@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
@@ -0,0 +1,137 @@
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 product_cache_exports = {};
20
+ __export(product_cache_exports, {
21
+ ProductCache: () => ProductCache,
22
+ createProductCache: () => createProductCache
23
+ });
24
+ module.exports = __toCommonJS(product_cache_exports);
25
+ var import_account_key = require('./account-key.js');
26
+ function stable(value) {
27
+ if (Array.isArray(value)) return value.map(stable);
28
+ if (value && typeof value === "object")
29
+ return Object.fromEntries(
30
+ Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => [k, stable(v)])
31
+ );
32
+ return value;
33
+ }
34
+ class ProductCache {
35
+ constructor(options = {}) {
36
+ this.options = options;
37
+ if (options.maxEntries !== void 0 && (!Number.isSafeInteger(options.maxEntries) || options.maxEntries < 1))
38
+ throw new Error("Product cache maxEntries must be a positive integer.");
39
+ for (const ttl of [options.publicTtl, options.accountTtl]) {
40
+ if (ttl !== void 0 && (!Number.isFinite(ttl) || ttl < 0))
41
+ throw new Error("Product cache TTLs must be nonnegative milliseconds.");
42
+ }
43
+ }
44
+ options;
45
+ entries = /* @__PURE__ */ new Map();
46
+ key(sellerScope, params) {
47
+ const { account, if_wholesale_feed_version: _feed, if_pricing_version: _price, ...query } = params;
48
+ if (account !== void 0) {
49
+ if (!account || typeof account !== "object") return void 0;
50
+ const ref = account;
51
+ if ("account_id" in ref) {
52
+ if (typeof ref.account_id !== "string" || !ref.account_id) return void 0;
53
+ } else if (!ref.brand || typeof ref.brand.domain !== "string" || typeof ref.operator !== "string") {
54
+ return void 0;
55
+ }
56
+ }
57
+ return JSON.stringify([
58
+ sellerScope,
59
+ account ? (0, import_account_key.accountReferenceKey)(account) : "public",
60
+ stable(query)
61
+ ]);
62
+ }
63
+ read(scope, params, allowExpired = false) {
64
+ const key = this.key(scope, params);
65
+ if (!key) return void 0;
66
+ const entry = this.entries.get(key);
67
+ if (!entry) return void 0;
68
+ const ttl = entry.scope === "public" ? this.options.publicTtl ?? 6e4 : this.options.accountTtl ?? 3e4;
69
+ if (!allowExpired && Date.now() - entry.storedAt >= ttl) return void 0;
70
+ return {
71
+ ...entry.result,
72
+ data: structuredClone(entry.result.data),
73
+ metadata: structuredClone(entry.result.metadata),
74
+ ...entry.result.debug_logs && { debug_logs: structuredClone(entry.result.debug_logs) }
75
+ };
76
+ }
77
+ conditionalParams(scope, params) {
78
+ if (params.if_wholesale_feed_version !== void 0 || params.if_pricing_version !== void 0) return params;
79
+ const result = this.read(scope, params, true);
80
+ const data = result?.data;
81
+ if (typeof data?.wholesale_feed_version !== "string") return params;
82
+ return {
83
+ ...params,
84
+ if_wholesale_feed_version: data.wholesale_feed_version,
85
+ ...typeof data.pricing_version === "string" && { if_pricing_version: data.pricing_version }
86
+ };
87
+ }
88
+ write(scope, params, result, conditionalSnapshot) {
89
+ const key = this.key(scope, params);
90
+ if (!key) return result;
91
+ if (!result.success || result.status !== "completed" || !result.data || typeof result.data !== "object")
92
+ return result;
93
+ const data = result.data;
94
+ if (data.cache_scope !== "public" && data.cache_scope !== "account") {
95
+ this.entries.delete(key);
96
+ return result;
97
+ }
98
+ if (data.cache_scope === "account" && !params.account) {
99
+ this.entries.delete(key);
100
+ return result;
101
+ }
102
+ let completed = result;
103
+ if (data.unchanged === true) {
104
+ if (typeof data.wholesale_feed_version !== "string") return result;
105
+ const old = conditionalSnapshot?.data ? { result: conditionalSnapshot, scope: conditionalSnapshot.data.cache_scope } : this.entries.get(key);
106
+ const oldData = old?.result.data;
107
+ if (!old || old.scope !== data.cache_scope || !oldData || data.wholesale_feed_version !== oldData.wholesale_feed_version || data.pricing_version !== void 0 && data.pricing_version !== oldData.pricing_version)
108
+ return result;
109
+ if (params.if_wholesale_feed_version !== void 0 || params.if_pricing_version !== void 0) return result;
110
+ completed = { ...result, data: structuredClone(oldData) };
111
+ } else if (!Array.isArray(data.products)) return result;
112
+ if (!this.entries.has(key) && this.entries.size >= (this.options.maxEntries ?? 1e3))
113
+ this.entries.delete(this.entries.keys().next().value);
114
+ this.entries.set(key, {
115
+ result: {
116
+ ...completed,
117
+ data: structuredClone(completed.data),
118
+ metadata: structuredClone(completed.metadata),
119
+ ...completed.debug_logs && { debug_logs: structuredClone(completed.debug_logs) }
120
+ },
121
+ storedAt: Date.now(),
122
+ scope: data.cache_scope
123
+ });
124
+ return completed;
125
+ }
126
+ clear() {
127
+ this.entries.clear();
128
+ }
129
+ }
130
+ function createProductCache(options = {}) {
131
+ return new ProductCache(options);
132
+ }
133
+ // Annotate the CommonJS export names for ESM import in node:
134
+ 0 && (module.exports = {
135
+ ProductCache,
136
+ createProductCache
137
+ });
@@ -0,0 +1,112 @@
1
+ import { accountReferenceKey } from "./account-key.mjs";
2
+ function stable(value) {
3
+ if (Array.isArray(value)) return value.map(stable);
4
+ if (value && typeof value === "object")
5
+ return Object.fromEntries(
6
+ Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => [k, stable(v)])
7
+ );
8
+ return value;
9
+ }
10
+ class ProductCache {
11
+ constructor(options = {}) {
12
+ this.options = options;
13
+ if (options.maxEntries !== void 0 && (!Number.isSafeInteger(options.maxEntries) || options.maxEntries < 1))
14
+ throw new Error("Product cache maxEntries must be a positive integer.");
15
+ for (const ttl of [options.publicTtl, options.accountTtl]) {
16
+ if (ttl !== void 0 && (!Number.isFinite(ttl) || ttl < 0))
17
+ throw new Error("Product cache TTLs must be nonnegative milliseconds.");
18
+ }
19
+ }
20
+ options;
21
+ entries = /* @__PURE__ */ new Map();
22
+ key(sellerScope, params) {
23
+ const { account, if_wholesale_feed_version: _feed, if_pricing_version: _price, ...query } = params;
24
+ if (account !== void 0) {
25
+ if (!account || typeof account !== "object") return void 0;
26
+ const ref = account;
27
+ if ("account_id" in ref) {
28
+ if (typeof ref.account_id !== "string" || !ref.account_id) return void 0;
29
+ } else if (!ref.brand || typeof ref.brand.domain !== "string" || typeof ref.operator !== "string") {
30
+ return void 0;
31
+ }
32
+ }
33
+ return JSON.stringify([
34
+ sellerScope,
35
+ account ? accountReferenceKey(account) : "public",
36
+ stable(query)
37
+ ]);
38
+ }
39
+ read(scope, params, allowExpired = false) {
40
+ const key = this.key(scope, params);
41
+ if (!key) return void 0;
42
+ const entry = this.entries.get(key);
43
+ if (!entry) return void 0;
44
+ const ttl = entry.scope === "public" ? this.options.publicTtl ?? 6e4 : this.options.accountTtl ?? 3e4;
45
+ if (!allowExpired && Date.now() - entry.storedAt >= ttl) return void 0;
46
+ return {
47
+ ...entry.result,
48
+ data: structuredClone(entry.result.data),
49
+ metadata: structuredClone(entry.result.metadata),
50
+ ...entry.result.debug_logs && { debug_logs: structuredClone(entry.result.debug_logs) }
51
+ };
52
+ }
53
+ conditionalParams(scope, params) {
54
+ if (params.if_wholesale_feed_version !== void 0 || params.if_pricing_version !== void 0) return params;
55
+ const result = this.read(scope, params, true);
56
+ const data = result?.data;
57
+ if (typeof data?.wholesale_feed_version !== "string") return params;
58
+ return {
59
+ ...params,
60
+ if_wholesale_feed_version: data.wholesale_feed_version,
61
+ ...typeof data.pricing_version === "string" && { if_pricing_version: data.pricing_version }
62
+ };
63
+ }
64
+ write(scope, params, result, conditionalSnapshot) {
65
+ const key = this.key(scope, params);
66
+ if (!key) return result;
67
+ if (!result.success || result.status !== "completed" || !result.data || typeof result.data !== "object")
68
+ return result;
69
+ const data = result.data;
70
+ if (data.cache_scope !== "public" && data.cache_scope !== "account") {
71
+ this.entries.delete(key);
72
+ return result;
73
+ }
74
+ if (data.cache_scope === "account" && !params.account) {
75
+ this.entries.delete(key);
76
+ return result;
77
+ }
78
+ let completed = result;
79
+ if (data.unchanged === true) {
80
+ if (typeof data.wholesale_feed_version !== "string") return result;
81
+ const old = conditionalSnapshot?.data ? { result: conditionalSnapshot, scope: conditionalSnapshot.data.cache_scope } : this.entries.get(key);
82
+ const oldData = old?.result.data;
83
+ if (!old || old.scope !== data.cache_scope || !oldData || data.wholesale_feed_version !== oldData.wholesale_feed_version || data.pricing_version !== void 0 && data.pricing_version !== oldData.pricing_version)
84
+ return result;
85
+ if (params.if_wholesale_feed_version !== void 0 || params.if_pricing_version !== void 0) return result;
86
+ completed = { ...result, data: structuredClone(oldData) };
87
+ } else if (!Array.isArray(data.products)) return result;
88
+ if (!this.entries.has(key) && this.entries.size >= (this.options.maxEntries ?? 1e3))
89
+ this.entries.delete(this.entries.keys().next().value);
90
+ this.entries.set(key, {
91
+ result: {
92
+ ...completed,
93
+ data: structuredClone(completed.data),
94
+ metadata: structuredClone(completed.metadata),
95
+ ...completed.debug_logs && { debug_logs: structuredClone(completed.debug_logs) }
96
+ },
97
+ storedAt: Date.now(),
98
+ scope: data.cache_scope
99
+ });
100
+ return completed;
101
+ }
102
+ clear() {
103
+ this.entries.clear();
104
+ }
105
+ }
106
+ function createProductCache(options = {}) {
107
+ return new ProductCache(options);
108
+ }
109
+ export {
110
+ ProductCache,
111
+ createProductCache
112
+ };
@@ -1,3 +1,4 @@
1
+ import { RequestSigningErrorCodeMetadata } from '../types/enums.generated.mjs';
1
2
  /**
2
3
  * Base class for all ADCP client errors
3
4
  */
