@adcp/sdk 16.5.0 → 16.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/dist/lib/adapters/version/3.0/brand-fields.d.mts +7 -1
  2. package/dist/lib/adapters/version/3.0/brand-fields.d.ts +7 -1
  3. package/dist/lib/adapters/version/3.0/brand-fields.js +139 -3
  4. package/dist/lib/adapters/version/3.0/brand-fields.mjs +136 -2
  5. package/dist/lib/adapters/version/3.0/index.js +6 -0
  6. package/dist/lib/adapters/version/3.0/index.mjs +7 -1
  7. package/dist/lib/adapters/version/3.1/bidding.js +1 -1
  8. package/dist/lib/adapters/version/3.1/bidding.mjs +1 -1
  9. package/dist/lib/adapters/version/types.d.mts +5 -0
  10. package/dist/lib/adapters/version/types.d.ts +5 -0
  11. package/dist/lib/canonical-references/index.js +2 -0
  12. package/dist/lib/canonical-references/index.mjs +2 -0
  13. package/dist/lib/client/account-changes.d.mts +3 -1
  14. package/dist/lib/client/account-changes.d.ts +3 -1
  15. package/dist/lib/client/account-changes.js +22 -2
  16. package/dist/lib/client/account-changes.mjs +22 -2
  17. package/dist/lib/conformance/oracle.js +3 -2
  18. package/dist/lib/conformance/oracle.mjs +3 -2
  19. package/dist/lib/core/AgentClient.d.mts +165 -1
  20. package/dist/lib/core/AgentClient.d.ts +165 -1
  21. package/dist/lib/core/AgentClient.js +446 -8
  22. package/dist/lib/core/AgentClient.mjs +446 -8
  23. package/dist/lib/core/ConversationTypes.d.mts +8 -0
  24. package/dist/lib/core/ConversationTypes.d.ts +8 -0
  25. package/dist/lib/core/ProtocolResponseParser.d.mts +1 -1
  26. package/dist/lib/core/ProtocolResponseParser.d.ts +1 -1
  27. package/dist/lib/core/ProtocolResponseParser.js +28 -18
  28. package/dist/lib/core/ProtocolResponseParser.mjs +11 -1
  29. package/dist/lib/core/ResponseValidator.js +1 -1
  30. package/dist/lib/core/ResponseValidator.mjs +1 -1
  31. package/dist/lib/core/SingleAgentClient.d.mts +116 -6
  32. package/dist/lib/core/SingleAgentClient.d.ts +116 -6
  33. package/dist/lib/core/SingleAgentClient.js +556 -84
  34. package/dist/lib/core/SingleAgentClient.mjs +545 -72
  35. package/dist/lib/core/TaskExecutor.d.mts +7 -0
  36. package/dist/lib/core/TaskExecutor.d.ts +7 -0
  37. package/dist/lib/core/TaskExecutor.js +23 -8
  38. package/dist/lib/core/TaskExecutor.mjs +23 -8
  39. package/dist/lib/core/task-status.d.mts +2 -0
  40. package/dist/lib/core/task-status.d.ts +2 -0
  41. package/dist/lib/core/task-status.js +11 -2
  42. package/dist/lib/core/task-status.mjs +9 -1
  43. package/dist/lib/errors/index.d.mts +22 -0
  44. package/dist/lib/errors/index.d.ts +22 -0
  45. package/dist/lib/errors/index.js +43 -0
  46. package/dist/lib/errors/index.mjs +42 -0
  47. package/dist/lib/identity-3.3/trust.d.mts +1 -4
  48. package/dist/lib/identity-3.3/trust.d.ts +1 -4
  49. package/dist/lib/identity-3.3/trust.js +34 -21
  50. package/dist/lib/identity-3.3/trust.mjs +34 -21
  51. package/dist/lib/identity-3.3/validation.js +5 -3
  52. package/dist/lib/identity-3.3/validation.mjs +6 -4
  53. package/dist/lib/index.d.mts +8 -54
  54. package/dist/lib/index.d.ts +8 -54
  55. package/dist/lib/index.js +15 -0
  56. package/dist/lib/index.mjs +11 -0
  57. package/dist/lib/media-buy/action-assessment.js +29 -3
  58. package/dist/lib/media-buy/action-assessment.mjs +32 -4
  59. package/dist/lib/media-buy/action-contracts.d.mts +3 -0
  60. package/dist/lib/media-buy/action-contracts.d.ts +3 -0
  61. package/dist/lib/media-buy/action-contracts.js +24 -1
  62. package/dist/lib/media-buy/action-contracts.mjs +22 -1
  63. package/dist/lib/media-buy/compatibility.js +6 -1
  64. package/dist/lib/media-buy/compatibility.mjs +6 -1
  65. package/dist/lib/media-buy/preflight.js +1 -1
  66. package/dist/lib/media-buy/preflight.mjs +3 -2
  67. package/dist/lib/media-buy/types.d.mts +6 -1
  68. package/dist/lib/media-buy/types.d.ts +6 -1
  69. package/dist/lib/protocols/mcp-modern.d.mts +2 -0
  70. package/dist/lib/protocols/mcp-modern.d.ts +2 -0
  71. package/dist/lib/protocols/mcp-modern.js +31 -5
  72. package/dist/lib/protocols/mcp-modern.mjs +31 -5
  73. package/dist/lib/protocols/mcp-scope.d.mts +6 -1
  74. package/dist/lib/protocols/mcp-scope.d.ts +6 -1
  75. package/dist/lib/protocols/mcp-scope.js +25 -3
  76. package/dist/lib/protocols/mcp-scope.mjs +24 -3
  77. package/dist/lib/protocols/mcp.js +12 -6
  78. package/dist/lib/protocols/mcp.mjs +13 -6
  79. package/dist/lib/reporting/inspection.js +1 -0
  80. package/dist/lib/reporting/inspection.mjs +1 -0
  81. package/dist/lib/schemas/browser.d.mts +2 -0
  82. package/dist/lib/schemas/browser.d.ts +2 -0
  83. package/dist/lib/schemas/browser.js +3 -0
  84. package/dist/lib/schemas/browser.mjs +2 -0
  85. package/dist/lib/schemas/index.d.mts +5 -2
  86. package/dist/lib/schemas/index.d.ts +5 -2
  87. package/dist/lib/schemas/index.js +5 -0
  88. package/dist/lib/schemas/index.mjs +4 -0
  89. package/dist/lib/server/account-response-identity.d.mts +17 -0
  90. package/dist/lib/server/account-response-identity.d.ts +17 -0
  91. package/dist/lib/server/account-response-identity.js +52 -0
  92. package/dist/lib/server/account-response-identity.mjs +28 -0
  93. package/dist/lib/server/account-sync-contract.js +1 -0
  94. package/dist/lib/server/account-sync-contract.mjs +1 -0
  95. package/dist/lib/server/create-adcp-server.js +32 -19
  96. package/dist/lib/server/create-adcp-server.mjs +36 -12
  97. package/dist/lib/server/decisioning/account.d.mts +13 -6
  98. package/dist/lib/server/decisioning/account.d.ts +13 -6
  99. package/dist/lib/server/decisioning/account.js +37 -15
  100. package/dist/lib/server/decisioning/account.mjs +37 -15
  101. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +5 -5
  102. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +5 -5
  103. package/dist/lib/server/decisioning/runtime/from-platform.js +6 -6
  104. package/dist/lib/server/decisioning/runtime/from-platform.mjs +6 -6
  105. package/dist/lib/server/index.d.mts +1 -1
  106. package/dist/lib/server/index.d.ts +1 -1
  107. package/dist/lib/server/index.js +2 -0
  108. package/dist/lib/server/index.mjs +2 -0
  109. package/dist/lib/server/media-buy-action-resolver.d.mts +3 -0
  110. package/dist/lib/server/media-buy-action-resolver.d.ts +3 -0
  111. package/dist/lib/server/media-buy-action-resolver.js +32 -0
  112. package/dist/lib/server/media-buy-action-resolver.mjs +32 -0
  113. package/dist/lib/server/media-buy-store.d.mts +26 -12
  114. package/dist/lib/server/media-buy-store.d.ts +26 -12
  115. package/dist/lib/server/media-buy-store.js +69 -21
  116. package/dist/lib/server/media-buy-store.mjs +69 -21
  117. package/dist/lib/server/responses.js +9 -1
  118. package/dist/lib/server/responses.mjs +9 -1
  119. package/dist/lib/server/state-machine.d.mts +10 -11
  120. package/dist/lib/server/state-machine.d.ts +10 -11
  121. package/dist/lib/server/state-machine.js +20 -5
  122. package/dist/lib/server/state-machine.mjs +19 -5
  123. package/dist/lib/signing/agent-fetch.d.mts +1 -1
  124. package/dist/lib/signing/agent-fetch.d.ts +1 -1
  125. package/dist/lib/signing/agent-fetch.js +3 -3
  126. package/dist/lib/signing/agent-fetch.mjs +3 -3
  127. package/dist/lib/testing/client.d.mts +1 -0
  128. package/dist/lib/testing/client.d.ts +1 -0
  129. package/dist/lib/testing/client.js +6 -5
  130. package/dist/lib/testing/client.mjs +6 -5
  131. package/dist/lib/testing/storyboard/canonical-format-satisfaction.js +60 -14
  132. package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +60 -14
  133. package/dist/lib/testing/storyboard/compliance.d.mts +2 -5
  134. package/dist/lib/testing/storyboard/compliance.d.ts +2 -5
  135. package/dist/lib/testing/storyboard/compliance.js +62 -13
  136. package/dist/lib/testing/storyboard/compliance.mjs +63 -14
  137. package/dist/lib/testing/storyboard/context.d.mts +13 -3
  138. package/dist/lib/testing/storyboard/context.d.ts +13 -3
  139. package/dist/lib/testing/storyboard/context.js +15 -10
  140. package/dist/lib/testing/storyboard/context.mjs +15 -10
  141. package/dist/lib/testing/storyboard/default-invariants.js +10 -8
  142. package/dist/lib/testing/storyboard/default-invariants.mjs +11 -9
  143. package/dist/lib/testing/storyboard/request-signing/vector-loader.d.mts +2 -0
  144. package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts +2 -0
  145. package/dist/lib/testing/storyboard/request-signing/vector-loader.js +11 -0
  146. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +10 -0
  147. package/dist/lib/testing/storyboard/runner.js +23 -10
  148. package/dist/lib/testing/storyboard/runner.mjs +23 -10
  149. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  150. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  151. package/dist/lib/testing/storyboard/validations.js +4 -1
  152. package/dist/lib/testing/storyboard/validations.mjs +4 -1
  153. package/dist/lib/testing/test-controller.js +3 -0
  154. package/dist/lib/testing/test-controller.mjs +3 -0
  155. package/dist/lib/types/asset-instances.d.mts +1 -1
  156. package/dist/lib/types/asset-instances.d.ts +1 -1
  157. package/dist/lib/types/index.d.mts +5 -0
  158. package/dist/lib/types/index.d.ts +5 -0
  159. package/dist/lib/types/index.js +6 -1
  160. package/dist/lib/types/index.mjs +4 -1
  161. package/dist/lib/types/inline-enums.generated.d.mts +30 -4
  162. package/dist/lib/types/inline-enums.generated.d.ts +30 -4
  163. package/dist/lib/types/inline-enums.generated.js +41 -2
  164. package/dist/lib/types/inline-enums.generated.mjs +28 -2
  165. package/dist/lib/types/media-buy-delivery-report.d.mts +4 -0
  166. package/dist/lib/types/media-buy-delivery-report.d.ts +4 -0
  167. package/dist/lib/types/media-buy-delivery-report.js +16 -0
  168. package/dist/lib/types/media-buy-delivery-report.mjs +0 -0
  169. package/dist/lib/types/schemas.generated.d.ts +20 -69
  170. package/dist/lib/types/schemas.generated.js +29 -46
  171. package/dist/lib/types/schemas.generated.mjs +29 -46
  172. package/dist/lib/types/targeting-keys.generated.d.mts +4 -0
  173. package/dist/lib/types/targeting-keys.generated.d.ts +4 -0
  174. package/dist/lib/types/targeting-keys.generated.js +105 -0
  175. package/dist/lib/types/targeting-keys.generated.mjs +80 -0
  176. package/dist/lib/utils/adcp-version-config.js +5 -2
  177. package/dist/lib/utils/adcp-version-config.mjs +5 -2
  178. package/dist/lib/utils/envelope-status-compat.d.mts +18 -1
  179. package/dist/lib/utils/envelope-status-compat.d.ts +18 -1
  180. package/dist/lib/utils/envelope-status-compat.js +11 -5
  181. package/dist/lib/utils/envelope-status-compat.mjs +11 -5
  182. package/dist/lib/utils/response-unwrapper.js +18 -10
  183. package/dist/lib/utils/response-unwrapper.mjs +18 -10
  184. package/dist/lib/v2/format-schema/resolver.js +1 -1
  185. package/dist/lib/v2/format-schema/resolver.mjs +1 -1
  186. package/dist/lib/v2/projection/creative-delivery.js +123 -30
  187. package/dist/lib/v2/projection/creative-delivery.mjs +127 -30
  188. package/dist/lib/v2/projection/index.d.mts +1 -0
  189. package/dist/lib/v2/projection/index.d.ts +1 -0
  190. package/dist/lib/v2/projection/index.js +3 -0
  191. package/dist/lib/v2/projection/index.mjs +2 -0
  192. package/dist/lib/v2/projection/legacy-metadata.d.mts +19 -0
  193. package/dist/lib/v2/projection/legacy-metadata.d.ts +19 -0
  194. package/dist/lib/v2/projection/legacy-metadata.js +91 -0
  195. package/dist/lib/v2/projection/legacy-metadata.mjs +86 -0
  196. package/dist/lib/validation/compact-schema.d.mts +27 -0
  197. package/dist/lib/validation/compact-schema.d.ts +27 -0
  198. package/dist/lib/validation/compact-schema.js +276 -0
  199. package/dist/lib/validation/compact-schema.mjs +250 -0
  200. package/dist/lib/validation/media-buy-delivery-report.d.mts +8 -0
  201. package/dist/lib/validation/media-buy-delivery-report.d.ts +8 -0
  202. package/dist/lib/validation/media-buy-delivery-report.js +31 -0
  203. package/dist/lib/validation/media-buy-delivery-report.mjs +7 -0
  204. package/dist/lib/validation/schema-diagnostic-origins.d.mts +21 -0
  205. package/dist/lib/validation/schema-diagnostic-origins.d.ts +21 -0
  206. package/dist/lib/validation/schema-diagnostic-origins.js +193 -0
  207. package/dist/lib/validation/schema-diagnostic-origins.mjs +169 -0
  208. package/dist/lib/validation/schema-loader.js +86 -16
  209. package/dist/lib/validation/schema-loader.mjs +82 -16
  210. package/dist/lib/validation/schema-validator.d.mts +10 -19
  211. package/dist/lib/validation/schema-validator.d.ts +10 -19
  212. package/dist/lib/validation/schema-validator.js +136 -43
  213. package/dist/lib/validation/schema-validator.mjs +140 -44
  214. package/dist/lib/version.d.mts +3 -3
  215. package/dist/lib/version.d.ts +3 -3
  216. package/dist/lib/version.js +3 -3
  217. package/dist/lib/version.mjs +3 -3
  218. package/dist/lib/webhooks/index.d.mts +3 -0
  219. package/dist/lib/webhooks/index.d.ts +3 -0
  220. package/dist/lib/webhooks/index.js +3 -0
  221. package/dist/lib/webhooks/index.mjs +2 -0
  222. package/dist/lib/webhooks/media-buy-delivery.d.mts +43 -0
  223. package/dist/lib/webhooks/media-buy-delivery.d.ts +43 -0
  224. package/dist/lib/webhooks/media-buy-delivery.js +119 -0
  225. package/dist/lib/webhooks/media-buy-delivery.mjs +94 -0
  226. package/docs/TYPE-SUMMARY.md +2 -2
  227. package/docs/guides/BUILD-AN-AGENT.md +9 -1
  228. package/docs/guides/DELIVERY-WEBHOOK-PARSING.md +135 -0
  229. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +15 -0
  230. package/docs/guides/TYPED-CLIENT-TOOLS.md +49 -0
  231. package/docs/llms.txt +3 -3
  232. package/docs/migration-14.x-rc-worksheet.md +4 -4
  233. package/docs/migration-6.6-to-6.7.md +14 -0
  234. package/docs/migration-account-change-feed.md +19 -0
  235. package/docs/releases/sdk-16.6-adoption-fixes.md +33 -0
  236. package/package.json +2 -2
