@copilotkit/react-core 1.5.1-next.2 → 1.5.1-next.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-LNI2Z45S.mjs → chunk-2KCEHGSI.mjs} +50 -100
- package/dist/chunk-2KCEHGSI.mjs.map +1 -0
- package/dist/{chunk-2KT73RVG.mjs → chunk-6OR25P32.mjs} +19 -75
- package/dist/chunk-6OR25P32.mjs.map +1 -0
- package/dist/{chunk-3GQPEN4M.mjs → chunk-DDVXFNYA.mjs} +32 -66
- package/dist/chunk-DDVXFNYA.mjs.map +1 -0
- package/dist/{chunk-XOQMISG3.mjs → chunk-FXHKK52V.mjs} +13 -14
- package/dist/chunk-FXHKK52V.mjs.map +1 -0
- package/dist/{chunk-HIUT2NLX.mjs → chunk-H4VZMKR6.mjs} +2 -2
- package/dist/{chunk-X36DNILG.mjs → chunk-H7LSKIDK.mjs} +23 -71
- package/dist/chunk-H7LSKIDK.mjs.map +1 -0
- package/dist/chunk-JDQCJCAQ.mjs +295 -0
- package/dist/chunk-JDQCJCAQ.mjs.map +1 -0
- package/dist/chunk-L34MHAXR.mjs +1 -0
- package/dist/{chunk-WXREY7UP.mjs → chunk-LODRWFMB.mjs} +4 -16
- package/dist/chunk-LODRWFMB.mjs.map +1 -0
- package/dist/{chunk-EWKJMQOF.mjs → chunk-MWZO6TUR.mjs} +13 -29
- package/dist/chunk-MWZO6TUR.mjs.map +1 -0
- package/dist/{chunk-6BQVZFNO.mjs → chunk-ODN4H66E.mjs} +2 -6
- package/dist/chunk-ODN4H66E.mjs.map +1 -0
- package/dist/{chunk-FQ53HQYZ.mjs → chunk-QDGDXRRJ.mjs} +2 -2
- package/dist/{chunk-22XKTBPF.mjs → chunk-XINZBP3J.mjs} +3 -15
- package/dist/chunk-XINZBP3J.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.d.ts +0 -9
- package/dist/components/copilot-provider/copilotkit-props.d.ts +0 -21
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +0 -9
- package/dist/components/copilot-provider/copilotkit.js +95 -224
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +8 -9
- package/dist/components/copilot-provider/index.d.ts +0 -9
- package/dist/components/copilot-provider/index.js +95 -224
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +8 -9
- package/dist/components/index.d.ts +0 -9
- package/dist/components/index.js +95 -224
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +8 -9
- package/dist/components/toast/toast-provider.d.ts +1 -2
- package/dist/components/toast/toast-provider.js +63 -77
- package/dist/components/toast/toast-provider.js.map +1 -1
- package/dist/components/toast/toast-provider.mjs +1 -1
- package/dist/context/copilot-context.d.ts +4 -37
- package/dist/context/copilot-context.js +3 -15
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +3 -15
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +4 -4
- package/dist/hooks/index.d.ts +1 -3
- package/dist/hooks/index.js +297 -703
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +23 -35
- package/dist/hooks/use-chat.d.ts +3 -35
- package/dist/hooks/use-chat.js +205 -453
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +3 -4
- package/dist/hooks/use-coagent-state-render.d.ts +2 -2
- package/dist/hooks/use-coagent-state-render.js +8 -43
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +2 -4
- package/dist/hooks/use-coagent.d.ts +1 -14
- package/dist/hooks/use-coagent.js +265 -603
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +12 -20
- package/dist/hooks/use-copilot-action.d.ts +2 -12
- package/dist/hooks/use-copilot-action.js +19 -169
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +2 -4
- package/dist/hooks/use-copilot-chat.d.ts +0 -2
- package/dist/hooks/use-copilot-chat.js +240 -545
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +11 -13
- package/dist/hooks/use-copilot-readable.js +3 -15
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-copilot-runtime-client.js +4 -110
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
- package/dist/hooks/use-make-copilot-document-readable.js +3 -15
- 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 +3 -4
- package/dist/index.js +398 -812
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -43
- package/dist/lib/copilot-task.d.ts +1 -6
- package/dist/lib/copilot-task.js +17 -55
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +9 -11
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +17 -55
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +9 -11
- package/dist/types/frontend-action.d.ts +2 -21
- package/dist/types/frontend-action.js +0 -34
- package/dist/types/frontend-action.js.map +1 -1
- package/dist/types/frontend-action.mjs +0 -7
- package/dist/types/index.d.ts +1 -2
- package/dist/types/index.js.map +1 -1
- package/dist/utils/extract.d.ts +2 -3
- package/dist/utils/extract.js +3 -21
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +8 -9
- package/dist/utils/index.js +3 -21
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +9 -10
- package/package.json +5 -5
- package/dist/chunk-22XKTBPF.mjs.map +0 -1
- package/dist/chunk-2KT73RVG.mjs.map +0 -1
- package/dist/chunk-3GQPEN4M.mjs.map +0 -1
- package/dist/chunk-6BQVZFNO.mjs.map +0 -1
- package/dist/chunk-EWKJMQOF.mjs.map +0 -1
- package/dist/chunk-LHKIIAUQ.mjs +0 -59
- package/dist/chunk-LHKIIAUQ.mjs.map +0 -1
- package/dist/chunk-LNI2Z45S.mjs.map +0 -1
- package/dist/chunk-NR2BTA6Z.mjs +0 -1
- package/dist/chunk-VGOFRULA.mjs +0 -401
- package/dist/chunk-VGOFRULA.mjs.map +0 -1
- package/dist/chunk-VNTDIJSG.mjs +0 -37
- package/dist/chunk-VNTDIJSG.mjs.map +0 -1
- package/dist/chunk-WXREY7UP.mjs.map +0 -1
- package/dist/chunk-X36DNILG.mjs.map +0 -1
- package/dist/chunk-XERJQUHA.mjs +0 -31
- package/dist/chunk-XERJQUHA.mjs.map +0 -1
- package/dist/chunk-XOQMISG3.mjs.map +0 -1
- package/dist/components/error-boundary/error-boundary.d.ts +0 -22
- package/dist/components/error-boundary/error-boundary.js +0 -183
- package/dist/components/error-boundary/error-boundary.js.map +0 -1
- package/dist/components/error-boundary/error-boundary.mjs +0 -12
- package/dist/components/error-boundary/error-boundary.mjs.map +0 -1
- package/dist/components/error-boundary/error-utils.d.ts +0 -11
- package/dist/components/error-boundary/error-utils.js +0 -177
- package/dist/components/error-boundary/error-utils.js.map +0 -1
- package/dist/components/error-boundary/error-utils.mjs +0 -13
- package/dist/components/error-boundary/error-utils.mjs.map +0 -1
- package/dist/hooks/use-copilot-authenticated-action.d.ts +0 -8
- package/dist/hooks/use-copilot-authenticated-action.js +0 -418
- package/dist/hooks/use-copilot-authenticated-action.js.map +0 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +0 -12
- package/dist/hooks/use-copilot-authenticated-action.mjs.map +0 -1
- /package/dist/{chunk-HIUT2NLX.mjs.map → chunk-H4VZMKR6.mjs.map} +0 -0
- /package/dist/{chunk-NR2BTA6Z.mjs.map → chunk-L34MHAXR.mjs.map} +0 -0
- /package/dist/{chunk-FQ53HQYZ.mjs.map → chunk-QDGDXRRJ.mjs.map} +0 -0
|
@@ -51,22 +51,9 @@ var emptyCopilotContext = {
|
|
|
51
51
|
coagentStates: {},
|
|
52
52
|
setCoagentStates: () => {
|
|
53
53
|
},
|
|
54
|
-
coagentStatesRef: { current: {} },
|
|
55
|
-
setCoagentStatesWithRef: () => {
|
|
56
|
-
},
|
|
57
54
|
agentSession: null,
|
|
58
55
|
setAgentSession: () => {
|
|
59
|
-
}
|
|
60
|
-
forwardedParameters: {},
|
|
61
|
-
agentLock: null,
|
|
62
|
-
threadId: null,
|
|
63
|
-
setThreadId: () => {
|
|
64
|
-
},
|
|
65
|
-
runId: null,
|
|
66
|
-
setRunId: () => {
|
|
67
|
-
},
|
|
68
|
-
chatAbortControllerRef: { current: null },
|
|
69
|
-
availableAgents: []
|
|
56
|
+
}
|
|
70
57
|
};
|
|
71
58
|
var CopilotContext = React.createContext(emptyCopilotContext);
|
|
72
59
|
function useCopilotContext() {
|
|
@@ -76,12 +63,13 @@ function useCopilotContext() {
|
|
|
76
63
|
}
|
|
77
64
|
return context;
|
|
78
65
|
}
|
|
79
|
-
function returnAndThrowInDebug(
|
|
66
|
+
function returnAndThrowInDebug(value) {
|
|
80
67
|
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
68
|
+
return value;
|
|
81
69
|
}
|
|
82
70
|
|
|
83
71
|
export {
|
|
84
72
|
CopilotContext,
|
|
85
73
|
useCopilotContext
|
|
86
74
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
75
|
+
//# sourceMappingURL=chunk-LODRWFMB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context/copilot-context.tsx"],"sourcesContent":["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":";;;;;AAEA,OAAO,WAAW;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,MAAM,cAAoC,mBAAmB;AAEpF,SAAS,oBAA0C;AACxD,QAAM,UAAU,MAAM,WAAW,cAAc;AAC/C,MAAI,YAAY,qBAAqB;AACnC,UAAM,IAAI,MAAM,uEAAuE;AAAA,EACzF;AACA,SAAO;AACT;AAEA,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT;","names":[]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotContext
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
useAsyncCallback
|
|
6
|
-
} from "./chunk-LNI2Z45S.mjs";
|
|
3
|
+
} from "./chunk-LODRWFMB.mjs";
|
|
7
4
|
import {
|
|
8
5
|
__async,
|
|
9
6
|
__spreadValues
|
|
@@ -17,15 +14,11 @@ function useCopilotAction(action, dependencies) {
|
|
|
17
14
|
const idRef = useRef(randomId());
|
|
18
15
|
const renderAndWaitRef = useRef(null);
|
|
19
16
|
action = __spreadValues({}, action);
|
|
20
|
-
if (
|
|
21
|
-
// renderAndWaitForResponse is not available for catch all actions
|
|
22
|
-
isFrontendAction(action) && // check if renderAndWaitForResponse is set
|
|
23
|
-
(action.renderAndWait || action.renderAndWaitForResponse)
|
|
24
|
-
) {
|
|
17
|
+
if (action.renderAndWait || action.renderAndWaitForResponse) {
|
|
25
18
|
const renderAndWait = action.renderAndWait || action.renderAndWaitForResponse;
|
|
26
19
|
action.renderAndWait = void 0;
|
|
27
20
|
action.renderAndWaitForResponse = void 0;
|
|
28
|
-
action.handler =
|
|
21
|
+
action.handler = () => __async(this, null, function* () {
|
|
29
22
|
let resolve;
|
|
30
23
|
let reject;
|
|
31
24
|
const promise = new Promise((resolvePromise, rejectPromise) => {
|
|
@@ -34,18 +27,14 @@ function useCopilotAction(action, dependencies) {
|
|
|
34
27
|
});
|
|
35
28
|
renderAndWaitRef.current = { promise, resolve, reject };
|
|
36
29
|
return yield promise;
|
|
37
|
-
})
|
|
30
|
+
});
|
|
38
31
|
action.render = (props) => {
|
|
39
|
-
let status = props.status;
|
|
40
|
-
if (props.status === "executing" && !renderAndWaitRef.current) {
|
|
41
|
-
status = "inProgress";
|
|
42
|
-
}
|
|
43
32
|
const waitProps = {
|
|
44
|
-
status,
|
|
33
|
+
status: props.status,
|
|
45
34
|
args: props.args,
|
|
46
35
|
result: props.result,
|
|
47
|
-
handler: status === "executing" ? renderAndWaitRef.current.resolve : void 0,
|
|
48
|
-
respond: status === "executing" ? renderAndWaitRef.current.resolve : void 0
|
|
36
|
+
handler: props.status === "executing" ? renderAndWaitRef.current.resolve : void 0,
|
|
37
|
+
respond: props.status === "executing" ? renderAndWaitRef.current.resolve : void 0
|
|
49
38
|
};
|
|
50
39
|
const isNoArgsRenderWait = (_fn) => {
|
|
51
40
|
var _a;
|
|
@@ -63,9 +52,7 @@ function useCopilotAction(action, dependencies) {
|
|
|
63
52
|
}
|
|
64
53
|
if (dependencies === void 0) {
|
|
65
54
|
if (actions[idRef.current]) {
|
|
66
|
-
|
|
67
|
-
actions[idRef.current].handler = action.handler;
|
|
68
|
-
}
|
|
55
|
+
actions[idRef.current].handler = action.handler;
|
|
69
56
|
if (typeof action.render === "function") {
|
|
70
57
|
if (chatComponentsCache.current !== null) {
|
|
71
58
|
chatComponentsCache.current.actions[action.name] = action.render;
|
|
@@ -84,24 +71,21 @@ function useCopilotAction(action, dependencies) {
|
|
|
84
71
|
}, [
|
|
85
72
|
setAction,
|
|
86
73
|
removeAction,
|
|
87
|
-
|
|
74
|
+
action.description,
|
|
88
75
|
action.name,
|
|
89
|
-
|
|
90
|
-
|
|
76
|
+
action.disabled,
|
|
77
|
+
action.available,
|
|
91
78
|
// This should be faster than deep equality checking
|
|
92
79
|
// In addition, all major JS engines guarantee the order of object keys
|
|
93
|
-
JSON.stringify(
|
|
80
|
+
JSON.stringify(action.parameters),
|
|
94
81
|
// include render only if it's a string
|
|
95
82
|
typeof action.render === "string" ? action.render : void 0,
|
|
96
83
|
// dependencies set by the developer
|
|
97
84
|
...dependencies || []
|
|
98
85
|
]);
|
|
99
86
|
}
|
|
100
|
-
function isFrontendAction(action) {
|
|
101
|
-
return action.name !== "*";
|
|
102
|
-
}
|
|
103
87
|
|
|
104
88
|
export {
|
|
105
89
|
useCopilotAction
|
|
106
90
|
};
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
91
|
+
//# sourceMappingURL=chunk-MWZO6TUR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-copilot-action.ts"],"sourcesContent":["/**\n * Example usage of useCopilotAction with complex parameters:\n *\n * @example\n * useCopilotAction({\n * name: \"myAction\",\n * parameters: [\n * { name: \"arg1\", type: \"string\", enum: [\"option1\", \"option2\", \"option3\"], required: false },\n * { name: \"arg2\", type: \"number\" },\n * {\n * name: \"arg3\",\n * type: \"object\",\n * attributes: [\n * { name: \"nestedArg1\", type: \"boolean\" },\n * { name: \"xyz\", required: false },\n * ],\n * },\n * { name: \"arg4\", type: \"number[]\" },\n * ],\n * handler: ({ arg1, arg2, arg3, arg4 }) => {\n * const x = arg3.nestedArg1;\n * const z = arg3.xyz;\n * console.log(arg1, arg2, arg3);\n * },\n * });\n *\n * @example\n * // Simple action without parameters\n * useCopilotAction({\n * name: \"myAction\",\n * handler: () => {\n * console.log(\"No parameters provided.\");\n * },\n * });\n *\n * @example\n * // Interactive action with UI rendering and response handling\n * useCopilotAction({\n * name: \"handleMeeting\",\n * description: \"Handle a meeting by booking or canceling\",\n * parameters: [\n * {\n * name: \"meeting\",\n * type: \"string\",\n * description: \"The meeting to handle\",\n * required: true,\n * },\n * {\n * name: \"date\",\n * type: \"string\",\n * description: \"The date of the meeting\",\n * required: true,\n * },\n * {\n * name: \"title\",\n * type: \"string\",\n * description: \"The title of the meeting\",\n * required: true,\n * },\n * ],\n * renderAndWaitForResponse: ({ args, respond, status }) => {\n * const { meeting, date, title } = args;\n * return (\n * <MeetingConfirmationDialog\n * meeting={meeting}\n * date={date}\n * title={title}\n * onConfirm={() => respond('meeting confirmed')}\n * onCancel={() => respond('meeting canceled')}\n * />\n * );\n * },\n * });\n */\n\n/**\n * <img src=\"/images/use-copilot-action/useCopilotAction.gif\" width=\"500\" />\n * `useCopilotAction` is a React hook that you can use in your application to provide\n * custom actions that can be called by the AI. Essentially, it allows the Copilot to\n * execute these actions contextually during a chat, based on the user's interactions\n * and needs.\n *\n * Here's how it works:\n *\n * Use `useCopilotAction` to set up actions that the Copilot can call. To provide\n * more context to the Copilot, you can provide it with a `description` (for example to explain\n * what the action does, under which conditions it can be called, etc.).\n *\n * Then you define the parameters of the action, which can be simple, e.g. primitives like strings or numbers,\n * or complex, e.g. objects or arrays.\n *\n * Finally, you provide a `handler` function that receives the parameters and returns a result.\n * CopilotKit takes care of automatically inferring the parameter types, so you get type safety\n * and autocompletion for free.\n *\n * To render a custom UI for the action, you can provide a `render()` function. This function\n * lets you render a custom component or return a string to display.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * ```tsx\n * useCopilotAction({\n * name: \"sayHello\",\n * description: \"Say hello to someone.\",\n * parameters: [\n * {\n * name: \"name\",\n * type: \"string\",\n * description: \"name of the person to say greet\",\n * },\n * ],\n * handler: async ({ name }) => {\n * alert(`Hello, ${name}!`);\n * },\n * });\n * ```\n *\n * ## Generative UI\n *\n * This hooks enables you to dynamically generate UI elements and render them in the copilot chat. For more information, check out the [Generative UI](/guides/generative-ui) page.\n */\nimport { Parameter, randomId } from \"@copilotkit/shared\";\nimport { createElement, Fragment, useEffect, useRef } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport {\n ActionRenderProps,\n ActionRenderPropsNoArgsWait,\n ActionRenderPropsWait,\n FrontendAction,\n} from \"../types/frontend-action\";\n\n// We implement useCopilotAction dependency handling so that\n// the developer has the option to not provide any dependencies.\n// In this case, we assume they want to update the handler on each rerender.\n// To avoid getting stuck in an infinite loop, we update the handler directly,\n// skipping React state updates.\n// This is ok in this case, because the handler is not part of any UI that\n// needs to be updated.\n// useCallback, useMemo or other memoization techniques are not suitable here,\n// because they will cause a infinite rerender loop.\nexport function useCopilotAction<const T extends Parameter[] | [] = []>(\n action: FrontendAction<T>,\n dependencies?: any[],\n): void {\n const { setAction, removeAction, actions, chatComponentsCache } = useCopilotContext();\n const idRef = useRef<string>(randomId());\n const renderAndWaitRef = useRef<RenderAndWaitForResponse | null>(null);\n\n // clone the action to avoid mutating the original object\n action = { ...action };\n\n // If the developer provides a renderAndWait function, we transform the action\n // to use a promise internally, so that we can treat it like a normal action.\n if (action.renderAndWait || action.renderAndWaitForResponse) {\n const renderAndWait = action.renderAndWait || action.renderAndWaitForResponse;\n // remove the renderAndWait function from the action\n action.renderAndWait = undefined;\n action.renderAndWaitForResponse = undefined;\n // add a handler that will be called when the action is executed\n action.handler = (async () => {\n // we create a new promise when the handler is called\n let resolve: (result: any) => void;\n let reject: (error: any) => void;\n const promise = new Promise<any>((resolvePromise, rejectPromise) => {\n resolve = resolvePromise;\n reject = rejectPromise;\n });\n renderAndWaitRef.current = { promise, resolve: resolve!, reject: reject! };\n // then we await the promise (it will be resolved in the original renderAndWait function)\n return await promise;\n }) as any;\n\n // add a render function that will be called when the action is rendered\n action.render = ((props: ActionRenderProps<T>): React.ReactElement => {\n // Create type safe waitProps based on whether T extends empty array or not\n const waitProps = {\n status: props.status,\n args: props.args,\n result: props.result,\n handler: props.status === \"executing\" ? renderAndWaitRef.current!.resolve : undefined,\n respond: props.status === \"executing\" ? renderAndWaitRef.current!.resolve : undefined,\n } as T extends [] ? ActionRenderPropsNoArgsWait<T> : ActionRenderPropsWait<T>;\n\n // Type guard to check if renderAndWait is for no args case\n const isNoArgsRenderWait = (\n _fn:\n | ((props: ActionRenderPropsNoArgsWait<T>) => React.ReactElement)\n | ((props: ActionRenderPropsWait<T>) => React.ReactElement),\n ): _fn is (props: ActionRenderPropsNoArgsWait<T>) => React.ReactElement => {\n return action.parameters?.length === 0;\n };\n\n // Safely call renderAndWait with correct props type\n if (renderAndWait) {\n if (isNoArgsRenderWait(renderAndWait)) {\n return renderAndWait(waitProps as ActionRenderPropsNoArgsWait<T>);\n } else {\n return renderAndWait(waitProps as ActionRenderPropsWait<T>);\n }\n }\n\n // Return empty Fragment instead of null\n return createElement(Fragment);\n }) as any;\n }\n\n // If the developer doesn't provide dependencies, we assume they want to\n // update handler and render function when the action object changes.\n // This ensures that any captured variables in the handler are up to date.\n if (dependencies === undefined) {\n if (actions[idRef.current]) {\n actions[idRef.current].handler = action.handler as any;\n if (typeof action.render === \"function\") {\n if (chatComponentsCache.current !== null) {\n chatComponentsCache.current.actions[action.name] = action.render;\n }\n }\n }\n }\n\n useEffect(() => {\n setAction(idRef.current, action as any);\n if (chatComponentsCache.current !== null && action.render !== undefined) {\n chatComponentsCache.current.actions[action.name] = action.render;\n }\n return () => {\n // NOTE: For now, we don't remove the chatComponentsCache entry when the action is removed.\n // This is because we currently don't have access to the messages array in CopilotContext.\n removeAction(idRef.current);\n };\n }, [\n setAction,\n removeAction,\n action.description,\n action.name,\n action.disabled,\n action.available,\n // This should be faster than deep equality checking\n // In addition, all major JS engines guarantee the order of object keys\n JSON.stringify(action.parameters),\n // include render only if it's a string\n typeof action.render === \"string\" ? action.render : undefined,\n // dependencies set by the developer\n ...(dependencies || []),\n ]);\n}\n\ninterface RenderAndWaitForResponse {\n promise: Promise<any>;\n resolve: (result: any) => void;\n reject: (error: any) => void;\n}\n"],"mappings":";;;;;;;;;AA2HA,SAAoB,gBAAgB;AACpC,SAAS,eAAe,UAAU,WAAW,cAAc;AAkBpD,SAAS,iBACd,QACA,cACM;AACN,QAAM,EAAE,WAAW,cAAc,SAAS,oBAAoB,IAAI,kBAAkB;AACpF,QAAM,QAAQ,OAAe,SAAS,CAAC;AACvC,QAAM,mBAAmB,OAAwC,IAAI;AAGrE,WAAS,mBAAK;AAId,MAAI,OAAO,iBAAiB,OAAO,0BAA0B;AAC3D,UAAM,gBAAgB,OAAO,iBAAiB,OAAO;AAErD,WAAO,gBAAgB;AACvB,WAAO,2BAA2B;AAElC,WAAO,UAAW,MAAY;AAE5B,UAAI;AACJ,UAAI;AACJ,YAAM,UAAU,IAAI,QAAa,CAAC,gBAAgB,kBAAkB;AAClE,kBAAU;AACV,iBAAS;AAAA,MACX,CAAC;AACD,uBAAiB,UAAU,EAAE,SAAS,SAAmB,OAAgB;AAEzE,aAAO,MAAM;AAAA,IACf;AAGA,WAAO,SAAU,CAAC,UAAoD;AAEpE,YAAM,YAAY;AAAA,QAChB,QAAQ,MAAM;AAAA,QACd,MAAM,MAAM;AAAA,QACZ,QAAQ,MAAM;AAAA,QACd,SAAS,MAAM,WAAW,cAAc,iBAAiB,QAAS,UAAU;AAAA,QAC5E,SAAS,MAAM,WAAW,cAAc,iBAAiB,QAAS,UAAU;AAAA,MAC9E;AAGA,YAAM,qBAAqB,CACzB,QAGyE;AA9LjF;AA+LQ,iBAAO,YAAO,eAAP,mBAAmB,YAAW;AAAA,MACvC;AAGA,UAAI,eAAe;AACjB,YAAI,mBAAmB,aAAa,GAAG;AACrC,iBAAO,cAAc,SAA2C;AAAA,QAClE,OAAO;AACL,iBAAO,cAAc,SAAqC;AAAA,QAC5D;AAAA,MACF;AAGA,aAAO,cAAc,QAAQ;AAAA,IAC/B;AAAA,EACF;AAKA,MAAI,iBAAiB,QAAW;AAC9B,QAAI,QAAQ,MAAM,OAAO,GAAG;AAC1B,cAAQ,MAAM,OAAO,EAAE,UAAU,OAAO;AACxC,UAAI,OAAO,OAAO,WAAW,YAAY;AACvC,YAAI,oBAAoB,YAAY,MAAM;AACxC,8BAAoB,QAAQ,QAAQ,OAAO,IAAI,IAAI,OAAO;AAAA,QAC5D;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,YAAU,MAAM;AACd,cAAU,MAAM,SAAS,MAAa;AACtC,QAAI,oBAAoB,YAAY,QAAQ,OAAO,WAAW,QAAW;AACvE,0BAAoB,QAAQ,QAAQ,OAAO,IAAI,IAAI,OAAO;AAAA,IAC5D;AACA,WAAO,MAAM;AAGX,mBAAa,MAAM,OAAO;AAAA,IAC5B;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA;AAAA;AAAA,IAGP,KAAK,UAAU,OAAO,UAAU;AAAA;AAAA,IAEhC,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS;AAAA;AAAA,IAEpD,GAAI,gBAAgB,CAAC;AAAA,EACvB,CAAC;AACH;","names":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
useErrorToast,
|
|
3
2
|
useToast
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2KCEHGSI.mjs";
|
|
5
4
|
import {
|
|
6
5
|
__spreadProps,
|
|
7
6
|
__spreadValues
|
|
@@ -14,14 +13,11 @@ import {
|
|
|
14
13
|
import { useMemo } from "react";
|
|
15
14
|
var useCopilotRuntimeClient = (options) => {
|
|
16
15
|
const { addGraphQLErrorsToast } = useToast();
|
|
17
|
-
const addErrorToast = useErrorToast();
|
|
18
16
|
const runtimeClient = useMemo(() => {
|
|
19
17
|
return new CopilotRuntimeClient(__spreadProps(__spreadValues({}, options), {
|
|
20
18
|
handleGQLErrors: (error) => {
|
|
21
19
|
if (error.graphQLErrors.length) {
|
|
22
20
|
addGraphQLErrorsToast(error.graphQLErrors);
|
|
23
|
-
} else {
|
|
24
|
-
addErrorToast([error]);
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
}));
|
|
@@ -32,4 +28,4 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
32
28
|
export {
|
|
33
29
|
useCopilotRuntimeClient
|
|
34
30
|
};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
31
|
+
//# sourceMappingURL=chunk-ODN4H66E.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-copilot-runtime-client.ts"],"sourcesContent":["import {\n CopilotRuntimeClient,\n CopilotRuntimeClientOptions,\n GraphQLError,\n} from \"@copilotkit/runtime-client-gql\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { useMemo } from \"react\";\n\nexport const useCopilotRuntimeClient = (options: CopilotRuntimeClientOptions) => {\n const { addGraphQLErrorsToast } = useToast();\n\n const runtimeClient = useMemo(() => {\n return new CopilotRuntimeClient({\n ...options,\n handleGQLErrors: (error) => {\n if ((error as any).graphQLErrors.length) {\n addGraphQLErrorsToast((error as any).graphQLErrors as GraphQLError[]);\n }\n },\n });\n }, [options, addGraphQLErrorsToast]);\n\n return runtimeClient;\n};\n"],"mappings":";;;;;;;;;AAAA;AAAA,EACE;AAAA,OAGK;AAEP,SAAS,eAAe;AAEjB,IAAM,0BAA0B,CAAC,YAAyC;AAC/E,QAAM,EAAE,sBAAsB,IAAI,SAAS;AAE3C,QAAM,gBAAgB,QAAQ,MAAM;AAClC,WAAO,IAAI,qBAAqB,iCAC3B,UAD2B;AAAA,MAE9B,iBAAiB,CAAC,UAAU;AAC1B,YAAK,MAAc,cAAc,QAAQ;AACvC,gCAAuB,MAAc,aAA+B;AAAA,QACtE;AAAA,MACF;AAAA,IACF,EAAC;AAAA,EACH,GAAG,CAAC,SAAS,qBAAqB,CAAC;AAEnC,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LODRWFMB.mjs";
|
|
4
4
|
|
|
5
5
|
// src/hooks/use-copilot-readable.ts
|
|
6
6
|
import { useEffect, useRef } from "react";
|
|
@@ -25,4 +25,4 @@ function useCopilotReadable({ description, value, parentId, categories, convert
|
|
|
25
25
|
export {
|
|
26
26
|
useCopilotReadable
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-QDGDXRRJ.mjs.map
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotContext
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
useToast
|
|
6
|
-
} from "./chunk-LNI2Z45S.mjs";
|
|
3
|
+
} from "./chunk-LODRWFMB.mjs";
|
|
7
4
|
|
|
8
5
|
// src/hooks/use-coagent-state-render.ts
|
|
9
6
|
import { useRef, useContext, useEffect } from "react";
|
|
@@ -13,18 +10,9 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
13
10
|
setCoAgentStateRender,
|
|
14
11
|
removeCoAgentStateRender,
|
|
15
12
|
coAgentStateRenders,
|
|
16
|
-
chatComponentsCache
|
|
17
|
-
availableAgents
|
|
13
|
+
chatComponentsCache
|
|
18
14
|
} = useContext(CopilotContext);
|
|
19
15
|
const idRef = useRef(randomId());
|
|
20
|
-
const { addToast } = useToast();
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === action.name)) {
|
|
23
|
-
const message = `(useCoAgentStateRender): Agent "${action.name}" not found. Make sure the agent exists and is properly configured.`;
|
|
24
|
-
console.warn(message);
|
|
25
|
-
addToast({ type: "warning", message });
|
|
26
|
-
}
|
|
27
|
-
}, [availableAgents]);
|
|
28
16
|
const key = `${action.name}-${action.nodeName || "global"}`;
|
|
29
17
|
if (dependencies === void 0) {
|
|
30
18
|
if (coAgentStateRenders[idRef.current]) {
|
|
@@ -58,4 +46,4 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
58
46
|
export {
|
|
59
47
|
useCoAgentStateRender
|
|
60
48
|
};
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-XINZBP3J.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-coagent-state-render.ts"],"sourcesContent":["/**\n * <Callout type=\"info\">\n * Usage of this hook assumes some additional setup in your application, for more information\n * on that see the CoAgents <span className=\"text-blue-500\">[Agentic Generative UI documentation](/coagents/chat-ui/render-agent-state)</span>.\n * </Callout>\n *\n * The useCoAgentStateRender hook allows you to render UI components or text based on a Agentic Copilot's state.\n * This is particularly useful for showing intermediate state or progress during Agentic Copilot operations.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCoagentStateRender } from \"@copilotkit/react-core\";\n *\n * type YourAgentState = {\n * agent_state_property: string;\n * }\n *\n * useCoagentStateRender<YourAgentState>({\n * name: \"basic_agent\",\n * nodeName: \"optionally_specify_a_specific_node\",\n * render: ({ status, state, nodeName }) => {\n * return (\n * <YourComponent\n * agentStateProperty={state.agent_state_property}\n * status={status}\n * nodeName={nodeName}\n * />\n * );\n * },\n * });\n * ```\n *\n * This allows for you to render UI components or text based on what is happening within the agent.\n *\n * ### Example\n * A great example of this is in our Perplexity Clone where we render the progress of an agent's internet search as it is happening.\n * You can play around with it below or learn how to build it with its [demo](/coagents/videos/perplexity-clone).\n *\n * <Callout type=\"info\">\n * This example is hosted on Vercel and may take a few seconds to load.\n * </Callout>\n *\n * <iframe src=\"https://examples-coagents-ai-researcher-ui.vercel.app/\" className=\"w-full rounded-lg border h-[700px] my-4\" />\n */\n\nimport { useRef, useContext, useEffect } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { randomId } from \"@copilotkit/shared\";\nimport { CoAgentStateRender } from \"../types/coagent-action\";\n\n/**\n * This hook is used to render agent state with custom UI components or text. This is particularly\n * useful for showing intermediate state or progress during Agentic Copilot operations.\n * To get started using rendering intermediate state through this hook, checkout the documentation.\n *\n * https://docs.copilotkit.ai/coagents/chat-ui/render-agent-state.\n */\n\n// We implement useCoAgentStateRender dependency handling so that\n// the developer has the option to not provide any dependencies.\n// see useCopilotAction for more details about this approach.\nexport function useCoAgentStateRender<T = any>(\n action: CoAgentStateRender<T>,\n dependencies?: any[],\n): void {\n const {\n setCoAgentStateRender,\n removeCoAgentStateRender,\n coAgentStateRenders,\n chatComponentsCache,\n } = useContext(CopilotContext);\n const idRef = useRef<string>(randomId());\n\n const key = `${action.name}-${action.nodeName || \"global\"}`;\n\n if (dependencies === undefined) {\n if (coAgentStateRenders[idRef.current]) {\n coAgentStateRenders[idRef.current].handler = action.handler as any;\n if (typeof action.render === \"function\") {\n if (chatComponentsCache.current !== null) {\n chatComponentsCache.current.coAgentStateRenders[key] = action.render;\n }\n }\n }\n }\n\n useEffect(() => {\n setCoAgentStateRender(idRef.current, action as any);\n if (chatComponentsCache.current !== null && action.render !== undefined) {\n chatComponentsCache.current.coAgentStateRenders[key] = action.render;\n }\n return () => {\n removeCoAgentStateRender(idRef.current);\n };\n }, [\n setCoAgentStateRender,\n removeCoAgentStateRender,\n action.name,\n // include render only if it's a string\n typeof action.render === \"string\" ? action.render : undefined,\n // dependencies set by the developer\n ...(dependencies || []),\n ]);\n}\n"],"mappings":";;;;;AAgDA,SAAS,QAAQ,YAAY,iBAAiB;AAE9C,SAAS,gBAAgB;AAclB,SAAS,sBACd,QACA,cACM;AACN,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,cAAc;AAC7B,QAAM,QAAQ,OAAe,SAAS,CAAC;AAEvC,QAAM,MAAM,GAAG,OAAO,QAAQ,OAAO,YAAY;AAEjD,MAAI,iBAAiB,QAAW;AAC9B,QAAI,oBAAoB,MAAM,OAAO,GAAG;AACtC,0BAAoB,MAAM,OAAO,EAAE,UAAU,OAAO;AACpD,UAAI,OAAO,OAAO,WAAW,YAAY;AACvC,YAAI,oBAAoB,YAAY,MAAM;AACxC,8BAAoB,QAAQ,oBAAoB,GAAG,IAAI,OAAO;AAAA,QAChE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,YAAU,MAAM;AACd,0BAAsB,MAAM,SAAS,MAAa;AAClD,QAAI,oBAAoB,YAAY,QAAQ,OAAO,WAAW,QAAW;AACvE,0BAAoB,QAAQ,oBAAoB,GAAG,IAAI,OAAO;AAAA,IAChE;AACA,WAAO,MAAM;AACX,+BAAyB,MAAM,OAAO;AAAA,IACxC;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA,OAAO;AAAA;AAAA,IAEP,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS;AAAA;AAAA,IAEpD,GAAI,gBAAgB,CAAC;AAAA,EACvB,CAAC;AACH;","names":[]}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { CopilotKitProps } from './copilotkit-props.js';
|
|
3
|
-
import '@copilotkit/runtime-client-gql';
|
|
4
3
|
import 'react';
|
|
5
|
-
import '../../context/copilot-context.js';
|
|
6
|
-
import '@copilotkit/shared';
|
|
7
|
-
import '../../types/frontend-action.js';
|
|
8
|
-
import '../../hooks/use-tree.js';
|
|
9
|
-
import '../../types/document-pointer.js';
|
|
10
|
-
import '../../types/chat-suggestion-configuration.js';
|
|
11
|
-
import '../../types/coagent-action.js';
|
|
12
|
-
import '../../types/coagent-state.js';
|
|
13
4
|
|
|
14
5
|
declare function CopilotMessages({ children, ...props }: CopilotKitProps): react_jsx_runtime.JSX.Element;
|
|
15
6
|
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { ForwardedParametersInput } from '@copilotkit/runtime-client-gql';
|
|
2
1
|
import { ReactNode } from 'react';
|
|
3
|
-
import { AuthState } from '../../context/copilot-context.js';
|
|
4
|
-
import '@copilotkit/shared';
|
|
5
|
-
import '../../types/frontend-action.js';
|
|
6
|
-
import '../../hooks/use-tree.js';
|
|
7
|
-
import '../../types/document-pointer.js';
|
|
8
|
-
import '../../types/chat-suggestion-configuration.js';
|
|
9
|
-
import '../../types/coagent-action.js';
|
|
10
|
-
import '../../types/coagent-state.js';
|
|
11
2
|
|
|
12
3
|
/**
|
|
13
4
|
* Props for CopilotKit.
|
|
@@ -76,18 +67,6 @@ interface CopilotKitProps {
|
|
|
76
67
|
* The name of the agent to use.
|
|
77
68
|
*/
|
|
78
69
|
agent?: string;
|
|
79
|
-
/**
|
|
80
|
-
* The forwarded parameters to use for the task.
|
|
81
|
-
*/
|
|
82
|
-
forwardedParameters?: Pick<ForwardedParametersInput, "temperature">;
|
|
83
|
-
/**
|
|
84
|
-
* The auth config to use for the CopilotKit.
|
|
85
|
-
*/
|
|
86
|
-
authConfig?: {
|
|
87
|
-
SignInComponent: React.ComponentType<{
|
|
88
|
-
onSignInComplete: (authState: AuthState) => void;
|
|
89
|
-
}>;
|
|
90
|
-
};
|
|
91
70
|
}
|
|
92
71
|
|
|
93
72
|
export { CopilotKitProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/copilot-provider/copilotkit-props.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/copilot-provider/copilotkit-props.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\n\n/**\n * Props for CopilotKit.\n */\n\nexport interface CopilotKitProps {\n /**\n * Your Copilot Cloud API key. Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free.\n */\n publicApiKey?: string;\n\n /**\n * Restrict input to a specific topic.\n */\n cloudRestrictToTopic?: {\n validTopics?: string[];\n invalidTopics?: string[];\n };\n\n /**\n * The endpoint for the Copilot Runtime instance. [Click here for more information](/concepts/copilot-runtime).\n */\n runtimeUrl?: 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 *\n * For example:\n * ```json\n * {\n * \"Authorization\": \"Bearer X\"\n * }\n * ```\n */\n headers?: Record<string, string>;\n\n /**\n * The children to be rendered within the CopilotKit.\n */\n children: ReactNode;\n\n /**\n * Custom properties to be sent with the request\n * For example:\n * ```js\n * {\n * 'user_id': 'users_id',\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n\n /**\n * Whether to show the dev console.\n *\n * If set to \"auto\", the dev console will be show on localhost only.\n */\n showDevConsole?: boolean | \"auto\";\n\n /**\n * The name of the agent to use.\n */\n agent?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { CopilotKitProps } from './copilotkit-props.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import '@copilotkit/runtime-client-gql';
|
|
4
3
|
import 'react';
|
|
5
|
-
import '../../context/copilot-context.js';
|
|
6
|
-
import '@copilotkit/shared';
|
|
7
|
-
import '../../types/frontend-action.js';
|
|
8
|
-
import '../../hooks/use-tree.js';
|
|
9
|
-
import '../../types/document-pointer.js';
|
|
10
|
-
import '../../types/chat-suggestion-configuration.js';
|
|
11
|
-
import '../../types/coagent-action.js';
|
|
12
|
-
import '../../types/coagent-state.js';
|
|
13
4
|
|
|
14
5
|
declare function CopilotKit({ children, ...props }: CopilotKitProps): react_jsx_runtime.JSX.Element;
|
|
15
6
|
declare function CopilotKitInternal({ children, ...props }: CopilotKitProps): react_jsx_runtime.JSX.Element;
|