@google/adk 0.6.0 → 0.6.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.
- package/dist/cjs/a2a/a2a_remote_agent.js +18 -13
- package/dist/cjs/a2a/a2a_remote_agent_run_processor.js +7 -0
- package/dist/cjs/index.js +16 -16
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/utils/gemini_schema_util.js +54 -12
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_remote_agent.js +18 -13
- package/dist/esm/a2a/a2a_remote_agent_run_processor.js +7 -0
- package/dist/esm/index.js +15 -15
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/utils/gemini_schema_util.js +54 -12
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent.d.ts +7 -3
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/a2a_remote_agent.js +15 -24
- package/dist/web/a2a/a2a_remote_agent_run_processor.js +7 -0
- package/dist/web/index.js +1 -1
- package/dist/web/index.js.map +1 -1
- package/dist/web/utils/gemini_schema_util.js +85 -12
- package/dist/web/version.js +1 -1
- package/package.json +2 -2
|
@@ -51,17 +51,24 @@ class RemoteA2AAgent extends import_base_agent.BaseAgent {
|
|
|
51
51
|
super(a2aConfig);
|
|
52
52
|
this.a2aConfig = a2aConfig;
|
|
53
53
|
this.isInitialized = false;
|
|
54
|
-
if (!a2aConfig.agentCard) {
|
|
55
|
-
throw new Error("AgentCard must be provided");
|
|
54
|
+
if (!a2aConfig.agentCard && !a2aConfig.client) {
|
|
55
|
+
throw new Error("Either AgentCard or Client must be provided");
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
async init() {
|
|
59
59
|
if (this.isInitialized) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
if (this.a2aConfig.client) {
|
|
63
|
+
this.client = this.a2aConfig.client;
|
|
64
|
+
}
|
|
65
|
+
if (this.a2aConfig.agentCard) {
|
|
66
|
+
this.card = await (0, import_agent_card.resolveAgentCard)(this.a2aConfig.agentCard);
|
|
67
|
+
if (!this.client) {
|
|
68
|
+
const factory = this.a2aConfig.clientFactory || new import_client.ClientFactory();
|
|
69
|
+
this.client = await factory.createFromAgentCard(this.card);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
65
72
|
this.isInitialized = true;
|
|
66
73
|
}
|
|
67
74
|
async *runAsyncImpl(context) {
|
|
@@ -97,13 +104,11 @@ class RemoteA2AAgent extends import_base_agent.BaseAgent {
|
|
|
97
104
|
messageId: (0, import_env_aware_utils.randomUUID)(),
|
|
98
105
|
role: import_a2a_event.MessageRole.USER,
|
|
99
106
|
parts,
|
|
100
|
-
metadata: {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
+
metadata: (0, import_metadata_converter_utils.getA2ASessionMetadata)({
|
|
108
|
+
appName: context.session.appName,
|
|
109
|
+
userId: context.session.userId,
|
|
110
|
+
sessionId: context.session.id
|
|
111
|
+
})
|
|
107
112
|
};
|
|
108
113
|
if (taskId) message.taskId = taskId;
|
|
109
114
|
if (contextId) message.contextId = contextId;
|
|
@@ -117,7 +122,7 @@ class RemoteA2AAgent extends import_base_agent.BaseAgent {
|
|
|
117
122
|
await callback(context, params);
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
|
-
const useStreaming = ((_b = this.card.capabilities) == null ? void 0 : _b.streaming) !== false;
|
|
125
|
+
const useStreaming = this.card ? ((_b = this.card.capabilities) == null ? void 0 : _b.streaming) !== false : true;
|
|
121
126
|
if (useStreaming) {
|
|
122
127
|
for await (const chunk of this.client.sendMessageStream(params)) {
|
|
123
128
|
if (this.a2aConfig.afterRequestCallbacks) {
|
|
@@ -179,6 +179,13 @@ class A2ARemoteAgentRunProcessor {
|
|
|
179
179
|
}
|
|
180
180
|
if (response) {
|
|
181
181
|
toAdd["response"] = response;
|
|
182
|
+
if ((0, import_a2a_event.isTask)(response)) {
|
|
183
|
+
if (response.id) toAdd["task_id"] = response.id;
|
|
184
|
+
if (response.contextId) toAdd["context_id"] = response.contextId;
|
|
185
|
+
} else if (response.taskId) {
|
|
186
|
+
toAdd["task_id"] = response.taskId;
|
|
187
|
+
if (response.contextId) toAdd["context_id"] = response.contextId;
|
|
188
|
+
}
|
|
182
189
|
}
|
|
183
190
|
if (Object.keys(toAdd).length === 0) {
|
|
184
191
|
return;
|