@adcp/sdk 14.0.0 → 14.2.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 (234) hide show
  1. package/dist/lib/adapters/implicit-account-store.d.mts +12 -7
  2. package/dist/lib/adapters/implicit-account-store.d.ts +12 -7
  3. package/dist/lib/adapters/implicit-account-store.js +69 -15
  4. package/dist/lib/adapters/implicit-account-store.mjs +69 -15
  5. package/dist/lib/core/AgentClient.d.mts +1 -0
  6. package/dist/lib/core/AgentClient.d.ts +1 -0
  7. package/dist/lib/core/AgentClient.js +3 -0
  8. package/dist/lib/core/AgentClient.mjs +3 -0
  9. package/dist/lib/core/SingleAgentClient.d.mts +35 -2
  10. package/dist/lib/core/SingleAgentClient.d.ts +35 -2
  11. package/dist/lib/core/SingleAgentClient.js +377 -36
  12. package/dist/lib/core/SingleAgentClient.mjs +387 -38
  13. package/dist/lib/core/TaskExecutor.d.mts +3 -1
  14. package/dist/lib/core/TaskExecutor.d.ts +3 -1
  15. package/dist/lib/core/TaskExecutor.js +17 -12
  16. package/dist/lib/core/TaskExecutor.mjs +17 -12
  17. package/dist/lib/core/account-key.d.mts +3 -0
  18. package/dist/lib/core/account-key.d.ts +3 -0
  19. package/dist/lib/core/account-key.js +41 -0
  20. package/dist/lib/core/account-key.mjs +17 -0
  21. package/dist/lib/core/account-resolution.d.mts +2 -0
  22. package/dist/lib/core/account-resolution.d.ts +2 -0
  23. package/dist/lib/core/buyer-account-registry.d.mts +93 -0
  24. package/dist/lib/core/buyer-account-registry.d.ts +93 -0
  25. package/dist/lib/core/buyer-account-registry.js +602 -0
  26. package/dist/lib/core/buyer-account-registry.mjs +578 -0
  27. package/dist/lib/core/product-cache.d.mts +18 -0
  28. package/dist/lib/core/product-cache.d.ts +18 -0
  29. package/dist/lib/core/product-cache.js +137 -0
  30. package/dist/lib/core/product-cache.mjs +112 -0
  31. package/dist/lib/errors/index.d.mts +40 -1
  32. package/dist/lib/errors/index.d.ts +40 -1
  33. package/dist/lib/errors/index.js +69 -3
  34. package/dist/lib/errors/index.mjs +64 -3
  35. package/dist/lib/governance/authorization.d.mts +17 -1
  36. package/dist/lib/governance/authorization.d.ts +17 -1
  37. package/dist/lib/governance/authorization.js +55 -7
  38. package/dist/lib/governance/authorization.mjs +59 -7
  39. package/dist/lib/governance/index.d.mts +2 -2
  40. package/dist/lib/governance/index.d.ts +2 -2
  41. package/dist/lib/governance/index.js +2 -0
  42. package/dist/lib/governance/index.mjs +3 -1
  43. package/dist/lib/index.d.mts +7 -4
  44. package/dist/lib/index.d.ts +7 -4
  45. package/dist/lib/index.js +29 -0
  46. package/dist/lib/index.mjs +31 -1
  47. package/dist/lib/net/agent-transport-fetch.d.mts +4 -0
  48. package/dist/lib/net/agent-transport-fetch.d.ts +4 -0
  49. package/dist/lib/net/agent-transport-fetch.js +18 -5
  50. package/dist/lib/net/agent-transport-fetch.mjs +17 -5
  51. package/dist/lib/protocols/a2a.js +9 -1
  52. package/dist/lib/protocols/a2a.mjs +9 -1
  53. package/dist/lib/protocols/index.js +9 -2
  54. package/dist/lib/protocols/index.mjs +9 -2
  55. package/dist/lib/protocols/mcp-modern.js +2 -1
  56. package/dist/lib/protocols/mcp-modern.mjs +2 -1
  57. package/dist/lib/protocols/mcp.js +5 -2
  58. package/dist/lib/protocols/mcp.mjs +5 -2
  59. package/dist/lib/protocols/rawResponseCapture.d.mts +6 -0
  60. package/dist/lib/protocols/rawResponseCapture.d.ts +6 -0
  61. package/dist/lib/protocols/rawResponseCapture.js +41 -29
  62. package/dist/lib/protocols/rawResponseCapture.mjs +40 -29
  63. package/dist/lib/protocols/signedRequestRejection.d.mts +9 -0
  64. package/dist/lib/protocols/signedRequestRejection.d.ts +9 -0
  65. package/dist/lib/protocols/signedRequestRejection.js +209 -0
  66. package/dist/lib/protocols/signedRequestRejection.mjs +189 -0
  67. package/dist/lib/protocols/transportDiagnostics.d.mts +1 -0
  68. package/dist/lib/protocols/transportDiagnostics.d.ts +1 -0
  69. package/dist/lib/protocols/transportDiagnostics.js +2 -0
  70. package/dist/lib/protocols/transportDiagnostics.mjs +1 -0
  71. package/dist/lib/registry/types.generated.d.mts +112 -45
  72. package/dist/lib/registry/types.generated.d.ts +112 -45
  73. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  74. package/dist/lib/server/account-provisioning.d.mts +2 -0
  75. package/dist/lib/server/account-provisioning.d.ts +2 -0
  76. package/dist/lib/server/account-provisioning.js +30 -0
  77. package/dist/lib/server/account-provisioning.mjs +6 -0
  78. package/dist/lib/server/account-reference-warnings.d.mts +12 -0
  79. package/dist/lib/server/account-reference-warnings.d.ts +12 -0
  80. package/dist/lib/server/account-reference-warnings.js +48 -0
  81. package/dist/lib/server/account-reference-warnings.mjs +23 -0
  82. package/dist/lib/server/auth-signature.js +1 -0
  83. package/dist/lib/server/auth-signature.mjs +1 -0
  84. package/dist/lib/server/create-adcp-server.d.mts +34 -0
  85. package/dist/lib/server/create-adcp-server.d.ts +34 -0
  86. package/dist/lib/server/create-adcp-server.js +225 -14
  87. package/dist/lib/server/create-adcp-server.mjs +225 -14
  88. package/dist/lib/server/decisioning/account.d.mts +2 -0
  89. package/dist/lib/server/decisioning/account.d.ts +2 -0
  90. package/dist/lib/server/decisioning/runtime/from-platform.js +49 -10
  91. package/dist/lib/server/decisioning/runtime/from-platform.mjs +49 -10
  92. package/dist/lib/server/index.d.mts +2 -2
  93. package/dist/lib/server/index.d.ts +2 -2
  94. package/dist/lib/server/index.js +2 -0
  95. package/dist/lib/server/index.mjs +3 -1
  96. package/dist/lib/signing/agent-resolver/consistency.d.mts +6 -13
  97. package/dist/lib/signing/agent-resolver/consistency.d.ts +6 -13
  98. package/dist/lib/signing/agent-resolver/consistency.js +0 -1
  99. package/dist/lib/signing/agent-resolver/consistency.mjs +0 -1
  100. package/dist/lib/signing/agent-resolver/errors.d.mts +3 -1
  101. package/dist/lib/signing/agent-resolver/errors.d.ts +3 -1
  102. package/dist/lib/signing/agent-resolver/errors.js +6 -0
  103. package/dist/lib/signing/agent-resolver/errors.mjs +6 -0
  104. package/dist/lib/signing/agent-resolver/fetch-helpers.d.mts +11 -0
  105. package/dist/lib/signing/agent-resolver/fetch-helpers.d.ts +11 -0
  106. package/dist/lib/signing/agent-resolver/fetch-helpers.js +37 -2
  107. package/dist/lib/signing/agent-resolver/fetch-helpers.mjs +40 -3
  108. package/dist/lib/signing/agent-resolver/jwks-set.js +24 -3
  109. package/dist/lib/signing/agent-resolver/jwks-set.mjs +24 -3
  110. package/dist/lib/signing/agent-resolver/legacy-brand.d.mts +15 -0
  111. package/dist/lib/signing/agent-resolver/legacy-brand.d.ts +15 -0
  112. package/dist/lib/signing/agent-resolver/legacy-brand.js +60 -0
  113. package/dist/lib/signing/agent-resolver/legacy-brand.mjs +36 -0
  114. package/dist/lib/signing/agent-resolver/operator-authorization.d.mts +13 -0
  115. package/dist/lib/signing/agent-resolver/operator-authorization.d.ts +13 -0
  116. package/dist/lib/signing/agent-resolver/operator-authorization.js +108 -0
  117. package/dist/lib/signing/agent-resolver/operator-authorization.mjs +84 -0
  118. package/dist/lib/signing/agent-resolver/resolve-agent.d.mts +14 -4
  119. package/dist/lib/signing/agent-resolver/resolve-agent.d.ts +14 -4
  120. package/dist/lib/signing/agent-resolver/resolve-agent.js +148 -137
  121. package/dist/lib/signing/agent-resolver/resolve-agent.mjs +157 -139
  122. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.mts +7 -1
  123. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.ts +7 -1
  124. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.js +50 -17
  125. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.mjs +50 -17
  126. package/dist/lib/signing/agent-resolver/select-agent.d.mts +14 -15
  127. package/dist/lib/signing/agent-resolver/select-agent.d.ts +14 -15
  128. package/dist/lib/signing/agent-resolver/select-agent.js +98 -13
  129. package/dist/lib/signing/agent-resolver/select-agent.mjs +95 -13
  130. package/dist/lib/signing/brand-jwks.d.mts +29 -75
  131. package/dist/lib/signing/brand-jwks.d.ts +29 -75
  132. package/dist/lib/signing/brand-jwks.js +120 -182
  133. package/dist/lib/signing/brand-jwks.mjs +120 -182
  134. package/dist/lib/signing/errors.d.mts +7 -3
  135. package/dist/lib/signing/errors.d.ts +7 -3
  136. package/dist/lib/signing/errors.js +7 -2
  137. package/dist/lib/signing/errors.mjs +7 -2
  138. package/dist/lib/signing/jwks-https.d.mts +7 -0
  139. package/dist/lib/signing/jwks-https.d.ts +7 -0
  140. package/dist/lib/signing/jwks-https.js +31 -8
  141. package/dist/lib/signing/jwks-https.mjs +31 -8
  142. package/dist/lib/signing/jwks.d.mts +8 -0
  143. package/dist/lib/signing/jwks.d.ts +8 -0
  144. package/dist/lib/signing/middleware.js +2 -1
  145. package/dist/lib/signing/middleware.mjs +2 -1
  146. package/dist/lib/signing/publisher-pins.d.mts +11 -0
  147. package/dist/lib/signing/publisher-pins.d.ts +11 -0
  148. package/dist/lib/signing/publisher-pins.js +125 -0
  149. package/dist/lib/signing/publisher-pins.mjs +101 -0
  150. package/dist/lib/signing/server.d.mts +1 -0
  151. package/dist/lib/signing/server.d.ts +1 -0
  152. package/dist/lib/signing/types.d.mts +5 -0
  153. package/dist/lib/signing/types.d.ts +5 -0
  154. package/dist/lib/signing/verifier.js +50 -5
  155. package/dist/lib/signing/verifier.mjs +50 -5
  156. package/dist/lib/signing/webhook-verifier.d.mts +7 -2
  157. package/dist/lib/signing/webhook-verifier.d.ts +7 -2
  158. package/dist/lib/signing/webhook-verifier.js +42 -2
  159. package/dist/lib/signing/webhook-verifier.mjs +42 -2
  160. package/dist/lib/testing/storyboard/account-policy.d.mts +2 -0
  161. package/dist/lib/testing/storyboard/account-policy.d.ts +2 -0
  162. package/dist/lib/testing/storyboard/account-policy.js +35 -0
  163. package/dist/lib/testing/storyboard/account-policy.mjs +11 -0
  164. package/dist/lib/testing/storyboard/context.js +6 -0
  165. package/dist/lib/testing/storyboard/context.mjs +6 -0
  166. package/dist/lib/testing/storyboard/request-builder.js +12 -2
  167. package/dist/lib/testing/storyboard/request-builder.mjs +12 -2
  168. package/dist/lib/testing/storyboard/runner.js +3 -2
  169. package/dist/lib/testing/storyboard/runner.mjs +3 -2
  170. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  171. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  172. package/dist/lib/types/accept-proposal.d.ts +19 -1
  173. package/dist/lib/types/buy-products.d.ts +19 -1
  174. package/dist/lib/types/check-governance.d.ts +19 -1
  175. package/dist/lib/types/comply-test-controller.d.ts +19 -1
  176. package/dist/lib/types/control-media-buy.d.ts +19 -1
  177. package/dist/lib/types/core.generated.d.mts +14 -1
  178. package/dist/lib/types/core.generated.d.ts +14 -1
  179. package/dist/lib/types/create-media-buy.d.ts +14 -1
  180. package/dist/lib/types/get-media-buys.d.ts +14 -1
  181. package/dist/lib/types/get-products.d.ts +19 -1
  182. package/dist/lib/types/list-products.d.ts +19 -1
  183. package/dist/lib/types/refine-proposals.d.ts +19 -1
  184. package/dist/lib/types/request-proposals.d.ts +19 -1
  185. package/dist/lib/types/schemas.generated.d.ts +12 -3
  186. package/dist/lib/types/schemas.generated.js +4 -1
  187. package/dist/lib/types/schemas.generated.mjs +4 -1
  188. package/dist/lib/types/tools.generated.d.mts +14 -1
  189. package/dist/lib/types/tools.generated.d.ts +14 -1
  190. package/dist/lib/types/update-media-buy.d.ts +14 -1
  191. package/dist/lib/version.d.mts +3 -3
  192. package/dist/lib/version.d.ts +3 -3
  193. package/dist/lib/version.js +3 -3
  194. package/dist/lib/version.mjs +3 -3
  195. package/dist/lib/webhooks/index.d.mts +24 -0
  196. package/dist/lib/webhooks/index.d.ts +24 -0
  197. package/dist/lib/webhooks/index.js +50 -24
  198. package/dist/lib/webhooks/index.mjs +49 -24
  199. package/dist/lib/wholesale-feed-sync/index.d.mts +2 -0
  200. package/dist/lib/wholesale-feed-sync/index.d.ts +2 -0
  201. package/dist/lib/wholesale-feed-sync/index.js +7 -0
  202. package/dist/lib/wholesale-feed-sync/index.mjs +4 -0
  203. package/dist/lib/wholesale-feed-sync/mirror.d.mts +97 -0
  204. package/dist/lib/wholesale-feed-sync/mirror.d.ts +97 -0
  205. package/dist/lib/wholesale-feed-sync/mirror.js +350 -0
  206. package/dist/lib/wholesale-feed-sync/mirror.mjs +322 -0
  207. package/dist/lib/wholesale-feed-sync/sync.d.mts +13 -29
  208. package/dist/lib/wholesale-feed-sync/sync.d.ts +13 -29
  209. package/dist/lib/wholesale-feed-sync/sync.js +208 -281
  210. package/dist/lib/wholesale-feed-sync/sync.mjs +213 -281
  211. package/dist/lib/wholesale-feed-sync/types.d.mts +4 -3
  212. package/dist/lib/wholesale-feed-sync/types.d.ts +4 -3
  213. package/docs/README.md +6 -0
  214. package/docs/TYPE-SUMMARY.md +2 -2
  215. package/docs/guides/BUILD-AN-AGENT.md +2 -2
  216. package/docs/guides/BUYER-QUICKSTART-3.2.md +2 -0
  217. package/docs/guides/BUYER-STORAGE.md +3 -0
  218. package/docs/guides/FIRST-CALL-TO-A-SELLER.md +106 -0
  219. package/docs/guides/SIGNING-GUIDE.md +16 -7
  220. package/docs/guides/account-resolution.md +132 -10
  221. package/docs/llms.txt +3 -2
  222. package/docs/migration-14.0-to-14.1.md +85 -0
  223. package/docs/migration-14.x-rc-worksheet.md +4 -4
  224. package/docs/migration-4.x-to-5.x.md +1 -0
  225. package/docs/migration-agent-resolution-3.3.md +125 -0
  226. package/docs/recipes/verifying-inbound-webhooks.md +60 -15
  227. package/package.json +3 -2
  228. package/skills/adcp-brand.previous/SKILL.md +0 -200
  229. package/skills/adcp-creative.previous/SKILL.md +0 -305
  230. package/skills/adcp-governance.previous/SKILL.md +0 -566
  231. package/skills/adcp-measurement.previous/SKILL.md +0 -136
  232. package/skills/adcp-media-buy.previous/SKILL.md +0 -556
  233. package/skills/adcp-si.previous/SKILL.md +0 -206
  234. package/skills/adcp-signals.previous/SKILL.md +0 -204
