@copilotkit/react-core 1.63.1 → 1.63.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{copilotkit-CN_LykOC.d.mts → copilotkit-BE1n5tSI.d.mts} +16 -1
- package/dist/{copilotkit-CN_LykOC.d.mts.map → copilotkit-BE1n5tSI.d.mts.map} +1 -1
- package/dist/{copilotkit-BLh58_Tt.mjs → copilotkit-CN2JVeH3.mjs} +101 -77
- package/dist/copilotkit-CN2JVeH3.mjs.map +1 -0
- package/dist/{copilotkit-BHs-vx6l.d.cts → copilotkit-CXvuYw_F.d.cts} +16 -1
- package/dist/{copilotkit-BHs-vx6l.d.cts.map → copilotkit-CXvuYw_F.d.cts.map} +1 -1
- package/dist/{copilotkit-nu7NwzH6.cjs → copilotkit-DDVfoiRM.cjs} +99 -75
- package/dist/copilotkit-DDVfoiRM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +98 -74
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +98 -74
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +15 -0
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +15 -0
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +100 -76
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +98 -74
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/dist/copilotkit-BLh58_Tt.mjs.map +0 -1
- package/dist/copilotkit-nu7NwzH6.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_copilotkit = require('./copilotkit-
|
|
4
|
+
const require_copilotkit = require('./copilotkit-DDVfoiRM.cjs');
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_copilotkit.__toESM(react);
|
|
7
7
|
let _copilotkit_core = require("@copilotkit/core");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as LangGraphInterruptRender, Gn as CopilotApiConfig, Jn as useCopilotContext, Kn as CopilotContext, Qn as LangGraphInterruptActionSetterArgs, Sr as RenderFunctionStatus, Wn as CoagentInChatRenderFunction, Xn as LangGraphInterruptAction, Y as useAgent, Yn as CoAgentStateRender, Zn as LangGraphInterruptActionSetter, _r as ActionRenderPropsWait, ar as CrewsResponseStatus, br as FrontendAction, cr as CrewsToolStateItem, dr as DocumentPointer, er as LangGraphInterruptRenderHandlerProps, fr as Tree, gr as ActionRenderPropsNoArgsWait, hr as ActionRenderPropsNoArgs, ir as CrewsResponse, lr as CopilotChatSuggestionConfiguration, mr as ActionRenderProps, n as defaultCopilotContextCategories, nr as QueuedInterruptEvent, or as CrewsStateItem, pr as TreeNode, qn as CopilotContextParams, r as CopilotKitProps, rr as CrewsAgentState, sr as CrewsTaskStateItem, t as CopilotKit, tr as LangGraphInterruptRenderProps, ur as SystemMessageFunction, vr as CatchAllActionRenderProps, vt as useRenderToolCall$1, xr as FrontendActionAvailability, yr as CatchAllFrontendAction } from "./copilotkit-
|
|
1
|
+
import { $n as LangGraphInterruptRender, Gn as CopilotApiConfig, Jn as useCopilotContext, Kn as CopilotContext, Qn as LangGraphInterruptActionSetterArgs, Sr as RenderFunctionStatus, Wn as CoagentInChatRenderFunction, Xn as LangGraphInterruptAction, Y as useAgent, Yn as CoAgentStateRender, Zn as LangGraphInterruptActionSetter, _r as ActionRenderPropsWait, ar as CrewsResponseStatus, br as FrontendAction, cr as CrewsToolStateItem, dr as DocumentPointer, er as LangGraphInterruptRenderHandlerProps, fr as Tree, gr as ActionRenderPropsNoArgsWait, hr as ActionRenderPropsNoArgs, ir as CrewsResponse, lr as CopilotChatSuggestionConfiguration, mr as ActionRenderProps, n as defaultCopilotContextCategories, nr as QueuedInterruptEvent, or as CrewsStateItem, pr as TreeNode, qn as CopilotContextParams, r as CopilotKitProps, rr as CrewsAgentState, sr as CrewsTaskStateItem, t as CopilotKit, tr as LangGraphInterruptRenderProps, ur as SystemMessageFunction, vr as CatchAllActionRenderProps, vt as useRenderToolCall$1, xr as FrontendActionAvailability, yr as CatchAllFrontendAction } from "./copilotkit-CXvuYw_F.cjs";
|
|
2
2
|
import "./v2/index.cjs";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import { CopilotRuntimeClient, CopilotRuntimeClientOptions, ForwardedParametersInput, Message } from "@copilotkit/runtime-client-gql";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as LangGraphInterruptRender, Gn as CopilotApiConfig, Jn as useCopilotContext, Kn as CopilotContext, Qn as LangGraphInterruptActionSetterArgs, Sr as RenderFunctionStatus, Wn as CoagentInChatRenderFunction, Xn as LangGraphInterruptAction, Y as useAgent, Yn as CoAgentStateRender, Zn as LangGraphInterruptActionSetter, _r as ActionRenderPropsWait, ar as CrewsResponseStatus, br as FrontendAction, cr as CrewsToolStateItem, dr as DocumentPointer, er as LangGraphInterruptRenderHandlerProps, fr as Tree, gr as ActionRenderPropsNoArgsWait, hr as ActionRenderPropsNoArgs, ir as CrewsResponse, lr as CopilotChatSuggestionConfiguration, mr as ActionRenderProps, n as defaultCopilotContextCategories, nr as QueuedInterruptEvent, or as CrewsStateItem, pr as TreeNode, qn as CopilotContextParams, r as CopilotKitProps, rr as CrewsAgentState, sr as CrewsTaskStateItem, t as CopilotKit, tr as LangGraphInterruptRenderProps, ur as SystemMessageFunction, vr as CatchAllActionRenderProps, vt as useRenderToolCall$1, xr as FrontendActionAvailability, yr as CatchAllFrontendAction } from "./copilotkit-
|
|
1
|
+
import { $n as LangGraphInterruptRender, Gn as CopilotApiConfig, Jn as useCopilotContext, Kn as CopilotContext, Qn as LangGraphInterruptActionSetterArgs, Sr as RenderFunctionStatus, Wn as CoagentInChatRenderFunction, Xn as LangGraphInterruptAction, Y as useAgent, Yn as CoAgentStateRender, Zn as LangGraphInterruptActionSetter, _r as ActionRenderPropsWait, ar as CrewsResponseStatus, br as FrontendAction, cr as CrewsToolStateItem, dr as DocumentPointer, er as LangGraphInterruptRenderHandlerProps, fr as Tree, gr as ActionRenderPropsNoArgsWait, hr as ActionRenderPropsNoArgs, ir as CrewsResponse, lr as CopilotChatSuggestionConfiguration, mr as ActionRenderProps, n as defaultCopilotContextCategories, nr as QueuedInterruptEvent, or as CrewsStateItem, pr as TreeNode, qn as CopilotContextParams, r as CopilotKitProps, rr as CrewsAgentState, sr as CrewsTaskStateItem, t as CopilotKit, tr as LangGraphInterruptRenderProps, ur as SystemMessageFunction, vr as CatchAllActionRenderProps, vt as useRenderToolCall$1, xr as FrontendActionAvailability, yr as CatchAllFrontendAction } from "./copilotkit-BE1n5tSI.mjs";
|
|
2
2
|
import "./v2/index.mjs";
|
|
3
3
|
import React, { ReactNode, RefObject, SetStateAction } from "react";
|
|
4
4
|
import { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { Tt as useCopilotKit, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useRenderCustomMessages, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, jt as useCopilotChatConfiguration, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useHumanInTheLoop$1, o as useThreads, ot as useFrontendTool$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useAgent, u as useAsyncCallback, ut as defineToolCallRenderer, wt as useRenderToolCall$1 } from "./copilotkit-
|
|
3
|
+
import { Tt as useCopilotKit, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useRenderCustomMessages, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, jt as useCopilotChatConfiguration, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useHumanInTheLoop$1, o as useThreads, ot as useFrontendTool$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useAgent, u as useAsyncCallback, ut as defineToolCallRenderer, wt as useRenderToolCall$1 } from "./copilotkit-CN2JVeH3.mjs";
|
|
4
4
|
import React, { Fragment, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus } from "@copilotkit/core";
|
|
6
6
|
import { AGUIConnectNotImplementedError, HttpAgent } from "@ag-ui/client";
|
package/dist/index.umd.js
CHANGED
|
@@ -2893,11 +2893,14 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2893
2893
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
2894
2894
|
const updateFlags = (0, react.useMemo)(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
2895
2895
|
const provisionalAgentCache = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
2896
|
-
const agent = (0, react.useMemo)(() => {
|
|
2896
|
+
const { agent, isReady } = (0, react.useMemo)(() => {
|
|
2897
2897
|
const existing = copilotkit.getAgent(resolvedAgentId);
|
|
2898
2898
|
if (existing) {
|
|
2899
2899
|
provisionalAgentCache.current.delete(resolvedAgentId);
|
|
2900
|
-
return
|
|
2900
|
+
return {
|
|
2901
|
+
agent: existing,
|
|
2902
|
+
isReady: true
|
|
2903
|
+
};
|
|
2901
2904
|
}
|
|
2902
2905
|
const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
|
|
2903
2906
|
const status = copilotkit.runtimeConnectionStatus;
|
|
@@ -2905,7 +2908,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2905
2908
|
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
2906
2909
|
if (cached) {
|
|
2907
2910
|
copilotkit.applyHeadersToAgent(cached);
|
|
2908
|
-
return
|
|
2911
|
+
return {
|
|
2912
|
+
agent: cached,
|
|
2913
|
+
isReady: false
|
|
2914
|
+
};
|
|
2909
2915
|
}
|
|
2910
2916
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
2911
2917
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
@@ -2915,13 +2921,19 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2915
2921
|
});
|
|
2916
2922
|
copilotkit.applyHeadersToAgent(provisional);
|
|
2917
2923
|
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
2918
|
-
return
|
|
2924
|
+
return {
|
|
2925
|
+
agent: provisional,
|
|
2926
|
+
isReady: false
|
|
2927
|
+
};
|
|
2919
2928
|
}
|
|
2920
2929
|
if (isRuntimeConfigured && status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
2921
2930
|
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
2922
2931
|
if (cached) {
|
|
2923
2932
|
copilotkit.applyHeadersToAgent(cached);
|
|
2924
|
-
return
|
|
2933
|
+
return {
|
|
2934
|
+
agent: cached,
|
|
2935
|
+
isReady: false
|
|
2936
|
+
};
|
|
2925
2937
|
}
|
|
2926
2938
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
2927
2939
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
@@ -2931,7 +2943,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2931
2943
|
});
|
|
2932
2944
|
copilotkit.applyHeadersToAgent(provisional);
|
|
2933
2945
|
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
2934
|
-
return
|
|
2946
|
+
return {
|
|
2947
|
+
agent: provisional,
|
|
2948
|
+
isReady: false
|
|
2949
|
+
};
|
|
2935
2950
|
}
|
|
2936
2951
|
const knownAgents = Object.keys(copilotkit.agents ?? {});
|
|
2937
2952
|
const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
|
|
@@ -2992,7 +3007,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2992
3007
|
configThreadId,
|
|
2993
3008
|
configHasExplicitThreadId
|
|
2994
3009
|
]);
|
|
2995
|
-
return {
|
|
3010
|
+
return {
|
|
3011
|
+
agent,
|
|
3012
|
+
isReady
|
|
3013
|
+
};
|
|
2996
3014
|
}
|
|
2997
3015
|
|
|
2998
3016
|
//#endregion
|
|
@@ -3255,8 +3273,9 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3255
3273
|
const pendingRef = (0, react.useRef)(pending);
|
|
3256
3274
|
pendingRef.current = pending;
|
|
3257
3275
|
const [handlerResult, setHandlerResult] = (0, react.useState)(null);
|
|
3258
|
-
const
|
|
3276
|
+
const interruptStateRef = (0, react.useRef)(new _copilotkit_core.ɵInterruptState());
|
|
3259
3277
|
(0, react.useEffect)(() => {
|
|
3278
|
+
const interruptState = interruptStateRef.current;
|
|
3260
3279
|
let localLegacy = null;
|
|
3261
3280
|
let localStandard = null;
|
|
3262
3281
|
const subscription = agent.subscribe({
|
|
@@ -3272,106 +3291,111 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3272
3291
|
onRunStartedEvent: () => {
|
|
3273
3292
|
localLegacy = null;
|
|
3274
3293
|
localStandard = null;
|
|
3275
|
-
|
|
3294
|
+
interruptState.clear();
|
|
3276
3295
|
setPending(null);
|
|
3277
3296
|
},
|
|
3278
3297
|
onRunFinalized: () => {
|
|
3279
|
-
if (localStandard && localStandard.length > 0)
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
})
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
});
|
|
3298
|
+
if (localStandard && localStandard.length > 0) {
|
|
3299
|
+
interruptState.setStandard(localStandard);
|
|
3300
|
+
setPending(interruptState.pending);
|
|
3301
|
+
} else if (localLegacy) {
|
|
3302
|
+
interruptState.setLegacy(localLegacy);
|
|
3303
|
+
setPending(interruptState.pending);
|
|
3304
|
+
}
|
|
3287
3305
|
localLegacy = null;
|
|
3288
3306
|
localStandard = null;
|
|
3289
3307
|
},
|
|
3290
3308
|
onRunFailed: () => {
|
|
3291
3309
|
localLegacy = null;
|
|
3292
3310
|
localStandard = null;
|
|
3293
|
-
|
|
3311
|
+
interruptState.clear();
|
|
3294
3312
|
setPending(null);
|
|
3295
3313
|
}
|
|
3296
3314
|
});
|
|
3297
|
-
return () =>
|
|
3315
|
+
return () => {
|
|
3316
|
+
subscription.unsubscribe();
|
|
3317
|
+
interruptState.clear();
|
|
3318
|
+
};
|
|
3298
3319
|
}, [agent]);
|
|
3299
|
-
const
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
if (
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
setPending(null);
|
|
3306
|
-
return;
|
|
3307
|
-
}
|
|
3308
|
-
const resume = (0, _ag_ui_client.buildResumeArray)(interrupts, responsesRef.current);
|
|
3309
|
-
for (const i of interrupts) {
|
|
3310
|
-
if (!i.toolCallId) continue;
|
|
3311
|
-
const response = responsesRef.current[i.id];
|
|
3312
|
-
const content = response.status === "cancelled" ? { status: "cancelled" } : response.payload ?? { status: "resolved" };
|
|
3313
|
-
agent.addMessage({
|
|
3314
|
-
id: (0, _ag_ui_client.randomUUID)(),
|
|
3315
|
-
role: "tool",
|
|
3316
|
-
toolCallId: i.toolCallId,
|
|
3317
|
-
content: JSON.stringify(content)
|
|
3318
|
-
});
|
|
3319
|
-
}
|
|
3320
|
-
responsesRef.current = {};
|
|
3321
|
-
try {
|
|
3320
|
+
const resolve = (0, react.useCallback)(async (payload, interruptId) => {
|
|
3321
|
+
const current = pendingRef.current;
|
|
3322
|
+
if (!current) return;
|
|
3323
|
+
if (current.kind === "standard" && current.interrupts.length > 1 && interruptId === void 0) console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${current.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);
|
|
3324
|
+
const decision = interruptStateRef.current.resolve(payload, interruptId);
|
|
3325
|
+
if (decision.kind === "legacy-resume") try {
|
|
3322
3326
|
return await copilotkit.runAgent({
|
|
3323
3327
|
agent,
|
|
3324
|
-
|
|
3328
|
+
forwardedProps: { command: {
|
|
3329
|
+
resume: decision.payload,
|
|
3330
|
+
interruptEvent: decision.interruptValue
|
|
3331
|
+
} }
|
|
3325
3332
|
});
|
|
3326
3333
|
} catch (err) {
|
|
3327
3334
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
3328
3335
|
setPending(null);
|
|
3329
3336
|
throw err;
|
|
3330
3337
|
}
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3338
|
+
if (decision.kind === "expired") {
|
|
3339
|
+
console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
|
|
3340
|
+
interruptStateRef.current.clear();
|
|
3341
|
+
setPending(null);
|
|
3342
|
+
return;
|
|
3343
|
+
}
|
|
3344
|
+
if (decision.kind !== "resume") return;
|
|
3345
|
+
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
3346
|
+
id: (0, _ag_ui_client.randomUUID)(),
|
|
3347
|
+
role: "tool",
|
|
3348
|
+
toolCallId: toolResult.toolCallId,
|
|
3349
|
+
content: toolResult.content
|
|
3350
|
+
});
|
|
3351
|
+
try {
|
|
3336
3352
|
return await copilotkit.runAgent({
|
|
3337
3353
|
agent,
|
|
3338
|
-
|
|
3339
|
-
resume: payload,
|
|
3340
|
-
interruptEvent: current.event.value
|
|
3341
|
-
} }
|
|
3354
|
+
resume: decision.resume
|
|
3342
3355
|
});
|
|
3343
3356
|
} catch (err) {
|
|
3344
3357
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
3358
|
+
interruptStateRef.current.clear();
|
|
3345
3359
|
setPending(null);
|
|
3346
3360
|
throw err;
|
|
3347
3361
|
}
|
|
3348
|
-
|
|
3349
|
-
const id = interruptId ?? current.interrupts[0]?.id;
|
|
3350
|
-
if (!id) return;
|
|
3351
|
-
responsesRef.current[id] = {
|
|
3352
|
-
status: "resolved",
|
|
3353
|
-
payload
|
|
3354
|
-
};
|
|
3355
|
-
return submitStandardIfComplete(current.interrupts);
|
|
3356
|
-
}, [
|
|
3357
|
-
agent,
|
|
3358
|
-
copilotkit,
|
|
3359
|
-
submitStandardIfComplete
|
|
3360
|
-
]);
|
|
3362
|
+
}, [agent, copilotkit]);
|
|
3361
3363
|
const cancel = (0, react.useCallback)(async (interruptId) => {
|
|
3362
3364
|
const current = pendingRef.current;
|
|
3363
3365
|
if (!current) return;
|
|
3364
|
-
if (current.kind === "
|
|
3366
|
+
if (current.kind === "standard" && current.interrupts.length > 1 && interruptId === void 0) console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${current.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);
|
|
3367
|
+
const decision = interruptStateRef.current.cancel(interruptId);
|
|
3368
|
+
if (decision.kind === "dismiss") {
|
|
3365
3369
|
console.warn("[CopilotKit] useInterrupt: cancel() is not supported for legacy on_interrupt interrupts; dismissing.");
|
|
3370
|
+
interruptStateRef.current.clear();
|
|
3371
|
+
setPending(null);
|
|
3372
|
+
return;
|
|
3373
|
+
}
|
|
3374
|
+
if (decision.kind === "expired") {
|
|
3375
|
+
console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
|
|
3376
|
+
interruptStateRef.current.clear();
|
|
3366
3377
|
setPending(null);
|
|
3367
3378
|
return;
|
|
3368
3379
|
}
|
|
3369
|
-
if (
|
|
3370
|
-
const
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3380
|
+
if (decision.kind !== "resume") return;
|
|
3381
|
+
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
3382
|
+
id: (0, _ag_ui_client.randomUUID)(),
|
|
3383
|
+
role: "tool",
|
|
3384
|
+
toolCallId: toolResult.toolCallId,
|
|
3385
|
+
content: toolResult.content
|
|
3386
|
+
});
|
|
3387
|
+
try {
|
|
3388
|
+
return await copilotkit.runAgent({
|
|
3389
|
+
agent,
|
|
3390
|
+
resume: decision.resume
|
|
3391
|
+
});
|
|
3392
|
+
} catch (err) {
|
|
3393
|
+
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
3394
|
+
interruptStateRef.current.clear();
|
|
3395
|
+
setPending(null);
|
|
3396
|
+
throw err;
|
|
3397
|
+
}
|
|
3398
|
+
}, [agent, copilotkit]);
|
|
3375
3399
|
const renderRef = (0, react.useRef)(config.render);
|
|
3376
3400
|
renderRef.current = config.render;
|
|
3377
3401
|
const enabledRef = (0, react.useRef)(config.enabled);
|
|
@@ -3413,7 +3437,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3413
3437
|
maybePromise = handler({
|
|
3414
3438
|
event: legacyEvent,
|
|
3415
3439
|
interrupt: pending.kind === "standard" ? pending.interrupts[0] : null,
|
|
3416
|
-
interrupts: pending.kind === "standard" ? pending.interrupts : [],
|
|
3440
|
+
interrupts: pending.kind === "standard" ? [...pending.interrupts] : [],
|
|
3417
3441
|
resolve: resolveRef.current,
|
|
3418
3442
|
cancel: cancelRef.current
|
|
3419
3443
|
});
|
|
@@ -3442,7 +3466,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3442
3466
|
return renderRef.current({
|
|
3443
3467
|
event: legacyEvent,
|
|
3444
3468
|
interrupt: pending.kind === "standard" ? pending.interrupts[0] : null,
|
|
3445
|
-
interrupts: pending.kind === "standard" ? pending.interrupts : [],
|
|
3469
|
+
interrupts: pending.kind === "standard" ? [...pending.interrupts] : [],
|
|
3446
3470
|
result: handlerResult,
|
|
3447
3471
|
resolve,
|
|
3448
3472
|
cancel
|