@adcp/sdk 14.0.0-beta.0 → 14.0.0-beta.1
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/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/get-account-financials-request.json +610 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/get-account-financials-response.json +1055 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/list-accounts-request.json +629 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/list-accounts-response.json +1558 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/report-usage-request.json +702 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/report-usage-response.json +309 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/sync-accounts-request.json +1113 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/sync-accounts-response.json +1567 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/sync-governance-request.json +662 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/account/sync-governance-response.json +921 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/creative/list-creatives-request.json +992 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/creative/list-creatives-response.json +5965 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/creative/sync-creatives-request.json +3936 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/creative/sync-creatives-response.json +3859 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/manifest.json +206 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/accept-proposal-request.json +601 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/accept-proposal-response.json +4799 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/buy-products-request.json +4107 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/buy-products-response.json +4799 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/control-media-buy-request.json +3365 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/control-media-buy-response.json +656 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/decline-proposals-request.json +334 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/decline-proposals-response.json +271 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/get-media-buy-delivery-request.json +1236 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/get-media-buy-delivery-response.json +2861 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/get-media-buys-request.json +678 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/get-media-buys-response.json +10861 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/list-products-request.json +4229 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/list-products-response.json +3824 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/log-event-request.json +421 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/log-event-response.json +394 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/media-buy-delivery-webhook-result.json +1366 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/provide-performance-feedback-request.json +884 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/provide-performance-feedback-response.json +422 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/refine-proposals-request.json +4335 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/refine-proposals-response.json +7328 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/request-proposals-request.json +4307 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/request-proposals-response.json +7105 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/sync-audiences-request.json +760 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/sync-audiences-response.json +541 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/sync-catalogs-request.json +1142 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/sync-catalogs-response.json +1153 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/sync-event-sources-request.json +743 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/media-buy/sync-event-sources-response.json +619 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/account/get-account-financials-request.json +544 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/account/list-accounts-request.json +557 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/account/report-usage-request.json +617 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/account/sync-accounts-request.json +984 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/account/sync-governance-request.json +581 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/creative/list-creatives-request.json +878 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/creative/sync-creatives-request.json +3456 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/manifest.json +175 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/accept-proposal-request.json +498 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/buy-products-request.json +3675 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/control-media-buy-request.json +3030 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/decline-proposals-request.json +282 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/get-media-buy-delivery-request.json +1136 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/get-media-buys-request.json +597 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/list-products-request.json +3780 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/log-event-request.json +386 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/provide-performance-feedback-request.json +784 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/refine-proposals-request.json +3878 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/request-proposals-request.json +3852 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/sync-audiences-request.json +682 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/sync-catalogs-request.json +1016 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/media-buy/sync-event-sources-request.json +660 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/protocol/get-adcp-capabilities-request.json +51 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/protocol/get-task-status-request.json +534 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/protocol/list-tasks-request.json +692 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/model-context/protocol/sync-agent-notification-configs-request.json +129 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/protocol/get-adcp-capabilities-request.json +58 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/protocol/get-adcp-capabilities-response.json +8069 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/protocol/get-task-status-request.json +601 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/protocol/get-task-status-response.json +612 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/protocol/list-tasks-request.json +775 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/protocol/list-tasks-response.json +483 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/protocol/sync-agent-notification-configs-request.json +155 -0
- package/dist/lib/schemas-data/3.2.0-beta.0/mcp/2026-07-28/profiles/media-buy/protocol/sync-agent-notification-configs-response.json +382 -0
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/create-adcp-server.d.mts +27 -0
- package/dist/lib/server/create-adcp-server.d.ts +27 -0
- package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
- package/dist/lib/server/create-adcp-server.js +120 -4
- package/dist/lib/server/create-adcp-server.js.map +1 -1
- package/dist/lib/server/create-adcp-server.mjs +121 -6
- package/dist/lib/server/create-adcp-server.mjs.map +1 -1
- package/dist/lib/server/decisioning/context.d.mts +6 -0
- package/dist/lib/server/decisioning/context.d.ts +6 -0
- package/dist/lib/server/decisioning/context.d.ts.map +1 -1
- package/dist/lib/server/decisioning/context.js.map +1 -1
- package/dist/lib/server/decisioning/index.d.mts +1 -1
- package/dist/lib/server/decisioning/index.d.ts +1 -1
- package/dist/lib/server/decisioning/index.d.ts.map +1 -1
- package/dist/lib/server/decisioning/index.js.map +1 -1
- package/dist/lib/server/decisioning/index.mjs.map +1 -1
- package/dist/lib/server/decisioning/platform.d.mts +21 -6
- package/dist/lib/server/decisioning/platform.d.ts +21 -6
- package/dist/lib/server/decisioning/platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.js +201 -18
- package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +203 -19
- package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.js +6 -0
- package/dist/lib/server/decisioning/runtime/to-context.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.mjs +6 -0
- package/dist/lib/server/decisioning/runtime/to-context.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/validate-platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/validate-platform.js +35 -4
- package/dist/lib/server/decisioning/runtime/validate-platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/validate-platform.mjs +35 -4
- package/dist/lib/server/decisioning/runtime/validate-platform.mjs.map +1 -1
- package/dist/lib/server/decisioning/specialisms/sales.d.mts +39 -0
- package/dist/lib/server/decisioning/specialisms/sales.d.ts +39 -0
- package/dist/lib/server/decisioning/specialisms/sales.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/sales.js.map +1 -1
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/validation/schema-loader.d.mts +2 -0
- package/dist/lib/validation/schema-loader.d.ts +2 -0
- package/dist/lib/validation/schema-loader.d.ts.map +1 -1
- package/dist/lib/validation/schema-loader.js +31 -0
- package/dist/lib/validation/schema-loader.js.map +1 -1
- package/dist/lib/validation/schema-loader.mjs +30 -0
- package/dist/lib/validation/schema-loader.mjs.map +1 -1
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.js.map +1 -1
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/version.mjs.map +1 -1
- package/docs/guides/BUILD-AN-AGENT.md +10 -1
- package/docs/guides/MEDIA-BUY-3.2-COMPATIBILITY.md +119 -0
- package/docs/llms.txt +1 -1
- package/docs/migration-12-to-14.md +8 -0
- package/docs/migration-13-to-14.md +30 -4
- package/docs/releases/14.0.0-beta.0.md +19 -1
- package/package.json +2 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import {
|
|
4
|
-
createAdcpServer
|
|
4
|
+
createAdcpServer,
|
|
5
|
+
COMPACT_MEDIA_BUY_MUTATION_TOOLS
|
|
5
6
|
} from "../../create-adcp-server.mjs";
|
|
6
7
|
import { normalizeTargetingCapabilities } from "../capabilities.mjs";
|
|
7
8
|
import {
|
|
@@ -1025,8 +1026,8 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1025
1026
|
const som = somCandidate != null && somCandidate.length > 0 ? somCandidate : void 0;
|
|
1026
1027
|
const fc = platform.capabilities.frequency_capping;
|
|
1027
1028
|
const targeting = platform.capabilities.targeting ? normalizeTargetingCapabilities(platform.capabilities.targeting) : void 0;
|
|
1028
|
-
const hasSalesPlatform = platform.sales != null || platform.proposalManager != null;
|
|
1029
|
-
const supportsProposals = platform.capabilities.supportsProposals ?? (platform.proposalManager != null ? true : hasSalesPlatform ? false : void 0);
|
|
1029
|
+
const hasSalesPlatform = platform.sales != null || platform.mediaBuyLifecycle != null || platform.proposalManager != null;
|
|
1030
|
+
const supportsProposals = platform.capabilities.supportsProposals ?? (platform.proposalManager != null || platform.mediaBuyLifecycle?.requestProposals != null || platform.mediaBuyLifecycle?.refineProposals != null ? true : hasSalesPlatform ? false : void 0);
|
|
1030
1031
|
const hasMediaBuyProjection = hasSalesPlatform || at != null || ct != null || cs != null || som != null || fc != null || targeting != null || supportsProposals !== void 0;
|
|
1031
1032
|
const configuredAdcpVersion = opts.adcpVersion ?? ADCP_VERSION;
|
|
1032
1033
|
const configuredRelease = parseAdcpRelease(configuredAdcpVersion);
|
|
@@ -1155,6 +1156,23 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1155
1156
|
}
|
|
1156
1157
|
};
|
|
1157
1158
|
const ctxFor = makeCtxFor(effectiveCtxMetadata);
|
|
1159
|
+
const platformProposalNegotiation = buildProposalNegotiationHandlers(
|
|
1160
|
+
platform,
|
|
1161
|
+
taskRegistry,
|
|
1162
|
+
taskWebhookEmit,
|
|
1163
|
+
observability,
|
|
1164
|
+
fwLogger,
|
|
1165
|
+
{
|
|
1166
|
+
allowPrivateWebhookUrls: opts.allowPrivateWebhookUrls === true,
|
|
1167
|
+
autoEmitCompletionWebhooks: opts.autoEmitCompletionWebhooks === true
|
|
1168
|
+
},
|
|
1169
|
+
ctxFor
|
|
1170
|
+
);
|
|
1171
|
+
if (platformProposalNegotiation && opts.proposalNegotiation) {
|
|
1172
|
+
throw new PlatformConfigError(
|
|
1173
|
+
"Configure refine_proposals through platform.mediaBuyLifecycle or opts.proposalNegotiation, not both"
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1158
1176
|
if (opts.resolveIdempotencyPrincipal === void 0) {
|
|
1159
1177
|
const env = process.env.NODE_ENV;
|
|
1160
1178
|
const inDevAllowlist = env === "test" || env === "development";
|
|
@@ -1167,6 +1185,7 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1167
1185
|
}
|
|
1168
1186
|
const config = {
|
|
1169
1187
|
...opts,
|
|
1188
|
+
requireCompactMutationAccountScope: true,
|
|
1170
1189
|
taskRegistry,
|
|
1171
1190
|
...autoSeedStore != null && { testController: makeAutoSeedBridge(autoSeedStore) },
|
|
1172
1191
|
...projectedCapabilitiesConfig != null && { capabilities: projectedCapabilitiesConfig },
|
|
@@ -1190,17 +1209,14 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1190
1209
|
// Pool-derived stores override the spread above when adopters supplied
|
|
1191
1210
|
// `pool` but no explicit per-store opt. Explicit values still win.
|
|
1192
1211
|
...effectiveIdempotency !== void 0 && { idempotency: effectiveIdempotency },
|
|
1193
|
-
//
|
|
1194
|
-
//
|
|
1195
|
-
//
|
|
1196
|
-
//
|
|
1197
|
-
//
|
|
1198
|
-
//
|
|
1199
|
-
//
|
|
1200
|
-
|
|
1201
|
-
// explicit values winning. Closed by the Emma matrix surfacing
|
|
1202
|
-
// SERVICE_UNAVAILABLE on every v6 mutating call.
|
|
1203
|
-
resolveIdempotencyPrincipal: opts.resolveIdempotencyPrincipal ?? ((ctx) => ctx.authInfo?.clientId ?? ctx.sessionKey ?? ctx.account?.id ?? void 0),
|
|
1212
|
+
// Preserve the SDK 13 principal namespace for established tools so a
|
|
1213
|
+
// retry spanning a rolling 13→14 deployment still finds its durable
|
|
1214
|
+
// idempotency entry. The new compact lifecycle uses credential-kind
|
|
1215
|
+
// namespacing and refuses session/account fallbacks, preventing
|
|
1216
|
+
// cross-credential collisions without reopening a duplicate-buy window
|
|
1217
|
+
// on create_media_buy/update_media_buy. Explicit adopter resolvers still
|
|
1218
|
+
// win for every tool.
|
|
1219
|
+
resolveIdempotencyPrincipal: opts.resolveIdempotencyPrincipal ?? ((ctx, _params, toolName) => COMPACT_MEDIA_BUY_MUTATION_TOOLS.has(toolName) ? authenticatedPrincipalFor(ctx) : ctx.authInfo?.clientId ?? ctx.sessionKey ?? ctx.account?.id ?? void 0),
|
|
1204
1220
|
resolveAccount: async (ref, ctx) => {
|
|
1205
1221
|
const start = Date.now();
|
|
1206
1222
|
let resolved = false;
|
|
@@ -1302,6 +1318,7 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1302
1318
|
mergeOpts,
|
|
1303
1319
|
defaultCreativeWireMode
|
|
1304
1320
|
),
|
|
1321
|
+
proposalNegotiation: platformProposalNegotiation ?? opts.proposalNegotiation,
|
|
1305
1322
|
creative: mergeHandlers(
|
|
1306
1323
|
legacyHandlers.creative,
|
|
1307
1324
|
buildCreativeHandlers(
|
|
@@ -2101,6 +2118,17 @@ function taskOwnerScopeFor(ctx, accountId) {
|
|
|
2101
2118
|
}
|
|
2102
2119
|
return `account:${accountId}`;
|
|
2103
2120
|
}
|
|
2121
|
+
function authenticatedPrincipalFor(ctx) {
|
|
2122
|
+
if (ctx.agent?.agent_url) return `agent:${ctx.agent.agent_url}`;
|
|
2123
|
+
const credential = ctx.authInfo?.credential;
|
|
2124
|
+
if (credential?.kind === "http_sig") return `http_sig:${credential.agent_url}`;
|
|
2125
|
+
if (credential?.kind === "oauth") return `oauth:${credential.client_id}`;
|
|
2126
|
+
if (credential?.kind === "api_key") return `api_key:${credential.key_id}`;
|
|
2127
|
+
if (typeof ctx.authInfo?.clientId === "string" && ctx.authInfo.clientId.length > 0) {
|
|
2128
|
+
return `client:${ctx.authInfo.clientId}`;
|
|
2129
|
+
}
|
|
2130
|
+
return void 0;
|
|
2131
|
+
}
|
|
2104
2132
|
function hasPushNotificationConfig(params) {
|
|
2105
2133
|
return params != null && typeof params === "object" && params.push_notification_config !== void 0;
|
|
2106
2134
|
}
|
|
@@ -2763,11 +2791,167 @@ function validatePushNotificationOperationId(operationId) {
|
|
|
2763
2791
|
}
|
|
2764
2792
|
return { ok: true };
|
|
2765
2793
|
}
|
|
2794
|
+
function buildProposalNegotiationHandlers(platform, taskRegistry, taskWebhookEmit, observability, logger, pushOpts, ctxFor) {
|
|
2795
|
+
const lifecycle = platform.mediaBuyLifecycle;
|
|
2796
|
+
if (!lifecycle?.refineProposals) return void 0;
|
|
2797
|
+
if (!lifecycle.proposalRefinement) {
|
|
2798
|
+
throw new PlatformConfigError(
|
|
2799
|
+
"mediaBuyLifecycle.refineProposals requires mediaBuyLifecycle.proposalRefinement capability metadata"
|
|
2800
|
+
);
|
|
2801
|
+
}
|
|
2802
|
+
return {
|
|
2803
|
+
capabilities: lifecycle.proposalRefinement,
|
|
2804
|
+
resolveScope: (ctx) => {
|
|
2805
|
+
const accountId = ctx.account?.id;
|
|
2806
|
+
if (!accountId) {
|
|
2807
|
+
throw new AdcpError("ACCOUNT_NOT_FOUND", {
|
|
2808
|
+
message: "refine_proposals requires an authenticated account scope",
|
|
2809
|
+
recovery: "correctable"
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
const principalId = authenticatedPrincipalFor(ctx);
|
|
2813
|
+
if (!principalId) {
|
|
2814
|
+
throw new AdcpError("AUTH_REQUIRED", {
|
|
2815
|
+
message: "refine_proposals requires an authenticated buyer principal",
|
|
2816
|
+
recovery: "correctable"
|
|
2817
|
+
});
|
|
2818
|
+
}
|
|
2819
|
+
return { tenant_id: accountId, account_id: accountId, principal_id: principalId };
|
|
2820
|
+
},
|
|
2821
|
+
refineProposals: async (params, ctx) => {
|
|
2822
|
+
const request = params;
|
|
2823
|
+
const reqCtx = ctxFor(ctx, request);
|
|
2824
|
+
if (!reqCtx.account?.id) {
|
|
2825
|
+
throw new AdcpError("ACCOUNT_NOT_FOUND", {
|
|
2826
|
+
message: "refine_proposals requires an authenticated account scope",
|
|
2827
|
+
recovery: "correctable"
|
|
2828
|
+
});
|
|
2829
|
+
}
|
|
2830
|
+
return projectSync(
|
|
2831
|
+
async () => {
|
|
2832
|
+
const push = extractPushConfig(request, logger, {
|
|
2833
|
+
allowPrivateWebhookUrls: pushOpts.allowPrivateWebhookUrls
|
|
2834
|
+
});
|
|
2835
|
+
const result = await lifecycle.refineProposals(params, reqCtx);
|
|
2836
|
+
return routeIfHandoff(
|
|
2837
|
+
taskRegistry,
|
|
2838
|
+
{
|
|
2839
|
+
tool: "refine_proposals",
|
|
2840
|
+
accountId: reqCtx.account.id,
|
|
2841
|
+
ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
|
|
2842
|
+
pushNotificationUrl: push.url,
|
|
2843
|
+
pushNotificationToken: push.token,
|
|
2844
|
+
pushNotificationOperationId: push.operationId,
|
|
2845
|
+
emitWebhook: taskWebhookEmit ?? ctx.emitWebhook,
|
|
2846
|
+
autoEmitCompletion: pushOpts.autoEmitCompletionWebhooks,
|
|
2847
|
+
observability,
|
|
2848
|
+
logger
|
|
2849
|
+
},
|
|
2850
|
+
result,
|
|
2851
|
+
(value) => value
|
|
2852
|
+
);
|
|
2853
|
+
},
|
|
2854
|
+
(value) => value
|
|
2855
|
+
);
|
|
2856
|
+
}
|
|
2857
|
+
};
|
|
2858
|
+
}
|
|
2766
2859
|
function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observability, logger, pushOpts, ctxFor, ctxMetadataStore, mediaBuyStore, proposalStore, legacyFormatConverter, canonicalFormatLegacyResolver, creativeWireMode) {
|
|
2767
2860
|
const sales = platform.sales;
|
|
2861
|
+
const lifecycle = platform.mediaBuyLifecycle;
|
|
2862
|
+
const getMediaBuyDelivery = lifecycle?.getMediaBuyDelivery ?? sales?.getMediaBuyDelivery;
|
|
2863
|
+
const getMediaBuys = lifecycle?.getMediaBuys ?? sales?.getMediaBuys;
|
|
2768
2864
|
const proposalManager = platform.proposalManager;
|
|
2769
|
-
if (!sales && !proposalManager) return void 0;
|
|
2865
|
+
if (!sales && !lifecycle && !proposalManager) return void 0;
|
|
2866
|
+
const dispatchCompactMutation = async (tool, params, ctx, invoke) => {
|
|
2867
|
+
return projectSync(
|
|
2868
|
+
async () => {
|
|
2869
|
+
if (ctx.authInfo === void 0 && ctx.agent === void 0) {
|
|
2870
|
+
throw new AdcpError("AUTH_MISSING", {
|
|
2871
|
+
message: `${tool} requires an authenticated buyer principal`,
|
|
2872
|
+
recovery: "correctable"
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
const accountId = ctx.account?.id;
|
|
2876
|
+
if (!accountId) {
|
|
2877
|
+
throw new AdcpError("ACCOUNT_NOT_FOUND", {
|
|
2878
|
+
message: `${tool} requires a resolved account scope`,
|
|
2879
|
+
recovery: "correctable"
|
|
2880
|
+
});
|
|
2881
|
+
}
|
|
2882
|
+
const principalId = authenticatedPrincipalFor(ctx);
|
|
2883
|
+
if (!principalId) {
|
|
2884
|
+
throw new AdcpError("AUTH_MISSING", {
|
|
2885
|
+
message: `${tool} requires an authenticated buyer principal`,
|
|
2886
|
+
recovery: "correctable"
|
|
2887
|
+
});
|
|
2888
|
+
}
|
|
2889
|
+
const callerMutationScope = Object.freeze({
|
|
2890
|
+
tenant_id: accountId,
|
|
2891
|
+
account_id: accountId,
|
|
2892
|
+
principal_id: principalId
|
|
2893
|
+
});
|
|
2894
|
+
const reqCtx = ctxFor({ ...ctx, callerMutationScope }, params);
|
|
2895
|
+
const push = extractPushConfig(params, logger, {
|
|
2896
|
+
allowPrivateWebhookUrls: pushOpts.allowPrivateWebhookUrls
|
|
2897
|
+
});
|
|
2898
|
+
const result = await invoke(reqCtx);
|
|
2899
|
+
return routeIfHandoff(
|
|
2900
|
+
taskRegistry,
|
|
2901
|
+
{
|
|
2902
|
+
tool,
|
|
2903
|
+
accountId,
|
|
2904
|
+
ownerScope: taskOwnerScopeFor(ctx, accountId),
|
|
2905
|
+
pushNotificationUrl: push.url,
|
|
2906
|
+
pushNotificationToken: push.token,
|
|
2907
|
+
pushNotificationOperationId: push.operationId,
|
|
2908
|
+
emitWebhook: taskWebhookEmit ?? ctx.emitWebhook,
|
|
2909
|
+
autoEmitCompletion: pushOpts.autoEmitCompletionWebhooks,
|
|
2910
|
+
observability,
|
|
2911
|
+
logger
|
|
2912
|
+
},
|
|
2913
|
+
result,
|
|
2914
|
+
(value) => value
|
|
2915
|
+
);
|
|
2916
|
+
},
|
|
2917
|
+
(value) => value
|
|
2918
|
+
);
|
|
2919
|
+
};
|
|
2770
2920
|
return {
|
|
2921
|
+
...lifecycle?.listProducts && {
|
|
2922
|
+
listProducts: async (...[params, ctx]) => {
|
|
2923
|
+
const reqCtx = ctxFor(ctx, params);
|
|
2924
|
+
return projectSync(
|
|
2925
|
+
() => lifecycle.listProducts(params, reqCtx),
|
|
2926
|
+
(value) => value
|
|
2927
|
+
);
|
|
2928
|
+
}
|
|
2929
|
+
},
|
|
2930
|
+
...lifecycle?.requestProposals && {
|
|
2931
|
+
requestProposals: async (...[params, ctx]) => dispatchCompactMutation(
|
|
2932
|
+
"request_proposals",
|
|
2933
|
+
params,
|
|
2934
|
+
ctx,
|
|
2935
|
+
(reqCtx) => lifecycle.requestProposals(params, reqCtx)
|
|
2936
|
+
)
|
|
2937
|
+
},
|
|
2938
|
+
...lifecycle?.declineProposals && {
|
|
2939
|
+
declineProposals: async (...[params, ctx]) => dispatchCompactMutation(
|
|
2940
|
+
"decline_proposals",
|
|
2941
|
+
params,
|
|
2942
|
+
ctx,
|
|
2943
|
+
(reqCtx) => lifecycle.declineProposals(params, reqCtx)
|
|
2944
|
+
)
|
|
2945
|
+
},
|
|
2946
|
+
...lifecycle?.buyProducts && {
|
|
2947
|
+
buyProducts: async (...[params, ctx]) => dispatchCompactMutation("buy_products", params, ctx, (reqCtx) => lifecycle.buyProducts(params, reqCtx))
|
|
2948
|
+
},
|
|
2949
|
+
...lifecycle?.acceptProposal && {
|
|
2950
|
+
acceptProposal: async (...[params, ctx]) => dispatchCompactMutation("accept_proposal", params, ctx, (reqCtx) => lifecycle.acceptProposal(params, reqCtx))
|
|
2951
|
+
},
|
|
2952
|
+
...lifecycle?.controlMediaBuy && {
|
|
2953
|
+
controlMediaBuy: async (...[params, ctx]) => dispatchCompactMutation("control_media_buy", params, ctx, (reqCtx) => lifecycle.controlMediaBuy(params, reqCtx))
|
|
2954
|
+
},
|
|
2771
2955
|
...(sales?.getProducts || proposalManager) && {
|
|
2772
2956
|
getProducts: async (...[params, ctx]) => {
|
|
2773
2957
|
const responseWireMode = creativeWireModeForRequest(
|
|
@@ -3115,7 +3299,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
|
|
|
3115
3299
|
);
|
|
3116
3300
|
}
|
|
3117
3301
|
},
|
|
3118
|
-
...
|
|
3302
|
+
...getMediaBuyDelivery && {
|
|
3119
3303
|
getMediaBuyDelivery: async (...[params, ctx]) => {
|
|
3120
3304
|
const responseWireMode = creativeWireModeForRequest(ctx, creativeWireMode, params);
|
|
3121
3305
|
const reqCtx = ctxFor(ctx, params);
|
|
@@ -3135,7 +3319,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
|
|
|
3135
3319
|
}
|
|
3136
3320
|
return projectSync(
|
|
3137
3321
|
async () => {
|
|
3138
|
-
const result = await
|
|
3322
|
+
const result = await getMediaBuyDelivery(asValidatedDomainRequest(params), reqCtx);
|
|
3139
3323
|
warnIfTruncatedMultiIdResponse(
|
|
3140
3324
|
"getMediaBuyDelivery",
|
|
3141
3325
|
"media_buy_ids",
|
|
@@ -3168,13 +3352,13 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
|
|
|
3168
3352
|
// platform-derived handler when absent lets `mergeHandlers` pick up the
|
|
3169
3353
|
// adopter's custom handler from `opts.legacyHandlers.mediaBuy` instead of throwing
|
|
3170
3354
|
// `sales.getMediaBuys is not a function`.
|
|
3171
|
-
...
|
|
3355
|
+
...getMediaBuys && {
|
|
3172
3356
|
getMediaBuys: async (...[params, ctx]) => {
|
|
3173
3357
|
const responseWireMode = creativeWireModeForRequest(ctx, creativeWireMode, params);
|
|
3174
3358
|
const reqCtx = ctxFor(ctx, params);
|
|
3175
3359
|
return projectSync(
|
|
3176
3360
|
async () => {
|
|
3177
|
-
const result = await
|
|
3361
|
+
const result = await getMediaBuys(asValidatedDomainRequest(params), reqCtx);
|
|
3178
3362
|
warnIfTruncatedMultiIdResponse(
|
|
3179
3363
|
"getMediaBuys",
|
|
3180
3364
|
"media_buy_ids",
|