@adcp/sdk 16.2.0 → 16.3.0
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/AGENTS.md +2 -0
- package/dist/lib/core/AgentClient.js +17 -1
- package/dist/lib/core/AgentClient.mjs +17 -1
- package/dist/lib/core/SingleAgentClient.js +13 -0
- package/dist/lib/core/SingleAgentClient.mjs +13 -0
- package/dist/lib/core/TaskExecutor.js +88 -13
- package/dist/lib/core/TaskExecutor.mjs +89 -14
- package/dist/lib/errors/index.d.mts +34 -0
- package/dist/lib/errors/index.d.ts +34 -0
- package/dist/lib/errors/index.js +11 -0
- package/dist/lib/errors/index.mjs +10 -0
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.mjs +2 -0
- package/dist/lib/media-buy/compatibility.d.mts +1 -0
- package/dist/lib/media-buy/compatibility.d.ts +1 -0
- package/dist/lib/media-buy/compatibility.js +33 -10
- package/dist/lib/media-buy/compatibility.mjs +32 -14
- package/dist/lib/negotiation/buyer.js +11 -5
- package/dist/lib/negotiation/buyer.mjs +11 -5
- package/dist/lib/negotiation/types.d.mts +4 -2
- package/dist/lib/negotiation/types.d.ts +4 -2
- package/dist/lib/negotiation/verification.d.mts +15 -6
- package/dist/lib/negotiation/verification.d.ts +15 -6
- package/dist/lib/negotiation/verification.js +146 -27
- package/dist/lib/negotiation/verification.mjs +146 -28
- package/dist/lib/negotiation/version.d.mts +6 -0
- package/dist/lib/negotiation/version.d.ts +6 -0
- package/dist/lib/negotiation/version.js +60 -0
- package/dist/lib/negotiation/version.mjs +33 -0
- package/dist/lib/server/create-adcp-server.js +1 -1
- package/dist/lib/server/create-adcp-server.mjs +1 -1
- package/dist/lib/server/error-arm-tools.d.mts +10 -10
- package/dist/lib/server/error-arm-tools.d.ts +10 -10
- package/dist/lib/server/error-arm-tools.js +22 -58
- package/dist/lib/server/error-arm-tools.mjs +30 -65
- package/dist/lib/testing/compliance/comply.js +17 -0
- package/dist/lib/testing/compliance/comply.mjs +17 -0
- package/dist/lib/testing/index.d.mts +3 -0
- package/dist/lib/testing/index.d.ts +3 -0
- package/dist/lib/testing/index.js +44 -2
- package/dist/lib/testing/index.mjs +42 -0
- package/dist/lib/testing/storyboard/collection-selection.d.mts +259 -0
- package/dist/lib/testing/storyboard/collection-selection.d.ts +259 -0
- package/dist/lib/testing/storyboard/collection-selection.js +384 -0
- package/dist/lib/testing/storyboard/collection-selection.mjs +348 -0
- package/dist/lib/testing/storyboard/context.js +12 -6
- package/dist/lib/testing/storyboard/context.mjs +12 -6
- package/dist/lib/testing/storyboard/fixture-resolution.d.mts +39 -1
- package/dist/lib/testing/storyboard/fixture-resolution.d.ts +39 -1
- package/dist/lib/testing/storyboard/fixture-resolution.js +216 -12
- package/dist/lib/testing/storyboard/fixture-resolution.mjs +218 -12
- package/dist/lib/testing/storyboard/index.d.mts +9 -2
- package/dist/lib/testing/storyboard/index.d.ts +9 -2
- package/dist/lib/testing/storyboard/index.js +51 -2
- package/dist/lib/testing/storyboard/index.mjs +49 -1
- package/dist/lib/testing/storyboard/prepared-fixtures.d.mts +471 -0
- package/dist/lib/testing/storyboard/prepared-fixtures.d.ts +471 -0
- package/dist/lib/testing/storyboard/prepared-fixtures.js +434 -0
- package/dist/lib/testing/storyboard/prepared-fixtures.mjs +389 -0
- package/dist/lib/testing/storyboard/protected-context.d.mts +127 -0
- package/dist/lib/testing/storyboard/protected-context.d.ts +127 -0
- package/dist/lib/testing/storyboard/protected-context.js +301 -0
- package/dist/lib/testing/storyboard/protected-context.mjs +267 -0
- package/dist/lib/testing/storyboard/rejection-hints.js +13 -4
- package/dist/lib/testing/storyboard/rejection-hints.mjs +13 -4
- package/dist/lib/testing/storyboard/runner.d.mts +24 -0
- package/dist/lib/testing/storyboard/runner.d.ts +24 -0
- package/dist/lib/testing/storyboard/runner.js +1061 -105
- package/dist/lib/testing/storyboard/runner.mjs +1075 -106
- package/dist/lib/testing/storyboard/seeding.d.mts +15 -1
- package/dist/lib/testing/storyboard/seeding.d.ts +15 -1
- package/dist/lib/testing/storyboard/seeding.js +272 -12
- package/dist/lib/testing/storyboard/seeding.mjs +274 -13
- package/dist/lib/testing/storyboard/types.d.mts +207 -10
- package/dist/lib/testing/storyboard/types.d.ts +207 -10
- package/dist/lib/testing/storyboard/types.js +1 -1
- package/dist/lib/testing/storyboard/types.mjs +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.js +95 -0
- package/dist/lib/testing/storyboard/validations.mjs +95 -0
- package/dist/lib/validation/bundled-schema-store.js +5 -0
- package/dist/lib/validation/bundled-schema-store.mjs +4 -0
- package/dist/lib/validation/schema-loader.js +19 -2
- package/dist/lib/validation/schema-loader.mjs +22 -3
- 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.mjs +3 -3
- package/docs/TYPE-SUMMARY.md +1 -1
- package/docs/guides/COLLECTION-FIXTURE-FOUNDATION.md +850 -0
- package/docs/guides/PROPOSAL-TERMS-VERIFICATION.md +66 -0
- package/docs/llms.txt +3 -2
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -21,6 +21,8 @@ This document contains essential guidelines for AI coding assistants (Claude, Co
|
|
|
21
21
|
|
|
22
22
|
**Migration guides** — [AdCP 2 retirement](docs/migration-drop-adcp-2.md) (AdCP 3-only discovery, removed compatibility APIs, and last supporting SDK pins); [Account change feed](docs/migration-account-change-feed.md) (wake-up parsing, guarded bootstrap/drain, subscriber registration and ownership boundaries); `docs/migration-6.6-to-6.7.md` (fifteen adopter recipes; two breaking changes — `'implicit'` enforces inline-`account_id` refusal and `SalesPlatform` split into `SalesCorePlatform & SalesIngestionPlatform`; plus `definePlatform` helpers, `composeMethod`, `accounts.resolve` security presets, `accounts.upsert/list/syncGovernance(ctx)`, typed errors, `issues[].hint`, `BuyerAgentRegistry`, `createTenantRegistry`, `createOAuthPassthroughResolver`, `createRosterAccountStore`, `createTenantStore` w/ built-in tenant gate, `MEDIA_BUY_TRANSITIONS` lifecycle helpers, `createMediaBuyStore` for `targeting_overlay` echo, `NoAccountCtx` narrow, `refAccountId(ref)`); `docs/migration-5.x-to-6.x.md` (5 → 6 framework shape); `docs/migration-4.x-to-5.x.md` (4 → 5); `docs/migration-buyer-agent-registry.md` (registry deep-dive).
|
|
23
23
|
|
|
24
|
+
**Pinning a real collection-bearing product in a storyboard?** — Read [`docs/guides/COLLECTION-FIXTURE-FOUNDATION.md`](docs/guides/COLLECTION-FIXTURE-FOUNDATION.md): `collection_selection_satisfies`, same-graph fixture captures, the protected `__adcp_fixture_` namespace, `prepareStoryboardFixtures()`, and `collection_set_equals_context` — plus the limits the foundation does not claim to solve.
|
|
25
|
+
|
|
24
26
|
**Putting credentials in `ctx_metadata`?** — Don't. Read `docs/guides/CTX-METADATA-SAFETY.md` — wire-strip protects buyer responses but not log lines / error envelopes / heap dumps / adopter strings. Re-derive bearers per request; embed only non-secret upstream IDs.
|
|
25
27
|
|
|
26
28
|
**Reviewing a safety-critical PR (auth, signing, replay, idempotency, governance, tenancy)?** — Read `docs/development/REVIEW-STACKS.md`. Run Claude expert agents (DX, protocol, code-review, security) in parallel **plus** `npm run review:codex -- --all --base main` for a second-model opinion. Convergence = ship confidence; divergence = the actual review.
|
|
@@ -37,6 +37,8 @@ var import_SingleAgentClient = require('./SingleAgentClient.js');
|
|
|
37
37
|
var import_request_proposals_guard = require('./request-proposals-guard.js');
|
|
38
38
|
var import_buyer = require('../negotiation/buyer.js');
|
|
39
39
|
var import_verification = require('../negotiation/verification.js');
|
|
40
|
+
var import_version = require('../negotiation/version.js');
|
|
41
|
+
var import_version2 = require('../version.js');
|
|
40
42
|
function stripRefineProposalsSdkAnnotations(data) {
|
|
41
43
|
const canonical = { ...data };
|
|
42
44
|
delete canonical.success;
|
|
@@ -179,6 +181,10 @@ class AgentClient {
|
|
|
179
181
|
getAdcpVersion() {
|
|
180
182
|
return this.client.getAdcpVersion();
|
|
181
183
|
}
|
|
184
|
+
/** @internal Original envelope pin, separate from the validation schema pin. */
|
|
185
|
+
getWireAdcpVersion() {
|
|
186
|
+
return this.client.getWireAdcpVersion();
|
|
187
|
+
}
|
|
182
188
|
/**
|
|
183
189
|
* Negotiate one compact-first media-buy facade for this seller.
|
|
184
190
|
*
|
|
@@ -512,7 +518,17 @@ class AgentClient {
|
|
|
512
518
|
this.retainSession(result);
|
|
513
519
|
if (result.success && result.status === "completed") {
|
|
514
520
|
const data = stripRefineProposalsSdkAnnotations(result.data);
|
|
515
|
-
|
|
521
|
+
const cachedServedVersion = this.client.getCachedServedAdcpVersion(taskOptions);
|
|
522
|
+
(0, import_verification.assertRefineProposalsResponse)(request, data, {
|
|
523
|
+
adcpVersion: this.client.getAdcpVersion(),
|
|
524
|
+
// Task metadata repeats the response echo. Independently discovered
|
|
525
|
+
// actual served evidence must constrain that seller-controlled value.
|
|
526
|
+
servedAdcpVersion: (0, import_version.applicableRefinementServedVersion)(
|
|
527
|
+
cachedServedVersion,
|
|
528
|
+
request.adcp_version,
|
|
529
|
+
(0, import_version2.toReleasePrecisionVersion)(this.client.getWireAdcpVersion())
|
|
530
|
+
) ?? result.metadata.adcpVersion
|
|
531
|
+
});
|
|
516
532
|
return { ...result, data };
|
|
517
533
|
}
|
|
518
534
|
return result;
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
import { assertNativeRequestProposalsTask, guardNativeRequestProposalsCompletion } from "./request-proposals-guard.mjs";
|
|
6
6
|
import { buildRefineProposalsRequest } from "../negotiation/buyer.mjs";
|
|
7
7
|
import { assertRefineProposalsResponse } from "../negotiation/verification.mjs";
|
|
8
|
+
import { applicableRefinementServedVersion } from "../negotiation/version.mjs";
|
|
9
|
+
import { toReleasePrecisionVersion } from "../version.mjs";
|
|
8
10
|
function stripRefineProposalsSdkAnnotations(data) {
|
|
9
11
|
const canonical = { ...data };
|
|
10
12
|
delete canonical.success;
|
|
@@ -147,6 +149,10 @@ class AgentClient {
|
|
|
147
149
|
getAdcpVersion() {
|
|
148
150
|
return this.client.getAdcpVersion();
|
|
149
151
|
}
|
|
152
|
+
/** @internal Original envelope pin, separate from the validation schema pin. */
|
|
153
|
+
getWireAdcpVersion() {
|
|
154
|
+
return this.client.getWireAdcpVersion();
|
|
155
|
+
}
|
|
150
156
|
/**
|
|
151
157
|
* Negotiate one compact-first media-buy facade for this seller.
|
|
152
158
|
*
|
|
@@ -480,7 +486,17 @@ class AgentClient {
|
|
|
480
486
|
this.retainSession(result);
|
|
481
487
|
if (result.success && result.status === "completed") {
|
|
482
488
|
const data = stripRefineProposalsSdkAnnotations(result.data);
|
|
483
|
-
|
|
489
|
+
const cachedServedVersion = this.client.getCachedServedAdcpVersion(taskOptions);
|
|
490
|
+
assertRefineProposalsResponse(request, data, {
|
|
491
|
+
adcpVersion: this.client.getAdcpVersion(),
|
|
492
|
+
// Task metadata repeats the response echo. Independently discovered
|
|
493
|
+
// actual served evidence must constrain that seller-controlled value.
|
|
494
|
+
servedAdcpVersion: applicableRefinementServedVersion(
|
|
495
|
+
cachedServedVersion,
|
|
496
|
+
request.adcp_version,
|
|
497
|
+
toReleasePrecisionVersion(this.client.getWireAdcpVersion())
|
|
498
|
+
) ?? result.metadata.adcpVersion
|
|
499
|
+
});
|
|
484
500
|
return { ...result, data };
|
|
485
501
|
}
|
|
486
502
|
return result;
|
|
@@ -1905,6 +1905,19 @@ class SingleAgentClient {
|
|
|
1905
1905
|
getWireAdcpVersion() {
|
|
1906
1906
|
return this.config.wireAdcpVersion ?? this.resolvedAdcpVersion;
|
|
1907
1907
|
}
|
|
1908
|
+
/** @internal Read only current, auth-scoped actual discovery evidence; never fetch. */
|
|
1909
|
+
getCachedServedAdcpVersion(options) {
|
|
1910
|
+
this.synchronizeCapabilityEvidenceAuthorizationScope();
|
|
1911
|
+
if (this.usesScopedDiscoveryTransport(options)) return void 0;
|
|
1912
|
+
if (this.primedCapabilitiesExpiresAt !== void 0 && this.primedCapabilitiesExpiresAt <= Date.now())
|
|
1913
|
+
return void 0;
|
|
1914
|
+
if (this.config.discoveryCache && this.cachedCapabilities) {
|
|
1915
|
+
const key = this.sharedDiscoveryKey(options);
|
|
1916
|
+
if (this.sharedEvidenceKey !== key || key !== void 0 && this.sharedEvidenceEpoch !== void 0 && this.sharedEvidenceEpoch !== this.sharedInvalidationEpoch(key))
|
|
1917
|
+
return void 0;
|
|
1918
|
+
}
|
|
1919
|
+
return this.cachedCapabilities?._synthetic === false ? this.cachedCapabilities.servedVersion : void 0;
|
|
1920
|
+
}
|
|
1908
1921
|
/**
|
|
1909
1922
|
* Ensure MCP endpoint is discovered (lazy initialization)
|
|
1910
1923
|
*
|
|
@@ -2002,6 +2002,19 @@ class SingleAgentClient {
|
|
|
2002
2002
|
getWireAdcpVersion() {
|
|
2003
2003
|
return this.config.wireAdcpVersion ?? this.resolvedAdcpVersion;
|
|
2004
2004
|
}
|
|
2005
|
+
/** @internal Read only current, auth-scoped actual discovery evidence; never fetch. */
|
|
2006
|
+
getCachedServedAdcpVersion(options) {
|
|
2007
|
+
this.synchronizeCapabilityEvidenceAuthorizationScope();
|
|
2008
|
+
if (this.usesScopedDiscoveryTransport(options)) return void 0;
|
|
2009
|
+
if (this.primedCapabilitiesExpiresAt !== void 0 && this.primedCapabilitiesExpiresAt <= Date.now())
|
|
2010
|
+
return void 0;
|
|
2011
|
+
if (this.config.discoveryCache && this.cachedCapabilities) {
|
|
2012
|
+
const key = this.sharedDiscoveryKey(options);
|
|
2013
|
+
if (this.sharedEvidenceKey !== key || key !== void 0 && this.sharedEvidenceEpoch !== void 0 && this.sharedEvidenceEpoch !== this.sharedInvalidationEpoch(key))
|
|
2014
|
+
return void 0;
|
|
2015
|
+
}
|
|
2016
|
+
return this.cachedCapabilities?._synthetic === false ? this.cachedCapabilities.servedVersion : void 0;
|
|
2017
|
+
}
|
|
2005
2018
|
/**
|
|
2006
2019
|
* Ensure MCP endpoint is discovered (lazy initialization)
|
|
2007
2020
|
*
|
|
@@ -53,6 +53,8 @@ var import_client_hooks = require('../validation/client-hooks.js');
|
|
|
53
53
|
var import_schema_validator = require('../validation/schema-validator.js');
|
|
54
54
|
var import_schema_loader = require('../validation/schema-loader.js');
|
|
55
55
|
var import_version = require('../version.js');
|
|
56
|
+
var import_version2 = require('../negotiation/version.js');
|
|
57
|
+
var import_verification = require('../negotiation/verification.js');
|
|
56
58
|
var import_response_unwrapper = require('../utils/response-unwrapper.js');
|
|
57
59
|
var import_error_extraction = require('../utils/error-extraction.js');
|
|
58
60
|
var import_idempotency = require('../utils/idempotency.js');
|
|
@@ -823,6 +825,13 @@ class TaskExecutor {
|
|
|
823
825
|
agent: { id: agent.id, name: agent.name, protocol: agent.protocol },
|
|
824
826
|
serverVersion: effectiveServerVersion,
|
|
825
827
|
serverVersionSynthetic: targetCapabilities?._synthetic ?? serverVersion === void 0,
|
|
828
|
+
...taskName === "refine_proposals" && targetCapabilities?._synthetic === false && {
|
|
829
|
+
refinementServedVersion: (0, import_version2.applicableRefinementServedVersion)(
|
|
830
|
+
targetCapabilities.servedVersion,
|
|
831
|
+
params?.adcp_version ?? (0, import_version.toReleasePrecisionVersion)(wireAdcpVersion ?? this.config.adcpVersion ?? import_version.ADCP_VERSION),
|
|
832
|
+
(0, import_version.toReleasePrecisionVersion)(this.config.wireAdcpVersion ?? this.config.adcpVersion ?? import_version.ADCP_VERSION)
|
|
833
|
+
)
|
|
834
|
+
},
|
|
826
835
|
idempotencyKey
|
|
827
836
|
};
|
|
828
837
|
this.activeTasks.set(taskId, taskState);
|
|
@@ -1113,7 +1122,8 @@ class TaskExecutor {
|
|
|
1113
1122
|
dispatchSettlement?.persistPausedContinuation ?? true,
|
|
1114
1123
|
effectiveServerVersion,
|
|
1115
1124
|
deferredClientContext,
|
|
1116
|
-
dispatchSettlement?.requireDeferredSettlementResumeAuthorization === true
|
|
1125
|
+
dispatchSettlement?.requireDeferredSettlementResumeAuthorization === true,
|
|
1126
|
+
taskState.refinementServedVersion
|
|
1117
1127
|
);
|
|
1118
1128
|
(0, import_abort.throwIfAborted)(postDispatchOptions.signal);
|
|
1119
1129
|
if (governanceResult) {
|
|
@@ -1256,7 +1266,7 @@ class TaskExecutor {
|
|
|
1256
1266
|
debug_logs: debugLogs
|
|
1257
1267
|
};
|
|
1258
1268
|
}
|
|
1259
|
-
async handleAsyncResponse(agent, taskId, taskName, params, response, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false) {
|
|
1269
|
+
async handleAsyncResponse(agent, taskId, taskName, params, response, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false, refinementServedVersion) {
|
|
1260
1270
|
const status = this.responseParser.getStatus(response);
|
|
1261
1271
|
const serverTaskId = this.responseParser.getTaskId(response);
|
|
1262
1272
|
const task = this.activeTasks.get(taskId);
|
|
@@ -1266,7 +1276,14 @@ class TaskExecutor {
|
|
|
1266
1276
|
const completedData = this.extractResponseData(response, debugLogs, taskName, serverVersion);
|
|
1267
1277
|
if (!deferTerminalTaskStatus) this.updateTaskStatus(taskId, "completed", completedData);
|
|
1268
1278
|
const operationSuccess = this.isOperationSuccess(completedData, taskName, serverVersion);
|
|
1269
|
-
const validationResult = this.validateResponseSchema(
|
|
1279
|
+
const validationResult = this.validateResponseSchema(
|
|
1280
|
+
completedData,
|
|
1281
|
+
taskName,
|
|
1282
|
+
debugLogs,
|
|
1283
|
+
serverVersion,
|
|
1284
|
+
params,
|
|
1285
|
+
refinementServedVersion
|
|
1286
|
+
);
|
|
1270
1287
|
const finalSuccess = operationSuccess && validationResult.valid;
|
|
1271
1288
|
const finalError = !finalSuccess ? validationResult.errors.length > 0 ? `Schema validation failed: ${validationResult.errors.join("; ")}` : this.extractOperationError(completedData) : void 0;
|
|
1272
1289
|
if (finalSuccess) {
|
|
@@ -1351,7 +1368,8 @@ class TaskExecutor {
|
|
|
1351
1368
|
persistPausedContinuation,
|
|
1352
1369
|
serverVersion,
|
|
1353
1370
|
deferredClientContext,
|
|
1354
|
-
requireDeferredSettlementResumeAuthorization
|
|
1371
|
+
requireDeferredSettlementResumeAuthorization,
|
|
1372
|
+
refinementServedVersion
|
|
1355
1373
|
);
|
|
1356
1374
|
case import_ProtocolResponseParser.ADCP_STATUS.FAILED:
|
|
1357
1375
|
case import_ProtocolResponseParser.ADCP_STATUS.REJECTED:
|
|
@@ -1387,7 +1405,14 @@ class TaskExecutor {
|
|
|
1387
1405
|
const defaultData = this.extractResponseData(response, debugLogs, taskName, serverVersion);
|
|
1388
1406
|
if (defaultData && (defaultData !== response || response.structuredContent || response.result || response.data)) {
|
|
1389
1407
|
const defaultSuccess = this.isOperationSuccess(defaultData, taskName, serverVersion);
|
|
1390
|
-
const defaultValidation = this.validateResponseSchema(
|
|
1408
|
+
const defaultValidation = this.validateResponseSchema(
|
|
1409
|
+
defaultData,
|
|
1410
|
+
taskName,
|
|
1411
|
+
debugLogs,
|
|
1412
|
+
serverVersion,
|
|
1413
|
+
params,
|
|
1414
|
+
refinementServedVersion
|
|
1415
|
+
);
|
|
1391
1416
|
const defaultFinalSuccess = defaultSuccess && defaultValidation.valid;
|
|
1392
1417
|
const defaultFinalError = !defaultFinalSuccess ? defaultValidation.errors.length > 0 ? `Schema validation failed: ${defaultValidation.errors.join("; ")}` : this.extractOperationError(defaultData) : void 0;
|
|
1393
1418
|
if (defaultFinalSuccess) {
|
|
@@ -2001,7 +2026,7 @@ class TaskExecutor {
|
|
|
2001
2026
|
* This is common for HITL (human-in-the-loop) workflows where the agent has already processed
|
|
2002
2027
|
* the request and is just signaling that async approval may be needed.
|
|
2003
2028
|
*/
|
|
2004
|
-
async handleInputRequired(agent, taskId, taskName, params, response, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, pauseStatus = "input-required", persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false) {
|
|
2029
|
+
async handleInputRequired(agent, taskId, taskName, params, response, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, pauseStatus = "input-required", persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false, refinementServedVersion) {
|
|
2005
2030
|
const inputRequest = this.responseParser.parseInputRequest(response);
|
|
2006
2031
|
const serverContextId = this.responseParser.getContextId(response) ?? response.contextId;
|
|
2007
2032
|
const a2aTaskId = this.responseParser.getA2AContinuationTaskId(response);
|
|
@@ -2059,6 +2084,7 @@ class TaskExecutor {
|
|
|
2059
2084
|
...options.wireAdcpVersion !== void 0 && { wireAdcpVersion: options.wireAdcpVersion },
|
|
2060
2085
|
...options.versionEnvelope !== void 0 && { versionEnvelope: options.versionEnvelope },
|
|
2061
2086
|
serverVersionSynthetic: this.activeTasks.get(taskId)?.serverVersionSynthetic,
|
|
2087
|
+
...refinementServedVersion !== void 0 && { refinementServedVersion },
|
|
2062
2088
|
agentId: agent.id,
|
|
2063
2089
|
taskName,
|
|
2064
2090
|
params: durableDeferredSnapshot(params),
|
|
@@ -2123,7 +2149,8 @@ class TaskExecutor {
|
|
|
2123
2149
|
persistPausedContinuation,
|
|
2124
2150
|
serverVersion,
|
|
2125
2151
|
deferredClientContext,
|
|
2126
|
-
requireDeferredSettlementResumeAuthorization
|
|
2152
|
+
requireDeferredSettlementResumeAuthorization,
|
|
2153
|
+
refinementServedVersion
|
|
2127
2154
|
);
|
|
2128
2155
|
};
|
|
2129
2156
|
const deferred = {
|
|
@@ -2201,6 +2228,7 @@ class TaskExecutor {
|
|
|
2201
2228
|
...options.wireAdcpVersion !== void 0 && { wireAdcpVersion: options.wireAdcpVersion },
|
|
2202
2229
|
...options.versionEnvelope !== void 0 && { versionEnvelope: options.versionEnvelope },
|
|
2203
2230
|
serverVersionSynthetic: this.activeTasks.get(taskId)?.serverVersionSynthetic,
|
|
2231
|
+
...refinementServedVersion !== void 0 && { refinementServedVersion },
|
|
2204
2232
|
agentId: agent.id,
|
|
2205
2233
|
taskName,
|
|
2206
2234
|
params: durableDeferredSnapshot(params),
|
|
@@ -2266,7 +2294,8 @@ class TaskExecutor {
|
|
|
2266
2294
|
persistPausedContinuation,
|
|
2267
2295
|
serverVersion,
|
|
2268
2296
|
deferredClientContext,
|
|
2269
|
-
requireDeferredSettlementResumeAuthorization
|
|
2297
|
+
requireDeferredSettlementResumeAuthorization,
|
|
2298
|
+
refinementServedVersion
|
|
2270
2299
|
);
|
|
2271
2300
|
};
|
|
2272
2301
|
const deferred = {
|
|
@@ -2317,7 +2346,8 @@ class TaskExecutor {
|
|
|
2317
2346
|
persistPausedContinuation,
|
|
2318
2347
|
serverVersion,
|
|
2319
2348
|
deferredClientContext,
|
|
2320
|
-
requireDeferredSettlementResumeAuthorization
|
|
2349
|
+
requireDeferredSettlementResumeAuthorization,
|
|
2350
|
+
refinementServedVersion
|
|
2321
2351
|
);
|
|
2322
2352
|
}
|
|
2323
2353
|
/**
|
|
@@ -3317,7 +3347,8 @@ class TaskExecutor {
|
|
|
3317
3347
|
false,
|
|
3318
3348
|
state.serverVersion,
|
|
3319
3349
|
state.clientContext,
|
|
3320
|
-
state.settlementResumeAuthorizationRequired === true
|
|
3350
|
+
state.settlementResumeAuthorizationRequired === true,
|
|
3351
|
+
state.refinementServedVersion
|
|
3321
3352
|
);
|
|
3322
3353
|
resumed = attachDeferredServerVersion(resumed, state);
|
|
3323
3354
|
const observedResumedServerTaskId = resumed.metadata.serverTaskId;
|
|
@@ -3343,6 +3374,9 @@ class TaskExecutor {
|
|
|
3343
3374
|
...resumed.metadata.contextId !== void 0 ? { contextId: resumed.metadata.contextId } : state.contextId !== void 0 ? { contextId: state.contextId } : {},
|
|
3344
3375
|
a2aTaskId: nextA2ATaskId,
|
|
3345
3376
|
serverVersion: state.serverVersion,
|
|
3377
|
+
...state.refinementServedVersion !== void 0 && {
|
|
3378
|
+
refinementServedVersion: state.refinementServedVersion
|
|
3379
|
+
},
|
|
3346
3380
|
...state.wireAdcpVersion !== void 0 && { wireAdcpVersion: state.wireAdcpVersion },
|
|
3347
3381
|
...state.versionEnvelope !== void 0 && { versionEnvelope: state.versionEnvelope },
|
|
3348
3382
|
...state.serverVersionSynthetic !== void 0 && {
|
|
@@ -4271,7 +4305,7 @@ class TaskExecutor {
|
|
|
4271
4305
|
/**
|
|
4272
4306
|
* Continue a task after receiving input
|
|
4273
4307
|
*/
|
|
4274
|
-
async continueTaskWithInput(agent, taskId, taskName, params, contextId, a2aTaskId, input, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false) {
|
|
4308
|
+
async continueTaskWithInput(agent, taskId, taskName, params, contextId, a2aTaskId, input, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false, refinementServedVersion) {
|
|
4275
4309
|
const inputSnapshot = structuredClone(input);
|
|
4276
4310
|
if (agent.protocol !== "a2a") {
|
|
4277
4311
|
throw new Error("MCP does not define a standard continuation for a returned input-required task.");
|
|
@@ -4337,7 +4371,8 @@ class TaskExecutor {
|
|
|
4337
4371
|
persistPausedContinuation,
|
|
4338
4372
|
serverVersion,
|
|
4339
4373
|
deferredClientContext,
|
|
4340
|
-
requireDeferredSettlementResumeAuthorization
|
|
4374
|
+
requireDeferredSettlementResumeAuthorization,
|
|
4375
|
+
refinementServedVersion
|
|
4341
4376
|
);
|
|
4342
4377
|
}
|
|
4343
4378
|
/**
|
|
@@ -4529,7 +4564,7 @@ class TaskExecutor {
|
|
|
4529
4564
|
* valid so the caller can continue. Off mode short-circuits before
|
|
4530
4565
|
* AJV runs.
|
|
4531
4566
|
*/
|
|
4532
|
-
validateResponseSchema(response, taskName, debugLogs, serverVersion) {
|
|
4567
|
+
validateResponseSchema(response, taskName, debugLogs, serverVersion, requestParams, refinementServedVersion) {
|
|
4533
4568
|
const mode = this.responseValidationMode;
|
|
4534
4569
|
const logViolations = this.config.logSchemaViolations !== false;
|
|
4535
4570
|
try {
|
|
@@ -4541,6 +4576,46 @@ class TaskExecutor {
|
|
|
4541
4576
|
(validationVersion) => this.validateResponseSchemaAgainst(response, taskName, debugLogs, mode, logViolations, validationVersion)
|
|
4542
4577
|
);
|
|
4543
4578
|
}
|
|
4579
|
+
if (taskName === "refine_proposals" && mode !== "off") {
|
|
4580
|
+
const ceiling = requestParams?.adcp_version ?? (0, import_version.toReleasePrecisionVersion)(this.config.wireAdcpVersion ?? pinnedValidationVersion);
|
|
4581
|
+
const issues = [];
|
|
4582
|
+
const selected = (0, import_verification.selectRefinementSchemaVersion)(
|
|
4583
|
+
ceiling,
|
|
4584
|
+
response,
|
|
4585
|
+
{
|
|
4586
|
+
adcpVersion: pinnedValidationVersion,
|
|
4587
|
+
servedAdcpVersion: (0, import_version2.applicableRefinementServedVersion)(refinementServedVersion, ceiling)
|
|
4588
|
+
},
|
|
4589
|
+
issues
|
|
4590
|
+
);
|
|
4591
|
+
if (!selected) {
|
|
4592
|
+
const errors = issues.map((issue) => `${issue.path}: ${issue.message}`);
|
|
4593
|
+
if (logViolations) {
|
|
4594
|
+
debugLogs.push({
|
|
4595
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4596
|
+
type: mode === "strict" ? "error" : "warning",
|
|
4597
|
+
message: `Schema validation ${mode === "strict" ? "failed" : "warning"} for ${taskName}: ${errors.join("; ")}`,
|
|
4598
|
+
errors,
|
|
4599
|
+
issues,
|
|
4600
|
+
schemaVersion: pinnedValidationVersion,
|
|
4601
|
+
mode
|
|
4602
|
+
});
|
|
4603
|
+
if (mode === "warn") {
|
|
4604
|
+
console.warn(
|
|
4605
|
+
`Schema validation failed for ${taskName} against AdCP ${pinnedValidationVersion} (non-blocking):`,
|
|
4606
|
+
errors
|
|
4607
|
+
);
|
|
4608
|
+
} else {
|
|
4609
|
+
console.error(
|
|
4610
|
+
`Schema validation failed for ${taskName} against AdCP ${pinnedValidationVersion}:`,
|
|
4611
|
+
errors
|
|
4612
|
+
);
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
return { valid: mode !== "strict", errors: mode === "strict" ? errors : [] };
|
|
4616
|
+
}
|
|
4617
|
+
return this.validateResponseSchemaAgainst(response, taskName, debugLogs, mode, logViolations, selected);
|
|
4618
|
+
}
|
|
4544
4619
|
return this.validateResponseSchemaAgainst(
|
|
4545
4620
|
response,
|
|
4546
4621
|
taskName,
|
|
@@ -28,7 +28,9 @@ import {
|
|
|
28
28
|
} from "../validation/client-hooks.mjs";
|
|
29
29
|
import { formatIssues } from "../validation/schema-validator.mjs";
|
|
30
30
|
import { withServedValidationVersion } from "../validation/schema-loader.mjs";
|
|
31
|
-
import { ADCP_VERSION } from "../version.mjs";
|
|
31
|
+
import { ADCP_VERSION, toReleasePrecisionVersion } from "../version.mjs";
|
|
32
|
+
import { applicableRefinementServedVersion } from "../negotiation/version.mjs";
|
|
33
|
+
import { selectRefinementSchemaVersion } from "../negotiation/verification.mjs";
|
|
32
34
|
import { unwrapProtocolResponse, isAdcpOperationSuccess } from "../utils/response-unwrapper.mjs";
|
|
33
35
|
import { extractAdcpErrorInfo, extractCorrelationId } from "../utils/error-extraction.mjs";
|
|
34
36
|
import { generateIdempotencyKey, requestUsesIdempotency, redactIdempotencyKeyInArgs } from "../utils/idempotency.mjs";
|
|
@@ -801,6 +803,13 @@ class TaskExecutor {
|
|
|
801
803
|
agent: { id: agent.id, name: agent.name, protocol: agent.protocol },
|
|
802
804
|
serverVersion: effectiveServerVersion,
|
|
803
805
|
serverVersionSynthetic: targetCapabilities?._synthetic ?? serverVersion === void 0,
|
|
806
|
+
...taskName === "refine_proposals" && targetCapabilities?._synthetic === false && {
|
|
807
|
+
refinementServedVersion: applicableRefinementServedVersion(
|
|
808
|
+
targetCapabilities.servedVersion,
|
|
809
|
+
params?.adcp_version ?? toReleasePrecisionVersion(wireAdcpVersion ?? this.config.adcpVersion ?? ADCP_VERSION),
|
|
810
|
+
toReleasePrecisionVersion(this.config.wireAdcpVersion ?? this.config.adcpVersion ?? ADCP_VERSION)
|
|
811
|
+
)
|
|
812
|
+
},
|
|
804
813
|
idempotencyKey
|
|
805
814
|
};
|
|
806
815
|
this.activeTasks.set(taskId, taskState);
|
|
@@ -1091,7 +1100,8 @@ class TaskExecutor {
|
|
|
1091
1100
|
dispatchSettlement?.persistPausedContinuation ?? true,
|
|
1092
1101
|
effectiveServerVersion,
|
|
1093
1102
|
deferredClientContext,
|
|
1094
|
-
dispatchSettlement?.requireDeferredSettlementResumeAuthorization === true
|
|
1103
|
+
dispatchSettlement?.requireDeferredSettlementResumeAuthorization === true,
|
|
1104
|
+
taskState.refinementServedVersion
|
|
1095
1105
|
);
|
|
1096
1106
|
throwIfAborted(postDispatchOptions.signal);
|
|
1097
1107
|
if (governanceResult) {
|
|
@@ -1234,7 +1244,7 @@ class TaskExecutor {
|
|
|
1234
1244
|
debug_logs: debugLogs
|
|
1235
1245
|
};
|
|
1236
1246
|
}
|
|
1237
|
-
async handleAsyncResponse(agent, taskId, taskName, params, response, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false) {
|
|
1247
|
+
async handleAsyncResponse(agent, taskId, taskName, params, response, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false, refinementServedVersion) {
|
|
1238
1248
|
const status = this.responseParser.getStatus(response);
|
|
1239
1249
|
const serverTaskId = this.responseParser.getTaskId(response);
|
|
1240
1250
|
const task = this.activeTasks.get(taskId);
|
|
@@ -1244,7 +1254,14 @@ class TaskExecutor {
|
|
|
1244
1254
|
const completedData = this.extractResponseData(response, debugLogs, taskName, serverVersion);
|
|
1245
1255
|
if (!deferTerminalTaskStatus) this.updateTaskStatus(taskId, "completed", completedData);
|
|
1246
1256
|
const operationSuccess = this.isOperationSuccess(completedData, taskName, serverVersion);
|
|
1247
|
-
const validationResult = this.validateResponseSchema(
|
|
1257
|
+
const validationResult = this.validateResponseSchema(
|
|
1258
|
+
completedData,
|
|
1259
|
+
taskName,
|
|
1260
|
+
debugLogs,
|
|
1261
|
+
serverVersion,
|
|
1262
|
+
params,
|
|
1263
|
+
refinementServedVersion
|
|
1264
|
+
);
|
|
1248
1265
|
const finalSuccess = operationSuccess && validationResult.valid;
|
|
1249
1266
|
const finalError = !finalSuccess ? validationResult.errors.length > 0 ? `Schema validation failed: ${validationResult.errors.join("; ")}` : this.extractOperationError(completedData) : void 0;
|
|
1250
1267
|
if (finalSuccess) {
|
|
@@ -1329,7 +1346,8 @@ class TaskExecutor {
|
|
|
1329
1346
|
persistPausedContinuation,
|
|
1330
1347
|
serverVersion,
|
|
1331
1348
|
deferredClientContext,
|
|
1332
|
-
requireDeferredSettlementResumeAuthorization
|
|
1349
|
+
requireDeferredSettlementResumeAuthorization,
|
|
1350
|
+
refinementServedVersion
|
|
1333
1351
|
);
|
|
1334
1352
|
case ADCP_STATUS.FAILED:
|
|
1335
1353
|
case ADCP_STATUS.REJECTED:
|
|
@@ -1365,7 +1383,14 @@ class TaskExecutor {
|
|
|
1365
1383
|
const defaultData = this.extractResponseData(response, debugLogs, taskName, serverVersion);
|
|
1366
1384
|
if (defaultData && (defaultData !== response || response.structuredContent || response.result || response.data)) {
|
|
1367
1385
|
const defaultSuccess = this.isOperationSuccess(defaultData, taskName, serverVersion);
|
|
1368
|
-
const defaultValidation = this.validateResponseSchema(
|
|
1386
|
+
const defaultValidation = this.validateResponseSchema(
|
|
1387
|
+
defaultData,
|
|
1388
|
+
taskName,
|
|
1389
|
+
debugLogs,
|
|
1390
|
+
serverVersion,
|
|
1391
|
+
params,
|
|
1392
|
+
refinementServedVersion
|
|
1393
|
+
);
|
|
1369
1394
|
const defaultFinalSuccess = defaultSuccess && defaultValidation.valid;
|
|
1370
1395
|
const defaultFinalError = !defaultFinalSuccess ? defaultValidation.errors.length > 0 ? `Schema validation failed: ${defaultValidation.errors.join("; ")}` : this.extractOperationError(defaultData) : void 0;
|
|
1371
1396
|
if (defaultFinalSuccess) {
|
|
@@ -1979,7 +2004,7 @@ class TaskExecutor {
|
|
|
1979
2004
|
* This is common for HITL (human-in-the-loop) workflows where the agent has already processed
|
|
1980
2005
|
* the request and is just signaling that async approval may be needed.
|
|
1981
2006
|
*/
|
|
1982
|
-
async handleInputRequired(agent, taskId, taskName, params, response, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, pauseStatus = "input-required", persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false) {
|
|
2007
|
+
async handleInputRequired(agent, taskId, taskName, params, response, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, pauseStatus = "input-required", persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false, refinementServedVersion) {
|
|
1983
2008
|
const inputRequest = this.responseParser.parseInputRequest(response);
|
|
1984
2009
|
const serverContextId = this.responseParser.getContextId(response) ?? response.contextId;
|
|
1985
2010
|
const a2aTaskId = this.responseParser.getA2AContinuationTaskId(response);
|
|
@@ -2037,6 +2062,7 @@ class TaskExecutor {
|
|
|
2037
2062
|
...options.wireAdcpVersion !== void 0 && { wireAdcpVersion: options.wireAdcpVersion },
|
|
2038
2063
|
...options.versionEnvelope !== void 0 && { versionEnvelope: options.versionEnvelope },
|
|
2039
2064
|
serverVersionSynthetic: this.activeTasks.get(taskId)?.serverVersionSynthetic,
|
|
2065
|
+
...refinementServedVersion !== void 0 && { refinementServedVersion },
|
|
2040
2066
|
agentId: agent.id,
|
|
2041
2067
|
taskName,
|
|
2042
2068
|
params: durableDeferredSnapshot(params),
|
|
@@ -2101,7 +2127,8 @@ class TaskExecutor {
|
|
|
2101
2127
|
persistPausedContinuation,
|
|
2102
2128
|
serverVersion,
|
|
2103
2129
|
deferredClientContext,
|
|
2104
|
-
requireDeferredSettlementResumeAuthorization
|
|
2130
|
+
requireDeferredSettlementResumeAuthorization,
|
|
2131
|
+
refinementServedVersion
|
|
2105
2132
|
);
|
|
2106
2133
|
};
|
|
2107
2134
|
const deferred = {
|
|
@@ -2179,6 +2206,7 @@ class TaskExecutor {
|
|
|
2179
2206
|
...options.wireAdcpVersion !== void 0 && { wireAdcpVersion: options.wireAdcpVersion },
|
|
2180
2207
|
...options.versionEnvelope !== void 0 && { versionEnvelope: options.versionEnvelope },
|
|
2181
2208
|
serverVersionSynthetic: this.activeTasks.get(taskId)?.serverVersionSynthetic,
|
|
2209
|
+
...refinementServedVersion !== void 0 && { refinementServedVersion },
|
|
2182
2210
|
agentId: agent.id,
|
|
2183
2211
|
taskName,
|
|
2184
2212
|
params: durableDeferredSnapshot(params),
|
|
@@ -2244,7 +2272,8 @@ class TaskExecutor {
|
|
|
2244
2272
|
persistPausedContinuation,
|
|
2245
2273
|
serverVersion,
|
|
2246
2274
|
deferredClientContext,
|
|
2247
|
-
requireDeferredSettlementResumeAuthorization
|
|
2275
|
+
requireDeferredSettlementResumeAuthorization,
|
|
2276
|
+
refinementServedVersion
|
|
2248
2277
|
);
|
|
2249
2278
|
};
|
|
2250
2279
|
const deferred = {
|
|
@@ -2295,7 +2324,8 @@ class TaskExecutor {
|
|
|
2295
2324
|
persistPausedContinuation,
|
|
2296
2325
|
serverVersion,
|
|
2297
2326
|
deferredClientContext,
|
|
2298
|
-
requireDeferredSettlementResumeAuthorization
|
|
2327
|
+
requireDeferredSettlementResumeAuthorization,
|
|
2328
|
+
refinementServedVersion
|
|
2299
2329
|
);
|
|
2300
2330
|
}
|
|
2301
2331
|
/**
|
|
@@ -3295,7 +3325,8 @@ class TaskExecutor {
|
|
|
3295
3325
|
false,
|
|
3296
3326
|
state.serverVersion,
|
|
3297
3327
|
state.clientContext,
|
|
3298
|
-
state.settlementResumeAuthorizationRequired === true
|
|
3328
|
+
state.settlementResumeAuthorizationRequired === true,
|
|
3329
|
+
state.refinementServedVersion
|
|
3299
3330
|
);
|
|
3300
3331
|
resumed = attachDeferredServerVersion(resumed, state);
|
|
3301
3332
|
const observedResumedServerTaskId = resumed.metadata.serverTaskId;
|
|
@@ -3321,6 +3352,9 @@ class TaskExecutor {
|
|
|
3321
3352
|
...resumed.metadata.contextId !== void 0 ? { contextId: resumed.metadata.contextId } : state.contextId !== void 0 ? { contextId: state.contextId } : {},
|
|
3322
3353
|
a2aTaskId: nextA2ATaskId,
|
|
3323
3354
|
serverVersion: state.serverVersion,
|
|
3355
|
+
...state.refinementServedVersion !== void 0 && {
|
|
3356
|
+
refinementServedVersion: state.refinementServedVersion
|
|
3357
|
+
},
|
|
3324
3358
|
...state.wireAdcpVersion !== void 0 && { wireAdcpVersion: state.wireAdcpVersion },
|
|
3325
3359
|
...state.versionEnvelope !== void 0 && { versionEnvelope: state.versionEnvelope },
|
|
3326
3360
|
...state.serverVersionSynthetic !== void 0 && {
|
|
@@ -4249,7 +4283,7 @@ class TaskExecutor {
|
|
|
4249
4283
|
/**
|
|
4250
4284
|
* Continue a task after receiving input
|
|
4251
4285
|
*/
|
|
4252
|
-
async continueTaskWithInput(agent, taskId, taskName, params, contextId, a2aTaskId, input, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false) {
|
|
4286
|
+
async continueTaskWithInput(agent, taskId, taskName, params, contextId, a2aTaskId, input, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false, refinementServedVersion) {
|
|
4253
4287
|
const inputSnapshot = structuredClone(input);
|
|
4254
4288
|
if (agent.protocol !== "a2a") {
|
|
4255
4289
|
throw new Error("MCP does not define a standard continuation for a returned input-required task.");
|
|
@@ -4315,7 +4349,8 @@ class TaskExecutor {
|
|
|
4315
4349
|
persistPausedContinuation,
|
|
4316
4350
|
serverVersion,
|
|
4317
4351
|
deferredClientContext,
|
|
4318
|
-
requireDeferredSettlementResumeAuthorization
|
|
4352
|
+
requireDeferredSettlementResumeAuthorization,
|
|
4353
|
+
refinementServedVersion
|
|
4319
4354
|
);
|
|
4320
4355
|
}
|
|
4321
4356
|
/**
|
|
@@ -4507,7 +4542,7 @@ class TaskExecutor {
|
|
|
4507
4542
|
* valid so the caller can continue. Off mode short-circuits before
|
|
4508
4543
|
* AJV runs.
|
|
4509
4544
|
*/
|
|
4510
|
-
validateResponseSchema(response, taskName, debugLogs, serverVersion) {
|
|
4545
|
+
validateResponseSchema(response, taskName, debugLogs, serverVersion, requestParams, refinementServedVersion) {
|
|
4511
4546
|
const mode = this.responseValidationMode;
|
|
4512
4547
|
const logViolations = this.config.logSchemaViolations !== false;
|
|
4513
4548
|
try {
|
|
@@ -4519,6 +4554,46 @@ class TaskExecutor {
|
|
|
4519
4554
|
(validationVersion) => this.validateResponseSchemaAgainst(response, taskName, debugLogs, mode, logViolations, validationVersion)
|
|
4520
4555
|
);
|
|
4521
4556
|
}
|
|
4557
|
+
if (taskName === "refine_proposals" && mode !== "off") {
|
|
4558
|
+
const ceiling = requestParams?.adcp_version ?? toReleasePrecisionVersion(this.config.wireAdcpVersion ?? pinnedValidationVersion);
|
|
4559
|
+
const issues = [];
|
|
4560
|
+
const selected = selectRefinementSchemaVersion(
|
|
4561
|
+
ceiling,
|
|
4562
|
+
response,
|
|
4563
|
+
{
|
|
4564
|
+
adcpVersion: pinnedValidationVersion,
|
|
4565
|
+
servedAdcpVersion: applicableRefinementServedVersion(refinementServedVersion, ceiling)
|
|
4566
|
+
},
|
|
4567
|
+
issues
|
|
4568
|
+
);
|
|
4569
|
+
if (!selected) {
|
|
4570
|
+
const errors = issues.map((issue) => `${issue.path}: ${issue.message}`);
|
|
4571
|
+
if (logViolations) {
|
|
4572
|
+
debugLogs.push({
|
|
4573
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4574
|
+
type: mode === "strict" ? "error" : "warning",
|
|
4575
|
+
message: `Schema validation ${mode === "strict" ? "failed" : "warning"} for ${taskName}: ${errors.join("; ")}`,
|
|
4576
|
+
errors,
|
|
4577
|
+
issues,
|
|
4578
|
+
schemaVersion: pinnedValidationVersion,
|
|
4579
|
+
mode
|
|
4580
|
+
});
|
|
4581
|
+
if (mode === "warn") {
|
|
4582
|
+
console.warn(
|
|
4583
|
+
`Schema validation failed for ${taskName} against AdCP ${pinnedValidationVersion} (non-blocking):`,
|
|
4584
|
+
errors
|
|
4585
|
+
);
|
|
4586
|
+
} else {
|
|
4587
|
+
console.error(
|
|
4588
|
+
`Schema validation failed for ${taskName} against AdCP ${pinnedValidationVersion}:`,
|
|
4589
|
+
errors
|
|
4590
|
+
);
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
return { valid: mode !== "strict", errors: mode === "strict" ? errors : [] };
|
|
4594
|
+
}
|
|
4595
|
+
return this.validateResponseSchemaAgainst(response, taskName, debugLogs, mode, logViolations, selected);
|
|
4596
|
+
}
|
|
4522
4597
|
return this.validateResponseSchemaAgainst(
|
|
4523
4598
|
response,
|
|
4524
4599
|
taskName,
|
|
@@ -537,3 +537,37 @@ export declare function extractErrorInfo(error: unknown): {
|
|
|
537
537
|
details?: unknown;
|
|
538
538
|
stack?: string;
|
|
539
539
|
};
|
|
540
|
+
/**
|
|
541
|
+
* Prepared fixture state was refused by the host authorizer.
|
|
542
|
+
*
|
|
543
|
+
* An authorization failure is an ACCESS-CONTROL error, not a grading
|
|
544
|
+
* outcome, so the refused caller gets this and no `StoryboardResult` —
|
|
545
|
+
* not a partial one, not a redacted one. It carries the machine refusal
|
|
546
|
+
* code and nothing else: no fixture identities, no `seller_ids`, no
|
|
547
|
+
* captures, no binding values, no request/response records, and no
|
|
548
|
+
* results from steps that ran before the grant was revoked.
|
|
549
|
+
*
|
|
550
|
+
* The complete, unredacted record — including the synthesized
|
|
551
|
+
* `prepared_fixtures_authorization` check, `fixture_resolutions` with
|
|
552
|
+
* `seller_ids`, and exact request/response records — is handed to the
|
|
553
|
+
* host's `prepared_fixtures_audit_sink` before this is thrown. Where no
|
|
554
|
+
* sink is configured the record is simply not produced to anyone.
|
|
555
|
+
*
|
|
556
|
+
* Hosted entry points should surface this as a 403-style denial.
|
|
557
|
+
*/
|
|
558
|
+
export declare class PreparedFixturesDeniedError extends ADCPError {
|
|
559
|
+
/**
|
|
560
|
+
* Machine refusal code: `authorizer_required` | `untrusted_state` |
|
|
561
|
+
* `contract_version_mismatch` | `authorizer_denied` |
|
|
562
|
+
* `binding_mismatch` | `unauthorized_metadata`.
|
|
563
|
+
*/
|
|
564
|
+
readonly refusalCode: string;
|
|
565
|
+
readonly code = "PREPARED_FIXTURES_DENIED";
|
|
566
|
+
constructor(
|
|
567
|
+
/**
|
|
568
|
+
* Machine refusal code: `authorizer_required` | `untrusted_state` |
|
|
569
|
+
* `contract_version_mismatch` | `authorizer_denied` |
|
|
570
|
+
* `binding_mismatch` | `unauthorized_metadata`.
|
|
571
|
+
*/
|
|
572
|
+
refusalCode: string);
|
|
573
|
+
}
|