@@ -43,6 +43,7 @@ var import_protocols = require('../protocols/index.js');
43
43
  var import_mcp_tasks = require('../protocols/mcp-tasks.js');
44
44
  var import_prepared_call_context = require('../protocols/prepared-call-context.js');
45
45
  var import_auth = require('../auth/index.js');
46
+ var import_signedRequestRejection = require('../protocols/signedRequestRejection.js');
46
47
  var import_errors = require('../errors/index.js');
47
48
  var import_client_hooks = require('../validation/client-hooks.js');
48
49
  var import_schema_validator = require('../validation/schema-validator.js');
@@ -943,16 +944,19 @@ class TaskExecutor {
943
944
  (0, import_abort.throwIfAborted)(options.signal);
944
945
  if (beforeProtocolDispatch) {
945
946
  let decision;
946
- dispatchBoundaryOwnsTerminalState = true;
947
+ const ownsSettlement = beforeProtocolDispatch.terminalSettlement !== "executor";
948
+ dispatchBoundaryOwnsTerminalState = ownsSettlement;
947
949
  try {
948
- this.compactClosedExternalTaskSettlementFences();
949
- if (this.liveExternalTaskSettlementCount() + this.settlementCapacityReservations.size >= COMPACTED_TASK_STATE_LIMIT) {
950
- throw new Error("The durable task-settlement capacity is exhausted; no mutation claim was attempted.");
951
- }
952
- this.settlementCapacityReservations.add(taskId);
953
- if (webhookRegistrationPersisted) {
954
- await this.config.onDurableSettlementRequired?.(taskId);
955
- (0, import_abort.throwIfAborted)(options.signal);
950
+ if (ownsSettlement) {
951
+ this.compactClosedExternalTaskSettlementFences();
952
+ if (this.liveExternalTaskSettlementCount() + this.settlementCapacityReservations.size >= COMPACTED_TASK_STATE_LIMIT) {
953
+ throw new Error("The durable task-settlement capacity is exhausted; no mutation claim was attempted.");
954
+ }
955
+ this.settlementCapacityReservations.add(taskId);
956
+ if (webhookRegistrationPersisted) {
957
+ await this.config.onDurableSettlementRequired?.(taskId);
958
+ (0, import_abort.throwIfAborted)(options.signal);
959
+ }
956
960
  }
957
961
  decision = await beforeProtocolDispatch(preparedCall.args, {
958
962
  operationId: taskId,
@@ -961,6 +965,7 @@ class TaskExecutor {
961
965
  registerExternalTaskSettlement: (handler) => this.registerExternalTaskSettlement(taskId, handler)
962
966
  });
963
967
  if (decision.action === "dispatch_committed") {
968
+ if (!ownsSettlement) throw new Error("An executor-settled dispatch hook cannot claim durable settlement.");
964
969
  if (decision.requireDeferredSettlementResumeAuthorization === true && this.config.deferredStorage !== void 0) {
965
970
  this.requireDeferredSettlementOperationRouting(this.config.deferredStorage);
966
971
  }
@@ -984,8 +989,8 @@ class TaskExecutor {
984
989
  }
985
990
  return (0, import_match.attachMatch)(earlyResult);
986
991
  }
987
- dispatchCommitted = true;
988
- dispatchSettlement = decision;
992
+ dispatchCommitted = decision.action === "dispatch_committed";
993
+ dispatchSettlement = decision.action === "dispatch_committed" ? decision : void 0;
989
994
  }
990
995
  (0, import_abort.throwIfAborted)(options.signal);
991
996
  const postDispatchOptions = dispatchCommitted ? { ...options, signal: void 0 } : options;
@@ -4212,7 +4217,7 @@ class TaskExecutor {
4212
4217
  status: "failed",
4213
4218
  error: error.message || String(error),
4214
4219
  adcpError: adcpErrorInfo,
4215
- errorInstance: this.buildErrorInstance(taskId, adcpErrorInfo),
4220
+ errorInstance: (0, import_signedRequestRejection.getSignedRequestRejection)(error) ?? this.buildErrorInstance(taskId, adcpErrorInfo),
4216
4221
  correlationId,
4217
4222
  metadata: this.buildMetadata({
4218
4223
  taskId,
@@ -7,6 +7,7 @@ import {
7
7
  import { listMCPTasks } from "../protocols/mcp-tasks.mjs";
8
8
  import { withPreparedProtocolToolCall } from "../protocols/prepared-call-context.mjs";
9
9
  import { getAuthToken } from "../auth/index.mjs";
10
+ import { getSignedRequestRejection } from "../protocols/signedRequestRejection.mjs";
10
11
  import { is401Error, adcpErrorToTypedError, ConfigurationError } from "../errors/index.mjs";
11
12
  import {
12
13
  validateOutgoingRequest,
@@ -916,16 +917,19 @@ class TaskExecutor {
916
917
  throwIfAborted(options.signal);
917
918
  if (beforeProtocolDispatch) {
918
919
  let decision;
919
- dispatchBoundaryOwnsTerminalState = true;
920
+ const ownsSettlement = beforeProtocolDispatch.terminalSettlement !== "executor";
921
+ dispatchBoundaryOwnsTerminalState = ownsSettlement;
920
922
  try {
921
- this.compactClosedExternalTaskSettlementFences();
922
- if (this.liveExternalTaskSettlementCount() + this.settlementCapacityReservations.size >= COMPACTED_TASK_STATE_LIMIT) {
923
- throw new Error("The durable task-settlement capacity is exhausted; no mutation claim was attempted.");
924
- }
925
- this.settlementCapacityReservations.add(taskId);
926
- if (webhookRegistrationPersisted) {
927
- await this.config.onDurableSettlementRequired?.(taskId);
928
- throwIfAborted(options.signal);
923
+ if (ownsSettlement) {
924
+ this.compactClosedExternalTaskSettlementFences();
925
+ if (this.liveExternalTaskSettlementCount() + this.settlementCapacityReservations.size >= COMPACTED_TASK_STATE_LIMIT) {
926
+ throw new Error("The durable task-settlement capacity is exhausted; no mutation claim was attempted.");
927
+ }
928
+ this.settlementCapacityReservations.add(taskId);
929
+ if (webhookRegistrationPersisted) {
930
+ await this.config.onDurableSettlementRequired?.(taskId);
931
+ throwIfAborted(options.signal);
932
+ }
929
933
  }
930
934
  decision = await beforeProtocolDispatch(preparedCall.args, {
931
935
  operationId: taskId,
@@ -934,6 +938,7 @@ class TaskExecutor {
934
938
  registerExternalTaskSettlement: (handler) => this.registerExternalTaskSettlement(taskId, handler)
935
939
  });
936
940
  if (decision.action === "dispatch_committed") {
941
+ if (!ownsSettlement) throw new Error("An executor-settled dispatch hook cannot claim durable settlement.");
937
942
  if (decision.requireDeferredSettlementResumeAuthorization === true && this.config.deferredStorage !== void 0) {
938
943
  this.requireDeferredSettlementOperationRouting(this.config.deferredStorage);
939
944
  }
@@ -957,8 +962,8 @@ class TaskExecutor {
957
962
  }
958
963
  return attachMatch(earlyResult);
959
964
  }
960
- dispatchCommitted = true;
961
- dispatchSettlement = decision;
965
+ dispatchCommitted = decision.action === "dispatch_committed";
966
+ dispatchSettlement = decision.action === "dispatch_committed" ? decision : void 0;
962
967
  }
963
968
  throwIfAborted(options.signal);
964
969
  const postDispatchOptions = dispatchCommitted ? { ...options, signal: void 0 } : options;
@@ -4185,7 +4190,7 @@ class TaskExecutor {
4185
4190
  status: "failed",
4186
4191
  error: error.message || String(error),
4187
4192
  adcpError: adcpErrorInfo,
4188
- errorInstance: this.buildErrorInstance(taskId, adcpErrorInfo),
4193
+ errorInstance: getSignedRequestRejection(error) ?? this.buildErrorInstance(taskId, adcpErrorInfo),
4189
4194
  correlationId,
4190
4195
  metadata: this.buildMetadata({
4191
4196
  taskId,
@@ -0,0 +1,3 @@
1
+ import type { AccountReference } from '../types/index.mjs';
2
+ /** Stable identity; never includes billing details or credentials. */
3
+ export declare function accountReferenceKey(ref: AccountReference): string;
@@ -0,0 +1,3 @@
1
+ import type { AccountReference } from '../types';
2
+ /** Stable identity; never includes billing details or credentials. */
3
+ export declare function accountReferenceKey(ref: AccountReference): string;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var account_key_exports = {};
20
+ __export(account_key_exports, {
21
+ accountReferenceKey: () => accountReferenceKey
22
+ });
23
+ module.exports = __toCommonJS(account_key_exports);
24
+ function accountReferenceKey(ref) {
25
+ if ("account_id" in ref) return JSON.stringify(["id", ref.account_id]);
26
+ return JSON.stringify([
27
+ "natural",
28
+ ref.brand.domain,
29
+ ref.brand.brand_id ?? null,
30
+ ref.brand.countries ? [...ref.brand.countries].sort() : null,
31
+ ref.operator,
32
+ ref.operator_unit?.id ?? null,
33
+ ref.currency ?? null,
34
+ ref.timezone ?? null,
35
+ ref.sandbox === true
36
+ ]);
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ accountReferenceKey
41
+ });
@@ -0,0 +1,17 @@
1
+ function accountReferenceKey(ref) {
2
+ if ("account_id" in ref) return JSON.stringify(["id", ref.account_id]);
3
+ return JSON.stringify([
4
+ "natural",
5
+ ref.brand.domain,
6
+ ref.brand.brand_id ?? null,
7
+ ref.brand.countries ? [...ref.brand.countries].sort() : null,
8
+ ref.operator,
9
+ ref.operator_unit?.id ?? null,
10
+ ref.currency ?? null,
11
+ ref.timezone ?? null,
12
+ ref.sandbox === true
13
+ ]);
14
+ }
15
+ export {
16
+ accountReferenceKey
17
+ };
@@ -16,6 +16,8 @@ export interface ResolveAccountOptions {
16
16
  forTask?: string;
17
17
  /** Billing party for buyer-declared accounts when the seller has no default. */
18
18
  billing?: 'operator' | 'agent' | 'advertiser';
19
+ paymentTerms?: import('../types/tools.generated.mjs').PaymentTerms;
20
+ billingEntity?: import('../types/tools.generated.mjs').BusinessEntity;
19
21
  /** An account_id or a callback choosing one of the eligible list_accounts rows. */
20
22
  select?: string | ((accounts: readonly ListedAccount[]) => string);
21
23
  }
@@ -16,6 +16,8 @@ export interface ResolveAccountOptions {
16
16
  forTask?: string;
17
17
  /** Billing party for buyer-declared accounts when the seller has no default. */
18
18
  billing?: 'operator' | 'agent' | 'advertiser';
19
+ paymentTerms?: import('../types/tools.generated').PaymentTerms;
20
+ billingEntity?: import('../types/tools.generated').BusinessEntity;
19
21
  /** An account_id or a callback choosing one of the eligible list_accounts rows. */
20
22
  select?: string | ((accounts: readonly ListedAccount[]) => string);
21
23
  }
@@ -0,0 +1,93 @@
1
+ import type { AccountReference, BusinessEntity, PaymentTerms, SyncAccountsResponse } from '../types/tools.generated.mjs';
2
+ import type { TaskOptions, TaskResult } from './ConversationTypes.mjs';
3
+ export type AccountPolicy = 'auto' | 'strict' | 'off';
4
+ export interface EnsureAccountOptions {
5
+ billing?: 'operator' | 'agent' | 'advertiser';
6
+ paymentTerms?: PaymentTerms;
7
+ billingEntity?: BusinessEntity;
8
+ /** Caller-owned retry identity. Settle ambiguous dispatches explicitly with this key; the registry never rotates it. */
9
+ idempotencyKey?: string;
10
+ }
11
+ export interface ProvisionedAccount {
12
+ account: AccountReference;
13
+ account_id?: string;
14
+ status: string;
15
+ pendingTaskId?: string;
16
+ /** Hashes of explicitly selected setup options; billing identities themselves are never persisted. */
17
+ setupTerms?: Partial<Record<keyof EnsureAccountOptions, string>>;
18
+ /** Stored reference aliases for authoritative repair after restart. */
19
+ aliases?: AccountReference[];
20
+ /** Monotonically increasing row revision when compareAndSet is implemented. */
21
+ revision?: number;
22
+ /** Durable claim. Reconcile an uncertain dispatch explicitly before provisioning again. */
23
+ dispatch?: {
24
+ idempotencyKey: string;
25
+ startedAt: string;
26
+ };
27
+ }
28
+ /** Partitioned by seller and caller scope. Implementations must provide read-your-writes. */
29
+ export interface BuyerAccountStorage {
30
+ get(key: string): Promise<ProvisionedAccount | undefined>;
31
+ set(key: string, account: ProvisionedAccount): Promise<void>;
32
+ /** Atomically insert (undefined revision) or replace. Store the supplied new revision. Required for multi-process safety. */
33
+ compareAndSet?(key: string, expectedRevision: number | undefined, account: ProvisionedAccount): Promise<boolean>;
34
+ }
35
+ export interface BuyerAccountDispatch {
36
+ storageKey: string;
37
+ account: AccountReference;
38
+ idempotencyKey: string;
39
+ }
40
+ export interface BuyerAccountProvisioningDispatch {
41
+ idempotencyKey: string;
42
+ /** Invoke immediately before the transport receives the mutation. */
43
+ beforeDispatch(): Promise<void>;
44
+ }
45
+ export interface BuyerAccountRegistryOptions {
46
+ /** Awaited before dispatch; rejection prevents the mutation. */
47
+ onDispatchStart?: (dispatch: BuyerAccountDispatch) => Promise<void>;
48
+ /** Awaited for each seller result before account writes. Rejection preserves the claim for caller reconciliation. */
49
+ onResult?: (dispatch: BuyerAccountDispatch & {
50
+ result: TaskResult<unknown>;
51
+ }) => Promise<void>;
52
+ maxEntries?: number;
53
+ normalizeOptions?: (options: EnsureAccountOptions, taskOptions?: TaskOptions) => Promise<EnsureAccountOptions>;
54
+ }
55
+ export declare class BuyerAccountRegistry {
56
+ private scope;
57
+ private provision;
58
+ private storage?;
59
+ private repair?;
60
+ private readonly registryOptions;
61
+ private entries;
62
+ private pending;
63
+ private writes;
64
+ private repairs;
65
+ private repairWaiters;
66
+ private invalidatedHandles;
67
+ private observationEpoch;
68
+ private observationFloor;
69
+ private statusEpochs;
70
+ private readonly maxEntries;
71
+ private readonly normalizeOptions?;
72
+ constructor(scope: () => string, provision: (key: AccountReference, options: EnsureAccountOptions, taskOptions?: TaskOptions, dispatch?: BuyerAccountProvisioningDispatch) => Promise<TaskResult<SyncAccountsResponse>>, storage?: BuyerAccountStorage | undefined, repair?: ((accountId: string, taskOptions?: TaskOptions) => Promise<readonly unknown[]>) | undefined, registryOptions?: BuyerAccountRegistryOptions);
73
+ private key;
74
+ /** Capture before a seller request; observations older than a status repair are ignored. */
75
+ captureObservation(): number;
76
+ private observationIsCurrent;
77
+ private remember;
78
+ get(account: AccountReference): Promise<ProvisionedAccount | undefined>;
79
+ ensure(account: AccountReference, options?: EnsureAccountOptions, taskOptions?: TaskOptions, onTaskResult?: (result: TaskResult<unknown>) => void): Promise<ProvisionedAccount>;
80
+ private write;
81
+ private record;
82
+ private enqueue;
83
+ observeSync(refs: readonly AccountReference[], rows: readonly unknown[], dryRun?: boolean, observationEpoch?: number, expectedRevision?: number): Promise<void>;
84
+ private reconcileId;
85
+ observeList(rows: readonly unknown[], queriedAccountId?: string, observationEpoch?: number): Promise<void>;
86
+ private observeListAtScope;
87
+ /** After verifying account.status_changed, repair aliases by handle from the authoritative seller. */
88
+ applyStatusChange(notification: {
89
+ account_id: string;
90
+ }, options?: TaskOptions): Promise<void>;
91
+ private repairStatus;
92
+ private runRepair;
93
+ }
@@ -0,0 +1,93 @@
1
+ import type { AccountReference, BusinessEntity, PaymentTerms, SyncAccountsResponse } from '../types/tools.generated';
2
+ import type { TaskOptions, TaskResult } from './ConversationTypes';
3
+ export type AccountPolicy = 'auto' | 'strict' | 'off';
4
+ export interface EnsureAccountOptions {
5
+ billing?: 'operator' | 'agent' | 'advertiser';
6
+ paymentTerms?: PaymentTerms;
7
+ billingEntity?: BusinessEntity;
8
+ /** Caller-owned retry identity. Settle ambiguous dispatches explicitly with this key; the registry never rotates it. */
9
+ idempotencyKey?: string;
10
+ }
11
+ export interface ProvisionedAccount {
12
+ account: AccountReference;
13
+ account_id?: string;
14
+ status: string;
15
+ pendingTaskId?: string;
16
+ /** Hashes of explicitly selected setup options; billing identities themselves are never persisted. */
17
+ setupTerms?: Partial<Record<keyof EnsureAccountOptions, string>>;
18
+ /** Stored reference aliases for authoritative repair after restart. */
19
+ aliases?: AccountReference[];
20
+ /** Monotonically increasing row revision when compareAndSet is implemented. */
21
+ revision?: number;
22
+ /** Durable claim. Reconcile an uncertain dispatch explicitly before provisioning again. */
23
+ dispatch?: {
24
+ idempotencyKey: string;
25
+ startedAt: string;
26
+ };
27
+ }
28
+ /** Partitioned by seller and caller scope. Implementations must provide read-your-writes. */
29
+ export interface BuyerAccountStorage {
30
+ get(key: string): Promise<ProvisionedAccount | undefined>;
31
+ set(key: string, account: ProvisionedAccount): Promise<void>;
32
+ /** Atomically insert (undefined revision) or replace. Store the supplied new revision. Required for multi-process safety. */
33
+ compareAndSet?(key: string, expectedRevision: number | undefined, account: ProvisionedAccount): Promise<boolean>;
34
+ }
35
+ export interface BuyerAccountDispatch {
36
+ storageKey: string;
37
+ account: AccountReference;
38
+ idempotencyKey: string;
39
+ }
40
+ export interface BuyerAccountProvisioningDispatch {
41
+ idempotencyKey: string;
42
+ /** Invoke immediately before the transport receives the mutation. */
43
+ beforeDispatch(): Promise<void>;
44
+ }
45
+ export interface BuyerAccountRegistryOptions {
46
+ /** Awaited before dispatch; rejection prevents the mutation. */
47
+ onDispatchStart?: (dispatch: BuyerAccountDispatch) => Promise<void>;
48
+ /** Awaited for each seller result before account writes. Rejection preserves the claim for caller reconciliation. */
49
+ onResult?: (dispatch: BuyerAccountDispatch & {
50
+ result: TaskResult<unknown>;
51
+ }) => Promise<void>;
52
+ maxEntries?: number;
53
+ normalizeOptions?: (options: EnsureAccountOptions, taskOptions?: TaskOptions) => Promise<EnsureAccountOptions>;
54
+ }
55
+ export declare class BuyerAccountRegistry {
56
+ private scope;
57
+ private provision;
58
+ private storage?;
59
+ private repair?;
60
+ private readonly registryOptions;
61
+ private entries;
62
+ private pending;
63
+ private writes;
64
+ private repairs;
65
+ private repairWaiters;
66
+ private invalidatedHandles;
67
+ private observationEpoch;
68
+ private observationFloor;
69
+ private statusEpochs;
70
+ private readonly maxEntries;
71
+ private readonly normalizeOptions?;
72
+ constructor(scope: () => string, provision: (key: AccountReference, options: EnsureAccountOptions, taskOptions?: TaskOptions, dispatch?: BuyerAccountProvisioningDispatch) => Promise<TaskResult<SyncAccountsResponse>>, storage?: BuyerAccountStorage | undefined, repair?: ((accountId: string, taskOptions?: TaskOptions) => Promise<readonly unknown[]>) | undefined, registryOptions?: BuyerAccountRegistryOptions);
73
+ private key;
74
+ /** Capture before a seller request; observations older than a status repair are ignored. */
75
+ captureObservation(): number;
76
+ private observationIsCurrent;
77
+ private remember;
78
+ get(account: AccountReference): Promise<ProvisionedAccount | undefined>;
79
+ ensure(account: AccountReference, options?: EnsureAccountOptions, taskOptions?: TaskOptions, onTaskResult?: (result: TaskResult<unknown>) => void): Promise<ProvisionedAccount>;
80
+ private write;
81
+ private record;
82
+ private enqueue;
83
+ observeSync(refs: readonly AccountReference[], rows: readonly unknown[], dryRun?: boolean, observationEpoch?: number, expectedRevision?: number): Promise<void>;
84
+ private reconcileId;
85
+ observeList(rows: readonly unknown[], queriedAccountId?: string, observationEpoch?: number): Promise<void>;
86
+ private observeListAtScope;
87
+ /** After verifying account.status_changed, repair aliases by handle from the authoritative seller. */
88
+ applyStatusChange(notification: {
89
+ account_id: string;
90
+ }, options?: TaskOptions): Promise<void>;
91
+ private repairStatus;
92
+ private runRepair;
93
+ }