@copilotkit/react-core 1.6.0-next.10 → 1.6.0-next.11
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 +8 -0
- package/dist/{chunk-XERJQUHA.mjs → chunk-4CEQJ2X6.mjs} +2 -2
- package/dist/{chunk-XERJQUHA.mjs.map → chunk-4CEQJ2X6.mjs.map} +1 -1
- package/dist/{chunk-ADTDNMYG.mjs → chunk-4EC4JK7H.mjs} +2 -2
- package/dist/{chunk-ALW2T2LL.mjs → chunk-FUO5LKSJ.mjs} +114 -60
- package/dist/chunk-FUO5LKSJ.mjs.map +1 -0
- package/dist/{chunk-MPFP6ANM.mjs → chunk-HBCP2KNA.mjs} +2 -2
- package/dist/{chunk-QJPWWVJQ.mjs → chunk-T4CAQC6B.mjs} +2 -2
- package/dist/{chunk-JFCNSGNU.mjs → chunk-Y2T56VSE.mjs} +2 -2
- package/dist/hooks/index.js +128 -77
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +5 -5
- package/dist/hooks/use-chat.js +113 -62
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +2 -2
- package/dist/hooks/use-coagent.js +119 -68
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +4 -4
- package/dist/hooks/use-copilot-chat.js +117 -66
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +3 -3
- package/dist/hooks/use-langgraph-interrupt.js +119 -68
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +4 -4
- package/dist/index.js +134 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/lib/copilot-task.js +1 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +2 -2
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +2 -2
- package/dist/types/frontend-action.d.ts +2 -1
- package/dist/types/frontend-action.js +1 -1
- package/dist/types/frontend-action.js.map +1 -1
- package/dist/types/frontend-action.mjs +1 -1
- package/package.json +3 -3
- package/src/hooks/use-chat.ts +133 -58
- package/src/types/frontend-action.ts +5 -2
- package/dist/chunk-ALW2T2LL.mjs.map +0 -1
- /package/dist/{chunk-ADTDNMYG.mjs.map → chunk-4EC4JK7H.mjs.map} +0 -0
- /package/dist/{chunk-MPFP6ANM.mjs.map → chunk-HBCP2KNA.mjs.map} +0 -0
- /package/dist/{chunk-QJPWWVJQ.mjs.map → chunk-T4CAQC6B.mjs.map} +0 -0
- /package/dist/{chunk-JFCNSGNU.mjs.map → chunk-Y2T56VSE.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1557,7 +1557,7 @@ function validateProps(props) {
|
|
|
1557
1557
|
|
|
1558
1558
|
// src/hooks/use-copilot-chat.ts
|
|
1559
1559
|
var import_react12 = require("react");
|
|
1560
|
-
var
|
|
1560
|
+
var import_runtime_client_gql7 = require("@copilotkit/runtime-client-gql");
|
|
1561
1561
|
|
|
1562
1562
|
// src/hooks/use-chat.ts
|
|
1563
1563
|
var import_react11 = require("react");
|
|
@@ -1569,7 +1569,7 @@ var import_runtime_client_gql5 = require("@copilotkit/runtime-client-gql");
|
|
|
1569
1569
|
var import_shared9 = require("@copilotkit/shared");
|
|
1570
1570
|
function processActionsForRuntimeRequest(actions) {
|
|
1571
1571
|
const filteredActions = actions.filter(
|
|
1572
|
-
(action) => action.available !== import_runtime_client_gql5.ActionInputAvailability.Disabled && action.disabled !== true && action.name !== "*"
|
|
1572
|
+
(action) => action.available !== import_runtime_client_gql5.ActionInputAvailability.Disabled && action.disabled !== true && action.name !== "*" && action.available != "frontend" && !action.pairedAction
|
|
1573
1573
|
).map((action) => {
|
|
1574
1574
|
let available = import_runtime_client_gql5.ActionInputAvailability.Enabled;
|
|
1575
1575
|
if (action.disabled) {
|
|
@@ -1590,8 +1590,6 @@ function processActionsForRuntimeRequest(actions) {
|
|
|
1590
1590
|
}
|
|
1591
1591
|
|
|
1592
1592
|
// src/hooks/use-chat.ts
|
|
1593
|
-
var import_runtime_client_gql7 = require("@copilotkit/runtime-client-gql");
|
|
1594
|
-
var import_shared11 = require("@copilotkit/shared");
|
|
1595
1593
|
function useChat(options) {
|
|
1596
1594
|
const {
|
|
1597
1595
|
messages,
|
|
@@ -1640,7 +1638,7 @@ function useChat(options) {
|
|
|
1640
1638
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1641
1639
|
setIsLoading(true);
|
|
1642
1640
|
const interruptEvent = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event;
|
|
1643
|
-
if ((interruptEvent == null ? void 0 : interruptEvent.name) ===
|
|
1641
|
+
if ((interruptEvent == null ? void 0 : interruptEvent.name) === import_runtime_client_gql6.MetaEventName.LangGraphInterruptEvent && (interruptEvent == null ? void 0 : interruptEvent.value) && !(interruptEvent == null ? void 0 : interruptEvent.response) && agentSessionRef.current) {
|
|
1644
1642
|
addErrorToast([
|
|
1645
1643
|
new Error(
|
|
1646
1644
|
"A message was sent while interrupt is active. This will cause failure on the agent side"
|
|
@@ -1734,16 +1732,16 @@ function useChat(options) {
|
|
|
1734
1732
|
setExtensions(extensionsRef.current);
|
|
1735
1733
|
let rawMessagesResponse = value.generateCopilotResponse.messages;
|
|
1736
1734
|
((_i = (_h = value.generateCopilotResponse) == null ? void 0 : _h.metaEvents) != null ? _i : []).forEach((ev) => {
|
|
1737
|
-
if (ev.name ===
|
|
1735
|
+
if (ev.name === import_runtime_client_gql6.MetaEventName.LangGraphInterruptEvent) {
|
|
1738
1736
|
let eventValue = (0, import_runtime_client_gql6.langGraphInterruptEvent)(ev).value;
|
|
1739
|
-
eventValue = (0,
|
|
1737
|
+
eventValue = (0, import_shared10.parseJson)(eventValue, eventValue);
|
|
1740
1738
|
setLangGraphInterruptAction({
|
|
1741
1739
|
event: __spreadProps(__spreadValues({}, (0, import_runtime_client_gql6.langGraphInterruptEvent)(ev)), {
|
|
1742
1740
|
value: eventValue
|
|
1743
1741
|
})
|
|
1744
1742
|
});
|
|
1745
1743
|
}
|
|
1746
|
-
if (ev.name ===
|
|
1744
|
+
if (ev.name === import_runtime_client_gql6.MetaEventName.CopilotKitLangGraphInterruptEvent) {
|
|
1747
1745
|
const data = ev.data;
|
|
1748
1746
|
rawMessagesResponse = [...rawMessagesResponse, ...data.messages];
|
|
1749
1747
|
interruptMessages = (0, import_runtime_client_gql6.convertGqlOutputToMessages)(
|
|
@@ -1824,7 +1822,7 @@ function useChat(options) {
|
|
|
1824
1822
|
setMessages([...previousMessages, ...newMessages]);
|
|
1825
1823
|
}
|
|
1826
1824
|
}
|
|
1827
|
-
|
|
1825
|
+
let finalMessages = constructFinalMessages(
|
|
1828
1826
|
[...syncedMessages, ...interruptMessages],
|
|
1829
1827
|
previousMessages,
|
|
1830
1828
|
newMessages
|
|
@@ -1834,7 +1832,7 @@ function useChat(options) {
|
|
|
1834
1832
|
const lastMessages = [];
|
|
1835
1833
|
for (let i = finalMessages.length - 1; i >= 0; i--) {
|
|
1836
1834
|
const message = finalMessages[i];
|
|
1837
|
-
if (message.isActionExecutionMessage() && message.status.code !== import_runtime_client_gql6.MessageStatusCode.Pending) {
|
|
1835
|
+
if ((message.isActionExecutionMessage() || message.isResultMessage()) && message.status.code !== import_runtime_client_gql6.MessageStatusCode.Pending) {
|
|
1838
1836
|
lastMessages.unshift(message);
|
|
1839
1837
|
} else {
|
|
1840
1838
|
break;
|
|
@@ -1842,59 +1840,51 @@ function useChat(options) {
|
|
|
1842
1840
|
}
|
|
1843
1841
|
for (const message of lastMessages) {
|
|
1844
1842
|
setMessages(finalMessages);
|
|
1845
|
-
const action = actions.find(
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
"abort",
|
|
1862
|
-
() => resolve("Operation was aborted by the user")
|
|
1863
|
-
);
|
|
1864
|
-
}
|
|
1865
|
-
),
|
|
1866
|
-
// if the user stopped generation, we also abort consecutive actions
|
|
1867
|
-
new Promise((resolve) => {
|
|
1868
|
-
var _a2;
|
|
1869
|
-
if ((_a2 = chatAbortControllerRef.current) == null ? void 0 : _a2.signal.aborted) {
|
|
1870
|
-
resolve("Operation was aborted by the user");
|
|
1871
|
-
}
|
|
1872
|
-
})
|
|
1873
|
-
]);
|
|
1874
|
-
} catch (e) {
|
|
1875
|
-
error = e;
|
|
1876
|
-
addErrorToast([error]);
|
|
1877
|
-
result = `Failed to execute action ${message.name}. ${error.message}`;
|
|
1878
|
-
console.error(`Failed to execute action ${message.name}: ${error}`);
|
|
1879
|
-
}
|
|
1843
|
+
const action = actions.find(
|
|
1844
|
+
(action2) => action2.name === message.name
|
|
1845
|
+
);
|
|
1846
|
+
const currentResultMessagePairedFeAction = message.isResultMessage() ? getPairedFeAction(actions, message) : null;
|
|
1847
|
+
const executeActionFromMessage = (action2, message2) => __async(this, null, function* () {
|
|
1848
|
+
followUp = action2 == null ? void 0 : action2.followUp;
|
|
1849
|
+
const resultMessage = yield executeAction({
|
|
1850
|
+
onFunctionCall,
|
|
1851
|
+
previousMessages,
|
|
1852
|
+
message: message2,
|
|
1853
|
+
chatAbortControllerRef,
|
|
1854
|
+
onError: (error) => {
|
|
1855
|
+
addErrorToast([error]);
|
|
1856
|
+
console.error(`Failed to execute action ${message2.name}: ${error}`);
|
|
1857
|
+
}
|
|
1858
|
+
});
|
|
1880
1859
|
didExecuteAction = true;
|
|
1881
|
-
const messageIndex = finalMessages.findIndex((msg) => msg.id ===
|
|
1882
|
-
finalMessages.splice(
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1860
|
+
const messageIndex = finalMessages.findIndex((msg) => msg.id === message2.id);
|
|
1861
|
+
finalMessages.splice(messageIndex + 1, 0, resultMessage);
|
|
1862
|
+
return resultMessage;
|
|
1863
|
+
});
|
|
1864
|
+
if (action && message.isActionExecutionMessage()) {
|
|
1865
|
+
const resultMessage = yield executeActionFromMessage(action, message);
|
|
1866
|
+
const pairedFeAction = getPairedFeAction(actions, resultMessage);
|
|
1867
|
+
if (pairedFeAction) {
|
|
1868
|
+
const newExecutionMessage = new import_runtime_client_gql6.ActionExecutionMessage({
|
|
1869
|
+
name: pairedFeAction.name,
|
|
1870
|
+
arguments: (0, import_shared10.parseJson)(resultMessage.result, resultMessage.result),
|
|
1871
|
+
status: message.status,
|
|
1872
|
+
createdAt: message.createdAt,
|
|
1873
|
+
parentMessageId: message.parentMessageId
|
|
1874
|
+
});
|
|
1875
|
+
yield executeActionFromMessage(pairedFeAction, newExecutionMessage);
|
|
1876
|
+
}
|
|
1877
|
+
} else if (message.isResultMessage() && currentResultMessagePairedFeAction) {
|
|
1878
|
+
const newExecutionMessage = new import_runtime_client_gql6.ActionExecutionMessage({
|
|
1879
|
+
name: currentResultMessagePairedFeAction.name,
|
|
1880
|
+
arguments: (0, import_shared10.parseJson)(message.result, message.result),
|
|
1881
|
+
status: message.status,
|
|
1882
|
+
createdAt: message.createdAt
|
|
1883
|
+
});
|
|
1884
|
+
finalMessages.push(newExecutionMessage);
|
|
1885
|
+
yield executeActionFromMessage(
|
|
1886
|
+
currentResultMessagePairedFeAction,
|
|
1887
|
+
newExecutionMessage
|
|
1898
1888
|
);
|
|
1899
1889
|
}
|
|
1900
1890
|
}
|
|
@@ -1965,7 +1955,7 @@ function useChat(options) {
|
|
|
1965
1955
|
if (!event)
|
|
1966
1956
|
return acc;
|
|
1967
1957
|
switch (event.name) {
|
|
1968
|
-
case
|
|
1958
|
+
case import_runtime_client_gql6.MetaEventName.LangGraphInterruptEvent:
|
|
1969
1959
|
if (event.response) {
|
|
1970
1960
|
setLangGraphInterruptAction(null);
|
|
1971
1961
|
const value = event.value;
|
|
@@ -2041,6 +2031,67 @@ function constructFinalMessages(syncedMessages, previousMessages, newMessages) {
|
|
|
2041
2031
|
}
|
|
2042
2032
|
return finalMessages;
|
|
2043
2033
|
}
|
|
2034
|
+
function executeAction(_0) {
|
|
2035
|
+
return __async(this, arguments, function* ({
|
|
2036
|
+
onFunctionCall,
|
|
2037
|
+
previousMessages,
|
|
2038
|
+
message,
|
|
2039
|
+
chatAbortControllerRef,
|
|
2040
|
+
onError
|
|
2041
|
+
}) {
|
|
2042
|
+
let result;
|
|
2043
|
+
let error = null;
|
|
2044
|
+
try {
|
|
2045
|
+
result = yield Promise.race([
|
|
2046
|
+
onFunctionCall({
|
|
2047
|
+
messages: previousMessages,
|
|
2048
|
+
name: message.name,
|
|
2049
|
+
args: message.arguments
|
|
2050
|
+
}),
|
|
2051
|
+
new Promise(
|
|
2052
|
+
(resolve) => {
|
|
2053
|
+
var _a;
|
|
2054
|
+
return (_a = chatAbortControllerRef.current) == null ? void 0 : _a.signal.addEventListener(
|
|
2055
|
+
"abort",
|
|
2056
|
+
() => resolve("Operation was aborted by the user")
|
|
2057
|
+
);
|
|
2058
|
+
}
|
|
2059
|
+
),
|
|
2060
|
+
// if the user stopped generation, we also abort consecutive actions
|
|
2061
|
+
new Promise((resolve) => {
|
|
2062
|
+
var _a;
|
|
2063
|
+
if ((_a = chatAbortControllerRef.current) == null ? void 0 : _a.signal.aborted) {
|
|
2064
|
+
resolve("Operation was aborted by the user");
|
|
2065
|
+
}
|
|
2066
|
+
})
|
|
2067
|
+
]);
|
|
2068
|
+
} catch (e) {
|
|
2069
|
+
onError(e);
|
|
2070
|
+
}
|
|
2071
|
+
return new import_runtime_client_gql6.ResultMessage({
|
|
2072
|
+
id: "result-" + message.id,
|
|
2073
|
+
result: import_runtime_client_gql6.ResultMessage.encodeResult(
|
|
2074
|
+
error ? {
|
|
2075
|
+
content: result,
|
|
2076
|
+
error: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)))
|
|
2077
|
+
} : result
|
|
2078
|
+
),
|
|
2079
|
+
actionExecutionId: message.id,
|
|
2080
|
+
actionName: message.name
|
|
2081
|
+
});
|
|
2082
|
+
});
|
|
2083
|
+
}
|
|
2084
|
+
function getPairedFeAction(actions, message) {
|
|
2085
|
+
let actionName = null;
|
|
2086
|
+
if (message.isActionExecutionMessage()) {
|
|
2087
|
+
actionName = message.name;
|
|
2088
|
+
} else if (message.isResultMessage()) {
|
|
2089
|
+
actionName = message.actionName;
|
|
2090
|
+
}
|
|
2091
|
+
return actions.find(
|
|
2092
|
+
(action) => action.name === actionName && action.available === "frontend" || action.pairedAction === actionName
|
|
2093
|
+
);
|
|
2094
|
+
}
|
|
2044
2095
|
|
|
2045
2096
|
// src/hooks/use-copilot-chat.ts
|
|
2046
2097
|
function useCopilotChat(_a = {}) {
|
|
@@ -2085,9 +2136,9 @@ function useCopilotChat(_a = {}) {
|
|
|
2085
2136
|
const makeSystemMessageCallback = (0, import_react12.useCallback)(() => {
|
|
2086
2137
|
const systemMessageMaker = makeSystemMessage2 || defaultSystemMessage;
|
|
2087
2138
|
const contextString = latestGetContextString.current([], defaultCopilotContextCategories);
|
|
2088
|
-
return new
|
|
2139
|
+
return new import_runtime_client_gql7.TextMessage({
|
|
2089
2140
|
content: systemMessageMaker(contextString, chatInstructions),
|
|
2090
|
-
role:
|
|
2141
|
+
role: import_runtime_client_gql7.Role.System
|
|
2091
2142
|
});
|
|
2092
2143
|
}, [getContextString, makeSystemMessage2, chatInstructions]);
|
|
2093
2144
|
const onCoAgentStateRender = useAsyncCallback(
|
|
@@ -2239,11 +2290,11 @@ ${additionalInstructions}` : "");
|
|
|
2239
2290
|
}
|
|
2240
2291
|
|
|
2241
2292
|
// src/hooks/use-copilot-action.ts
|
|
2242
|
-
var
|
|
2293
|
+
var import_shared11 = require("@copilotkit/shared");
|
|
2243
2294
|
var import_react13 = require("react");
|
|
2244
2295
|
function useCopilotAction(action, dependencies) {
|
|
2245
2296
|
const { setAction, removeAction, actions, chatComponentsCache } = useCopilotContext();
|
|
2246
|
-
const idRef = (0, import_react13.useRef)((0,
|
|
2297
|
+
const idRef = (0, import_react13.useRef)((0, import_shared11.randomId)());
|
|
2247
2298
|
const renderAndWaitRef = (0, import_react13.useRef)(null);
|
|
2248
2299
|
const { addToast } = useToast();
|
|
2249
2300
|
action = __spreadValues({}, action);
|
|
@@ -2345,7 +2396,7 @@ function isFrontendAction(action) {
|
|
|
2345
2396
|
|
|
2346
2397
|
// src/hooks/use-coagent-state-render.ts
|
|
2347
2398
|
var import_react14 = require("react");
|
|
2348
|
-
var
|
|
2399
|
+
var import_shared12 = require("@copilotkit/shared");
|
|
2349
2400
|
function useCoAgentStateRender(action, dependencies) {
|
|
2350
2401
|
const {
|
|
2351
2402
|
setCoAgentStateRender,
|
|
@@ -2354,7 +2405,7 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
2354
2405
|
chatComponentsCache,
|
|
2355
2406
|
availableAgents
|
|
2356
2407
|
} = (0, import_react14.useContext)(CopilotContext);
|
|
2357
|
-
const idRef = (0, import_react14.useRef)((0,
|
|
2408
|
+
const idRef = (0, import_react14.useRef)((0, import_shared12.randomId)());
|
|
2358
2409
|
const { addToast } = useToast();
|
|
2359
2410
|
(0, import_react14.useEffect)(() => {
|
|
2360
2411
|
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === action.name)) {
|
|
@@ -2453,7 +2504,7 @@ function useCopilotReadable({ description, value, parentId, categories, convert
|
|
|
2453
2504
|
|
|
2454
2505
|
// src/hooks/use-coagent.ts
|
|
2455
2506
|
var import_react17 = require("react");
|
|
2456
|
-
var
|
|
2507
|
+
var import_shared13 = require("@copilotkit/shared");
|
|
2457
2508
|
function useCoAgent(options) {
|
|
2458
2509
|
const generalContext = useCopilotContext();
|
|
2459
2510
|
const { availableAgents } = generalContext;
|
|
@@ -2504,7 +2555,7 @@ function useCoAgent(options) {
|
|
|
2504
2555
|
if (((_d = (_c = result.data) == null ? void 0 : _c.loadAgentState) == null ? void 0 : _d.threadExists) && newState && newState != "{}") {
|
|
2505
2556
|
lastLoadedState.current = newState;
|
|
2506
2557
|
lastLoadedThreadId.current = threadId;
|
|
2507
|
-
const fetchedState = (0,
|
|
2558
|
+
const fetchedState = (0, import_shared13.parseJson)(newState, {});
|
|
2508
2559
|
isExternalStateManagement(options) ? options.setState(fetchedState) : setState(fetchedState);
|
|
2509
2560
|
}
|
|
2510
2561
|
});
|
|
@@ -2630,7 +2681,7 @@ var import_react19 = __toESM(require("react"));
|
|
|
2630
2681
|
function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
2631
2682
|
const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
|
|
2632
2683
|
const pendingActionRef = (0, import_react18.useRef)(null);
|
|
2633
|
-
const
|
|
2684
|
+
const executeAction2 = (0, import_react18.useCallback)(
|
|
2634
2685
|
(props) => {
|
|
2635
2686
|
if (typeof action.render === "function") {
|
|
2636
2687
|
return action.render(props);
|
|
@@ -2650,13 +2701,13 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
2650
2701
|
onSignInComplete: (authState) => {
|
|
2651
2702
|
setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
|
|
2652
2703
|
if (pendingActionRef.current) {
|
|
2653
|
-
|
|
2704
|
+
executeAction2(pendingActionRef.current);
|
|
2654
2705
|
pendingActionRef.current = null;
|
|
2655
2706
|
}
|
|
2656
2707
|
}
|
|
2657
2708
|
}) : import_react19.default.createElement(import_react18.Fragment);
|
|
2658
2709
|
}
|
|
2659
|
-
return
|
|
2710
|
+
return executeAction2(props);
|
|
2660
2711
|
},
|
|
2661
2712
|
[action, authStates_c, setAuthStates_c]
|
|
2662
2713
|
);
|
|
@@ -2670,13 +2721,13 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
2670
2721
|
|
|
2671
2722
|
// src/hooks/use-langgraph-interrupt.ts
|
|
2672
2723
|
var import_react20 = require("react");
|
|
2673
|
-
var
|
|
2724
|
+
var import_shared14 = require("@copilotkit/shared");
|
|
2674
2725
|
function useLangGraphInterrupt(action, dependencies) {
|
|
2675
2726
|
var _a;
|
|
2676
2727
|
const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0, import_react20.useContext)(CopilotContext);
|
|
2677
2728
|
const { runChatCompletion } = useCopilotChat();
|
|
2678
2729
|
const { addToast } = useToast();
|
|
2679
|
-
const actionId = (0,
|
|
2730
|
+
const actionId = (0, import_shared14.dataToUUID)(JSON.stringify(action), "lgAction");
|
|
2680
2731
|
const hasAction = (0, import_react20.useMemo)(
|
|
2681
2732
|
() => Boolean(langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id),
|
|
2682
2733
|
[langGraphInterruptAction]
|
|
@@ -2755,7 +2806,7 @@ function useLangGraphInterruptRender() {
|
|
|
2755
2806
|
}
|
|
2756
2807
|
|
|
2757
2808
|
// src/lib/copilot-task.ts
|
|
2758
|
-
var
|
|
2809
|
+
var import_runtime_client_gql8 = require("@copilotkit/runtime-client-gql");
|
|
2759
2810
|
var CopilotTask = class {
|
|
2760
2811
|
constructor(config) {
|
|
2761
2812
|
this.instructions = config.instructions;
|
|
@@ -2783,12 +2834,12 @@ var CopilotTask = class {
|
|
|
2783
2834
|
if (this.includeCopilotReadable) {
|
|
2784
2835
|
contextString += context.getContextString([], defaultCopilotContextCategories);
|
|
2785
2836
|
}
|
|
2786
|
-
const systemMessage = new
|
|
2837
|
+
const systemMessage = new import_runtime_client_gql8.TextMessage({
|
|
2787
2838
|
content: taskSystemMessage(contextString, this.instructions),
|
|
2788
|
-
role:
|
|
2839
|
+
role: import_runtime_client_gql8.Role.System
|
|
2789
2840
|
});
|
|
2790
2841
|
const messages = [systemMessage];
|
|
2791
|
-
const runtimeClient = new
|
|
2842
|
+
const runtimeClient = new import_runtime_client_gql8.CopilotRuntimeClient({
|
|
2792
2843
|
url: context.copilotApiConfig.chatApiEndpoint,
|
|
2793
2844
|
publicApiKey: context.copilotApiConfig.publicApiKey,
|
|
2794
2845
|
headers: context.copilotApiConfig.headers,
|
|
@@ -2800,9 +2851,9 @@ var CopilotTask = class {
|
|
|
2800
2851
|
actions: processActionsForRuntimeRequest(Object.values(actions)),
|
|
2801
2852
|
url: window.location.href
|
|
2802
2853
|
},
|
|
2803
|
-
messages: (0,
|
|
2854
|
+
messages: (0, import_runtime_client_gql8.convertMessagesToGqlInput)((0, import_runtime_client_gql8.filterAgentStateMessages)(messages)),
|
|
2804
2855
|
metadata: {
|
|
2805
|
-
requestType:
|
|
2856
|
+
requestType: import_runtime_client_gql8.CopilotRequestType.Task
|
|
2806
2857
|
},
|
|
2807
2858
|
forwardedParameters: __spreadProps(__spreadValues({}, (_a = this.forwardedParameters) != null ? _a : {}), {
|
|
2808
2859
|
toolChoice: "required"
|
|
@@ -2811,7 +2862,7 @@ var CopilotTask = class {
|
|
|
2811
2862
|
properties: context.copilotApiConfig.properties
|
|
2812
2863
|
}).toPromise();
|
|
2813
2864
|
const functionCallHandler = context.getFunctionCallHandler(actions);
|
|
2814
|
-
const functionCalls = (0,
|
|
2865
|
+
const functionCalls = (0, import_runtime_client_gql8.convertGqlOutputToMessages)(
|
|
2815
2866
|
((_c = (_b = response.data) == null ? void 0 : _b.generateCopilotResponse) == null ? void 0 : _c.messages) || []
|
|
2816
2867
|
).filter((m) => m.isActionExecutionMessage());
|
|
2817
2868
|
for (const functionCall of functionCalls) {
|