@adcp/sdk 14.0.0-beta.10 → 14.0.0-beta.12
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/bin/adcp-storyboard-sandbox.js +16 -0
- package/bin/adcp.js +28 -30
- package/dist/lib/core/AgentClient.d.ts.map +1 -1
- package/dist/lib/core/SingleAgentClient.d.mts +2 -1
- package/dist/lib/core/SingleAgentClient.d.ts +2 -1
- package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
- package/dist/lib/core/SingleAgentClient.js +113 -64
- package/dist/lib/core/SingleAgentClient.js.map +1 -1
- package/dist/lib/core/SingleAgentClient.mjs +113 -64
- package/dist/lib/core/SingleAgentClient.mjs.map +1 -1
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/protocols/a2a.d.mts +10 -3
- package/dist/lib/protocols/a2a.d.ts +10 -3
- package/dist/lib/protocols/a2a.d.ts.map +1 -1
- package/dist/lib/protocols/a2a.js +162 -34
- package/dist/lib/protocols/a2a.js.map +1 -1
- package/dist/lib/protocols/a2a.mjs +166 -34
- package/dist/lib/protocols/a2a.mjs.map +1 -1
- package/dist/lib/schemas/index.d.mts +385 -1
- package/dist/lib/schemas/index.d.ts +385 -1
- package/dist/lib/schemas/index.d.ts.map +1 -1
- package/dist/lib/schemas/index.js +13 -0
- package/dist/lib/schemas/index.js.map +1 -1
- package/dist/lib/schemas/index.mjs +11 -0
- package/dist/lib/schemas/index.mjs.map +1 -1
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/a2a-adapter.d.mts +59 -33
- package/dist/lib/server/a2a-adapter.d.ts +59 -33
- package/dist/lib/server/a2a-adapter.d.ts.map +1 -1
- package/dist/lib/server/a2a-adapter.js +278 -67
- package/dist/lib/server/a2a-adapter.js.map +1 -1
- package/dist/lib/server/a2a-adapter.mjs +280 -68
- package/dist/lib/server/a2a-adapter.mjs.map +1 -1
- package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
- package/dist/lib/server/create-adcp-server.js +35 -108
- package/dist/lib/server/create-adcp-server.js.map +1 -1
- package/dist/lib/server/create-adcp-server.mjs +37 -109
- package/dist/lib/server/create-adcp-server.mjs.map +1 -1
- package/dist/lib/server/decisioning/index.d.mts +2 -0
- package/dist/lib/server/decisioning/index.d.ts +2 -0
- package/dist/lib/server/decisioning/index.d.ts.map +1 -1
- package/dist/lib/server/decisioning/index.js +5 -2
- package/dist/lib/server/decisioning/index.js.map +1 -1
- package/dist/lib/server/decisioning/index.mjs +3 -1
- package/dist/lib/server/decisioning/index.mjs.map +1 -1
- package/dist/lib/server/decisioning/response-summary.d.mts +33 -0
- package/dist/lib/server/decisioning/response-summary.d.ts +34 -0
- package/dist/lib/server/decisioning/response-summary.d.ts.map +1 -0
- package/dist/lib/server/decisioning/response-summary.js +62 -0
- package/dist/lib/server/decisioning/response-summary.js.map +1 -0
- package/dist/lib/server/decisioning/response-summary.mjs +37 -0
- package/dist/lib/server/decisioning/response-summary.mjs.map +1 -0
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.js +27 -5
- package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +27 -5
- package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
- package/dist/lib/server/decisioning/specialisms/sales.d.mts +7 -1
- package/dist/lib/server/decisioning/specialisms/sales.d.ts +7 -1
- package/dist/lib/server/decisioning/specialisms/sales.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/sales.js.map +1 -1
- package/dist/lib/server/index.d.mts +1 -1
- package/dist/lib/server/index.d.ts +1 -1
- package/dist/lib/server/index.d.ts.map +1 -1
- package/dist/lib/server/index.js.map +1 -1
- package/dist/lib/server/index.mjs.map +1 -1
- package/dist/lib/server/responses.d.ts.map +1 -1
- package/dist/lib/server/responses.js +9 -1
- package/dist/lib/server/responses.js.map +1 -1
- package/dist/lib/server/responses.mjs +8 -1
- package/dist/lib/server/responses.mjs.map +1 -1
- package/dist/lib/signing/agent-context.d.mts +1 -0
- package/dist/lib/signing/agent-context.d.ts +1 -0
- package/dist/lib/signing/agent-context.d.ts.map +1 -1
- package/dist/lib/signing/agent-context.js +37 -2
- package/dist/lib/signing/agent-context.js.map +1 -1
- package/dist/lib/signing/agent-context.mjs +38 -3
- package/dist/lib/signing/agent-context.mjs.map +1 -1
- package/dist/lib/signing/agent-fetch.d.mts +1 -2
- package/dist/lib/signing/agent-fetch.d.ts +1 -2
- package/dist/lib/signing/agent-fetch.d.ts.map +1 -1
- package/dist/lib/signing/agent-fetch.js +2 -0
- package/dist/lib/signing/agent-fetch.js.map +1 -1
- package/dist/lib/signing/agent-fetch.mjs +2 -0
- package/dist/lib/signing/agent-fetch.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/etld.js.map +1 -1
- package/dist/lib/signing/agent-resolver/etld.mjs.map +1 -1
- package/dist/lib/testing/client.d.mts +6 -0
- package/dist/lib/testing/client.d.ts +6 -0
- package/dist/lib/testing/client.d.ts.map +1 -1
- package/dist/lib/testing/client.js +76 -4
- package/dist/lib/testing/client.js.map +1 -1
- package/dist/lib/testing/client.mjs +75 -4
- package/dist/lib/testing/client.mjs.map +1 -1
- package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
- package/dist/lib/testing/compliance/comply.js +6 -0
- package/dist/lib/testing/compliance/comply.js.map +1 -1
- package/dist/lib/testing/compliance/comply.mjs +7 -1
- package/dist/lib/testing/compliance/comply.mjs.map +1 -1
- package/dist/lib/testing/storyboard/context.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/context.js +9 -4
- package/dist/lib/testing/storyboard/context.js.map +1 -1
- package/dist/lib/testing/storyboard/context.mjs +9 -4
- package/dist/lib/testing/storyboard/context.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-builder.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/request-builder.js +28 -4
- package/dist/lib/testing/storyboard/request-builder.js.map +1 -1
- package/dist/lib/testing/storyboard/request-builder.mjs +28 -4
- package/dist/lib/testing/storyboard/request-builder.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.d.mts +15 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.d.ts +16 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.d.ts.map +1 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.js +106 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.js.map +1 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.mjs +82 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.mjs.map +1 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.d.mts +15 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.d.ts +15 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/test-kit.js +58 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.js.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/test-kit.mjs +58 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.mts +2 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts +2 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.js +7 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.js.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +6 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs.map +1 -1
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +31 -7
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/testing/storyboard/runner.mjs +31 -7
- package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/validations.js +18 -7
- package/dist/lib/testing/storyboard/validations.js.map +1 -1
- package/dist/lib/testing/storyboard/validations.mjs +18 -7
- package/dist/lib/testing/storyboard/validations.mjs.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.js +32 -20
- package/dist/lib/testing/storyboard/webhook-receiver.js.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.mjs +32 -20
- package/dist/lib/testing/storyboard/webhook-receiver.mjs.map +1 -1
- package/dist/lib/testing/types.d.mts +10 -0
- package/dist/lib/testing/types.d.ts +10 -0
- package/dist/lib/testing/types.d.ts.map +1 -1
- package/dist/lib/testing/types.js.map +1 -1
- package/dist/lib/types/comply-test-controller.d.ts +1 -14
- package/dist/lib/types/core.generated.d.mts +1 -1
- package/dist/lib/types/core.generated.d.ts +1 -1
- package/dist/lib/types/core.generated.d.ts.map +1 -1
- package/dist/lib/types/core.generated.js.map +1 -1
- package/dist/lib/types/get-products.d.ts +1 -14
- package/dist/lib/types/schemas.generated.d.ts +519 -571
- package/dist/lib/types/schemas.generated.d.ts.map +1 -1
- package/dist/lib/types/schemas.generated.js +2 -2
- package/dist/lib/types/schemas.generated.js.map +1 -1
- package/dist/lib/types/schemas.generated.mjs +2 -2
- package/dist/lib/types/schemas.generated.mjs.map +1 -1
- package/dist/lib/types/tools.generated.d.mts +1 -1
- package/dist/lib/types/tools.generated.d.ts +1 -1
- package/dist/lib/types/tools.generated.d.ts.map +1 -1
- package/dist/lib/types/tools.generated.js.map +1 -1
- package/dist/lib/utils/a2a-artifacts.d.ts.map +1 -1
- package/dist/lib/utils/a2a-artifacts.js +2 -2
- package/dist/lib/utils/a2a-artifacts.js.map +1 -1
- package/dist/lib/utils/a2a-artifacts.mjs +2 -2
- package/dist/lib/utils/a2a-artifacts.mjs.map +1 -1
- package/dist/lib/utils/a2a-discovery.d.mts +3 -3
- package/dist/lib/utils/a2a-discovery.d.ts +3 -3
- package/dist/lib/utils/a2a-discovery.js +1 -1
- package/dist/lib/utils/a2a-discovery.js.map +1 -1
- package/dist/lib/utils/a2a-discovery.mjs +1 -1
- package/dist/lib/utils/a2a-discovery.mjs.map +1 -1
- package/dist/lib/utils/tool-request-schemas.d.mts +31 -31
- package/dist/lib/utils/tool-request-schemas.d.ts +31 -31
- package/dist/lib/v2/projection/index.d.mts +2 -0
- package/dist/lib/v2/projection/index.d.ts +2 -0
- package/dist/lib/v2/projection/index.d.ts.map +1 -1
- package/dist/lib/v2/projection/index.js +3 -0
- package/dist/lib/v2/projection/index.js.map +1 -1
- package/dist/lib/v2/projection/index.mjs +2 -0
- package/dist/lib/v2/projection/index.mjs.map +1 -1
- package/dist/lib/v2/projection/legacy-normalization.d.mts +24 -0
- package/dist/lib/v2/projection/legacy-normalization.d.ts +25 -0
- package/dist/lib/v2/projection/legacy-normalization.d.ts.map +1 -0
- package/dist/lib/v2/projection/legacy-normalization.js +32 -0
- package/dist/lib/v2/projection/legacy-normalization.js.map +1 -0
- package/dist/lib/v2/projection/legacy-normalization.mjs +8 -0
- package/dist/lib/v2/projection/legacy-normalization.mjs.map +1 -0
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.js.map +1 -1
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/version.mjs.map +1 -1
- package/docs/guides/BUILD-AN-AGENT.md +42 -6
- package/docs/llms.txt +2 -2
- package/docs/migration-13-to-14.md +17 -0
- package/package.json +44 -41
|
@@ -24,8 +24,26 @@ __export(a2a_adapter_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(a2a_adapter_exports);
|
|
25
25
|
var import_server = require("@a2a-js/sdk/server");
|
|
26
26
|
var import_express = require("@a2a-js/sdk/server/express");
|
|
27
|
+
var import_sdk = require("@a2a-js/sdk");
|
|
28
|
+
var import_v0_3 = require("@a2a-js/sdk/compat/v0_3");
|
|
27
29
|
var import_node_crypto = require("node:crypto");
|
|
30
|
+
var import_redact_secrets = require('../utils/redact-secrets.js');
|
|
28
31
|
var import_adcp_server = require('./adcp-server.js');
|
|
32
|
+
class RedactingA2ATaskStore {
|
|
33
|
+
constructor(delegate) {
|
|
34
|
+
this.delegate = delegate;
|
|
35
|
+
}
|
|
36
|
+
delegate;
|
|
37
|
+
save(task, context) {
|
|
38
|
+
return this.delegate.save((0, import_redact_secrets.redactSecrets)(task), context);
|
|
39
|
+
}
|
|
40
|
+
load(taskId, context) {
|
|
41
|
+
return this.delegate.load(taskId, context);
|
|
42
|
+
}
|
|
43
|
+
list(params, context) {
|
|
44
|
+
return this.delegate.list(params, context);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
29
47
|
function buildAuthenticatedUser(authInfo) {
|
|
30
48
|
const clientId = authInfo.clientId;
|
|
31
49
|
return {
|
|
@@ -52,11 +70,13 @@ function getAdcpAuthInfo(context) {
|
|
|
52
70
|
const user = context?.user;
|
|
53
71
|
return user?.adcpAuthInfo;
|
|
54
72
|
}
|
|
55
|
-
function extractInvocation(message) {
|
|
73
|
+
function extractInvocation(message, allowLegacyParameters = false) {
|
|
56
74
|
if (!Array.isArray(message.parts) || message.parts.length === 0) {
|
|
57
75
|
throw new A2AInvocationError("Message must carry at least one part with a `data` kind.");
|
|
58
76
|
}
|
|
59
|
-
const dataParts = message.parts.filter(
|
|
77
|
+
const dataParts = message.parts.filter(
|
|
78
|
+
(part) => part.content?.$case === "data"
|
|
79
|
+
);
|
|
60
80
|
if (dataParts.length === 0) {
|
|
61
81
|
throw new A2AInvocationError(
|
|
62
82
|
"Message must include a DataPart with { skill, input } \u2014 text-only messages aren't routable to AdCP tools."
|
|
@@ -64,24 +84,27 @@ function extractInvocation(message) {
|
|
|
64
84
|
}
|
|
65
85
|
if (dataParts.length > 1) {
|
|
66
86
|
throw new A2AInvocationError(
|
|
67
|
-
"Message must include exactly one DataPart \u2014 multi-part invocations are not supported
|
|
87
|
+
"Message must include exactly one DataPart \u2014 multi-part invocations are not supported."
|
|
68
88
|
);
|
|
69
89
|
}
|
|
70
90
|
const firstDataPart = dataParts[0];
|
|
71
|
-
const rawData = firstDataPart.
|
|
91
|
+
const rawData = firstDataPart.content.value;
|
|
72
92
|
if (rawData == null || typeof rawData !== "object" || Array.isArray(rawData)) {
|
|
73
93
|
throw new A2AInvocationError("DataPart `data` must be an object containing { skill, input }.");
|
|
74
94
|
}
|
|
75
95
|
const payload = rawData;
|
|
76
96
|
const skill = payload.skill;
|
|
77
|
-
const input = payload.input ?? payload.parameters;
|
|
97
|
+
const input = payload.input ?? (allowLegacyParameters ? payload.parameters : void 0);
|
|
78
98
|
if (typeof skill !== "string" || skill.length === 0) {
|
|
79
99
|
throw new A2AInvocationError("DataPart must include a non-empty string `skill` field naming the AdCP tool.");
|
|
80
100
|
}
|
|
81
101
|
if (input != null && (typeof input !== "object" || Array.isArray(input))) {
|
|
82
|
-
throw new A2AInvocationError("DataPart `input`
|
|
102
|
+
throw new A2AInvocationError("DataPart `input` must be an object.");
|
|
103
|
+
}
|
|
104
|
+
if (input == null) {
|
|
105
|
+
throw new A2AInvocationError("DataPart must include an `input` object.");
|
|
83
106
|
}
|
|
84
|
-
return { skill, input
|
|
107
|
+
return { skill, input };
|
|
85
108
|
}
|
|
86
109
|
class A2AInvocationError extends Error {
|
|
87
110
|
constructor(message) {
|
|
@@ -127,12 +150,25 @@ class AdcpA2AAgentExecutor {
|
|
|
127
150
|
async execute(requestContext, eventBus) {
|
|
128
151
|
const { taskId, contextId, userMessage } = requestContext;
|
|
129
152
|
const authInfo = getAdcpAuthInfo(requestContext.context);
|
|
153
|
+
const requestedExtensions = requestContext.context.requestedExtensions;
|
|
154
|
+
const requestedAdcpExtension = Array.isArray(requestedExtensions) && requestedExtensions.some((extension) => extension === ADCP_A2A_EXTENSION);
|
|
155
|
+
const legacyWire = requestContext.context.requestedVersion.startsWith("0.");
|
|
130
156
|
this.taskContextIds.set(taskId, contextId);
|
|
131
157
|
try {
|
|
132
158
|
this.publishInitialTask(eventBus, taskId, contextId, userMessage);
|
|
159
|
+
if (!legacyWire) {
|
|
160
|
+
if (!requestedAdcpExtension) {
|
|
161
|
+
this.emitFailure(eventBus, taskId, contextId, {
|
|
162
|
+
reason: "REQUIRED_EXTENSION_MISSING",
|
|
163
|
+
message: `A2A requests must activate ${ADCP_A2A_EXTENSION}`
|
|
164
|
+
});
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
requestContext.context.addActivatedExtension(ADCP_A2A_EXTENSION);
|
|
168
|
+
}
|
|
133
169
|
let invocation;
|
|
134
170
|
try {
|
|
135
|
-
invocation = extractInvocation(userMessage);
|
|
171
|
+
invocation = extractInvocation(userMessage, legacyWire);
|
|
136
172
|
} catch (err) {
|
|
137
173
|
const message = err instanceof Error ? err.message : "Invalid A2A invocation";
|
|
138
174
|
this.emitFailure(eventBus, taskId, contextId, {
|
|
@@ -172,7 +208,7 @@ class AdcpA2AAgentExecutor {
|
|
|
172
208
|
});
|
|
173
209
|
this.emitFailure(eventBus, taskId, contextId, {
|
|
174
210
|
reason: "HANDLER_THREW",
|
|
175
|
-
message
|
|
211
|
+
message: "The A2A tool invocation failed."
|
|
176
212
|
});
|
|
177
213
|
return;
|
|
178
214
|
}
|
|
@@ -184,17 +220,16 @@ class AdcpA2AAgentExecutor {
|
|
|
184
220
|
return;
|
|
185
221
|
}
|
|
186
222
|
if (this.canceled.has(taskId)) {
|
|
187
|
-
this.publishStatus(eventBus, taskId, contextId,
|
|
223
|
+
this.publishStatus(eventBus, taskId, contextId, import_sdk.TaskState.TASK_STATE_CANCELED);
|
|
188
224
|
return;
|
|
189
225
|
}
|
|
190
226
|
const classified = classifyResponse(response);
|
|
191
|
-
this.publishArtifact(eventBus, taskId, contextId, classified);
|
|
227
|
+
this.publishArtifact(eventBus, taskId, contextId, classified, legacyWire);
|
|
192
228
|
this.publishStatus(
|
|
193
229
|
eventBus,
|
|
194
230
|
taskId,
|
|
195
231
|
contextId,
|
|
196
|
-
classified.kind === "success" || classified.kind === "submitted" || classified.kind === "paused"
|
|
197
|
-
true
|
|
232
|
+
classified.kind === "success" || classified.kind === "submitted" || classified.kind === "paused" || !legacyWire && classified.kind === "error_arm" ? import_sdk.TaskState.TASK_STATE_COMPLETED : import_sdk.TaskState.TASK_STATE_FAILED
|
|
198
233
|
);
|
|
199
234
|
} finally {
|
|
200
235
|
this.canceled.delete(taskId);
|
|
@@ -205,80 +240,98 @@ class AdcpA2AAgentExecutor {
|
|
|
205
240
|
async cancelTask(taskId, eventBus) {
|
|
206
241
|
this.canceled.add(taskId);
|
|
207
242
|
const contextId = this.taskContextIds.get(taskId) ?? "";
|
|
208
|
-
this.publishStatus(eventBus, taskId, contextId,
|
|
243
|
+
this.publishStatus(eventBus, taskId, contextId, import_sdk.TaskState.TASK_STATE_CANCELED);
|
|
209
244
|
}
|
|
210
245
|
publishInitialTask(eventBus, taskId, contextId, userMessage) {
|
|
211
246
|
const task = {
|
|
212
|
-
kind: "task",
|
|
213
247
|
id: taskId,
|
|
214
248
|
contextId,
|
|
215
249
|
status: {
|
|
216
|
-
state:
|
|
250
|
+
state: import_sdk.TaskState.TASK_STATE_WORKING,
|
|
251
|
+
message: void 0,
|
|
217
252
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
218
253
|
},
|
|
219
|
-
|
|
254
|
+
artifacts: [],
|
|
255
|
+
history: [userMessage],
|
|
256
|
+
metadata: void 0
|
|
220
257
|
};
|
|
221
|
-
eventBus.publish(task);
|
|
258
|
+
eventBus.publish(import_server.AgentEvent.task(task));
|
|
222
259
|
}
|
|
223
|
-
publishStatus(eventBus, taskId, contextId, state,
|
|
260
|
+
publishStatus(eventBus, taskId, contextId, state, messageData) {
|
|
224
261
|
const event = {
|
|
225
|
-
kind: "status-update",
|
|
226
262
|
taskId,
|
|
227
263
|
contextId,
|
|
228
264
|
status: {
|
|
229
265
|
state,
|
|
230
266
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
267
|
+
message: messageData ? {
|
|
268
|
+
messageId: (0, import_node_crypto.randomUUID)(),
|
|
269
|
+
contextId,
|
|
270
|
+
taskId,
|
|
271
|
+
role: import_sdk.Role.ROLE_AGENT,
|
|
272
|
+
parts: [dataPart(messageData)],
|
|
273
|
+
metadata: void 0,
|
|
274
|
+
extensions: [],
|
|
275
|
+
referenceTaskIds: []
|
|
276
|
+
} : void 0
|
|
239
277
|
},
|
|
240
|
-
|
|
278
|
+
metadata: void 0
|
|
241
279
|
};
|
|
242
|
-
eventBus.publish(event);
|
|
280
|
+
eventBus.publish(import_server.AgentEvent.statusUpdate(event));
|
|
243
281
|
}
|
|
244
|
-
publishArtifact(eventBus, taskId, contextId, classified) {
|
|
282
|
+
publishArtifact(eventBus, taskId, contextId, classified, legacyWire) {
|
|
245
283
|
const artifactName = classified.kind === "success" ? "result" : classified.kind === "submitted" ? "submitted" : classified.kind === "paused" ? "result" : "error";
|
|
246
284
|
const artifact = {
|
|
247
285
|
artifactId: (0, import_node_crypto.randomUUID)(),
|
|
248
286
|
name: artifactName,
|
|
249
|
-
|
|
250
|
-
|
|
287
|
+
description: "",
|
|
288
|
+
parts: [dataPart(classified.data)],
|
|
289
|
+
metadata: legacyWire ? {
|
|
251
290
|
adcp_status: classified.kind === "submitted" ? "submitted" : classified.kind === "paused" ? classified.status : classified.kind === "success" ? "completed" : "failed",
|
|
252
291
|
...classified.kind === "submitted" && { adcp_task_id: classified.adcpTaskId }
|
|
253
|
-
}
|
|
292
|
+
} : void 0,
|
|
293
|
+
extensions: []
|
|
254
294
|
};
|
|
255
295
|
const event = {
|
|
256
|
-
kind: "artifact-update",
|
|
257
296
|
taskId,
|
|
258
297
|
contextId,
|
|
259
298
|
artifact,
|
|
260
299
|
append: false,
|
|
261
|
-
lastChunk: true
|
|
300
|
+
lastChunk: true,
|
|
301
|
+
metadata: void 0
|
|
262
302
|
};
|
|
263
|
-
eventBus.publish(event);
|
|
303
|
+
eventBus.publish(import_server.AgentEvent.artifactUpdate(event));
|
|
264
304
|
}
|
|
265
305
|
emitFailure(eventBus, taskId, contextId, payload) {
|
|
266
306
|
const artifact = {
|
|
267
307
|
artifactId: (0, import_node_crypto.randomUUID)(),
|
|
268
308
|
name: "error",
|
|
269
|
-
|
|
309
|
+
description: "",
|
|
310
|
+
parts: [dataPart(payload)],
|
|
311
|
+
metadata: void 0,
|
|
312
|
+
extensions: []
|
|
270
313
|
};
|
|
271
|
-
eventBus.publish(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
314
|
+
eventBus.publish(
|
|
315
|
+
import_server.AgentEvent.artifactUpdate({
|
|
316
|
+
taskId,
|
|
317
|
+
contextId,
|
|
318
|
+
artifact,
|
|
319
|
+
append: false,
|
|
320
|
+
lastChunk: true,
|
|
321
|
+
metadata: void 0
|
|
322
|
+
})
|
|
323
|
+
);
|
|
324
|
+
this.publishStatus(eventBus, taskId, contextId, import_sdk.TaskState.TASK_STATE_FAILED);
|
|
280
325
|
}
|
|
281
326
|
}
|
|
327
|
+
function dataPart(value) {
|
|
328
|
+
return {
|
|
329
|
+
content: { $case: "data", value },
|
|
330
|
+
metadata: void 0,
|
|
331
|
+
filename: "",
|
|
332
|
+
mediaType: "application/json"
|
|
333
|
+
};
|
|
334
|
+
}
|
|
282
335
|
function isToolNotRegistered(err, toolName) {
|
|
283
336
|
return err instanceof Error && err.message.includes(`tool "${toolName}" is not registered`);
|
|
284
337
|
}
|
|
@@ -286,7 +339,8 @@ function a2aSkillToServerToolNames(skill) {
|
|
|
286
339
|
return skill === "tasks/get" ? ["tasks_get", "tasks/get"] : [skill];
|
|
287
340
|
}
|
|
288
341
|
const DEFAULT_MODES = ["application/json"];
|
|
289
|
-
const DEFAULT_PROTOCOL_VERSION = "
|
|
342
|
+
const DEFAULT_PROTOCOL_VERSION = "1.0";
|
|
343
|
+
const ADCP_A2A_EXTENSION = "https://adcontextprotocol.org/extensions/adcp/v3";
|
|
290
344
|
const PUBLIC_AGENT_CARD_EXCLUDED_SKILLS = /* @__PURE__ */ new Set(["comply_test_controller"]);
|
|
291
345
|
function deriveSkills(toolNames) {
|
|
292
346
|
const publicNames = new Set(toolNames.map(toA2ASkillName));
|
|
@@ -294,7 +348,11 @@ function deriveSkills(toolNames) {
|
|
|
294
348
|
id: name,
|
|
295
349
|
name,
|
|
296
350
|
description: `AdCP tool: ${name}. Send { skill: "${name}", input: { ... } } as a DataPart.`,
|
|
297
|
-
tags: ["adcp"]
|
|
351
|
+
tags: ["adcp"],
|
|
352
|
+
examples: [],
|
|
353
|
+
inputModes: [],
|
|
354
|
+
outputModes: [],
|
|
355
|
+
securityRequirements: []
|
|
298
356
|
}));
|
|
299
357
|
}
|
|
300
358
|
function toA2ASkillName(toolName) {
|
|
@@ -312,42 +370,177 @@ function filterPublicAgentCardSkills(skills) {
|
|
|
312
370
|
return !(id != null && PUBLIC_AGENT_CARD_EXCLUDED_SKILLS.has(id) || name != null && PUBLIC_AGENT_CARD_EXCLUDED_SKILLS.has(name));
|
|
313
371
|
});
|
|
314
372
|
}
|
|
373
|
+
function normalizeAgentCardSkills(skills) {
|
|
374
|
+
return skills.map((skill) => ({
|
|
375
|
+
...skill,
|
|
376
|
+
examples: skill.examples ?? [],
|
|
377
|
+
inputModes: skill.inputModes ?? [],
|
|
378
|
+
outputModes: skill.outputModes ?? [],
|
|
379
|
+
securityRequirements: skill.securityRequirements ?? []
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
315
382
|
function buildAgentCard(server, overrides) {
|
|
383
|
+
if (overrides.preferredTransport && overrides.preferredTransport.toUpperCase() !== "JSONRPC") {
|
|
384
|
+
throw new Error("createA2AAdapter: only the JSONRPC A2A transport is supported");
|
|
385
|
+
}
|
|
316
386
|
const tools = listRegisteredTools(server);
|
|
317
|
-
const skills = filterPublicAgentCardSkills(
|
|
387
|
+
const skills = filterPublicAgentCardSkills(
|
|
388
|
+
overrides.skills ? normalizeAgentCardSkills(overrides.skills) : deriveSkills(tools)
|
|
389
|
+
);
|
|
318
390
|
if (tools.includes("get_adcp_capabilities") && !skills.some((skill) => skill.id === "get_adcp_capabilities" || skill.name === "get_adcp_capabilities")) {
|
|
319
391
|
skills.push(...deriveSkills(["get_adcp_capabilities"]));
|
|
320
392
|
}
|
|
321
393
|
const card = {
|
|
322
394
|
name: overrides.name,
|
|
323
395
|
description: overrides.description,
|
|
324
|
-
|
|
396
|
+
supportedInterfaces: (0, import_v0_3.duplicateInterfacesForLegacy)(
|
|
397
|
+
[
|
|
398
|
+
{
|
|
399
|
+
url: overrides.url,
|
|
400
|
+
protocolBinding: "JSONRPC",
|
|
401
|
+
protocolVersion: DEFAULT_PROTOCOL_VERSION,
|
|
402
|
+
tenant: ""
|
|
403
|
+
}
|
|
404
|
+
],
|
|
405
|
+
["JSONRPC"]
|
|
406
|
+
),
|
|
325
407
|
version: overrides.version,
|
|
326
|
-
protocolVersion: overrides.protocolVersion ?? DEFAULT_PROTOCOL_VERSION,
|
|
327
408
|
defaultInputModes: overrides.defaultInputModes ?? [...DEFAULT_MODES],
|
|
328
409
|
defaultOutputModes: overrides.defaultOutputModes ?? [...DEFAULT_MODES],
|
|
329
|
-
capabilities:
|
|
330
|
-
streaming: false,
|
|
331
|
-
pushNotifications: false
|
|
410
|
+
capabilities: {
|
|
411
|
+
streaming: overrides.capabilities?.streaming ?? false,
|
|
412
|
+
pushNotifications: overrides.capabilities?.pushNotifications ?? false,
|
|
413
|
+
extendedAgentCard: overrides.capabilities?.extendedAgentCard,
|
|
414
|
+
extensions: [
|
|
415
|
+
...(overrides.capabilities?.extensions ?? []).filter((extension) => extension.uri !== ADCP_A2A_EXTENSION),
|
|
416
|
+
{
|
|
417
|
+
uri: ADCP_A2A_EXTENSION,
|
|
418
|
+
description: "AdCP structured task invocation profile",
|
|
419
|
+
required: true,
|
|
420
|
+
params: void 0
|
|
421
|
+
}
|
|
422
|
+
]
|
|
332
423
|
},
|
|
333
424
|
skills,
|
|
334
|
-
|
|
425
|
+
provider: overrides.provider,
|
|
426
|
+
securitySchemes: normalizeSecuritySchemes(overrides.securitySchemes),
|
|
427
|
+
securityRequirements: (overrides.security ?? []).map((requirement) => ({
|
|
428
|
+
schemes: Object.fromEntries(Object.entries(requirement).map(([name, scopes]) => [name, { list: scopes }]))
|
|
429
|
+
})),
|
|
430
|
+
signatures: [],
|
|
335
431
|
...overrides.documentationUrl && { documentationUrl: overrides.documentationUrl },
|
|
336
|
-
...overrides.iconUrl && { iconUrl: overrides.iconUrl }
|
|
337
|
-
...overrides.securitySchemes && { securitySchemes: overrides.securitySchemes },
|
|
338
|
-
...overrides.security && { security: overrides.security },
|
|
339
|
-
...overrides.preferredTransport && { preferredTransport: overrides.preferredTransport }
|
|
432
|
+
...overrides.iconUrl && { iconUrl: overrides.iconUrl }
|
|
340
433
|
};
|
|
434
|
+
Object.defineProperties(card, {
|
|
435
|
+
url: { value: overrides.url, enumerable: false },
|
|
436
|
+
protocolVersion: { value: DEFAULT_PROTOCOL_VERSION, enumerable: false },
|
|
437
|
+
// The SDK's Express card middleware currently calls JSON.stringify on the
|
|
438
|
+
// ts-proto in-memory shape. Supply the official JSON projection so v1
|
|
439
|
+
// security-scheme unions serialize as `type`/`scheme`, not `$case`.
|
|
440
|
+
toJSON: { value: () => import_sdk.AgentCard.toJSON(card), enumerable: false }
|
|
441
|
+
});
|
|
341
442
|
validateAgentCard(card);
|
|
342
443
|
return card;
|
|
343
444
|
}
|
|
445
|
+
function normalizeSecuritySchemes(schemes) {
|
|
446
|
+
return Object.fromEntries(
|
|
447
|
+
Object.entries(schemes ?? {}).map(([name, value]) => {
|
|
448
|
+
const candidate = value;
|
|
449
|
+
if (candidate.scheme && typeof candidate.scheme === "object" && "$case" in candidate.scheme) {
|
|
450
|
+
return [name, value];
|
|
451
|
+
}
|
|
452
|
+
const legacy = value;
|
|
453
|
+
switch (legacy.type) {
|
|
454
|
+
case "apiKey":
|
|
455
|
+
return [
|
|
456
|
+
name,
|
|
457
|
+
{
|
|
458
|
+
scheme: {
|
|
459
|
+
$case: "apiKeySecurityScheme",
|
|
460
|
+
value: { description: legacy.description ?? "", location: legacy.in, name: legacy.name }
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
];
|
|
464
|
+
case "http":
|
|
465
|
+
return [
|
|
466
|
+
name,
|
|
467
|
+
{
|
|
468
|
+
scheme: {
|
|
469
|
+
$case: "httpAuthSecurityScheme",
|
|
470
|
+
value: {
|
|
471
|
+
description: legacy.description ?? "",
|
|
472
|
+
scheme: legacy.scheme,
|
|
473
|
+
bearerFormat: legacy.bearerFormat ?? ""
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
];
|
|
478
|
+
case "oauth2":
|
|
479
|
+
return [
|
|
480
|
+
name,
|
|
481
|
+
{
|
|
482
|
+
scheme: {
|
|
483
|
+
$case: "oauth2SecurityScheme",
|
|
484
|
+
value: {
|
|
485
|
+
description: legacy.description ?? "",
|
|
486
|
+
oauth2MetadataUrl: legacy.oauth2MetadataUrl ?? "",
|
|
487
|
+
flows: normalizeLegacyOAuthFlows(legacy.flows)
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
];
|
|
492
|
+
case "openIdConnect":
|
|
493
|
+
return [
|
|
494
|
+
name,
|
|
495
|
+
{
|
|
496
|
+
scheme: {
|
|
497
|
+
$case: "openIdConnectSecurityScheme",
|
|
498
|
+
value: {
|
|
499
|
+
description: legacy.description ?? "",
|
|
500
|
+
openIdConnectUrl: legacy.openIdConnectUrl
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
];
|
|
505
|
+
case "mutualTLS":
|
|
506
|
+
return [
|
|
507
|
+
name,
|
|
508
|
+
{
|
|
509
|
+
scheme: {
|
|
510
|
+
$case: "mtlsSecurityScheme",
|
|
511
|
+
value: { description: legacy.description ?? "" }
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
];
|
|
515
|
+
}
|
|
516
|
+
throw new Error(`createA2AAdapter: unsupported security scheme shape for "${name}"`);
|
|
517
|
+
})
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
function normalizeLegacyOAuthFlows(flows) {
|
|
521
|
+
const selected = flows.authorizationCode ? ["authorizationCode", flows.authorizationCode] : flows.clientCredentials ? ["clientCredentials", flows.clientCredentials] : flows.implicit ? ["implicit", flows.implicit] : flows.password ? ["password", flows.password] : void 0;
|
|
522
|
+
if (!selected) return void 0;
|
|
523
|
+
const [kind, flow] = selected;
|
|
524
|
+
return {
|
|
525
|
+
flow: {
|
|
526
|
+
$case: kind,
|
|
527
|
+
value: {
|
|
528
|
+
authorizationUrl: flow.authorizationUrl ?? "",
|
|
529
|
+
tokenUrl: flow.tokenUrl ?? "",
|
|
530
|
+
refreshUrl: flow.refreshUrl ?? "",
|
|
531
|
+
scopes: flow.scopes,
|
|
532
|
+
...kind === "authorizationCode" && { pkceRequired: false }
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
}
|
|
344
537
|
function validateAgentCard(card) {
|
|
345
538
|
const missing = [];
|
|
346
539
|
if (!card.name) missing.push("name");
|
|
347
540
|
if (!card.description) missing.push("description");
|
|
348
|
-
if (!card.url) missing.push("url");
|
|
541
|
+
if (!card.supportedInterfaces?.[0]?.url) missing.push("supportedInterfaces[0].url");
|
|
349
542
|
if (!card.version) missing.push("version");
|
|
350
|
-
if (
|
|
543
|
+
if (card.supportedInterfaces?.[0]?.protocolVersion !== DEFAULT_PROTOCOL_VERSION) missing.push("protocolVersion=1.0");
|
|
351
544
|
if (!card.capabilities) missing.push("capabilities");
|
|
352
545
|
if (!Array.isArray(card.defaultInputModes) || card.defaultInputModes.length === 0) {
|
|
353
546
|
missing.push("defaultInputModes");
|
|
@@ -376,10 +569,22 @@ const DEFAULT_LOGGER = {
|
|
|
376
569
|
function createA2AAdapter(options) {
|
|
377
570
|
const logger = options.logger ?? DEFAULT_LOGGER;
|
|
378
571
|
const card = buildAgentCard(options.server, options.agentCard);
|
|
379
|
-
const
|
|
572
|
+
const handlerCard = structuredClone(card);
|
|
573
|
+
if (handlerCard.capabilities?.extensions) {
|
|
574
|
+
handlerCard.capabilities.extensions = handlerCard.capabilities.extensions.map(
|
|
575
|
+
(extension) => extension.uri === ADCP_A2A_EXTENSION ? { ...extension, required: false } : extension
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
const development = process.env.NODE_ENV === "test" || process.env.NODE_ENV === "development";
|
|
579
|
+
if (!options.taskStore && !development) {
|
|
580
|
+
throw new Error(
|
|
581
|
+
"createA2AAdapter: production requires a bounded durable taskStore; the SDK in-memory store is available only under NODE_ENV=test or NODE_ENV=development"
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
const taskStore = new RedactingA2ATaskStore(options.taskStore ?? new import_server.InMemoryTaskStore());
|
|
380
585
|
const executor = new AdcpA2AAgentExecutor(options.server, logger);
|
|
381
586
|
const eventBusManager = new import_server.DefaultExecutionEventBusManager();
|
|
382
|
-
const requestHandler = new import_server.DefaultRequestHandler(
|
|
587
|
+
const requestHandler = new import_server.DefaultRequestHandler(handlerCard, taskStore, executor, eventBusManager);
|
|
383
588
|
const userBuilder = async (req) => {
|
|
384
589
|
if (!options.authenticate) return buildAnonymousUser();
|
|
385
590
|
const authInfo = await options.authenticate(req);
|
|
@@ -388,11 +593,17 @@ function createA2AAdapter(options) {
|
|
|
388
593
|
}
|
|
389
594
|
return buildAuthenticatedUser(authInfo);
|
|
390
595
|
};
|
|
391
|
-
const
|
|
392
|
-
const
|
|
596
|
+
const legacyCompat = { enabled: true };
|
|
597
|
+
const jsonRpc = (0, import_express.jsonRpcHandler)({ requestHandler, userBuilder, legacyCompat });
|
|
598
|
+
const nativeAgentCardMiddleware = (0, import_express.agentCardHandler)({ agentCardProvider: async () => card });
|
|
599
|
+
const legacyAgentCardMiddleware = (0, import_express.agentCardHandler)({ agentCardProvider: async () => handlerCard, legacyCompat });
|
|
600
|
+
const agentCardMiddleware = (req, res, next) => {
|
|
601
|
+
const requestedVersion = req.header("A2A-Version");
|
|
602
|
+
return requestedVersion && !requestedVersion.startsWith("0.") ? nativeAgentCardMiddleware(req, res, next) : legacyAgentCardMiddleware(req, res, next);
|
|
603
|
+
};
|
|
393
604
|
const defaultBasePath = (() => {
|
|
394
605
|
try {
|
|
395
|
-
const parsed = new URL(card.url);
|
|
606
|
+
const parsed = new URL(card.supportedInterfaces[0].url);
|
|
396
607
|
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
397
608
|
return pathname.length > 0 ? pathname : "/a2a";
|
|
398
609
|
} catch {
|