@copilotkit/vue 1.70.3 → 1.71.1

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.
@@ -1,6 +1,7 @@
1
1
  import { onScopeDispose, ref } from "vue";
2
2
  import type { WatchSource } from "vue";
3
3
  import { h } from "vue";
4
+ import { ToolCallStatus } from "@copilotkit/core";
4
5
  import { useCopilotKit } from "../providers/useCopilotKit";
5
6
  import { useFrontendTool } from "./use-frontend-tool";
6
7
  import type {
@@ -31,17 +32,44 @@ export function useHumanInTheLoop<T extends Record<string, unknown>>(
31
32
  ) {
32
33
  const { copilotkit } = useCopilotKit();
33
34
  const resolvePromiseRef = ref<((result: unknown) => void) | null>(null);
35
+ const rejectPromiseRef = ref<((error: unknown) => void) | null>(null);
36
+ const cleanupAbortRef = ref<(() => void) | null>(null);
34
37
 
35
38
  const respond = async (result: unknown) => {
36
39
  if (resolvePromiseRef.value) {
40
+ cleanupAbortRef.value?.();
41
+ cleanupAbortRef.value = null;
37
42
  resolvePromiseRef.value(result);
38
43
  resolvePromiseRef.value = null;
44
+ rejectPromiseRef.value = null;
39
45
  }
40
46
  };
41
47
 
42
- const handler = async () => {
43
- return new Promise((resolve) => {
48
+ const handler = async (_args: T, context?: { signal?: AbortSignal }) => {
49
+ const signal = context?.signal;
50
+ return new Promise((resolve, reject) => {
51
+ if (signal?.aborted) {
52
+ reject(new Error("Human-in-the-loop interaction aborted"));
53
+ return;
54
+ }
55
+
44
56
  resolvePromiseRef.value = resolve;
57
+ rejectPromiseRef.value = reject;
58
+
59
+ if (signal) {
60
+ const onAbort = () => {
61
+ cleanupAbortRef.value = null;
62
+ resolvePromiseRef.value = null;
63
+ const rejectPending = rejectPromiseRef.value;
64
+ rejectPromiseRef.value = null;
65
+ rejectPending?.(new Error("Human-in-the-loop interaction aborted"));
66
+ };
67
+
68
+ signal.addEventListener("abort", onAbort, { once: true });
69
+ cleanupAbortRef.value = () => {
70
+ signal.removeEventListener("abort", onAbort);
71
+ };
72
+ }
45
73
  });
46
74
  };
47
75
 
@@ -49,31 +77,36 @@ export function useHumanInTheLoop<T extends Record<string, unknown>>(
49
77
  props: VueToolCallRendererRenderProps<T>,
50
78
  ) => {
51
79
  const ToolComponent = tool.render;
52
- if (props.status === "inProgress") {
80
+ if (props.status === ToolCallStatus.InProgress) {
53
81
  return h(ToolComponent as Parameters<typeof h>[0], {
54
82
  ...props,
55
83
  name: tool.name,
56
84
  description: tool.description || "",
85
+ agentId: tool.agentId,
57
86
  respond: undefined,
58
87
  });
59
88
  }
60
- if (props.status === "executing") {
89
+ if (props.status === ToolCallStatus.Executing) {
61
90
  return h(ToolComponent as Parameters<typeof h>[0], {
62
91
  ...props,
63
92
  name: tool.name,
64
93
  description: tool.description || "",
94
+ agentId: tool.agentId,
65
95
  respond,
66
96
  });
67
97
  }
68
- if (props.status === "complete") {
98
+ if (props.status === ToolCallStatus.Complete) {
69
99
  return h(ToolComponent as Parameters<typeof h>[0], {
70
100
  ...props,
71
101
  name: tool.name,
72
102
  description: tool.description || "",
103
+ agentId: tool.agentId,
73
104
  respond: undefined,
74
105
  });
75
106
  }
76
- return h(ToolComponent as Parameters<typeof h>[0], props);
107
+
108
+ const exhaustiveCheck: never = props;
109
+ return exhaustiveCheck;
77
110
  };
78
111
 
79
112
  const frontendTool: VueFrontendTool<T> = {
@@ -5,6 +5,8 @@ export type VueHumanInTheLoopRenderProps<T> =
5
5
  | {
6
6
  name: string;
7
7
  description: string;
8
+ toolCallId: string;
9
+ agentId?: string;
8
10
  args: Partial<T>;
9
11
  status: ToolCallStatus.InProgress;
10
12
  result: undefined;
@@ -13,6 +15,8 @@ export type VueHumanInTheLoopRenderProps<T> =
13
15
  | {
14
16
  name: string;
15
17
  description: string;
18
+ toolCallId: string;
19
+ agentId?: string;
16
20
  args: T;
17
21
  status: ToolCallStatus.Executing;
18
22
  result: undefined;
@@ -21,6 +25,8 @@ export type VueHumanInTheLoopRenderProps<T> =
21
25
  | {
22
26
  name: string;
23
27
  description: string;
28
+ toolCallId: string;
29
+ agentId?: string;
24
30
  args: T;
25
31
  status: ToolCallStatus.Complete;
26
32
  result: string;
package/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- # Changelog
2
-
3
- ## [1.51.4-next.2] - Unreleased
4
-
5
- ### Added
6
-
7
- - Initial v1 release: Vue 3 core providers and composables
8
- - `CopilotKitProvider` and `CopilotChatConfigurationProvider` (SFC-based)
9
- - `useCopilotKit`, `useCopilotChatConfiguration`
10
- - Composables: `useAgent`, `useFrontendTool`, `useHumanInTheLoop`, `useSuggestions`, `useConfigureSuggestions`, `useAgentContext`
11
- - Vue renderer types: `VueToolCallRenderer`, `VueActivityMessageRenderer`, `VueCustomMessageRenderer`, `VueFrontendTool`, `VueHumanInTheLoop`
12
- - `defineToolCallRenderer` (Vue version)
13
- - `CopilotKitCoreVue` - core subclass with `setRenderToolCalls` and `onRenderToolCallsChanged`