@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
|
@@ -13,8 +13,7 @@ import { beta6ReportingRequestIssue } from "../media-buy/reporting-version.mjs";
|
|
|
13
13
|
import { getVersionAdapter, resolveAdapterKey } from "../adapters/version/index.mjs";
|
|
14
14
|
import { isExternalSchemaRootActive, schemaAllowsTopLevelField } from "../validation/schema-loader.mjs";
|
|
15
15
|
import { generateIdempotencyKey, requestUsesIdempotency } from "../utils/idempotency.mjs";
|
|
16
|
-
import {
|
|
17
|
-
const A2AClient = A2AClientImpl;
|
|
16
|
+
import { createA2AClientFromCardUrl } from "../protocols/a2a.mjs";
|
|
18
17
|
import {
|
|
19
18
|
TaskExecutor,
|
|
20
19
|
DEFERRED_SETTLEMENT_ACK,
|
|
@@ -128,6 +127,51 @@ import {
|
|
|
128
127
|
import { isProjectionProductInput } from "../v2/projection/types.mjs";
|
|
129
128
|
import { canonicalize as canonicalizeJson } from "../utils/jcs.mjs";
|
|
130
129
|
const CAPABILITY_DISCOVERY_CONTEXT = /* @__PURE__ */ Symbol("capabilityDiscoveryContext");
|
|
130
|
+
function a2aUrlString(input) {
|
|
131
|
+
return typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
132
|
+
}
|
|
133
|
+
function a2aScopedHeaders(input, requestHeaders, configuredAgentUrl, agentHeaders, authToken) {
|
|
134
|
+
const normalized = {};
|
|
135
|
+
new Headers(requestHeaders).forEach((value, key) => {
|
|
136
|
+
normalized[key] = value;
|
|
137
|
+
});
|
|
138
|
+
const sameOrigin = new URL(a2aUrlString(input)).origin === new URL(configuredAgentUrl).origin;
|
|
139
|
+
if (!sameOrigin) {
|
|
140
|
+
for (const key of Object.keys(normalized)) {
|
|
141
|
+
if (!["accept", "content-type", "a2a-version", "a2a-extensions"].includes(key.toLowerCase())) {
|
|
142
|
+
delete normalized[key];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return normalized;
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
...normalized,
|
|
149
|
+
...agentHeaders,
|
|
150
|
+
...authToken && {
|
|
151
|
+
Authorization: `Bearer ${authToken}`,
|
|
152
|
+
"x-adcp-auth": authToken
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function sameA2AProtocolVersion(left, right) {
|
|
157
|
+
if (typeof left !== "string" || typeof right !== "string") return false;
|
|
158
|
+
const normalize = (value) => value.split(".").slice(0, 2).join(".");
|
|
159
|
+
return normalize(left) === normalize(right);
|
|
160
|
+
}
|
|
161
|
+
function selectA2AJsonRpcUrl(agentCard, protocolVersion, configuredAgentUrl) {
|
|
162
|
+
const interfaces = Array.isArray(agentCard?.supportedInterfaces) ? agentCard.supportedInterfaces.filter(
|
|
163
|
+
(candidate) => candidate?.protocolBinding === "JSONRPC" && typeof candidate?.url === "string"
|
|
164
|
+
) : [];
|
|
165
|
+
const selected = interfaces.find((candidate) => sameA2AProtocolVersion(candidate.protocolVersion, protocolVersion)) ?? interfaces.find((candidate) => sameA2AProtocolVersion(candidate.protocolVersion, "1.0")) ?? interfaces[0];
|
|
166
|
+
if (!selected) return void 0;
|
|
167
|
+
const resolved = new URL(selected.url, configuredAgentUrl);
|
|
168
|
+
if (resolved.origin !== new URL(configuredAgentUrl).origin) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
`A2A Agent Card selected a cross-origin JSON-RPC endpoint (${resolved.origin}); configure that endpoint explicitly before sending credentials`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return resolved.toString();
|
|
174
|
+
}
|
|
131
175
|
function creativeSchemaSupport(value, depth = 0) {
|
|
132
176
|
if (depth > 24 || value === null || typeof value !== "object") return "unknown";
|
|
133
177
|
if (Array.isArray(value)) {
|
|
@@ -1459,14 +1503,7 @@ class SingleAgentClient {
|
|
|
1459
1503
|
const authToken = this.normalizedAgent.oauth_client_credentials ? this.normalizedAgent.oauth_tokens?.access_token : this.normalizedAgent.auth_token;
|
|
1460
1504
|
let got401 = false;
|
|
1461
1505
|
const fetchImpl = async (url, requestInit) => {
|
|
1462
|
-
const headers =
|
|
1463
|
-
...requestInit?.headers,
|
|
1464
|
-
...this.normalizedAgent.headers,
|
|
1465
|
-
...authToken && {
|
|
1466
|
-
Authorization: `Bearer ${authToken}`,
|
|
1467
|
-
"x-adcp-auth": authToken
|
|
1468
|
-
}
|
|
1469
|
-
};
|
|
1506
|
+
const headers = a2aScopedHeaders(url, requestInit?.headers, agentUri, this.normalizedAgent.headers, authToken);
|
|
1470
1507
|
const response = await withAbortSignal(
|
|
1471
1508
|
[readOptions?.signal, requestInit?.signal],
|
|
1472
1509
|
requestTimeoutMs,
|
|
@@ -1483,7 +1520,7 @@ class SingleAgentClient {
|
|
|
1483
1520
|
let lastError = new Error(`A2A agent card not found at ${cardUrls.join(", ")}`);
|
|
1484
1521
|
for (const cardUrl of cardUrls) {
|
|
1485
1522
|
try {
|
|
1486
|
-
client = await withResponseSizeLimit(maxResponseBytes, () =>
|
|
1523
|
+
client = await withResponseSizeLimit(maxResponseBytes, () => createA2AClientFromCardUrl(cardUrl, fetchImpl));
|
|
1487
1524
|
break;
|
|
1488
1525
|
} catch (err) {
|
|
1489
1526
|
lastError = err;
|
|
@@ -1493,13 +1530,12 @@ class SingleAgentClient {
|
|
|
1493
1530
|
if (!client) {
|
|
1494
1531
|
throw lastError;
|
|
1495
1532
|
}
|
|
1496
|
-
const agentCard = await withResponseSizeLimit(
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
);
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
}
|
|
1533
|
+
const agentCard = await withResponseSizeLimit(maxResponseBytes, async () => {
|
|
1534
|
+
const compatibleClient = client;
|
|
1535
|
+
return typeof compatibleClient.getAgentCard === "function" ? compatibleClient.getAgentCard() : compatibleClient.agentCardPromise ?? compatibleClient.agentCard;
|
|
1536
|
+
});
|
|
1537
|
+
const canonicalUrl = selectA2AJsonRpcUrl(agentCard, client.protocolVersion, agentUri);
|
|
1538
|
+
if (canonicalUrl) return canonicalUrl;
|
|
1503
1539
|
return this.computeBaseUrl(agentUri);
|
|
1504
1540
|
} catch (error) {
|
|
1505
1541
|
if (is401Error(error, got401)) {
|
|
@@ -2449,8 +2485,9 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
2449
2485
|
"Unsupported webhook payload format: received a bare delivery report result. Webhook POST bodies must be an MCP envelope with top-level idempotency_key, operation_id, task_id, task_type, status, timestamp, and result, or an A2A task/status event. Put delivery fields under result."
|
|
2450
2486
|
);
|
|
2451
2487
|
}
|
|
2452
|
-
|
|
2453
|
-
|
|
2488
|
+
const normalizedA2APayload = normalizeA2AWebhookEnvelope(payload);
|
|
2489
|
+
if (normalizedA2APayload) {
|
|
2490
|
+
const a2aPayload = normalizedA2APayload;
|
|
2454
2491
|
const statusMessageData = latestA2AWebhookMessageData(a2aPayload.status?.message?.parts);
|
|
2455
2492
|
const artifactExtraction = a2aPayload.kind === "task" ? getLatestA2ADataPartFromTask(a2aPayload) : void 0;
|
|
2456
2493
|
const artifactData = artifactExtraction?.data;
|
|
@@ -2502,7 +2539,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
2502
2539
|
);
|
|
2503
2540
|
}
|
|
2504
2541
|
const result = Object.hasOwn(adcpData, "result") ? adcpData.result : adcpData;
|
|
2505
|
-
const textParts =
|
|
2542
|
+
const textParts = latestA2AWebhookTextParts(a2aPayload.status?.message?.parts);
|
|
2506
2543
|
return {
|
|
2507
2544
|
operation_id: operationId,
|
|
2508
2545
|
context_id: responseParser.getContextId(wrapped),
|
|
@@ -5468,35 +5505,15 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5468
5505
|
const { wrapFetchWithSizeLimit } = await import("../protocols/responseSizeLimit.mjs");
|
|
5469
5506
|
const authToken = await ensureReadAuthToken();
|
|
5470
5507
|
const agentHeaders = this.normalizedAgent.headers ?? {};
|
|
5508
|
+
const configuredAgentUrl = this.normalizedAgent.agent_uri;
|
|
5471
5509
|
const sizeLimitedFetch = wrapFetchWithSizeLimit(
|
|
5472
|
-
(
|
|
5510
|
+
createAgentTransportFetch(configuredAgentUrl, {
|
|
5511
|
+
trustedFetchFn: transport?.trustedFetchFn,
|
|
5512
|
+
allowPrivateIp: transport?.allowPrivateIp
|
|
5513
|
+
})
|
|
5473
5514
|
);
|
|
5474
|
-
const normalizeHeaders = (headers) => {
|
|
5475
|
-
const normalized = {};
|
|
5476
|
-
if (!headers) return normalized;
|
|
5477
|
-
if (headers instanceof Headers) {
|
|
5478
|
-
headers.forEach((value, key) => {
|
|
5479
|
-
normalized[key] = value;
|
|
5480
|
-
});
|
|
5481
|
-
} else if (Array.isArray(headers)) {
|
|
5482
|
-
for (const [key, value] of headers) {
|
|
5483
|
-
normalized[key] = value;
|
|
5484
|
-
}
|
|
5485
|
-
} else {
|
|
5486
|
-
Object.assign(normalized, headers);
|
|
5487
|
-
}
|
|
5488
|
-
return normalized;
|
|
5489
|
-
};
|
|
5490
|
-
const buildHeaders = (requestInit) => ({
|
|
5491
|
-
...normalizeHeaders(requestInit?.headers),
|
|
5492
|
-
...agentHeaders,
|
|
5493
|
-
...authToken && {
|
|
5494
|
-
Authorization: `Bearer ${authToken}`,
|
|
5495
|
-
"x-adcp-auth": authToken
|
|
5496
|
-
}
|
|
5497
|
-
});
|
|
5498
5515
|
const fetchImpl = async (url, requestInit) => {
|
|
5499
|
-
const headers =
|
|
5516
|
+
const headers = a2aScopedHeaders(url, requestInit?.headers, configuredAgentUrl, agentHeaders, authToken);
|
|
5500
5517
|
return withAbortSignal(
|
|
5501
5518
|
[options?.signal, requestInit?.signal],
|
|
5502
5519
|
requestTimeoutMs,
|
|
@@ -5508,7 +5525,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5508
5525
|
let lastCardError = new Error(`A2A agent card not found at ${cardUrls.join(", ")}`);
|
|
5509
5526
|
for (const cardUrl of cardUrls) {
|
|
5510
5527
|
try {
|
|
5511
|
-
client = await withResponseSizeLimit(maxResponseBytes, () =>
|
|
5528
|
+
client = await withResponseSizeLimit(maxResponseBytes, () => createA2AClientFromCardUrl(cardUrl, fetchImpl));
|
|
5512
5529
|
break;
|
|
5513
5530
|
} catch (err) {
|
|
5514
5531
|
lastCardError = err;
|
|
@@ -5517,10 +5534,10 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5517
5534
|
if (!client) {
|
|
5518
5535
|
throw lastCardError;
|
|
5519
5536
|
}
|
|
5520
|
-
const agentCard = await withResponseSizeLimit(
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
);
|
|
5537
|
+
const agentCard = await withResponseSizeLimit(maxResponseBytes, async () => {
|
|
5538
|
+
const compatibleClient = client;
|
|
5539
|
+
return typeof compatibleClient.getAgentCard === "function" ? compatibleClient.getAgentCard() : compatibleClient.agentCardPromise ?? compatibleClient.agentCard;
|
|
5540
|
+
});
|
|
5524
5541
|
const tools = agentCard?.skills ? agentCard.skills.map(
|
|
5525
5542
|
(skill) => ({
|
|
5526
5543
|
name: skill.id || skill.name,
|
|
@@ -5530,7 +5547,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5530
5547
|
})
|
|
5531
5548
|
) : [];
|
|
5532
5549
|
return {
|
|
5533
|
-
name: agentCard?.
|
|
5550
|
+
name: agentCard?.name || this.normalizedAgent.name,
|
|
5534
5551
|
description: agentCard?.description,
|
|
5535
5552
|
protocol: this.normalizedAgent.protocol,
|
|
5536
5553
|
url: this.normalizedAgent.agent_uri,
|
|
@@ -6248,26 +6265,55 @@ function normalizeRfc9421WebhookHeaders(headers) {
|
|
|
6248
6265
|
function isBareDeliveryReport(payload) {
|
|
6249
6266
|
return typeof payload.notification_type === "string" && ("media_buy_deliveries" in payload || "creative_deliveries" in payload || "reporting_period" in payload) && !("result" in payload) && !("task_id" in payload);
|
|
6250
6267
|
}
|
|
6268
|
+
function normalizeA2AWebhookEnvelope(payload) {
|
|
6269
|
+
if (payload.kind === "task" || payload.kind === "status-update") return payload;
|
|
6270
|
+
const oneof = isObjectRecord(payload.payload) ? payload.payload : void 0;
|
|
6271
|
+
const oneofCase = oneof?.$case;
|
|
6272
|
+
const oneofValue = isObjectRecord(oneof?.value) ? oneof.value : void 0;
|
|
6273
|
+
if (oneofValue && oneofCase === "task") return { ...oneofValue, kind: "task" };
|
|
6274
|
+
if (oneofValue && oneofCase === "statusUpdate") return { ...oneofValue, kind: "status-update" };
|
|
6275
|
+
if (isObjectRecord(payload.task)) return { ...payload.task, kind: "task" };
|
|
6276
|
+
if (isObjectRecord(payload.statusUpdate)) return { ...payload.statusUpdate, kind: "status-update" };
|
|
6277
|
+
if (typeof payload.id === "string" && isObjectRecord(payload.status) && Array.isArray(payload.artifacts)) {
|
|
6278
|
+
return { ...payload, kind: "task" };
|
|
6279
|
+
}
|
|
6280
|
+
if (typeof payload.taskId === "string" && isObjectRecord(payload.status) && !("artifact" in payload)) {
|
|
6281
|
+
return { ...payload, kind: "status-update" };
|
|
6282
|
+
}
|
|
6283
|
+
return void 0;
|
|
6284
|
+
}
|
|
6285
|
+
function a2aWebhookPartValue(part, expectedCase) {
|
|
6286
|
+
if (!isObjectRecord(part)) return void 0;
|
|
6287
|
+
if (part.kind === expectedCase) return part[expectedCase];
|
|
6288
|
+
if (part.kind === void 0 && Object.hasOwn(part, expectedCase)) return part[expectedCase];
|
|
6289
|
+
const content = isObjectRecord(part.content) ? part.content : void 0;
|
|
6290
|
+
return content?.$case === expectedCase ? content.value : void 0;
|
|
6291
|
+
}
|
|
6251
6292
|
function latestA2AWebhookMessageData(parts) {
|
|
6252
6293
|
if (!Array.isArray(parts)) return void 0;
|
|
6253
6294
|
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
6254
|
-
const
|
|
6255
|
-
if (!isObjectRecord(
|
|
6256
|
-
return
|
|
6295
|
+
const data = a2aWebhookPartValue(parts[index], "data");
|
|
6296
|
+
if (!isObjectRecord(data)) continue;
|
|
6297
|
+
return data;
|
|
6257
6298
|
}
|
|
6258
6299
|
return void 0;
|
|
6259
6300
|
}
|
|
6301
|
+
function latestA2AWebhookTextParts(parts) {
|
|
6302
|
+
if (!Array.isArray(parts)) return [];
|
|
6303
|
+
return parts.map((part) => a2aWebhookPartValue(part, "text")).filter((value) => typeof value === "string");
|
|
6304
|
+
}
|
|
6260
6305
|
function extractSignedWebhookRoute(payload) {
|
|
6261
6306
|
if (!isObjectRecord(payload)) return { ok: true };
|
|
6307
|
+
const normalizedA2A = normalizeA2AWebhookEnvelope(payload);
|
|
6262
6308
|
const records = [payload];
|
|
6263
|
-
if (
|
|
6309
|
+
if (normalizedA2A) {
|
|
6264
6310
|
records.length = 0;
|
|
6265
|
-
const status = isObjectRecord(
|
|
6311
|
+
const status = isObjectRecord(normalizedA2A.status) ? normalizedA2A.status : void 0;
|
|
6266
6312
|
const message = isObjectRecord(status?.message) ? status.message : void 0;
|
|
6267
6313
|
const messageData = latestA2AWebhookMessageData(message?.parts);
|
|
6268
6314
|
if (messageData) records.push(messageData);
|
|
6269
|
-
if (
|
|
6270
|
-
const artifactData = getLatestA2ADataPartFromTask(
|
|
6315
|
+
if (normalizedA2A.kind === "task") {
|
|
6316
|
+
const artifactData = getLatestA2ADataPartFromTask(normalizedA2A)?.data;
|
|
6271
6317
|
if (artifactData) records.push(artifactData);
|
|
6272
6318
|
}
|
|
6273
6319
|
}
|
|
@@ -6296,11 +6342,14 @@ function extractSignedWebhookRoute(payload) {
|
|
|
6296
6342
|
function legacyA2AArtifactStatus(payload, artifact) {
|
|
6297
6343
|
if (payload.kind !== "task" || !isObjectRecord(artifact) || typeof artifact.name !== "string") return void 0;
|
|
6298
6344
|
const transportState = payload.status?.state;
|
|
6299
|
-
if (artifact.name === "result" && transportState === "completed"
|
|
6345
|
+
if (artifact.name === "result" && (transportState === "completed" || transportState === "TASK_STATE_COMPLETED" || transportState === 3))
|
|
6346
|
+
return "completed";
|
|
6300
6347
|
if (artifact.name !== "error") return void 0;
|
|
6301
|
-
if (transportState === "failed" || transportState === "
|
|
6302
|
-
|
|
6303
|
-
|
|
6348
|
+
if (transportState === "failed" || transportState === "TASK_STATE_FAILED" || transportState === 4) return "failed";
|
|
6349
|
+
if (transportState === "rejected" || transportState === "TASK_STATE_REJECTED" || transportState === 7)
|
|
6350
|
+
return "rejected";
|
|
6351
|
+
if (transportState === "canceled" || transportState === "TASK_STATE_CANCELED" || transportState === 5)
|
|
6352
|
+
return "canceled";
|
|
6304
6353
|
return void 0;
|
|
6305
6354
|
}
|
|
6306
6355
|
function isMcpWebhookCandidate(payload) {
|