@copilotkit/vue 1.61.0 → 1.61.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/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/use-render-activity-message-9_0XvKn5.cjs +85 -0
- package/dist/use-render-activity-message-9_0XvKn5.cjs.map +1 -0
- package/dist/{use-render-activity-message-BB43N8wJ.js → use-render-activity-message-B1YTA0pi.js} +2408 -2323
- package/dist/use-render-activity-message-B1YTA0pi.js.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
- package/dist/v2/hooks/use-interrupt.d.ts +21 -8
- package/dist/v2/hooks/use-interrupt.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/types/interrupt.d.ts +11 -2
- package/dist/v2/types/interrupt.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/v2/components/chat/CopilotChatMessageView.vue +3 -0
- package/src/v2/hooks/__tests__/use-interrupt.test.ts +187 -2
- package/src/v2/hooks/use-interrupt.ts +218 -44
- package/src/v2/providers/CopilotKitProvider.vue +4 -6
- package/src/v2/types/interrupt.ts +18 -2
- package/dist/use-render-activity-message-B0zDl3Lc.cjs +0 -85
- package/dist/use-render-activity-message-B0zDl3Lc.cjs.map +0 -1
- package/dist/use-render-activity-message-BB43N8wJ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatMessageView.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/chat/CopilotChatMessageView.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CopilotChatMessageView.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/chat/CopilotChatMessageView.vue"],"names":[],"mappings":"AAmeA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,OAAO,E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@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ComputedRef, Ref } from "vue";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { Interrupt } from "@ag-ui/client";
|
|
3
|
+
import type { InterruptEvent, InterruptHandlerProps, InterruptRenderProps, InterruptResolveFn, InterruptCancelFn } from "../types/interrupt";
|
|
4
|
+
export type { InterruptEvent, InterruptHandlerProps, InterruptRenderProps, Interrupt, };
|
|
4
5
|
type InterruptHandlerFn<TValue, TResult> = (props: InterruptHandlerProps<TValue>) => TResult | PromiseLike<TResult>;
|
|
5
6
|
type InterruptResultFromHandler<THandler> = THandler extends (...args: never[]) => infer TResult ? TResult extends PromiseLike<infer TResolved> ? TResolved | null : TResult | null : null;
|
|
6
7
|
type InterruptResult<TValue, TResult> = InterruptResultFromHandler<InterruptHandlerFn<TValue, TResult>>;
|
|
@@ -14,20 +15,32 @@ export interface UseInterruptResult<TValue = unknown, TResult = never> {
|
|
|
14
15
|
interrupt: Ref<InterruptEvent<TValue> | null>;
|
|
15
16
|
result: Ref<InterruptResult<TValue, TResult>>;
|
|
16
17
|
hasInterrupt: ComputedRef<boolean>;
|
|
17
|
-
|
|
18
|
+
/** Resolve the pending interrupt. Standard: records resolved response and submits when all addressed. Legacy: resumes via forwardedProps.command. */
|
|
19
|
+
resolve: InterruptResolveFn;
|
|
20
|
+
/** Alias of resolve for back-compat. */
|
|
21
|
+
resolveInterrupt: InterruptResolveFn;
|
|
22
|
+
/** Cancel the pending interrupt. Standard: records cancelled response and submits when all addressed. */
|
|
23
|
+
cancel: InterruptCancelFn;
|
|
24
|
+
/** Alias of cancel for back-compat. */
|
|
25
|
+
cancelInterrupt: InterruptCancelFn;
|
|
18
26
|
slotProps: ComputedRef<InterruptRenderProps<TValue, InterruptResult<TValue, TResult>> | null>;
|
|
19
27
|
}
|
|
20
28
|
export declare function isPromiseLike<TValue>(value: TValue | PromiseLike<TValue>): value is PromiseLike<TValue>;
|
|
21
29
|
/**
|
|
22
|
-
* Vue composable for handling
|
|
30
|
+
* Vue composable for handling agent interrupts with optional filtering,
|
|
31
|
+
* preprocessing, and resume behavior.
|
|
23
32
|
*
|
|
24
|
-
*
|
|
25
|
-
* `
|
|
26
|
-
* interrupts
|
|
33
|
+
* Supports both the AG-UI standard interrupt flow (`RUN_FINISHED` with
|
|
34
|
+
* `outcome:"interrupt"`) and the legacy custom-event flow (`on_interrupt`).
|
|
35
|
+
* For standard interrupts, `slotProps` receives `interrupt` (the primary one)
|
|
36
|
+
* and `interrupts` (the full open set); call `resolve(payload)` to resume or
|
|
37
|
+
* `cancel()` to cancel. Resuming addresses the targeted interrupt and, once
|
|
38
|
+
* every open interrupt is addressed, submits a single spec `resume` array via
|
|
39
|
+
* `copilotkit.runAgent`.
|
|
27
40
|
*
|
|
28
41
|
* @example
|
|
29
42
|
* ```ts
|
|
30
|
-
* const { interrupt, hasInterrupt,
|
|
43
|
+
* const { interrupt, hasInterrupt, resolve, cancel } = useInterrupt({
|
|
31
44
|
* handler: ({ event }) => ({ label: String(event.value) }),
|
|
32
45
|
* });
|
|
33
46
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-interrupt.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-interrupt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"use-interrupt.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-interrupt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,eAAe,CAAC;AAG/D,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,cAAc,EACd,qBAAqB,EACr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iBAAiB,CAAC;IAC1B,uCAAuC;IACvC,eAAe,EAAE,iBAAiB,CAAC;IACnC,SAAS,EAAE,WAAW,CAAC,oBAAoB,CACzC,MAAM,EACN,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CACjC,GAAG,IAAI,CAAC,CAAC;CACX;AAED,wBAAgB,aAAa,CAAC,MAAM,EAClC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,GAClC,KAAK,IAAI,WAAW,CAAC,MAAM,CAAC,CAM9B;AAwBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,KAAK,EAC5D,MAAM,GAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAM,GAC/C,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAiTrC"}
|
package/dist/v2/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@copilotkit/core"),i=require("@ag-ui/client"),e=require("../use-render-activity-message-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@copilotkit/core"),i=require("@ag-ui/client"),e=require("../use-render-activity-message-9_0XvKn5.cjs"),n=require("@copilotkit/shared");exports.A2UIActivityContentSchema=e.A2UIActivityContentSchema;exports.A2UISurfaceActivityRenderer=e._sfc_main;exports.A2UISurfaceActivityType=e.A2UISurfaceActivityType;exports.CopilotChat=e.CopilotChat;exports.CopilotChatAssistantMessage=e._sfc_main$1;exports.CopilotChatAttachmentQueue=e._sfc_main$2;exports.CopilotChatAttachmentRenderer=e._sfc_main$3;exports.CopilotChatAudioRecorder=e._sfc_main$4;exports.CopilotChatConfigurationProvider=e._sfc_main$5;exports.CopilotChatDefaultLabels=e.CopilotChatDefaultLabels;exports.CopilotChatInput=e._sfc_main$6;exports.CopilotChatMessageView=e._sfc_main$7;exports.CopilotChatReasoningMessage=e._sfc_main$8;exports.CopilotChatSuggestionPill=e._sfc_main$9;exports.CopilotChatSuggestionView=e._sfc_main$10;exports.CopilotChatToggleButton=e.CopilotChatToggleButton;exports.CopilotChatToggleButtonCloseIcon=e.CopilotChatToggleButtonCloseIcon;exports.CopilotChatToggleButtonOpenIcon=e.CopilotChatToggleButtonOpenIcon;exports.CopilotChatToolCallsView=e._sfc_main$11;exports.CopilotChatUserMessage=e._sfc_main$12;exports.CopilotChatView=e._sfc_main$13;exports.CopilotKitCoreVue=e.CopilotKitCoreVue;exports.CopilotKitInspector=e._sfc_main$14;exports.CopilotKitProvider=e._sfc_main$15;exports.CopilotModalHeader=e.CopilotModalHeader;exports.CopilotPopup=e._sfc_main$16;exports.CopilotPopupView=e.CopilotPopupView;exports.CopilotSidebar=e._sfc_main$17;exports.CopilotSidebarView=e.CopilotSidebarView;exports.GenerateSandboxedUiArgsSchema=e.GenerateSandboxedUiArgsSchema;exports.LicenseContextKey=e.LicenseContextKey;exports.MCPAppsActivityContentSchema=e.MCPAppsActivityContentSchema;exports.MCPAppsActivityRenderer=e.MCPAppsActivityRenderer;exports.MCPAppsActivityType=e.MCPAppsActivityType;exports.OpenGenerativeUIActivityRenderer=e.OpenGenerativeUIActivityRenderer;exports.OpenGenerativeUIActivityType=e.OpenGenerativeUIActivityType;exports.OpenGenerativeUIContentSchema=e.OpenGenerativeUIContentSchema;exports.OpenGenerativeUIRenderer=e.OpenGenerativeUIRenderer;exports.OpenGenerativeUIToolRenderer=e.OpenGenerativeUIToolRenderer;exports.UseAgentUpdate=e.UseAgentUpdate;exports.createA2UIMessageRenderer=e.createA2UIMessageRenderer;exports.createDefaultLicenseRef=e.createDefaultLicenseRef;exports.defineToolCallRenderer=e.defineToolCallRenderer;exports.extractCompleteStyles=e.extractCompleteStyles;exports.getOperationSurfaceId=e.getOperationSurfaceId;exports.processPartialHtml=e.processPartialHtml;exports.useAgent=e.useAgent;exports.useAgentContext=e.useAgentContext;exports.useAttachments=e.useAttachments;exports.useCapabilities=e.useCapabilities;exports.useComponent=e.useComponent;exports.useConfigureSuggestions=e.useConfigureSuggestions;exports.useCopilotChatConfiguration=e.useCopilotChatConfiguration;exports.useCopilotKit=e.useCopilotKit;exports.useDefaultRenderTool=e.useDefaultRenderTool;exports.useFrontendTool=e.useFrontendTool;exports.useHumanInTheLoop=e.useHumanInTheLoop;exports.useInterrupt=e.useInterrupt;exports.useKatexStyles=e.useKatexStyles;exports.useKeyboardHeight=e.useKeyboardHeight;exports.useLicenseContext=e.useLicenseContext;exports.useRenderActivityMessage=e.useRenderActivityMessage;exports.useRenderCustomMessages=e.useRenderCustomMessages;exports.useRenderTool=e.useRenderTool;exports.useSandboxFunctions=e.useSandboxFunctions;exports.useSuggestions=e.useSuggestions;exports.useThreads=e.useThreads;Object.defineProperty(exports,"createLicenseContextValue",{enumerable:!0,get:()=>n.createLicenseContextValue});Object.keys(o).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>o[t]})});Object.keys(i).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>i[t]})});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/v2/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "@copilotkit/core";
|
|
2
2
|
export * from "@ag-ui/client";
|
|
3
|
-
import { A as o, _ as i, a as n, C, b as r, c as p, d as l, e as u, f as c, g, h as d, i as h, j as A, k as S, l as m, m as v, n as y, o as I, p as f, q as R, r as T, s as U, t as x, u as M, v as P, w as b, x as V, y as K, z as O, G as w, L as G, M as L, B as H, D as B, O as D, E as F, F as Q, H as j, I as k, U as q, J as z, K as E, N as J, P as N, Q as W, R as X, S as Y, T as Z, V as _, W as $, X as ee, Y as ae, Z as te, $ as se, a0 as oe, a1 as ie, a2 as ne, a3 as Ce, a4 as re, a5 as pe, a6 as le, a7 as ue, a8 as ce, a9 as ge, aa as de, ab as he, ac as Ae } from "../use-render-activity-message-
|
|
3
|
+
import { A as o, _ as i, a as n, C, b as r, c as p, d as l, e as u, f as c, g, h as d, i as h, j as A, k as S, l as m, m as v, n as y, o as I, p as f, q as R, r as T, s as U, t as x, u as M, v as P, w as b, x as V, y as K, z as O, G as w, L as G, M as L, B as H, D as B, O as D, E as F, F as Q, H as j, I as k, U as q, J as z, K as E, N as J, P as N, Q as W, R as X, S as Y, T as Z, V as _, W as $, X as ee, Y as ae, Z as te, $ as se, a0 as oe, a1 as ie, a2 as ne, a3 as Ce, a4 as re, a5 as pe, a6 as le, a7 as ue, a8 as ce, a9 as ge, aa as de, ab as he, ac as Ae } from "../use-render-activity-message-B1YTA0pi.js";
|
|
4
4
|
import { createLicenseContextValue as me } from "@copilotkit/shared";
|
|
5
5
|
export {
|
|
6
6
|
o as A2UIActivityContentSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotKitProvider.vue.d.ts","sourceRoot":"","sources":["../../../src/v2/providers/CopilotKitProvider.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CopilotKitProvider.vue.d.ts","sourceRoot":"","sources":["../../../src/v2/providers/CopilotKitProvider.vue"],"names":[],"mappings":"AAupBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAiCnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,eAAe,EACf,iBAAiB,EAElB,MAAM,UAAU,CAAC;AAwpBlB,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AA2B/C,QAAA,MAAM,eAAe;;;;;;;;;;;wBAvuBrB,CArmByB;mBAqmBzB,CApmBkC;;;;aAomBlC,CAjmBoC;eAimBpC,CAjmB6D;wBAimB7D,CA/lBA;qBA+lBA,CA9lBY;;6EA40CV,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAa1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
+
import type { Interrupt, RunAgentResult } from "@ag-ui/client";
|
|
1
2
|
export interface InterruptEvent<TValue = unknown> {
|
|
2
3
|
name: string;
|
|
3
4
|
value: TValue;
|
|
4
5
|
}
|
|
6
|
+
export type InterruptResolveFn = (payload?: unknown, interruptId?: string) => Promise<RunAgentResult | void>;
|
|
7
|
+
export type InterruptCancelFn = (interruptId?: string) => Promise<RunAgentResult | void>;
|
|
5
8
|
export interface InterruptHandlerProps<TValue = unknown> {
|
|
6
9
|
event: InterruptEvent<TValue>;
|
|
7
|
-
|
|
10
|
+
interrupt: Interrupt | null;
|
|
11
|
+
interrupts: Interrupt[];
|
|
12
|
+
resolve: InterruptResolveFn;
|
|
13
|
+
cancel: InterruptCancelFn;
|
|
8
14
|
}
|
|
9
15
|
export interface InterruptRenderProps<TValue = unknown, TResult = unknown> {
|
|
10
16
|
event: InterruptEvent<TValue>;
|
|
17
|
+
interrupt: Interrupt | null;
|
|
18
|
+
interrupts: Interrupt[];
|
|
11
19
|
result: TResult;
|
|
12
|
-
resolve:
|
|
20
|
+
resolve: InterruptResolveFn;
|
|
21
|
+
cancel: InterruptCancelFn;
|
|
13
22
|
}
|
|
14
23
|
//# sourceMappingURL=interrupt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interrupt.d.ts","sourceRoot":"","sources":["../../../src/v2/types/interrupt.ts"],"names":[],"mappings":"AAAA,MAAM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,kBAAkB,CAAC;IAC5B,MAAM,EAAE,iBAAiB,CAAC;CAC3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/vue",
|
|
3
|
-
"version": "1.61.
|
|
3
|
+
"version": "1.61.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Vue 3 components and composables for CopilotKit",
|
|
6
6
|
"keywords": [
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"streamdown-vue": "^1.0.29",
|
|
71
71
|
"zod": "^3.25.75",
|
|
72
72
|
"zod-to-json-schema": "^3.24.5",
|
|
73
|
-
"@copilotkit/core": "1.61.
|
|
74
|
-
"@copilotkit/web-inspector": "1.61.
|
|
75
|
-
"@copilotkit/shared": "1.61.
|
|
73
|
+
"@copilotkit/core": "1.61.2",
|
|
74
|
+
"@copilotkit/web-inspector": "1.61.2",
|
|
75
|
+
"@copilotkit/shared": "1.61.2"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@eslint/js": "^9.39.2",
|
|
@@ -462,8 +462,11 @@ function resolveToolMessage(
|
|
|
462
462
|
v-if="interruptState"
|
|
463
463
|
name="interrupt"
|
|
464
464
|
:event="interruptState.event"
|
|
465
|
+
:interrupt="interruptState.interrupt"
|
|
466
|
+
:interrupts="interruptState.interrupts"
|
|
465
467
|
:result="interruptState.result"
|
|
466
468
|
:resolve="interruptState.resolve"
|
|
469
|
+
:cancel="interruptState.cancel"
|
|
467
470
|
/>
|
|
468
471
|
|
|
469
472
|
<slot v-if="showCursor" name="cursor">
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mount } from "@vue/test-utils";
|
|
2
2
|
import { computed, defineComponent, h, nextTick } from "vue";
|
|
3
3
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import type { Interrupt } from "@ag-ui/client";
|
|
4
5
|
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
5
6
|
import { useAgent } from "../use-agent";
|
|
6
7
|
import { useInterrupt } from "../use-interrupt";
|
|
@@ -16,11 +17,16 @@ vi.mock("../use-agent", () => ({
|
|
|
16
17
|
const mockUseCopilotKit = useCopilotKit as ReturnType<typeof vi.fn>;
|
|
17
18
|
const mockUseAgent = useAgent as ReturnType<typeof vi.fn>;
|
|
18
19
|
|
|
20
|
+
type RunFinishedParams =
|
|
21
|
+
| { outcome: "success"; result?: unknown }
|
|
22
|
+
| { outcome: "interrupt"; interrupts: Interrupt[] };
|
|
23
|
+
|
|
19
24
|
type SubscriptionHandlers = {
|
|
20
25
|
onCustomEvent?: (payload: {
|
|
21
26
|
event: { name: string; value: unknown };
|
|
22
27
|
}) => void;
|
|
23
28
|
onRunStartedEvent?: () => void;
|
|
29
|
+
onRunFinishedEvent?: (params: RunFinishedParams) => void;
|
|
24
30
|
onRunFinalized?: () => void;
|
|
25
31
|
onRunFailed?: () => void;
|
|
26
32
|
};
|
|
@@ -51,6 +57,7 @@ describe("useInterrupt", () => {
|
|
|
51
57
|
mockAgent = {
|
|
52
58
|
subscribe: subscribeMock,
|
|
53
59
|
id: "test-agent",
|
|
60
|
+
pendingInterrupts: [] as Interrupt[],
|
|
54
61
|
};
|
|
55
62
|
|
|
56
63
|
coreState = {
|
|
@@ -177,15 +184,24 @@ describe("useInterrupt", () => {
|
|
|
177
184
|
expect(wrapper.get("[data-testid=interrupt-state]").text()).toBe("idle");
|
|
178
185
|
});
|
|
179
186
|
|
|
180
|
-
it("resolve
|
|
187
|
+
it("resolve keeps card mounted until run starts, then resumes agent with response payload", async () => {
|
|
188
|
+
// Legacy resolve must NOT clear pending synchronously; it relies on
|
|
189
|
+
// onRunStartedEvent (fired by the resume run) to unmount the card —
|
|
190
|
+
// matching react-core's behavior.
|
|
181
191
|
const wrapper = mountHarness({ renderInChat: false });
|
|
182
192
|
|
|
183
193
|
emitInterrupt("approve-me");
|
|
184
194
|
await nextTick();
|
|
195
|
+
|
|
196
|
+
// Trigger resolve (click the interrupt card).
|
|
185
197
|
await wrapper.get("[data-testid=interrupt-state]").trigger("click");
|
|
186
198
|
await nextTick();
|
|
199
|
+
await Promise.resolve();
|
|
187
200
|
|
|
188
|
-
|
|
201
|
+
// Card must still be mounted — runAgent was dispatched but the run hasn't started yet.
|
|
202
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).not.toBe(
|
|
203
|
+
"idle",
|
|
204
|
+
);
|
|
189
205
|
expect(runAgentMock).toHaveBeenCalledWith({
|
|
190
206
|
agent: mockAgent,
|
|
191
207
|
forwardedProps: {
|
|
@@ -195,6 +211,11 @@ describe("useInterrupt", () => {
|
|
|
195
211
|
},
|
|
196
212
|
},
|
|
197
213
|
});
|
|
214
|
+
|
|
215
|
+
// Simulate the resume run starting — onRunStartedEvent clears pending.
|
|
216
|
+
handlers.onRunStartedEvent?.();
|
|
217
|
+
await nextTick();
|
|
218
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toBe("idle");
|
|
198
219
|
});
|
|
199
220
|
|
|
200
221
|
it("does not render and does not run handler when enabled returns false", async () => {
|
|
@@ -342,4 +363,168 @@ describe("useInterrupt", () => {
|
|
|
342
363
|
"second",
|
|
343
364
|
);
|
|
344
365
|
});
|
|
366
|
+
|
|
367
|
+
describe("AG-UI standard interrupts (vue)", () => {
|
|
368
|
+
const INT: Interrupt = {
|
|
369
|
+
id: "int-1",
|
|
370
|
+
reason: "confirmation",
|
|
371
|
+
message: "Approve?",
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
/** Mount a component that exposes resolve/cancel from slotProps. */
|
|
375
|
+
function mountStandardHarness() {
|
|
376
|
+
const Harness = defineComponent({
|
|
377
|
+
setup() {
|
|
378
|
+
const { slotProps } = useInterrupt({ renderInChat: false });
|
|
379
|
+
return () => {
|
|
380
|
+
const props = slotProps.value;
|
|
381
|
+
if (!props) return h("div", { "data-testid": "idle" }, "idle");
|
|
382
|
+
return h("div", { "data-testid": "active" }, [
|
|
383
|
+
h(
|
|
384
|
+
"button",
|
|
385
|
+
{
|
|
386
|
+
"data-testid": "resolve-btn",
|
|
387
|
+
onClick: () => void props.resolve({ ok: true }),
|
|
388
|
+
},
|
|
389
|
+
"resolve",
|
|
390
|
+
),
|
|
391
|
+
h(
|
|
392
|
+
"button",
|
|
393
|
+
{
|
|
394
|
+
"data-testid": "cancel-btn",
|
|
395
|
+
onClick: () => void props.cancel(),
|
|
396
|
+
},
|
|
397
|
+
"cancel",
|
|
398
|
+
),
|
|
399
|
+
]);
|
|
400
|
+
};
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
return mount(Harness);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/** Fire the standard interrupt sequence through the subscription handlers. */
|
|
407
|
+
function fireStandardInterrupt(interrupts: Interrupt[]) {
|
|
408
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
409
|
+
(mockAgent as any).pendingInterrupts = interrupts;
|
|
410
|
+
handlers.onRunStartedEvent?.();
|
|
411
|
+
handlers.onRunFinishedEvent?.({ outcome: "interrupt", interrupts });
|
|
412
|
+
handlers.onRunFinalized?.();
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
it("resolveInterrupt resumes with a resolved ResumeEntry", async () => {
|
|
416
|
+
runAgentMock.mockResolvedValue({ result: undefined, newMessages: [] });
|
|
417
|
+
const wrapper = mountStandardHarness();
|
|
418
|
+
|
|
419
|
+
fireStandardInterrupt([INT]);
|
|
420
|
+
await nextTick();
|
|
421
|
+
|
|
422
|
+
// Click the resolve button (which calls props.resolve({ ok: true }))
|
|
423
|
+
await wrapper.get("[data-testid=resolve-btn]").trigger("click");
|
|
424
|
+
await nextTick();
|
|
425
|
+
await Promise.resolve();
|
|
426
|
+
await nextTick();
|
|
427
|
+
|
|
428
|
+
expect(runAgentMock).toHaveBeenCalledWith({
|
|
429
|
+
agent: mockAgent,
|
|
430
|
+
resume: [
|
|
431
|
+
{ interruptId: "int-1", status: "resolved", payload: { ok: true } },
|
|
432
|
+
],
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
it("cancelInterrupt resumes with a cancelled ResumeEntry (no payload)", async () => {
|
|
437
|
+
runAgentMock.mockResolvedValue({ result: undefined, newMessages: [] });
|
|
438
|
+
const wrapper = mountStandardHarness();
|
|
439
|
+
|
|
440
|
+
fireStandardInterrupt([INT]);
|
|
441
|
+
await nextTick();
|
|
442
|
+
|
|
443
|
+
// Click the cancel button (which calls props.cancel())
|
|
444
|
+
await wrapper.get("[data-testid=cancel-btn]").trigger("click");
|
|
445
|
+
await nextTick();
|
|
446
|
+
await Promise.resolve();
|
|
447
|
+
await nextTick();
|
|
448
|
+
|
|
449
|
+
expect(runAgentMock).toHaveBeenCalledWith({
|
|
450
|
+
agent: mockAgent,
|
|
451
|
+
resume: [{ interruptId: "int-1", status: "cancelled" }],
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it("warns when resolve is called without interruptId while multiple interrupts are open", async () => {
|
|
456
|
+
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
457
|
+
const INT2: Interrupt = { id: "int-2", reason: "confirmation" };
|
|
458
|
+
|
|
459
|
+
let capturedResolve: ((payload?: unknown) => void) | undefined;
|
|
460
|
+
const Harness = defineComponent({
|
|
461
|
+
setup() {
|
|
462
|
+
const { slotProps } = useInterrupt({ renderInChat: false });
|
|
463
|
+
capturedResolve = (payload?: unknown) =>
|
|
464
|
+
void slotProps.value?.resolve(payload);
|
|
465
|
+
return () => h("div");
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
mount(Harness);
|
|
469
|
+
|
|
470
|
+
// Fire standard interrupt with 2 open interrupts.
|
|
471
|
+
fireStandardInterrupt([INT, INT2]);
|
|
472
|
+
await nextTick();
|
|
473
|
+
|
|
474
|
+
// Call resolve without an interruptId while 2 interrupts are open.
|
|
475
|
+
await capturedResolve?.({ a: 1 });
|
|
476
|
+
await nextTick();
|
|
477
|
+
await Promise.resolve();
|
|
478
|
+
|
|
479
|
+
// Warning must have fired.
|
|
480
|
+
expect(warnSpy).toHaveBeenCalledWith(
|
|
481
|
+
expect.stringContaining("2 interrupts are open"),
|
|
482
|
+
);
|
|
483
|
+
// Only primary addressed — runAgent must NOT have been called yet.
|
|
484
|
+
expect(runAgentMock).not.toHaveBeenCalled();
|
|
485
|
+
|
|
486
|
+
warnSpy.mockRestore();
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it("legacy on_interrupt still resumes via forwardedProps.command", async () => {
|
|
490
|
+
runAgentMock.mockResolvedValue({ result: undefined, newMessages: [] });
|
|
491
|
+
|
|
492
|
+
// Use resolveInterrupt directly from the composable for the legacy path.
|
|
493
|
+
let capturedResolve: ((payload: unknown) => void) | undefined;
|
|
494
|
+
const Harness = defineComponent({
|
|
495
|
+
setup() {
|
|
496
|
+
const { slotProps, resolveInterrupt } = useInterrupt({
|
|
497
|
+
renderInChat: false,
|
|
498
|
+
});
|
|
499
|
+
capturedResolve = resolveInterrupt;
|
|
500
|
+
return () => {
|
|
501
|
+
const props = slotProps.value;
|
|
502
|
+
if (!props) return h("div", { "data-testid": "idle" }, "idle");
|
|
503
|
+
return h("div", { "data-testid": "active" }, "active");
|
|
504
|
+
};
|
|
505
|
+
},
|
|
506
|
+
});
|
|
507
|
+
mount(Harness);
|
|
508
|
+
|
|
509
|
+
// Fire legacy on_interrupt path
|
|
510
|
+
handlers.onRunStartedEvent?.();
|
|
511
|
+
handlers.onCustomEvent?.({
|
|
512
|
+
event: { name: "on_interrupt", value: "q?" },
|
|
513
|
+
});
|
|
514
|
+
handlers.onRunFinalized?.();
|
|
515
|
+
await nextTick();
|
|
516
|
+
|
|
517
|
+
// Call resolve with legacy payload
|
|
518
|
+
await capturedResolve?.({ approved: true });
|
|
519
|
+
await nextTick();
|
|
520
|
+
await Promise.resolve();
|
|
521
|
+
|
|
522
|
+
expect(runAgentMock).toHaveBeenCalledWith({
|
|
523
|
+
agent: mockAgent,
|
|
524
|
+
forwardedProps: {
|
|
525
|
+
command: { resume: { approved: true }, interruptEvent: "q?" },
|
|
526
|
+
},
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
});
|
|
345
530
|
});
|