@@ -84,6 +85,7 @@ export declare class AccountRequiredError extends ADCPError {
84
85
  readonly accountModel: 'explicit' | 'implicit';
85
86
  readonly taskName: string;
86
87
  readonly code = "ACCOUNT_REQUIRED";
88
+ readonly fault: "buyer_setup";
87
89
  constructor(accountModel: 'explicit' | 'implicit', taskName: string, reason?: string);
88
90
  }
89
91
  /** Account provisioning succeeded but the seller has not approved its use. */
@@ -91,6 +93,7 @@ export declare class AccountPendingApprovalError extends ADCPError {
91
93
  readonly account: import('../types/index.mjs').AccountReference;
92
94
  readonly accountId?: string | undefined;
93
95
  readonly code = "ACCOUNT_PENDING_APPROVAL";
96
+ readonly fault: "buyer_setup";
94
97
  constructor(account: import('../types/index.mjs').AccountReference, accountId?: string | undefined);
95
98
  }
96
99
  /** More than one active account matches the caller's selection hints. */
@@ -99,6 +102,27 @@ export declare class AccountAmbiguousError extends ADCPError {
99
102
  readonly code = "ACCOUNT_AMBIGUOUS";
100
103
  constructor(candidates: readonly string[]);
101
104
  }
105
+ /** Buyer setup errors must be excluded from seller-health failure counts. */
106
+ export declare abstract class BuyerSetupError extends ADCPError {
107
+ readonly fault: "buyer_setup";
108
+ }
109
+ export declare class AccountNotFoundError extends BuyerSetupError {
110
+ readonly code: string;
111
+ constructor(message?: string);
112
+ }
113
+ export declare class AccountSetupRequiredError extends BuyerSetupError {
114
+ readonly code: string;
115
+ constructor(message?: string);
116
+ }
117
+ export declare class AccountPaymentRequiredError extends BuyerSetupError {
118
+ readonly code: string;
119
+ constructor(message?: string);
120
+ }
121
+ export declare class AccountNotProvisionedError extends AccountNotFoundError {
122
+ readonly account: import('../types/index.mjs').AccountReference;
123
+ readonly taskName: string;
124
+ constructor(account: import('../types/index.mjs').AccountReference, taskName: string);
125
+ }
102
126
  /**
103
127
  * Error thrown when protocol communication fails
104
128
  */