@@ -35,6 +35,7 @@ __export(SingleAgentClient_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(SingleAgentClient_exports);
37
37
  var import_mcp_connection_policy = require('../protocols/mcp-connection-policy.js');
38
+ var import_mcp_scope = require('../protocols/mcp-scope.js');
38
39
  var import_protocol_methods = require('../signing/protocol-methods.js');
39
40
  var import_pricing_adapter = require('../utils/pricing-adapter.js');
40
41
  var import_creative_adapter = require('../utils/creative-adapter.js');
@@ -83,6 +84,7 @@ var import_errors3 = require('../errors/index.js');
83
84
  var import_buyer_account_registry = require('./buyer-account-registry.js');
84
85
  var import_account_resolution = require('./account-resolution.js');
85
86
  var import_request_normalizer = require('../utils/request-normalizer.js');
87
+ var import_legacy_metadata = require('../v2/projection/legacy-metadata.js');
86
88
  var import_global_async_local_storage = require('../utils/global-async-local-storage.js');
87
89
  var import_validate_user_agent = require('../utils/validate-user-agent.js');
88
90
  var import_webhook_url = require('./webhook-url.js');
@@ -92,7 +94,7 @@ var import_creative_delivery = require('../v2/projection/creative-delivery.js');
92
94
  var import_legacy_routes = require('../v2/projection/legacy-routes.js');
93
95
  var import_catalog_snapshot = require('../v2/projection/catalog-snapshot.js');
94
96
  var import_augment_response = require('../v2/projection/augment-response.js');
95
- var import_legacy_metadata = require('../v2/projection/legacy-metadata.js');
97
+ var import_legacy_metadata2 = require('../v2/projection/legacy-metadata.js');
96
98
  var import_types = require('../v2/projection/types.js');
97
99
  var import_jcs = require('../utils/jcs.js');
98
100
  function loadWebBotAuth() {
@@ -100,6 +102,16 @@ function loadWebBotAuth() {
100
102
  }
101
103
  const SKIP_PRODUCT_CACHE = /* @__PURE__ */ Symbol("adcp.skipProductCache");
102
104
  const SKIP_ACCOUNT_REGISTRY_OBSERVATION = /* @__PURE__ */ Symbol("adcp.skipAccountRegistryObservation");
105
+ const NONTERMINAL_TASK_RESULT_STATUSES = /* @__PURE__ */ new Set([
106
+ "submitted",
107
+ "working",
108
+ "input-required",
109
+ "auth-required",
110
+ "deferred"
111
+ ]);
112
+ function isNonterminalTaskResult(result) {
113
+ return result !== null && typeof result === "object" && "success" in result && result.success === true && "status" in result && typeof result.status === "string" && NONTERMINAL_TASK_RESULT_STATUSES.has(result.status);
114
+ }
103
115
  function presentedStaticTransportCredential(authToken, headers, authProvider) {
104
116
  if (authProvider) return false;
105
117
  if (authToken) return true;
@@ -626,10 +638,7 @@ const STANDARD_ADCP_TASK_NAMES = /* @__PURE__ */ new Set([
626
638
  "list_transformers",
627
639
  "preview_creative",
628
640
  "build_creative",
629
- // These standard protocol tools still carry legacy creative `format_id`
630
- // identity through artifacts, manifests, standards, or rights constraints.
631
- // They are available only through explicitly named *Legacy APIs until a
632
- // lossless canonical projection exists.
641
+ // Wire-level creative and content tools also have typed primary methods.
633
642
  "list_content_standards",
634
643
  "get_content_standards",
635
644
  "create_content_standards",
@@ -913,7 +922,19 @@ class SingleAgentClient {
913
922
  adcpVersion: this.resolvedAdcpVersion,
914
923
  ...config.wireAdcpVersion !== void 0 && { wireAdcpVersion: config.wireAdcpVersion },
915
924
  ...config.versionEnvelope !== void 0 && { versionEnvelope: config.versionEnvelope },
916
- transport: config.transport
925
+ transport: config.transport,
926
+ resolveTaskStatusTool: async (pollAgent, options) => {
927
+ const client = pollAgent.id === this.normalizedAgent.id ? this : new SingleAgentClient(pollAgent, {
928
+ adcpVersion: this.resolvedAdcpVersion,
929
+ wireAdcpVersion: this.config.wireAdcpVersion,
930
+ versionEnvelope: this.config.versionEnvelope,
931
+ userAgent: this.config.userAgent,
932
+ discoveryCache: this.config.discoveryCache,
933
+ onTransportActivity: this.config.onTransportActivity,
934
+ transport: options.transport
935
+ });
936
+ return await client.advertisesTool("get_task_status", options) ? "get_task_status" : pollAgent.protocol === "mcp" ? "tasks_get" : "tasks/get";
937
+ }
917
938
  });
918
939
  if (config.handlers) {
919
940
  this.asyncHandler = new import_AsyncHandler.AsyncHandler(config.handlers);
@@ -1461,18 +1482,18 @@ class SingleAgentClient {
1461
1482
  publisher_domain: option.publisher_domain,
1462
1483
  format_option_id: option.format_option_id
1463
1484
  } : { scope: "product", format_option_id: option.format_option_id };
1464
- const refs = (0, import_legacy_metadata.legacyFormatRefsForDeclaration)(option);
1465
- const declared = declaredOptions ? declaredOptions.get(product.product_id)?.some((declaredRef) => this.sameCanonicalOptionRef(declaredRef, ref)) : (0, import_legacy_metadata.sellerDeclaredFormatOption)(option);
1466
- if (declared !== void 0) (0, import_legacy_metadata.rememberSellerDeclaredFormatOption)(option, declared);
1485
+ const refs = (0, import_legacy_metadata2.legacyFormatRefsForDeclaration)(option);
1486
+ const declared = declaredOptions ? declaredOptions.get(product.product_id)?.some((declaredRef) => this.sameCanonicalOptionRef(declaredRef, ref)) : (0, import_legacy_metadata2.sellerDeclaredFormatOption)(option);
1487
+ if (declared !== void 0) (0, import_legacy_metadata2.rememberSellerDeclaredFormatOption)(option, declared);
1467
1488
  if (declared === true && evidence)
1468
- (0, import_legacy_metadata.rememberSellerFormatEvidence)(option, { ...evidence, productId: product.product_id });
1489
+ (0, import_legacy_metadata2.rememberSellerFormatEvidence)(option, { ...evidence, productId: product.product_id });
1469
1490
  this.rememberCanonicalLegacyRoute(this.canonicalLegacyRouteKey(account, product.product_id, ref), {
1470
1491
  kind: "product",
1471
1492
  accountScope,
1472
1493
  productId: product.product_id,
1473
1494
  optionRef: ref,
1474
1495
  refs,
1475
- ...declared === true && (0, import_legacy_metadata.sellerFormatEvidence)(option) ? { declaration: (0, import_legacy_metadata.structuredCloneWithLegacyCreativeMetadata)(option) } : {},
1496
+ ...declared === true && (0, import_legacy_metadata2.sellerFormatEvidence)(option) ? { declaration: (0, import_legacy_metadata2.structuredCloneWithLegacyCreativeMetadata)(option) } : {},
1476
1497
  ...declared === false ? { undeclaredSelector: (0, import_legacy_routes.undeclaredFormatOptionSelector)(option) } : {}
1477
1498
  });
1478
1499
  }
@@ -1721,8 +1742,18 @@ class SingleAgentClient {
1721
1742
  const agent = this.normalizedAgent.protocol === "a2a" ? await this.ensureCanonicalUrlResolved(snapshot) : await this.ensureEndpointDiscovered(snapshot);
1722
1743
  return this.executor.trackTask(agent, snapshot);
1723
1744
  }
1724
- /** Poll through the same discovered/canonical protocol endpoint used for dispatch. @internal */
1725
- async getTaskStatus(taskId, transport, signal, wireOptions) {
1745
+ async getTaskStatus(taskIdOrParams, transportOrHandler, signalOrOptions, wireOptions) {
1746
+ if (typeof taskIdOrParams !== "string") {
1747
+ return this.executeTaskUnprojected(
1748
+ "get_task_status",
1749
+ taskIdOrParams,
1750
+ transportOrHandler,
1751
+ signalOrOptions
1752
+ );
1753
+ }
1754
+ const taskId = taskIdOrParams;
1755
+ const transport = transportOrHandler;
1756
+ const signal = signalOrOptions;
1726
1757
  const transportSnapshot = transport === void 0 ? void 0 : { ...transport };
1727
1758
  const options = { transport: transportSnapshot, signal };
1728
1759
  const agent = this.normalizedAgent.protocol === "a2a" ? await this.ensureCanonicalUrlResolved(options) : await this.ensureEndpointDiscovered(options);
@@ -2195,6 +2226,9 @@ class SingleAgentClient {
2195
2226
  * - A validated MCP protected-resource metadata chain yields NeedsAuthorizationError
2196
2227
  * - Otherwise AuthenticationRequiredError carries the advertised challenge
2197
2228
  *
2229
+ * Rate limiting (429, or 503 with Retry-After) stops probing at that URL and
2230
+ * throws AgentRateLimitedError carrying the status and Retry-After.
2231
+ *
2198
2232
  * Note: This is async and called lazily on first agent interaction
2199
2233
  */
2200
2234
  async discoverMCPEndpoint(providedUri, options) {
@@ -2205,8 +2239,8 @@ class SingleAgentClient {
2205
2239
  }
2206
2240
  async discoverMCPEndpointWithConnectionPolicy(providedUri, options) {
2207
2241
  (0, import_abort2.throwIfAborted)(options?.signal);
2208
- const { connectMCPWithFallback } = await import("../protocols/mcp.js");
2209
- const { probeModernMCPConnection } = await import("../protocols/mcp-modern.js");
2242
+ const { connectMCPWithFallback, withScopedLegacyConnection } = await import("../protocols/mcp.js");
2243
+ const { probeModernMCPConnection, retryAfterOf } = await import("../protocols/mcp-modern.js");
2210
2244
  const transport = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport);
2211
2245
  const usesScopedFetch = this.usesScopedDiscoveryTransport(options);
2212
2246
  const endpointEpoch = this.discoveryEpochSnapshot(options);
@@ -2236,19 +2270,35 @@ class SingleAgentClient {
2236
2270
  }
2237
2271
  return { success: true };
2238
2272
  }
2239
- const client = await connectMCPWithFallback(
2240
- new URL(url),
2241
- authHeaders,
2242
- [],
2243
- "endpoint discovery",
2244
- transport?.trustedFetchFn,
2273
+ const shared = await withScopedLegacyConnection(
2245
2274
  {
2275
+ agentUrl: url,
2276
+ authToken,
2277
+ customHeaders: agentHeaders,
2278
+ authProvider,
2246
2279
  signal: options?.signal,
2247
2280
  requestTimeoutMs: transport?.requestTimeoutMs,
2281
+ fetchFn: transport?.trustedFetchFn,
2248
2282
  allowPrivateIp: transport?.allowPrivateIp
2249
- }
2283
+ },
2284
+ "endpoint discovery",
2285
+ async () => void 0
2250
2286
  );
2251
- await client.close();
2287
+ if (!shared) {
2288
+ const client = await connectMCPWithFallback(
2289
+ new URL(url),
2290
+ authHeaders,
2291
+ [],
2292
+ "endpoint discovery",
2293
+ transport?.trustedFetchFn,
2294
+ {
2295
+ signal: options?.signal,
2296
+ requestTimeoutMs: transport?.requestTimeoutMs,
2297
+ allowPrivateIp: transport?.allowPrivateIp
2298
+ }
2299
+ );
2300
+ await client.close();
2301
+ }
2252
2302
  if (mayRetain()) {
2253
2303
  this.discoveredMcpEra = "legacy";
2254
2304
  this.discoveredMcpEraAt = Date.now();
@@ -2265,7 +2315,8 @@ class SingleAgentClient {
2265
2315
  }
2266
2316
  const errObj = error;
2267
2317
  const status = errObj?.status || errObj?.response?.status || errObj?.cause?.status;
2268
- return { success: false, status, error };
2318
+ const retryAfter = retryAfterOf(error);
2319
+ return { success: false, status, ...retryAfter !== void 0 && { retryAfter }, error };
2269
2320
  }
2270
2321
  };
2271
2322
  const urlsToTry = [];
@@ -2288,6 +2339,9 @@ class SingleAgentClient {
2288
2339
  firstWorkingUrl = url;
2289
2340
  break;
2290
2341
  }
2342
+ if (result.status === 429 || result.status === 503 && result.retryAfter !== void 0) {
2343
+ throw new import_errors.AgentRateLimitedError(url, result.status, result.retryAfter, result.error);
2344
+ }
2291
2345
  if (result.status === 401) {
2292
2346
  got401 = true;
2293
2347
  first401Error ??= result.error;
@@ -2564,6 +2618,24 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2564
2618
  };
2565
2619
  }
2566
2620
  }
2621
+ let artifactPayloadValidator;
2622
+ if (registration?.deliveryKind === "artifact") {
2623
+ try {
2624
+ const loader = require('../validation/schema-loader.js');
2625
+ artifactPayloadValidator = loader.getSchemaValidatorByRef(
2626
+ "content-standards/artifact-webhook-payload.json",
2627
+ this.resolvedAdcpVersion
2628
+ );
2629
+ if (!artifactPayloadValidator) throw new import_errors.ConfigurationError("Bundled artifact webhook schema is unavailable.");
2630
+ } catch (cause) {
2631
+ return {
2632
+ ok: false,
2633
+ code: "webhook_verification_unavailable",
2634
+ message: "Artifact webhook schema configuration is unavailable.",
2635
+ cause
2636
+ };
2637
+ }
2638
+ }
2567
2639
  if (registration?.mode === "rfc9421") {
2568
2640
  const { verifyWebBotAuth, selectSignatureProfile, WebBotAuthError, WebBotAuthUnavailableError } = loadWebBotAuth();
2569
2641
  const requestMethod = options.requestMethod;
@@ -2738,7 +2810,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2738
2810
  const isReport = registration.deliveryKind === "reporting";
2739
2811
  const payload = isReport ? body.result : body;
2740
2812
  const schemaRef = isReport ? "media-buy/media-buy-delivery-webhook-result.json" : "content-standards/artifact-webhook-payload.json";
2741
- const validator = loader.getSchemaValidatorByRef(schemaRef, this.resolvedAdcpVersion);
2813
+ const validator = isReport ? loader.getSchemaValidatorByRef(schemaRef, this.resolvedAdcpVersion) : artifactPayloadValidator;
2742
2814
  const envelopeValidator = isReport ? loader.getSchemaValidatorByRef("core/mcp-webhook-payload.json", this.resolvedAdcpVersion) : void 0;
2743
2815
  if (!validator || !validator(payload) || isReport && (!envelopeValidator || !envelopeValidator(body) || body.task_type !== "media_buy_delivery"))
2744
2816
  return {
@@ -3500,17 +3572,32 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
3500
3572
  timestamp
3501
3573
  }).ok;
3502
3574
  }
3503
- /**
3504
- * Execute task and call appropriate handler on completion
3505
- *
3506
- * Adapts requests for maintained AdCP 3 releases and normalizes product responses.
3507
- */
3575
+ /** One task owns discovery and dispatch sessions unless the caller already owns reuse. */
3576
+ withConnectionScope(options, run, preserveSessionOnResult) {
3577
+ const transport = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport);
3578
+ return (0, import_mcp_connection_policy.withMCPConnectionPolicy)(
3579
+ transport,
3580
+ () => (0, import_mcp_connection_policy.shouldReuseMCPConnection)(transport?.trustedFetchFn !== void 0) ? run() : (0, import_mcp_scope.withMCPConnectionScope)(run, {
3581
+ signal: options?.signal,
3582
+ preserveOnInterruption: true,
3583
+ preserveSessionOnResult
3584
+ })
3585
+ );
3586
+ }
3587
+ withTaskConnectionScope(options, run) {
3588
+ return (0, import_task_deadline.withTaskDeadline)(
3589
+ options,
3590
+ (effective) => this.withConnectionScope(effective, () => run(effective), isNonterminalTaskResult)
3591
+ );
3592
+ }
3593
+ /** Execute a task, adapt maintained AdCP 3 releases, and call the completion handler. */
3508
3594
  async executeAndHandle(taskType, handlerName, params, inputHandler, options, transformCompletedResponse, legacyFormatConverter, canonicalRequest, projectionCatalogs) {
3595
+ const projectionDrifts = (0, import_legacy_metadata.getCreativeDeliveryDiagnostics)(params);
3509
3596
  const requestParamsSnapshot = structuredClone(params);
3510
3597
  const canonicalRequestSnapshot = canonicalRequest === void 0 ? void 0 : structuredClone(canonicalRequest);
3511
3598
  const deferredProjectionCatalogs = projectionCatalogs ? structuredClone(projectionCatalogs) : void 0;
3512
3599
  const taskOptionsSnapshot = snapshotTaskOptions(options);
3513
- return (0, import_task_deadline.withTaskDeadline)(
3600
+ return this.withTaskConnectionScope(
3514
3601
  taskOptionsSnapshot,
3515
3602
  (effectiveOptions) => this.executeAndHandleWithinDeadline(
3516
3603
  taskType,
@@ -3521,11 +3608,12 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
3521
3608
  transformCompletedResponse,
3522
3609
  legacyFormatConverter,
3523
3610
  canonicalRequestSnapshot,
3524
- deferredProjectionCatalogs
3611
+ deferredProjectionCatalogs,
3612
+ projectionDrifts
3525
3613
  )
3526
3614
  );
3527
3615
  }
3528
- async executeAndHandleWithinDeadline(taskType, handlerName, params, inputHandler, options, transformCompletedResponse, legacyFormatConverter, canonicalRequest, projectionCatalogs) {
3616
+ async executeAndHandleWithinDeadline(taskType, handlerName, params, inputHandler, options, transformCompletedResponse, legacyFormatConverter, canonicalRequest, projectionCatalogs, projectionDrifts = []) {
3529
3617
  (0, import_abort2.throwIfAborted)(options?.signal);
3530
3618
  const canonicalCreativeInvocation = CANONICAL_CREATIVE_ACTIVITY_TASKS.has(taskType) || canonicalRequest !== void 0;
3531
3619
  params = await this.applyAccountPolicy(taskType, params, options);
@@ -3601,7 +3689,15 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
3601
3689
  if (negotiatedRelease?.downgraded && !options?.skipIdempotencyAutoInject && !options?.skipAccountValidation && !options?.skipRequestValidation) {
3602
3690
  this.executor.validateRequest(taskType, adaptedParams, inputSchemaStripLogs, negotiatedRelease.version);
3603
3691
  }
3604
- const adaptationLogs = [...adaptDriftLogs];
3692
+ const adaptationLogs = [
3693
+ ...projectionDrifts.map((drift) => ({
3694
+ ...drift,
3695
+ taskName: taskType,
3696
+ clientVersion: this.resolvedAdcpVersion,
3697
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
3698
+ })),
3699
+ ...adaptDriftLogs
3700
+ ];
3605
3701
  if (webhookDriftLog) adaptationLogs.push(webhookDriftLog);
3606
3702
  const canonicalInputHandler = this.canonicalCreativeInputHandler(
3607
3703
  taskType,
@@ -4710,8 +4806,15 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4710
4806
  * stamps it on the version envelope and validates the response against it.
4711
4807
  */
4712
4808
  withNegotiatedRelease(options, negotiated) {
4713
- if (!negotiated?.downgraded) return options;
4714
- return { ...options ?? {}, wireAdcpVersion: negotiated.version, negotiatedAdcpVersion: negotiated.version };
4809
+ if (!negotiated) return options;
4810
+ return {
4811
+ ...options ?? {},
4812
+ selectedAdcpVersion: negotiated.version,
4813
+ ...negotiated.downgraded && {
4814
+ wireAdcpVersion: negotiated.version,
4815
+ negotiatedAdcpVersion: negotiated.version
4816
+ }
4817
+ };
4715
4818
  }
4716
4819
  /**
4717
4820
  * Refuse a tool the negotiated release does not define (a 3.2-only task
@@ -4980,8 +5083,9 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4980
5083
  const adapterKey = (0, import_version2.resolveAdapterKey)(this.resolvedAdcpVersion, perCallCapabilities ?? this.cachedCapabilities);
4981
5084
  if (adapterKey) {
4982
5085
  const versionAdapter = (0, import_version2.getVersionAdapter)(adapterKey, taskType);
4983
- if (versionAdapter?.adaptRequest) {
4984
- const result = versionAdapter.adaptRequest(adapted);
5086
+ const adaptRequest = negotiated ? versionAdapter?.adaptRequest : versionAdapter?.adaptUnnegotiatedRequest ?? versionAdapter?.adaptRequest;
5087
+ if (adaptRequest) {
5088
+ const result = adaptRequest(adapted);
4985
5089
  adapted = result.params;
4986
5090
  if (result.drift) {
4987
5091
  driftLogs.push({
@@ -5043,7 +5147,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5043
5147
  legacyFormatConverter,
5044
5148
  projectionCatalogs ?? this.config.projectionCatalogs
5045
5149
  );
5046
- return (0, import_task_deadline.withTaskDeadline)(snapshotTaskOptions(taskOptions), async (effectiveOptions) => {
5150
+ return this.withTaskConnectionScope(snapshotTaskOptions(taskOptions), async (effectiveOptions) => {
5047
5151
  this.assertRequestSupportedByConfiguredVersion("get_products", params, effectiveOptions);
5048
5152
  let request = await this.applyAccountPolicy("get_products", params, effectiveOptions);
5049
5153
  const legacyAccountId = request.account_id;
@@ -5226,13 +5330,13 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5226
5330
  async createMediaBuy(params, inputHandler, options) {
5227
5331
  assertRawMethodForGovernedPayload("create_media_buy", options);
5228
5332
  this.assertDurableProjectionOverrideSupported(options?.legacyFormatConverter);
5229
- const requestSnapshot = (0, import_legacy_metadata.structuredCloneWithLegacyCreativeMetadata)(params);
5333
+ const requestSnapshot = (0, import_legacy_metadata2.structuredCloneWithLegacyCreativeMetadata)(params);
5230
5334
  const projectionCatalogs = options?.projectionCatalogs ? structuredClone(options.projectionCatalogs) : void 0;
5231
5335
  const snapshottedOptions = {
5232
5336
  ...snapshotTaskOptions(options),
5233
5337
  ...projectionCatalogs !== void 0 && { projectionCatalogs }
5234
5338
  };
5235
- return (0, import_task_deadline.withTaskDeadline)(
5339
+ return this.withTaskConnectionScope(
5236
5340
  snapshottedOptions,
5237
5341
  (effectiveOptions) => this.createMediaBuyWithinDeadline(requestSnapshot, inputHandler, effectiveOptions)
5238
5342
  );
@@ -5385,13 +5489,13 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5385
5489
  async updateMediaBuy(params, inputHandler, options) {
5386
5490
  assertRawMethodForGovernedPayload("update_media_buy", options);
5387
5491
  this.assertDurableProjectionOverrideSupported(options?.legacyFormatConverter);
5388
- const requestSnapshot = (0, import_legacy_metadata.structuredCloneWithLegacyCreativeMetadata)(params);
5492
+ const requestSnapshot = (0, import_legacy_metadata2.structuredCloneWithLegacyCreativeMetadata)(params);
5389
5493
  const projectionCatalogs = options?.projectionCatalogs ? structuredClone(options.projectionCatalogs) : void 0;
5390
5494
  const snapshottedOptions = {
5391
5495
  ...snapshotTaskOptions(options),
5392
5496
  ...projectionCatalogs !== void 0 && { projectionCatalogs }
5393
5497
  };
5394
- return (0, import_task_deadline.withTaskDeadline)(
5498
+ return this.withTaskConnectionScope(
5395
5499
  snapshottedOptions,
5396
5500
  (effectiveOptions) => this.updateMediaBuyWithinDeadline(requestSnapshot, inputHandler, effectiveOptions)
5397
5501
  );
@@ -5467,12 +5571,12 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5467
5571
  this.assertDurableProjectionOverrideSupported(
5468
5572
  options?.creativeFormatProjection?.legacyFormatConverter ?? options?.legacyFormatConverter
5469
5573
  );
5470
- const requestSnapshot = (0, import_legacy_metadata.structuredCloneWithLegacyCreativeMetadata)(params);
5574
+ const requestSnapshot = (0, import_legacy_metadata2.structuredCloneWithLegacyCreativeMetadata)(params);
5471
5575
  const projectionCatalogs = options?.projectionCatalogs ? structuredClone(options.projectionCatalogs) : void 0;
5472
5576
  const creativeFormatProjection = options?.creativeFormatProjection ? {
5473
5577
  ...options.creativeFormatProjection,
5474
5578
  ...options.creativeFormatProjection.selectorContainers !== void 0 && {
5475
- selectorContainers: (0, import_legacy_metadata.structuredCloneWithLegacyCreativeMetadata)(
5579
+ selectorContainers: (0, import_legacy_metadata2.structuredCloneWithLegacyCreativeMetadata)(
5476
5580
  options.creativeFormatProjection.selectorContainers
5477
5581
  )
5478
5582
  }
@@ -5482,7 +5586,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5482
5586
  ...projectionCatalogs !== void 0 && { projectionCatalogs },
5483
5587
  ...creativeFormatProjection !== void 0 && { creativeFormatProjection }
5484
5588
  };
5485
- return (0, import_task_deadline.withTaskDeadline)(
5589
+ return this.withTaskConnectionScope(
5486
5590
  snapshottedOptions,
5487
5591
  (effectiveOptions) => this.syncCreativesWithinDeadline(requestSnapshot, inputHandler, effectiveOptions)
5488
5592
  );
@@ -5640,10 +5744,10 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5640
5744
  const creativeRef = isPlainRecord(creative) ? optionRef(creative.format_option_ref) : void 0;
5641
5745
  if (isPlainRecord(creative) && creative.format_option_ref !== void 0 && !creativeRef) return false;
5642
5746
  const isSellerDeclaration = (value) => {
5643
- if (!isPlainRecord(value) || (0, import_legacy_metadata.sellerDeclaredFormatOption)(value) !== true || (0, import_legacy_metadata.isSynthesizedFormatOption)(value)) {
5747
+ if (!isPlainRecord(value) || (0, import_legacy_metadata2.sellerDeclaredFormatOption)(value) !== true || (0, import_legacy_metadata2.isSynthesizedFormatOption)(value)) {
5644
5748
  return false;
5645
5749
  }
5646
- const evidence2 = (0, import_legacy_metadata.sellerFormatEvidence)(value);
5750
+ const evidence2 = (0, import_legacy_metadata2.sellerFormatEvidence)(value);
5647
5751
  if (!evidence2 || evidence2.scopeKey !== scopeKey || typeof container.product_id === "string" && evidence2.productId !== container.product_id || evidence2.expiresAt <= Date.now() || evidence2.accountScope !== accountScope && evidence2.accountScope !== "none")
5648
5752
  return false;
5649
5753
  const ref = optionRef(value);
@@ -5657,7 +5761,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5657
5761
  };
5658
5762
  const declarations = [
5659
5763
  ...(Array.isArray(container.format_options) ? container.format_options : []).filter(isSellerDeclaration),
5660
- ...(0, import_legacy_metadata.selectedFormatOptions)(container).filter(isSellerDeclaration)
5764
+ ...(0, import_legacy_metadata2.selectedFormatOptions)(container).filter(isSellerDeclaration)
5661
5765
  ];
5662
5766
  if (typeof container.product_id === "string") {
5663
5767
  for (const ref of [...refs, ...creativeRef ? [creativeRef] : []]) {
@@ -5934,25 +6038,31 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5934
6038
  * Pass an explicit agent via options.agent to override.
5935
6039
  */
5936
6040
  async syncPlans(params, inputHandler, options) {
6041
+ if (!options?.agent && !this.config.governance?.campaign?.agent) {
6042
+ return this.executeTaskUnprojected("sync_plans", params, inputHandler, options);
6043
+ }
5937
6044
  const agent = options?.agent ?? this.getGovernanceAgent();
5938
6045
  this.executor.validateRequest("sync_plans", params);
5939
6046
  return this.executor.executeTask(agent, "sync_plans", params, inputHandler, options);
5940
6047
  }
5941
- /**
5942
- * Get governance audit logs for one or more plans.
5943
- * Returns budget state, channel allocation, per-campaign breakdown, and audit trail.
5944
- *
5945
- * Uses the governance agent from config.governance.campaign.agent by default.
5946
- * Pass an explicit agent via options.agent to override.
5947
- */
5948
- async getPlanAuditLogs(params, options) {
6048
+ async getPlanAuditLogs(params, inputHandlerOrOptions, taskOptions) {
6049
+ const inputHandler = typeof inputHandlerOrOptions === "function" ? inputHandlerOrOptions : void 0;
6050
+ const options = inputHandlerOrOptions === void 0 || typeof inputHandlerOrOptions === "function" ? taskOptions : inputHandlerOrOptions;
6051
+ if (!options?.agent && !this.config.governance?.campaign?.agent) {
6052
+ return this.executeTaskUnprojected(
6053
+ "get_plan_audit_logs",
6054
+ params,
6055
+ inputHandler,
6056
+ options
6057
+ );
6058
+ }
5949
6059
  const agent = options?.agent ?? this.getGovernanceAgent();
5950
6060
  this.executor.validateRequest("get_plan_audit_logs", params);
5951
6061
  return this.executor.executeTask(
5952
6062
  agent,
5953
6063
  "get_plan_audit_logs",
5954
6064
  params,
5955
- void 0,
6065
+ inputHandler,
5956
6066
  options
5957
6067
  );
5958
6068
  }
@@ -5990,6 +6100,374 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5990
6100
  }
5991
6101
  return agent;
5992
6102
  }
6103
+ async advertisesTool(taskName, options) {
6104
+ const context = {};
6105
+ const capabilities = await this.getCapabilities({
6106
+ ...options,
6107
+ [CAPABILITY_DISCOVERY_CONTEXT]: context
6108
+ });
6109
+ return capabilities.discoveredTools?.includes(taskName) === true || context.toolSchemas?.has(taskName) === true;
6110
+ }
6111
+ /** Accept a committed proposal to create or amend a media buy, or apply a negotiated cancellation. */
6112
+ async acceptProposal(params, inputHandler, options) {
6113
+ return this.executeTaskUnprojected(
6114
+ "accept_proposal",
6115
+ params,
6116
+ inputHandler,
6117
+ options
6118
+ );
6119
+ }
6120
+ /** Execute the AdCP acquire_rights tool. */
6121
+ async acquireRights(params, inputHandler, options) {
6122
+ return this.executeTaskUnprojected(
6123
+ "acquire_rights",
6124
+ params,
6125
+ inputHandler,
6126
+ options
6127
+ );
6128
+ }
6129
+ /** Generate, transform, refine, retrieve, or adapt creative manifests for advertised creative capabilities. */
6130
+ async buildCreative(params, inputHandler, options) {
6131
+ return this.executeTaskUnprojected(
6132
+ "build_creative",
6133
+ params,
6134
+ inputHandler,
6135
+ options
6136
+ );
6137
+ }
6138
+ /** Create a media buy directly from published seller products and record its accepted commercial snapshot. */
6139
+ async buyProducts(params, inputHandler, options) {
6140
+ return this.executeTaskUnprojected("buy_products", params, inputHandler, options);
6141
+ }
6142
+ /** Execute the AdCP calibrate_content tool. */
6143
+ async calibrateContent(params, inputHandler, options) {
6144
+ return this.executeTaskUnprojected(
6145
+ "calibrate_content",
6146
+ params,
6147
+ inputHandler,
6148
+ options
6149
+ );
6150
+ }
6151
+ /** Execute the AdCP check_governance tool. */
6152
+ async checkGovernance(params, inputHandler, options) {
6153
+ return this.executeTaskUnprojected(
6154
+ "check_governance",
6155
+ params,
6156
+ inputHandler,
6157
+ options
6158
+ );
6159
+ }
6160
+ /** Control a seller compliance scenario. Intended for conformance testing. */
6161
+ async complyTestController(params, inputHandler, options) {
6162
+ return this.executeTaskUnprojected(
6163
+ "comply_test_controller",
6164
+ params,
6165
+ inputHandler,
6166
+ options
6167
+ );
6168
+ }
6169
+ /** Rename, pause, resume, cancel, or adjust delivery controls within accepted proposal change rights. */
6170
+ async controlMediaBuy(params, inputHandler, options) {
6171
+ return this.executeTaskUnprojected(
6172
+ "control_media_buy",
6173
+ params,
6174
+ inputHandler,
6175
+ options
6176
+ );
6177
+ }
6178
+ /** Execute the AdCP create_collection_list tool. */
6179
+ async createCollectionList(params, inputHandler, options) {
6180
+ return this.executeTaskUnprojected(
6181
+ "create_collection_list",
6182
+ params,
6183
+ inputHandler,
6184
+ options
6185
+ );
6186
+ }
6187
+ /** Execute the AdCP create_content_standards tool. */
6188
+ async createContentStandards(params, inputHandler, options) {
6189
+ return this.executeTaskUnprojected(
6190
+ "create_content_standards",
6191
+ params,
6192
+ inputHandler,
6193
+ options
6194
+ );
6195
+ }
6196
+ /** Terminally decline one or more proposals and record the buyer's reason. */
6197
+ async declineProposals(params, inputHandler, options) {
6198
+ return this.executeTaskUnprojected(
6199
+ "decline_proposals",
6200
+ params,
6201
+ inputHandler,
6202
+ options
6203
+ );
6204
+ }
6205
+ /** Execute the AdCP delete_collection_list tool. */
6206
+ async deleteCollectionList(params, inputHandler, options) {
6207
+ return this.executeTaskUnprojected(
6208
+ "delete_collection_list",
6209
+ params,
6210
+ inputHandler,
6211
+ options
6212
+ );
6213
+ }
6214
+ /** Retrieve spend, credit or balance status, and invoice history for an operator-billed account. */
6215
+ async getAccountFinancials(params, inputHandler, options) {
6216
+ return this.executeTaskUnprojected(
6217
+ "get_account_financials",
6218
+ params,
6219
+ inputHandler,
6220
+ options
6221
+ );
6222
+ }
6223
+ /** Execute the AdCP get_brand_identity tool. */
6224
+ async getBrandIdentity(params, inputHandler, options) {
6225
+ return this.executeTaskUnprojected(
6226
+ "get_brand_identity",
6227
+ params,
6228
+ inputHandler,
6229
+ options
6230
+ );
6231
+ }
6232
+ /** Execute the AdCP get_collection_list tool. */
6233
+ async getCollectionList(params, inputHandler, options) {
6234
+ return this.executeTaskUnprojected(
6235
+ "get_collection_list",
6236
+ params,
6237
+ inputHandler,
6238
+ options
6239
+ );
6240
+ }
6241
+ /** Execute the AdCP get_content_standards tool. */
6242
+ async getContentStandards(params, inputHandler, options) {
6243
+ return this.executeTaskUnprojected(
6244
+ "get_content_standards",
6245
+ params,
6246
+ inputHandler,
6247
+ options
6248
+ );
6249
+ }
6250
+ /** Evaluate a creative manifest and return scored safety, content, quality, and governance features. */
6251
+ async getCreativeFeatures(params, inputHandler, options) {
6252
+ return this.executeTaskUnprojected(
6253
+ "get_creative_features",
6254
+ params,
6255
+ inputHandler,
6256
+ options
6257
+ );
6258
+ }
6259
+ /** Execute the AdCP get_media_buy_artifacts tool. */
6260
+ async getMediaBuyArtifacts(params, inputHandler, options) {
6261
+ return this.executeTaskUnprojected(
6262
+ "get_media_buy_artifacts",
6263
+ params,
6264
+ inputHandler,
6265
+ options
6266
+ );
6267
+ }
6268
+ /** Check reporting health, enumerate expected periods and all retained revisions, or resolve one exact reporting revision. */
6269
+ async getReportingStatus(params, inputHandler, options) {
6270
+ return this.executeTaskUnprojected(
6271
+ "get_reporting_status",
6272
+ params,
6273
+ inputHandler,
6274
+ options
6275
+ );
6276
+ }
6277
+ /** Execute the AdCP get_rights tool. */
6278
+ async getRights(params, inputHandler, options) {
6279
+ return this.executeTaskUnprojected("get_rights", params, inputHandler, options);
6280
+ }
6281
+ /** Execute the AdCP list_collection_lists tool. */
6282
+ async listCollectionLists(params, inputHandler, options) {
6283
+ return this.executeTaskUnprojected(
6284
+ "list_collection_lists",
6285
+ params,
6286
+ inputHandler,
6287
+ options
6288
+ );
6289
+ }
6290
+ /** Execute the AdCP list_content_standards tool. */
6291
+ async listContentStandards(params, inputHandler, options) {
6292
+ return this.executeTaskUnprojected(
6293
+ "list_content_standards",
6294
+ params,
6295
+ inputHandler,
6296
+ options
6297
+ );
6298
+ }
6299
+ /** Execute the AdCP list_creative_formats tool. */
6300
+ async listCreativeFormats(params, inputHandler, options) {
6301
+ return this.executeTaskUnprojected(
6302
+ "list_creative_formats",
6303
+ params,
6304
+ inputHandler,
6305
+ options
6306
+ );
6307
+ }
6308
+ /** Discover account-scoped creative transformers and their selectable configuration options. */
6309
+ async listTransformers(params, inputHandler, options) {
6310
+ return this.executeTaskUnprojected(
6311
+ "list_transformers",
6312
+ params,
6313
+ inputHandler,
6314
+ options
6315
+ );
6316
+ }
6317
+ /** Log batches of marketing events against a configured event source for measurement and attribution. */
6318
+ async logEvent(params, inputHandler, options) {
6319
+ return this.executeTaskUnprojected("log_event", params, inputHandler, options);
6320
+ }
6321
+ /** Revise draft proposals, finalize them into committed, inventory-held snapshots, or extend a committed hold. */
6322
+ async refineProposals(params, inputHandler, options) {
6323
+ return this.executeTask("refine_proposals", params, inputHandler, options);
6324
+ }
6325
+ /** Execute the AdCP report_plan_adjustment tool. */
6326
+ async reportPlanAdjustment(params, inputHandler, options) {
6327
+ return this.executeTaskUnprojected(
6328
+ "report_plan_adjustment",
6329
+ params,
6330
+ inputHandler,
6331
+ options
6332
+ );
6333
+ }
6334
+ /** Execute the AdCP report_plan_outcome tool. */
6335
+ async reportPlanOutcome(params, inputHandler, options) {
6336
+ return this.executeTaskUnprojected(
6337
+ "report_plan_outcome",
6338
+ params,
6339
+ inputHandler,
6340
+ options
6341
+ );
6342
+ }
6343
+ /** Report vendor-service consumption and final measurements for revenue tracking and billing reconciliation. */
6344
+ async reportUsage(params, inputHandler, options) {
6345
+ return this.executeTaskUnprojected("report_usage", params, inputHandler, options);
6346
+ }
6347
+ /** Ask a seller to create one or more draft media-plan proposals from a campaign brief. */
6348
+ async requestProposals(params, inputHandler, options) {
6349
+ return this.executeTask("request_proposals", params, inputHandler, options);
6350
+ }
6351
+ /** Execute the AdCP search_brands tool. */
6352
+ async searchBrands(params, inputHandler, options) {
6353
+ return this.executeTaskUnprojected("search_brands", params, inputHandler, options);
6354
+ }
6355
+ /** Register, replace, pause, or clear caller-scoped webhooks for agent-level notifications. */
6356
+ async syncAgentNotificationConfigs(params, inputHandler, options) {
6357
+ return this.executeTaskUnprojected(
6358
+ "sync_agent_notification_configs",
6359
+ params,
6360
+ inputHandler,
6361
+ options
6362
+ );
6363
+ }
6364
+ /** List or synchronize buyer-managed account catalog feeds, suppress or restore specific items, and read current availability state. */
6365
+ async syncCatalogs(params, inputHandler, options) {
6366
+ return this.executeTaskUnprojected("sync_catalogs", params, inputHandler, options);
6367
+ }
6368
+ /** List or synchronize account event sources with upsert and optional replacement semantics. */
6369
+ async syncEventSources(params, inputHandler, options) {
6370
+ return this.executeTaskUnprojected(
6371
+ "sync_event_sources",
6372
+ params,
6373
+ inputHandler,
6374
+ options
6375
+ );
6376
+ }
6377
+ /** Bind or replace the governance agent used for approval across specific advertiser accounts. */
6378
+ async syncGovernance(params, inputHandler, options) {
6379
+ return this.executeTaskUnprojected(
6380
+ "sync_governance",
6381
+ params,
6382
+ inputHandler,
6383
+ options
6384
+ );
6385
+ }
6386
+ /** Record a consumer's independently verified reporting totals and destination evidence in the seller ledger. */
6387
+ async syncReportingReceipts(params, inputHandler, options) {
6388
+ return this.executeTaskUnprojected(
6389
+ "sync_reporting_receipts",
6390
+ params,
6391
+ inputHandler,
6392
+ options
6393
+ );
6394
+ }
6395
+ /** Tell a seller whether expected reporting was received, omitted, missing, unreadable, or contradictory. */
6396
+ async syncReportingStatus(params, inputHandler, options) {
6397
+ return this.executeTaskUnprojected(
6398
+ "sync_reporting_status",
6399
+ params,
6400
+ inputHandler,
6401
+ options
6402
+ );
6403
+ }
6404
+ /** Execute the AdCP update_collection_list tool. */
6405
+ async updateCollectionList(params, inputHandler, options) {
6406
+ return this.executeTaskUnprojected(
6407
+ "update_collection_list",
6408
+ params,
6409
+ inputHandler,
6410
+ options
6411
+ );
6412
+ }
6413
+ /** Execute the AdCP update_content_standards tool. */
6414
+ async updateContentStandards(params, inputHandler, options) {
6415
+ return this.executeTaskUnprojected(
6416
+ "update_content_standards",
6417
+ params,
6418
+ inputHandler,
6419
+ options
6420
+ );
6421
+ }
6422
+ /** Execute the AdCP update_rights tool. */
6423
+ async updateRights(params, inputHandler, options) {
6424
+ return this.executeTaskUnprojected("update_rights", params, inputHandler, options);
6425
+ }
6426
+ /** Execute the AdCP validate_content_delivery tool. */
6427
+ async validateContentDelivery(params, inputHandler, options) {
6428
+ return this.executeTaskUnprojected(
6429
+ "validate_content_delivery",
6430
+ params,
6431
+ inputHandler,
6432
+ options
6433
+ );
6434
+ }
6435
+ /** Preflight a creative manifest against canonical formats, products, third-party formats, or agent capabilities. */
6436
+ async validateInput(params, inputHandler, options) {
6437
+ return this.executeTaskUnprojected(
6438
+ "validate_input",
6439
+ params,
6440
+ inputHandler,
6441
+ options
6442
+ );
6443
+ }
6444
+ /** Execute the AdCP validate_property_delivery tool. */
6445
+ async validatePropertyDelivery(params, inputHandler, options) {
6446
+ return this.executeTaskUnprojected(
6447
+ "validate_property_delivery",
6448
+ params,
6449
+ inputHandler,
6450
+ options
6451
+ );
6452
+ }
6453
+ /** Execute the AdCP verify_brand_claim tool. */
6454
+ async verifyBrandClaim(params, inputHandler, options) {
6455
+ return this.executeTaskUnprojected(
6456
+ "verify_brand_claim",
6457
+ params,
6458
+ inputHandler,
6459
+ options
6460
+ );
6461
+ }
6462
+ /** Execute the AdCP verify_brand_claims tool. */
6463
+ async verifyBrandClaims(params, inputHandler, options) {
6464
+ return this.executeTaskUnprojected(
6465
+ "verify_brand_claims",
6466
+ params,
6467
+ inputHandler,
6468
+ options
6469
+ );
6470
+ }
5993
6471
  // ====== PROTOCOL TASKS ======
5994
6472
  /**
5995
6473
  * Get AdCP capabilities
@@ -5999,7 +6477,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5999
6477
  * @param options - Task execution options
6000
6478
  */
6001
6479
  async getAdcpCapabilities(params, inputHandler, options) {
6002
- return (0, import_task_deadline.withTaskDeadline)(
6480
+ return this.withTaskConnectionScope(
6003
6481
  snapshotTaskOptions(options),
6004
6482
  (effectiveOptions) => this.getAdcpCapabilitiesWithinDeadline(params, inputHandler, effectiveOptions)
6005
6483
  );
@@ -6081,7 +6559,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
6081
6559
  );
6082
6560
  }
6083
6561
  async resolveAccount(hints = {}, options, onTaskResult) {
6084
- return (0, import_task_deadline.withTaskDeadline)(snapshotTaskOptions(options), async (effectiveOptions) => {
6562
+ return this.withTaskConnectionScope(snapshotTaskOptions(options), async (effectiveOptions) => {
6085
6563
  const capabilities = await this.getCapabilities(effectiveOptions);
6086
6564
  if (capabilities._synthetic || !capabilities.account) {
6087
6565
  throw new import_errors3.AccountRequiredError(
@@ -6521,6 +6999,12 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
6521
6999
  return this.getMediaBuyDelivery(params, inputHandler, options);
6522
7000
  case "get_creative_delivery":
6523
7001
  return this.getCreativeDelivery(params, inputHandler, options);
7002
+ case "preview_creative":
7003
+ return this.previewCreative(params, inputHandler, options);
7004
+ case "sync_plans":
7005
+ return this.syncPlans(params, inputHandler, options);
7006
+ case "get_plan_audit_logs":
7007
+ return this.getPlanAuditLogs(params, inputHandler, options);
6524
7008
  case "get_principal":
6525
7009
  return this.getPrincipal(params, inputHandler, options);
6526
7010
  case "sync_principal":
@@ -6557,7 +7041,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
6557
7041
  async executeTaskUnprojected(taskName, params, inputHandler, options, handlerName, beforeDispatch) {
6558
7042
  const requestParamsSnapshot = structuredClone(params);
6559
7043
  const taskOptionsSnapshot = snapshotTaskOptions(options);
6560
- return (0, import_task_deadline.withTaskDeadline)(taskOptionsSnapshot, async (effectiveOptions) => {
7044
+ return this.withTaskConnectionScope(taskOptionsSnapshot, async (effectiveOptions) => {
6561
7045
  const result = await this.executeTaskUnprojectedWithinDeadline(
6562
7046
  taskName,
6563
7047
  requestParamsSnapshot,
@@ -6599,6 +7083,11 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
6599
7083
  const serverVersion = await this.detectServerVersion(detectionOptions);
6600
7084
  detectedServerVersion = serverVersion;
6601
7085
  detectedServerVersionSynthetic = capabilityDiscoveryContext.capabilities?._synthetic;
7086
+ if ((taskName === "sync_plans" || taskName === "get_plan_audit_logs") && capabilityDiscoveryContext.capabilities?.discoveredTools?.includes(taskName) !== true && capabilityDiscoveryContext.toolSchemas?.has(taskName) !== true) {
7087
+ throw new import_errors.ConfigurationError(
7088
+ `No governance agent configured and this agent does not advertise ${taskName}. Pass options.agent or configure governance.campaign.agent.`
7089
+ );
7090
+ }
6602
7091
  const negotiatedRelease = this.negotiateCallRelease(capabilityDiscoveryContext.capabilities, options);
6603
7092
  this.assertToolAvailableAtRelease(taskName, negotiatedRelease, capabilityDiscoveryContext.toolSchemas);
6604
7093
  this.assertRequestSupportedByTargetVersion(
@@ -6972,21 +7461,10 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
6972
7461
  });
6973
7462
  });
6974
7463
  }
6975
- // ====== TASK MANAGEMENT & NOTIFICATIONS ======
6976
- /**
6977
- * List all tasks for this agent with detailed information
6978
- *
6979
- * @returns Promise resolving to array of task information
6980
- *
6981
- * @example
6982
- * ```typescript
6983
- * const tasks = await client.listTasks();
6984
- * tasks.forEach(task => {
6985
- * console.log(`${task.taskName}: ${task.status}`);
6986
- * });
6987
- * ```
6988
- */
6989
- async listTasks() {
7464
+ async listTasks(params, inputHandler, options) {
7465
+ if (params !== void 0) {
7466
+ return this.executeTaskUnprojected("list_tasks", params, inputHandler, options);
7467
+ }
6990
7468
  const tasks = await this.executor.getTaskList(this.agent.id);
6991
7469
  return tasks.map(
6992
7470
  (task) => (0, import_request_proposals_guard.assertNativeRequestProposalsTask)(
@@ -7136,10 +7614,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
7136
7614
  * ```
7137
7615
  */
7138
7616
  async getAgentInfo(options) {
7139
- return (0, import_mcp_connection_policy.withMCPConnectionPolicy)(
7140
- (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport),
7141
- () => this.getAgentInfoWithConnectionPolicy(options)
7142
- );
7617
+ return this.withConnectionScope(options, () => this.getAgentInfoWithConnectionPolicy(options));
7143
7618
  }
7144
7619
  async getAgentInfoWithConnectionPolicy(options) {
7145
7620
  (0, import_abort2.throwIfAborted)(options?.signal);
@@ -7390,10 +7865,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
7390
7865
  * ```
7391
7866
  */
7392
7867
  async getCapabilities(options) {
7393
- return (0, import_mcp_connection_policy.withMCPConnectionPolicy)(
7394
- (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport),
7395
- () => this.getCapabilitiesWithConnectionPolicy(options)
7396
- );
7868
+ return this.withConnectionScope(options, () => this.getCapabilitiesWithConnectionPolicy(options));
7397
7869
  }
7398
7870
  async getCapabilitiesWithConnectionPolicy(options) {
7399
7871
  (0, import_abort2.throwIfAborted)(options?.signal);