@adcp/sdk 17.0.0-beta.21 → 17.0.0-beta.22
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/README.md +26 -2
- package/dist/lib/client/core.d.mts +4 -0
- package/dist/lib/client/core.d.ts +4 -0
- package/dist/lib/client/core.js +13 -0
- package/dist/lib/client/core.mjs +12 -0
- package/dist/lib/conformance/property-lists.d.mts +1 -1
- package/dist/lib/conformance/property-lists.d.ts +1 -1
- package/dist/lib/conformance/property-lists.js +1 -1
- package/dist/lib/conformance/property-lists.mjs +1 -1
- package/dist/lib/core/SingleAgentClient.d.mts +10 -1
- package/dist/lib/core/SingleAgentClient.d.ts +10 -1
- package/dist/lib/core/SingleAgentClient.js +56 -7
- package/dist/lib/core/SingleAgentClient.mjs +61 -7
- package/dist/lib/core/targeting-helpers.d.mts +123 -0
- package/dist/lib/core/targeting-helpers.d.ts +123 -0
- package/dist/lib/core/targeting-helpers.js +412 -0
- package/dist/lib/core/targeting-helpers.mjs +370 -0
- package/dist/lib/entrypoints/client-account-changes.d.mts +5 -0
- package/dist/lib/entrypoints/client-account-changes.d.ts +5 -0
- package/dist/lib/entrypoints/client-account-changes.js +28 -0
- package/dist/lib/entrypoints/client-account-changes.mjs +4 -0
- package/dist/lib/entrypoints/client-webhook-stores.d.mts +2 -0
- package/dist/lib/entrypoints/client-webhook-stores.d.ts +2 -0
- package/dist/lib/entrypoints/client-webhook-stores.js +37 -0
- package/dist/lib/entrypoints/client-webhook-stores.mjs +16 -0
- package/dist/lib/entrypoints/discovery.d.mts +9 -0
- package/dist/lib/entrypoints/discovery.d.ts +9 -0
- package/dist/lib/entrypoints/discovery.js +72 -0
- package/dist/lib/entrypoints/discovery.mjs +56 -0
- package/dist/lib/entrypoints/errors.d.mts +11 -0
- package/dist/lib/entrypoints/errors.d.ts +11 -0
- package/dist/lib/entrypoints/errors.js +159 -0
- package/dist/lib/entrypoints/errors.mjs +132 -0
- package/dist/lib/entrypoints/media-buy.d.mts +5 -0
- package/dist/lib/entrypoints/media-buy.d.ts +5 -0
- package/dist/lib/entrypoints/media-buy.js +119 -0
- package/dist/lib/entrypoints/media-buy.mjs +100 -0
- package/dist/lib/entrypoints/registry.d.mts +5 -0
- package/dist/lib/entrypoints/registry.d.ts +5 -0
- package/dist/lib/entrypoints/registry.js +61 -0
- package/dist/lib/entrypoints/registry.mjs +40 -0
- package/dist/lib/entrypoints/utils.d.mts +7 -0
- package/dist/lib/entrypoints/utils.d.ts +7 -0
- package/dist/lib/entrypoints/utils.js +100 -0
- package/dist/lib/entrypoints/utils.mjs +72 -0
- package/dist/lib/entrypoints/version.d.mts +3 -0
- package/dist/lib/entrypoints/version.d.ts +3 -0
- package/dist/lib/entrypoints/version.js +57 -0
- package/dist/lib/entrypoints/version.mjs +36 -0
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/media-buy/action-contracts.js +3 -3
- package/dist/lib/media-buy/action-contracts.mjs +1 -1
- package/dist/lib/media-buy/creative-start-policy.d.mts +19 -0
- package/dist/lib/media-buy/creative-start-policy.d.ts +19 -0
- package/dist/lib/media-buy/creative-start-policy.js +59 -0
- package/dist/lib/media-buy/creative-start-policy.mjs +31 -0
- package/dist/lib/media-buy/valid-actions.d.mts +47 -0
- package/dist/lib/media-buy/valid-actions.d.ts +47 -0
- package/dist/lib/media-buy/valid-actions.js +42 -0
- package/dist/lib/media-buy/valid-actions.mjs +18 -0
- package/dist/lib/net/pin-and-bind-fetch.d.mts +121 -0
- package/dist/lib/net/pin-and-bind-fetch.d.ts +121 -0
- package/dist/lib/net/pin-and-bind-fetch.js +209 -0
- package/dist/lib/net/pin-and-bind-fetch.mjs +183 -0
- package/dist/lib/registry/types.generated.d.ts +18 -2
- package/dist/lib/reporting/ledger/index.d.mts +1 -0
- package/dist/lib/reporting/ledger/index.d.ts +1 -0
- package/dist/lib/reporting/ledger/index.js +3 -1
- package/dist/lib/reporting/ledger/index.mjs +1 -0
- package/dist/lib/reporting/ledger/instant.d.mts +5 -0
- package/dist/lib/reporting/ledger/instant.d.ts +5 -0
- package/dist/lib/reporting/ledger/instant.js +10 -0
- package/dist/lib/reporting/ledger/instant.mjs +9 -0
- package/dist/lib/reporting/ledger/issue-events.d.mts +333 -0
- package/dist/lib/reporting/ledger/issue-events.d.ts +333 -0
- package/dist/lib/reporting/ledger/issue-events.js +310 -0
- package/dist/lib/reporting/ledger/issue-events.mjs +282 -0
- package/dist/lib/reporting/service/index.d.mts +36 -1
- package/dist/lib/reporting/service/index.d.ts +36 -1
- package/dist/lib/reporting/service/index.js +51 -1
- package/dist/lib/reporting/service/index.mjs +52 -2
- package/dist/lib/reporting/service/scheduler-support.d.mts +1 -1
- package/dist/lib/reporting/service/scheduler-support.d.ts +1 -1
- package/dist/lib/reporting/service/scheduler-support.js +1 -1
- package/dist/lib/reporting/service/scheduler-support.mjs +1 -1
- package/dist/lib/server/capabilities-release-projection.d.mts +43 -0
- package/dist/lib/server/capabilities-release-projection.d.ts +43 -0
- package/dist/lib/server/capabilities-release-projection.js +128 -0
- package/dist/lib/server/capabilities-release-projection.mjs +112 -0
- package/dist/lib/server/create-adcp-server.d.mts +29 -5
- package/dist/lib/server/create-adcp-server.d.ts +29 -5
- package/dist/lib/server/create-adcp-server.js +95 -22
- package/dist/lib/server/create-adcp-server.mjs +106 -21
- package/dist/lib/server/decisioning/capabilities.d.mts +27 -0
- package/dist/lib/server/decisioning/capabilities.d.ts +27 -0
- package/dist/lib/server/decisioning/runtime/from-platform.js +99 -27
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +103 -27
- package/dist/lib/server/declared-input-schema.d.mts +108 -0
- package/dist/lib/server/declared-input-schema.d.ts +108 -0
- package/dist/lib/server/declared-input-schema.js +167 -0
- package/dist/lib/server/declared-input-schema.mjs +137 -0
- package/dist/lib/server/envelope-allowlist.d.mts +1 -105
- package/dist/lib/server/envelope-allowlist.d.ts +1 -105
- package/dist/lib/server/envelope-allowlist.js +3 -79
- package/dist/lib/server/envelope-allowlist.mjs +1 -71
- package/dist/lib/server/errors.d.mts +1 -186
- package/dist/lib/server/errors.d.ts +1 -186
- package/dist/lib/server/errors.js +3 -98
- package/dist/lib/server/errors.mjs +1 -94
- package/dist/lib/server/index.d.mts +1 -1
- package/dist/lib/server/index.d.ts +1 -1
- package/dist/lib/server/mcp-modern-server.js +21 -4
- package/dist/lib/server/mcp-modern-server.mjs +21 -4
- package/dist/lib/server/media-buy-action-resolver.d.mts +7 -0
- package/dist/lib/server/media-buy-action-resolver.d.ts +7 -0
- package/dist/lib/server/media-buy-action-resolver.js +10 -1
- package/dist/lib/server/media-buy-action-resolver.mjs +10 -1
- package/dist/lib/server/media-buy-helpers.d.mts +1 -47
- package/dist/lib/server/media-buy-helpers.d.ts +1 -47
- package/dist/lib/server/media-buy-helpers.js +3 -23
- package/dist/lib/server/media-buy-helpers.mjs +1 -18
- package/dist/lib/server/pick-safe-details.d.mts +1 -89
- package/dist/lib/server/pick-safe-details.d.ts +1 -89
- package/dist/lib/server/pick-safe-details.js +3 -61
- package/dist/lib/server/pick-safe-details.mjs +1 -56
- package/dist/lib/server/pin-and-bind-fetch.d.mts +1 -121
- package/dist/lib/server/pin-and-bind-fetch.d.ts +1 -121
- package/dist/lib/server/pin-and-bind-fetch.js +3 -190
- package/dist/lib/server/pin-and-bind-fetch.mjs +1 -183
- package/dist/lib/server/targeting-helpers.d.mts +1 -123
- package/dist/lib/server/targeting-helpers.d.ts +1 -123
- package/dist/lib/server/targeting-helpers.js +3 -393
- package/dist/lib/server/targeting-helpers.mjs +1 -370
- package/dist/lib/server/test-controller.js +7 -3
- package/dist/lib/server/test-controller.mjs +7 -3
- package/dist/lib/storage/memory-ledger.js +219 -1
- package/dist/lib/storage/memory-ledger.mjs +223 -1
- package/dist/lib/testing/compliance/storyboard-tracks.js +0 -4
- package/dist/lib/testing/compliance/storyboard-tracks.mjs +0 -4
- package/dist/lib/testing/comply-controller.js +7 -2
- package/dist/lib/testing/comply-controller.mjs +7 -2
- package/dist/lib/testing/storyboard/request-signing/grader.d.mts +21 -0
- package/dist/lib/testing/storyboard/request-signing/grader.d.ts +21 -0
- package/dist/lib/testing/storyboard/request-signing/grader.js +31 -0
- package/dist/lib/testing/storyboard/request-signing/grader.mjs +30 -0
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.js +1 -1
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs +2 -1
- package/dist/lib/testing/storyboard/request-signing/types.d.mts +12 -0
- package/dist/lib/testing/storyboard/request-signing/types.d.ts +12 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.js +7 -2
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +7 -2
- package/dist/lib/testing/storyboard/runner.js +2 -2
- package/dist/lib/testing/storyboard/runner.mjs +2 -2
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/utils/adcp-error-response.d.mts +196 -0
- package/dist/lib/utils/adcp-error-response.d.ts +196 -0
- package/dist/lib/utils/adcp-error-response.js +118 -0
- package/dist/lib/utils/adcp-error-response.mjs +95 -0
- package/dist/lib/utils/buyer-retry-policy.js +2 -2
- package/dist/lib/utils/buyer-retry-policy.mjs +1 -1
- package/dist/lib/utils/capabilities.d.mts +6 -0
- package/dist/lib/utils/capabilities.d.ts +6 -0
- package/dist/lib/utils/capabilities.js +6 -2
- package/dist/lib/utils/capabilities.mjs +6 -2
- package/dist/lib/utils/envelope-allowlist.d.mts +105 -0
- package/dist/lib/utils/envelope-allowlist.d.ts +105 -0
- package/dist/lib/utils/envelope-allowlist.js +98 -0
- package/dist/lib/utils/envelope-allowlist.mjs +71 -0
- package/dist/lib/utils/pick-safe-details.d.mts +89 -0
- package/dist/lib/utils/pick-safe-details.d.ts +89 -0
- package/dist/lib/utils/pick-safe-details.js +80 -0
- package/dist/lib/utils/pick-safe-details.mjs +56 -0
- package/dist/lib/v2/projection/augment-response.d.mts +4 -0
- package/dist/lib/v2/projection/augment-response.d.ts +4 -0
- package/dist/lib/v2/projection/creative-delivery.d.mts +20 -3
- package/dist/lib/v2/projection/creative-delivery.d.ts +20 -3
- package/dist/lib/v2/projection/creative-delivery.js +20 -4
- package/dist/lib/v2/projection/creative-delivery.mjs +19 -4
- package/dist/lib/v2/projection/index.d.mts +2 -2
- package/dist/lib/v2/projection/index.d.ts +2 -2
- package/dist/lib/v2/projection/index.js +4 -0
- package/dist/lib/v2/projection/index.mjs +5 -1
- package/dist/lib/v2/projection/legacy-metadata.d.mts +7 -0
- package/dist/lib/v2/projection/legacy-metadata.d.ts +7 -0
- package/dist/lib/v2/projection/legacy-metadata.js +14 -0
- package/dist/lib/v2/projection/legacy-metadata.mjs +12 -0
- package/dist/lib/v2/projection/legacy-routes.d.mts +11 -0
- package/dist/lib/v2/projection/legacy-routes.d.ts +11 -0
- package/dist/lib/v2/projection/legacy-routes.js +2 -1
- package/dist/lib/v2/projection/legacy-routes.mjs +7 -2
- package/dist/lib/v2/projection/v1-to-v2.d.mts +21 -1
- package/dist/lib/v2/projection/v1-to-v2.d.ts +21 -1
- package/dist/lib/v2/projection/v1-to-v2.js +18 -11
- package/dist/lib/v2/projection/v1-to-v2.mjs +19 -11
- 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 +2 -2
- package/docs/guides/CREATIVE-DELIVERY.md +12 -0
- package/docs/guides/REPORTING-LEDGER.md +121 -0
- package/docs/guides/VALIDATE-YOUR-AGENT.md +1 -0
- package/docs/llms.txt +2 -2
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-16-to-17.md +149 -0
- package/docs/migration-reporting-storage-package.md +10 -0
- package/package.json +106 -1
|
@@ -33,6 +33,7 @@ var import_account_reference_warnings = require('../../account-reference-warning
|
|
|
33
33
|
var import_node_crypto = require("node:crypto");
|
|
34
34
|
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
35
35
|
var import_create_adcp_server = require('../../create-adcp-server.js');
|
|
36
|
+
var import_inline_enums = require('../../../types/inline-enums.generated.js');
|
|
36
37
|
var import_capabilities = require('../capabilities.js');
|
|
37
38
|
var import_adcp_version_config = require('../../../utils/adcp-version-config.js');
|
|
38
39
|
var import_envelope_status_compat = require('../../../utils/envelope-status-compat.js');
|
|
@@ -62,6 +63,7 @@ var import_comply_controller = require('../../../testing/comply-controller.js');
|
|
|
62
63
|
var import_test_controller = require('../../test-controller.js');
|
|
63
64
|
var import_seed_merge = require('../../../testing/seed-merge.js');
|
|
64
65
|
var import_adcp_server = require('../../adcp-server.js');
|
|
66
|
+
var import_declared_input_schema = require('../../declared-input-schema.js');
|
|
65
67
|
var import_account_mode = require('../../account-mode.js');
|
|
66
68
|
var import_observed_modes = require('./observed-modes.js');
|
|
67
69
|
var import_normalize_errors = require('../../normalize-errors.js');
|
|
@@ -198,6 +200,16 @@ function isPlainObject(v) {
|
|
|
198
200
|
const proto = Object.getPrototypeOf(v);
|
|
199
201
|
return proto === Object.prototype || proto === null;
|
|
200
202
|
}
|
|
203
|
+
const COMPLY_ECHO_BYTE_CAP = 8 * 1024;
|
|
204
|
+
function cappedComplyEcho(value) {
|
|
205
|
+
if (value == null || typeof value !== "object") return void 0;
|
|
206
|
+
try {
|
|
207
|
+
if (JSON.stringify(value).length > COMPLY_ECHO_BYTE_CAP) return void 0;
|
|
208
|
+
return value;
|
|
209
|
+
} catch {
|
|
210
|
+
return void 0;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
201
213
|
function deepMergePlainObjects(target, source) {
|
|
202
214
|
if (source === void 0) return target;
|
|
203
215
|
if (source === null) return null;
|
|
@@ -217,6 +229,47 @@ function deepMergePlainObjects(target, source) {
|
|
|
217
229
|
function mergeCapabilityOverride(adopter, framework) {
|
|
218
230
|
return deepMergePlainObjects(adopter ?? {}, framework);
|
|
219
231
|
}
|
|
232
|
+
function deriveBuyingModes(briefPath, catalogue, supportsProposals) {
|
|
233
|
+
return [
|
|
234
|
+
...briefPath || supportsProposals === true || !catalogue ? ["brief"] : [],
|
|
235
|
+
...supportsProposals === true ? ["refine"] : [],
|
|
236
|
+
...catalogue ? ["wholesale"] : []
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
function validateDeclaredBuyingModes(declared, handlers) {
|
|
240
|
+
const field = "capabilities.buyingModes";
|
|
241
|
+
const known = import_inline_enums.GetProductsRequest_BuyingModeValues;
|
|
242
|
+
if (!Array.isArray(declared) || declared.length === 0) {
|
|
243
|
+
throw new import_validate_platform.PlatformConfigError(
|
|
244
|
+
`${field} must list at least one of ${known.map((m) => `'${m}'`).join(", ")}; omit it to derive the modes from the registered handlers`,
|
|
245
|
+
{ configField: field }
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
const modes = [...new Set(declared)];
|
|
249
|
+
const unknown = modes.filter((mode) => typeof mode !== "string" || !known.includes(mode));
|
|
250
|
+
if (unknown.length > 0) {
|
|
251
|
+
throw new import_validate_platform.PlatformConfigError(
|
|
252
|
+
`${field} contains ${unknown.map((mode) => JSON.stringify(mode)).join(", ")}, which ${unknown.length === 1 ? "is" : "are"} not a buying mode; use ${known.map((m) => `'${m}'`).join(", ")}`,
|
|
253
|
+
{ configField: field }
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
const declaredModes = modes;
|
|
257
|
+
const unserved = declaredModes.flatMap((mode) => {
|
|
258
|
+
if (mode === "wholesale") {
|
|
259
|
+
return handlers.getProducts || handlers.listProducts ? [] : [`'wholesale' needs sales.getProducts (answering buying_mode 'wholesale') or mediaBuyLifecycle.listProducts`];
|
|
260
|
+
}
|
|
261
|
+
return handlers.getProducts || handlers.proposals ? [] : [
|
|
262
|
+
`'${mode}' needs sales.getProducts or a proposal path (proposalManager, mediaBuyLifecycle.requestProposals or mediaBuyLifecycle.refineProposals)`
|
|
263
|
+
];
|
|
264
|
+
});
|
|
265
|
+
if (unserved.length > 0) {
|
|
266
|
+
throw new import_validate_platform.PlatformConfigError(
|
|
267
|
+
`${field} declares ${declaredModes.map((m) => `'${m}'`).join(", ")}, but the platform registers no handler for: ${unserved.join("; ")}. Register the handler or remove the mode.`,
|
|
268
|
+
{ configField: field }
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
return declaredModes;
|
|
272
|
+
}
|
|
220
273
|
function normalizeRowErrors(row) {
|
|
221
274
|
if (row?.errors == null) return row;
|
|
222
275
|
return { ...row, errors: (0, import_normalize_errors.normalizeErrors)(row.errors) };
|
|
@@ -1019,7 +1072,7 @@ function matchLegacyRefToDeclaration(declaration, ref, ownerId, legacyFormatConv
|
|
|
1019
1072
|
description: ownerId,
|
|
1020
1073
|
format_ids: [ref]
|
|
1021
1074
|
},
|
|
1022
|
-
{ legacyFormatConverter,
|
|
1075
|
+
{ legacyFormatConverter, authoritativeOnly }
|
|
1023
1076
|
);
|
|
1024
1077
|
if (projected.diagnostics.length > 0 || projected.v2.format_options.length !== 1) return "unresolved";
|
|
1025
1078
|
const expected = projected.v2.format_options[0];
|
|
@@ -1487,8 +1540,15 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1487
1540
|
const reportingDelivery = platform.reporting?.capabilities;
|
|
1488
1541
|
const targeting = platform.capabilities.targeting ? (0, import_capabilities.normalizeTargetingCapabilities)(platform.capabilities.targeting) : void 0;
|
|
1489
1542
|
const hasSalesPlatform = platform.sales != null || platform.mediaBuyLifecycle != null || platform.proposalManager != null;
|
|
1490
|
-
const
|
|
1491
|
-
const
|
|
1543
|
+
const hasProposalPath = platform.proposalManager != null || platform.mediaBuyLifecycle?.requestProposals != null || platform.mediaBuyLifecycle?.refineProposals != null;
|
|
1544
|
+
const supportsProposals = platform.capabilities.supportsProposals ?? (hasProposalPath ? true : hasSalesPlatform ? false : void 0);
|
|
1545
|
+
const hasCatalogueHandler = platform.mediaBuyLifecycle?.listProducts != null;
|
|
1546
|
+
const declaredBuyingModes = platform.capabilities.buyingModes === void 0 ? void 0 : validateDeclaredBuyingModes(platform.capabilities.buyingModes, {
|
|
1547
|
+
getProducts: platform.sales?.getProducts != null || legacyHandlers.mediaBuy?.getProducts != null,
|
|
1548
|
+
listProducts: hasCatalogueHandler || legacyHandlers.mediaBuy?.listProducts != null,
|
|
1549
|
+
proposals: hasProposalPath || legacyHandlers.mediaBuy?.requestProposals != null || opts.proposalNegotiation != null
|
|
1550
|
+
});
|
|
1551
|
+
const hasMediaBuyProjection = hasSalesPlatform || at != null || ct != null || cs != null || som != null || fc != null || reportingDelivery != null || targeting != null || supportsProposals !== void 0 || declaredBuyingModes !== void 0;
|
|
1492
1552
|
const configuredAdcpVersion = opts.adcpVersion ?? import_version.ADCP_VERSION;
|
|
1493
1553
|
const configuredRelease = parseAdcpRelease(configuredAdcpVersion);
|
|
1494
1554
|
if (!configuredRelease) {
|
|
@@ -1530,8 +1590,12 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1530
1590
|
const canonicalCreativeCapability = supportsCanonicalCreativeCapability(configuredAdcpVersion);
|
|
1531
1591
|
const defaultCreativeWireMode = canonicalCreativeCapability ? "canonical" : "legacy";
|
|
1532
1592
|
const mediaBuyOverrides = {
|
|
1533
|
-
...hasSalesPlatform && {
|
|
1534
|
-
buying_modes:
|
|
1593
|
+
...declaredBuyingModes !== void 0 ? { buying_modes: declaredBuyingModes } : hasSalesPlatform && {
|
|
1594
|
+
buying_modes: deriveBuyingModes(
|
|
1595
|
+
platform.sales?.getProducts != null || hasProposalPath,
|
|
1596
|
+
hasCatalogueHandler,
|
|
1597
|
+
supportsProposals
|
|
1598
|
+
)
|
|
1535
1599
|
},
|
|
1536
1600
|
...at != null && { audience_targeting: at },
|
|
1537
1601
|
...ct != null && { conversion_tracking: ct },
|
|
@@ -2137,13 +2201,28 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2137
2201
|
sandbox: import_zod.z.boolean().optional()
|
|
2138
2202
|
}).strict().optional()
|
|
2139
2203
|
};
|
|
2140
|
-
mcp.registerTool(
|
|
2204
|
+
const registeredController = mcp.registerTool(
|
|
2141
2205
|
controller.toolDefinition.name,
|
|
2142
2206
|
{
|
|
2143
2207
|
description: controller.toolDefinition.description,
|
|
2144
2208
|
inputSchema: gatedInputSchema
|
|
2145
2209
|
},
|
|
2146
|
-
(async (
|
|
2210
|
+
(async (rawInput, extra) => {
|
|
2211
|
+
const parsed = await (0, import_declared_input_schema.parseDeclaredToolInput)(mcp, controller.toolDefinition.name, rawInput, {
|
|
2212
|
+
echoContext: cappedComplyEcho
|
|
2213
|
+
});
|
|
2214
|
+
if (!parsed.success) {
|
|
2215
|
+
if (!await resolveComplyControllerVisible(extra, "comply_test_controller", rawInput)) {
|
|
2216
|
+
throw new import_types.McpError(import_types.ErrorCode.MethodNotFound, "Method not found");
|
|
2217
|
+
}
|
|
2218
|
+
return parsed.response;
|
|
2219
|
+
}
|
|
2220
|
+
const input = parsed.data;
|
|
2221
|
+
const callerContext = cappedComplyEcho(isPlainObject(rawInput) ? rawInput.context : void 0);
|
|
2222
|
+
const reject = (response) => (0, import_declared_input_schema.finishDeclaredInputRejection)(mcp, controller.toolDefinition.name, response, {
|
|
2223
|
+
context: callerContext,
|
|
2224
|
+
releaseArgs: input
|
|
2225
|
+
});
|
|
2147
2226
|
const principalAuthority = await resolveComplyPrincipalAuthority(extra, "comply_test_controller", input);
|
|
2148
2227
|
if (!isComplyControllerVisible(principalAuthority.principalAccount)) {
|
|
2149
2228
|
throw new import_types.McpError(import_types.ErrorCode.MethodNotFound, "Method not found");
|
|
@@ -2155,11 +2234,11 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2155
2234
|
const refFromContext = input.context?.account;
|
|
2156
2235
|
const accountRef = refFromTop ?? refFromContext;
|
|
2157
2236
|
if (accountRef !== void 0 && (typeof accountRef !== "object" || Array.isArray(accountRef))) {
|
|
2158
|
-
return (0, import_errors.adcpError)("INVALID_REQUEST", { message: "account must be an object" });
|
|
2237
|
+
return reject((0, import_errors.adcpError)("INVALID_REQUEST", { message: "account must be an object" }));
|
|
2159
2238
|
}
|
|
2160
2239
|
const requestedAccountId = (0, import_account.refAccountId)(accountRef);
|
|
2161
2240
|
if (requestedAccountId !== void 0 && (typeof requestedAccountId !== "string" || requestedAccountId.length === 0 || accountRef !== void 0 && ("brand" in accountRef || "operator" in accountRef))) {
|
|
2162
|
-
return (0, import_errors.adcpError)("INVALID_REQUEST", { message: "Invalid account_id reference" });
|
|
2241
|
+
return reject((0, import_errors.adcpError)("INVALID_REQUEST", { message: "Invalid account_id reference" }));
|
|
2163
2242
|
}
|
|
2164
2243
|
const resolverRef = requestedAccountId === void 0 ? accountRef : { account_id: requestedAccountId };
|
|
2165
2244
|
let resolvedAccount = null;
|
|
@@ -2184,12 +2263,12 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2184
2263
|
if (err instanceof import_account.AccountNotFoundError || err instanceof import_async_outcome.AdcpError && err.code === "ACCOUNT_NOT_FOUND") {
|
|
2185
2264
|
resolvedAccount = null;
|
|
2186
2265
|
} else if (err instanceof import_async_outcome.AdcpError) {
|
|
2187
|
-
return (0, import_errors.adcpError)(err.code, err.toStructuredError());
|
|
2266
|
+
return reject((0, import_errors.adcpError)(err.code, err.toStructuredError()));
|
|
2188
2267
|
} else {
|
|
2189
2268
|
fwLogger.error?.("Account resolution failed during comply controller dispatch", {
|
|
2190
2269
|
error_type: err instanceof Error ? err.name : typeof err
|
|
2191
2270
|
});
|
|
2192
|
-
return (0, import_errors.adcpError)("SERVICE_UNAVAILABLE", { message: "Account resolution failed" });
|
|
2271
|
+
return reject((0, import_errors.adcpError)("SERVICE_UNAVAILABLE", { message: "Account resolution failed" }));
|
|
2193
2272
|
}
|
|
2194
2273
|
}
|
|
2195
2274
|
resolvedAccount = assertResolvedAccountMatchesRef(
|
|
@@ -2212,18 +2291,8 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2212
2291
|
}
|
|
2213
2292
|
const allowed = accountIsSandbox || resolvedAccount == null && refSandbox || envSandbox;
|
|
2214
2293
|
if (!allowed) {
|
|
2215
|
-
const
|
|
2216
|
-
const
|
|
2217
|
-
if (value == null || typeof value !== "object") return void 0;
|
|
2218
|
-
try {
|
|
2219
|
-
if (JSON.stringify(value).length > ECHO_BYTE_CAP) return void 0;
|
|
2220
|
-
return value;
|
|
2221
|
-
} catch {
|
|
2222
|
-
return void 0;
|
|
2223
|
-
}
|
|
2224
|
-
};
|
|
2225
|
-
const requestContext = safeEcho(input.context);
|
|
2226
|
-
const requestExt = safeEcho(input.ext);
|
|
2294
|
+
const requestContext = cappedComplyEcho(input.context);
|
|
2295
|
+
const requestExt = cappedComplyEcho(input.ext);
|
|
2227
2296
|
const response = (0, import_errors.adcpError)("PERMISSION_DENIED", {
|
|
2228
2297
|
message: "comply_test_controller requires a sandbox or mock target account; resolved target account is live or unresolved.",
|
|
2229
2298
|
recovery: "terminal",
|
|
@@ -2264,10 +2333,12 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2264
2333
|
fwLogger.warn?.("Session key resolution failed during comply controller dispatch", {
|
|
2265
2334
|
error: (0, import_redact.redactCredentialPatterns)(err instanceof Error ? err.message : String(err))
|
|
2266
2335
|
});
|
|
2267
|
-
return (
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2336
|
+
return reject(
|
|
2337
|
+
(0, import_errors.adcpError)("SERVICE_UNAVAILABLE", {
|
|
2338
|
+
message: "Session key resolution failed",
|
|
2339
|
+
recovery: "transient"
|
|
2340
|
+
})
|
|
2341
|
+
);
|
|
2271
2342
|
}
|
|
2272
2343
|
}
|
|
2273
2344
|
let taskScope;
|
|
@@ -2296,6 +2367,7 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2296
2367
|
});
|
|
2297
2368
|
})
|
|
2298
2369
|
);
|
|
2370
|
+
(0, import_declared_input_schema.validateToolInputAtAdcpLayer)(mcp, controller.toolDefinition.name, registeredController);
|
|
2299
2371
|
const wrappedToolsCall = (0, import_adcp_server.wrapSdkRequestHandler)(mcp, "tools/call", async (orig, req, extra) => {
|
|
2300
2372
|
const params = req.params ?? {};
|
|
2301
2373
|
if (params.name === "comply_test_controller") {
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
createAdcpServer,
|
|
13
13
|
COMPACT_MEDIA_BUY_MUTATION_TOOLS
|
|
14
14
|
} from "../../create-adcp-server.mjs";
|
|
15
|
+
import { GetProductsRequest_BuyingModeValues } from "../../../types/inline-enums.generated.mjs";
|
|
15
16
|
import { normalizeTargetingCapabilities } from "../capabilities.mjs";
|
|
16
17
|
import { isAdcpVersionAtLeast, isPre31AdcpVersion } from "../../../utils/adcp-version-config.mjs";
|
|
17
18
|
import { omitsEnvelopeStatusForRelease } from "../../../utils/envelope-status-compat.mjs";
|
|
@@ -100,6 +101,11 @@ import {
|
|
|
100
101
|
wrapRegisteredToolHandler,
|
|
101
102
|
wrapSdkRequestHandler
|
|
102
103
|
} from "../../adcp-server.mjs";
|
|
104
|
+
import {
|
|
105
|
+
finishDeclaredInputRejection,
|
|
106
|
+
parseDeclaredToolInput,
|
|
107
|
+
validateToolInputAtAdcpLayer
|
|
108
|
+
} from "../../declared-input-schema.mjs";
|
|
103
109
|
import { isSandboxOrMockAccount } from "../../account-mode.mjs";
|
|
104
110
|
import { recordResolvedAccountMode, hasObservedLiveMode } from "./observed-modes.mjs";
|
|
105
111
|
import { normalizeErrors } from "../../normalize-errors.mjs";
|
|
@@ -230,6 +236,16 @@ function isPlainObject(v) {
|
|
|
230
236
|
const proto = Object.getPrototypeOf(v);
|
|
231
237
|
return proto === Object.prototype || proto === null;
|
|
232
238
|
}
|
|
239
|
+
const COMPLY_ECHO_BYTE_CAP = 8 * 1024;
|
|
240
|
+
function cappedComplyEcho(value) {
|
|
241
|
+
if (value == null || typeof value !== "object") return void 0;
|
|
242
|
+
try {
|
|
243
|
+
if (JSON.stringify(value).length > COMPLY_ECHO_BYTE_CAP) return void 0;
|
|
244
|
+
return value;
|
|
245
|
+
} catch {
|
|
246
|
+
return void 0;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
233
249
|
function deepMergePlainObjects(target, source) {
|
|
234
250
|
if (source === void 0) return target;
|
|
235
251
|
if (source === null) return null;
|
|
@@ -249,6 +265,47 @@ function deepMergePlainObjects(target, source) {
|
|
|
249
265
|
function mergeCapabilityOverride(adopter, framework) {
|
|
250
266
|
return deepMergePlainObjects(adopter ?? {}, framework);
|
|
251
267
|
}
|
|
268
|
+
function deriveBuyingModes(briefPath, catalogue, supportsProposals) {
|
|
269
|
+
return [
|
|
270
|
+
...briefPath || supportsProposals === true || !catalogue ? ["brief"] : [],
|
|
271
|
+
...supportsProposals === true ? ["refine"] : [],
|
|
272
|
+
...catalogue ? ["wholesale"] : []
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
function validateDeclaredBuyingModes(declared, handlers) {
|
|
276
|
+
const field = "capabilities.buyingModes";
|
|
277
|
+
const known = GetProductsRequest_BuyingModeValues;
|
|
278
|
+
if (!Array.isArray(declared) || declared.length === 0) {
|
|
279
|
+
throw new PlatformConfigError(
|
|
280
|
+
`${field} must list at least one of ${known.map((m) => `'${m}'`).join(", ")}; omit it to derive the modes from the registered handlers`,
|
|
281
|
+
{ configField: field }
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
const modes = [...new Set(declared)];
|
|
285
|
+
const unknown = modes.filter((mode) => typeof mode !== "string" || !known.includes(mode));
|
|
286
|
+
if (unknown.length > 0) {
|
|
287
|
+
throw new PlatformConfigError(
|
|
288
|
+
`${field} contains ${unknown.map((mode) => JSON.stringify(mode)).join(", ")}, which ${unknown.length === 1 ? "is" : "are"} not a buying mode; use ${known.map((m) => `'${m}'`).join(", ")}`,
|
|
289
|
+
{ configField: field }
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
const declaredModes = modes;
|
|
293
|
+
const unserved = declaredModes.flatMap((mode) => {
|
|
294
|
+
if (mode === "wholesale") {
|
|
295
|
+
return handlers.getProducts || handlers.listProducts ? [] : [`'wholesale' needs sales.getProducts (answering buying_mode 'wholesale') or mediaBuyLifecycle.listProducts`];
|
|
296
|
+
}
|
|
297
|
+
return handlers.getProducts || handlers.proposals ? [] : [
|
|
298
|
+
`'${mode}' needs sales.getProducts or a proposal path (proposalManager, mediaBuyLifecycle.requestProposals or mediaBuyLifecycle.refineProposals)`
|
|
299
|
+
];
|
|
300
|
+
});
|
|
301
|
+
if (unserved.length > 0) {
|
|
302
|
+
throw new PlatformConfigError(
|
|
303
|
+
`${field} declares ${declaredModes.map((m) => `'${m}'`).join(", ")}, but the platform registers no handler for: ${unserved.join("; ")}. Register the handler or remove the mode.`,
|
|
304
|
+
{ configField: field }
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
return declaredModes;
|
|
308
|
+
}
|
|
252
309
|
function normalizeRowErrors(row) {
|
|
253
310
|
if (row?.errors == null) return row;
|
|
254
311
|
return { ...row, errors: normalizeErrors(row.errors) };
|
|
@@ -1051,7 +1108,7 @@ function matchLegacyRefToDeclaration(declaration, ref, ownerId, legacyFormatConv
|
|
|
1051
1108
|
description: ownerId,
|
|
1052
1109
|
format_ids: [ref]
|
|
1053
1110
|
},
|
|
1054
|
-
{ legacyFormatConverter,
|
|
1111
|
+
{ legacyFormatConverter, authoritativeOnly }
|
|
1055
1112
|
);
|
|
1056
1113
|
if (projected.diagnostics.length > 0 || projected.v2.format_options.length !== 1) return "unresolved";
|
|
1057
1114
|
const expected = projected.v2.format_options[0];
|
|
@@ -1519,8 +1576,15 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1519
1576
|
const reportingDelivery = platform.reporting?.capabilities;
|
|
1520
1577
|
const targeting = platform.capabilities.targeting ? normalizeTargetingCapabilities(platform.capabilities.targeting) : void 0;
|
|
1521
1578
|
const hasSalesPlatform = platform.sales != null || platform.mediaBuyLifecycle != null || platform.proposalManager != null;
|
|
1522
|
-
const
|
|
1523
|
-
const
|
|
1579
|
+
const hasProposalPath = platform.proposalManager != null || platform.mediaBuyLifecycle?.requestProposals != null || platform.mediaBuyLifecycle?.refineProposals != null;
|
|
1580
|
+
const supportsProposals = platform.capabilities.supportsProposals ?? (hasProposalPath ? true : hasSalesPlatform ? false : void 0);
|
|
1581
|
+
const hasCatalogueHandler = platform.mediaBuyLifecycle?.listProducts != null;
|
|
1582
|
+
const declaredBuyingModes = platform.capabilities.buyingModes === void 0 ? void 0 : validateDeclaredBuyingModes(platform.capabilities.buyingModes, {
|
|
1583
|
+
getProducts: platform.sales?.getProducts != null || legacyHandlers.mediaBuy?.getProducts != null,
|
|
1584
|
+
listProducts: hasCatalogueHandler || legacyHandlers.mediaBuy?.listProducts != null,
|
|
1585
|
+
proposals: hasProposalPath || legacyHandlers.mediaBuy?.requestProposals != null || opts.proposalNegotiation != null
|
|
1586
|
+
});
|
|
1587
|
+
const hasMediaBuyProjection = hasSalesPlatform || at != null || ct != null || cs != null || som != null || fc != null || reportingDelivery != null || targeting != null || supportsProposals !== void 0 || declaredBuyingModes !== void 0;
|
|
1524
1588
|
const configuredAdcpVersion = opts.adcpVersion ?? ADCP_VERSION;
|
|
1525
1589
|
const configuredRelease = parseAdcpRelease(configuredAdcpVersion);
|
|
1526
1590
|
if (!configuredRelease) {
|
|
@@ -1562,8 +1626,12 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1562
1626
|
const canonicalCreativeCapability = supportsCanonicalCreativeCapability(configuredAdcpVersion);
|
|
1563
1627
|
const defaultCreativeWireMode = canonicalCreativeCapability ? "canonical" : "legacy";
|
|
1564
1628
|
const mediaBuyOverrides = {
|
|
1565
|
-
...hasSalesPlatform && {
|
|
1566
|
-
buying_modes:
|
|
1629
|
+
...declaredBuyingModes !== void 0 ? { buying_modes: declaredBuyingModes } : hasSalesPlatform && {
|
|
1630
|
+
buying_modes: deriveBuyingModes(
|
|
1631
|
+
platform.sales?.getProducts != null || hasProposalPath,
|
|
1632
|
+
hasCatalogueHandler,
|
|
1633
|
+
supportsProposals
|
|
1634
|
+
)
|
|
1567
1635
|
},
|
|
1568
1636
|
...at != null && { audience_targeting: at },
|
|
1569
1637
|
...ct != null && { conversion_tracking: ct },
|
|
@@ -2169,13 +2237,28 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2169
2237
|
sandbox: z.boolean().optional()
|
|
2170
2238
|
}).strict().optional()
|
|
2171
2239
|
};
|
|
2172
|
-
mcp.registerTool(
|
|
2240
|
+
const registeredController = mcp.registerTool(
|
|
2173
2241
|
controller.toolDefinition.name,
|
|
2174
2242
|
{
|
|
2175
2243
|
description: controller.toolDefinition.description,
|
|
2176
2244
|
inputSchema: gatedInputSchema
|
|
2177
2245
|
},
|
|
2178
|
-
(async (
|
|
2246
|
+
(async (rawInput, extra) => {
|
|
2247
|
+
const parsed = await parseDeclaredToolInput(mcp, controller.toolDefinition.name, rawInput, {
|
|
2248
|
+
echoContext: cappedComplyEcho
|
|
2249
|
+
});
|
|
2250
|
+
if (!parsed.success) {
|
|
2251
|
+
if (!await resolveComplyControllerVisible(extra, "comply_test_controller", rawInput)) {
|
|
2252
|
+
throw new McpError(ErrorCode.MethodNotFound, "Method not found");
|
|
2253
|
+
}
|
|
2254
|
+
return parsed.response;
|
|
2255
|
+
}
|
|
2256
|
+
const input = parsed.data;
|
|
2257
|
+
const callerContext = cappedComplyEcho(isPlainObject(rawInput) ? rawInput.context : void 0);
|
|
2258
|
+
const reject = (response) => finishDeclaredInputRejection(mcp, controller.toolDefinition.name, response, {
|
|
2259
|
+
context: callerContext,
|
|
2260
|
+
releaseArgs: input
|
|
2261
|
+
});
|
|
2179
2262
|
const principalAuthority = await resolveComplyPrincipalAuthority(extra, "comply_test_controller", input);
|
|
2180
2263
|
if (!isComplyControllerVisible(principalAuthority.principalAccount)) {
|
|
2181
2264
|
throw new McpError(ErrorCode.MethodNotFound, "Method not found");
|
|
@@ -2187,11 +2270,11 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2187
2270
|
const refFromContext = input.context?.account;
|
|
2188
2271
|
const accountRef = refFromTop ?? refFromContext;
|
|
2189
2272
|
if (accountRef !== void 0 && (typeof accountRef !== "object" || Array.isArray(accountRef))) {
|
|
2190
|
-
return adcpError("INVALID_REQUEST", { message: "account must be an object" });
|
|
2273
|
+
return reject(adcpError("INVALID_REQUEST", { message: "account must be an object" }));
|
|
2191
2274
|
}
|
|
2192
2275
|
const requestedAccountId = refAccountId(accountRef);
|
|
2193
2276
|
if (requestedAccountId !== void 0 && (typeof requestedAccountId !== "string" || requestedAccountId.length === 0 || accountRef !== void 0 && ("brand" in accountRef || "operator" in accountRef))) {
|
|
2194
|
-
return adcpError("INVALID_REQUEST", { message: "Invalid account_id reference" });
|
|
2277
|
+
return reject(adcpError("INVALID_REQUEST", { message: "Invalid account_id reference" }));
|
|
2195
2278
|
}
|
|
2196
2279
|
const resolverRef = requestedAccountId === void 0 ? accountRef : { account_id: requestedAccountId };
|
|
2197
2280
|
let resolvedAccount = null;
|
|
@@ -2216,12 +2299,12 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2216
2299
|
if (err instanceof AccountNotFoundError || err instanceof AdcpError && err.code === "ACCOUNT_NOT_FOUND") {
|
|
2217
2300
|
resolvedAccount = null;
|
|
2218
2301
|
} else if (err instanceof AdcpError) {
|
|
2219
|
-
return adcpError(err.code, err.toStructuredError());
|
|
2302
|
+
return reject(adcpError(err.code, err.toStructuredError()));
|
|
2220
2303
|
} else {
|
|
2221
2304
|
fwLogger.error?.("Account resolution failed during comply controller dispatch", {
|
|
2222
2305
|
error_type: err instanceof Error ? err.name : typeof err
|
|
2223
2306
|
});
|
|
2224
|
-
return adcpError("SERVICE_UNAVAILABLE", { message: "Account resolution failed" });
|
|
2307
|
+
return reject(adcpError("SERVICE_UNAVAILABLE", { message: "Account resolution failed" }));
|
|
2225
2308
|
}
|
|
2226
2309
|
}
|
|
2227
2310
|
resolvedAccount = assertResolvedAccountMatchesRef(
|
|
@@ -2244,18 +2327,8 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2244
2327
|
}
|
|
2245
2328
|
const allowed = accountIsSandbox || resolvedAccount == null && refSandbox || envSandbox;
|
|
2246
2329
|
if (!allowed) {
|
|
2247
|
-
const
|
|
2248
|
-
const
|
|
2249
|
-
if (value == null || typeof value !== "object") return void 0;
|
|
2250
|
-
try {
|
|
2251
|
-
if (JSON.stringify(value).length > ECHO_BYTE_CAP) return void 0;
|
|
2252
|
-
return value;
|
|
2253
|
-
} catch {
|
|
2254
|
-
return void 0;
|
|
2255
|
-
}
|
|
2256
|
-
};
|
|
2257
|
-
const requestContext = safeEcho(input.context);
|
|
2258
|
-
const requestExt = safeEcho(input.ext);
|
|
2330
|
+
const requestContext = cappedComplyEcho(input.context);
|
|
2331
|
+
const requestExt = cappedComplyEcho(input.ext);
|
|
2259
2332
|
const response = adcpError("PERMISSION_DENIED", {
|
|
2260
2333
|
message: "comply_test_controller requires a sandbox or mock target account; resolved target account is live or unresolved.",
|
|
2261
2334
|
recovery: "terminal",
|
|
@@ -2296,10 +2369,12 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2296
2369
|
fwLogger.warn?.("Session key resolution failed during comply controller dispatch", {
|
|
2297
2370
|
error: redactCredentialPatterns(err instanceof Error ? err.message : String(err))
|
|
2298
2371
|
});
|
|
2299
|
-
return
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2372
|
+
return reject(
|
|
2373
|
+
adcpError("SERVICE_UNAVAILABLE", {
|
|
2374
|
+
message: "Session key resolution failed",
|
|
2375
|
+
recovery: "transient"
|
|
2376
|
+
})
|
|
2377
|
+
);
|
|
2303
2378
|
}
|
|
2304
2379
|
}
|
|
2305
2380
|
let taskScope;
|
|
@@ -2328,6 +2403,7 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
2328
2403
|
});
|
|
2329
2404
|
})
|
|
2330
2405
|
);
|
|
2406
|
+
validateToolInputAtAdcpLayer(mcp, controller.toolDefinition.name, registeredController);
|
|
2331
2407
|
const wrappedToolsCall = wrapSdkRequestHandler(mcp, "tools/call", async (orig, req, extra) => {
|
|
2332
2408
|
const params = req.params ?? {};
|
|
2333
2409
|
if (params.name === "comply_test_controller") {
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdCP-layer validation for tools registered with a zod input schema.
|
|
3
|
+
*
|
|
4
|
+
* The MCP SDK parses `tools/call` arguments against a tool's registered
|
|
5
|
+
* `inputSchema` before the handler runs, and answers a failure with a bare
|
|
6
|
+
* `-32602` text result: no `structuredContent`, no `adcp_error`, and no echo
|
|
7
|
+
* of the caller's `context` (adcp-client#3666). Framework tools avoid that by
|
|
8
|
+
* registering a passthrough schema and validating inside the handler. These
|
|
9
|
+
* helpers give zod-declared tools (`customTools`, `tasks_get`,
|
|
10
|
+
* `comply_test_controller`) the same treatment:
|
|
11
|
+
*
|
|
12
|
+
* - {@link validateToolInputAtAdcpLayer} swaps the registered schema for a
|
|
13
|
+
* passthrough one, so MCP-level validation cannot reject first, and keeps
|
|
14
|
+
* `tools/list` advertising the declared schema.
|
|
15
|
+
* - {@link parseDeclaredToolInput} runs the declared schema inside the
|
|
16
|
+
* handler and returns either the parsed value (coercion, defaults and
|
|
17
|
+
* transforms applied exactly as the SDK applied them) or an
|
|
18
|
+
* `INVALID_REQUEST` response that echoes `context`.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
import type { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
23
|
+
import { type AnySchema } from '@modelcontextprotocol/sdk/server/zod-compat.js';
|
|
24
|
+
import type { McpToolResponse } from './responses.mjs';
|
|
25
|
+
/**
|
|
26
|
+
* Registered MCP input schema for tools whose arguments the AdCP layer
|
|
27
|
+
* validates. Accepts any object and keeps every key, so the handler sees the
|
|
28
|
+
* caller's arguments unchanged.
|
|
29
|
+
*/
|
|
30
|
+
export declare const PASSTHROUGH_INPUT_SCHEMA: z.ZodObject<{}, z.core.$loose>;
|
|
31
|
+
/** What a framework-built rejection on a declared-input tool is finished from. */
|
|
32
|
+
export interface DeclaredInputRejection {
|
|
33
|
+
/** The caller's `context`, echoed verbatim. It never feeds a decision. */
|
|
34
|
+
context: unknown;
|
|
35
|
+
/**
|
|
36
|
+
* Arguments the served release is read from: the parsed value once parsing
|
|
37
|
+
* succeeded, the caller's arguments when parsing itself failed.
|
|
38
|
+
*/
|
|
39
|
+
releaseArgs: unknown;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Finishes a framework-built rejection the way the hosting server finishes its
|
|
43
|
+
* own errors: the caller's `context`, envelope `status`, served `adcp_version`.
|
|
44
|
+
*/
|
|
45
|
+
export type DeclaredInputErrorFinalizer = (toolName: string, response: McpToolResponse, rejection: DeclaredInputRejection) => McpToolResponse;
|
|
46
|
+
/**
|
|
47
|
+
* Configure how declared-input errors on `server` are finished. Called by
|
|
48
|
+
* `createAdcpServer` so tools registered after it returns (the
|
|
49
|
+
* `comply_test_controller` helpers) stamp the same envelope fields as
|
|
50
|
+
* framework errors. Without it, errors still carry `adcp_error` and `context`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function configureDeclaredInputErrors(server: McpServer, options: {
|
|
53
|
+
finalize: DeclaredInputErrorFinalizer;
|
|
54
|
+
exposeSchemaPath: boolean;
|
|
55
|
+
}): void;
|
|
56
|
+
/**
|
|
57
|
+
* Move a freshly registered tool's argument validation from the MCP SDK to
|
|
58
|
+
* the AdCP layer. The schema the SDK normalized at registration becomes the
|
|
59
|
+
* declared schema: {@link parseDeclaredToolInput} validates against it and
|
|
60
|
+
* `tools/list` keeps advertising it. The SDK itself validates against
|
|
61
|
+
* {@link PASSTHROUGH_INPUT_SCHEMA} from now on.
|
|
62
|
+
*
|
|
63
|
+
* The handler must call {@link parseDeclaredToolInput} before using its
|
|
64
|
+
* arguments. A tool registered without an input schema is left unchanged, and
|
|
65
|
+
* so is a tool on a server that is not an SDK `McpServer` (a test double or
|
|
66
|
+
* proxy that returns no registration record or has no `tools/list` handler to
|
|
67
|
+
* wrap): its SDK keeps validating, and {@link parseDeclaredToolInput} passes
|
|
68
|
+
* the arguments through.
|
|
69
|
+
*/
|
|
70
|
+
export declare function validateToolInputAtAdcpLayer(server: McpServer, name: string, registered: Pick<RegisteredTool, 'inputSchema'> | {
|
|
71
|
+
inputSchema?: unknown;
|
|
72
|
+
} | undefined): void;
|
|
73
|
+
/** The declared input schema of `name` on `server`, when the AdCP layer validates it. */
|
|
74
|
+
export declare function getDeclaredInputSchema(server: McpServer, name: string): AnySchema | undefined;
|
|
75
|
+
/** The JSON Schema the MCP SDK's own `tools/list` emits for an input schema. */
|
|
76
|
+
export declare function declaredInputJsonSchema(schema: AnySchema): Record<string, unknown>;
|
|
77
|
+
export type DeclaredInputParseResult = {
|
|
78
|
+
success: true;
|
|
79
|
+
data: unknown;
|
|
80
|
+
} | {
|
|
81
|
+
success: false;
|
|
82
|
+
response: McpToolResponse;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Validate `args` against the schema `name` declared at registration.
|
|
86
|
+
*
|
|
87
|
+
* Success carries the parsed value — the same value the MCP SDK used to hand
|
|
88
|
+
* the handler, with zod coercion, defaults and transforms applied. Every
|
|
89
|
+
* decision the caller makes afterwards (authorization, release selection,
|
|
90
|
+
* gating) must read this value and hand the handler this same value; reading
|
|
91
|
+
* the raw arguments again would let a default or coercion change what was
|
|
92
|
+
* authorized. Failure carries an `INVALID_REQUEST` response with `field`
|
|
93
|
+
* naming the first failing path, the field-level `issues`, and the caller's
|
|
94
|
+
* `context` echoed. A tool without a declared schema passes `args` through.
|
|
95
|
+
*
|
|
96
|
+
* `options.echoContext` maps the caller's `context` before it is echoed, so
|
|
97
|
+
* a tool that bounds its echoes (the platform `comply_test_controller` caps
|
|
98
|
+
* them at 8 KiB) bounds this one too.
|
|
99
|
+
*/
|
|
100
|
+
export declare function parseDeclaredToolInput(server: McpServer, name: string, args: unknown, options?: {
|
|
101
|
+
echoContext?: (context: unknown) => unknown;
|
|
102
|
+
}): Promise<DeclaredInputParseResult>;
|
|
103
|
+
/**
|
|
104
|
+
* Finish a framework-built rejection of `name` the way its `INVALID_REQUEST`
|
|
105
|
+
* is finished: with the hosting server's finalizer, or on a server without
|
|
106
|
+
* one, by echoing the caller's `context`.
|
|
107
|
+
*/
|
|
108
|
+
export declare function finishDeclaredInputRejection(server: McpServer, name: string, response: McpToolResponse, rejection: DeclaredInputRejection): McpToolResponse;
|