@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
|
@@ -43,7 +43,7 @@ var import_reporting_version = require('../media-buy/reporting-version.js');
|
|
|
43
43
|
var import_version2 = require('../adapters/version/index.js');
|
|
44
44
|
var import_schema_loader = require('../validation/schema-loader.js');
|
|
45
45
|
var import_idempotency = require('../utils/idempotency.js');
|
|
46
|
-
var
|
|
46
|
+
var import_a2a = require('../protocols/a2a.js');
|
|
47
47
|
var import_TaskExecutor = require('./TaskExecutor.js');
|
|
48
48
|
var import_match = require('./match.js');
|
|
49
49
|
var import_request_proposals_guard = require('./request-proposals-guard.js');
|
|
@@ -79,8 +79,52 @@ var import_augment_response = require('../v2/projection/augment-response.js');
|
|
|
79
79
|
var import_legacy_metadata = require('../v2/projection/legacy-metadata.js');
|
|
80
80
|
var import_types = require('../v2/projection/types.js');
|
|
81
81
|
var import_jcs = require('../utils/jcs.js');
|
|
82
|
-
const A2AClient = import_client.A2AClient;
|
|
83
82
|
const CAPABILITY_DISCOVERY_CONTEXT = /* @__PURE__ */ Symbol("capabilityDiscoveryContext");
|
|
83
|
+
function a2aUrlString(input) {
|
|
84
|
+
return typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
85
|
+
}
|
|
86
|
+
function a2aScopedHeaders(input, requestHeaders, configuredAgentUrl, agentHeaders, authToken) {
|
|
87
|
+
const normalized = {};
|
|
88
|
+
new Headers(requestHeaders).forEach((value, key) => {
|
|
89
|
+
normalized[key] = value;
|
|
90
|
+
});
|
|
91
|
+
const sameOrigin = new URL(a2aUrlString(input)).origin === new URL(configuredAgentUrl).origin;
|
|
92
|
+
if (!sameOrigin) {
|
|
93
|
+
for (const key of Object.keys(normalized)) {
|
|
94
|
+
if (!["accept", "content-type", "a2a-version", "a2a-extensions"].includes(key.toLowerCase())) {
|
|
95
|
+
delete normalized[key];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return normalized;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
...normalized,
|
|
102
|
+
...agentHeaders,
|
|
103
|
+
...authToken && {
|
|
104
|
+
Authorization: `Bearer ${authToken}`,
|
|
105
|
+
"x-adcp-auth": authToken
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function sameA2AProtocolVersion(left, right) {
|
|
110
|
+
if (typeof left !== "string" || typeof right !== "string") return false;
|
|
111
|
+
const normalize = (value) => value.split(".").slice(0, 2).join(".");
|
|
112
|
+
return normalize(left) === normalize(right);
|
|
113
|
+
}
|
|
114
|
+
function selectA2AJsonRpcUrl(agentCard, protocolVersion, configuredAgentUrl) {
|
|
115
|
+
const interfaces = Array.isArray(agentCard?.supportedInterfaces) ? agentCard.supportedInterfaces.filter(
|
|
116
|
+
(candidate) => candidate?.protocolBinding === "JSONRPC" && typeof candidate?.url === "string"
|
|
117
|
+
) : [];
|
|
118
|
+
const selected = interfaces.find((candidate) => sameA2AProtocolVersion(candidate.protocolVersion, protocolVersion)) ?? interfaces.find((candidate) => sameA2AProtocolVersion(candidate.protocolVersion, "1.0")) ?? interfaces[0];
|
|
119
|
+
if (!selected) return void 0;
|
|
120
|
+
const resolved = new URL(selected.url, configuredAgentUrl);
|
|
121
|
+
if (resolved.origin !== new URL(configuredAgentUrl).origin) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`A2A Agent Card selected a cross-origin JSON-RPC endpoint (${resolved.origin}); configure that endpoint explicitly before sending credentials`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return resolved.toString();
|
|
127
|
+
}
|
|
84
128
|
function creativeSchemaSupport(value, depth = 0) {
|
|
85
129
|
if (depth > 24 || value === null || typeof value !== "object") return "unknown";
|
|
86
130
|
if (Array.isArray(value)) {
|
|
@@ -1412,14 +1456,7 @@ class SingleAgentClient {
|
|
|
1412
1456
|
const authToken = this.normalizedAgent.oauth_client_credentials ? this.normalizedAgent.oauth_tokens?.access_token : this.normalizedAgent.auth_token;
|
|
1413
1457
|
let got401 = false;
|
|
1414
1458
|
const fetchImpl = async (url, requestInit) => {
|
|
1415
|
-
const headers =
|
|
1416
|
-
...requestInit?.headers,
|
|
1417
|
-
...this.normalizedAgent.headers,
|
|
1418
|
-
...authToken && {
|
|
1419
|
-
Authorization: `Bearer ${authToken}`,
|
|
1420
|
-
"x-adcp-auth": authToken
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1459
|
+
const headers = a2aScopedHeaders(url, requestInit?.headers, agentUri, this.normalizedAgent.headers, authToken);
|
|
1423
1460
|
const response = await (0, import_abort2.withAbortSignal)(
|
|
1424
1461
|
[readOptions?.signal, requestInit?.signal],
|
|
1425
1462
|
requestTimeoutMs,
|
|
@@ -1436,7 +1473,7 @@ class SingleAgentClient {
|
|
|
1436
1473
|
let lastError = new Error(`A2A agent card not found at ${cardUrls.join(", ")}`);
|
|
1437
1474
|
for (const cardUrl of cardUrls) {
|
|
1438
1475
|
try {
|
|
1439
|
-
client = await withResponseSizeLimit(maxResponseBytes, () =>
|
|
1476
|
+
client = await withResponseSizeLimit(maxResponseBytes, () => (0, import_a2a.createA2AClientFromCardUrl)(cardUrl, fetchImpl));
|
|
1440
1477
|
break;
|
|
1441
1478
|
} catch (err) {
|
|
1442
1479
|
lastError = err;
|
|
@@ -1446,13 +1483,12 @@ class SingleAgentClient {
|
|
|
1446
1483
|
if (!client) {
|
|
1447
1484
|
throw lastError;
|
|
1448
1485
|
}
|
|
1449
|
-
const agentCard = await withResponseSizeLimit(
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
);
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
}
|
|
1486
|
+
const agentCard = await withResponseSizeLimit(maxResponseBytes, async () => {
|
|
1487
|
+
const compatibleClient = client;
|
|
1488
|
+
return typeof compatibleClient.getAgentCard === "function" ? compatibleClient.getAgentCard() : compatibleClient.agentCardPromise ?? compatibleClient.agentCard;
|
|
1489
|
+
});
|
|
1490
|
+
const canonicalUrl = selectA2AJsonRpcUrl(agentCard, client.protocolVersion, agentUri);
|
|
1491
|
+
if (canonicalUrl) return canonicalUrl;
|
|
1456
1492
|
return this.computeBaseUrl(agentUri);
|
|
1457
1493
|
} catch (error) {
|
|
1458
1494
|
if ((0, import_errors.is401Error)(error, got401)) {
|
|
@@ -2402,8 +2438,9 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
2402
2438
|
"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."
|
|
2403
2439
|
);
|
|
2404
2440
|
}
|
|
2405
|
-
|
|
2406
|
-
|
|
2441
|
+
const normalizedA2APayload = normalizeA2AWebhookEnvelope(payload);
|
|
2442
|
+
if (normalizedA2APayload) {
|
|
2443
|
+
const a2aPayload = normalizedA2APayload;
|
|
2407
2444
|
const statusMessageData = latestA2AWebhookMessageData(a2aPayload.status?.message?.parts);
|
|
2408
2445
|
const artifactExtraction = a2aPayload.kind === "task" ? (0, import_a2a_artifacts.getLatestA2ADataPartFromTask)(a2aPayload) : void 0;
|
|
2409
2446
|
const artifactData = artifactExtraction?.data;
|
|
@@ -2455,7 +2492,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
2455
2492
|
);
|
|
2456
2493
|
}
|
|
2457
2494
|
const result = Object.hasOwn(adcpData, "result") ? adcpData.result : adcpData;
|
|
2458
|
-
const textParts =
|
|
2495
|
+
const textParts = latestA2AWebhookTextParts(a2aPayload.status?.message?.parts);
|
|
2459
2496
|
return {
|
|
2460
2497
|
operation_id: operationId,
|
|
2461
2498
|
context_id: import_ProtocolResponseParser.responseParser.getContextId(wrapped),
|
|
@@ -5421,35 +5458,15 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5421
5458
|
const { wrapFetchWithSizeLimit } = await import("../protocols/responseSizeLimit.js");
|
|
5422
5459
|
const authToken = await ensureReadAuthToken();
|
|
5423
5460
|
const agentHeaders = this.normalizedAgent.headers ?? {};
|
|
5461
|
+
const configuredAgentUrl = this.normalizedAgent.agent_uri;
|
|
5424
5462
|
const sizeLimitedFetch = wrapFetchWithSizeLimit(
|
|
5425
|
-
(
|
|
5463
|
+
(0, import_net.createAgentTransportFetch)(configuredAgentUrl, {
|
|
5464
|
+
trustedFetchFn: transport?.trustedFetchFn,
|
|
5465
|
+
allowPrivateIp: transport?.allowPrivateIp
|
|
5466
|
+
})
|
|
5426
5467
|
);
|
|
5427
|
-
const normalizeHeaders = (headers) => {
|
|
5428
|
-
const normalized = {};
|
|
5429
|
-
if (!headers) return normalized;
|
|
5430
|
-
if (headers instanceof Headers) {
|
|
5431
|
-
headers.forEach((value, key) => {
|
|
5432
|
-
normalized[key] = value;
|
|
5433
|
-
});
|
|
5434
|
-
} else if (Array.isArray(headers)) {
|
|
5435
|
-
for (const [key, value] of headers) {
|
|
5436
|
-
normalized[key] = value;
|
|
5437
|
-
}
|
|
5438
|
-
} else {
|
|
5439
|
-
Object.assign(normalized, headers);
|
|
5440
|
-
}
|
|
5441
|
-
return normalized;
|
|
5442
|
-
};
|
|
5443
|
-
const buildHeaders = (requestInit) => ({
|
|
5444
|
-
...normalizeHeaders(requestInit?.headers),
|
|
5445
|
-
...agentHeaders,
|
|
5446
|
-
...authToken && {
|
|
5447
|
-
Authorization: `Bearer ${authToken}`,
|
|
5448
|
-
"x-adcp-auth": authToken
|
|
5449
|
-
}
|
|
5450
|
-
});
|
|
5451
5468
|
const fetchImpl = async (url, requestInit) => {
|
|
5452
|
-
const headers =
|
|
5469
|
+
const headers = a2aScopedHeaders(url, requestInit?.headers, configuredAgentUrl, agentHeaders, authToken);
|
|
5453
5470
|
return (0, import_abort2.withAbortSignal)(
|
|
5454
5471
|
[options?.signal, requestInit?.signal],
|
|
5455
5472
|
requestTimeoutMs,
|
|
@@ -5461,7 +5478,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5461
5478
|
let lastCardError = new Error(`A2A agent card not found at ${cardUrls.join(", ")}`);
|
|
5462
5479
|
for (const cardUrl of cardUrls) {
|
|
5463
5480
|
try {
|
|
5464
|
-
client = await withResponseSizeLimit(maxResponseBytes, () =>
|
|
5481
|
+
client = await withResponseSizeLimit(maxResponseBytes, () => (0, import_a2a.createA2AClientFromCardUrl)(cardUrl, fetchImpl));
|
|
5465
5482
|
break;
|
|
5466
5483
|
} catch (err) {
|
|
5467
5484
|
lastCardError = err;
|
|
@@ -5470,10 +5487,10 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5470
5487
|
if (!client) {
|
|
5471
5488
|
throw lastCardError;
|
|
5472
5489
|
}
|
|
5473
|
-
const agentCard = await withResponseSizeLimit(
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
);
|
|
5490
|
+
const agentCard = await withResponseSizeLimit(maxResponseBytes, async () => {
|
|
5491
|
+
const compatibleClient = client;
|
|
5492
|
+
return typeof compatibleClient.getAgentCard === "function" ? compatibleClient.getAgentCard() : compatibleClient.agentCardPromise ?? compatibleClient.agentCard;
|
|
5493
|
+
});
|
|
5477
5494
|
const tools = agentCard?.skills ? agentCard.skills.map(
|
|
5478
5495
|
(skill) => ({
|
|
5479
5496
|
name: skill.id || skill.name,
|
|
@@ -5483,7 +5500,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5483
5500
|
})
|
|
5484
5501
|
) : [];
|
|
5485
5502
|
return {
|
|
5486
|
-
name: agentCard?.
|
|
5503
|
+
name: agentCard?.name || this.normalizedAgent.name,
|
|
5487
5504
|
description: agentCard?.description,
|
|
5488
5505
|
protocol: this.normalizedAgent.protocol,
|
|
5489
5506
|
url: this.normalizedAgent.agent_uri,
|
|
@@ -6201,26 +6218,55 @@ function normalizeRfc9421WebhookHeaders(headers) {
|
|
|
6201
6218
|
function isBareDeliveryReport(payload) {
|
|
6202
6219
|
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);
|
|
6203
6220
|
}
|
|
6221
|
+
function normalizeA2AWebhookEnvelope(payload) {
|
|
6222
|
+
if (payload.kind === "task" || payload.kind === "status-update") return payload;
|
|
6223
|
+
const oneof = isObjectRecord(payload.payload) ? payload.payload : void 0;
|
|
6224
|
+
const oneofCase = oneof?.$case;
|
|
6225
|
+
const oneofValue = isObjectRecord(oneof?.value) ? oneof.value : void 0;
|
|
6226
|
+
if (oneofValue && oneofCase === "task") return { ...oneofValue, kind: "task" };
|
|
6227
|
+
if (oneofValue && oneofCase === "statusUpdate") return { ...oneofValue, kind: "status-update" };
|
|
6228
|
+
if (isObjectRecord(payload.task)) return { ...payload.task, kind: "task" };
|
|
6229
|
+
if (isObjectRecord(payload.statusUpdate)) return { ...payload.statusUpdate, kind: "status-update" };
|
|
6230
|
+
if (typeof payload.id === "string" && isObjectRecord(payload.status) && Array.isArray(payload.artifacts)) {
|
|
6231
|
+
return { ...payload, kind: "task" };
|
|
6232
|
+
}
|
|
6233
|
+
if (typeof payload.taskId === "string" && isObjectRecord(payload.status) && !("artifact" in payload)) {
|
|
6234
|
+
return { ...payload, kind: "status-update" };
|
|
6235
|
+
}
|
|
6236
|
+
return void 0;
|
|
6237
|
+
}
|
|
6238
|
+
function a2aWebhookPartValue(part, expectedCase) {
|
|
6239
|
+
if (!isObjectRecord(part)) return void 0;
|
|
6240
|
+
if (part.kind === expectedCase) return part[expectedCase];
|
|
6241
|
+
if (part.kind === void 0 && Object.hasOwn(part, expectedCase)) return part[expectedCase];
|
|
6242
|
+
const content = isObjectRecord(part.content) ? part.content : void 0;
|
|
6243
|
+
return content?.$case === expectedCase ? content.value : void 0;
|
|
6244
|
+
}
|
|
6204
6245
|
function latestA2AWebhookMessageData(parts) {
|
|
6205
6246
|
if (!Array.isArray(parts)) return void 0;
|
|
6206
6247
|
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
6207
|
-
const
|
|
6208
|
-
if (!isObjectRecord(
|
|
6209
|
-
return
|
|
6248
|
+
const data = a2aWebhookPartValue(parts[index], "data");
|
|
6249
|
+
if (!isObjectRecord(data)) continue;
|
|
6250
|
+
return data;
|
|
6210
6251
|
}
|
|
6211
6252
|
return void 0;
|
|
6212
6253
|
}
|
|
6254
|
+
function latestA2AWebhookTextParts(parts) {
|
|
6255
|
+
if (!Array.isArray(parts)) return [];
|
|
6256
|
+
return parts.map((part) => a2aWebhookPartValue(part, "text")).filter((value) => typeof value === "string");
|
|
6257
|
+
}
|
|
6213
6258
|
function extractSignedWebhookRoute(payload) {
|
|
6214
6259
|
if (!isObjectRecord(payload)) return { ok: true };
|
|
6260
|
+
const normalizedA2A = normalizeA2AWebhookEnvelope(payload);
|
|
6215
6261
|
const records = [payload];
|
|
6216
|
-
if (
|
|
6262
|
+
if (normalizedA2A) {
|
|
6217
6263
|
records.length = 0;
|
|
6218
|
-
const status = isObjectRecord(
|
|
6264
|
+
const status = isObjectRecord(normalizedA2A.status) ? normalizedA2A.status : void 0;
|
|
6219
6265
|
const message = isObjectRecord(status?.message) ? status.message : void 0;
|
|
6220
6266
|
const messageData = latestA2AWebhookMessageData(message?.parts);
|
|
6221
6267
|
if (messageData) records.push(messageData);
|
|
6222
|
-
if (
|
|
6223
|
-
const artifactData = (0, import_a2a_artifacts.getLatestA2ADataPartFromTask)(
|
|
6268
|
+
if (normalizedA2A.kind === "task") {
|
|
6269
|
+
const artifactData = (0, import_a2a_artifacts.getLatestA2ADataPartFromTask)(normalizedA2A)?.data;
|
|
6224
6270
|
if (artifactData) records.push(artifactData);
|
|
6225
6271
|
}
|
|
6226
6272
|
}
|
|
@@ -6249,11 +6295,14 @@ function extractSignedWebhookRoute(payload) {
|
|
|
6249
6295
|
function legacyA2AArtifactStatus(payload, artifact) {
|
|
6250
6296
|
if (payload.kind !== "task" || !isObjectRecord(artifact) || typeof artifact.name !== "string") return void 0;
|
|
6251
6297
|
const transportState = payload.status?.state;
|
|
6252
|
-
if (artifact.name === "result" && transportState === "completed"
|
|
6298
|
+
if (artifact.name === "result" && (transportState === "completed" || transportState === "TASK_STATE_COMPLETED" || transportState === 3))
|
|
6299
|
+
return "completed";
|
|
6253
6300
|
if (artifact.name !== "error") return void 0;
|
|
6254
|
-
if (transportState === "failed" || transportState === "
|
|
6255
|
-
|
|
6256
|
-
|
|
6301
|
+
if (transportState === "failed" || transportState === "TASK_STATE_FAILED" || transportState === 4) return "failed";
|
|
6302
|
+
if (transportState === "rejected" || transportState === "TASK_STATE_REJECTED" || transportState === 7)
|
|
6303
|
+
return "rejected";
|
|
6304
|
+
if (transportState === "canceled" || transportState === "TASK_STATE_CANCELED" || transportState === 5)
|
|
6305
|
+
return "canceled";
|
|
6257
6306
|
return void 0;
|
|
6258
6307
|
}
|
|
6259
6308
|
function isMcpWebhookCandidate(payload) {
|