@@ -172,6 +196,12 @@ export interface AuthChallengeInfo {
172
196
  error?: string;
173
197
  error_description?: string;
174
198
  }
199
+ /** Diagnostics from the original HTTP response to an SDK-signed request. */
200
+ export interface SignedRequestRejectionInfo {
201
+ status: number;
202
+ /** Untrusted seller text, already bounded and redacted by the transport. */
203
+ responseBody?: string;
204
+ }
175
205
  /**
176
206
  * Error thrown when authentication is required to access an MCP endpoint
177
207
  *
@@ -215,7 +245,16 @@ export declare class AuthenticationRequiredError extends ADCPError {
215
245
  readonly oauthMetadata?: OAuthMetadataInfo | undefined;
216
246
  readonly challenge?: AuthChallengeInfo | undefined;
217
247
  readonly code = "AUTHENTICATION_REQUIRED";
218
- constructor(agentUrl: string, oauthMetadata?: OAuthMetadataInfo | undefined, message?: string, challenge?: AuthChallengeInfo | undefined);
248
+ readonly signatureErrorCode?: keyof typeof RequestSigningErrorCodeMetadata;
249
+ readonly requestSigned?: boolean;
250
+ readonly status?: number;
251
+ /**
252
+ * Bounded, redacted seller diagnostic. Non-enumerable: do not forward this
253
+ * untrusted text to automated prompts or treat it as recovery instructions.
254
+ * Read it directly as `error.responseBody`; spread and JSON serialization omit it.
255
+ */
256
+ readonly responseBody?: string;
257
+ constructor(agentUrl: string, oauthMetadata?: OAuthMetadataInfo | undefined, message?: string, challenge?: AuthChallengeInfo | undefined, signedRejection?: SignedRequestRejectionInfo);
219
258
  /**
220
259
  * Check if OAuth authentication is available
221
260
  */
