@adcp/sdk 14.0.0-rc.50 → 14.0.0-rc.51

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.
Files changed (56) hide show
  1. package/dist/lib/client/core.d.mts +1 -0
  2. package/dist/lib/client/core.d.ts +1 -0
  3. package/dist/lib/core/AgentClient.d.mts +4 -1
  4. package/dist/lib/core/AgentClient.d.ts +4 -1
  5. package/dist/lib/core/AgentClient.js +8 -0
  6. package/dist/lib/core/AgentClient.mjs +8 -0
  7. package/dist/lib/core/SingleAgentClient.d.mts +10 -1
  8. package/dist/lib/core/SingleAgentClient.d.ts +10 -1
  9. package/dist/lib/core/SingleAgentClient.js +238 -34
  10. package/dist/lib/core/SingleAgentClient.mjs +240 -35
  11. package/dist/lib/core/TaskExecutor.js +1 -1
  12. package/dist/lib/core/TaskExecutor.mjs +1 -1
  13. package/dist/lib/core/account-resolution.d.mts +24 -0
  14. package/dist/lib/core/account-resolution.d.ts +24 -0
  15. package/dist/lib/core/account-resolution.js +79 -0
  16. package/dist/lib/core/account-resolution.mjs +54 -0
  17. package/dist/lib/errors/index.d.mts +27 -0
  18. package/dist/lib/errors/index.d.ts +27 -0
  19. package/dist/lib/errors/index.js +56 -0
  20. package/dist/lib/errors/index.mjs +52 -0
  21. package/dist/lib/index.d.mts +4 -3
  22. package/dist/lib/index.d.ts +4 -3
  23. package/dist/lib/index.js +10 -0
  24. package/dist/lib/index.mjs +10 -0
  25. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  26. package/dist/lib/testing/scenarios/media-buy.d.mts +2 -1
  27. package/dist/lib/testing/scenarios/media-buy.d.ts +2 -1
  28. package/dist/lib/testing/scenarios/media-buy.js +31 -3
  29. package/dist/lib/testing/scenarios/media-buy.mjs +31 -3
  30. package/dist/lib/testing/storyboard/runner.d.mts +2 -1
  31. package/dist/lib/testing/storyboard/runner.d.ts +2 -1
  32. package/dist/lib/testing/storyboard/runner.js +144 -15
  33. package/dist/lib/testing/storyboard/runner.mjs +146 -16
  34. package/dist/lib/testing/storyboard/task-map.d.mts +1 -0
  35. package/dist/lib/testing/storyboard/task-map.d.ts +1 -0
  36. package/dist/lib/testing/storyboard/task-map.js +8 -2
  37. package/dist/lib/testing/storyboard/task-map.mjs +8 -2
  38. package/dist/lib/testing/storyboard/types.d.mts +10 -3
  39. package/dist/lib/testing/storyboard/types.d.ts +10 -3
  40. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  41. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  42. package/dist/lib/utils/capabilities.d.mts +13 -0
  43. package/dist/lib/utils/capabilities.d.ts +13 -0
  44. package/dist/lib/utils/capabilities.js +17 -0
  45. package/dist/lib/utils/capabilities.mjs +16 -0
  46. package/dist/lib/utils/request-normalizer.js +1 -1
  47. package/dist/lib/utils/request-normalizer.mjs +1 -1
  48. package/dist/lib/version.d.mts +3 -3
  49. package/dist/lib/version.d.ts +3 -3
  50. package/dist/lib/version.js +3 -3
  51. package/dist/lib/version.mjs +3 -3
  52. package/docs/TYPE-SUMMARY.md +1 -1
  53. package/docs/guides/BUYER-QUICKSTART-3.2.md +28 -1
  54. package/docs/llms.txt +1 -1
  55. package/docs/migration-14.x-rc-worksheet.md +4 -4
  56. package/package.json +1 -1
@@ -6,3 +6,4 @@ export { ConfigurationManager } from '../core/ConfigurationManager.mjs';
6
6
  export { InMemoryWebhookRegistrationStore, type InMemoryWebhookRegistrationStoreOptions, type WebhookAuthenticationMode, type WebhookRegistration, type WebhookRegistrationStore, } from '../core/webhook-registration.mjs';
7
7
  export type { ConversationConfig, ConversationContext, InputHandler, InputHandlerResponse, InputRequest, Message, TaskInfo, TaskOptions, TaskResult, TaskResultCompleted, TaskResultFailure, TaskResultIntermediate, TaskResultMetadata, } from '../core/ConversationTypes.mjs';
8
8
  export type { AgentConfig } from '../types/adcp.mjs';
9
+ export type { ResolveAccountOptions, ListedAccount } from '../core/account-resolution.mjs';
@@ -6,3 +6,4 @@ export { ConfigurationManager } from '../core/ConfigurationManager';
6
6
  export { InMemoryWebhookRegistrationStore, type InMemoryWebhookRegistrationStoreOptions, type WebhookAuthenticationMode, type WebhookRegistration, type WebhookRegistrationStore, } from '../core/webhook-registration';
7
7
  export type { ConversationConfig, ConversationContext, InputHandler, InputHandlerResponse, InputRequest, Message, TaskInfo, TaskOptions, TaskResult, TaskResultCompleted, TaskResultFailure, TaskResultIntermediate, TaskResultMetadata, } from '../core/ConversationTypes';
8
8
  export type { AgentConfig } from '../types/adcp';
9
+ export type { ResolveAccountOptions, ListedAccount } from '../core/account-resolution';
@@ -1,5 +1,6 @@
1
1
  import type { Client as MCPClient } from '@modelcontextprotocol/sdk/client/index.js';
