@assistant-ui/react-a2a 0.1.4 → 0.1.6
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/A2AMessageAccumulator.js +26 -32
- package/dist/A2AMessageAccumulator.js.map +1 -1
- package/dist/appendA2AChunk.d.ts +1 -1
- package/dist/appendA2AChunk.d.ts.map +1 -1
- package/dist/appendA2AChunk.js +102 -82
- package/dist/appendA2AChunk.js.map +1 -1
- package/dist/convertA2AMessages.d.ts +1 -1
- package/dist/convertA2AMessages.d.ts.map +1 -1
- package/dist/convertA2AMessages.js +82 -85
- package/dist/convertA2AMessages.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/testUtils.d.ts +2 -2
- package/dist/testUtils.d.ts.map +1 -1
- package/dist/testUtils.js +4 -8
- package/dist/testUtils.js.map +1 -1
- package/dist/types.js +9 -13
- package/dist/types.js.map +1 -1
- package/dist/useA2AMessages.d.ts +1 -1
- package/dist/useA2AMessages.d.ts.map +1 -1
- package/dist/useA2AMessages.js +115 -127
- package/dist/useA2AMessages.js.map +1 -1
- package/dist/useA2ARuntime.d.ts +1 -1
- package/dist/useA2ARuntime.d.ts.map +1 -1
- package/dist/useA2ARuntime.js +174 -201
- package/dist/useA2ARuntime.js.map +1 -1
- package/package.json +23 -19
package/dist/useA2ARuntime.js
CHANGED
|
@@ -1,215 +1,188 @@
|
|
|
1
|
-
// src/useA2ARuntime.ts
|
|
2
1
|
import { useEffect, useRef, useState } from "react";
|
|
3
|
-
import {
|
|
4
|
-
useExternalMessageConverter,
|
|
5
|
-
useExternalStoreRuntime,
|
|
6
|
-
useThread,
|
|
7
|
-
useThreadListItemRuntime
|
|
8
|
-
} from "@assistant-ui/react";
|
|
2
|
+
import { useExternalMessageConverter, useExternalStoreRuntime, useThread, useThreadListItemRuntime, } from "@assistant-ui/react";
|
|
9
3
|
import { convertA2AMessage } from "./convertA2AMessages.js";
|
|
10
4
|
import { useA2AMessages } from "./useA2AMessages.js";
|
|
11
5
|
import { appendA2AChunk } from "./appendA2AChunk.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
const getPendingToolCalls = (messages) => {
|
|
7
|
+
const pendingToolCalls = new Map();
|
|
8
|
+
for (const message of messages) {
|
|
9
|
+
if (message.role === "assistant") {
|
|
10
|
+
for (const toolCall of message.tool_calls ?? []) {
|
|
11
|
+
pendingToolCalls.set(toolCall.id, toolCall);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (message.role === "tool") {
|
|
15
|
+
pendingToolCalls.delete(message.tool_call_id);
|
|
16
|
+
}
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
pendingToolCalls.delete(message.tool_call_id);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return [...pendingToolCalls.values()];
|
|
18
|
+
return [...pendingToolCalls.values()];
|
|
25
19
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
const getMessageContent = (msg) => {
|
|
21
|
+
const allContent = [
|
|
22
|
+
...msg.content,
|
|
23
|
+
...(msg.attachments?.flatMap((a) => a.content) ?? []),
|
|
24
|
+
];
|
|
25
|
+
const content = allContent.map((part) => {
|
|
26
|
+
const type = part.type;
|
|
27
|
+
switch (type) {
|
|
28
|
+
case "text":
|
|
29
|
+
return { type: "text", text: part.text };
|
|
30
|
+
case "image":
|
|
31
|
+
return { type: "image_url", image_url: { url: part.image } };
|
|
32
|
+
case "tool-call":
|
|
33
|
+
throw new Error("Tool call appends are not supported.");
|
|
34
|
+
default:
|
|
35
|
+
const _exhaustiveCheck = type;
|
|
36
|
+
throw new Error(`Unsupported append message part type: ${_exhaustiveCheck}`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (content.length === 1 && content[0]?.type === "text") {
|
|
40
|
+
return content[0].text ?? "";
|
|
45
41
|
}
|
|
46
|
-
|
|
47
|
-
if (content.length === 1 && content[0]?.type === "text") {
|
|
48
|
-
return content[0].text ?? "";
|
|
49
|
-
}
|
|
50
|
-
return content;
|
|
51
|
-
};
|
|
52
|
-
var symbolA2ARuntimeExtras = /* @__PURE__ */ Symbol("a2a-runtime-extras");
|
|
53
|
-
var asA2ARuntimeExtras = (extras) => {
|
|
54
|
-
if (typeof extras !== "object" || extras == null || !(symbolA2ARuntimeExtras in extras))
|
|
55
|
-
throw new Error(
|
|
56
|
-
"This method can only be called when you are using useA2ARuntime"
|
|
57
|
-
);
|
|
58
|
-
return extras;
|
|
42
|
+
return content;
|
|
59
43
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
const symbolA2ARuntimeExtras = Symbol("a2a-runtime-extras");
|
|
45
|
+
const asA2ARuntimeExtras = (extras) => {
|
|
46
|
+
if (typeof extras !== "object" ||
|
|
47
|
+
extras == null ||
|
|
48
|
+
!(symbolA2ARuntimeExtras in extras))
|
|
49
|
+
throw new Error("This method can only be called when you are using useA2ARuntime");
|
|
50
|
+
return extras;
|
|
63
51
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
export const useA2ATaskState = () => {
|
|
53
|
+
const { taskState } = useThread((t) => asA2ARuntimeExtras(t.extras));
|
|
54
|
+
return taskState;
|
|
67
55
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
export const useA2AArtifacts = () => {
|
|
57
|
+
const { artifacts } = useThread((t) => asA2ARuntimeExtras(t.extras));
|
|
58
|
+
return artifacts;
|
|
71
59
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
unstable_allowCancellation,
|
|
76
|
-
stream,
|
|
77
|
-
contextId,
|
|
78
|
-
onSwitchToNewThread,
|
|
79
|
-
onSwitchToThread,
|
|
80
|
-
eventHandlers
|
|
81
|
-
}) => {
|
|
82
|
-
const {
|
|
83
|
-
taskState,
|
|
84
|
-
artifacts,
|
|
85
|
-
setArtifacts,
|
|
86
|
-
messages,
|
|
87
|
-
sendMessage,
|
|
88
|
-
cancel,
|
|
89
|
-
setMessages
|
|
90
|
-
} = useA2AMessages({
|
|
91
|
-
appendMessage: appendA2AChunk,
|
|
92
|
-
stream,
|
|
93
|
-
...eventHandlers && { eventHandlers }
|
|
94
|
-
});
|
|
95
|
-
const [isRunning, setIsRunning] = useState(false);
|
|
96
|
-
const handleSendMessage = async (messages2, config) => {
|
|
97
|
-
try {
|
|
98
|
-
setIsRunning(true);
|
|
99
|
-
await sendMessage(messages2, config);
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.error("Error streaming A2A messages:", error);
|
|
102
|
-
} finally {
|
|
103
|
-
setIsRunning(false);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
const threadMessages = useExternalMessageConverter({
|
|
107
|
-
callback: convertA2AMessage,
|
|
108
|
-
messages,
|
|
109
|
-
isRunning
|
|
110
|
-
});
|
|
111
|
-
const switchToThread = !onSwitchToThread ? void 0 : async (externalId) => {
|
|
112
|
-
const { messages: messages2, artifacts: artifacts2 } = await onSwitchToThread(externalId);
|
|
113
|
-
setMessages(messages2);
|
|
114
|
-
if (artifacts2) {
|
|
115
|
-
setArtifacts(artifacts2);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
const threadList = {
|
|
119
|
-
threadId: contextId,
|
|
120
|
-
onSwitchToNewThread: !onSwitchToNewThread ? void 0 : async () => {
|
|
121
|
-
await onSwitchToNewThread();
|
|
122
|
-
setMessages([]);
|
|
123
|
-
setArtifacts([]);
|
|
124
|
-
},
|
|
125
|
-
onSwitchToThread: switchToThread
|
|
126
|
-
};
|
|
127
|
-
const loadingRef = useRef(false);
|
|
128
|
-
const threadListItemRuntime = useThreadListItemRuntime({ optional: true });
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (!threadListItemRuntime || !switchToThread || loadingRef.current) return;
|
|
131
|
-
const externalId = threadListItemRuntime.getState().externalId;
|
|
132
|
-
if (externalId) {
|
|
133
|
-
loadingRef.current = true;
|
|
134
|
-
switchToThread(externalId).finally(() => {
|
|
135
|
-
loadingRef.current = false;
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}, []);
|
|
139
|
-
return useExternalStoreRuntime({
|
|
140
|
-
isRunning,
|
|
141
|
-
messages: threadMessages,
|
|
142
|
-
adapters: {
|
|
143
|
-
attachments,
|
|
144
|
-
feedback,
|
|
145
|
-
speech,
|
|
146
|
-
threadList
|
|
147
|
-
},
|
|
148
|
-
extras: {
|
|
149
|
-
[symbolA2ARuntimeExtras]: true,
|
|
150
|
-
taskState,
|
|
151
|
-
artifacts,
|
|
152
|
-
send: handleSendMessage
|
|
153
|
-
},
|
|
154
|
-
onNew: (msg) => {
|
|
155
|
-
const cancellations = autoCancelPendingToolCalls !== false ? getPendingToolCalls(messages).map(
|
|
156
|
-
(t) => ({
|
|
157
|
-
role: "tool",
|
|
158
|
-
tool_call_id: t.id,
|
|
159
|
-
content: JSON.stringify({ cancelled: true }),
|
|
160
|
-
status: {
|
|
161
|
-
type: "incomplete",
|
|
162
|
-
reason: "cancelled"
|
|
163
|
-
}
|
|
164
|
-
})
|
|
165
|
-
) : [];
|
|
166
|
-
const config = {};
|
|
167
|
-
if (contextId !== void 0) config.contextId = contextId;
|
|
168
|
-
if (msg.runConfig !== void 0) config.runConfig = msg.runConfig;
|
|
169
|
-
return handleSendMessage(
|
|
170
|
-
[
|
|
171
|
-
...cancellations,
|
|
172
|
-
{
|
|
173
|
-
role: "user",
|
|
174
|
-
content: getMessageContent(msg)
|
|
175
|
-
}
|
|
176
|
-
],
|
|
177
|
-
config
|
|
178
|
-
);
|
|
179
|
-
},
|
|
180
|
-
onAddToolResult: async ({
|
|
181
|
-
toolCallId,
|
|
182
|
-
toolName: _toolName,
|
|
183
|
-
result,
|
|
184
|
-
isError,
|
|
185
|
-
artifact
|
|
186
|
-
}) => {
|
|
187
|
-
const message = {
|
|
188
|
-
role: "tool",
|
|
189
|
-
tool_call_id: toolCallId,
|
|
190
|
-
content: JSON.stringify(result),
|
|
191
|
-
status: isError ? { type: "incomplete", reason: "error" } : { type: "complete", reason: "stop" }
|
|
192
|
-
};
|
|
193
|
-
if (artifact) {
|
|
194
|
-
message.artifacts = [artifact];
|
|
195
|
-
}
|
|
196
|
-
const config = {};
|
|
197
|
-
if (contextId !== void 0) config.contextId = contextId;
|
|
198
|
-
await handleSendMessage(
|
|
199
|
-
[message],
|
|
200
|
-
// TODO reuse runconfig here!
|
|
201
|
-
config
|
|
202
|
-
);
|
|
203
|
-
},
|
|
204
|
-
onCancel: unstable_allowCancellation ? async () => {
|
|
205
|
-
cancel();
|
|
206
|
-
} : void 0
|
|
207
|
-
});
|
|
60
|
+
export const useA2ASend = () => {
|
|
61
|
+
const { send } = useThread((t) => asA2ARuntimeExtras(t.extras));
|
|
62
|
+
return send;
|
|
208
63
|
};
|
|
209
|
-
export {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
64
|
+
export const useA2ARuntime = ({ autoCancelPendingToolCalls, adapters: { attachments, feedback, speech } = {}, unstable_allowCancellation, stream, contextId, onSwitchToNewThread, onSwitchToThread, eventHandlers, }) => {
|
|
65
|
+
const { taskState, artifacts, setArtifacts, messages, sendMessage, cancel, setMessages, } = useA2AMessages({
|
|
66
|
+
appendMessage: appendA2AChunk,
|
|
67
|
+
stream,
|
|
68
|
+
...(eventHandlers && { eventHandlers }),
|
|
69
|
+
});
|
|
70
|
+
const [isRunning, setIsRunning] = useState(false);
|
|
71
|
+
const handleSendMessage = async (messages, config) => {
|
|
72
|
+
try {
|
|
73
|
+
setIsRunning(true);
|
|
74
|
+
await sendMessage(messages, config);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error("Error streaming A2A messages:", error);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
setIsRunning(false);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const threadMessages = useExternalMessageConverter({
|
|
84
|
+
callback: convertA2AMessage,
|
|
85
|
+
messages,
|
|
86
|
+
isRunning,
|
|
87
|
+
});
|
|
88
|
+
const switchToThread = !onSwitchToThread
|
|
89
|
+
? undefined
|
|
90
|
+
: async (externalId) => {
|
|
91
|
+
const { messages, artifacts } = await onSwitchToThread(externalId);
|
|
92
|
+
setMessages(messages);
|
|
93
|
+
if (artifacts) {
|
|
94
|
+
setArtifacts(artifacts);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const threadList = {
|
|
98
|
+
threadId: contextId,
|
|
99
|
+
onSwitchToNewThread: !onSwitchToNewThread
|
|
100
|
+
? undefined
|
|
101
|
+
: async () => {
|
|
102
|
+
await onSwitchToNewThread();
|
|
103
|
+
setMessages([]);
|
|
104
|
+
setArtifacts([]);
|
|
105
|
+
},
|
|
106
|
+
onSwitchToThread: switchToThread,
|
|
107
|
+
};
|
|
108
|
+
const loadingRef = useRef(false);
|
|
109
|
+
const threadListItemRuntime = useThreadListItemRuntime({ optional: true });
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (!threadListItemRuntime || !switchToThread || loadingRef.current)
|
|
112
|
+
return;
|
|
113
|
+
const externalId = threadListItemRuntime.getState().externalId;
|
|
114
|
+
if (externalId) {
|
|
115
|
+
loadingRef.current = true;
|
|
116
|
+
switchToThread(externalId).finally(() => {
|
|
117
|
+
loadingRef.current = false;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, []);
|
|
121
|
+
return useExternalStoreRuntime({
|
|
122
|
+
isRunning,
|
|
123
|
+
messages: threadMessages,
|
|
124
|
+
adapters: {
|
|
125
|
+
attachments,
|
|
126
|
+
feedback,
|
|
127
|
+
speech,
|
|
128
|
+
threadList,
|
|
129
|
+
},
|
|
130
|
+
extras: {
|
|
131
|
+
[symbolA2ARuntimeExtras]: true,
|
|
132
|
+
taskState,
|
|
133
|
+
artifacts,
|
|
134
|
+
send: handleSendMessage,
|
|
135
|
+
},
|
|
136
|
+
onNew: (msg) => {
|
|
137
|
+
const cancellations = autoCancelPendingToolCalls !== false
|
|
138
|
+
? getPendingToolCalls(messages).map((t) => ({
|
|
139
|
+
role: "tool",
|
|
140
|
+
tool_call_id: t.id,
|
|
141
|
+
content: JSON.stringify({ cancelled: true }),
|
|
142
|
+
status: {
|
|
143
|
+
type: "incomplete",
|
|
144
|
+
reason: "cancelled",
|
|
145
|
+
},
|
|
146
|
+
}))
|
|
147
|
+
: [];
|
|
148
|
+
const config = {};
|
|
149
|
+
if (contextId !== undefined)
|
|
150
|
+
config.contextId = contextId;
|
|
151
|
+
if (msg.runConfig !== undefined)
|
|
152
|
+
config.runConfig = msg.runConfig;
|
|
153
|
+
return handleSendMessage([
|
|
154
|
+
...cancellations,
|
|
155
|
+
{
|
|
156
|
+
role: "user",
|
|
157
|
+
content: getMessageContent(msg),
|
|
158
|
+
},
|
|
159
|
+
], config);
|
|
160
|
+
},
|
|
161
|
+
onAddToolResult: async ({ toolCallId, toolName: _toolName, result, isError, artifact, }) => {
|
|
162
|
+
// TODO parallel human in the loop calls
|
|
163
|
+
const message = {
|
|
164
|
+
role: "tool",
|
|
165
|
+
tool_call_id: toolCallId,
|
|
166
|
+
content: JSON.stringify(result),
|
|
167
|
+
status: isError
|
|
168
|
+
? { type: "incomplete", reason: "error" }
|
|
169
|
+
: { type: "complete", reason: "stop" },
|
|
170
|
+
};
|
|
171
|
+
if (artifact) {
|
|
172
|
+
message.artifacts = [artifact];
|
|
173
|
+
}
|
|
174
|
+
const config = {};
|
|
175
|
+
if (contextId !== undefined)
|
|
176
|
+
config.contextId = contextId;
|
|
177
|
+
await handleSendMessage([message],
|
|
178
|
+
// TODO reuse runconfig here!
|
|
179
|
+
config);
|
|
180
|
+
},
|
|
181
|
+
onCancel: unstable_allowCancellation
|
|
182
|
+
? async () => {
|
|
183
|
+
cancel();
|
|
184
|
+
}
|
|
185
|
+
: undefined,
|
|
186
|
+
});
|
|
214
187
|
};
|
|
215
188
|
//# sourceMappingURL=useA2ARuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useA2ARuntime.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport {\n A2AMessage,\n A2AToolCall,\n A2AArtifact,\n A2ATaskState,\n A2ASendMessageConfig,\n A2AStreamCallback,\n OnTaskUpdateEventCallback,\n OnArtifactsEventCallback,\n OnErrorEventCallback,\n OnStateUpdateEventCallback,\n OnCustomEventCallback,\n} from \"./types\";\nimport {\n useExternalMessageConverter,\n useExternalStoreRuntime,\n useThread,\n useThreadListItemRuntime,\n} from \"@assistant-ui/react\";\nimport { convertA2AMessage } from \"./convertA2AMessages\";\nimport { useA2AMessages } from \"./useA2AMessages\";\nimport { AttachmentAdapter } from \"@assistant-ui/react\";\nimport { AppendMessage } from \"@assistant-ui/react\";\nimport { ExternalStoreAdapter } from \"@assistant-ui/react\";\nimport { FeedbackAdapter } from \"@assistant-ui/react\";\nimport { SpeechSynthesisAdapter } from \"@assistant-ui/react\";\nimport { appendA2AChunk } from \"./appendA2AChunk\";\n\nconst getPendingToolCalls = (messages: A2AMessage[]) => {\n const pendingToolCalls = new Map<string, A2AToolCall>();\n for (const message of messages) {\n if (message.role === \"assistant\") {\n for (const toolCall of message.tool_calls ?? []) {\n pendingToolCalls.set(toolCall.id, toolCall);\n }\n }\n if (message.role === \"tool\") {\n pendingToolCalls.delete(message.tool_call_id!);\n }\n }\n\n return [...pendingToolCalls.values()];\n};\n\nconst getMessageContent = (msg: AppendMessage) => {\n const allContent = [\n ...msg.content,\n ...(msg.attachments?.flatMap((a) => a.content) ?? []),\n ];\n const content = allContent.map((part) => {\n const type = part.type;\n switch (type) {\n case \"text\":\n return { type: \"text\" as const, text: part.text };\n case \"image\":\n return { type: \"image_url\" as const, image_url: { url: part.image } };\n\n case \"tool-call\":\n throw new Error(\"Tool call appends are not supported.\");\n\n default:\n const _exhaustiveCheck:\n | \"reasoning\"\n | \"source\"\n | \"file\"\n | \"audio\"\n | \"data\" = type;\n throw new Error(\n `Unsupported append message part type: ${_exhaustiveCheck}`,\n );\n }\n });\n\n if (content.length === 1 && content[0]?.type === \"text\") {\n return content[0].text ?? \"\";\n }\n\n return content;\n};\n\nconst symbolA2ARuntimeExtras = Symbol(\"a2a-runtime-extras\");\ntype A2ARuntimeExtras = {\n [symbolA2ARuntimeExtras]: true;\n send: (messages: A2AMessage[], config: A2ASendMessageConfig) => Promise<void>;\n taskState: A2ATaskState | undefined;\n artifacts: A2AArtifact[];\n};\n\nconst asA2ARuntimeExtras = (extras: unknown): A2ARuntimeExtras => {\n if (\n typeof extras !== \"object\" ||\n extras == null ||\n !(symbolA2ARuntimeExtras in extras)\n )\n throw new Error(\n \"This method can only be called when you are using useA2ARuntime\",\n );\n\n return extras as A2ARuntimeExtras;\n};\n\nexport const useA2ATaskState = () => {\n const { taskState } = useThread((t) => asA2ARuntimeExtras(t.extras));\n return taskState;\n};\n\nexport const useA2AArtifacts = () => {\n const { artifacts } = useThread((t) => asA2ARuntimeExtras(t.extras));\n return artifacts;\n};\n\nexport const useA2ASend = () => {\n const { send } = useThread((t) => asA2ARuntimeExtras(t.extras));\n return send;\n};\n\nexport const useA2ARuntime = ({\n autoCancelPendingToolCalls,\n adapters: { attachments, feedback, speech } = {},\n unstable_allowCancellation,\n stream,\n contextId,\n onSwitchToNewThread,\n onSwitchToThread,\n eventHandlers,\n}: {\n /**\n * @deprecated For thread management use `useCloudThreadListRuntime` instead. This option will be removed in a future version.\n */\n contextId?: string | undefined;\n autoCancelPendingToolCalls?: boolean | undefined;\n unstable_allowCancellation?: boolean | undefined;\n stream: A2AStreamCallback<A2AMessage>;\n /**\n * @deprecated For thread management use `useCloudThreadListRuntime` instead. This option will be removed in a future version.\n */\n onSwitchToNewThread?: () => Promise<void> | void;\n onSwitchToThread?: (contextId: string) => Promise<{\n messages: A2AMessage[];\n artifacts?: A2AArtifact[];\n }>;\n adapters?:\n | {\n attachments?: AttachmentAdapter;\n speech?: SpeechSynthesisAdapter;\n feedback?: FeedbackAdapter;\n }\n | undefined;\n /**\n * Event handlers for various A2A stream events\n */\n eventHandlers?:\n | {\n /**\n * Called when task updates are received from the A2A stream\n */\n onTaskUpdate?: OnTaskUpdateEventCallback;\n /**\n * Called when artifacts are received from the A2A stream\n */\n onArtifacts?: OnArtifactsEventCallback;\n /**\n * Called when errors occur during A2A stream processing\n */\n onError?: OnErrorEventCallback;\n /**\n * Called when state updates are received from the A2A stream\n */\n onStateUpdate?: OnStateUpdateEventCallback;\n /**\n * Called when custom events are received from the A2A stream\n */\n onCustomEvent?: OnCustomEventCallback;\n }\n | undefined;\n}) => {\n const {\n taskState,\n artifacts,\n setArtifacts,\n messages,\n sendMessage,\n cancel,\n setMessages,\n } = useA2AMessages({\n appendMessage: appendA2AChunk,\n stream,\n ...(eventHandlers && { eventHandlers }),\n });\n\n const [isRunning, setIsRunning] = useState(false);\n const handleSendMessage = async (\n messages: A2AMessage[],\n config: A2ASendMessageConfig,\n ) => {\n try {\n setIsRunning(true);\n await sendMessage(messages, config);\n } catch (error) {\n console.error(\"Error streaming A2A messages:\", error);\n } finally {\n setIsRunning(false);\n }\n };\n\n const threadMessages = useExternalMessageConverter({\n callback: convertA2AMessage,\n messages,\n isRunning,\n });\n\n const switchToThread = !onSwitchToThread\n ? undefined\n : async (externalId: string) => {\n const { messages, artifacts } = await onSwitchToThread(externalId);\n setMessages(messages);\n if (artifacts) {\n setArtifacts(artifacts);\n }\n };\n\n const threadList: NonNullable<\n ExternalStoreAdapter[\"adapters\"]\n >[\"threadList\"] = {\n threadId: contextId,\n onSwitchToNewThread: !onSwitchToNewThread\n ? undefined\n : async () => {\n await onSwitchToNewThread();\n setMessages([]);\n setArtifacts([]);\n },\n onSwitchToThread: switchToThread,\n };\n\n const loadingRef = useRef(false);\n const threadListItemRuntime = useThreadListItemRuntime({ optional: true });\n useEffect(() => {\n if (!threadListItemRuntime || !switchToThread || loadingRef.current) return;\n\n const externalId = threadListItemRuntime.getState().externalId;\n if (externalId) {\n loadingRef.current = true;\n switchToThread(externalId).finally(() => {\n loadingRef.current = false;\n });\n }\n }, []);\n\n return useExternalStoreRuntime({\n isRunning,\n messages: threadMessages,\n adapters: {\n attachments,\n feedback,\n speech,\n threadList,\n },\n extras: {\n [symbolA2ARuntimeExtras]: true,\n taskState,\n artifacts,\n send: handleSendMessage,\n } satisfies A2ARuntimeExtras,\n onNew: (msg) => {\n const cancellations =\n autoCancelPendingToolCalls !== false\n ? getPendingToolCalls(messages).map(\n (t) =>\n ({\n role: \"tool\",\n tool_call_id: t.id,\n content: JSON.stringify({ cancelled: true }),\n status: {\n type: \"incomplete\",\n reason: \"cancelled\",\n },\n }) satisfies A2AMessage & { role: \"tool\" },\n )\n : [];\n\n const config: A2ASendMessageConfig = {};\n if (contextId !== undefined) config.contextId = contextId;\n if (msg.runConfig !== undefined) config.runConfig = msg.runConfig;\n return handleSendMessage(\n [\n ...cancellations,\n {\n role: \"user\",\n content: getMessageContent(msg),\n },\n ],\n config,\n );\n },\n onAddToolResult: async ({\n toolCallId,\n toolName: _toolName,\n result,\n isError,\n artifact,\n }) => {\n // TODO parallel human in the loop calls\n const message: A2AMessage = {\n role: \"tool\",\n tool_call_id: toolCallId,\n content: JSON.stringify(result),\n status: isError\n ? { type: \"incomplete\", reason: \"error\" }\n : { type: \"complete\", reason: \"stop\" },\n };\n if (artifact) {\n message.artifacts = [artifact] as A2AArtifact[];\n }\n const config: A2ASendMessageConfig = {};\n if (contextId !== undefined) config.contextId = contextId;\n await handleSendMessage(\n [message],\n // TODO reuse runconfig here!\n config,\n );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EAAE,WAAW,KAAK,CAAC;AAAA,UAC3C,QAAQ;AAAA,YACN,MAAM;AAAA,YACN,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACJ,IACA,CAAC;AAEP,YAAM,SAA+B,CAAC;AACtC,UAAI,cAAc,OAAW,QAAO,YAAY;AAChD,UAAI,IAAI,cAAc,OAAW,QAAO,YAAY,IAAI;AACxD,aAAO;AAAA,QACL;AAAA,UACE,GAAG;AAAA,UACH;AAAA,YACE,MAAM;AAAA,YACN,SAAS,kBAAkB,GAAG;AAAA,UAChC;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,iBAAiB,OAAO;AAAA,MACtB;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,IACF,MAAM;AAEJ,YAAM,UAAsB;AAAA,QAC1B,MAAM;AAAA,QACN,cAAc;AAAA,QACd,SAAS,KAAK,UAAU,MAAM;AAAA,QAC9B,QAAQ,UACJ,EAAE,MAAM,cAAc,QAAQ,QAAQ,IACtC,EAAE,MAAM,YAAY,QAAQ,OAAO;AAAA,MACzC;AACA,UAAI,UAAU;AACZ,gBAAQ,YAAY,CAAC,QAAQ;AAAA,MAC/B;AACA,YAAM,SAA+B,CAAC;AACtC,UAAI,cAAc,OAAW,QAAO,YAAY;AAChD,YAAM;AAAA,QACJ,CAAC,OAAO;AAAA;AAAA,QAER;AAAA,MACF;AAAA,IACF;AAAA,IACA,UAAU,6BACN,YAAY;AACV,aAAO;AAAA,IACT,IACA;AAAA,EACN,CAAC;AACH;","names":["messages","artifacts"]}
|
|
1
|
+
{"version":3,"file":"useA2ARuntime.js","sourceRoot":"","sources":["../src/useA2ARuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAcpD,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,SAAS,EACT,wBAAwB,GACzB,MAAM,qBAAqB,C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AAE,EAAE;YACH,wCAAwC;YACxC,MAAM,OAAO,GAAe;gBAC1B,IAAI,EAAE,MAAM;gBACZ,YAAY,EAAE,UAAU;gBACxB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;gBAC/B,MAAM,EAAE,OAAO;oBACb,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE;oBACzC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE;aACzC,CAAC;YACF,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,CAAC,SAAS,GAAG,CAAC,QAAQ,CAAkB,CAAC;YAClD,CAAC;YACD,MAAM,MAAM,GAAyB,EAAE,CAAC;YACxC,IAAI,SAAS,KAAK,SAAS;gBAAE,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;YAC1D,MAAM,iBAAiB,CACrB,CAAC,OAAO,CAAC;YACT,6BAA6B;YAC7B,MAAM,CACP,CAAC;QACJ,CAAC;QACD,QAAQ,EAAE,0BAA0B;YAClC,CAAC,CAAC,KAAK,IAAI,EAAE;gBACT,MAAM,EAAE,CAAC;YACX,CAAC;YACH,CAAC,CAAC,SAAS;KACd,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react-a2a",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "A2A protocol adapter for assistant-ui",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"a2a",
|
|
7
|
+
"agent-to-agent",
|
|
8
|
+
"assistant-ui",
|
|
9
|
+
"react",
|
|
10
|
+
"ai",
|
|
11
|
+
"chat",
|
|
12
|
+
"protocol"
|
|
13
|
+
],
|
|
14
|
+
"author": "AgentbaseAI Inc.",
|
|
4
15
|
"license": "MIT",
|
|
5
16
|
"type": "module",
|
|
6
17
|
"exports": {
|
|
7
18
|
".": {
|
|
19
|
+
"aui-source": "./src/index.ts",
|
|
8
20
|
"types": "./dist/index.d.ts",
|
|
9
21
|
"default": "./dist/index.js"
|
|
10
22
|
}
|
|
@@ -18,14 +30,13 @@
|
|
|
18
30
|
],
|
|
19
31
|
"sideEffects": false,
|
|
20
32
|
"dependencies": {
|
|
21
|
-
"assistant-stream": "^0.2.
|
|
22
|
-
"uuid": "^13.0.0"
|
|
23
|
-
"zod": "^4.1.13"
|
|
33
|
+
"assistant-stream": "^0.2.47",
|
|
34
|
+
"uuid": "^13.0.0"
|
|
24
35
|
},
|
|
25
36
|
"peerDependencies": {
|
|
26
|
-
"@assistant-ui/react": "^0.11.
|
|
37
|
+
"@assistant-ui/react": "^0.11.58",
|
|
27
38
|
"@types/react": "*",
|
|
28
|
-
"react": "^18 || ^19
|
|
39
|
+
"react": "^18 || ^19"
|
|
29
40
|
},
|
|
30
41
|
"peerDependenciesMeta": {
|
|
31
42
|
"@types/react": {
|
|
@@ -33,16 +44,10 @@
|
|
|
33
44
|
}
|
|
34
45
|
},
|
|
35
46
|
"devDependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@testing-library/react": "^16.3.0",
|
|
38
|
-
"@types/node": "^25.0.0",
|
|
39
|
-
"@types/react": "^19.2.7",
|
|
47
|
+
"@types/react": "^19.2.9",
|
|
40
48
|
"@types/uuid": "^11.0.0",
|
|
41
|
-
"
|
|
42
|
-
"react": "
|
|
43
|
-
"tsx": "^4.21.0",
|
|
44
|
-
"vitest": "^4.0.15",
|
|
45
|
-
"@assistant-ui/react": "0.11.50",
|
|
49
|
+
"react": "^19.2.3",
|
|
50
|
+
"@assistant-ui/react": "0.11.58",
|
|
46
51
|
"@assistant-ui/x-buildutils": "0.0.1"
|
|
47
52
|
},
|
|
48
53
|
"publishConfig": {
|
|
@@ -52,14 +57,13 @@
|
|
|
52
57
|
"homepage": "https://www.assistant-ui.com/",
|
|
53
58
|
"repository": {
|
|
54
59
|
"type": "git",
|
|
55
|
-
"url": "https://github.com/assistant-ui/assistant-ui
|
|
60
|
+
"url": "git+https://github.com/assistant-ui/assistant-ui.git",
|
|
61
|
+
"directory": "packages/react-a2a"
|
|
56
62
|
},
|
|
57
63
|
"bugs": {
|
|
58
64
|
"url": "https://github.com/assistant-ui/assistant-ui/issues"
|
|
59
65
|
},
|
|
60
66
|
"scripts": {
|
|
61
|
-
"build": "
|
|
62
|
-
"test": "vitest run --passWithNoTests",
|
|
63
|
-
"test:watch": "vitest"
|
|
67
|
+
"build": "aui-build"
|
|
64
68
|
}
|
|
65
69
|
}
|