@@ -1,3 +1,4 @@
1
+ import { RequestSigningErrorCodeMetadata } from '../types/enums.generated';
1
2
  /**
2
3
  * Base class for all ADCP client errors
3
4
  */
@@ -84,6 +85,7 @@ export declare class AccountRequiredError extends ADCPError {
84
85
  readonly accountModel: 'explicit' | 'implicit';
85
86
  readonly taskName: string;
86
87
  readonly code = "ACCOUNT_REQUIRED";
88
+ readonly fault: "buyer_setup";
87
89
  constructor(accountModel: 'explicit' | 'implicit', taskName: string, reason?: string);
88
90
  }
89
91
  /** Account provisioning succeeded but the seller has not approved its use. */
@@ -91,6 +93,7 @@ export declare class AccountPendingApprovalError extends ADCPError {
91
93
  readonly account: import('../types').AccountReference;
92
94
  readonly accountId?: string | undefined;
93
95
  readonly code = "ACCOUNT_PENDING_APPROVAL";
96
+ readonly fault: "buyer_setup";
94
97
  constructor(account: import('../types').AccountReference, accountId?: string | undefined);
95
98
  }
96
99
  /** More than one active account matches the caller's selection hints. */
@@ -99,6 +102,27 @@ export declare class AccountAmbiguousError extends ADCPError {
99
102
  readonly code = "ACCOUNT_AMBIGUOUS";
100
103
  constructor(candidates: readonly string[]);
101
104
  }