2
- import type { AgentConfig } from '../types/index.mjs';
2
+ import type { AccountReference, AgentConfig } from '../types/index.mjs';
3
+ import type { ResolveAccountOptions } from './account-resolution.mjs';
3
4
  import type { MCPWebhookPayload, GetBrandIdentityRequest, GetBrandIdentityResponse, ContextMatchRequest, ContextMatchResponse, IdentityMatchRequest, IdentityMatchResponseRouterPublisher } from '../types/core.generated.mjs';
4
5
  import type { Task as A2ATask, TaskStatusUpdateEvent } from '@a2a-js/sdk';
5
6
  import { type CapabilityEvidenceScope, type CapabilityEvidenceSnapshot, type CanonicalReadTaskOptions, type CreativeDeliveryTaskOptions, type SingleAgentClientConfig, type SyncCreativesTaskOptions, type VerifyAndParseWebhookOptions, type WebhookHandlerAdapter, type WebhookParseResult, type WebhookRequestContext } from './SingleAgentClient.mjs';
@@ -565,6 +566,8 @@ export declare class AgentClient {
565
566
  * List accounts
566
567
  */
567
568
  listAccounts(params: ListAccountsRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ListAccountsResponse>>;
569
+ /** Resolve the seller's account contract into a reusable wire account reference. */
570
+ resolveAccount(hints?: ResolveAccountOptions, options?: TaskOptions): Promise<AccountReference>;
568
571
  /**
569
572
  * Sync accounts
570
573
  */
@@ -1,5 +1,6 @@
1
1
  import type { Client as MCPClient } from '@modelcontextprotocol/sdk/client/index.js';
2
- import type { AgentConfig } from '../types';
2
+ import type { AccountReference, AgentConfig } from '../types';
3
+ import type { ResolveAccountOptions } from './account-resolution';
3
4
  import type { MCPWebhookPayload, GetBrandIdentityRequest, GetBrandIdentityResponse, ContextMatchRequest, ContextMatchResponse, IdentityMatchRequest, IdentityMatchResponseRouterPublisher } from '../types/core.generated';
4
5
  import type { Task as A2ATask, TaskStatusUpdateEvent } from '@a2a-js/sdk';
5
6
  import { type CapabilityEvidenceScope, type CapabilityEvidenceSnapshot, type CanonicalReadTaskOptions, type CreativeDeliveryTaskOptions, type SingleAgentClientConfig, type SyncCreativesTaskOptions, type VerifyAndParseWebhookOptions, type WebhookHandlerAdapter, type WebhookParseResult, type WebhookRequestContext } from './SingleAgentClient';
@@ -565,6 +566,8 @@ export declare class AgentClient {
565
566
  * List accounts
566
567
  */
567
568
  listAccounts(params: ListAccountsRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ListAccountsResponse>>;
569
+ /** Resolve the seller's account contract into a reusable wire account reference. */
570
+ resolveAccount(hints?: ResolveAccountOptions, options?: TaskOptions): Promise<AccountReference>;
568
571
  /**
569
572
  * Sync accounts
570
573
  */
@@ -863,6 +863,14 @@ class AgentClient {
863
863
  this.retainSession(result);
864
864
  return result;
865
865
  }
866
+ /** Resolve the seller's account contract into a reusable wire account reference. */
867
+ async resolveAccount(hints = {}, options) {
868
+ return this.client.resolveAccount(
869
+ hints,
870
+ this.withSession("resolve_account", options),
871
+ (result) => this.retainSession(result)
872
+ );
873
+ }
866
874
  /**
867
875
  * Sync accounts
868
876
  */
@@ -831,6 +831,14 @@ class AgentClient {
831
831
  this.retainSession(result);
832
832
  return result;
833
833
  }
834
+ /** Resolve the seller's account contract into a reusable wire account reference. */
835
+ async resolveAccount(hints = {}, options) {
836
+ return this.client.resolveAccount(
837
+ hints,
838
+ this.withSession("resolve_account", options),
839
+ (result) => this.retainSession(result)
840
+ );
841
+ }
834
842
  /**
835
843
  * Sync accounts
836
844
  */
@@ -1,5 +1,5 @@
1
1
  import { type ListProductsResponseWithSupplyPath, type ProductSupplyPathOptions } from '../supply-path/products.mjs';
2
- import type { AgentConfig } from '../types/index.mjs';
2
+ import type { AccountReference, AgentConfig } from '../types/index.mjs';
3
3
  import { type AdcpVersion } from '../version.mjs';
4
4
  import type { GetProductsRequest, GetProductsResponse, ListProductsRequest, ListCreativeFormatsRequest, ListCreativeFormatsResponse, ListTransformersRequest, ListTransformersResponse, CreateMediaBuyRequest, CreateMediaBuyResponse, UpdateMediaBuyRequest, UpdateMediaBuyResponse, SyncCreativesRequest, SyncCreativesResponse, ListCreativesRequest, ListCreativesResponse, GetMediaBuysRequest, GetMediaBuysResponse, GetMediaBuyDeliveryRequest, GetMediaBuyDeliveryResponse, GetCreativeDeliveryRequest, GetCreativeDeliveryResponse, ProvidePerformanceFeedbackRequest, ProvidePerformanceFeedbackResponse, GetSignalsRequest, GetSignalsResponse, ActivateSignalRequest, ActivateSignalResponse, PreviewCreativeRequest, PreviewCreativeResponse, BuildCreativeRequest, BuildCreativeResponse, Format, GetAdCPCapabilitiesRequest, GetAdCPCapabilitiesResponse, ListAccountChangesRequest, ListAccountChangesResponse, ListAccountsRequest, ListAccountsResponse, SyncAccountsRequest, SyncAccountsResponse, SyncAudiencesRequest, SyncAudiencesResponse, CreatePropertyListRequest, CreatePropertyListResponse, GetPropertyListRequest, GetPropertyListResponse, UpdatePropertyListRequest, UpdatePropertyListResponse, ListPropertyListsRequest, ListPropertyListsResponse, DeletePropertyListRequest, DeletePropertyListResponse, ListContentStandardsRequest, ListContentStandardsResponse, GetContentStandardsRequest, GetContentStandardsResponse, CalibrateContentRequest, CalibrateContentResponse, ValidateContentDeliveryRequest, ValidateContentDeliveryResponse, SIGetOfferingRequest, SIGetOfferingResponse, SIInitiateSessionRequest, SIInitiateSessionResponse, SISendMessageRequest, SISendMessageResponse, SITerminateSessionRequest, SITerminateSessionResponse, SyncPlansRequest, SyncPlansResponse, GetPlanAuditLogsRequest, GetPlanAuditLogsResponse, GetPrincipalRequest, GetPrincipalResponse, SyncPrincipalRequest, SyncPrincipalResponse, OutcomeType } from '../types/tools.generated.mjs';
5
5
  import { type MutatingRequestInput } from '../utils/idempotency.mjs';
@@ -14,6 +14,7 @@ import { type WebhookHeaderValue, type WebhookHeadersLike } from '../webhooks/in
14
14
  import { type WebhookRegistrationStore } from './webhook-registration.mjs';
15
15
  import { type ReplayStore, type RevocationStore, type JwksResolver, type WebhookSignatureErrorCode, type ResolvedAgentJwksResolverOptions } from '../signing/server.mjs';
16
16
  import type { AdcpCapabilities, FeatureName } from '../utils/capabilities.mjs';
17
+ import { type ResolveAccountOptions } from './account-resolution.mjs';
17
18
  import { type BuyerPropertyPolicy, type ProductPropertyPolicyMode } from '../media-buy/property-policy.mjs';
18
19
  import { type ResolveListOptions } from '../server/targeting-helpers.mjs';
19
20
  import { type CanonicalCreateMediaBuyInput, type CanonicalCreativeResponse, type CanonicalGetProductsRequest, type CanonicalGetProductsResponse, type CanonicalListCreativesRequest, type CanonicalListCreativesResponse, type CanonicalPreviewCreativeRequest, type CanonicalPreviewCreativeResponse, type CanonicalSyncCreativesRequest, type CanonicalUpdateMediaBuyRequest, type SyncCreativeFormatProjection } from '../v2/projection/creative-delivery.mjs';
@@ -1019,6 +1020,14 @@ export declare class SingleAgentClient {
1019
1020
  * List accounts
1020
1021
  */
1021
1022
  listAccounts(params: ListAccountsRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ListAccountsResponse>>;
1023
+ /**
1024
+ * Resolve an account for the authenticated caller. Explicit-account sellers
1025
+ * are discovered with list_accounts; implicit-account sellers are registered
1026
+ * with sync_accounts and addressed by their natural key.
1027
+ */
1028
+ resolveAccount(hints?: ResolveAccountOptions, options?: TaskOptions,
1029
+ /** @internal Allows the AgentClient wrapper to retain nested task session ids. */
1030
+ onTaskResult?: (result: TaskResult<unknown>) => void): Promise<AccountReference>;
1022
1031
  /**
1023
1032
  * Sync accounts
1024
1033
  */
@@ -1,5 +1,5 @@
1
1
  import { type ListProductsResponseWithSupplyPath, type ProductSupplyPathOptions } from '../supply-path/products';
2
- import type { AgentConfig } from '../types';
2
+ import type { AccountReference, AgentConfig } from '../types';
3
3
  import { type AdcpVersion } from '../version';
4
4
  import type { GetProductsRequest, GetProductsResponse, ListProductsRequest, ListCreativeFormatsRequest, ListCreativeFormatsResponse, ListTransformersRequest, ListTransformersResponse, CreateMediaBuyRequest, CreateMediaBuyResponse, UpdateMediaBuyRequest, UpdateMediaBuyResponse, SyncCreativesRequest, SyncCreativesResponse, ListCreativesRequest, ListCreativesResponse, GetMediaBuysRequest, GetMediaBuysResponse, GetMediaBuyDeliveryRequest, GetMediaBuyDeliveryResponse, GetCreativeDeliveryRequest, GetCreativeDeliveryResponse, ProvidePerformanceFeedbackRequest, ProvidePerformanceFeedbackResponse, GetSignalsRequest, GetSignalsResponse, ActivateSignalRequest, ActivateSignalResponse, PreviewCreativeRequest, PreviewCreativeResponse, BuildCreativeRequest, BuildCreativeResponse, Format, GetAdCPCapabilitiesRequest, GetAdCPCapabilitiesResponse, ListAccountChangesRequest, ListAccountChangesResponse, ListAccountsRequest, ListAccountsResponse, SyncAccountsRequest, SyncAccountsResponse, SyncAudiencesRequest, SyncAudiencesResponse, CreatePropertyListRequest, CreatePropertyListResponse, GetPropertyListRequest, GetPropertyListResponse, UpdatePropertyListRequest, UpdatePropertyListResponse, ListPropertyListsRequest, ListPropertyListsResponse, DeletePropertyListRequest, DeletePropertyListResponse, ListContentStandardsRequest, ListContentStandardsResponse, GetContentStandardsRequest, GetContentStandardsResponse, CalibrateContentRequest, CalibrateContentResponse, ValidateContentDeliveryRequest, ValidateContentDeliveryResponse, SIGetOfferingRequest, SIGetOfferingResponse, SIInitiateSessionRequest, SIInitiateSessionResponse, SISendMessageRequest, SISendMessageResponse, SITerminateSessionRequest, SITerminateSessionResponse, SyncPlansRequest, SyncPlansResponse, GetPlanAuditLogsRequest, GetPlanAuditLogsResponse, GetPrincipalRequest, GetPrincipalResponse, SyncPrincipalRequest, SyncPrincipalResponse, OutcomeType } from '../types/tools.generated';
5
5
  import { type MutatingRequestInput } from '../utils/idempotency';
@@ -14,6 +14,7 @@ import { type WebhookHeaderValue, type WebhookHeadersLike } from '../webhooks';
14
14
  import { type WebhookRegistrationStore } from './webhook-registration';
15
15
  import { type ReplayStore, type RevocationStore, type JwksResolver, type WebhookSignatureErrorCode, type ResolvedAgentJwksResolverOptions } from '../signing/server';
16
16
  import type { AdcpCapabilities, FeatureName } from '../utils/capabilities';
17
+ import { type ResolveAccountOptions } from './account-resolution';
17
18
  import { type BuyerPropertyPolicy, type ProductPropertyPolicyMode } from '../media-buy/property-policy';
18
19
  import { type ResolveListOptions } from '../server/targeting-helpers';
19
20
  import { type CanonicalCreateMediaBuyInput, type CanonicalCreativeResponse, type CanonicalGetProductsRequest, type CanonicalGetProductsResponse, type CanonicalListCreativesRequest, type CanonicalListCreativesResponse, type CanonicalPreviewCreativeRequest, type CanonicalPreviewCreativeResponse, type CanonicalSyncCreativesRequest, type CanonicalUpdateMediaBuyRequest, type SyncCreativeFormatProjection } from '../v2/projection/creative-delivery';
@@ -1019,6 +1020,14 @@ export declare class SingleAgentClient {
1019
1020
  * List accounts
1020
1021
  */
1021
1022
  listAccounts(params: ListAccountsRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ListAccountsResponse>>;
1023
+ /**
1024
+ * Resolve an account for the authenticated caller. Explicit-account sellers
1025
+ * are discovered with list_accounts; implicit-account sellers are registered
1026
+ * with sync_accounts and addressed by their natural key.
1027
+ */
1028
+ resolveAccount(hints?: ResolveAccountOptions, options?: TaskOptions,
1029
+ /** @internal Allows the AgentClient wrapper to retain nested task session ids. */
1030
+ onTaskResult?: (result: TaskResult<unknown>) => void): Promise<AccountReference>;
1022
1031
  /**
1023
1032
  * Sync accounts
1024
1033
  */
@@ -68,6 +68,8 @@ var import_a2a_discovery = require('../utils/a2a-discovery.js');
68
68
  var crypto = __toESM(require("crypto"));
69
69
  var import_abort2 = require('../protocols/abort.js');
70
70
  var import_capabilities = require('../utils/capabilities.js');
71
+ var import_errors3 = require('../errors/index.js');
72
+ var import_account_resolution = require('./account-resolution.js');
71
73
  var import_request_normalizer = require('../utils/request-normalizer.js');
72
74
  var import_global_async_local_storage = require('../utils/global-async-local-storage.js');
73
75
  var import_validate_user_agent = require('../utils/validate-user-agent.js');
@@ -249,12 +251,18 @@ function canonicalAccountRoutingSnapshot(value) {
249
251
  if (typeof sourceBrand.domain !== "string") return void 0;
250
252
  const brand = Object.freeze({
251
253
  domain: sourceBrand.domain,
252
- ...typeof sourceBrand.brand_id === "string" ? { brand_id: sourceBrand.brand_id } : {}
254
+ ...typeof sourceBrand.brand_id === "string" ? { brand_id: sourceBrand.brand_id } : {},
255
+ ...Array.isArray(sourceBrand.countries) && sourceBrand.countries.every((country) => typeof country === "string") ? { countries: Object.freeze([...sourceBrand.countries].sort()) } : {}
253
256
  });
257
+ const operatorUnit = account.operator_unit;
258
+ const unitId = operatorUnit && typeof operatorUnit === "object" && !Array.isArray(operatorUnit) ? operatorUnit.id : void 0;
254
259
  return Object.freeze({
255
260
  brand,
256
261
  operator: account.operator,
257
- ...typeof account.sandbox === "boolean" ? { sandbox: account.sandbox } : {}
262
+ ...typeof unitId === "string" ? { operator_unit: Object.freeze({ id: unitId }) } : {},
263
+ ...typeof account.currency === "string" ? { currency: account.currency } : {},
264
+ ...typeof account.timezone === "string" ? { timezone: account.timezone } : {},
265
+ sandbox: account.sandbox === true
258
266
  });
259
267
  }
260
268
  function canonicalOptionRefRoutingSnapshot(value) {
@@ -514,6 +522,13 @@ function snapshotTaskOptions(options) {
514
522
  }
515
523
  };
516
524
  }
525
+ function assertRawMethodForGovernedPayload(taskType, options) {
526
+ if (options?.preserveGovernedPayload) {
527
+ throw new import_errors.ConfigurationError(
528
+ `Governed ${taskType} requires the raw legacy task method; canonical creative projection can reshape approved arguments.`
529
+ );
530
+ }
531
+ }
517
532
  const PRIMARY_ADCP_TASK_NAMES = {
518
533
  get_products: true,
519
534
  list_products: true,
@@ -2895,17 +2910,17 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2895
2910
  async executeAndHandleWithinDeadline(taskType, handlerName, params, inputHandler, options, transformCompletedResponse, legacyFormatConverter, canonicalRequest, projectionCatalogs) {
2896
2911
  (0, import_abort2.throwIfAborted)(options?.signal);
2897
2912
  const canonicalCreativeInvocation = CANONICAL_CREATIVE_ACTIVITY_TASKS.has(taskType) || canonicalRequest !== void 0;
2898
- let normalizedParams = (0, import_request_normalizer.normalizeRequestParams)(taskType, params, {
2913
+ let normalizedParams = options?.preserveGovernedPayload ? params : (0, import_request_normalizer.normalizeRequestParams)(taskType, params, {
2899
2914
  skipIdempotencyAutoInject: options?.skipIdempotencyAutoInject,
2900
2915
  skipAccountValidation: options?.skipAccountValidation
2901
2916
  });
2902
2917
  if (!options?.skipRequestValidation) assertNoPrincipalIdentityInput(taskType, normalizedParams);
2903
2918
  this.assertRequestSupportedByConfiguredVersion(taskType, normalizedParams, options, canonicalCreativeInvocation);
2904
2919
  this.assertDurablePropertyListCredentialSupported(taskType, normalizedParams);
2905
- if (!options?.skipIdempotencyAutoInject && (0, import_idempotency.requestUsesIdempotency)(taskType, normalizedParams) && normalizedParams && typeof normalizedParams === "object" && !normalizedParams.idempotency_key) {
2920
+ if (!options?.skipIdempotencyAutoInject && !options?.preserveGovernedPayload && (0, import_idempotency.requestUsesIdempotency)(taskType, normalizedParams) && normalizedParams && typeof normalizedParams === "object" && !normalizedParams.idempotency_key) {
2906
2921
  normalizedParams = { ...normalizedParams, idempotency_key: (0, import_idempotency.generateIdempotencyKey)() };
2907
2922
  }
2908
- if (!options?.skipIdempotencyAutoInject && !options?.skipAccountValidation && !options?.skipRequestValidation && !(0, import_schema_loader.isExternalSchemaRootActive)(this.resolvedAdcpVersion)) {
2923
+ if (!options?.skipIdempotencyAutoInject && !options?.skipAccountValidation && !options?.skipRequestValidation && !options?.preserveGovernedPayload && !(0, import_schema_loader.isExternalSchemaRootActive)(this.resolvedAdcpVersion)) {
2909
2924
  this.validateRequest(taskType, normalizedParams);
2910
2925
  }
2911
2926
  await this.validateTaskFeatures(taskType, options);
@@ -2921,7 +2936,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2921
2936
  }
2922
2937
  const agent = await this.ensureEndpointDiscovered(options);
2923
2938
  (0, import_abort2.throwIfAborted)(options?.signal);
2924
- if (!options?.skipIdempotencyAutoInject && !options?.skipAccountValidation && !options?.skipRequestValidation) {
2939
+ if (!options?.skipIdempotencyAutoInject && !options?.skipAccountValidation && !options?.skipRequestValidation && !options?.preserveGovernedPayload) {
2925
2940
  this.executor.validateRequest(taskType, normalizedParams);
2926
2941
  }
2927
2942
  const capabilityDiscoveryContext = {};
@@ -2944,7 +2959,12 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2944
2959
  capabilityDiscoveryContext.capabilities
2945
2960
  );
2946
2961
  const inputSchemaStripLogs = [];
2947
- const { params: adaptedParams, driftLogs: adaptDriftLogs } = this.adaptRequest(
2962
+ if (options?.preserveGovernedPayload && serverVersion !== "v3") {
2963
+ throw new import_errors.ConfigurationError(
2964
+ "Governed storyboard requests require a v3 seller to preserve the approved payload."
2965
+ );
2966
+ }
2967
+ const { params: adaptedParams, driftLogs: adaptDriftLogs } = options?.preserveGovernedPayload ? { params: normalizedParams, driftLogs: [] } : this.adaptRequest(
2948
2968
  taskType,
2949
2969
  normalizedParams,
2950
2970
  serverVersion,
@@ -4054,28 +4074,67 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4054
4074
  legacyFormatConverter,
4055
4075
  projectionCatalogs ?? this.config.projectionCatalogs
4056
4076
  );
4057
- const account = canonicalAccountRoutingSnapshot(params.account);
4058
- return this.executeAndHandle(
4059
- "get_products",
4060
- "onGetProductsStatusChange",
4061
- params,
4062
- inputHandler,
4063
- taskOptions,
4064
- (data) => {
4065
- const { response, diagnostics } = (0, import_augment_response.toCanonicalOnlyResponse)(data, {
4066
- legacyFormatConverter: effectiveLegacyFormatConverter,
4067
- projectionCatalogs: projectionCatalogs ?? this.config.projectionCatalogs
4068
- });
4069
- const authoritativeProducts = Array.isArray(data.products) ? data.products : response.products;
4070
- this.rememberCanonicalProductRoutes(response.products, account, authoritativeProducts);
4071
- const { _message: _dropLegacyMessage, ...canonical } = response;
4072
- void _dropLegacyMessage;
4073
- return { ...canonical, projection: { diagnostics } };
4074
- },
4075
- effectiveLegacyFormatConverter,
4076
- void 0,
4077
- projectionCatalogs
4078
- );
4077
+ return (0, import_task_deadline.withTaskDeadline)(snapshotTaskOptions(taskOptions), async (effectiveOptions) => {
4078
+ this.assertRequestSupportedByConfiguredVersion("get_products", params, effectiveOptions);
4079
+ let request = params;
4080
+ const legacyAccountId = request.account_id;
4081
+ const accountReference = request.account ?? (typeof legacyAccountId === "string" && legacyAccountId ? { account_id: legacyAccountId } : void 0);
4082
+ if (!request.account && typeof legacyAccountId === "string" && legacyAccountId) {
4083
+ const { account_id: _legacyAccountId, ...rest } = request;
4084
+ void _legacyAccountId;
4085
+ request = { ...rest, account: { account_id: legacyAccountId } };
4086
+ }
4087
+ if (!effectiveOptions.skipRequestValidation && this.config.validateFeatures !== false) {
4088
+ const capabilities = await this.getCapabilities(effectiveOptions);
4089
+ const sellerDeclares31 = capabilities.servedVersion !== void 0 ? !(0, import_adcp_version_config.isPre31AdcpVersion)(capabilities.servedVersion) : capabilities.supportedVersions?.some((version) => !(0, import_adcp_version_config.isPre31AdcpVersion)(version)) === true;
4090
+ const sellerDeclaresBuyingModes = Array.isArray(
4091
+ capabilities._raw?.media_buy?.buying_modes
4092
+ );
4093
+ if (!capabilities._synthetic) {
4094
+ const effectiveMode = request.buying_mode ?? (request.brief ? "brief" : void 0);
4095
+ if (effectiveMode && (sellerDeclares31 || sellerDeclaresBuyingModes) && !(0, import_capabilities.supportsBuyingMode)(capabilities, effectiveMode)) {
4096
+ throw new import_errors3.UnsupportedBuyingModeError(effectiveMode, capabilities.buyingModes ?? ["brief"]);
4097
+ }
4098
+ if (!effectiveOptions.skipAccountValidation && !accountReference && capabilities.account?.requiredForProducts) {
4099
+ throw new import_errors3.AccountRequiredError(
4100
+ capabilities.account.requireOperatorAuth ? "explicit" : "implicit",
4101
+ "get_products"
4102
+ );
4103
+ }
4104
+ }
4105
+ if (!request.buying_mode && !request.brief) {
4106
+ const legacySeller = capabilities._synthetic || !sellerDeclares31 && !sellerDeclaresBuyingModes;
4107
+ if (!legacySeller && !(0, import_capabilities.supportsBuyingMode)(capabilities, "wholesale")) {
4108
+ throw new import_errors3.UnsupportedBuyingModeError(void 0, capabilities.buyingModes ?? ["brief"]);
4109
+ }
4110
+ }
4111
+ }
4112
+ if (!request.buying_mode && !request.brief) {
4113
+ request = { ...request, buying_mode: "wholesale" };
4114
+ }
4115
+ const account = canonicalAccountRoutingSnapshot(accountReference);
4116
+ return this.executeAndHandle(
4117
+ "get_products",
4118
+ "onGetProductsStatusChange",
4119
+ request,
4120
+ inputHandler,
4121
+ effectiveOptions,
4122
+ (data) => {
4123
+ const { response, diagnostics } = (0, import_augment_response.toCanonicalOnlyResponse)(data, {
4124
+ legacyFormatConverter: effectiveLegacyFormatConverter,
4125
+ projectionCatalogs: projectionCatalogs ?? this.config.projectionCatalogs
4126
+ });
4127
+ const authoritativeProducts = Array.isArray(data.products) ? data.products : response.products;
4128
+ this.rememberCanonicalProductRoutes(response.products, account, authoritativeProducts);
4129
+ const { _message: _dropLegacyMessage, ...canonical } = response;
4130
+ void _dropLegacyMessage;
4131
+ return { ...canonical, projection: { diagnostics } };
4132
+ },
4133
+ effectiveLegacyFormatConverter,
4134
+ void 0,
4135
+ projectionCatalogs
4136
+ );
4137
+ });
4079
4138
  }
4080
4139
  /** Discover products through the compact AdCP 3.2 catalog task. */
4081
4140
  async listProducts(params, inputHandler, options) {
@@ -4089,11 +4148,14 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4089
4148
  }
4090
4149
  /** @deprecated Explicit raw-wire escape hatch for migration tooling. */
4091
4150
  async getProductsLegacy(params, inputHandler, options) {
4092
- return this.executeTaskUnprojected("get_products", params, inputHandler, options);
4151
+ const request = params.buying_mode || params.brief ? params : { ...params, buying_mode: "wholesale" };
4152
+ return this.executeTaskUnprojected("get_products", request, inputHandler, options);
4093
4153
  }
4094
4154
  /** @internal Run final legacy get_products adaptation before an application-owned atomic mutation claim. */
4095
4155
  async getProductsLegacyWithPreDispatch(params, beforeDispatch, inputHandler, options) {
4096
- const requestSnapshot = structuredClone(params);
4156
+ const requestSnapshot = structuredClone(
4157
+ params.buying_mode || params.brief ? params : { ...params, buying_mode: "wholesale" }
4158
+ );
4097
4159
  return this.executeTaskUnprojected(
4098
4160
  "get_products",
4099
4161
  requestSnapshot,
@@ -4132,6 +4194,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4132
4194
  * @param options - Task execution options
4133
4195
  */
4134
4196
  async createMediaBuy(params, inputHandler, options) {
4197
+ assertRawMethodForGovernedPayload("create_media_buy", options);
4135
4198
  this.assertDurableProjectionOverrideSupported(options?.legacyFormatConverter);
4136
4199
  const requestSnapshot = (0, import_legacy_metadata.structuredCloneWithLegacyCreativeMetadata)(params);
4137
4200
  const projectionCatalogs = options?.projectionCatalogs ? structuredClone(options.projectionCatalogs) : void 0;
@@ -4261,6 +4324,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4261
4324
  * @param options - Task execution options
4262
4325
  */
4263
4326
  async updateMediaBuy(params, inputHandler, options) {
4327
+ assertRawMethodForGovernedPayload("update_media_buy", options);
4264
4328
  this.assertDurableProjectionOverrideSupported(options?.legacyFormatConverter);
4265
4329
  const requestSnapshot = (0, import_legacy_metadata.structuredCloneWithLegacyCreativeMetadata)(params);
4266
4330
  const projectionCatalogs = options?.projectionCatalogs ? structuredClone(options.projectionCatalogs) : void 0;
@@ -4329,6 +4393,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4329
4393
  * @param options - Task execution options
4330
4394
  */
4331
4395
  async syncCreatives(params, inputHandler, options) {
4396
+ assertRawMethodForGovernedPayload("sync_creatives", options);
4332
4397
  this.assertDurableProjectionOverrideSupported(
4333
4398
  options?.creativeFormatProjection?.legacyFormatConverter ?? options?.legacyFormatConverter
4334
4399
  );
@@ -4787,6 +4852,140 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4787
4852
  options
4788
4853
  );
4789
4854
  }
4855
+ /**
4856
+ * Resolve an account for the authenticated caller. Explicit-account sellers
4857
+ * are discovered with list_accounts; implicit-account sellers are registered
4858
+ * with sync_accounts and addressed by their natural key.
4859
+ */
4860
+ async resolveAccount(hints = {}, options, onTaskResult) {
4861
+ return (0, import_task_deadline.withTaskDeadline)(snapshotTaskOptions(options), async (effectiveOptions) => {
4862
+ const capabilities = await this.getCapabilities(effectiveOptions);
4863
+ if (capabilities._synthetic || !capabilities.account) {
4864
+ throw new import_errors3.AccountRequiredError(
4865
+ "explicit",
4866
+ "resolveAccount",
4867
+ "The seller did not provide an account contract. Probe get_adcp_capabilities or pass an account reference explicitly."
4868
+ );
4869
+ }
4870
+ if (capabilities.account.requireOperatorAuth) {
4871
+ const accounts = [];
4872
+ const seenCursors = /* @__PURE__ */ new Set();
4873
+ let cursor;
4874
+ for (let page = 0; page < 100; page++) {
4875
+ const result2 = await this.listAccounts(
4876
+ {
4877
+ status: "active",
4878
+ sandbox: hints.sandbox ?? false,
4879
+ ...cursor !== void 0 && { pagination: { cursor } }
4880
+ },
4881
+ void 0,
4882
+ effectiveOptions
4883
+ );
4884
+ onTaskResult?.(result2);
4885
+ if (!result2.success || result2.status !== "completed" || !result2.data || !("accounts" in result2.data) || !Array.isArray(result2.data.accounts)) {
4886
+ throw new Error("list_accounts did not return a completed account list.");
4887
+ }
4888
+ accounts.push(...result2.data.accounts);
4889
+ if (!result2.data.pagination?.has_more) return (0, import_account_resolution.selectListedAccount)(accounts, hints);
4890
+ const nextCursor = result2.data.pagination.cursor;
4891
+ if (!nextCursor || seenCursors.has(nextCursor)) break;
4892
+ seenCursors.add(nextCursor);
4893
+ cursor = nextCursor;
4894
+ }
4895
+ throw new import_errors3.AccountRequiredError(
4896
+ "explicit",
4897
+ "resolveAccount",
4898
+ "Could not complete list_accounts pagination. Select an account_id explicitly after listing accounts."
4899
+ );
4900
+ }
4901
+ if (!hints.brand?.domain || !hints.operator) {
4902
+ throw new import_errors3.AccountRequiredError(
4903
+ "implicit",
4904
+ "resolveAccount",
4905
+ "Implicit-account sellers require both brand and operator to sync an account."
4906
+ );
4907
+ }
4908
+ const uses32NaturalKey = hints.operatorUnit !== void 0 || hints.currency !== void 0 || hints.timezone !== void 0;
4909
+ const sellerServes32 = capabilities.servedVersion ? !(0, import_adcp_version_config.isPre32AdcpVersion)(capabilities.servedVersion) : capabilities.supportedVersions?.some((version) => !(0, import_adcp_version_config.isPre32AdcpVersion)(version)) === true;
4910
+ if (uses32NaturalKey && ((0, import_adcp_version_config.isPre32AdcpVersion)(this.resolvedAdcpVersion) || !sellerServes32)) {
4911
+ throw new import_errors3.AccountRequiredError(
4912
+ "implicit",
4913
+ "resolveAccount",
4914
+ "Operator unit, account currency, and account timezone require AdCP 3.2 on both buyer and seller."
4915
+ );
4916
+ }
4917
+ const timezone = capabilities.account.timezone;
4918
+ if (timezone?.accountSelection === "buyer_selected") {
4919
+ if (!hints.timezone || !timezone.supportedTimezones?.includes(hints.timezone)) {
4920
+ throw new import_errors3.AccountRequiredError(
4921
+ "implicit",
4922
+ "resolveAccount",
4923
+ "Choose a supported account timezone before sync_accounts."
4924
+ );
4925
+ }
4926
+ } else if (hints.timezone && timezone) {
4927
+ throw new import_errors3.AccountRequiredError(
4928
+ "implicit",
4929
+ "resolveAccount",
4930
+ "This seller does not accept a buyer-selected account timezone."
4931
+ );
4932
+ }
4933
+ const currencyModes = capabilities.account.supportedAccountCurrencyModes;
4934
+ if (currencyModes?.length === 1 && currencyModes[0] === "fixed" && !hints.currency) {
4935
+ throw new import_errors3.AccountRequiredError("implicit", "resolveAccount", "This seller requires a fixed account currency.");
4936
+ }
4937
+ if (hints.currency && currencyModes?.length === 1 && currencyModes[0] === "per_media_buy") {
4938
+ throw new import_errors3.AccountRequiredError("implicit", "resolveAccount", "This seller selects currency per media buy.");
4939
+ }
4940
+ const account = {
4941
+ brand: hints.brand,
4942
+ operator: hints.operator,
4943
+ ...hints.operatorUnit !== void 0 && { operator_unit: hints.operatorUnit },
4944
+ ...hints.currency !== void 0 && { currency: hints.currency },
4945
+ ...hints.timezone !== void 0 && { timezone: hints.timezone },
4946
+ ...hints.sandbox !== void 0 && { sandbox: hints.sandbox }
4947
+ };
4948
+ const supportedBilling = capabilities.account.supportedBilling;
4949
+ const billing = hints.billing ?? capabilities.account.defaultBilling ?? (supportedBilling.length === 1 ? supportedBilling[0] : void 0);
4950
+ if (!billing || supportedBilling.length > 0 && !supportedBilling.includes(billing)) {
4951
+ throw new import_errors3.AccountRequiredError(
4952
+ "implicit",
4953
+ "resolveAccount",
4954
+ `Choose a supported billing party for sync_accounts (seller supports: ${supportedBilling.join(", ") || "(none)"}).`
4955
+ );
4956
+ }
4957
+ const result = await this.syncAccounts(
4958
+ {
4959
+ accounts: [
4960
+ {
4961
+ ...account,
4962
+ billing
4963
+ }
4964
+ ]
4965
+ },
4966
+ void 0,
4967
+ effectiveOptions
4968
+ );
4969
+ onTaskResult?.(result);
4970
+ if (!result.success || result.status !== "completed" || !result.data || !("accounts" in result.data) || !Array.isArray(result.data.accounts)) {
4971
+ throw new Error("sync_accounts did not return a completed account result.");
4972
+ }
4973
+ const synced = result.data.accounts.find(
4974
+ (row) => row.brand?.domain === hints.brand.domain && row.operator === hints.operator && (!hints.brand.brand_id || row.brand.brand_id === hints.brand.brand_id) && (0, import_account_resolution.sameCountrySet)(hints.brand.countries, row.brand.countries) && (!hints.operatorUnit || row.operator_unit?.id === hints.operatorUnit.id) && (!hints.currency || row.currency === hints.currency) && (!hints.timezone || row.timezone === hints.timezone) && (row.sandbox === void 0 || row.sandbox === true === (hints.sandbox === true))
4975
+ );
4976
+ if (synced?.status === "pending_approval") {
4977
+ throw new import_errors3.AccountPendingApprovalError(account, synced.account_id);
4978
+ }
4979
+ if (!synced || synced.action === "failed" || synced.status !== "active") {
4980
+ throw new import_errors3.AccountRequiredError(
4981
+ "implicit",
4982
+ "resolveAccount",
4983
+ "sync_accounts did not establish an active account for the requested brand and operator."
4984
+ );
4985
+ }
4986
+ return account;
4987
+ });
4988
+ }
4790
4989
  /**
4791
4990
  * Sync accounts
4792
4991
  */
@@ -5055,7 +5254,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5055
5254
  let detectedServerVersion;
5056
5255
  let detectedServerVersionSynthetic;
5057
5256
  try {
5058
- const normalizedParams = (0, import_request_normalizer.normalizeRequestParams)(taskName, params, {
5257
+ const normalizedParams = options?.preserveGovernedPayload ? params : (0, import_request_normalizer.normalizeRequestParams)(taskName, params, {
5059
5258
  skipIdempotencyAutoInject: options?.skipIdempotencyAutoInject,
5060
5259
  skipAccountValidation: options?.skipAccountValidation
5061
5260
  });
@@ -5067,7 +5266,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5067
5266
  await this.requireSupportedMajor(taskName, options);
5068
5267
  }
5069
5268
  const agent = await this.ensureEndpointDiscovered(options);
5070
- if (!options?.skipIdempotencyAutoInject && !options?.skipAccountValidation && !options?.skipRequestValidation) {
5269
+ if (!options?.skipIdempotencyAutoInject && !options?.skipAccountValidation && !options?.skipRequestValidation && !options?.preserveGovernedPayload) {
5071
5270
  this.executor.validateRequest(taskName, normalizedParams);
5072
5271
  }
5073
5272
  const capabilityDiscoveryContext = {};
@@ -5091,7 +5290,12 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5091
5290
  capabilityDiscoveryContext.capabilities
5092
5291
  );
5093
5292
  const inputSchemaStripLogs = [];
5094
- const { params: adaptedParams, driftLogs: adaptDriftLogs } = this.adaptRequest(
5293
+ if (options?.preserveGovernedPayload && serverVersion !== "v3") {
5294
+ throw new import_errors.ConfigurationError(
5295
+ "Governed storyboard requests require a v3 seller to preserve the approved payload."
5296
+ );
5297
+ }
5298
+ const { params: adaptedParams, driftLogs: adaptDriftLogs } = options?.preserveGovernedPayload ? { params: normalizedParams, driftLogs: [] } : this.adaptRequest(
5095
5299
  taskName,
5096
5300
  normalizedParams,
5097
5301
  serverVersion,