105
+ /** Buyer setup errors must be excluded from seller-health failure counts. */
106
+ export declare abstract class BuyerSetupError extends ADCPError {
107
+ readonly fault: "buyer_setup";
108
+ }
109
+ export declare class AccountNotFoundError extends BuyerSetupError {
110
+ readonly code: string;
111
+ constructor(message?: string);
112
+ }
113
+ export declare class AccountSetupRequiredError extends BuyerSetupError {
114
+ readonly code: string;
115
+ constructor(message?: string);
116
+ }
117
+ export declare class AccountPaymentRequiredError extends BuyerSetupError {
118
+ readonly code: string;
119
+ constructor(message?: string);
120
+ }
121
+ export declare class AccountNotProvisionedError extends AccountNotFoundError {
122
+ readonly account: import('../types').AccountReference;
123
+ readonly taskName: string;
124
+ constructor(account: import('../types').AccountReference, taskName: string);
125
+ }
102
126
  /**
103
127
  * Error thrown when protocol communication fails
104
128
  */
@@ -172,6 +196,12 @@ export interface AuthChallengeInfo {
172
196
  error?: string;
173
197
  error_description?: string;
174
198
  }
199
+ /** Diagnostics from the original HTTP response to an SDK-signed request. */
200
+ export interface SignedRequestRejectionInfo {
201
+ status: number;
202
+ /** Untrusted seller text, already bounded and redacted by the transport. */
203
+ responseBody?: string;
204
+ }
175
205
  /**
176
206
  * Error thrown when authentication is required to access an MCP endpoint
177
207
  *
@@ -215,7 +245,16 @@ export declare class AuthenticationRequiredError extends ADCPError {
215
245
  readonly oauthMetadata?: OAuthMetadataInfo | undefined;
216
246
  readonly challenge?: AuthChallengeInfo | undefined;
217
247
  readonly code = "AUTHENTICATION_REQUIRED";
218
- constructor(agentUrl: string, oauthMetadata?: OAuthMetadataInfo | undefined, message?: string, challenge?: AuthChallengeInfo | undefined);
248
+ readonly signatureErrorCode?: keyof typeof RequestSigningErrorCodeMetadata;
249
+ readonly requestSigned?: boolean;
250
+ readonly status?: number;
251
+ /**
252
+ * Bounded, redacted seller diagnostic. Non-enumerable: do not forward this
253
+ * untrusted text to automated prompts or treat it as recovery instructions.
254
+ * Read it directly as `error.responseBody`; spread and JSON serialization omit it.
255
+ */
256
+ readonly responseBody?: string;
257
+ constructor(agentUrl: string, oauthMetadata?: OAuthMetadataInfo | undefined, message?: string, challenge?: AuthChallengeInfo | undefined, signedRejection?: SignedRequestRejectionInfo);
219
258
  /**
220
259
  * Check if OAuth authentication is available
221
260
  */
@@ -20,12 +20,17 @@ var errors_exports = {};
20
20
  __export(errors_exports, {
21
21
  ADCPError: () => ADCPError,
22
22
  AccountAmbiguousError: () => AccountAmbiguousError,
23
+ AccountNotFoundError: () => AccountNotFoundError,
24
+ AccountNotProvisionedError: () => AccountNotProvisionedError,
25
+ AccountPaymentRequiredError: () => AccountPaymentRequiredError,
23
26
  AccountPendingApprovalError: () => AccountPendingApprovalError,
24
27
  AccountRequiredError: () => AccountRequiredError,
28
+ AccountSetupRequiredError: () => AccountSetupRequiredError,
25
29
  ActionNotAllowedError: () => ActionNotAllowedError,
26
30
  AgentNotFoundError: () => AgentNotFoundError,
27
31
  AuthenticationCredentialsRejectedError: () => AuthenticationCredentialsRejectedError,
28
32
  AuthenticationRequiredError: () => AuthenticationRequiredError,
33
+ BuyerSetupError: () => BuyerSetupError,
29
34
  ConfigurationError: () => ConfigurationError,
30
35
  DeferredTaskError: () => DeferredTaskError,
31
36
  FeatureUnsupportedError: () => FeatureUnsupportedError,
@@ -53,6 +58,7 @@ __export(errors_exports, {
53
58
  mapSdkErrorCodeToProtocolErrorCode: () => mapSdkErrorCodeToProtocolErrorCode
54
59
  });
55
60
  module.exports = __toCommonJS(errors_exports);
61
+ var import_enums = require('../types/enums.generated.js');
56
62
  class ADCPError extends Error {
57
63
  constructor(message, details) {
58
64
  super(message);
@@ -160,6 +166,7 @@ class AccountRequiredError extends ADCPError {
160
166
  accountModel;
161
167
  taskName;
162
168
  code = "ACCOUNT_REQUIRED";
169
+ fault = "buyer_setup";
163
170
  }
164
171
  class AccountPendingApprovalError extends ADCPError {
165
172
  constructor(account, accountId) {
@@ -171,6 +178,7 @@ class AccountPendingApprovalError extends ADCPError {
171
178
  account;
172
179
  accountId;
173
180
  code = "ACCOUNT_PENDING_APPROVAL";
181
+ fault = "buyer_setup";
174
182
  }
175
183
  class AccountAmbiguousError extends ADCPError {
176
184
  constructor(candidates) {
@@ -181,6 +189,36 @@ class AccountAmbiguousError extends ADCPError {
181
189
  candidates;
182
190
  code = "ACCOUNT_AMBIGUOUS";
183
191
  }
192
+ class BuyerSetupError extends ADCPError {
193
+ fault = "buyer_setup";
194
+ }
195
+ class AccountNotFoundError extends BuyerSetupError {
196
+ code = "ACCOUNT_NOT_FOUND";
197
+ constructor(message = "The account has not been provisioned at this seller.") {
198
+ super(message);
199
+ }
200
+ }
201
+ class AccountSetupRequiredError extends BuyerSetupError {
202
+ code = "ACCOUNT_SETUP_REQUIRED";
203
+ constructor(message = "Complete account setup before making account-scoped requests.") {
204
+ super(message);
205
+ }
206
+ }
207
+ class AccountPaymentRequiredError extends BuyerSetupError {
208
+ code = "ACCOUNT_PAYMENT_REQUIRED";
209
+ constructor(message = "Complete account payment before making account-scoped requests.") {
210
+ super(message);
211
+ }
212
+ }
213
+ class AccountNotProvisionedError extends AccountNotFoundError {
214
+ constructor(account, taskName) {
215
+ super(`${taskName} requires an account provisioned at this seller. Call client.accounts.ensure first.`);
216
+ this.account = account;
217
+ this.taskName = taskName;
218
+ }
219
+ account;
220
+ taskName;
221
+ }
184
222
  class ProtocolError extends ADCPError {
185
223
  constructor(protocol, message, originalError) {
186
224
  super(`${protocol.toUpperCase()} protocol error: ${message}`);
@@ -236,13 +274,21 @@ class ConfigurationError extends ADCPError {
236
274
  code = "CONFIGURATION_ERROR";
237
275
  }
238
276
  class AuthenticationRequiredError extends ADCPError {
239
- constructor(agentUrl, oauthMetadata, message, challenge) {
240
- const defaultMessage = buildAuthRequiredMessage(agentUrl, oauthMetadata, challenge);
277
+ constructor(agentUrl, oauthMetadata, message, challenge, signedRejection) {
278
+ const defaultMessage = buildAuthRequiredMessage(agentUrl, oauthMetadata, challenge, !!signedRejection);
241
279
  super(message || defaultMessage);
242
280
  this.agentUrl = agentUrl;
243
281
  this.oauthMetadata = oauthMetadata;
244
282
  this.challenge = challenge;
245
283
  this.details = { agentUrl, oauthMetadata, challenge };
284
+ if (signedRejection) {
285
+ this.requestSigned = true;
286
+ this.status = signedRejection.status;
287
+ const signatureCode = getRequestSignatureRejectionCode(challenge);
288
+ if (signatureCode) this.signatureErrorCode = signatureCode;
289
+ Object.defineProperty(this, "responseBody", { value: signedRejection.responseBody, enumerable: false });
290
+ this.details = { agentUrl, challenge, requestSigned: true, status: this.status };
291
+ }
246
292
  }
247
293
  agentUrl;
248
294
  oauthMetadata;
@@ -300,7 +346,12 @@ function sanitizeAgentUrlForError(value) {
300
346
  return "invalid_url";
301
347
  }
302
348
  }
303
- function buildAuthRequiredMessage(agentUrl, oauthMetadata, challenge) {
349
+ function buildAuthRequiredMessage(agentUrl, oauthMetadata, challenge, requestSigned = false) {
350
+ if (requestSigned || challenge?.scheme === "signature") {
351
+ const code = getRequestSignatureRejectionCode(challenge);
352
+ const suggestion = code ? ` ${import_enums.RequestSigningErrorCodeMetadata[code].suggestion}.` : "";
353
+ return `Authentication failed with HTTP 401 for ${sanitizeAgentUrlForError(agentUrl)}. ` + (requestSigned ? "The seller rejected an SDK-signed request" : "The seller requires a valid request signature") + (code ? ` (${code})` : "") + ". Check signature verification and key discovery (brand_json_url \u2192 agents[] \u2192 jwks_uri)." + (requestSigned && !challenge ? " No authentication challenge was returned; check configured credentials too." : "") + suggestion + (requestSigned ? " A bounded seller diagnostic is available on responseBody when captured." : "");
354
+ }
304
355
  if (challenge && challenge.scheme !== "bearer") {
305
356
  if (challenge.scheme === "basic") {
306
357
  return `Authentication required for ${agentUrl}. Agent (or its fronting gateway) speaks HTTP Basic (RFC 7617). Configure via createTestClient({ auth: { type: 'basic', username, password } }) \u2014 or from the CLI, --auth <user:pass> --auth-scheme basic.`;
@@ -313,6 +364,10 @@ function buildAuthRequiredMessage(agentUrl, oauthMetadata, challenge) {
313
364
  }
314
365
  return `Authentication required for ${agentUrl}. No OAuth metadata available - provide auth_token in agent config.`;
315
366
  }
367
+ function getRequestSignatureRejectionCode(challenge) {
368
+ if (challenge?.scheme !== "signature" || !challenge.error) return void 0;
369
+ return Object.prototype.hasOwnProperty.call(import_enums.RequestSigningErrorCodeMetadata, challenge.error) ? challenge.error : void 0;
370
+ }
316
371
  class IdempotencyConflictError extends ADCPError {
317
372
  code = "IDEMPOTENCY_CONFLICT";
318
373
  // Exposed via the getter so `console.log(err)` and JSON.stringify don't
@@ -518,6 +573,12 @@ function is401Error(error, got401Flag = false) {
518
573
  }
519
574
  function adcpErrorToTypedError(adcpError, idempotencyKey) {
520
575
  switch (adcpError.code) {
576
+ case "ACCOUNT_NOT_FOUND":
577
+ return new AccountNotFoundError(adcpError.message);
578
+ case "ACCOUNT_SETUP_REQUIRED":
579
+ return new AccountSetupRequiredError(adcpError.message);
580
+ case "ACCOUNT_PAYMENT_REQUIRED":
581
+ return new AccountPaymentRequiredError(adcpError.message);
521
582
  case "IDEMPOTENCY_CONFLICT":
522
583
  return new IdempotencyConflictError(idempotencyKey, adcpError.message);
523
584
  case "IDEMPOTENCY_EXPIRED":
@@ -596,12 +657,17 @@ function extractErrorInfo(error) {
596
657
  0 && (module.exports = {
597
658
  ADCPError,
598
659
  AccountAmbiguousError,
660
+ AccountNotFoundError,
661
+ AccountNotProvisionedError,
662
+ AccountPaymentRequiredError,
599
663
  AccountPendingApprovalError,
600
664
  AccountRequiredError,
665
+ AccountSetupRequiredError,
601
666
  ActionNotAllowedError,
602
667
  AgentNotFoundError,
603
668
  AuthenticationCredentialsRejectedError,
604
669
  AuthenticationRequiredError,
670
+ BuyerSetupError,
605
671
  ConfigurationError,
606
672
  DeferredTaskError,
607
673
  FeatureUnsupportedError,