@adcp/sdk 12.0.0 → 12.0.2

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 (959) hide show
  1. package/dist/lib/adapters/content-standards-adapter.mjs +0 -6
  2. package/dist/lib/adapters/content-standards-adapter.mjs.map +1 -1
  3. package/dist/lib/adapters/derived-account-store.mjs +0 -6
  4. package/dist/lib/adapters/derived-account-store.mjs.map +1 -1
  5. package/dist/lib/adapters/governance-adapter.mjs +0 -6
  6. package/dist/lib/adapters/governance-adapter.mjs.map +1 -1
  7. package/dist/lib/adapters/implicit-account-store.mjs +0 -6
  8. package/dist/lib/adapters/implicit-account-store.mjs.map +1 -1
  9. package/dist/lib/adapters/index.mjs +0 -6
  10. package/dist/lib/adapters/index.mjs.map +1 -1
  11. package/dist/lib/adapters/legacy/v2-5/create_media_buy.mjs +0 -6
  12. package/dist/lib/adapters/legacy/v2-5/create_media_buy.mjs.map +1 -1
  13. package/dist/lib/adapters/legacy/v2-5/get_products.mjs +0 -6
  14. package/dist/lib/adapters/legacy/v2-5/get_products.mjs.map +1 -1
  15. package/dist/lib/adapters/legacy/v2-5/index.mjs +0 -6
  16. package/dist/lib/adapters/legacy/v2-5/index.mjs.map +1 -1
  17. package/dist/lib/adapters/legacy/v2-5/list_creative_formats.mjs +0 -6
  18. package/dist/lib/adapters/legacy/v2-5/list_creative_formats.mjs.map +1 -1
  19. package/dist/lib/adapters/legacy/v2-5/preview_creative.mjs +0 -6
  20. package/dist/lib/adapters/legacy/v2-5/preview_creative.mjs.map +1 -1
  21. package/dist/lib/adapters/legacy/v2-5/sync_creatives.mjs +0 -6
  22. package/dist/lib/adapters/legacy/v2-5/sync_creatives.mjs.map +1 -1
  23. package/dist/lib/adapters/legacy/v2-5/types.mjs +0 -6
  24. package/dist/lib/adapters/legacy/v2-5/update_media_buy.mjs +0 -6
  25. package/dist/lib/adapters/legacy/v2-5/update_media_buy.mjs.map +1 -1
  26. package/dist/lib/adapters/oauth-passthrough-resolver.mjs +0 -6
  27. package/dist/lib/adapters/oauth-passthrough-resolver.mjs.map +1 -1
  28. package/dist/lib/adapters/property-list-adapter.mjs +0 -6
  29. package/dist/lib/adapters/property-list-adapter.mjs.map +1 -1
  30. package/dist/lib/adapters/roster-account-store.mjs +0 -6
  31. package/dist/lib/adapters/roster-account-store.mjs.map +1 -1
  32. package/dist/lib/adapters/si-session-manager.mjs +0 -6
  33. package/dist/lib/adapters/si-session-manager.mjs.map +1 -1
  34. package/dist/lib/adapters/version/3.0/brand-fields.mjs +0 -6
  35. package/dist/lib/adapters/version/3.0/brand-fields.mjs.map +1 -1
  36. package/dist/lib/adapters/version/3.0/get-products.mjs +0 -6
  37. package/dist/lib/adapters/version/3.0/get-products.mjs.map +1 -1
  38. package/dist/lib/adapters/version/3.0/index.mjs +0 -6
  39. package/dist/lib/adapters/version/3.0/index.mjs.map +1 -1
  40. package/dist/lib/adapters/version/3.0/sync-accounts.mjs +0 -6
  41. package/dist/lib/adapters/version/3.0/sync-accounts.mjs.map +1 -1
  42. package/dist/lib/adapters/version/index.mjs +0 -6
  43. package/dist/lib/adapters/version/index.mjs.map +1 -1
  44. package/dist/lib/adapters/version/types.mjs +0 -6
  45. package/dist/lib/advanced.mjs +0 -6
  46. package/dist/lib/advanced.mjs.map +1 -1
  47. package/dist/lib/agents/index.generated.mjs +0 -6
  48. package/dist/lib/agents/index.generated.mjs.map +1 -1
  49. package/dist/lib/auth/index.mjs +0 -6
  50. package/dist/lib/auth/index.mjs.map +1 -1
  51. package/dist/lib/auth/oauth/CLIFlowHandler.mjs +0 -6
  52. package/dist/lib/auth/oauth/CLIFlowHandler.mjs.map +1 -1
  53. package/dist/lib/auth/oauth/ClientCredentialsFlow.mjs +0 -6
  54. package/dist/lib/auth/oauth/ClientCredentialsFlow.mjs.map +1 -1
  55. package/dist/lib/auth/oauth/MCPOAuthProvider.mjs +0 -6
  56. package/dist/lib/auth/oauth/MCPOAuthProvider.mjs.map +1 -1
  57. package/dist/lib/auth/oauth/NonInteractiveFlowHandler.mjs +0 -6
  58. package/dist/lib/auth/oauth/NonInteractiveFlowHandler.mjs.map +1 -1
  59. package/dist/lib/auth/oauth/authorization-required.mjs +0 -6
  60. package/dist/lib/auth/oauth/authorization-required.mjs.map +1 -1
  61. package/dist/lib/auth/oauth/diagnose.mjs +0 -6
  62. package/dist/lib/auth/oauth/diagnose.mjs.map +1 -1
  63. package/dist/lib/auth/oauth/diagnostics.mjs +0 -6
  64. package/dist/lib/auth/oauth/diagnostics.mjs.map +1 -1
  65. package/dist/lib/auth/oauth/discovery.mjs +0 -6
  66. package/dist/lib/auth/oauth/discovery.mjs.map +1 -1
  67. package/dist/lib/auth/oauth/file-storage.mjs +0 -6
  68. package/dist/lib/auth/oauth/file-storage.mjs.map +1 -1
  69. package/dist/lib/auth/oauth/index.mjs +0 -6
  70. package/dist/lib/auth/oauth/index.mjs.map +1 -1
  71. package/dist/lib/auth/oauth/secret-resolver.mjs +0 -6
  72. package/dist/lib/auth/oauth/secret-resolver.mjs.map +1 -1
  73. package/dist/lib/auth/oauth/storage-registry.mjs +0 -6
  74. package/dist/lib/auth/oauth/storage-registry.mjs.map +1 -1
  75. package/dist/lib/auth/oauth/types.mjs +0 -6
  76. package/dist/lib/auth/oauth/types.mjs.map +1 -1
  77. package/dist/lib/auth/oauth/web-flow.mjs +0 -6
  78. package/dist/lib/auth/oauth/web-flow.mjs.map +1 -1
  79. package/dist/lib/brand/index.mjs +0 -6
  80. package/dist/lib/brand/index.mjs.map +1 -1
  81. package/dist/lib/canonical-references/index.mjs +6 -7
  82. package/dist/lib/canonical-references/index.mjs.map +1 -1
  83. package/dist/lib/client/index.mjs +0 -6
  84. package/dist/lib/client/index.mjs.map +1 -1
  85. package/dist/lib/compliance/index.mjs +0 -6
  86. package/dist/lib/compliance/index.mjs.map +1 -1
  87. package/dist/lib/compliance-fixtures/index.mjs +0 -6
  88. package/dist/lib/compliance-fixtures/index.mjs.map +1 -1
  89. package/dist/lib/compliance-fixtures/test-authorization-server.mjs +0 -6
  90. package/dist/lib/compliance-fixtures/test-authorization-server.mjs.map +1 -1
  91. package/dist/lib/conformance/index.mjs +0 -6
  92. package/dist/lib/conformance/index.mjs.map +1 -1
  93. package/dist/lib/conformance/invariants/uniformError.mjs +0 -6
  94. package/dist/lib/conformance/invariants/uniformError.mjs.map +1 -1
  95. package/dist/lib/conformance/invariants/uniformErrorComparator.mjs +0 -6
  96. package/dist/lib/conformance/invariants/uniformErrorComparator.mjs.map +1 -1
  97. package/dist/lib/conformance/oracle.mjs +0 -6
  98. package/dist/lib/conformance/oracle.mjs.map +1 -1
  99. package/dist/lib/conformance/runConformance.mjs +0 -6
  100. package/dist/lib/conformance/runConformance.mjs.map +1 -1
  101. package/dist/lib/conformance/runners.mjs +0 -6
  102. package/dist/lib/conformance/runners.mjs.map +1 -1
  103. package/dist/lib/conformance/schemaArbitrary.mjs +0 -6
  104. package/dist/lib/conformance/schemaArbitrary.mjs.map +1 -1
  105. package/dist/lib/conformance/schemaLoader.mjs +5 -6
  106. package/dist/lib/conformance/schemaLoader.mjs.map +1 -1
  107. package/dist/lib/conformance/seeder.mjs +0 -6
  108. package/dist/lib/conformance/seeder.mjs.map +1 -1
  109. package/dist/lib/conformance/types.mjs +0 -6
  110. package/dist/lib/conformance/types.mjs.map +1 -1
  111. package/dist/lib/conformance/webhook.mjs +0 -6
  112. package/dist/lib/conformance/webhook.mjs.map +1 -1
  113. package/dist/lib/core/ADCPMultiAgentClient.mjs +0 -6
  114. package/dist/lib/core/ADCPMultiAgentClient.mjs.map +1 -1
  115. package/dist/lib/core/AgentClient.mjs +0 -6
  116. package/dist/lib/core/AgentClient.mjs.map +1 -1
  117. package/dist/lib/core/AsyncHandler.mjs +0 -6
  118. package/dist/lib/core/AsyncHandler.mjs.map +1 -1
  119. package/dist/lib/core/ConfigurationManager.mjs +0 -6
  120. package/dist/lib/core/ConfigurationManager.mjs.map +1 -1
  121. package/dist/lib/core/ConversationTypes.mjs +0 -6
  122. package/dist/lib/core/CreativeAgentClient.mjs +0 -6
  123. package/dist/lib/core/CreativeAgentClient.mjs.map +1 -1
  124. package/dist/lib/core/GovernanceMiddleware.mjs +0 -6
  125. package/dist/lib/core/GovernanceMiddleware.mjs.map +1 -1
  126. package/dist/lib/core/GovernanceTypes.mjs +0 -6
  127. package/dist/lib/core/GovernanceTypes.mjs.map +1 -1
  128. package/dist/lib/core/ProtocolResponseParser.mjs +0 -6
  129. package/dist/lib/core/ProtocolResponseParser.mjs.map +1 -1
  130. package/dist/lib/core/ResponseValidator.mjs +0 -6
  131. package/dist/lib/core/ResponseValidator.mjs.map +1 -1
  132. package/dist/lib/core/SingleAgentClient.mjs +0 -6
  133. package/dist/lib/core/SingleAgentClient.mjs.map +1 -1
  134. package/dist/lib/core/TaskEventTypes.mjs +0 -6
  135. package/dist/lib/core/TaskEventTypes.mjs.map +1 -1
  136. package/dist/lib/core/TaskExecutor.mjs +0 -6
  137. package/dist/lib/core/TaskExecutor.mjs.map +1 -1
  138. package/dist/lib/core/match.mjs +0 -6
  139. package/dist/lib/core/match.mjs.map +1 -1
  140. package/dist/lib/core/task-status.mjs +0 -6
  141. package/dist/lib/core/task-status.mjs.map +1 -1
  142. package/dist/lib/core/webhook-url.mjs +0 -6
  143. package/dist/lib/core/webhook-url.mjs.map +1 -1
  144. package/dist/lib/discovery/adagents-redirects.mjs +0 -6
  145. package/dist/lib/discovery/adagents-redirects.mjs.map +1 -1
  146. package/dist/lib/discovery/agent-directory.mjs +0 -6
  147. package/dist/lib/discovery/agent-directory.mjs.map +1 -1
  148. package/dist/lib/discovery/inline-publisher-properties.mjs +0 -6
  149. package/dist/lib/discovery/inline-publisher-properties.mjs.map +1 -1
  150. package/dist/lib/discovery/network-consistency-checker.mjs +0 -6
  151. package/dist/lib/discovery/network-consistency-checker.mjs.map +1 -1
  152. package/dist/lib/discovery/property-crawler.mjs +0 -6
  153. package/dist/lib/discovery/property-crawler.mjs.map +1 -1
  154. package/dist/lib/discovery/property-index.mjs +0 -6
  155. package/dist/lib/discovery/property-index.mjs.map +1 -1
  156. package/dist/lib/discovery/publisher-property-selector.mjs +0 -6
  157. package/dist/lib/discovery/publisher-property-selector.mjs.map +1 -1
  158. package/dist/lib/discovery/resolve-agent-properties.mjs +0 -6
  159. package/dist/lib/discovery/resolve-agent-properties.mjs.map +1 -1
  160. package/dist/lib/discovery/types.mjs +0 -6
  161. package/dist/lib/discovery/validate-adagents.mjs +0 -6
  162. package/dist/lib/discovery/validate-adagents.mjs.map +1 -1
  163. package/dist/lib/enums.mjs +0 -6
  164. package/dist/lib/enums.mjs.map +1 -1
  165. package/dist/lib/errors/index.mjs +0 -6
  166. package/dist/lib/errors/index.mjs.map +1 -1
  167. package/dist/lib/express-mcp/index.mjs +0 -6
  168. package/dist/lib/express-mcp/index.mjs.map +1 -1
  169. package/dist/lib/governance/index.mjs +0 -6
  170. package/dist/lib/governance/index.mjs.map +1 -1
  171. package/dist/lib/handlers/types.mjs +0 -6
  172. package/dist/lib/handlers/types.mjs.map +1 -1
  173. package/dist/lib/index.d.mts +1 -1
  174. package/dist/lib/index.d.ts +1 -1
  175. package/dist/lib/index.d.ts.map +1 -1
  176. package/dist/lib/index.js.map +1 -1
  177. package/dist/lib/index.mjs +0 -6
  178. package/dist/lib/index.mjs.map +1 -1
  179. package/dist/lib/media-buy/available-actions.mjs +0 -6
  180. package/dist/lib/media-buy/available-actions.mjs.map +1 -1
  181. package/dist/lib/media-buy/index.mjs +0 -6
  182. package/dist/lib/media-buy/index.mjs.map +1 -1
  183. package/dist/lib/media-buy/preflight.mjs +0 -6
  184. package/dist/lib/media-buy/preflight.mjs.map +1 -1
  185. package/dist/lib/media-buy/property-policy.mjs +0 -6
  186. package/dist/lib/media-buy/property-policy.mjs.map +1 -1
  187. package/dist/lib/media-buy/types.mjs +0 -6
  188. package/dist/lib/media-buy/types.mjs.map +1 -1
  189. package/dist/lib/media-buy/update-fields.generated.mjs +0 -6
  190. package/dist/lib/media-buy/update-fields.generated.mjs.map +1 -1
  191. package/dist/lib/mock-server/creative-ad-server/seed-data.mjs +0 -6
  192. package/dist/lib/mock-server/creative-ad-server/seed-data.mjs.map +1 -1
  193. package/dist/lib/mock-server/creative-ad-server/server.mjs +0 -6
  194. package/dist/lib/mock-server/creative-ad-server/server.mjs.map +1 -1
  195. package/dist/lib/mock-server/creative-template/seed-data.mjs +0 -6
  196. package/dist/lib/mock-server/creative-template/seed-data.mjs.map +1 -1
  197. package/dist/lib/mock-server/creative-template/server.mjs +0 -6
  198. package/dist/lib/mock-server/creative-template/server.mjs.map +1 -1
  199. package/dist/lib/mock-server/index.mjs +0 -6
  200. package/dist/lib/mock-server/index.mjs.map +1 -1
  201. package/dist/lib/mock-server/sales-guaranteed/recipe.mjs +0 -6
  202. package/dist/lib/mock-server/sales-guaranteed/recipe.mjs.map +1 -1
  203. package/dist/lib/mock-server/sales-guaranteed/seed-data.mjs +0 -6
  204. package/dist/lib/mock-server/sales-guaranteed/seed-data.mjs.map +1 -1
  205. package/dist/lib/mock-server/sales-guaranteed/server.mjs +0 -6
  206. package/dist/lib/mock-server/sales-guaranteed/server.mjs.map +1 -1
  207. package/dist/lib/mock-server/sales-non-guaranteed/recipe.mjs +0 -6
  208. package/dist/lib/mock-server/sales-non-guaranteed/recipe.mjs.map +1 -1
  209. package/dist/lib/mock-server/sales-non-guaranteed/seed-data.mjs +0 -6
  210. package/dist/lib/mock-server/sales-non-guaranteed/seed-data.mjs.map +1 -1
  211. package/dist/lib/mock-server/sales-non-guaranteed/server.mjs +0 -6
  212. package/dist/lib/mock-server/sales-non-guaranteed/server.mjs.map +1 -1
  213. package/dist/lib/mock-server/sales-social/seed-data.mjs +0 -6
  214. package/dist/lib/mock-server/sales-social/seed-data.mjs.map +1 -1
  215. package/dist/lib/mock-server/sales-social/server.mjs +0 -6
  216. package/dist/lib/mock-server/sales-social/server.mjs.map +1 -1
  217. package/dist/lib/mock-server/scenario.mjs +0 -6
  218. package/dist/lib/mock-server/scenario.mjs.map +1 -1
  219. package/dist/lib/mock-server/signal-marketplace/seed-data.mjs +0 -6
  220. package/dist/lib/mock-server/signal-marketplace/seed-data.mjs.map +1 -1
  221. package/dist/lib/mock-server/signal-marketplace/server.mjs +0 -6
  222. package/dist/lib/mock-server/signal-marketplace/server.mjs.map +1 -1
  223. package/dist/lib/mock-server/sponsored-intelligence/seed-data.mjs +0 -6
  224. package/dist/lib/mock-server/sponsored-intelligence/seed-data.mjs.map +1 -1
  225. package/dist/lib/mock-server/sponsored-intelligence/server.mjs +0 -6
  226. package/dist/lib/mock-server/sponsored-intelligence/server.mjs.map +1 -1
  227. package/dist/lib/net/address-guards.mjs +0 -6
  228. package/dist/lib/net/address-guards.mjs.map +1 -1
  229. package/dist/lib/net/index.mjs +0 -6
  230. package/dist/lib/net/index.mjs.map +1 -1
  231. package/dist/lib/net/ssrf-fetch.mjs +0 -6
  232. package/dist/lib/net/ssrf-fetch.mjs.map +1 -1
  233. package/dist/lib/observability/index.mjs +0 -6
  234. package/dist/lib/observability/index.mjs.map +1 -1
  235. package/dist/lib/observability/tracing.mjs +6 -7
  236. package/dist/lib/observability/tracing.mjs.map +1 -1
  237. package/dist/lib/protocols/a2a.mjs +0 -6
  238. package/dist/lib/protocols/a2a.mjs.map +1 -1
  239. package/dist/lib/protocols/abort.mjs +0 -6
  240. package/dist/lib/protocols/abort.mjs.map +1 -1
  241. package/dist/lib/protocols/index.mjs +0 -6
  242. package/dist/lib/protocols/index.mjs.map +1 -1
  243. package/dist/lib/protocols/mcp-modern.mjs +0 -6
  244. package/dist/lib/protocols/mcp-modern.mjs.map +1 -1
  245. package/dist/lib/protocols/mcp-tasks.mjs +0 -6
  246. package/dist/lib/protocols/mcp-tasks.mjs.map +1 -1
  247. package/dist/lib/protocols/mcp.mjs +0 -6
  248. package/dist/lib/protocols/mcp.mjs.map +1 -1
  249. package/dist/lib/protocols/rawResponseCapture.mjs +0 -6
  250. package/dist/lib/protocols/rawResponseCapture.mjs.map +1 -1
  251. package/dist/lib/protocols/responseSizeLimit.mjs +0 -6
  252. package/dist/lib/protocols/responseSizeLimit.mjs.map +1 -1
  253. package/dist/lib/protocols/transportDiagnostics.mjs +0 -6
  254. package/dist/lib/protocols/transportDiagnostics.mjs.map +1 -1
  255. package/dist/lib/registry/cursor-store.mjs +0 -6
  256. package/dist/lib/registry/cursor-store.mjs.map +1 -1
  257. package/dist/lib/registry/feed-stream.mjs +0 -6
  258. package/dist/lib/registry/feed-stream.mjs.map +1 -1
  259. package/dist/lib/registry/index.mjs +0 -6
  260. package/dist/lib/registry/index.mjs.map +1 -1
  261. package/dist/lib/registry/property-registry.mjs +0 -6
  262. package/dist/lib/registry/property-registry.mjs.map +1 -1
  263. package/dist/lib/registry/sync.mjs +0 -6
  264. package/dist/lib/registry/sync.mjs.map +1 -1
  265. package/dist/lib/registry/types.generated.mjs +0 -6
  266. package/dist/lib/registry/types.mjs +0 -6
  267. package/dist/lib/schemas/index.mjs +0 -6
  268. package/dist/lib/schemas/index.mjs.map +1 -1
  269. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  270. package/dist/lib/server/a2a-adapter.mjs +0 -6
  271. package/dist/lib/server/a2a-adapter.mjs.map +1 -1
  272. package/dist/lib/server/account-mode.mjs +0 -6
  273. package/dist/lib/server/account-mode.mjs.map +1 -1
  274. package/dist/lib/server/adcp-server.mjs +0 -6
  275. package/dist/lib/server/adcp-server.mjs.map +1 -1
  276. package/dist/lib/server/auth-introspection.mjs +0 -6
  277. package/dist/lib/server/auth-introspection.mjs.map +1 -1
  278. package/dist/lib/server/auth-signature.mjs +0 -6
  279. package/dist/lib/server/auth-signature.mjs.map +1 -1
  280. package/dist/lib/server/auth.mjs +0 -6
  281. package/dist/lib/server/auth.mjs.map +1 -1
  282. package/dist/lib/server/create-adcp-server.d.mts +13 -0
  283. package/dist/lib/server/create-adcp-server.d.ts +13 -0
  284. package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
  285. package/dist/lib/server/create-adcp-server.js +3 -2
  286. package/dist/lib/server/create-adcp-server.js.map +1 -1
  287. package/dist/lib/server/create-adcp-server.mjs +3 -8
  288. package/dist/lib/server/create-adcp-server.mjs.map +1 -1
  289. package/dist/lib/server/credential-policy.mjs +0 -6
  290. package/dist/lib/server/credential-policy.mjs.map +1 -1
  291. package/dist/lib/server/ctx-metadata/backends/memory.mjs +0 -6
  292. package/dist/lib/server/ctx-metadata/backends/memory.mjs.map +1 -1
  293. package/dist/lib/server/ctx-metadata/backends/pg.mjs +0 -6
  294. package/dist/lib/server/ctx-metadata/backends/pg.mjs.map +1 -1
  295. package/dist/lib/server/ctx-metadata/backends/redis.mjs +0 -6
  296. package/dist/lib/server/ctx-metadata/backends/redis.mjs.map +1 -1
  297. package/dist/lib/server/ctx-metadata/index.mjs +0 -6
  298. package/dist/lib/server/ctx-metadata/index.mjs.map +1 -1
  299. package/dist/lib/server/ctx-metadata/store.mjs +0 -6
  300. package/dist/lib/server/ctx-metadata/store.mjs.map +1 -1
  301. package/dist/lib/server/ctx-metadata/wire-shape.mjs +0 -6
  302. package/dist/lib/server/ctx-metadata/wire-shape.mjs.map +1 -1
  303. package/dist/lib/server/decisioning/account.mjs +0 -6
  304. package/dist/lib/server/decisioning/account.mjs.map +1 -1
  305. package/dist/lib/server/decisioning/admin-router.mjs +0 -6
  306. package/dist/lib/server/decisioning/admin-router.mjs.map +1 -1
  307. package/dist/lib/server/decisioning/assembly-helpers.mjs +0 -6
  308. package/dist/lib/server/decisioning/assembly-helpers.mjs.map +1 -1
  309. package/dist/lib/server/decisioning/async-outcome.mjs +0 -6
  310. package/dist/lib/server/decisioning/async-outcome.mjs.map +1 -1
  311. package/dist/lib/server/decisioning/buyer-agent.mjs +0 -6
  312. package/dist/lib/server/decisioning/buyer-agent.mjs.map +1 -1
  313. package/dist/lib/server/decisioning/capabilities.mjs +0 -6
  314. package/dist/lib/server/decisioning/capabilities.mjs.map +1 -1
  315. package/dist/lib/server/decisioning/compose.mjs +0 -6
  316. package/dist/lib/server/decisioning/compose.mjs.map +1 -1
  317. package/dist/lib/server/decisioning/context.mjs +0 -6
  318. package/dist/lib/server/decisioning/errors-typed.mjs +0 -6
  319. package/dist/lib/server/decisioning/errors-typed.mjs.map +1 -1
  320. package/dist/lib/server/decisioning/helpers.mjs +0 -6
  321. package/dist/lib/server/decisioning/helpers.mjs.map +1 -1
  322. package/dist/lib/server/decisioning/index.mjs +0 -6
  323. package/dist/lib/server/decisioning/index.mjs.map +1 -1
  324. package/dist/lib/server/decisioning/list-helpers.mjs +0 -6
  325. package/dist/lib/server/decisioning/list-helpers.mjs.map +1 -1
  326. package/dist/lib/server/decisioning/manifest-helpers.mjs +0 -6
  327. package/dist/lib/server/decisioning/manifest-helpers.mjs.map +1 -1
  328. package/dist/lib/server/decisioning/pagination.mjs +0 -6
  329. package/dist/lib/server/decisioning/platform-helpers.mjs +0 -6
  330. package/dist/lib/server/decisioning/platform-helpers.mjs.map +1 -1
  331. package/dist/lib/server/decisioning/platform.mjs +0 -6
  332. package/dist/lib/server/decisioning/proposal/dispatch.mjs +0 -6
  333. package/dist/lib/server/decisioning/proposal/dispatch.mjs.map +1 -1
  334. package/dist/lib/server/decisioning/proposal/index.mjs +0 -6
  335. package/dist/lib/server/decisioning/proposal/index.mjs.map +1 -1
  336. package/dist/lib/server/decisioning/proposal/lifecycle.mjs +0 -6
  337. package/dist/lib/server/decisioning/proposal/lifecycle.mjs.map +1 -1
  338. package/dist/lib/server/decisioning/proposal/mock-manager.mjs +0 -6
  339. package/dist/lib/server/decisioning/proposal/mock-manager.mjs.map +1 -1
  340. package/dist/lib/server/decisioning/proposal/store.mjs +0 -6
  341. package/dist/lib/server/decisioning/proposal/store.mjs.map +1 -1
  342. package/dist/lib/server/decisioning/proposal/types.mjs +0 -6
  343. package/dist/lib/server/decisioning/proposal/types.mjs.map +1 -1
  344. package/dist/lib/server/decisioning/resolve-presets.mjs +0 -6
  345. package/dist/lib/server/decisioning/resolve-presets.mjs.map +1 -1
  346. package/dist/lib/server/decisioning/runtime/entity-hydration.generated.mjs +0 -6
  347. package/dist/lib/server/decisioning/runtime/entity-hydration.generated.mjs.map +1 -1
  348. package/dist/lib/server/decisioning/runtime/from-platform.mjs +0 -6
  349. package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
  350. package/dist/lib/server/decisioning/runtime/observed-modes.mjs +0 -6
  351. package/dist/lib/server/decisioning/runtime/observed-modes.mjs.map +1 -1
  352. package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs +0 -6
  353. package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs.map +1 -1
  354. package/dist/lib/server/decisioning/runtime/protocol-for-tool.mjs +0 -6
  355. package/dist/lib/server/decisioning/runtime/protocol-for-tool.mjs.map +1 -1
  356. package/dist/lib/server/decisioning/runtime/task-registry.mjs +0 -6
  357. package/dist/lib/server/decisioning/runtime/task-registry.mjs.map +1 -1
  358. package/dist/lib/server/decisioning/runtime/to-context.mjs +0 -6
  359. package/dist/lib/server/decisioning/runtime/to-context.mjs.map +1 -1
  360. package/dist/lib/server/decisioning/runtime/validate-platform.mjs +0 -6
  361. package/dist/lib/server/decisioning/runtime/validate-platform.mjs.map +1 -1
  362. package/dist/lib/server/decisioning/specialisms/audiences.mjs +0 -6
  363. package/dist/lib/server/decisioning/specialisms/brand-rights.mjs +0 -6
  364. package/dist/lib/server/decisioning/specialisms/campaign-governance.mjs +0 -6
  365. package/dist/lib/server/decisioning/specialisms/content-standards.mjs +0 -6
  366. package/dist/lib/server/decisioning/specialisms/creative-ad-server.mjs +0 -6
  367. package/dist/lib/server/decisioning/specialisms/creative.mjs +0 -6
  368. package/dist/lib/server/decisioning/specialisms/lists.mjs +0 -6
  369. package/dist/lib/server/decisioning/specialisms/sales.mjs +0 -6
  370. package/dist/lib/server/decisioning/specialisms/signals.mjs +0 -6
  371. package/dist/lib/server/decisioning/specialisms/sponsored-intelligence.mjs +0 -6
  372. package/dist/lib/server/decisioning/start-time.mjs +0 -6
  373. package/dist/lib/server/decisioning/start-time.mjs.map +1 -1
  374. package/dist/lib/server/decisioning/status-changes.mjs +0 -6
  375. package/dist/lib/server/decisioning/status-changes.mjs.map +1 -1
  376. package/dist/lib/server/decisioning/status-mappers.mjs +0 -6
  377. package/dist/lib/server/decisioning/status-mappers.mjs.map +1 -1
  378. package/dist/lib/server/decisioning/tenant-registry.mjs +0 -6
  379. package/dist/lib/server/decisioning/tenant-registry.mjs.map +1 -1
  380. package/dist/lib/server/decisioning/tenant-store.mjs +0 -6
  381. package/dist/lib/server/decisioning/tenant-store.mjs.map +1 -1
  382. package/dist/lib/server/decisioning/validate-specialisms.mjs +0 -6
  383. package/dist/lib/server/decisioning/validate-specialisms.mjs.map +1 -1
  384. package/dist/lib/server/dynamic-registry.mjs +0 -6
  385. package/dist/lib/server/dynamic-registry.mjs.map +1 -1
  386. package/dist/lib/server/envelope-allowlist.mjs +0 -6
  387. package/dist/lib/server/envelope-allowlist.mjs.map +1 -1
  388. package/dist/lib/server/error-arm-tools.mjs +5 -6
  389. package/dist/lib/server/error-arm-tools.mjs.map +1 -1
  390. package/dist/lib/server/errors.mjs +0 -6
  391. package/dist/lib/server/errors.mjs.map +1 -1
  392. package/dist/lib/server/example-tld-guard.mjs +0 -6
  393. package/dist/lib/server/example-tld-guard.mjs.map +1 -1
  394. package/dist/lib/server/express-adapter.mjs +0 -6
  395. package/dist/lib/server/express-adapter.mjs.map +1 -1
  396. package/dist/lib/server/governance.mjs +0 -6
  397. package/dist/lib/server/governance.mjs.map +1 -1
  398. package/dist/lib/server/idempotency/backends/lazy.mjs +0 -6
  399. package/dist/lib/server/idempotency/backends/lazy.mjs.map +1 -1
  400. package/dist/lib/server/idempotency/backends/memory.mjs +0 -6
  401. package/dist/lib/server/idempotency/backends/memory.mjs.map +1 -1
  402. package/dist/lib/server/idempotency/backends/pg.mjs +0 -6
  403. package/dist/lib/server/idempotency/backends/pg.mjs.map +1 -1
  404. package/dist/lib/server/idempotency/backends/redis.mjs +0 -6
  405. package/dist/lib/server/idempotency/backends/redis.mjs.map +1 -1
  406. package/dist/lib/server/idempotency/index.mjs +0 -6
  407. package/dist/lib/server/idempotency/index.mjs.map +1 -1
  408. package/dist/lib/server/idempotency/store.mjs +0 -6
  409. package/dist/lib/server/idempotency/store.mjs.map +1 -1
  410. package/dist/lib/server/index.d.mts +1 -1
  411. package/dist/lib/server/index.d.ts +1 -1
  412. package/dist/lib/server/index.d.ts.map +1 -1
  413. package/dist/lib/server/index.js.map +1 -1
  414. package/dist/lib/server/index.mjs +0 -6
  415. package/dist/lib/server/index.mjs.map +1 -1
  416. package/dist/lib/server/legacy/v5/index.d.mts +1 -1
  417. package/dist/lib/server/legacy/v5/index.d.ts +1 -1
  418. package/dist/lib/server/legacy/v5/index.d.ts.map +1 -1
  419. package/dist/lib/server/legacy/v5/index.js.map +1 -1
  420. package/dist/lib/server/legacy/v5/index.mjs +0 -6
  421. package/dist/lib/server/legacy/v5/index.mjs.map +1 -1
  422. package/dist/lib/server/mcp-modern-server.mjs +0 -6
  423. package/dist/lib/server/mcp-modern-server.mjs.map +1 -1
  424. package/dist/lib/server/media-buy-actions.mjs +0 -6
  425. package/dist/lib/server/media-buy-actions.mjs.map +1 -1
  426. package/dist/lib/server/media-buy-helpers.mjs +0 -6
  427. package/dist/lib/server/media-buy-helpers.mjs.map +1 -1
  428. package/dist/lib/server/media-buy-store.mjs +0 -6
  429. package/dist/lib/server/media-buy-store.mjs.map +1 -1
  430. package/dist/lib/server/normalize-errors.mjs +0 -6
  431. package/dist/lib/server/normalize-errors.mjs.map +1 -1
  432. package/dist/lib/server/operational-platform.mjs +0 -6
  433. package/dist/lib/server/operational-platform.mjs.map +1 -1
  434. package/dist/lib/server/pick-safe-details.mjs +0 -6
  435. package/dist/lib/server/pick-safe-details.mjs.map +1 -1
  436. package/dist/lib/server/pin-and-bind-fetch.mjs +0 -6
  437. package/dist/lib/server/pin-and-bind-fetch.mjs.map +1 -1
  438. package/dist/lib/server/postgres-state-store.mjs +0 -6
  439. package/dist/lib/server/postgres-state-store.mjs.map +1 -1
  440. package/dist/lib/server/postgres-task-store.mjs +0 -6
  441. package/dist/lib/server/postgres-task-store.mjs.map +1 -1
  442. package/dist/lib/server/product-defaults.mjs +0 -6
  443. package/dist/lib/server/product-defaults.mjs.map +1 -1
  444. package/dist/lib/server/redact.mjs +0 -6
  445. package/dist/lib/server/redact.mjs.map +1 -1
  446. package/dist/lib/server/responses.mjs +0 -6
  447. package/dist/lib/server/responses.mjs.map +1 -1
  448. package/dist/lib/server/serve.mjs +0 -6
  449. package/dist/lib/server/serve.mjs.map +1 -1
  450. package/dist/lib/server/socket-mode/conformance-client.mjs +0 -6
  451. package/dist/lib/server/socket-mode/conformance-client.mjs.map +1 -1
  452. package/dist/lib/server/socket-mode/index.mjs +0 -6
  453. package/dist/lib/server/socket-mode/index.mjs.map +1 -1
  454. package/dist/lib/server/socket-mode/ws-transport.mjs +0 -6
  455. package/dist/lib/server/socket-mode/ws-transport.mjs.map +1 -1
  456. package/dist/lib/server/state-machine.mjs +0 -6
  457. package/dist/lib/server/state-machine.mjs.map +1 -1
  458. package/dist/lib/server/state-store.mjs +0 -6
  459. package/dist/lib/server/state-store.mjs.map +1 -1
  460. package/dist/lib/server/structured-serialize.mjs +0 -6
  461. package/dist/lib/server/structured-serialize.mjs.map +1 -1
  462. package/dist/lib/server/targeting-helpers.mjs +0 -6
  463. package/dist/lib/server/targeting-helpers.mjs.map +1 -1
  464. package/dist/lib/server/tasks.mjs +0 -6
  465. package/dist/lib/server/tasks.mjs.map +1 -1
  466. package/dist/lib/server/test-controller-bridge.mjs +0 -6
  467. package/dist/lib/server/test-controller-bridge.mjs.map +1 -1
  468. package/dist/lib/server/test-controller.mjs +0 -6
  469. package/dist/lib/server/test-controller.mjs.map +1 -1
  470. package/dist/lib/server/upstream-helpers.mjs +0 -6
  471. package/dist/lib/server/upstream-helpers.mjs.map +1 -1
  472. package/dist/lib/server/webhook-emitter.mjs +0 -6
  473. package/dist/lib/server/webhook-emitter.mjs.map +1 -1
  474. package/dist/lib/server/wire-safe.mjs +0 -6
  475. package/dist/lib/server/wire-safe.mjs.map +1 -1
  476. package/dist/lib/server/wire-spec-fields.generated.mjs +0 -6
  477. package/dist/lib/server/wire-spec-fields.generated.mjs.map +1 -1
  478. package/dist/lib/server/wrap-envelope.mjs +0 -6
  479. package/dist/lib/server/wrap-envelope.mjs.map +1 -1
  480. package/dist/lib/signing/agent-context.mjs +0 -6
  481. package/dist/lib/signing/agent-context.mjs.map +1 -1
  482. package/dist/lib/signing/agent-fetch.mjs +0 -6
  483. package/dist/lib/signing/agent-fetch.mjs.map +1 -1
  484. package/dist/lib/signing/agent-resolver/canonicalize.mjs +0 -6
  485. package/dist/lib/signing/agent-resolver/canonicalize.mjs.map +1 -1
  486. package/dist/lib/signing/agent-resolver/capabilities-types.mjs +0 -6
  487. package/dist/lib/signing/agent-resolver/capabilities-types.mjs.map +1 -1
  488. package/dist/lib/signing/agent-resolver/consistency.mjs +0 -6
  489. package/dist/lib/signing/agent-resolver/consistency.mjs.map +1 -1
  490. package/dist/lib/signing/agent-resolver/errors.mjs +0 -6
  491. package/dist/lib/signing/agent-resolver/errors.mjs.map +1 -1
  492. package/dist/lib/signing/agent-resolver/etld.mjs +0 -6
  493. package/dist/lib/signing/agent-resolver/etld.mjs.map +1 -1
  494. package/dist/lib/signing/agent-resolver/fetch-helpers.mjs +0 -6
  495. package/dist/lib/signing/agent-resolver/fetch-helpers.mjs.map +1 -1
  496. package/dist/lib/signing/agent-resolver/index.mjs +0 -6
  497. package/dist/lib/signing/agent-resolver/index.mjs.map +1 -1
  498. package/dist/lib/signing/agent-resolver/jwks-set.mjs +0 -6
  499. package/dist/lib/signing/agent-resolver/jwks-set.mjs.map +1 -1
  500. package/dist/lib/signing/agent-resolver/resolve-agent.mjs +0 -6
  501. package/dist/lib/signing/agent-resolver/resolve-agent.mjs.map +1 -1
  502. package/dist/lib/signing/agent-resolver/select-agent.mjs +0 -6
  503. package/dist/lib/signing/agent-resolver/select-agent.mjs.map +1 -1
  504. package/dist/lib/signing/agent-resolver/strict-json.mjs +0 -6
  505. package/dist/lib/signing/agent-resolver/strict-json.mjs.map +1 -1
  506. package/dist/lib/signing/brand-jwks.mjs +0 -6
  507. package/dist/lib/signing/brand-jwks.mjs.map +1 -1
  508. package/dist/lib/signing/canonicalize.mjs +0 -6
  509. package/dist/lib/signing/canonicalize.mjs.map +1 -1
  510. package/dist/lib/signing/capability-cache.mjs +0 -6
  511. package/dist/lib/signing/capability-cache.mjs.map +1 -1
  512. package/dist/lib/signing/capability-priming.mjs +0 -6
  513. package/dist/lib/signing/capability-priming.mjs.map +1 -1
  514. package/dist/lib/signing/client.mjs +0 -6
  515. package/dist/lib/signing/client.mjs.map +1 -1
  516. package/dist/lib/signing/content-digest.mjs +0 -6
  517. package/dist/lib/signing/content-digest.mjs.map +1 -1
  518. package/dist/lib/signing/crypto.mjs +0 -6
  519. package/dist/lib/signing/crypto.mjs.map +1 -1
  520. package/dist/lib/signing/ecdsa-encoding.mjs +0 -6
  521. package/dist/lib/signing/ecdsa-encoding.mjs.map +1 -1
  522. package/dist/lib/signing/errors.mjs +0 -6
  523. package/dist/lib/signing/errors.mjs.map +1 -1
  524. package/dist/lib/signing/fetch-async.mjs +0 -6
  525. package/dist/lib/signing/fetch-async.mjs.map +1 -1
  526. package/dist/lib/signing/fetch.mjs +0 -6
  527. package/dist/lib/signing/fetch.mjs.map +1 -1
  528. package/dist/lib/signing/index.mjs +0 -6
  529. package/dist/lib/signing/index.mjs.map +1 -1
  530. package/dist/lib/signing/jwks-helpers.mjs +0 -6
  531. package/dist/lib/signing/jwks-helpers.mjs.map +1 -1
  532. package/dist/lib/signing/jwks-https.mjs +0 -6
  533. package/dist/lib/signing/jwks-https.mjs.map +1 -1
  534. package/dist/lib/signing/jwks.mjs +0 -6
  535. package/dist/lib/signing/jwks.mjs.map +1 -1
  536. package/dist/lib/signing/middleware.mjs +0 -6
  537. package/dist/lib/signing/middleware.mjs.map +1 -1
  538. package/dist/lib/signing/parser.mjs +0 -6
  539. package/dist/lib/signing/parser.mjs.map +1 -1
  540. package/dist/lib/signing/postgres-replay-store.mjs +0 -6
  541. package/dist/lib/signing/postgres-replay-store.mjs.map +1 -1
  542. package/dist/lib/signing/protocol-response.mjs +0 -6
  543. package/dist/lib/signing/protocol-response.mjs.map +1 -1
  544. package/dist/lib/signing/provider.mjs +0 -6
  545. package/dist/lib/signing/redis-replay-store.mjs +0 -6
  546. package/dist/lib/signing/redis-replay-store.mjs.map +1 -1
  547. package/dist/lib/signing/replay.mjs +0 -6
  548. package/dist/lib/signing/replay.mjs.map +1 -1
  549. package/dist/lib/signing/request-context.mjs +0 -6
  550. package/dist/lib/signing/request-context.mjs.map +1 -1
  551. package/dist/lib/signing/revocation-https.mjs +0 -6
  552. package/dist/lib/signing/revocation-https.mjs.map +1 -1
  553. package/dist/lib/signing/revocation.mjs +0 -6
  554. package/dist/lib/signing/revocation.mjs.map +1 -1
  555. package/dist/lib/signing/server.mjs +0 -6
  556. package/dist/lib/signing/server.mjs.map +1 -1
  557. package/dist/lib/signing/signer-async.mjs +0 -6
  558. package/dist/lib/signing/signer-async.mjs.map +1 -1
  559. package/dist/lib/signing/signer.mjs +0 -6
  560. package/dist/lib/signing/signer.mjs.map +1 -1
  561. package/dist/lib/signing/testing.mjs +0 -6
  562. package/dist/lib/signing/testing.mjs.map +1 -1
  563. package/dist/lib/signing/types.mjs +0 -6
  564. package/dist/lib/signing/types.mjs.map +1 -1
  565. package/dist/lib/signing/verifier.mjs +0 -6
  566. package/dist/lib/signing/verifier.mjs.map +1 -1
  567. package/dist/lib/signing/webhook-auth-detection.mjs +0 -6
  568. package/dist/lib/signing/webhook-auth-detection.mjs.map +1 -1
  569. package/dist/lib/signing/webhook-verifier.mjs +0 -6
  570. package/dist/lib/signing/webhook-verifier.mjs.map +1 -1
  571. package/dist/lib/storage/MemoryStorage.mjs +0 -6
  572. package/dist/lib/storage/MemoryStorage.mjs.map +1 -1
  573. package/dist/lib/storage/interfaces.mjs +0 -6
  574. package/dist/lib/substitution/encoder/SubstitutionEncoder.mjs +0 -6
  575. package/dist/lib/substitution/encoder/SubstitutionEncoder.mjs.map +1 -1
  576. package/dist/lib/substitution/encoder/index.mjs +0 -6
  577. package/dist/lib/substitution/encoder/index.mjs.map +1 -1
  578. package/dist/lib/substitution/index.mjs +0 -6
  579. package/dist/lib/substitution/index.mjs.map +1 -1
  580. package/dist/lib/substitution/observer/SubstitutionObserver.mjs +0 -6
  581. package/dist/lib/substitution/observer/SubstitutionObserver.mjs.map +1 -1
  582. package/dist/lib/substitution/observer/alignment.mjs +0 -6
  583. package/dist/lib/substitution/observer/alignment.mjs.map +1 -1
  584. package/dist/lib/substitution/observer/assertions.mjs +0 -6
  585. package/dist/lib/substitution/observer/assertions.mjs.map +1 -1
  586. package/dist/lib/substitution/observer/html-parser.mjs +0 -6
  587. package/dist/lib/substitution/observer/html-parser.mjs.map +1 -1
  588. package/dist/lib/substitution/observer/index.mjs +0 -6
  589. package/dist/lib/substitution/observer/index.mjs.map +1 -1
  590. package/dist/lib/substitution/observer/ssrf.mjs +0 -6
  591. package/dist/lib/substitution/observer/ssrf.mjs.map +1 -1
  592. package/dist/lib/substitution/rfc3986.mjs +0 -6
  593. package/dist/lib/substitution/rfc3986.mjs.map +1 -1
  594. package/dist/lib/substitution/translate.mjs +0 -6
  595. package/dist/lib/substitution/translate.mjs.map +1 -1
  596. package/dist/lib/substitution/types.mjs +0 -6
  597. package/dist/lib/substitution/vectors.mjs +0 -6
  598. package/dist/lib/substitution/vectors.mjs.map +1 -1
  599. package/dist/lib/testing/agent-tester.mjs +0 -6
  600. package/dist/lib/testing/agent-tester.mjs.map +1 -1
  601. package/dist/lib/testing/client.mjs +0 -6
  602. package/dist/lib/testing/client.mjs.map +1 -1
  603. package/dist/lib/testing/compliance/briefs.mjs +0 -6
  604. package/dist/lib/testing/compliance/briefs.mjs.map +1 -1
  605. package/dist/lib/testing/compliance/comply.mjs +0 -6
  606. package/dist/lib/testing/compliance/comply.mjs.map +1 -1
  607. package/dist/lib/testing/compliance/index.mjs +0 -6
  608. package/dist/lib/testing/compliance/index.mjs.map +1 -1
  609. package/dist/lib/testing/compliance/spec-conformance.mjs +0 -6
  610. package/dist/lib/testing/compliance/spec-conformance.mjs.map +1 -1
  611. package/dist/lib/testing/compliance/storyboard-tracks.mjs +0 -6
  612. package/dist/lib/testing/compliance/storyboard-tracks.mjs.map +1 -1
  613. package/dist/lib/testing/compliance/summary.mjs +0 -6
  614. package/dist/lib/testing/compliance/summary.mjs.map +1 -1
  615. package/dist/lib/testing/compliance/types.mjs +0 -6
  616. package/dist/lib/testing/comply-controller.mjs +0 -6
  617. package/dist/lib/testing/comply-controller.mjs.map +1 -1
  618. package/dist/lib/testing/controller-assertions.mjs +0 -6
  619. package/dist/lib/testing/controller-assertions.mjs.map +1 -1
  620. package/dist/lib/testing/formatter.mjs +0 -6
  621. package/dist/lib/testing/formatter.mjs.map +1 -1
  622. package/dist/lib/testing/index.mjs +0 -6
  623. package/dist/lib/testing/index.mjs.map +1 -1
  624. package/dist/lib/testing/local-agent-runner.mjs +0 -6
  625. package/dist/lib/testing/local-agent-runner.mjs.map +1 -1
  626. package/dist/lib/testing/orchestrator.mjs +0 -6
  627. package/dist/lib/testing/orchestrator.mjs.map +1 -1
  628. package/dist/lib/testing/personas/index.mjs +0 -6
  629. package/dist/lib/testing/personas/index.mjs.map +1 -1
  630. package/dist/lib/testing/scenarios/brand-rights.mjs +0 -6
  631. package/dist/lib/testing/scenarios/brand-rights.mjs.map +1 -1
  632. package/dist/lib/testing/scenarios/capabilities.mjs +0 -6
  633. package/dist/lib/testing/scenarios/capabilities.mjs.map +1 -1
  634. package/dist/lib/testing/scenarios/creative.mjs +0 -6
  635. package/dist/lib/testing/scenarios/creative.mjs.map +1 -1
  636. package/dist/lib/testing/scenarios/deterministic.mjs +0 -6
  637. package/dist/lib/testing/scenarios/deterministic.mjs.map +1 -1
  638. package/dist/lib/testing/scenarios/discovery.mjs +0 -6
  639. package/dist/lib/testing/scenarios/discovery.mjs.map +1 -1
  640. package/dist/lib/testing/scenarios/edge-cases.mjs +0 -6
  641. package/dist/lib/testing/scenarios/edge-cases.mjs.map +1 -1
  642. package/dist/lib/testing/scenarios/error-compliance.mjs +0 -6
  643. package/dist/lib/testing/scenarios/error-compliance.mjs.map +1 -1
  644. package/dist/lib/testing/scenarios/governance.mjs +0 -6
  645. package/dist/lib/testing/scenarios/governance.mjs.map +1 -1
  646. package/dist/lib/testing/scenarios/health.mjs +0 -6
  647. package/dist/lib/testing/scenarios/health.mjs.map +1 -1
  648. package/dist/lib/testing/scenarios/index.mjs +0 -6
  649. package/dist/lib/testing/scenarios/index.mjs.map +1 -1
  650. package/dist/lib/testing/scenarios/media-buy.mjs +0 -6
  651. package/dist/lib/testing/scenarios/media-buy.mjs.map +1 -1
  652. package/dist/lib/testing/scenarios/schema-compliance.mjs +0 -6
  653. package/dist/lib/testing/scenarios/schema-compliance.mjs.map +1 -1
  654. package/dist/lib/testing/scenarios/signals.mjs +0 -6
  655. package/dist/lib/testing/scenarios/signals.mjs.map +1 -1
  656. package/dist/lib/testing/scenarios/sponsored-intelligence.mjs +0 -6
  657. package/dist/lib/testing/scenarios/sponsored-intelligence.mjs.map +1 -1
  658. package/dist/lib/testing/scenarios/trusted-match.mjs +0 -6
  659. package/dist/lib/testing/scenarios/trusted-match.mjs.map +1 -1
  660. package/dist/lib/testing/seed-merge.mjs +0 -6
  661. package/dist/lib/testing/seed-merge.mjs.map +1 -1
  662. package/dist/lib/testing/storyboard/agent-routing.mjs +0 -6
  663. package/dist/lib/testing/storyboard/agent-routing.mjs.map +1 -1
  664. package/dist/lib/testing/storyboard/assertions.mjs +0 -6
  665. package/dist/lib/testing/storyboard/assertions.mjs.map +1 -1
  666. package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +0 -6
  667. package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs.map +1 -1
  668. package/dist/lib/testing/storyboard/compliance.mjs +5 -6
  669. package/dist/lib/testing/storyboard/compliance.mjs.map +1 -1
  670. package/dist/lib/testing/storyboard/context.mjs +0 -6
  671. package/dist/lib/testing/storyboard/context.mjs.map +1 -1
  672. package/dist/lib/testing/storyboard/default-invariants.mjs +0 -6
  673. package/dist/lib/testing/storyboard/default-invariants.mjs.map +1 -1
  674. package/dist/lib/testing/storyboard/index.mjs +0 -6
  675. package/dist/lib/testing/storyboard/index.mjs.map +1 -1
  676. package/dist/lib/testing/storyboard/junit.mjs +0 -6
  677. package/dist/lib/testing/storyboard/junit.mjs.map +1 -1
  678. package/dist/lib/testing/storyboard/loader.mjs +0 -6
  679. package/dist/lib/testing/storyboard/loader.mjs.map +1 -1
  680. package/dist/lib/testing/storyboard/parallel-dispatch.mjs +0 -6
  681. package/dist/lib/testing/storyboard/parallel-dispatch.mjs.map +1 -1
  682. package/dist/lib/testing/storyboard/path.mjs +0 -6
  683. package/dist/lib/testing/storyboard/path.mjs.map +1 -1
  684. package/dist/lib/testing/storyboard/probes.mjs +0 -6
  685. package/dist/lib/testing/storyboard/probes.mjs.map +1 -1
  686. package/dist/lib/testing/storyboard/rate-limit-trip.mjs +0 -6
  687. package/dist/lib/testing/storyboard/rate-limit-trip.mjs.map +1 -1
  688. package/dist/lib/testing/storyboard/rejection-hints.mjs +0 -6
  689. package/dist/lib/testing/storyboard/rejection-hints.mjs.map +1 -1
  690. package/dist/lib/testing/storyboard/request-builder.mjs +0 -6
  691. package/dist/lib/testing/storyboard/request-builder.mjs.map +1 -1
  692. package/dist/lib/testing/storyboard/request-signing/builder.mjs +0 -6
  693. package/dist/lib/testing/storyboard/request-signing/builder.mjs.map +1 -1
  694. package/dist/lib/testing/storyboard/request-signing/grader.mjs +0 -6
  695. package/dist/lib/testing/storyboard/request-signing/grader.mjs.map +1 -1
  696. package/dist/lib/testing/storyboard/request-signing/index.mjs +0 -6
  697. package/dist/lib/testing/storyboard/request-signing/index.mjs.map +1 -1
  698. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs +0 -6
  699. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs.map +1 -1
  700. package/dist/lib/testing/storyboard/request-signing/probe.mjs +0 -6
  701. package/dist/lib/testing/storyboard/request-signing/probe.mjs.map +1 -1
  702. package/dist/lib/testing/storyboard/request-signing/synthesize.mjs +0 -6
  703. package/dist/lib/testing/storyboard/request-signing/synthesize.mjs.map +1 -1
  704. package/dist/lib/testing/storyboard/request-signing/test-kit.mjs +0 -6
  705. package/dist/lib/testing/storyboard/request-signing/test-kit.mjs.map +1 -1
  706. package/dist/lib/testing/storyboard/request-signing/types.mjs +0 -6
  707. package/dist/lib/testing/storyboard/request-signing/types.mjs.map +1 -1
  708. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +0 -6
  709. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs.map +1 -1
  710. package/dist/lib/testing/storyboard/runner.mjs +0 -6
  711. package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
  712. package/dist/lib/testing/storyboard/sandbox-entities.mjs +0 -6
  713. package/dist/lib/testing/storyboard/sandbox-entities.mjs.map +1 -1
  714. package/dist/lib/testing/storyboard/seeding.mjs +0 -6
  715. package/dist/lib/testing/storyboard/seeding.mjs.map +1 -1
  716. package/dist/lib/testing/storyboard/shape-drift-hints.mjs +0 -6
  717. package/dist/lib/testing/storyboard/shape-drift-hints.mjs.map +1 -1
  718. package/dist/lib/testing/storyboard/signer-grader/grader.mjs +0 -6
  719. package/dist/lib/testing/storyboard/signer-grader/grader.mjs.map +1 -1
  720. package/dist/lib/testing/storyboard/signer-grader/index.mjs +0 -6
  721. package/dist/lib/testing/storyboard/signer-grader/index.mjs.map +1 -1
  722. package/dist/lib/testing/storyboard/signer-grader/types.mjs +0 -6
  723. package/dist/lib/testing/storyboard/strict-validation-hints.mjs +0 -6
  724. package/dist/lib/testing/storyboard/strict-validation-hints.mjs.map +1 -1
  725. package/dist/lib/testing/storyboard/task-map.mjs +0 -6
  726. package/dist/lib/testing/storyboard/task-map.mjs.map +1 -1
  727. package/dist/lib/testing/storyboard/test-kit.mjs +0 -6
  728. package/dist/lib/testing/storyboard/test-kit.mjs.map +1 -1
  729. package/dist/lib/testing/storyboard/types.mjs +0 -6
  730. package/dist/lib/testing/storyboard/types.mjs.map +1 -1
  731. package/dist/lib/testing/storyboard/validations.mjs +0 -6
  732. package/dist/lib/testing/storyboard/validations.mjs.map +1 -1
  733. package/dist/lib/testing/storyboard/webhook-assertions.mjs +0 -6
  734. package/dist/lib/testing/storyboard/webhook-assertions.mjs.map +1 -1
  735. package/dist/lib/testing/storyboard/webhook-receiver.mjs +0 -6
  736. package/dist/lib/testing/storyboard/webhook-receiver.mjs.map +1 -1
  737. package/dist/lib/testing/stubs/governance-agent-stub.mjs +0 -6
  738. package/dist/lib/testing/stubs/governance-agent-stub.mjs.map +1 -1
  739. package/dist/lib/testing/stubs/index.mjs +0 -6
  740. package/dist/lib/testing/stubs/index.mjs.map +1 -1
  741. package/dist/lib/testing/test-controller.mjs +0 -6
  742. package/dist/lib/testing/test-controller.mjs.map +1 -1
  743. package/dist/lib/testing/test-helpers.mjs +0 -6
  744. package/dist/lib/testing/test-helpers.mjs.map +1 -1
  745. package/dist/lib/testing/types.mjs +0 -6
  746. package/dist/lib/types/adcp.mjs +0 -6
  747. package/dist/lib/types/adcp.mjs.map +1 -1
  748. package/dist/lib/types/asset-instances.mjs +0 -6
  749. package/dist/lib/types/compat.mjs +0 -6
  750. package/dist/lib/types/compat.mjs.map +1 -1
  751. package/dist/lib/types/core.generated.mjs +0 -6
  752. package/dist/lib/types/enums.generated.mjs +0 -6
  753. package/dist/lib/types/enums.generated.mjs.map +1 -1
  754. package/dist/lib/types/error-codes.mjs +0 -6
  755. package/dist/lib/types/error-codes.mjs.map +1 -1
  756. package/dist/lib/types/error-details.aliases.mjs +0 -6
  757. package/dist/lib/types/error-details.aliases.mjs.map +1 -1
  758. package/dist/lib/types/format-asset-slots.mjs +0 -6
  759. package/dist/lib/types/forward-compat-error-codes.mjs +0 -6
  760. package/dist/lib/types/forward-compat-error-codes.mjs.map +1 -1
  761. package/dist/lib/types/index.mjs +0 -6
  762. package/dist/lib/types/index.mjs.map +1 -1
  763. package/dist/lib/types/inline-enums.aliases.mjs +0 -6
  764. package/dist/lib/types/inline-enums.aliases.mjs.map +1 -1
  765. package/dist/lib/types/inline-enums.generated.mjs +0 -6
  766. package/dist/lib/types/inline-enums.generated.mjs.map +1 -1
  767. package/dist/lib/types/manifest.generated.mjs +0 -6
  768. package/dist/lib/types/manifest.generated.mjs.map +1 -1
  769. package/dist/lib/types/schemas.generated.mjs +0 -6
  770. package/dist/lib/types/schemas.generated.mjs.map +1 -1
  771. package/dist/lib/types/server-payload-aliases.mjs +0 -6
  772. package/dist/lib/types/server-payload.mjs +0 -6
  773. package/dist/lib/types/sync-rows.mjs +0 -6
  774. package/dist/lib/types/tools.generated.mjs +0 -6
  775. package/dist/lib/types/v2-5/index.mjs +0 -6
  776. package/dist/lib/types/v2-5/index.mjs.map +1 -1
  777. package/dist/lib/types/v2-5/tools.generated.mjs +0 -6
  778. package/dist/lib/types/v3-1-beta/index.mjs +0 -6
  779. package/dist/lib/types/v3-1-beta/index.mjs.map +1 -1
  780. package/dist/lib/types/v3-1-beta/tools.generated.mjs +0 -6
  781. package/dist/lib/types/wellknown-schemas.generated.mjs +0 -6
  782. package/dist/lib/types/wellknown-schemas.generated.mjs.map +1 -1
  783. package/dist/lib/upstream-recorder/constants.mjs +0 -6
  784. package/dist/lib/upstream-recorder/constants.mjs.map +1 -1
  785. package/dist/lib/upstream-recorder/index.mjs +0 -6
  786. package/dist/lib/upstream-recorder/index.mjs.map +1 -1
  787. package/dist/lib/upstream-recorder/recorder.mjs +0 -6
  788. package/dist/lib/upstream-recorder/recorder.mjs.map +1 -1
  789. package/dist/lib/upstream-recorder/types.mjs +0 -6
  790. package/dist/lib/upstream-recorder/types.mjs.map +1 -1
  791. package/dist/lib/utils/a2a-artifacts.mjs +0 -6
  792. package/dist/lib/utils/a2a-artifacts.mjs.map +1 -1
  793. package/dist/lib/utils/a2a-discovery.mjs +0 -6
  794. package/dist/lib/utils/a2a-discovery.mjs.map +1 -1
  795. package/dist/lib/utils/activation-key-builders.mjs +0 -6
  796. package/dist/lib/utils/activation-key-builders.mjs.map +1 -1
  797. package/dist/lib/utils/adcp-version-config.mjs +0 -6
  798. package/dist/lib/utils/adcp-version-config.mjs.map +1 -1
  799. package/dist/lib/utils/asset-builders.mjs +0 -6
  800. package/dist/lib/utils/asset-builders.mjs.map +1 -1
  801. package/dist/lib/utils/build-creative-return-builders.mjs +0 -6
  802. package/dist/lib/utils/build-creative-return-builders.mjs.map +1 -1
  803. package/dist/lib/utils/buyer-retry-policy.mjs +0 -6
  804. package/dist/lib/utils/buyer-retry-policy.mjs.map +1 -1
  805. package/dist/lib/utils/capabilities.mjs +0 -6
  806. package/dist/lib/utils/capabilities.mjs.map +1 -1
  807. package/dist/lib/utils/capability-rollups.mjs +0 -6
  808. package/dist/lib/utils/capability-rollups.mjs.map +1 -1
  809. package/dist/lib/utils/creative-adapter.mjs +0 -6
  810. package/dist/lib/utils/creative-adapter.mjs.map +1 -1
  811. package/dist/lib/utils/creative-delivery.mjs +0 -6
  812. package/dist/lib/utils/creative-delivery.mjs.map +1 -1
  813. package/dist/lib/utils/deprecation.mjs +0 -6
  814. package/dist/lib/utils/deprecation.mjs.map +1 -1
  815. package/dist/lib/utils/envelope-status-compat.mjs +0 -6
  816. package/dist/lib/utils/envelope-status-compat.mjs.map +1 -1
  817. package/dist/lib/utils/error-extraction.mjs +0 -6
  818. package/dist/lib/utils/error-extraction.mjs.map +1 -1
  819. package/dist/lib/utils/extract-result.mjs +0 -6
  820. package/dist/lib/utils/extract-result.mjs.map +1 -1
  821. package/dist/lib/utils/format-asset-slot-builders.mjs +0 -6
  822. package/dist/lib/utils/format-asset-slot-builders.mjs.map +1 -1
  823. package/dist/lib/utils/format-assets.mjs +0 -6
  824. package/dist/lib/utils/format-assets.mjs.map +1 -1
  825. package/dist/lib/utils/format-render-builders.mjs +0 -6
  826. package/dist/lib/utils/format-render-builders.mjs.map +1 -1
  827. package/dist/lib/utils/format-renders.mjs +0 -6
  828. package/dist/lib/utils/format-renders.mjs.map +1 -1
  829. package/dist/lib/utils/get-products-cache-scope.mjs +0 -6
  830. package/dist/lib/utils/get-products-cache-scope.mjs.map +1 -1
  831. package/dist/lib/utils/glob.mjs +0 -6
  832. package/dist/lib/utils/glob.mjs.map +1 -1
  833. package/dist/lib/utils/global-async-local-storage.mjs +0 -6
  834. package/dist/lib/utils/global-async-local-storage.mjs.map +1 -1
  835. package/dist/lib/utils/idempotency.mjs +0 -6
  836. package/dist/lib/utils/idempotency.mjs.map +1 -1
  837. package/dist/lib/utils/index.mjs +0 -6
  838. package/dist/lib/utils/index.mjs.map +1 -1
  839. package/dist/lib/utils/jcs.mjs +0 -6
  840. package/dist/lib/utils/jcs.mjs.map +1 -1
  841. package/dist/lib/utils/json-depth.mjs +0 -6
  842. package/dist/lib/utils/json-depth.mjs.map +1 -1
  843. package/dist/lib/utils/logger.mjs +0 -6
  844. package/dist/lib/utils/logger.mjs.map +1 -1
  845. package/dist/lib/utils/media-buy-delivery-notification-builders.mjs +0 -6
  846. package/dist/lib/utils/media-buy-delivery-notification-builders.mjs.map +1 -1
  847. package/dist/lib/utils/media-buy-status.mjs +0 -6
  848. package/dist/lib/utils/media-buy-status.mjs.map +1 -1
  849. package/dist/lib/utils/pagination.mjs +0 -6
  850. package/dist/lib/utils/pagination.mjs.map +1 -1
  851. package/dist/lib/utils/preview-creative-builders.mjs +0 -6
  852. package/dist/lib/utils/preview-creative-builders.mjs.map +1 -1
  853. package/dist/lib/utils/preview-normalizer.mjs +0 -6
  854. package/dist/lib/utils/preview-normalizer.mjs.map +1 -1
  855. package/dist/lib/utils/preview-utils.mjs +0 -6
  856. package/dist/lib/utils/preview-utils.mjs.map +1 -1
  857. package/dist/lib/utils/pricing-adapter.mjs +0 -6
  858. package/dist/lib/utils/pricing-adapter.mjs.map +1 -1
  859. package/dist/lib/utils/probe-policy.mjs +0 -6
  860. package/dist/lib/utils/probe-policy.mjs.map +1 -1
  861. package/dist/lib/utils/protocol-detection.mjs +0 -6
  862. package/dist/lib/utils/protocol-detection.mjs.map +1 -1
  863. package/dist/lib/utils/redact-secrets.mjs +0 -6
  864. package/dist/lib/utils/redact-secrets.mjs.map +1 -1
  865. package/dist/lib/utils/redis-default-prefix-warn.mjs +0 -6
  866. package/dist/lib/utils/redis-default-prefix-warn.mjs.map +1 -1
  867. package/dist/lib/utils/render-builders.mjs +0 -6
  868. package/dist/lib/utils/render-builders.mjs.map +1 -1
  869. package/dist/lib/utils/request-normalizer.mjs +0 -6
  870. package/dist/lib/utils/request-normalizer.mjs.map +1 -1
  871. package/dist/lib/utils/response-schemas.mjs +0 -6
  872. package/dist/lib/utils/response-schemas.mjs.map +1 -1
  873. package/dist/lib/utils/response-unwrapper.mjs +0 -6
  874. package/dist/lib/utils/response-unwrapper.mjs.map +1 -1
  875. package/dist/lib/utils/retry.mjs +0 -6
  876. package/dist/lib/utils/retry.mjs.map +1 -1
  877. package/dist/lib/utils/signal-discovery-helpers.mjs +0 -6
  878. package/dist/lib/utils/signal-discovery-helpers.mjs.map +1 -1
  879. package/dist/lib/utils/signal-id-builders.mjs +0 -6
  880. package/dist/lib/utils/signal-id-builders.mjs.map +1 -1
  881. package/dist/lib/utils/sync-creatives-adapter.mjs +0 -6
  882. package/dist/lib/utils/sync-creatives-adapter.mjs.map +1 -1
  883. package/dist/lib/utils/task-state.mjs +0 -6
  884. package/dist/lib/utils/task-state.mjs.map +1 -1
  885. package/dist/lib/utils/tool-request-schemas.mjs +0 -6
  886. package/dist/lib/utils/tool-request-schemas.mjs.map +1 -1
  887. package/dist/lib/utils/typeGuards.mjs +0 -6
  888. package/dist/lib/utils/typeGuards.mjs.map +1 -1
  889. package/dist/lib/utils/union-errors.mjs +0 -6
  890. package/dist/lib/utils/union-errors.mjs.map +1 -1
  891. package/dist/lib/utils/validate-user-agent.mjs +0 -6
  892. package/dist/lib/utils/validate-user-agent.mjs.map +1 -1
  893. package/dist/lib/v2/format-schema/fetch.mjs +0 -6
  894. package/dist/lib/v2/format-schema/fetch.mjs.map +1 -1
  895. package/dist/lib/v2/format-schema/index.mjs +0 -6
  896. package/dist/lib/v2/format-schema/index.mjs.map +1 -1
  897. package/dist/lib/v2/format-schema/regex-safety.mjs +0 -6
  898. package/dist/lib/v2/format-schema/regex-safety.mjs.map +1 -1
  899. package/dist/lib/v2/format-schema/resolver.mjs +7 -8
  900. package/dist/lib/v2/format-schema/resolver.mjs.map +1 -1
  901. package/dist/lib/v2/format-schema/sandbox-refs.mjs +0 -6
  902. package/dist/lib/v2/format-schema/sandbox-refs.mjs.map +1 -1
  903. package/dist/lib/v2/projection/augment-response.mjs +0 -6
  904. package/dist/lib/v2/projection/augment-response.mjs.map +1 -1
  905. package/dist/lib/v2/projection/builders.mjs +0 -6
  906. package/dist/lib/v2/projection/builders.mjs.map +1 -1
  907. package/dist/lib/v2/projection/cache-versions.mjs +0 -6
  908. package/dist/lib/v2/projection/cache-versions.mjs.map +1 -1
  909. package/dist/lib/v2/projection/canonical-properties.mjs +5 -6
  910. package/dist/lib/v2/projection/canonical-properties.mjs.map +1 -1
  911. package/dist/lib/v2/projection/catalog.mjs +5 -6
  912. package/dist/lib/v2/projection/catalog.mjs.map +1 -1
  913. package/dist/lib/v2/projection/constants.mjs +0 -6
  914. package/dist/lib/v2/projection/constants.mjs.map +1 -1
  915. package/dist/lib/v2/projection/index.mjs +0 -6
  916. package/dist/lib/v2/projection/index.mjs.map +1 -1
  917. package/dist/lib/v2/projection/registry.mjs +5 -6
  918. package/dist/lib/v2/projection/registry.mjs.map +1 -1
  919. package/dist/lib/v2/projection/types.mjs +0 -6
  920. package/dist/lib/v2/projection/v1-to-v2.mjs +0 -6
  921. package/dist/lib/v2/projection/v1-to-v2.mjs.map +1 -1
  922. package/dist/lib/v2/projection/v2-to-v1.mjs +0 -6
  923. package/dist/lib/v2/projection/v2-to-v1.mjs.map +1 -1
  924. package/dist/lib/v2/projection/write-side.mjs +0 -6
  925. package/dist/lib/v2/projection/write-side.mjs.map +1 -1
  926. package/dist/lib/v2/publisher-catalog/formats.mjs +0 -6
  927. package/dist/lib/v2/publisher-catalog/formats.mjs.map +1 -1
  928. package/dist/lib/v2/publisher-catalog/index.mjs +0 -6
  929. package/dist/lib/v2/publisher-catalog/index.mjs.map +1 -1
  930. package/dist/lib/validation/client-hooks.mjs +0 -6
  931. package/dist/lib/validation/client-hooks.mjs.map +1 -1
  932. package/dist/lib/validation/hints.mjs +0 -6
  933. package/dist/lib/validation/hints.mjs.map +1 -1
  934. package/dist/lib/validation/index.mjs +0 -6
  935. package/dist/lib/validation/index.mjs.map +1 -1
  936. package/dist/lib/validation/schema-errors.mjs +0 -6
  937. package/dist/lib/validation/schema-errors.mjs.map +1 -1
  938. package/dist/lib/validation/schema-loader.mjs +5 -6
  939. package/dist/lib/validation/schema-loader.mjs.map +1 -1
  940. package/dist/lib/validation/schema-validator.mjs +0 -6
  941. package/dist/lib/validation/schema-validator.mjs.map +1 -1
  942. package/dist/lib/validation/sync-creatives.mjs +0 -6
  943. package/dist/lib/validation/sync-creatives.mjs.map +1 -1
  944. package/dist/lib/version.d.mts +3 -3
  945. package/dist/lib/version.d.ts +3 -3
  946. package/dist/lib/version.js +3 -3
  947. package/dist/lib/version.js.map +1 -1
  948. package/dist/lib/version.mjs +3 -9
  949. package/dist/lib/version.mjs.map +1 -1
  950. package/dist/lib/webhooks/index.mjs +0 -6
  951. package/dist/lib/webhooks/index.mjs.map +1 -1
  952. package/dist/lib/wholesale-feed-sync/index.mjs +0 -6
  953. package/dist/lib/wholesale-feed-sync/index.mjs.map +1 -1
  954. package/dist/lib/wholesale-feed-sync/sync.mjs +0 -6
  955. package/dist/lib/wholesale-feed-sync/sync.mjs.map +1 -1
  956. package/dist/lib/wholesale-feed-sync/types.mjs +0 -6
  957. package/dist/lib/wholesale-feed-sync/webhook-notification.mjs +0 -6
  958. package/dist/lib/wholesale-feed-sync/webhook-notification.mjs.map +1 -1
  959. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/validation/schema-loader.ts"],"sourcesContent":["/**\n * JSON Schema loader for AdCP tool request/response validation.\n *\n * Loads the bundled per-tool schemas shipped with the SDK plus the\n * `core/` schemas that async response variants `$ref`, then compiles\n * AJV validators lazily by `(toolName, direction)`.\n *\n * Stage 3: state is per-AdCP-version. The same SDK instance can hold\n * compiled validators for `3.0.0`, `3.0.1`, `3.1.0-beta.1`, etc. side by\n * side; callers pass the version they're validating against. Default is\n * the SDK-pinned `ADCP_VERSION` so callers that don't care about\n * cross-version selection (most internal call sites) keep working\n * unchanged.\n */\n\nimport Ajv, { type ValidateFunction } from 'ajv';\nimport addFormats from 'ajv-formats';\nimport { AsyncLocalStorage } from 'async_hooks';\nimport { readdirSync, readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport { ADCP_VERSION } from '../version';\nimport { ConfigurationError } from '../errors';\n\nexport type ResponseVariant = 'sync' | 'submitted' | 'working' | 'input-required';\nexport type Direction = 'request' | ResponseVariant;\n\ninterface LoadedSchema {\n $id?: string;\n [k: string]: unknown;\n}\n\nconst SCHEMA_FILENAME_SUFFIX: Record<Direction, string> = {\n request: 'request',\n sync: 'response',\n submitted: 'async-response-submitted',\n working: 'async-response-working',\n 'input-required': 'async-response-input-required',\n};\n\n/**\n * Map a consumer-provided version pin to the loader's bundle key.\n *\n * - Stable semver `'3.0.0'` / `'3.0.1'` → `'3.0'` (latest patch in minor)\n * - Bare minor `'3.0'` → `'3.0'` (already the bundle key)\n * - Release-precision prerelease `'3.1-beta'` / `'3.1-beta.0'` →\n * returned verbatim. {@link resolveSchemaRoot} fuzzy-resolves to the\n * highest cached prerelease directory whose own release-precision form\n * matches (e.g. `'3.1-beta'` matches `schemas/cache/3.1.0-beta.0/`).\n * Accepted because sellers advertise `supported_versions` in this\n * shape (`[\"3.1-beta\"]`), and a buyer reading that off the wire must\n * be able to pin to it.\n * - Full prerelease semver `'3.1.0-beta.1'` → `'3.1.0-beta.1'`\n * (exact-version, intentional pin)\n * - Legacy alias `'v3'` / `'v2.5'` / `'v2.6'` → returned verbatim (cache\n * historically keyed these directories by the alias name)\n *\n * Per the AdCP spec convention patches don't change wire shape, so collapsing\n * stable patches into the minor is functionally equivalent for any validator\n * consumer. Prereleases are kept exact because pinning a beta is intentional\n * and bit-fidelity matters for cross-version interop tests.\n *\n * Throws `ConfigurationError` for any input that doesn't match one of the\n * recognized shapes. Strings reach `path.join` via `resolveSchemaRoot`, and\n * pass-through of arbitrary garbage (`'../etc'`, `'3foo'`) lets a non-version\n * directory probe leak through `hasSchemaBundle`'s boolean. The throw is\n * caught by `hasSchemaBundle`'s try/catch (still returns false) and surfaces\n * with a useful field name from `resolveAdcpVersion`.\n */\nexport function resolveBundleKey(version: string): string {\n // Bare 'MAJOR.MINOR' (no patch).\n const minorOnly = version.match(/^(\\d+)\\.(\\d+)$/);\n if (minorOnly) return `${minorOnly[1]}.${minorOnly[2]}`;\n // Release-precision prerelease 'MAJOR.MINOR-PRE' (no patch). Same SemVer §9\n // prerelease constraint as the full-semver branch — `'3.1-/../etc'`-style\n // strings can't slip through. Returns verbatim; resolveSchemaRoot does the\n // fuzzy directory match.\n const releasePrecisionPre = version.match(/^(\\d+)\\.(\\d+)-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*$/);\n if (releasePrecisionPre) return version;\n // Full 'MAJOR.MINOR.PATCH' with optional prerelease. Prerelease group\n // restricted to SemVer §9 identifiers (alphanumerics + hyphen,\n // dot-separated) so `'3.0.0-/../etc'`-style strings can't slip through\n // and reach `path.join` as a directory component. The full version is\n // returned verbatim for prereleases, so this is the last line of defense\n // before that string becomes a path segment.\n const semver = version.match(/^(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$/);\n if (semver) {\n const [, major, minor, , prerelease] = semver;\n if (prerelease !== undefined) return version;\n return `${major}.${minor}`;\n }\n // Legacy alias: 'v' followed by a major and optional minor. Restricted to\n // this exact shape so non-version garbage can't reach the filesystem.\n const legacyAlias = version.match(/^v\\d+(\\.\\d+)?$/);\n if (legacyAlias) return version;\n throw new ConfigurationError(\n `AdCP version ${JSON.stringify(version)} is not a recognized version format. ` +\n `Expected semver (e.g. '3.0.1', '3.1.0-beta.1'), bare minor ('3.0'), ` +\n `release-precision ('3.1-beta'), or legacy alias ('v3', 'v2.5').`,\n 'adcpVersion'\n );\n}\n\n/**\n * Collapse a bundle key to the release-precision string the AdCP wire schema\n * accepts for the `adcp_version` envelope field (spec PR\n * `adcontextprotocol/adcp#3493`). The wire pattern is\n * `^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$` — release-precision (MAJOR.MINOR with\n * optional prerelease), never full MAJOR.MINOR.PATCH semver.\n *\n * - Stable bundle key `'3.0'` / `'3.1'` → returned verbatim.\n * - Prerelease bundle key `'3.1.0-beta.0'` → `'3.1-beta.0'` (PATCH segment\n * dropped; the prerelease tag is the wire-meaningful release identifier,\n * PATCH is implementation-internal).\n * - Full stable semver `'3.0.11'` → `'3.0'` (patches don't change wire\n * shape; surface them via `build_version` on capabilities instead).\n * - Legacy alias `'v3'` / `'v2.5'` — returned verbatim. The wire spec\n * predates the envelope field, so legacy-aliased clients won't emit\n * `adcp_version` anyway (gated by `bundleSupportsAdcpVersionField`).\n *\n * The normalization rule is declared in `core/version-envelope.json`:\n *\n * > SDKs that read full-semver values from bundle metadata (e.g.\n * > ComplianceIndex.published_version = \"3.1.0-beta.1\") MUST normalize to\n * > release-precision (\"3.1-beta.1\") before emitting on the wire —\n * > meta-field values are NOT valid wire values.\n *\n * **Idempotent.** Re-applying to an already-wire-shaped value is a no-op:\n * `toReleasePrecisionWire('3.1-beta.0') === '3.1-beta.0'`. Safe to call\n * defensively on values a caller read off the wire and is passing back.\n *\n * **Prerelease regex is stricter than the wire pattern by design.** The wire\n * pattern allows `[a-zA-Z0-9.-]+` (any mix of dots and hyphens), but this\n * function only accepts SemVer §9-shaped prerelease tags\n * (`[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*`) — disallowing leading dots, double\n * dots, or trailing dots. Mirrors the path-traversal hardening on\n * {@link resolveBundleKey} (`'3.0.0-/../etc'`-style strings can't reach the\n * filesystem there, and shouldn't be silently mirrored to the wire here).\n * A future reader who wants to \"fix\" this to match the wire regex\n * character-for-character should NOT — the strictness is intentional.\n *\n * Defense: rejecting unrecognized shapes here surfaces SDK-internal misuse\n * (someone calling this with raw garbage) loudly instead of silently\n * emitting a non-spec wire string.\n */\n/**\n * The exact pattern `core/version-envelope.json` applies to `adcp_version`\n * on the wire. Kept verbatim so {@link validateAdcpVersionWire} doesn't\n * drift from the spec — bump only when the spec itself bumps.\n */\nconst ADCP_VERSION_WIRE_PATTERN = /^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$/;\n\n/**\n * Validate a string against the AdCP 3.1 `adcp_version` wire pattern.\n * Throws `ConfigurationError` with a hint that points at\n * {@link toReleasePrecisionWire} when the value would be sent on the wire\n * but doesn't satisfy `core/version-envelope.json`'s pattern.\n *\n * Use this when you're constructing a request envelope by hand (storyboard\n * fixtures, conformance harnesses, custom transports) and want a clear\n * error rather than a downstream AJV pattern-mismatch from the seller —\n * by the time the seller rejects the request, the buyer's stack frame is\n * long gone and `core/version-envelope.json/properties/adcp_version/pattern`\n * is the only clue.\n *\n * The SDK's own `buildVersionEnvelope` calls this as a postcondition after\n * normalizing the bundle key — should never throw in well-formed SDK code,\n * but if a future refactor breaks the normalization the assertion fires\n * with a message that names the helper to call.\n *\n * Returns the value with the type narrowed to `string` via assertion.\n */\nexport function validateAdcpVersionWire(value: unknown): asserts value is string {\n if (typeof value !== 'string') {\n throw new ConfigurationError(\n `adcp_version must be a string. Got ${typeof value}. ` +\n `Use toReleasePrecisionWire() to convert a bundle key or full-semver pin to a wire-shaped string.`,\n 'adcp_version'\n );\n }\n if (!ADCP_VERSION_WIRE_PATTERN.test(value)) {\n throw new ConfigurationError(\n `adcp_version ${JSON.stringify(value)} doesn't match the AdCP 3.1 wire pattern ${ADCP_VERSION_WIRE_PATTERN}. ` +\n `Full-semver bundle keys (e.g. \"3.1.0-beta.0\") are NOT valid wire values — ` +\n `call toReleasePrecisionWire() to normalize (e.g. \"3.1.0-beta.0\" → \"3.1-beta.0\").`,\n 'adcp_version'\n );\n }\n}\n\nexport function toReleasePrecisionWire(bundleKeyOrVersion: string): string {\n // Bare release-precision (MAJOR.MINOR or MAJOR.MINOR-PRE) — already wire-shaped.\n const releasePrecision = bundleKeyOrVersion.match(/^(\\d+)\\.(\\d+)(-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/);\n if (releasePrecision) {\n const [, major, minor, prerelease = ''] = releasePrecision;\n return `${major}.${minor}${prerelease}`;\n }\n // Full semver — collapse PATCH segment. Prerelease (if any) is preserved.\n const fullSemver = bundleKeyOrVersion.match(/^(\\d+)\\.(\\d+)\\.\\d+(-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/);\n if (fullSemver) {\n const [, major, minor, prerelease = ''] = fullSemver;\n return `${major}.${minor}${prerelease}`;\n }\n // Legacy alias passthrough. Callers that reach here with a legacy alias\n // shouldn't be emitting `adcp_version` (no version-envelope support), but\n // returning the input verbatim is least-surprise.\n if (/^v\\d+(\\.\\d+)?$/.test(bundleKeyOrVersion)) return bundleKeyOrVersion;\n throw new ConfigurationError(\n `Cannot normalize ${JSON.stringify(bundleKeyOrVersion)} to release-precision wire format. ` +\n `Expected a bundle key or AdCP version string.`,\n 'adcpVersion'\n );\n}\n\n/**\n * Resolve the directory that holds the bundled + core schemas for a given\n * AdCP version. Source layout (dev):\n * schemas/cache/<exact-version>/{bundled,core}\n * Built layout (dist):\n * dist/lib/schemas-data/<bundle-key>/{bundled,core}\n *\n * Stable releases use minor-name keys (`3.0/`); prereleases use full-version\n * keys (`3.1.0-beta.1/`). See {@link resolveBundleKey}.\n *\n * Falls back to the source-tree cache when dist isn't built (dev workflow\n * before `npm run build:lib`). For stable pins, the cache fallback scans\n * for the highest-patch sibling in the requested minor — `'3.0.0'` resolves\n * to `schemas/cache/3.0.1/` when only `3.0.1` is cached, matching dist's\n * collapse behavior.\n *\n * Throws when no bundle exists. Callers pinning a specific prerelease\n * surface the error; the construction-time fence in `resolveAdcpVersion`\n * catches most cross-major mistakes before this point.\n */\nfunction resolveSchemaRoot(version: string): string {\n const key = resolveBundleKey(version);\n const scopedRoot = scopedExternalSchemaRoots.getStore()?.get(key);\n if (scopedRoot && existsSync(scopedRoot)) return scopedRoot;\n\n const externalRoot = externalSchemaRoots.get(key);\n if (externalRoot && existsSync(externalRoot)) return externalRoot;\n\n const distCandidate = path.join(__dirname, '..', 'schemas-data', key);\n if (existsSync(distCandidate)) return distCandidate;\n\n // Published builds carry exact prerelease bundle directories\n // (`3.1.0-rc.1/`), while callers may pin the release-precision family\n // alias (`3.1-rc`). Resolve that alias before falling back to source cache.\n const releasePrecisionMatch = /^\\d+\\.\\d+-/.test(key);\n if (releasePrecisionMatch) {\n const distPrereleaseCandidate = findPrereleaseBundle(path.join(__dirname, '..', 'schemas-data'), key);\n if (distPrereleaseCandidate) return distPrereleaseCandidate;\n }\n\n // Source-tree fallback: cache stays exact-version-named, so map the key\n // back to the highest-patch cache directory in the same minor for stable\n // pins. Prereleases need an exact match.\n const cacheRoot = path.join(__dirname, '..', '..', '..', 'schemas', 'cache');\n const exactCandidate = path.join(cacheRoot, version);\n if (existsSync(exactCandidate)) return exactCandidate;\n\n // For minor-only or stable-patch pins, find the highest stable patch in\n // the cache that matches the resolved minor. Skip `*.previous` snapshots\n // — `sync-schemas` writes those as transient backups during replaceTree;\n // a partially-written snapshot whose patch number happens to be highest\n // would otherwise win the sort.\n const minorMatch = key.match(/^(\\d+)\\.(\\d+)$/);\n if (minorMatch && existsSync(cacheRoot)) {\n const [, major, minor] = minorMatch;\n const prefix = `${major}.${minor}.`;\n const cached = readdirSync(cacheRoot, { withFileTypes: true })\n .filter(\n e =>\n e.isDirectory() &&\n e.name.startsWith(prefix) &&\n !e.name.endsWith('.previous') &&\n /^\\d+\\.\\d+\\.\\d+$/.test(e.name)\n )\n .map(e => ({\n name: e.name,\n patch: parseInt(e.name.slice(prefix.length), 10),\n }))\n .filter(c => Number.isFinite(c.patch))\n .sort((a, b) => b.patch - a.patch);\n if (cached.length > 0) return path.join(cacheRoot, cached[0]!.name);\n }\n\n // For release-precision prerelease pins (`'3.1-beta'`, `'3.1-beta.0'`),\n // find the highest cached prerelease directory whose own release-precision\n // form starts with the requested key. A pin of `'3.1-beta'` matches any\n // directory whose `toReleasePrecisionWire` form is `'3.1-beta'` or\n // `'3.1-beta.*'`. A pin of `'3.1-beta.0'` matches `'3.1-beta.0'` or\n // `'3.1-beta.0.*'`. Sort newest-first by directory name with numeric\n // collation so rc.10 wins over rc.9.\n if (releasePrecisionMatch) {\n const cachePrereleaseCandidate = findPrereleaseBundle(cacheRoot, key);\n if (cachePrereleaseCandidate) return cachePrereleaseCandidate;\n }\n\n throw new Error(\n `AdCP schema data for version \"${version}\" not found. ` +\n `Looked for bundle key \"${key}\" in ${distCandidate}, exact path ${exactCandidate}, ` +\n `and the latest-patch fallback in ${cacheRoot}. ` +\n `Run \\`npm run sync-schemas\\` and \\`npm run build:lib\\` to populate the bundle.`\n );\n}\n\nfunction findPrereleaseBundle(root: string, key: string): string | undefined {\n if (!existsSync(root)) return undefined;\n const cached = readdirSync(root, { withFileTypes: true })\n .filter(e => e.isDirectory() && !e.name.endsWith('.previous'))\n .map(e => {\n try {\n return { name: e.name, rp: toReleasePrecisionWire(e.name) };\n } catch {\n return null;\n }\n })\n .filter((c): c is { name: string; rp: string } => c !== null)\n .filter(c => c.rp === key || c.rp.startsWith(`${key}.`))\n .sort((a, b) => compareBundleNamesDesc(a.name, b.name));\n if (cached.length === 0) return undefined;\n return path.join(root, cached[0]!.name);\n}\n\nfunction compareBundleNamesDesc(a: string, b: string): number {\n return b.localeCompare(a, undefined, { numeric: true, sensitivity: 'base' });\n}\n\ninterface LoaderState {\n ajv: Ajv;\n fileIndex: Map<string, string>;\n validators: Map<string, ValidateFunction>;\n rawSchemas: Map<string, Record<string, unknown>>;\n root: string;\n coreLoaded: boolean;\n version: string;\n}\n\nconst states: Map<string, LoaderState> = new Map();\nconst externalSchemaRoots: Map<string, string> = new Map();\nconst scopedExternalSchemaRoots = new AsyncLocalStorage<Map<string, string>>();\n\nfunction stateCacheKey(bundleKey: string, root: string): string {\n return `${bundleKey}\\0${root}`;\n}\n\nfunction clearStatesForBundle(bundleKey: string): void {\n for (const [stateKey, state] of states) {\n if (state.version === bundleKey) states.delete(stateKey);\n }\n}\n\nfunction hasSchemaRootShape(root: string): boolean {\n if (!existsSync(root)) return false;\n const bundledRoot = path.join(root, 'bundled');\n const files = existsSync(bundledRoot) ? walkJsonFiles(bundledRoot) : walkJsonFiles(root);\n return files.some(file => {\n try {\n const schema = loadJson(file);\n return typeof schema.$id === 'string' || typeof schema.$schema === 'string';\n } catch {\n return false;\n }\n });\n}\n\nfunction schemaIdVersionHint(schemaId: string): string | undefined {\n return schemaId.match(/\\/schemas\\/([^/]+)\\//)?.[1];\n}\n\nfunction collectSchemaRootVersionAliases(root: string): Set<string> {\n const aliases = new Set<string>();\n for (const file of walkJsonFiles(root)) {\n let schema: LoadedSchema;\n try {\n schema = loadJson(file);\n } catch {\n continue;\n }\n if (typeof schema.$id !== 'string') continue;\n const hint = schemaIdVersionHint(schema.$id);\n if (!hint) continue;\n for (const alias of schemaRootVersionAliases(hint)) aliases.add(alias);\n }\n return aliases;\n}\n\nfunction schemaRootVersionAliases(version: string): Set<string> {\n const aliases = new Set<string>([version]);\n try {\n aliases.add(resolveBundleKey(version));\n } catch {\n // Keep the raw value only; callers that care will throw separately.\n }\n try {\n const releasePrecision = toReleasePrecisionWire(version);\n aliases.add(releasePrecision);\n const family = prereleaseFamilyAlias(releasePrecision);\n if (family) aliases.add(family);\n } catch {\n // Keep any aliases already collected.\n }\n return aliases;\n}\n\nfunction prereleaseFamilyAlias(releasePrecisionVersion: string): string | undefined {\n return releasePrecisionVersion.match(/^(\\d+\\.\\d+-[0-9A-Za-z-]+)\\.\\d+$/)?.[1];\n}\n\nfunction collectSchemaRootVersionAliasGroups(root: string): Array<{ hint: string; aliases: Set<string> }> {\n const groups: Array<{ hint: string; aliases: Set<string> }> = [];\n for (const file of walkJsonFiles(root)) {\n let schema: LoadedSchema;\n try {\n schema = loadJson(file);\n } catch {\n continue;\n }\n if (typeof schema.$id !== 'string') continue;\n const hint = schemaIdVersionHint(schema.$id);\n if (!hint) continue;\n groups.push({ hint, aliases: schemaRootVersionAliases(hint) });\n }\n return groups;\n}\n\nfunction assertSchemaRootMatchesVersion(version: string, root: string): Set<string> {\n const expectedAliases = schemaRootVersionAliases(version);\n const rootGroups = collectSchemaRootVersionAliasGroups(root);\n const rootAliases = collectSchemaRootVersionAliases(root);\n if (\n rootGroups.length > 0 &&\n rootGroups.every(group => [...group.aliases].some(alias => expectedAliases.has(alias)))\n ) {\n return new Set([...expectedAliases, ...rootAliases]);\n }\n const found =\n rootGroups.length === 0\n ? 'no AdCP schema ids'\n : rootGroups\n .map(group => `${group.hint} (${Array.from(group.aliases).sort().join(', ')})`)\n .sort()\n .join(', ');\n throw new Error(\n `External AdCP schema root for version \"${version}\" at ${root} does not match the requested version and ` +\n `must contain only schema ids matching ${Array.from(expectedAliases).sort().join(', ')}; found ${found}.`\n );\n}\n\nconst externalSchemaRootAliases: Map<string, Set<string>> = new Map();\n\n/**\n * Register a schema bundle supplied outside the installed SDK package.\n *\n * Compliance runners use this when `--compliance-dir` points at another\n * package/check-out whose storyboards and schema bundle should be used\n * together. The root must be the schema-data directory itself, e.g.\n * `.../dist/lib/schemas-data/3.0`.\n */\nexport function registerExternalSchemaRoot(version: string, root: string): void {\n const key = resolveBundleKey(version);\n if (!hasSchemaRootShape(root)) {\n throw new Error(`External AdCP schema root for version \"${version}\" not found or empty at ${root}`);\n }\n const aliases = assertSchemaRootMatchesVersion(version, root);\n externalSchemaRootAliases.set(key, aliases);\n for (const alias of aliases) {\n const previous = externalSchemaRoots.get(alias);\n externalSchemaRoots.set(alias, root);\n if (previous !== root) clearStatesForBundle(alias);\n }\n}\n\n/** Test/helper hook for unregistering an external schema bundle. */\nexport function unregisterExternalSchemaRoot(version: string): void {\n const key = resolveBundleKey(version);\n const aliases = new Set(schemaRootVersionAliases(version));\n for (const [registeredKey, registeredAliases] of externalSchemaRootAliases) {\n if (\n registeredKey === key ||\n registeredAliases.has(key) ||\n [...aliases].some(alias => registeredAliases.has(alias))\n ) {\n for (const alias of registeredAliases) aliases.add(alias);\n externalSchemaRootAliases.delete(registeredKey);\n }\n }\n for (const alias of aliases) {\n externalSchemaRoots.delete(alias);\n clearStatesForBundle(alias);\n }\n}\n\n/**\n * Run a callback with an external schema root scoped to the current async\n * execution chain. Unlike `registerExternalSchemaRoot`, this does not poison\n * process-global validation state for later hosted/compliance runs.\n */\nexport function withExternalSchemaRoot<T>(version: string, root: string | undefined, fn: () => T): T {\n if (root === undefined) return fn();\n if (!hasSchemaRootShape(root)) {\n throw new Error(`External AdCP schema root for version \"${version}\" not found or empty at ${root}`);\n }\n const aliases = assertSchemaRootMatchesVersion(version, root);\n const parent = scopedExternalSchemaRoots.getStore();\n const next = new Map(parent);\n for (const alias of aliases) {\n next.set(alias, root);\n clearStatesForBundle(alias);\n }\n return scopedExternalSchemaRoots.run(next, fn);\n}\n\nfunction walkJsonFiles(dir: string): string[] {\n if (!existsSync(dir)) return [];\n const out: string[] = [];\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) out.push(...walkJsonFiles(full));\n else if (entry.isFile() && entry.name.endsWith('.json')) out.push(full);\n }\n return out;\n}\n\nfunction loadJson(file: string): LoadedSchema {\n return JSON.parse(readFileSync(file, 'utf-8')) as LoadedSchema;\n}\n\n/**\n * Clear `additionalProperties: false` at the response root so envelope\n * fields (`replayed`, `context`, `ext`, and future envelope additions)\n * can ride alongside the tool-specific body — per security.mdx the\n * envelope is always extensible. Upstream bundled schemas pin\n * `additionalProperties: false` at the root on a handful of mutating\n * tools (the property-list family), which rejects envelope fields like\n * `replayed` that aren't declared in the tool-specific body.\n *\n * Scope is deliberately narrow: only the top-level object, plus each\n * direct branch of a root-level `oneOf` / `anyOf` / `allOf`. Nested\n * bodies stay strict so response-side drift detection still catches\n * typos inside `Product`, `Package`, `MediaBuy` etc. Applied only to\n * response variants; request schemas stay strict so outgoing drift\n * fails at the edge.\n */\nfunction relaxResponseRoot(schema: LoadedSchema): LoadedSchema {\n const clone = { ...schema };\n if (clone.additionalProperties === false) {\n clone.additionalProperties = true;\n }\n for (const key of ['oneOf', 'anyOf', 'allOf'] as const) {\n const branches = clone[key];\n if (Array.isArray(branches)) {\n clone[key] = branches.map(branch => {\n if (!branch || typeof branch !== 'object') return branch;\n const branchClone = { ...(branch as Record<string, unknown>) };\n if (branchClone.additionalProperties === false) {\n branchClone.additionalProperties = true;\n }\n return branchClone;\n });\n }\n }\n return clone;\n}\n\nfunction getAjvRegisteredIds(ajv: Ajv): Set<string> {\n const internals = ajv as unknown as {\n schemas?: Record<string, unknown>;\n refs?: Record<string, unknown>;\n };\n return new Set([...Object.keys(internals.schemas ?? {}), ...Object.keys(internals.refs ?? {})]);\n}\n\n/**\n * Build the (toolName, direction) → file path index by scanning the schema\n * tree once. Runs eagerly at first validator lookup.\n */\nfunction buildFileIndex(root: string): Map<string, string> {\n const index = new Map<string, string>();\n const record = (toolName: string, direction: Direction, file: string): void => {\n index.set(`${toolName}::${direction}`, file);\n };\n\n // Sync request/response live in the pre-resolved bundled/ tree.\n const bundledRoot = path.join(root, 'bundled');\n for (const file of walkJsonFiles(bundledRoot)) {\n const base = path.basename(file, '.json');\n if (base.endsWith('-request')) {\n const tool = base.slice(0, -'-request'.length).replace(/-/g, '_');\n record(tool, 'request', file);\n } else if (base.endsWith('-response')) {\n const tool = base.slice(0, -'-response'.length).replace(/-/g, '_');\n record(tool, 'sync', file);\n }\n }\n\n // Async variants AND domain schemas that ship flat (not pre-bundled) both\n // live in the per-domain directories. Walk each for sync request/response\n // files and async variant files. Skip `bundled/` (already indexed above)\n // and `core/` (pure $ref targets, no tools).\n //\n // Flat-tree domains include `governance/`, `brand/`, `account/`,\n // `content-standards/`, `property/`, `collection/` — their schemas are\n // NOT pre-resolved into `bundled/`, so a bundled-only walk would miss\n // every `check_governance` / `acquire_rights` / `creative_approval` /\n // `sync_governance` / `*_property_list` request-response pair. That gap\n // (flagged by the ad-tech-protocol reviewer on PR #831) would leave\n // protocol-wide-requirement-bearing tasks (idempotency_key pattern,\n // `format: uri` on `caller`) invisible to the strict-validation signal.\n // Register flat-tree sync pairs only when `bundled/` didn't already\n // index them, so pre-resolved schemas (with $refs already inlined) win\n // for any domain that ships both.\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n if (entry.name === 'bundled' || entry.name === 'core') continue;\n const domainDir = path.join(root, entry.name);\n for (const file of walkJsonFiles(domainDir)) {\n const base = path.basename(file, '.json');\n if (base.endsWith('-async-response-submitted')) {\n const tool = base.slice(0, -'-async-response-submitted'.length).replace(/-/g, '_');\n record(tool, 'submitted', file);\n } else if (base.endsWith('-async-response-working')) {\n const tool = base.slice(0, -'-async-response-working'.length).replace(/-/g, '_');\n record(tool, 'working', file);\n } else if (base.endsWith('-async-response-input-required')) {\n const tool = base.slice(0, -'-async-response-input-required'.length).replace(/-/g, '_');\n record(tool, 'input-required', file);\n } else if (base.endsWith('-request')) {\n const tool = base.slice(0, -'-request'.length).replace(/-/g, '_');\n if (!index.has(`${tool}::request`)) record(tool, 'request', file);\n } else if (base.endsWith('-response')) {\n const tool = base.slice(0, -'-response'.length).replace(/-/g, '_');\n if (!index.has(`${tool}::sync`)) record(tool, 'sync', file);\n }\n }\n }\n\n return index;\n}\n\nfunction ensureInit(version: string): LoaderState {\n // States are keyed by bundle key, not by raw version string, so\n // `getValidator('foo', 'request', '3.0.0')` and the same call with\n // `'3.0.1'` share state — both resolve to bundle key `'3.0'` and the\n // same compiled AJV instance.\n const key = resolveBundleKey(version);\n const root = resolveSchemaRoot(version);\n const cacheKey = stateCacheKey(key, root);\n const cached = states.get(cacheKey);\n if (cached) return cached;\n const ajv = new Ajv({\n strict: false,\n allErrors: true,\n allowUnionTypes: true,\n });\n addFormats(ajv);\n\n const state: LoaderState = {\n ajv,\n fileIndex: buildFileIndex(root),\n validators: new Map(),\n rawSchemas: new Map(),\n root,\n coreLoaded: false,\n version: key,\n };\n states.set(cacheKey, state);\n return state;\n}\n\n/**\n * Lazily pre-register every non-tool JSON schema shipped with the SDK so\n * cross-domain `$ref`s compile. Async response variants and flat-tree\n * domain schemas `$ref` out to three classes of building-block schemas:\n *\n * - `core/` + `enums/` — shared primitives referenced by every domain.\n * - `pricing-options/`, `error-details/`, `extensions/` — stand-alone\n * fragment trees.\n * - Sibling fragments inside each domain directory — e.g.\n * `governance/audience-constraints.json` referenced by\n * `governance/sync-plans-request.json`, or `signals/*` fragments\n * referenced by `signals/activate-signal-*.json`.\n *\n * Walk every directory except `bundled/` (pre-resolved schemas with refs\n * already inlined). Response files that `buildFileIndex` registered as tools\n * are registered with `relaxResponseRoot` applied, matching `getValidator`.\n * The fileIndex check is stricter than a filename-suffix match:\n * building-block fragments like `core/pagination-response.json` end in\n * `-response.json` but aren't tools, so suffix-matching would wrongly treat\n * them as relaxable response roots.\n */\nfunction ensureCoreLoaded(s: LoaderState): void {\n if (s.coreLoaded) return;\n // Tool response files are pre-registered with the same response-root\n // relaxation `getValidator` would apply. This matters for the async response\n // union: `core/async-response-data.json` can `$ref` both async variants and\n // sync responses, so callers must not have to prewarm response validators\n // before compiling a request that references the union.\n //\n // Why this matters: bundles whose source tree doesn't include a `bundled/`\n // pre-resolved subtree (e.g. v2.5, where the spec ships flat schemas with\n // unresolved `$ref`s) classify fragments like `media-buy/package-request.json`\n // as tool `package::request` via the filename-suffix heuristic in\n // `buildFileIndex`. Skipping all tool files would leave that fragment\n // unregistered, so a later compile of `create_media_buy` fails on\n // `MissingRefError: can't resolve /schemas/media-buy/package-request.json`.\n //\n const responseToolFiles = new Map<string, Direction>();\n for (const [key, file] of s.fileIndex) {\n if (key.endsWith('::request')) continue;\n const direction = key.slice(key.indexOf('::') + 2) as Direction;\n responseToolFiles.set(file, direction);\n }\n const registeredIds = getAjvRegisteredIds(s.ajv);\n for (const entry of readdirSync(s.root, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n if (entry.name === 'bundled') continue;\n const abs = path.join(s.root, entry.name);\n for (const file of walkJsonFiles(abs)) {\n const responseDirection = responseToolFiles.get(file);\n const schema = loadJson(file);\n const schemaToRegister = responseDirection === undefined ? schema : relaxResponseRoot(schema);\n if (typeof schemaToRegister.$id === 'string' && !registeredIds.has(schemaToRegister.$id)) {\n s.ajv.addSchema(schemaToRegister);\n registeredIds.add(schemaToRegister.$id);\n }\n }\n }\n s.coreLoaded = true;\n}\n\n/**\n * Look up the compiled AJV validator for a given tool + direction in the\n * specified AdCP version's schema bundle. Returns `undefined` when no\n * schema exists for the pair — callers can skip validation cleanly (e.g.,\n * custom tools outside the AdCP spec).\n *\n * `version` defaults to the SDK-pinned `ADCP_VERSION`. Pass the per-instance\n * `getAdcpVersion()` value when the validator should track the client/server's\n * configured pin (Stage 3+).\n */\nexport function getValidator(\n toolName: string,\n direction: Direction,\n version: string = ADCP_VERSION\n): ValidateFunction | undefined {\n const s = ensureInit(version);\n const cacheKey = `${toolName}::${direction}`;\n const cached = s.validators.get(cacheKey);\n if (cached) return cached;\n\n const file = s.fileIndex.get(cacheKey);\n if (!file) return undefined;\n\n // Schemas that $ref into core/ and enums/ need those trees registered\n // before compile. Async response variants always do; flat-tree domain\n // schemas (anything outside `bundled/`) do too — their $refs weren't\n // pre-resolved at spec-publish time.\n const fromBundled = file.includes(`${path.sep}bundled${path.sep}`);\n if (direction === 'request' || !fromBundled) ensureCoreLoaded(s);\n\n const rawSchema = loadJson(file);\n // Bundled files inline every referenced subschema with the original\n // canonical `$id` (e.g. `core/version-envelope.json` appears nested\n // inside every bundled tool response). Bundled files carry NO\n // internal `$ref`s — the spec publishes them fully resolved, see\n // the `note: \"This is a bundled schema with all $ref resolved inline\"`\n // tag on every bundled file. Once `ensureCoreLoaded` has registered\n // any of those core schemas standalone (which it does for the flat-\n // tree governance / brand / property domains), Ajv's compile of a\n // bundled file trips the ambiguous-ref check on every nested $id.\n //\n // The fix: strip nested `$id` fields before compile on bundled\n // schemas. The root `$id` is kept (it's the validator's lookup key);\n // every other `$id` in the tree was just metadata anyway.\n const prepared = fromBundled ? stripNestedIds(rawSchema) : rawSchema;\n const schema = direction === 'request' ? prepared : relaxResponseRoot(prepared);\n const existing = typeof schema.$id === 'string' ? s.ajv.getSchema(schema.$id) : undefined;\n const compiled = existing ?? s.ajv.compile(schema);\n s.validators.set(cacheKey, compiled);\n return compiled;\n}\n\n/**\n * Compile an arbitrary schema from the cached bundle by path, e.g.\n * `core/mcp-webhook-payload.json`. Used by storyboard webhook assertions\n * whose payload schema is not tied to a tool request/response pair.\n */\nexport function getSchemaValidatorByRef(\n schemaRef: string,\n version: string = ADCP_VERSION\n): ValidateFunction | undefined {\n const s = ensureInit(version);\n const normalized = normalizeSchemaRef(schemaRef);\n if (!normalized) return undefined;\n\n const cacheKey = `schema-ref::${normalized}`;\n const cached = s.validators.get(cacheKey);\n if (cached) return cached;\n\n const file = path.join(s.root, normalized);\n if (!existsSync(file)) return undefined;\n\n // Use an isolated AJV instance for arbitrary schema refs. Tool response\n // validators deliberately relax some roots for SDK back-compat; webhook\n // payload schemas need strict raw JSON Schema behavior without polluting the\n // shared tool-validator registry with unrelaxed response schemas.\n const ajv = new Ajv({\n strict: false,\n allErrors: true,\n allowUnionTypes: true,\n });\n addFormats(ajv);\n const dependencySchemas: LoadedSchema[] = [];\n const registeredIds = new Set<string>();\n for (const schemaFile of walkJsonFiles(s.root)) {\n if (schemaFile.includes(`${path.sep}bundled${path.sep}`)) continue;\n if (schemaFile === file) continue;\n const schema = loadJson(schemaFile);\n if (typeof schema.$id === 'string' && !registeredIds.has(schema.$id)) {\n registeredIds.add(schema.$id);\n dependencySchemas.push(schema);\n }\n }\n if (dependencySchemas.length > 0) {\n ajv.addSchema(dependencySchemas);\n }\n const rawSchema = loadJson(file);\n const compiled = ajv.compile(rawSchema);\n s.validators.set(cacheKey, compiled);\n return compiled;\n}\n\nfunction normalizeSchemaRef(schemaRef: string): string | undefined {\n const trimmed = schemaRef.replace(/^\\/+/, '');\n if (trimmed.length === 0) return undefined;\n const normalized = path.normalize(trimmed);\n if (normalized.startsWith('..') || path.isAbsolute(normalized)) return undefined;\n return normalized;\n}\n\n/**\n * Strip `$id` from every subschema of a bundled response file, preserving\n * the root `$id`. Bundled files are fully inlined (no internal `$ref`s),\n * so the nested `$id`s are vestigial metadata — Ajv only cares about the\n * root `$id` for validator lookup. Without this strip, Ajv's\n * `checkAmbiguousRef` throws when an inlined nested `$id` matches one\n * already registered standalone via `ensureCoreLoaded`.\n *\n * Returns a deep-copied tree; the input is not mutated.\n */\nfunction stripNestedIds(schema: LoadedSchema): LoadedSchema {\n const root = JSON.parse(JSON.stringify(schema)) as LoadedSchema;\n const rootId = typeof root.$id === 'string' ? root.$id : undefined;\n const walk = (node: unknown): void => {\n if (Array.isArray(node)) {\n for (const item of node) walk(item);\n return;\n }\n if (!node || typeof node !== 'object') return;\n const obj = node as Record<string, unknown>;\n if (typeof obj.$id === 'string' && obj.$id !== rootId) {\n delete obj.$id;\n }\n for (const value of Object.values(obj)) walk(value);\n };\n walk(root);\n return root;\n}\n\n/** List of (toolName, direction) pairs that have schemas. Used by tests. */\nexport function listValidatorKeys(version: string = ADCP_VERSION): string[] {\n const s = ensureInit(version);\n return [...s.fileIndex.keys()].sort();\n}\n\n/**\n * `$id`s of every schema currently registered with the AdCP validator's AJV\n * instance for `version`. Used by the schema-validator to extract the\n * rejecting sub-schema's `$id` from an Ajv error's `schemaPath`: when a\n * `$ref` is followed, Ajv prefixes the schemaPath with the target schema's\n * `$id`, so the longest registered `$id` that prefixes a schemaPath is the\n * sub-schema responsible for the failure.\n *\n * The set grows as `getValidator` calls trigger `ensureCoreLoaded` and\n * compile new tool roots — callers should read it AFTER the validate call\n * they're projecting errors from.\n */\nexport function getRegisteredSchemaIds(version: string = ADCP_VERSION): readonly string[] {\n const s = ensureInit(version);\n // Ajv 8 keeps registered schemas at `ajv.schemas` (URI → SchemaEnv). Returning\n // the keys is enough for prefix matching; we don't expose the SchemaEnv values.\n const registry = (s.ajv as unknown as { schemas?: Record<string, unknown> }).schemas;\n return registry ? Object.keys(registry) : [];\n}\n\n/** Suffix used in the suffix table — exported for testing. */\nexport { SCHEMA_FILENAME_SUFFIX };\n\n/**\n * Returns true when the schema bundle for `version` is reachable from the\n * dist build or the source-tree fallback. Cheap synchronous check; safe\n * to call at construction time of clients/servers to fail fast on a pin\n * we don't have schemas for.\n */\nexport function hasSchemaBundle(version: string): boolean {\n try {\n resolveSchemaRoot(version);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Test hook: reset cached state. With no argument, clears every version's\n * loader state; with a version, clears only the bundle that version\n * resolves to (so passing `'3.0.0'` and `'3.0.1'` both clear the `'3.0'`\n * bundle).\n */\nexport function _resetValidationLoader(version?: string): void {\n if (version === undefined) {\n states.clear();\n } else {\n clearStatesForBundle(resolveBundleKey(version));\n }\n}\n\n/**\n * Returns true when `field` is **explicitly declared** as a top-level property\n * in the request schema for `toolName`, or when no schema is available\n * (fail-open). Used by the storyboard runner to decide whether to inject\n * envelope fields that aren't universally present across tools (e.g. `brand`,\n * `account`, `ext`).\n *\n * Reads the raw JSON schema file without compiling — avoids coupling to AJV\n * internals. Only inspects the top-level `properties` map; nested sub-schemas\n * are not traversed. Results are memoized in `LoaderState.rawSchemas` so\n * multi-step storyboard runs don't re-read the same file on each step.\n *\n * **Semantic note**: AdCP 3.1.0-beta.3 set `additionalProperties: true` on\n * mutating request schemas (vendor-extension friendly). Before that flip, the\n * helper used `additionalProperties: false` as the gate — \"if the schema is\n * strict, only `properties` keys are allowed.\" Now requests are universally\n * permissive at the schema level, so that gate would say `true` for any field\n * on any request — defeating the storyboard runner's intent (\"only inject\n * envelope fields the tool's schema declares it expects to see\"). The helper\n * now checks `field in properties` directly: the question we actually care\n * about is **\"does the schema declare this field at top level?\"**, not\n * \"does the schema permit this field at top level?\" (it permits everything).\n *\n * Fails open (returns `true`) when:\n * - No schema file is indexed for the tool (custom tool, schema not synced)\n * - The schema root is not reachable (schemas not built/synced yet)\n * - Any I/O / parse error during the read\n *\n * @internal — not part of the public API surface; may change without a major bump.\n */\nexport function schemaAllowsTopLevelField(toolName: string, field: string, version: string = ADCP_VERSION): boolean {\n try {\n const s = ensureInit(version);\n const cacheKey = `${toolName}::request`;\n const file = s.fileIndex.get(cacheKey);\n if (!file) return true;\n let schema = s.rawSchemas.get(cacheKey);\n if (!schema) {\n schema = loadJson(file) as Record<string, unknown>;\n s.rawSchemas.set(cacheKey, schema);\n }\n const props = schema.properties as Record<string, unknown> | undefined;\n return props !== undefined && field in props;\n } catch {\n return true;\n }\n}\n\n/**\n * Resolve a JSON Schema `default` value by walking a dot-separated property\n * path through a schema's nested `properties` maps.\n *\n * This intentionally does not instantiate AJV's `useDefaults` mutation mode.\n * Callers decide when a schema default is semantically meaningful for their\n * runtime object; this helper only reports what the bundled schema declares.\n *\n * Fails closed (`undefined`) when the schema is unavailable, the path is not a\n * concrete properties path, or the target schema node has no `default`.\n *\n * @internal — not part of the public API surface; may change without a major bump.\n */\nexport function getSchemaDefaultByPath(schemaRef: string, dottedPath: string, version: string = ADCP_VERSION): unknown {\n try {\n const s = ensureInit(version);\n const normalized = normalizeSchemaRef(schemaRef);\n if (!normalized) return undefined;\n\n const cacheKey = `schema-ref::${normalized}`;\n const file = path.join(s.root, normalized);\n if (!existsSync(file)) return undefined;\n\n let schema = s.rawSchemas.get(cacheKey);\n if (!schema) {\n schema = loadJson(file) as Record<string, unknown>;\n s.rawSchemas.set(cacheKey, schema);\n }\n\n const node = resolveSchemaPropertyPath(schema, dottedPath);\n if (!node || !Object.prototype.hasOwnProperty.call(node, 'default')) return undefined;\n return cloneJsonValue((node as { default: unknown }).default);\n } catch {\n return undefined;\n }\n}\n\nfunction resolveSchemaPropertyPath(\n schema: Record<string, unknown>,\n dottedPath: string\n): Record<string, unknown> | undefined {\n let current: unknown = schema;\n for (const key of dottedPath.split('.')) {\n if (!current || typeof current !== 'object') return undefined;\n const props = (current as Record<string, unknown>).properties;\n if (!props || typeof props !== 'object') return undefined;\n if (!Object.prototype.hasOwnProperty.call(props, key)) return undefined;\n current = (props as Record<string, unknown>)[key];\n }\n return current && typeof current === 'object' ? (current as Record<string, unknown>) : undefined;\n}\n\nfunction cloneJsonValue(value: unknown): unknown {\n if (value === null || typeof value !== 'object') return value;\n return JSON.parse(JSON.stringify(value)) as unknown;\n}\n"],"mappings":";;;;;;AAeA,OAAO,SAAoC;AAC3C,OAAO,gBAAgB;AACvB,SAAS,yBAAyB;AAClC,SAAS,aAAa,cAAc,kBAAkB;AACtD,OAAO,UAAU;AACjB,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AAUnC,MAAM,yBAAoD;AAAA,EACxD,SAAS;AAAA,EACT,MAAM;AAAA,EACN,WAAW;AAAA,EACX,SAAS;AAAA,EACT,kBAAkB;AACpB;AA+BO,SAAS,iBAAiB,SAAyB;AAExD,QAAM,YAAY,QAAQ,MAAM,gBAAgB;AAChD,MAAI,UAAW,QAAO,GAAG,UAAU,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC;AAKrD,QAAM,sBAAsB,QAAQ,MAAM,kDAAkD;AAC5F,MAAI,oBAAqB,QAAO;AAOhC,QAAM,SAAS,QAAQ,MAAM,gEAAgE;AAC7F,MAAI,QAAQ;AACV,UAAM,CAAC,EAAE,OAAO,OAAO,EAAE,UAAU,IAAI;AAC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,OAAO,GAAG,EAAG,QAAO;AAC9D,cAAW,MAAkC,GAAG;AAAA,EAClD;AACA,SAAO,WAAW,OAAO,YAAY,WAAY,UAAsC;AACzF;AAEA,SAAS,eAAe,OAAyB;AAC/C,MAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;","names":[]}
1
+ {"version":3,"sources":["../../../src/lib/validation/schema-loader.ts"],"sourcesContent":["import { fileURLToPath as __adcpFileURLToPath } from 'node:url';\nimport { dirname as __adcpDirname } from 'node:path';\nimport { createRequire as __adcpCreateRequire } from 'node:module';\nconst __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));\nconst require = __adcpCreateRequire(import.meta.url);\n/**\n * JSON Schema loader for AdCP tool request/response validation.\n *\n * Loads the bundled per-tool schemas shipped with the SDK plus the\n * `core/` schemas that async response variants `$ref`, then compiles\n * AJV validators lazily by `(toolName, direction)`.\n *\n * Stage 3: state is per-AdCP-version. The same SDK instance can hold\n * compiled validators for `3.0.0`, `3.0.1`, `3.1.0-beta.1`, etc. side by\n * side; callers pass the version they're validating against. Default is\n * the SDK-pinned `ADCP_VERSION` so callers that don't care about\n * cross-version selection (most internal call sites) keep working\n * unchanged.\n */\n\nimport Ajv, { type ValidateFunction } from 'ajv';\nimport addFormats from 'ajv-formats';\nimport { AsyncLocalStorage } from 'async_hooks';\nimport { readdirSync, readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport { ADCP_VERSION } from '../version';\nimport { ConfigurationError } from '../errors';\n\nexport type ResponseVariant = 'sync' | 'submitted' | 'working' | 'input-required';\nexport type Direction = 'request' | ResponseVariant;\n\ninterface LoadedSchema {\n $id?: string;\n [k: string]: unknown;\n}\n\nconst SCHEMA_FILENAME_SUFFIX: Record<Direction, string> = {\n request: 'request',\n sync: 'response',\n submitted: 'async-response-submitted',\n working: 'async-response-working',\n 'input-required': 'async-response-input-required',\n};\n\n/**\n * Map a consumer-provided version pin to the loader's bundle key.\n *\n * - Stable semver `'3.0.0'` / `'3.0.1'` → `'3.0'` (latest patch in minor)\n * - Bare minor `'3.0'` → `'3.0'` (already the bundle key)\n * - Release-precision prerelease `'3.1-beta'` / `'3.1-beta.0'` →\n * returned verbatim. {@link resolveSchemaRoot} fuzzy-resolves to the\n * highest cached prerelease directory whose own release-precision form\n * matches (e.g. `'3.1-beta'` matches `schemas/cache/3.1.0-beta.0/`).\n * Accepted because sellers advertise `supported_versions` in this\n * shape (`[\"3.1-beta\"]`), and a buyer reading that off the wire must\n * be able to pin to it.\n * - Full prerelease semver `'3.1.0-beta.1'` → `'3.1.0-beta.1'`\n * (exact-version, intentional pin)\n * - Legacy alias `'v3'` / `'v2.5'` / `'v2.6'` → returned verbatim (cache\n * historically keyed these directories by the alias name)\n *\n * Per the AdCP spec convention patches don't change wire shape, so collapsing\n * stable patches into the minor is functionally equivalent for any validator\n * consumer. Prereleases are kept exact because pinning a beta is intentional\n * and bit-fidelity matters for cross-version interop tests.\n *\n * Throws `ConfigurationError` for any input that doesn't match one of the\n * recognized shapes. Strings reach `path.join` via `resolveSchemaRoot`, and\n * pass-through of arbitrary garbage (`'../etc'`, `'3foo'`) lets a non-version\n * directory probe leak through `hasSchemaBundle`'s boolean. The throw is\n * caught by `hasSchemaBundle`'s try/catch (still returns false) and surfaces\n * with a useful field name from `resolveAdcpVersion`.\n */\nexport function resolveBundleKey(version: string): string {\n // Bare 'MAJOR.MINOR' (no patch).\n const minorOnly = version.match(/^(\\d+)\\.(\\d+)$/);\n if (minorOnly) return `${minorOnly[1]}.${minorOnly[2]}`;\n // Release-precision prerelease 'MAJOR.MINOR-PRE' (no patch). Same SemVer §9\n // prerelease constraint as the full-semver branch — `'3.1-/../etc'`-style\n // strings can't slip through. Returns verbatim; resolveSchemaRoot does the\n // fuzzy directory match.\n const releasePrecisionPre = version.match(/^(\\d+)\\.(\\d+)-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*$/);\n if (releasePrecisionPre) return version;\n // Full 'MAJOR.MINOR.PATCH' with optional prerelease. Prerelease group\n // restricted to SemVer §9 identifiers (alphanumerics + hyphen,\n // dot-separated) so `'3.0.0-/../etc'`-style strings can't slip through\n // and reach `path.join` as a directory component. The full version is\n // returned verbatim for prereleases, so this is the last line of defense\n // before that string becomes a path segment.\n const semver = version.match(/^(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$/);\n if (semver) {\n const [, major, minor, , prerelease] = semver;\n if (prerelease !== undefined) return version;\n return `${major}.${minor}`;\n }\n // Legacy alias: 'v' followed by a major and optional minor. Restricted to\n // this exact shape so non-version garbage can't reach the filesystem.\n const legacyAlias = version.match(/^v\\d+(\\.\\d+)?$/);\n if (legacyAlias) return version;\n throw new ConfigurationError(\n `AdCP version ${JSON.stringify(version)} is not a recognized version format. ` +\n `Expected semver (e.g. '3.0.1', '3.1.0-beta.1'), bare minor ('3.0'), ` +\n `release-precision ('3.1-beta'), or legacy alias ('v3', 'v2.5').`,\n 'adcpVersion'\n );\n}\n\n/**\n * Collapse a bundle key to the release-precision string the AdCP wire schema\n * accepts for the `adcp_version` envelope field (spec PR\n * `adcontextprotocol/adcp#3493`). The wire pattern is\n * `^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$` — release-precision (MAJOR.MINOR with\n * optional prerelease), never full MAJOR.MINOR.PATCH semver.\n *\n * - Stable bundle key `'3.0'` / `'3.1'` → returned verbatim.\n * - Prerelease bundle key `'3.1.0-beta.0'` → `'3.1-beta.0'` (PATCH segment\n * dropped; the prerelease tag is the wire-meaningful release identifier,\n * PATCH is implementation-internal).\n * - Full stable semver `'3.0.11'` → `'3.0'` (patches don't change wire\n * shape; surface them via `build_version` on capabilities instead).\n * - Legacy alias `'v3'` / `'v2.5'` — returned verbatim. The wire spec\n * predates the envelope field, so legacy-aliased clients won't emit\n * `adcp_version` anyway (gated by `bundleSupportsAdcpVersionField`).\n *\n * The normalization rule is declared in `core/version-envelope.json`:\n *\n * > SDKs that read full-semver values from bundle metadata (e.g.\n * > ComplianceIndex.published_version = \"3.1.0-beta.1\") MUST normalize to\n * > release-precision (\"3.1-beta.1\") before emitting on the wire —\n * > meta-field values are NOT valid wire values.\n *\n * **Idempotent.** Re-applying to an already-wire-shaped value is a no-op:\n * `toReleasePrecisionWire('3.1-beta.0') === '3.1-beta.0'`. Safe to call\n * defensively on values a caller read off the wire and is passing back.\n *\n * **Prerelease regex is stricter than the wire pattern by design.** The wire\n * pattern allows `[a-zA-Z0-9.-]+` (any mix of dots and hyphens), but this\n * function only accepts SemVer §9-shaped prerelease tags\n * (`[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*`) — disallowing leading dots, double\n * dots, or trailing dots. Mirrors the path-traversal hardening on\n * {@link resolveBundleKey} (`'3.0.0-/../etc'`-style strings can't reach the\n * filesystem there, and shouldn't be silently mirrored to the wire here).\n * A future reader who wants to \"fix\" this to match the wire regex\n * character-for-character should NOT — the strictness is intentional.\n *\n * Defense: rejecting unrecognized shapes here surfaces SDK-internal misuse\n * (someone calling this with raw garbage) loudly instead of silently\n * emitting a non-spec wire string.\n */\n/**\n * The exact pattern `core/version-envelope.json` applies to `adcp_version`\n * on the wire. Kept verbatim so {@link validateAdcpVersionWire} doesn't\n * drift from the spec — bump only when the spec itself bumps.\n */\nconst ADCP_VERSION_WIRE_PATTERN = /^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$/;\n\n/**\n * Validate a string against the AdCP 3.1 `adcp_version` wire pattern.\n * Throws `ConfigurationError` with a hint that points at\n * {@link toReleasePrecisionWire} when the value would be sent on the wire\n * but doesn't satisfy `core/version-envelope.json`'s pattern.\n *\n * Use this when you're constructing a request envelope by hand (storyboard\n * fixtures, conformance harnesses, custom transports) and want a clear\n * error rather than a downstream AJV pattern-mismatch from the seller —\n * by the time the seller rejects the request, the buyer's stack frame is\n * long gone and `core/version-envelope.json/properties/adcp_version/pattern`\n * is the only clue.\n *\n * The SDK's own `buildVersionEnvelope` calls this as a postcondition after\n * normalizing the bundle key — should never throw in well-formed SDK code,\n * but if a future refactor breaks the normalization the assertion fires\n * with a message that names the helper to call.\n *\n * Returns the value with the type narrowed to `string` via assertion.\n */\nexport function validateAdcpVersionWire(value: unknown): asserts value is string {\n if (typeof value !== 'string') {\n throw new ConfigurationError(\n `adcp_version must be a string. Got ${typeof value}. ` +\n `Use toReleasePrecisionWire() to convert a bundle key or full-semver pin to a wire-shaped string.`,\n 'adcp_version'\n );\n }\n if (!ADCP_VERSION_WIRE_PATTERN.test(value)) {\n throw new ConfigurationError(\n `adcp_version ${JSON.stringify(value)} doesn't match the AdCP 3.1 wire pattern ${ADCP_VERSION_WIRE_PATTERN}. ` +\n `Full-semver bundle keys (e.g. \"3.1.0-beta.0\") are NOT valid wire values — ` +\n `call toReleasePrecisionWire() to normalize (e.g. \"3.1.0-beta.0\" → \"3.1-beta.0\").`,\n 'adcp_version'\n );\n }\n}\n\nexport function toReleasePrecisionWire(bundleKeyOrVersion: string): string {\n // Bare release-precision (MAJOR.MINOR or MAJOR.MINOR-PRE) — already wire-shaped.\n const releasePrecision = bundleKeyOrVersion.match(/^(\\d+)\\.(\\d+)(-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/);\n if (releasePrecision) {\n const [, major, minor, prerelease = ''] = releasePrecision;\n return `${major}.${minor}${prerelease}`;\n }\n // Full semver — collapse PATCH segment. Prerelease (if any) is preserved.\n const fullSemver = bundleKeyOrVersion.match(/^(\\d+)\\.(\\d+)\\.\\d+(-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/);\n if (fullSemver) {\n const [, major, minor, prerelease = ''] = fullSemver;\n return `${major}.${minor}${prerelease}`;\n }\n // Legacy alias passthrough. Callers that reach here with a legacy alias\n // shouldn't be emitting `adcp_version` (no version-envelope support), but\n // returning the input verbatim is least-surprise.\n if (/^v\\d+(\\.\\d+)?$/.test(bundleKeyOrVersion)) return bundleKeyOrVersion;\n throw new ConfigurationError(\n `Cannot normalize ${JSON.stringify(bundleKeyOrVersion)} to release-precision wire format. ` +\n `Expected a bundle key or AdCP version string.`,\n 'adcpVersion'\n );\n}\n\n/**\n * Resolve the directory that holds the bundled + core schemas for a given\n * AdCP version. Source layout (dev):\n * schemas/cache/<exact-version>/{bundled,core}\n * Built layout (dist):\n * dist/lib/schemas-data/<bundle-key>/{bundled,core}\n *\n * Stable releases use minor-name keys (`3.0/`); prereleases use full-version\n * keys (`3.1.0-beta.1/`). See {@link resolveBundleKey}.\n *\n * Falls back to the source-tree cache when dist isn't built (dev workflow\n * before `npm run build:lib`). For stable pins, the cache fallback scans\n * for the highest-patch sibling in the requested minor — `'3.0.0'` resolves\n * to `schemas/cache/3.0.1/` when only `3.0.1` is cached, matching dist's\n * collapse behavior.\n *\n * Throws when no bundle exists. Callers pinning a specific prerelease\n * surface the error; the construction-time fence in `resolveAdcpVersion`\n * catches most cross-major mistakes before this point.\n */\nfunction resolveSchemaRoot(version: string): string {\n const key = resolveBundleKey(version);\n const scopedRoot = scopedExternalSchemaRoots.getStore()?.get(key);\n if (scopedRoot && existsSync(scopedRoot)) return scopedRoot;\n\n const externalRoot = externalSchemaRoots.get(key);\n if (externalRoot && existsSync(externalRoot)) return externalRoot;\n\n const distCandidate = path.join(__dirname, '..', 'schemas-data', key);\n if (existsSync(distCandidate)) return distCandidate;\n\n // Published builds carry exact prerelease bundle directories\n // (`3.1.0-rc.1/`), while callers may pin the release-precision family\n // alias (`3.1-rc`). Resolve that alias before falling back to source cache.\n const releasePrecisionMatch = /^\\d+\\.\\d+-/.test(key);\n if (releasePrecisionMatch) {\n const distPrereleaseCandidate = findPrereleaseBundle(path.join(__dirname, '..', 'schemas-data'), key);\n if (distPrereleaseCandidate) return distPrereleaseCandidate;\n }\n\n // Source-tree fallback: cache stays exact-version-named, so map the key\n // back to the highest-patch cache directory in the same minor for stable\n // pins. Prereleases need an exact match.\n const cacheRoot = path.join(__dirname, '..', '..', '..', 'schemas', 'cache');\n const exactCandidate = path.join(cacheRoot, version);\n if (existsSync(exactCandidate)) return exactCandidate;\n\n // For minor-only or stable-patch pins, find the highest stable patch in\n // the cache that matches the resolved minor. Skip `*.previous` snapshots\n // — `sync-schemas` writes those as transient backups during replaceTree;\n // a partially-written snapshot whose patch number happens to be highest\n // would otherwise win the sort.\n const minorMatch = key.match(/^(\\d+)\\.(\\d+)$/);\n if (minorMatch && existsSync(cacheRoot)) {\n const [, major, minor] = minorMatch;\n const prefix = `${major}.${minor}.`;\n const cached = readdirSync(cacheRoot, { withFileTypes: true })\n .filter(\n e =>\n e.isDirectory() &&\n e.name.startsWith(prefix) &&\n !e.name.endsWith('.previous') &&\n /^\\d+\\.\\d+\\.\\d+$/.test(e.name)\n )\n .map(e => ({\n name: e.name,\n patch: parseInt(e.name.slice(prefix.length), 10),\n }))\n .filter(c => Number.isFinite(c.patch))\n .sort((a, b) => b.patch - a.patch);\n if (cached.length > 0) return path.join(cacheRoot, cached[0]!.name);\n }\n\n // For release-precision prerelease pins (`'3.1-beta'`, `'3.1-beta.0'`),\n // find the highest cached prerelease directory whose own release-precision\n // form starts with the requested key. A pin of `'3.1-beta'` matches any\n // directory whose `toReleasePrecisionWire` form is `'3.1-beta'` or\n // `'3.1-beta.*'`. A pin of `'3.1-beta.0'` matches `'3.1-beta.0'` or\n // `'3.1-beta.0.*'`. Sort newest-first by directory name with numeric\n // collation so rc.10 wins over rc.9.\n if (releasePrecisionMatch) {\n const cachePrereleaseCandidate = findPrereleaseBundle(cacheRoot, key);\n if (cachePrereleaseCandidate) return cachePrereleaseCandidate;\n }\n\n throw new Error(\n `AdCP schema data for version \"${version}\" not found. ` +\n `Looked for bundle key \"${key}\" in ${distCandidate}, exact path ${exactCandidate}, ` +\n `and the latest-patch fallback in ${cacheRoot}. ` +\n `Run \\`npm run sync-schemas\\` and \\`npm run build:lib\\` to populate the bundle.`\n );\n}\n\nfunction findPrereleaseBundle(root: string, key: string): string | undefined {\n if (!existsSync(root)) return undefined;\n const cached = readdirSync(root, { withFileTypes: true })\n .filter(e => e.isDirectory() && !e.name.endsWith('.previous'))\n .map(e => {\n try {\n return { name: e.name, rp: toReleasePrecisionWire(e.name) };\n } catch {\n return null;\n }\n })\n .filter((c): c is { name: string; rp: string } => c !== null)\n .filter(c => c.rp === key || c.rp.startsWith(`${key}.`))\n .sort((a, b) => compareBundleNamesDesc(a.name, b.name));\n if (cached.length === 0) return undefined;\n return path.join(root, cached[0]!.name);\n}\n\nfunction compareBundleNamesDesc(a: string, b: string): number {\n return b.localeCompare(a, undefined, { numeric: true, sensitivity: 'base' });\n}\n\ninterface LoaderState {\n ajv: Ajv;\n fileIndex: Map<string, string>;\n validators: Map<string, ValidateFunction>;\n rawSchemas: Map<string, Record<string, unknown>>;\n root: string;\n coreLoaded: boolean;\n version: string;\n}\n\nconst states: Map<string, LoaderState> = new Map();\nconst externalSchemaRoots: Map<string, string> = new Map();\nconst scopedExternalSchemaRoots = new AsyncLocalStorage<Map<string, string>>();\n\nfunction stateCacheKey(bundleKey: string, root: string): string {\n return `${bundleKey}\\0${root}`;\n}\n\nfunction clearStatesForBundle(bundleKey: string): void {\n for (const [stateKey, state] of states) {\n if (state.version === bundleKey) states.delete(stateKey);\n }\n}\n\nfunction hasSchemaRootShape(root: string): boolean {\n if (!existsSync(root)) return false;\n const bundledRoot = path.join(root, 'bundled');\n const files = existsSync(bundledRoot) ? walkJsonFiles(bundledRoot) : walkJsonFiles(root);\n return files.some(file => {\n try {\n const schema = loadJson(file);\n return typeof schema.$id === 'string' || typeof schema.$schema === 'string';\n } catch {\n return false;\n }\n });\n}\n\nfunction schemaIdVersionHint(schemaId: string): string | undefined {\n return schemaId.match(/\\/schemas\\/([^/]+)\\//)?.[1];\n}\n\nfunction collectSchemaRootVersionAliases(root: string): Set<string> {\n const aliases = new Set<string>();\n for (const file of walkJsonFiles(root)) {\n let schema: LoadedSchema;\n try {\n schema = loadJson(file);\n } catch {\n continue;\n }\n if (typeof schema.$id !== 'string') continue;\n const hint = schemaIdVersionHint(schema.$id);\n if (!hint) continue;\n for (const alias of schemaRootVersionAliases(hint)) aliases.add(alias);\n }\n return aliases;\n}\n\nfunction schemaRootVersionAliases(version: string): Set<string> {\n const aliases = new Set<string>([version]);\n try {\n aliases.add(resolveBundleKey(version));\n } catch {\n // Keep the raw value only; callers that care will throw separately.\n }\n try {\n const releasePrecision = toReleasePrecisionWire(version);\n aliases.add(releasePrecision);\n const family = prereleaseFamilyAlias(releasePrecision);\n if (family) aliases.add(family);\n } catch {\n // Keep any aliases already collected.\n }\n return aliases;\n}\n\nfunction prereleaseFamilyAlias(releasePrecisionVersion: string): string | undefined {\n return releasePrecisionVersion.match(/^(\\d+\\.\\d+-[0-9A-Za-z-]+)\\.\\d+$/)?.[1];\n}\n\nfunction collectSchemaRootVersionAliasGroups(root: string): Array<{ hint: string; aliases: Set<string> }> {\n const groups: Array<{ hint: string; aliases: Set<string> }> = [];\n for (const file of walkJsonFiles(root)) {\n let schema: LoadedSchema;\n try {\n schema = loadJson(file);\n } catch {\n continue;\n }\n if (typeof schema.$id !== 'string') continue;\n const hint = schemaIdVersionHint(schema.$id);\n if (!hint) continue;\n groups.push({ hint, aliases: schemaRootVersionAliases(hint) });\n }\n return groups;\n}\n\nfunction assertSchemaRootMatchesVersion(version: string, root: string): Set<string> {\n const expectedAliases = schemaRootVersionAliases(version);\n const rootGroups = collectSchemaRootVersionAliasGroups(root);\n const rootAliases = collectSchemaRootVersionAliases(root);\n if (\n rootGroups.length > 0 &&\n rootGroups.every(group => [...group.aliases].some(alias => expectedAliases.has(alias)))\n ) {\n return new Set([...expectedAliases, ...rootAliases]);\n }\n const found =\n rootGroups.length === 0\n ? 'no AdCP schema ids'\n : rootGroups\n .map(group => `${group.hint} (${Array.from(group.aliases).sort().join(', ')})`)\n .sort()\n .join(', ');\n throw new Error(\n `External AdCP schema root for version \"${version}\" at ${root} does not match the requested version and ` +\n `must contain only schema ids matching ${Array.from(expectedAliases).sort().join(', ')}; found ${found}.`\n );\n}\n\nconst externalSchemaRootAliases: Map<string, Set<string>> = new Map();\n\n/**\n * Register a schema bundle supplied outside the installed SDK package.\n *\n * Compliance runners use this when `--compliance-dir` points at another\n * package/check-out whose storyboards and schema bundle should be used\n * together. The root must be the schema-data directory itself, e.g.\n * `.../dist/lib/schemas-data/3.0`.\n */\nexport function registerExternalSchemaRoot(version: string, root: string): void {\n const key = resolveBundleKey(version);\n if (!hasSchemaRootShape(root)) {\n throw new Error(`External AdCP schema root for version \"${version}\" not found or empty at ${root}`);\n }\n const aliases = assertSchemaRootMatchesVersion(version, root);\n externalSchemaRootAliases.set(key, aliases);\n for (const alias of aliases) {\n const previous = externalSchemaRoots.get(alias);\n externalSchemaRoots.set(alias, root);\n if (previous !== root) clearStatesForBundle(alias);\n }\n}\n\n/** Test/helper hook for unregistering an external schema bundle. */\nexport function unregisterExternalSchemaRoot(version: string): void {\n const key = resolveBundleKey(version);\n const aliases = new Set(schemaRootVersionAliases(version));\n for (const [registeredKey, registeredAliases] of externalSchemaRootAliases) {\n if (\n registeredKey === key ||\n registeredAliases.has(key) ||\n [...aliases].some(alias => registeredAliases.has(alias))\n ) {\n for (const alias of registeredAliases) aliases.add(alias);\n externalSchemaRootAliases.delete(registeredKey);\n }\n }\n for (const alias of aliases) {\n externalSchemaRoots.delete(alias);\n clearStatesForBundle(alias);\n }\n}\n\n/**\n * Run a callback with an external schema root scoped to the current async\n * execution chain. Unlike `registerExternalSchemaRoot`, this does not poison\n * process-global validation state for later hosted/compliance runs.\n */\nexport function withExternalSchemaRoot<T>(version: string, root: string | undefined, fn: () => T): T {\n if (root === undefined) return fn();\n if (!hasSchemaRootShape(root)) {\n throw new Error(`External AdCP schema root for version \"${version}\" not found or empty at ${root}`);\n }\n const aliases = assertSchemaRootMatchesVersion(version, root);\n const parent = scopedExternalSchemaRoots.getStore();\n const next = new Map(parent);\n for (const alias of aliases) {\n next.set(alias, root);\n clearStatesForBundle(alias);\n }\n return scopedExternalSchemaRoots.run(next, fn);\n}\n\nfunction walkJsonFiles(dir: string): string[] {\n if (!existsSync(dir)) return [];\n const out: string[] = [];\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) out.push(...walkJsonFiles(full));\n else if (entry.isFile() && entry.name.endsWith('.json')) out.push(full);\n }\n return out;\n}\n\nfunction loadJson(file: string): LoadedSchema {\n return JSON.parse(readFileSync(file, 'utf-8')) as LoadedSchema;\n}\n\n/**\n * Clear `additionalProperties: false` at the response root so envelope\n * fields (`replayed`, `context`, `ext`, and future envelope additions)\n * can ride alongside the tool-specific body — per security.mdx the\n * envelope is always extensible. Upstream bundled schemas pin\n * `additionalProperties: false` at the root on a handful of mutating\n * tools (the property-list family), which rejects envelope fields like\n * `replayed` that aren't declared in the tool-specific body.\n *\n * Scope is deliberately narrow: only the top-level object, plus each\n * direct branch of a root-level `oneOf` / `anyOf` / `allOf`. Nested\n * bodies stay strict so response-side drift detection still catches\n * typos inside `Product`, `Package`, `MediaBuy` etc. Applied only to\n * response variants; request schemas stay strict so outgoing drift\n * fails at the edge.\n */\nfunction relaxResponseRoot(schema: LoadedSchema): LoadedSchema {\n const clone = { ...schema };\n if (clone.additionalProperties === false) {\n clone.additionalProperties = true;\n }\n for (const key of ['oneOf', 'anyOf', 'allOf'] as const) {\n const branches = clone[key];\n if (Array.isArray(branches)) {\n clone[key] = branches.map(branch => {\n if (!branch || typeof branch !== 'object') return branch;\n const branchClone = { ...(branch as Record<string, unknown>) };\n if (branchClone.additionalProperties === false) {\n branchClone.additionalProperties = true;\n }\n return branchClone;\n });\n }\n }\n return clone;\n}\n\nfunction getAjvRegisteredIds(ajv: Ajv): Set<string> {\n const internals = ajv as unknown as {\n schemas?: Record<string, unknown>;\n refs?: Record<string, unknown>;\n };\n return new Set([...Object.keys(internals.schemas ?? {}), ...Object.keys(internals.refs ?? {})]);\n}\n\n/**\n * Build the (toolName, direction) → file path index by scanning the schema\n * tree once. Runs eagerly at first validator lookup.\n */\nfunction buildFileIndex(root: string): Map<string, string> {\n const index = new Map<string, string>();\n const record = (toolName: string, direction: Direction, file: string): void => {\n index.set(`${toolName}::${direction}`, file);\n };\n\n // Sync request/response live in the pre-resolved bundled/ tree.\n const bundledRoot = path.join(root, 'bundled');\n for (const file of walkJsonFiles(bundledRoot)) {\n const base = path.basename(file, '.json');\n if (base.endsWith('-request')) {\n const tool = base.slice(0, -'-request'.length).replace(/-/g, '_');\n record(tool, 'request', file);\n } else if (base.endsWith('-response')) {\n const tool = base.slice(0, -'-response'.length).replace(/-/g, '_');\n record(tool, 'sync', file);\n }\n }\n\n // Async variants AND domain schemas that ship flat (not pre-bundled) both\n // live in the per-domain directories. Walk each for sync request/response\n // files and async variant files. Skip `bundled/` (already indexed above)\n // and `core/` (pure $ref targets, no tools).\n //\n // Flat-tree domains include `governance/`, `brand/`, `account/`,\n // `content-standards/`, `property/`, `collection/` — their schemas are\n // NOT pre-resolved into `bundled/`, so a bundled-only walk would miss\n // every `check_governance` / `acquire_rights` / `creative_approval` /\n // `sync_governance` / `*_property_list` request-response pair. That gap\n // (flagged by the ad-tech-protocol reviewer on PR #831) would leave\n // protocol-wide-requirement-bearing tasks (idempotency_key pattern,\n // `format: uri` on `caller`) invisible to the strict-validation signal.\n // Register flat-tree sync pairs only when `bundled/` didn't already\n // index them, so pre-resolved schemas (with $refs already inlined) win\n // for any domain that ships both.\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n if (entry.name === 'bundled' || entry.name === 'core') continue;\n const domainDir = path.join(root, entry.name);\n for (const file of walkJsonFiles(domainDir)) {\n const base = path.basename(file, '.json');\n if (base.endsWith('-async-response-submitted')) {\n const tool = base.slice(0, -'-async-response-submitted'.length).replace(/-/g, '_');\n record(tool, 'submitted', file);\n } else if (base.endsWith('-async-response-working')) {\n const tool = base.slice(0, -'-async-response-working'.length).replace(/-/g, '_');\n record(tool, 'working', file);\n } else if (base.endsWith('-async-response-input-required')) {\n const tool = base.slice(0, -'-async-response-input-required'.length).replace(/-/g, '_');\n record(tool, 'input-required', file);\n } else if (base.endsWith('-request')) {\n const tool = base.slice(0, -'-request'.length).replace(/-/g, '_');\n if (!index.has(`${tool}::request`)) record(tool, 'request', file);\n } else if (base.endsWith('-response')) {\n const tool = base.slice(0, -'-response'.length).replace(/-/g, '_');\n if (!index.has(`${tool}::sync`)) record(tool, 'sync', file);\n }\n }\n }\n\n return index;\n}\n\nfunction ensureInit(version: string): LoaderState {\n // States are keyed by bundle key, not by raw version string, so\n // `getValidator('foo', 'request', '3.0.0')` and the same call with\n // `'3.0.1'` share state — both resolve to bundle key `'3.0'` and the\n // same compiled AJV instance.\n const key = resolveBundleKey(version);\n const root = resolveSchemaRoot(version);\n const cacheKey = stateCacheKey(key, root);\n const cached = states.get(cacheKey);\n if (cached) return cached;\n const ajv = new Ajv({\n strict: false,\n allErrors: true,\n allowUnionTypes: true,\n });\n addFormats(ajv);\n\n const state: LoaderState = {\n ajv,\n fileIndex: buildFileIndex(root),\n validators: new Map(),\n rawSchemas: new Map(),\n root,\n coreLoaded: false,\n version: key,\n };\n states.set(cacheKey, state);\n return state;\n}\n\n/**\n * Lazily pre-register every non-tool JSON schema shipped with the SDK so\n * cross-domain `$ref`s compile. Async response variants and flat-tree\n * domain schemas `$ref` out to three classes of building-block schemas:\n *\n * - `core/` + `enums/` — shared primitives referenced by every domain.\n * - `pricing-options/`, `error-details/`, `extensions/` — stand-alone\n * fragment trees.\n * - Sibling fragments inside each domain directory — e.g.\n * `governance/audience-constraints.json` referenced by\n * `governance/sync-plans-request.json`, or `signals/*` fragments\n * referenced by `signals/activate-signal-*.json`.\n *\n * Walk every directory except `bundled/` (pre-resolved schemas with refs\n * already inlined). Response files that `buildFileIndex` registered as tools\n * are registered with `relaxResponseRoot` applied, matching `getValidator`.\n * The fileIndex check is stricter than a filename-suffix match:\n * building-block fragments like `core/pagination-response.json` end in\n * `-response.json` but aren't tools, so suffix-matching would wrongly treat\n * them as relaxable response roots.\n */\nfunction ensureCoreLoaded(s: LoaderState): void {\n if (s.coreLoaded) return;\n // Tool response files are pre-registered with the same response-root\n // relaxation `getValidator` would apply. This matters for the async response\n // union: `core/async-response-data.json` can `$ref` both async variants and\n // sync responses, so callers must not have to prewarm response validators\n // before compiling a request that references the union.\n //\n // Why this matters: bundles whose source tree doesn't include a `bundled/`\n // pre-resolved subtree (e.g. v2.5, where the spec ships flat schemas with\n // unresolved `$ref`s) classify fragments like `media-buy/package-request.json`\n // as tool `package::request` via the filename-suffix heuristic in\n // `buildFileIndex`. Skipping all tool files would leave that fragment\n // unregistered, so a later compile of `create_media_buy` fails on\n // `MissingRefError: can't resolve /schemas/media-buy/package-request.json`.\n //\n const responseToolFiles = new Map<string, Direction>();\n for (const [key, file] of s.fileIndex) {\n if (key.endsWith('::request')) continue;\n const direction = key.slice(key.indexOf('::') + 2) as Direction;\n responseToolFiles.set(file, direction);\n }\n const registeredIds = getAjvRegisteredIds(s.ajv);\n for (const entry of readdirSync(s.root, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n if (entry.name === 'bundled') continue;\n const abs = path.join(s.root, entry.name);\n for (const file of walkJsonFiles(abs)) {\n const responseDirection = responseToolFiles.get(file);\n const schema = loadJson(file);\n const schemaToRegister = responseDirection === undefined ? schema : relaxResponseRoot(schema);\n if (typeof schemaToRegister.$id === 'string' && !registeredIds.has(schemaToRegister.$id)) {\n s.ajv.addSchema(schemaToRegister);\n registeredIds.add(schemaToRegister.$id);\n }\n }\n }\n s.coreLoaded = true;\n}\n\n/**\n * Look up the compiled AJV validator for a given tool + direction in the\n * specified AdCP version's schema bundle. Returns `undefined` when no\n * schema exists for the pair — callers can skip validation cleanly (e.g.,\n * custom tools outside the AdCP spec).\n *\n * `version` defaults to the SDK-pinned `ADCP_VERSION`. Pass the per-instance\n * `getAdcpVersion()` value when the validator should track the client/server's\n * configured pin (Stage 3+).\n */\nexport function getValidator(\n toolName: string,\n direction: Direction,\n version: string = ADCP_VERSION\n): ValidateFunction | undefined {\n const s = ensureInit(version);\n const cacheKey = `${toolName}::${direction}`;\n const cached = s.validators.get(cacheKey);\n if (cached) return cached;\n\n const file = s.fileIndex.get(cacheKey);\n if (!file) return undefined;\n\n // Schemas that $ref into core/ and enums/ need those trees registered\n // before compile. Async response variants always do; flat-tree domain\n // schemas (anything outside `bundled/`) do too — their $refs weren't\n // pre-resolved at spec-publish time.\n const fromBundled = file.includes(`${path.sep}bundled${path.sep}`);\n if (direction === 'request' || !fromBundled) ensureCoreLoaded(s);\n\n const rawSchema = loadJson(file);\n // Bundled files inline every referenced subschema with the original\n // canonical `$id` (e.g. `core/version-envelope.json` appears nested\n // inside every bundled tool response). Bundled files carry NO\n // internal `$ref`s — the spec publishes them fully resolved, see\n // the `note: \"This is a bundled schema with all $ref resolved inline\"`\n // tag on every bundled file. Once `ensureCoreLoaded` has registered\n // any of those core schemas standalone (which it does for the flat-\n // tree governance / brand / property domains), Ajv's compile of a\n // bundled file trips the ambiguous-ref check on every nested $id.\n //\n // The fix: strip nested `$id` fields before compile on bundled\n // schemas. The root `$id` is kept (it's the validator's lookup key);\n // every other `$id` in the tree was just metadata anyway.\n const prepared = fromBundled ? stripNestedIds(rawSchema) : rawSchema;\n const schema = direction === 'request' ? prepared : relaxResponseRoot(prepared);\n const existing = typeof schema.$id === 'string' ? s.ajv.getSchema(schema.$id) : undefined;\n const compiled = existing ?? s.ajv.compile(schema);\n s.validators.set(cacheKey, compiled);\n return compiled;\n}\n\n/**\n * Compile an arbitrary schema from the cached bundle by path, e.g.\n * `core/mcp-webhook-payload.json`. Used by storyboard webhook assertions\n * whose payload schema is not tied to a tool request/response pair.\n */\nexport function getSchemaValidatorByRef(\n schemaRef: string,\n version: string = ADCP_VERSION\n): ValidateFunction | undefined {\n const s = ensureInit(version);\n const normalized = normalizeSchemaRef(schemaRef);\n if (!normalized) return undefined;\n\n const cacheKey = `schema-ref::${normalized}`;\n const cached = s.validators.get(cacheKey);\n if (cached) return cached;\n\n const file = path.join(s.root, normalized);\n if (!existsSync(file)) return undefined;\n\n // Use an isolated AJV instance for arbitrary schema refs. Tool response\n // validators deliberately relax some roots for SDK back-compat; webhook\n // payload schemas need strict raw JSON Schema behavior without polluting the\n // shared tool-validator registry with unrelaxed response schemas.\n const ajv = new Ajv({\n strict: false,\n allErrors: true,\n allowUnionTypes: true,\n });\n addFormats(ajv);\n const dependencySchemas: LoadedSchema[] = [];\n const registeredIds = new Set<string>();\n for (const schemaFile of walkJsonFiles(s.root)) {\n if (schemaFile.includes(`${path.sep}bundled${path.sep}`)) continue;\n if (schemaFile === file) continue;\n const schema = loadJson(schemaFile);\n if (typeof schema.$id === 'string' && !registeredIds.has(schema.$id)) {\n registeredIds.add(schema.$id);\n dependencySchemas.push(schema);\n }\n }\n if (dependencySchemas.length > 0) {\n ajv.addSchema(dependencySchemas);\n }\n const rawSchema = loadJson(file);\n const compiled = ajv.compile(rawSchema);\n s.validators.set(cacheKey, compiled);\n return compiled;\n}\n\nfunction normalizeSchemaRef(schemaRef: string): string | undefined {\n const trimmed = schemaRef.replace(/^\\/+/, '');\n if (trimmed.length === 0) return undefined;\n const normalized = path.normalize(trimmed);\n if (normalized.startsWith('..') || path.isAbsolute(normalized)) return undefined;\n return normalized;\n}\n\n/**\n * Strip `$id` from every subschema of a bundled response file, preserving\n * the root `$id`. Bundled files are fully inlined (no internal `$ref`s),\n * so the nested `$id`s are vestigial metadata — Ajv only cares about the\n * root `$id` for validator lookup. Without this strip, Ajv's\n * `checkAmbiguousRef` throws when an inlined nested `$id` matches one\n * already registered standalone via `ensureCoreLoaded`.\n *\n * Returns a deep-copied tree; the input is not mutated.\n */\nfunction stripNestedIds(schema: LoadedSchema): LoadedSchema {\n const root = JSON.parse(JSON.stringify(schema)) as LoadedSchema;\n const rootId = typeof root.$id === 'string' ? root.$id : undefined;\n const walk = (node: unknown): void => {\n if (Array.isArray(node)) {\n for (const item of node) walk(item);\n return;\n }\n if (!node || typeof node !== 'object') return;\n const obj = node as Record<string, unknown>;\n if (typeof obj.$id === 'string' && obj.$id !== rootId) {\n delete obj.$id;\n }\n for (const value of Object.values(obj)) walk(value);\n };\n walk(root);\n return root;\n}\n\n/** List of (toolName, direction) pairs that have schemas. Used by tests. */\nexport function listValidatorKeys(version: string = ADCP_VERSION): string[] {\n const s = ensureInit(version);\n return [...s.fileIndex.keys()].sort();\n}\n\n/**\n * `$id`s of every schema currently registered with the AdCP validator's AJV\n * instance for `version`. Used by the schema-validator to extract the\n * rejecting sub-schema's `$id` from an Ajv error's `schemaPath`: when a\n * `$ref` is followed, Ajv prefixes the schemaPath with the target schema's\n * `$id`, so the longest registered `$id` that prefixes a schemaPath is the\n * sub-schema responsible for the failure.\n *\n * The set grows as `getValidator` calls trigger `ensureCoreLoaded` and\n * compile new tool roots — callers should read it AFTER the validate call\n * they're projecting errors from.\n */\nexport function getRegisteredSchemaIds(version: string = ADCP_VERSION): readonly string[] {\n const s = ensureInit(version);\n // Ajv 8 keeps registered schemas at `ajv.schemas` (URI → SchemaEnv). Returning\n // the keys is enough for prefix matching; we don't expose the SchemaEnv values.\n const registry = (s.ajv as unknown as { schemas?: Record<string, unknown> }).schemas;\n return registry ? Object.keys(registry) : [];\n}\n\n/** Suffix used in the suffix table — exported for testing. */\nexport { SCHEMA_FILENAME_SUFFIX };\n\n/**\n * Returns true when the schema bundle for `version` is reachable from the\n * dist build or the source-tree fallback. Cheap synchronous check; safe\n * to call at construction time of clients/servers to fail fast on a pin\n * we don't have schemas for.\n */\nexport function hasSchemaBundle(version: string): boolean {\n try {\n resolveSchemaRoot(version);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Test hook: reset cached state. With no argument, clears every version's\n * loader state; with a version, clears only the bundle that version\n * resolves to (so passing `'3.0.0'` and `'3.0.1'` both clear the `'3.0'`\n * bundle).\n */\nexport function _resetValidationLoader(version?: string): void {\n if (version === undefined) {\n states.clear();\n } else {\n clearStatesForBundle(resolveBundleKey(version));\n }\n}\n\n/**\n * Returns true when `field` is **explicitly declared** as a top-level property\n * in the request schema for `toolName`, or when no schema is available\n * (fail-open). Used by the storyboard runner to decide whether to inject\n * envelope fields that aren't universally present across tools (e.g. `brand`,\n * `account`, `ext`).\n *\n * Reads the raw JSON schema file without compiling — avoids coupling to AJV\n * internals. Only inspects the top-level `properties` map; nested sub-schemas\n * are not traversed. Results are memoized in `LoaderState.rawSchemas` so\n * multi-step storyboard runs don't re-read the same file on each step.\n *\n * **Semantic note**: AdCP 3.1.0-beta.3 set `additionalProperties: true` on\n * mutating request schemas (vendor-extension friendly). Before that flip, the\n * helper used `additionalProperties: false` as the gate — \"if the schema is\n * strict, only `properties` keys are allowed.\" Now requests are universally\n * permissive at the schema level, so that gate would say `true` for any field\n * on any request — defeating the storyboard runner's intent (\"only inject\n * envelope fields the tool's schema declares it expects to see\"). The helper\n * now checks `field in properties` directly: the question we actually care\n * about is **\"does the schema declare this field at top level?\"**, not\n * \"does the schema permit this field at top level?\" (it permits everything).\n *\n * Fails open (returns `true`) when:\n * - No schema file is indexed for the tool (custom tool, schema not synced)\n * - The schema root is not reachable (schemas not built/synced yet)\n * - Any I/O / parse error during the read\n *\n * @internal — not part of the public API surface; may change without a major bump.\n */\nexport function schemaAllowsTopLevelField(toolName: string, field: string, version: string = ADCP_VERSION): boolean {\n try {\n const s = ensureInit(version);\n const cacheKey = `${toolName}::request`;\n const file = s.fileIndex.get(cacheKey);\n if (!file) return true;\n let schema = s.rawSchemas.get(cacheKey);\n if (!schema) {\n schema = loadJson(file) as Record<string, unknown>;\n s.rawSchemas.set(cacheKey, schema);\n }\n const props = schema.properties as Record<string, unknown> | undefined;\n return props !== undefined && field in props;\n } catch {\n return true;\n }\n}\n\n/**\n * Resolve a JSON Schema `default` value by walking a dot-separated property\n * path through a schema's nested `properties` maps.\n *\n * This intentionally does not instantiate AJV's `useDefaults` mutation mode.\n * Callers decide when a schema default is semantically meaningful for their\n * runtime object; this helper only reports what the bundled schema declares.\n *\n * Fails closed (`undefined`) when the schema is unavailable, the path is not a\n * concrete properties path, or the target schema node has no `default`.\n *\n * @internal — not part of the public API surface; may change without a major bump.\n */\nexport function getSchemaDefaultByPath(schemaRef: string, dottedPath: string, version: string = ADCP_VERSION): unknown {\n try {\n const s = ensureInit(version);\n const normalized = normalizeSchemaRef(schemaRef);\n if (!normalized) return undefined;\n\n const cacheKey = `schema-ref::${normalized}`;\n const file = path.join(s.root, normalized);\n if (!existsSync(file)) return undefined;\n\n let schema = s.rawSchemas.get(cacheKey);\n if (!schema) {\n schema = loadJson(file) as Record<string, unknown>;\n s.rawSchemas.set(cacheKey, schema);\n }\n\n const node = resolveSchemaPropertyPath(schema, dottedPath);\n if (!node || !Object.prototype.hasOwnProperty.call(node, 'default')) return undefined;\n return cloneJsonValue((node as { default: unknown }).default);\n } catch {\n return undefined;\n }\n}\n\nfunction resolveSchemaPropertyPath(\n schema: Record<string, unknown>,\n dottedPath: string\n): Record<string, unknown> | undefined {\n let current: unknown = schema;\n for (const key of dottedPath.split('.')) {\n if (!current || typeof current !== 'object') return undefined;\n const props = (current as Record<string, unknown>).properties;\n if (!props || typeof props !== 'object') return undefined;\n if (!Object.prototype.hasOwnProperty.call(props, key)) return undefined;\n current = (props as Record<string, unknown>)[key];\n }\n return current && typeof current === 'object' ? (current as Record<string, unknown>) : undefined;\n}\n\nfunction cloneJsonValue(value: unknown): unknown {\n if (value === null || typeof value !== 'object') return value;\n return JSON.parse(JSON.stringify(value)) as unknown;\n}\n"],"mappings":"AAAA,SAAS,iBAAiB,2BAA2B;AACrD,SAAS,WAAW,qBAAqB;AACzC,SAAS,iBAAiB,2BAA2B;AACrD,MAAM,YAAY,cAAc,oBAAoB,YAAY,GAAG,CAAC;AACpE,MAAMA,WAAU,oBAAoB,YAAY,GAAG;AAgBnD,OAAO,SAAoC;AAC3C,OAAO,gBAAgB;AACvB,SAAS,yBAAyB;AAClC,SAAS,aAAa,cAAc,kBAAkB;AACtD,OAAO,UAAU;AACjB,SAAS,oBAA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AAM;AAAA,IACnC;AAEA,UAAM,OAAO,0BAA0B,QAAQ,UAAU;AACzD,QAAI,CAAC,QAAQ,CAAC,OAAO,UAAU,eAAe,KAAK,MAAM,SAAS,EAAG,QAAO;AAC5E,WAAO,eAAgB,KAA8B,OAAO;AAAA,EAC9D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,0BACP,QACA,YACqC;AACrC,MAAI,UAAmB;AACvB,aAAW,OAAO,WAAW,MAAM,GAAG,GAAG;AACvC,QAAI,CAAC,WAAW,OAAO,YAAY,SAAU,QAAO;AACpD,UAAM,QAAS,QAAoC;AACnD,QAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,OAAO,GAAG,EAAG,QAAO;AAC9D,cAAW,MAAkC,GAAG;AAAA,EAClD;AACA,SAAO,WAAW,OAAO,YAAY,WAAY,UAAsC;AACzF;AAEA,SAAS,eAAe,OAAyB;AAC/C,MAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;","names":["require"]}
@@ -1,9 +1,3 @@
1
- import { fileURLToPath as __adcpFileURLToPath } from 'node:url';
2
- import { dirname as __adcpDirname } from 'node:path';
3
- import { createRequire as __adcpCreateRequire } from 'node:module';
4
- const __filename = __adcpFileURLToPath(import.meta.url);
5
- const __dirname = __adcpDirname(__filename);
6
- const require = __adcpCreateRequire(import.meta.url);
7
1
  import { getValidator, getRegisteredSchemaIds } from "./schema-loader.mjs";
8
2
  import { parseAdcpMajorVersion } from "../version.mjs";
9
3
  import { findHint } from "./hints.mjs";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/validation/schema-validator.ts"],"sourcesContent":["/**\n * Schema-driven validation for AdCP tool requests and responses.\n *\n * The client uses this pre-send and post-receive; the opt-in server\n * middleware uses the same core to reject drift at the dispatcher.\n */\n\nimport type { ErrorObject } from 'ajv';\nimport { getValidator, getRegisteredSchemaIds, type Direction, type ResponseVariant } from './schema-loader';\nimport { parseAdcpMajorVersion } from '../version';\nimport { findHint } from './hints';\nimport { injectLegacyEnvelopeStatus } from '../utils/envelope-status-compat';\n\n/**\n * One variant of a `oneOf` / `anyOf` that the caller's payload could have\n * matched, summarized down to what a client (human or LLM) needs to know\n * to pick one. Attached to `ValidationIssue` when `keyword` is `oneOf`\n * or `anyOf`. Omitted otherwise.\n */\nexport interface ValidationIssueVariant {\n /** Zero-based index of the variant in the schema's `oneOf`/`anyOf` array. */\n index: number;\n /** Required property names on this variant (per its `required` array). */\n required: string[];\n /**\n * Keys declared in the variant's `properties`. Useful for clients that\n * want to show \"this variant accepts X, Y, Z\" without fetching the\n * full schema. Empty if the variant doesn't declare properties.\n */\n properties: string[];\n}\n\n/**\n * A single validation failure with a JSON Pointer to the offending field,\n * the AJV message, and the schema path that rejected it. Mirrors the\n * format a `VALIDATION_ERROR` carries at `adcp_error.issues` (top level)\n * and `adcp_error.details.issues` (spec-convention mirror).\n */\nexport interface ValidationIssue {\n /** RFC 6901 JSON Pointer to the offending field in the payload. */\n pointer: string;\n /** Human-readable message from the schema. */\n message: string;\n /** AJV keyword that rejected the payload (e.g., `required`, `type`). */\n keyword: string;\n /** Path inside the schema that rejected the payload. */\n schemaPath: string;\n /**\n * `$id` of the rejecting schema. Resolved by finding the longest\n * registered AJV `$id` that prefixes {@link schemaPath}.\n *\n * Bundling caveat: AdCP ships most tools through `schemas/cache/<v>/bundled/`\n * with `$ref`s pre-resolved and inner `$id`s stripped at bundle time. For\n * those tools, `schemaId` resolves to the response root (e.g.\n * `/schemas/3.0.4/bundled/signals/activate-signal-response.json`), not\n * the deeper sub-schema. Tools served from the flat tree (`governance/`,\n * `brand/`, etc.) preserve sub-schema `$id`s, so `schemaId` can land on\n * something deeper like `/schemas/3.0.4/core/activation-key.json`. Either\n * way, the field names exactly the schema the validator looked at.\n *\n * Always projected — the `$id` is the published spec URI, not internal\n * handler shape. (Same precedent as {@link ValidationIssue.variants} and\n * {@link ValidationIssue.allowedValues}, both of which already ship\n * always-on with the same rationale.)\n *\n * Absent only when the rejecting schema didn't declare an `$id`.\n */\n schemaId?: string;\n /**\n * Discriminator field/value pair(s) of a `oneOf`/`anyOf` that the payload\n * was inferred to be targeting. Populated by {@link compactUnionErrors}\n * when a const-discriminator collapse picks a \"best surviving variant\" —\n * the variant the user matched the discriminator of but missed required\n * fields or other constraints in. Compound discriminators like\n * `audience-selector`'s `(type, value_type)` produce multi-entry arrays.\n *\n * Names align with OpenAPI 3.x `discriminator.propertyName`.\n *\n * Absent when no discriminator could be resolved — either the keyword\n * isn't a union, the union has no `const`-asserting properties, or the\n * payload didn't match any branch's discriminator (in which case the\n * synthetic `enum`-keyword issue carries `allowedValues` instead).\n */\n discriminator?: ReadonlyArray<{ field: string; value: unknown }>;\n /**\n * Variants a caller can pick from when `keyword === 'oneOf'` or\n * `'anyOf'`. Each entry carries the variant's required fields + known\n * properties so a naive LLM client can recover without fetching the\n * full schema. Absent on non-union keywords.\n *\n * Unlike {@link ValidationIssue.schemaPath} (which is gated behind\n * `exposeSchemaPath` because it encodes which branch the seller's\n * handler rejected first — an implementation detail), `variants[]`\n * ships on the wire by default. Rationale: it reflects the PUBLIC\n * spec's union shape, which the bundled AdCP schemas under\n * `schemas/cache/<version>/` already make available to anyone with\n * `@adcp/sdk` installed. Gating would hurt naive LLM clients in\n * production — exactly the audience this field was built to help\n * (adcp-client#919).\n */\n variants?: ValidationIssueVariant[];\n /**\n * Closed enum values the payload MUST match for `keyword: 'enum'`\n * issues. AdCP wire schemas use enum heavily for status fields,\n * channels, pricing models, delivery types, etc. Without this list\n * on the wire envelope, both LLM-generated platforms and humans\n * have to fetch the schema just to discover the allowed values —\n * the most common self-correction failure surfaced by the Emma matrix.\n *\n * Absent on non-enum keywords. Always projected (not gated behind\n * `exposeSchemaPath`) — these are PUBLIC spec values, not internal\n * branch detail.\n */\n allowedValues?: readonly unknown[];\n /**\n * Curated one-sentence hint naming the most common adopter mistake for\n * a recognized failure pattern (e.g. \"type='key_value' requires\n * top-level `key` and `value` strings; do not nest under a `key_value`\n * field\"). Sourced from {@link import('./hints').findHint} — see\n * `validation/hints.ts` for the rule table and the\n * empirical-evidence quality bar for adding new entries.\n *\n * Absent for issues that don't match a curated rule. Most issues\n * won't have a hint, and that's fine — the structured `pointer` +\n * `keyword` + `discriminator` + `variants` already cover the long\n * tail. Hints are reserved for shape gotchas where the validator's\n * raw message reads as ambiguous to a first-time adopter.\n */\n hint?: string;\n}\n\nexport interface ValidationOutcome {\n valid: boolean;\n issues: ValidationIssue[];\n /** Which schema variant was selected — useful for logging/debugging. */\n variant: Direction | 'skipped';\n /**\n * `$id` of the root validator that produced this outcome (e.g.\n * `/schemas/3.0.4/bundled/signals/activate-signal-response.json`). Lets\n * downstream callers suppress redundant `(schema: ...)` prose suffixes\n * on issues that landed on the response root — typical for the bundled\n * tree, where most issues do. Absent when no schema was applied\n * (`variant: 'skipped'`) or the root schema didn't declare an `$id`.\n */\n schemaId?: string;\n /**\n * True when the response's `status` field named an async variant\n * (`submitted` / `working` / `input-required`) but no compiled schema\n * existed for that variant, so validation fell back to the sync\n * response schema. The agent is using an async shape that this tool\n * doesn't explicitly schema — a conformance signal the sync-fallback\n * validation can't render by itself. Absent on normal sync or\n * fully-schema-covered async flows.\n */\n variant_fallback_applied?: boolean;\n /** Variant requested by payload shape before fallback. Set iff `variant_fallback_applied`. */\n requested_variant?: ResponseVariant;\n}\n\nconst OK: ValidationOutcome = Object.freeze({ valid: true, issues: [], variant: 'skipped' });\n\n/**\n * Marker attached by {@link compactUnionErrors} to the residual errors of\n * the variant it picked as the best surviving branch. Carries the\n * discriminator field+value pair(s) that variant requires, so\n * {@link formatIssue} can surface the branch identifier on every issue\n * inherited from that variant. Marker key is namespaced with `__adcp_` to\n * avoid colliding with anything Ajv may add.\n */\ntype AdcpDiscriminatedError = ErrorObject & {\n __adcp_discriminator?: ReadonlyArray<{ field: string; value: unknown }>;\n};\n\n/**\n * Find the longest registered AJV `$id` that prefixes `schemaPath` — that\n * `$id` belongs to the schema (or `$ref`'d sub-schema) responsible for the\n * failure. Returns `undefined` for inline (`#/...`) paths when the root\n * schema doesn't declare an `$id`.\n *\n * AJV 8 prefixes a `$ref`'d schema's errors with the target schema's `$id`\n * (e.g. `/schemas/3.0.4/core/activation-key.json/oneOf/1/required`), so\n * the prefix search resolves cleanly without re-traversing the schema\n * graph. The match must end at a path boundary — `'/'` or `'#'` — so an\n * `$id` ending in `.json` can't false-match a sibling whose `$id` is a\n * proper extension of it.\n */\nfunction extractSchemaId(\n schemaPath: string,\n rootSchema: unknown,\n registeredIds: readonly string[]\n): string | undefined {\n if (schemaPath.startsWith('#') || schemaPath === '') {\n const id = (rootSchema as { $id?: unknown } | null | undefined)?.$id;\n return typeof id === 'string' ? id : undefined;\n }\n // The Ajv registry includes the JSON Schema meta-schema\n // (`http://json-schema.org/draft-07/schema`) alongside AdCP `$id`s. Ajv\n // never emits schemaPaths prefixed with the meta-schema URL — those\n // paths use the relative `#/...` form and take the branch above — so\n // the meta-schema entry never false-matches here.\n let best: string | undefined;\n for (const id of registeredIds) {\n if (!id) continue;\n if (schemaPath === id || schemaPath.startsWith(`${id}/`) || schemaPath.startsWith(`${id}#`)) {\n if (best === undefined || id.length > best.length) best = id;\n }\n }\n return best;\n}\n\ninterface FormatContext {\n rootSchema: unknown;\n registeredIds: readonly string[];\n /**\n * Tool name being validated. Threaded into {@link findHint} so curated\n * hints that gate on tool name can fire. Optional only because\n * `validateRequest` / `validateResponse` always pass it; tests that\n * call `formatIssue` directly are the rare exception.\n */\n toolName?: string;\n}\n\nfunction formatIssue(err: ErrorObject, ctx: FormatContext): ValidationIssue {\n const instancePath = err.instancePath || '';\n const missingProperty =\n err.keyword === 'required' &&\n err.params &&\n typeof (err.params as { missingProperty?: string }).missingProperty === 'string'\n ? `/${(err.params as { missingProperty: string }).missingProperty}`\n : '';\n\n // Enrich enum errors with the allowed values from AJV's params + replace\n // the opaque \"must be equal to one of the allowed values\" message with\n // the actual list. Without this, LLM-generated platforms can't self-\n // correct (Emma matrix v17, 2026-04-30): the validation cascade from\n // a single bad enum value swallows ~30 storyboard steps because no\n // self-correction signal is available without fetching the schema.\n const isEnum =\n err.keyword === 'enum' &&\n err.params != null &&\n Array.isArray((err.params as { allowedValues?: unknown[] }).allowedValues);\n const allowedValues = isEnum ? (err.params as { allowedValues: readonly unknown[] }).allowedValues : undefined;\n const message = isEnum\n ? `must be one of: ${allowedValues!.map(v => JSON.stringify(v)).join(', ')}`\n : (err.message ?? 'validation failed');\n\n const schemaId = extractSchemaId(err.schemaPath, ctx.rootSchema, ctx.registeredIds);\n const discriminator = (err as AdcpDiscriminatedError).__adcp_discriminator;\n const issue: ValidationIssue = {\n pointer: `${instancePath}${missingProperty}` || '/',\n message,\n keyword: err.keyword,\n schemaPath: err.schemaPath,\n ...(schemaId !== undefined && { schemaId }),\n ...(discriminator !== undefined && discriminator.length > 0 && { discriminator }),\n ...(allowedValues !== undefined && { allowedValues }),\n };\n // Attach a curated `hint` last so the matcher can read every other\n // resolved field (schemaId, discriminator, pointer, keyword) when\n // deciding whether to fire. Most issues won't match any rule —\n // findHint returns undefined, and the field stays absent.\n const hint = findHint(issue, ctx.toolName);\n if (hint !== undefined) issue.hint = hint;\n return issue;\n}\n\n// Path segments we refuse to walk into during schema-path resolution. AJV\n// emits trusted `schemaPath` strings today, but the function is exported in\n// shape (anything in this file is reachable via the compiled JS), so any\n// future caller passing user-influenced paths can't traverse into prototype\n// chains. Bundled schemas have no use for these names either.\nconst FORBIDDEN_SCHEMA_PATH_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/**\n * Resolve an AJV `schemaPath` like `\"#/properties/account/oneOf\"` against\n * the compiled validator's root schema. Returns `undefined` if the path\n * doesn't land on an object. Handles URI-encoded path segments (AJV\n * escapes `~` as `~0` and `/` as `~1` per RFC 6901).\n *\n * Refuses prototype-chain segments and uses own-property indexing so a\n * future caller (or a pathological future schema) can't induce a walk\n * into `Object.prototype`.\n */\nfunction resolveSchemaPath(rootSchema: unknown, schemaPath: string): unknown {\n if (rootSchema == null) return undefined;\n const clean = schemaPath.replace(/^#\\/?/, '');\n if (clean.length === 0) return rootSchema;\n let cursor: unknown = rootSchema;\n for (const raw of clean.split('/')) {\n if (cursor == null || (typeof cursor !== 'object' && !Array.isArray(cursor))) return undefined;\n const decoded = raw.replace(/~1/g, '/').replace(/~0/g, '~');\n if (FORBIDDEN_SCHEMA_PATH_SEGMENTS.has(decoded)) return undefined;\n if (!Object.prototype.hasOwnProperty.call(cursor, decoded)) return undefined;\n cursor = (cursor as Record<string, unknown>)[decoded];\n }\n return cursor;\n}\n\n/**\n * Compact AJV's `oneOf` / `anyOf` cascades before they reach the wire.\n *\n * AJV with `allErrors: true` emits one error per non-matching variant\n * plus a synthetic \"must match exactly one schema\" root. For a 9-way\n * `pricing_options` union with a single bad `pricing_model` value that\n * is 14+ errors per failed item, drowning real residual errors elsewhere\n * in the same payload (adcontextprotocol/adcp-client#1111).\n *\n * Strategy:\n * 1. For each union root, group variant errors by variant index.\n * 2. Inspect each variant's schema for `const`-constrained properties.\n * A property where ≥2 variants assert `const` at the same path is a\n * candidate discriminator (covers single-field discriminators like\n * `pricing_model` and composite ones like `audience-selector`'s\n * `(type, value_type)`).\n * 3. Collapse a candidate path iff EVERY variant that asserts `const`\n * there emitted a `const` error. (If some variants silently passed,\n * the user's value matched some allowed const — collapsing would\n * hide that and tell them their valid value was wrong.)\n * 4. Each collapse becomes a synthetic `enum`-keyword issue carrying\n * the union of allowed const values; the existing `formatIssue`\n * enrichment then renders \"must be one of: A, B, ...\".\n * 5. After collapse, if any variant has zero residual errors, the\n * discriminator collapse fully explains the failure — drop the\n * synthetic union root and the residuals from the other variants.\n * 6. Otherwise pick the variant with the fewest residual errors,\n * tie-breaking by fewest residual `const` errors so a variant the\n * user's discriminator value satisfied wins over a sibling whose\n * discriminator they violated. Drop the rest.\n */\nfunction compactUnionErrors(errors: readonly ErrorObject[], rootSchema: unknown): ErrorObject[] {\n if (errors.length === 0) return [...errors];\n\n // Pre-bucket once so each error is scanned a constant number of times even\n // when a malicious or pathological payload pushes Ajv to emit thousands of\n // errors across many union failures. The naive `for root in unionRoots: for\n // e in errors` form is O(U·N) — at K=100 product items each producing a\n // 14-error pricing-options cascade that's ~140k iterations on the\n // request-validation hot path.\n const errorsByOneOfPath = new Map<string, ErrorObject[]>();\n for (const e of errors) {\n const m = e.schemaPath.match(/^(.*\\/(?:oneOf|anyOf))\\/\\d+(?:\\/|$)/);\n if (!m) continue;\n const root = m[1]!;\n const bucket = errorsByOneOfPath.get(root);\n if (bucket) bucket.push(e);\n else errorsByOneOfPath.set(root, [e]);\n }\n\n const dropped = new Set<ErrorObject>();\n const added: ErrorObject[] = [];\n\n // Deepest-first ordering matters for nested unions: by the time the outer\n // root is evaluated, the inner cascade has already been replaced by a\n // synthetic enum at a `<...>/discriminator/<field>` schemaPath that won't\n // match the outer's `oneOfPath + '/'` prefix and stays independent.\n const unionRoots = errors\n .filter(e => e.keyword === 'oneOf' || e.keyword === 'anyOf')\n .slice()\n .sort((a, b) => b.schemaPath.length - a.schemaPath.length);\n\n for (const root of unionRoots) {\n if (dropped.has(root)) continue;\n const oneOfPath = root.schemaPath;\n const rootInstance = root.instancePath;\n\n // Variant errors: pulled from the prebuilt index (constant per-error work\n // above), then grouped by variant index. instancePath scoping keeps two\n // separate union failures sharing the same `schemaPath` but different\n // instancePaths — e.g., `products[0].pricing_options[0]` and\n // `products[1]...` — independent.\n const candidateErrors = errorsByOneOfPath.get(oneOfPath) ?? [];\n const byVariant = new Map<number, ErrorObject[]>();\n for (const e of candidateErrors) {\n if (e === root || dropped.has(e)) continue;\n const tail = e.schemaPath.slice(oneOfPath.length + 1);\n const m = tail.match(/^(\\d+)(?:\\/|$)/);\n if (!m) continue;\n if (e.instancePath !== rootInstance && !e.instancePath.startsWith(rootInstance + '/')) continue;\n const idx = parseInt(m[1]!, 10);\n const bucket = byVariant.get(idx);\n if (bucket) bucket.push(e);\n else byVariant.set(idx, [e]);\n }\n if (byVariant.size === 0) continue;\n\n // Resolve the variant schema array. Without it we fall back to a pure\n // error-shape collapse (still correct, just less precise on which\n // variants asserted const where the user happened to match).\n const variantSchemas = resolveSchemaPath(rootSchema, oneOfPath);\n const variantArr: readonly unknown[] = Array.isArray(variantSchemas) ? variantSchemas : [];\n\n // For each top-level property in each variant, record which variants\n // declare a `const` value there. Top-level only — composite\n // discriminators in AdCP (`audience-selector`, pricing-option) all\n // sit at the variant root.\n const constAsserters = new Map<string, Map<number, unknown>>();\n for (let i = 0; i < variantArr.length; i++) {\n const variant = variantArr[i];\n if (!variant || typeof variant !== 'object') continue;\n const props = (variant as { properties?: unknown }).properties;\n if (!props || typeof props !== 'object') continue;\n for (const [key, prop] of Object.entries(props as Record<string, unknown>)) {\n if (prop && typeof prop === 'object' && 'const' in prop) {\n const path = `/${key.replace(/~/g, '~0').replace(/\\//g, '~1')}`;\n let m = constAsserters.get(path);\n if (!m) constAsserters.set(path, (m = new Map()));\n m.set(i, (prop as { const: unknown }).const);\n }\n }\n }\n\n // For each candidate path with ≥2 asserters, did every asserter emit?\n const collapsedPaths = new Set<string>();\n for (const [relPath, asserters] of constAsserters) {\n if (asserters.size < 2) continue;\n const absolutePath = rootInstance + relPath;\n const emittersByVariant = new Map<number, ErrorObject>();\n for (const [idx, errs] of byVariant) {\n for (const e of errs) {\n if (e.keyword === 'const' && e.instancePath === absolutePath) {\n emittersByVariant.set(idx, e);\n break;\n }\n }\n }\n let allEmitted = true;\n for (const idx of asserters.keys()) {\n if (!emittersByVariant.has(idx)) {\n allEmitted = false;\n break;\n }\n }\n if (!allEmitted) continue;\n\n const allowedValues: unknown[] = [];\n for (const v of asserters.values()) {\n const already = allowedValues.some(existing => existing === v);\n if (!already) allowedValues.push(v);\n }\n const sample = emittersByVariant.values().next().value as ErrorObject;\n // Synthetic enum issue. `schemaPath: ''` keeps it out of any caller\n // that walks the path back to a real schema location (the synthesized\n // `<oneOfPath>/discriminator/<field>` would dangle if dereferenced)\n // while still satisfying the wire shape — the response-side errors\n // helper already gates `schemaPath` exposure via `exposeSchemaPath`.\n // `JSON.stringify` on the const values is safe: they come from the\n // bundled (trusted) schema and the outer wire envelope re-encodes\n // anyway, so control characters or quotes can't break framing.\n added.push({\n ...sample,\n keyword: 'enum',\n schemaPath: '',\n message: `must be one of: ${allowedValues.map(v => JSON.stringify(v)).join(', ')}`,\n params: { allowedValues },\n } as ErrorObject);\n for (const e of emittersByVariant.values()) dropped.add(e);\n collapsedPaths.add(absolutePath);\n }\n\n // Compute residuals after the collapse.\n const residualByVariant = new Map<number, ErrorObject[]>();\n for (const [idx, errs] of byVariant) {\n residualByVariant.set(\n idx,\n errs.filter(e => !dropped.has(e))\n );\n }\n\n if (collapsedPaths.size > 0) {\n const anyZeroResidual = [...residualByVariant.values()].some(r => r.length === 0);\n if (anyZeroResidual) {\n for (const errs of residualByVariant.values()) for (const e of errs) dropped.add(e);\n dropped.add(root);\n continue;\n }\n }\n\n // Variants with a `not` keyword failure are excluded from candidacy:\n // the payload populates fields the variant forbids by design (e.g. an\n // Error variant whose `not` clause rejects payloads that carry the\n // Success variant's `account` / `currency` / `period` fields). The\n // adopter's actionable lever is the OTHER variant's residuals (missing\n // required fields they need to add) — surfacing the `not` failure\n // points at a path the adopter shouldn't take. See adcp-client#1337.\n //\n // **Spec assumption.** AdCP 3.x uses `not` only as an envelope-level\n // mutual-exclusion guard between Success ↔ Error arms of a response\n // oneOf — never as an intra-arm discriminator (those use `const` on a\n // tag field, e.g. async `status: 'submitted' | 'working' | ...`).\n // The exclusion logic here targets that dominant pattern. If a future\n // spec ever inverts the convention (a Success arm using `not` to\n // discriminate sub-variants), this heuristic would suppress an\n // actionable diagnostic — re-evaluate the assumption when adopting\n // any AdCP version that does so.\n //\n // If every variant has a `not` failure, fall back to the unconstrained\n // pick — preserves diagnostic on contrived schemas where mutual-\n // exclusion is the only signal.\n const variantsWithNotFailure = new Set<number>();\n for (const [idx, errs] of byVariant) {\n for (const e of errs) {\n if (e.keyword === 'not') {\n variantsWithNotFailure.add(idx);\n break;\n }\n }\n }\n const allVariantsHaveNot = variantsWithNotFailure.size === byVariant.size && byVariant.size > 0;\n\n // Pick the best surviving variant; prefer fewest residuals, tie-break\n // by fewest residual `const` errors (so variants whose discriminator\n // the user actually picked win over siblings whose discriminator they\n // violated). Excluded variants (mutual-exclusion `not` rejections) are\n // skipped unless all variants are excluded.\n let bestIdx = -1;\n let bestCount = Infinity;\n let bestConsts = Infinity;\n for (const [idx, residual] of residualByVariant) {\n if (!allVariantsHaveNot && variantsWithNotFailure.has(idx)) continue;\n const constCount = residual.reduce((n, e) => (e.keyword === 'const' ? n + 1 : n), 0);\n if (residual.length < bestCount || (residual.length === bestCount && constCount < bestConsts)) {\n bestIdx = idx;\n bestCount = residual.length;\n bestConsts = constCount;\n }\n }\n for (const [idx, residual] of residualByVariant) {\n if (idx !== bestIdx) for (const e of residual) dropped.add(e);\n }\n\n // Tag the surviving variant's residuals with the discriminator\n // field+value pair(s) it requires. Adopters reading the projected\n // issue see \"branch: type='key_value'\" alongside the missing-required\n // error, so they know which branch the seller's payload was inferred\n // to be targeting (issue #1283). Compound discriminators (e.g.,\n // `audience-selector`'s (type, value_type)) become multi-entry\n // arrays — order follows iteration of `constAsserters`, which mirrors\n // the variant's `properties` declaration order.\n if (bestIdx >= 0) {\n const pairs: Array<{ field: string; value: unknown }> = [];\n for (const [relPath, asserters] of constAsserters) {\n const constValue = asserters.get(bestIdx);\n if (constValue === undefined) continue;\n const field = relPath.startsWith('/') ? relPath.slice(1) : relPath;\n pairs.push({ field, value: constValue });\n }\n if (pairs.length > 0) {\n const surviving = residualByVariant.get(bestIdx) ?? [];\n for (const e of surviving) {\n // Deepest-first ordering means inner unions tag first; if a\n // residual is already tagged it carries the more specific\n // (deeper) discriminator, which is what the adopter needs to\n // fix. Don't clobber it with the outer union's tag — the outer\n // discriminator is context, not the actionable lever.\n // Bucketing-by-deepest-prefix in `errorsByOneOfPath` already\n // protects most leaf errors from entering this loop, but the\n // explicit guard makes the invariant resilient to future\n // changes in that bucket scheme.\n if ((e as AdcpDiscriminatedError).__adcp_discriminator !== undefined) continue;\n (e as AdcpDiscriminatedError).__adcp_discriminator = pairs;\n }\n }\n }\n }\n\n return [...errors.filter(e => !dropped.has(e)), ...added];\n}\n\n/**\n * When an AJV error has `keyword: 'oneOf' | 'anyOf'`, resolve the\n * schema's variant array and summarize each variant so a client can\n * pick one without fetching the full schema. See {@link ValidationIssueVariant}.\n * Returns the issue unchanged when the keyword doesn't match or the\n * resolution fails (e.g. the variant list is inlined in an unexpected\n * way).\n */\nfunction enrichWithVariants(issue: ValidationIssue, rootSchema: unknown): ValidationIssue {\n if (issue.keyword !== 'oneOf' && issue.keyword !== 'anyOf') return issue;\n const resolved = resolveSchemaPath(rootSchema, issue.schemaPath);\n if (!Array.isArray(resolved)) return issue;\n const variants: ValidationIssueVariant[] = resolved.map((variant: unknown, index: number) => {\n if (variant == null || typeof variant !== 'object') {\n return { index, required: [], properties: [] };\n }\n const v = variant as Record<string, unknown>;\n const required = Array.isArray(v.required) ? (v.required.filter(r => typeof r === 'string') as string[]) : [];\n const properties =\n v.properties != null && typeof v.properties === 'object' ? Object.keys(v.properties as object) : [];\n return { index, required, properties };\n });\n return { ...issue, variants };\n}\n\n/**\n * Validate an outgoing request against `{tool}-request.json`.\n *\n * `version` selects which AdCP version's schema bundle to validate against;\n * defaults to the SDK-pinned `ADCP_VERSION`. Pass the per-instance value\n * from `getAdcpVersion()` to validate against a pinned-version client/server's\n * schema.\n */\nexport function validateRequest(toolName: string, payload: unknown, version?: string): ValidationOutcome {\n const validator = getValidator(toolName, 'request', version);\n if (!validator) return OK;\n const valid = validator(payload) as boolean;\n const rootSchema = (validator as { schema?: unknown }).schema;\n const rootSchemaId =\n rootSchema && typeof rootSchema === 'object' && typeof (rootSchema as { $id?: unknown }).$id === 'string'\n ? ((rootSchema as { $id: string }).$id as string)\n : undefined;\n if (valid) return { valid: true, issues: [], variant: 'request', ...(rootSchemaId && { schemaId: rootSchemaId }) };\n const registeredIds = getRegisteredSchemaIds(version);\n const ctx: FormatContext = { rootSchema, registeredIds, toolName };\n const compacted = compactUnionErrors(validator.errors ?? [], rootSchema);\n return {\n valid: false,\n issues: compacted.map(e => formatIssue(e, ctx)).map(i => enrichWithVariants(i, rootSchema)),\n variant: 'request',\n ...(rootSchemaId && { schemaId: rootSchemaId }),\n };\n}\n\n/**\n * Strip top-level optional fields whose value is `null` but whose declared\n * schema type is not nullable (`type` does not include `'null'`).\n *\n * Applies only when validating against a v2.x schema bundle. v2.5 sellers\n * (Pydantic-origin) commonly emit `errors: null`, `context: null`, `ext: null`\n * to signal \"nothing here\" rather than omitting the key. The v2.5 schemas\n * don't include `null` in those types, so Ajv spuriously rejects them.\n *\n * Gated to v2.x only — in v3, `errors` is a required field on failure\n * branches, and silently stripping it across all versions would mask real\n * bugs in v3 seller responses.\n *\n * Returns a shallow clone with the offending keys removed, or the original\n * object unchanged if nothing was stripped. Safe to pass to an Ajv validator:\n * Ajv 8 (without `removeAdditional`/`useDefaults`/`coerceTypes`) does not\n * mutate its input.\n */\nfunction stripEnvelopeNulls(payload: unknown, schema: unknown): unknown {\n if (payload == null || typeof payload !== 'object' || Array.isArray(payload)) return payload;\n const s = schema as Record<string, unknown> | null;\n if (!s) return payload;\n const properties = s.properties as Record<string, unknown> | undefined;\n if (!properties) return payload;\n const required = new Set<string>(Array.isArray(s.required) ? (s.required as string[]) : []);\n const payloadObj = payload as Record<string, unknown>;\n let cloned: Record<string, unknown> | null = null;\n for (const [key, value] of Object.entries(payloadObj)) {\n if (value !== null) continue;\n if (required.has(key)) continue;\n const propSchema = properties[key] as Record<string, unknown> | undefined;\n if (!propSchema) continue;\n const type = propSchema.type;\n const isNullable = type === 'null' || (Array.isArray(type) && (type as string[]).includes('null'));\n if (!isNullable) {\n if (!cloned) cloned = { ...payloadObj };\n delete cloned[key];\n }\n }\n return cloned ?? payload;\n}\n\n/**\n * Select the response variant by payload shape (per issue #688: choose by\n * `status` field, not just the tool name). Matches the AdCP 3.0 async\n * contract: `submitted`, `working`, `input-required`, and the sync\n * terminal states (`completed` / no status).\n */\nfunction selectResponseVariant(payload: unknown): ResponseVariant {\n if (payload && typeof payload === 'object' && 'status' in (payload as Record<string, unknown>)) {\n const status = (payload as Record<string, unknown>).status;\n if (status === 'submitted') return 'submitted';\n if (status === 'working') return 'working';\n if (status === 'input-required') return 'input-required';\n }\n return 'sync';\n}\n\n/**\n * Validate an incoming response; picks the async variant by payload shape.\n *\n * `version` selects which AdCP version's schema bundle to validate against;\n * defaults to the SDK-pinned `ADCP_VERSION`. See {@link validateRequest} for\n * the per-instance use case.\n */\nexport function validateResponse(toolName: string, payload: unknown, version?: string): ValidationOutcome {\n // 3.0.x back-compat: synthesize envelope `status` when the payload\n // declares itself as 3.0.x (or carries no version field at all). 3.1+\n // payloads remain unchanged so the strict validator still rejects a\n // 3.1 peer that omits `status`. Applied before variant selection so a\n // synthesized `completed` doesn't get misrouted to the async-variant\n // schema. See `utils/envelope-status-compat.ts`.\n const compatPayload =\n payload && typeof payload === 'object' && !Array.isArray(payload)\n ? injectLegacyEnvelopeStatus(payload as Record<string, unknown>, { toolName })\n : payload;\n const variant = selectResponseVariant(compatPayload);\n const validator = getValidator(toolName, variant, version);\n // If an async variant schema is missing, fall back to the sync one —\n // some tools declare `-response.json` only and use `status` as an\n // in-band marker without a dedicated variant schema.\n const effective = validator ?? (variant !== 'sync' ? getValidator(toolName, 'sync', version) : undefined);\n if (!effective) return OK;\n const rootSchema = (effective as { schema?: unknown }).schema;\n // v2.x sellers (Pydantic-origin) emit optional envelope fields as null instead\n // of omitting them. Strip before Ajv to avoid spurious type errors on `errors`,\n // `context`, and `ext`. Gated to v2.x only — see stripEnvelopeNulls JSDoc.\n const isV2Bundle = version != null && parseAdcpMajorVersion(version) === 2;\n const normalizedPayload = isV2Bundle ? stripEnvelopeNulls(compatPayload, rootSchema) : compatPayload;\n const valid = effective(normalizedPayload) as boolean;\n const usedVariant: Direction = validator ? variant : 'sync';\n const variantFallback = !validator && variant !== 'sync';\n const fallbackFields: Pick<ValidationOutcome, 'variant_fallback_applied' | 'requested_variant'> = variantFallback\n ? { variant_fallback_applied: true, requested_variant: variant }\n : {};\n const rootSchemaId =\n rootSchema && typeof rootSchema === 'object' && typeof (rootSchema as { $id?: unknown }).$id === 'string'\n ? ((rootSchema as { $id: string }).$id as string)\n : undefined;\n if (valid) {\n return {\n valid: true,\n issues: [],\n variant: usedVariant,\n ...(rootSchemaId && { schemaId: rootSchemaId }),\n ...fallbackFields,\n };\n }\n const registeredIds = getRegisteredSchemaIds(version);\n const ctx: FormatContext = { rootSchema, registeredIds, toolName };\n const compacted = compactUnionErrors(effective.errors ?? [], rootSchema);\n return {\n valid: false,\n issues: compacted.map(e => formatIssue(e, ctx)).map(i => enrichWithVariants(i, rootSchema)),\n variant: usedVariant,\n ...(rootSchemaId && { schemaId: rootSchemaId }),\n ...fallbackFields,\n };\n}\n\n/**\n * Render `discriminator[]` as `field='value', other='x'`. Strings are\n * single-quoted (matches the issue #1283 example shape) with embedded\n * apostrophes backslash-escaped so a future spec const containing `'`\n * can't produce ambiguous output. Other JSON-safe values use\n * `JSON.stringify` so booleans and numbers stay unambiguous. Returns an\n * empty string when the array is empty so callers can compose\n * conditionally.\n */\nexport function formatDiscriminator(\n discriminator: ReadonlyArray<{ field: string; value: unknown }> | undefined\n): string {\n if (!discriminator || discriminator.length === 0) return '';\n return discriminator\n .map(({ field, value }) => {\n if (typeof value !== 'string') return `${field}=${JSON.stringify(value)}`;\n const escaped = value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n return `${field}='${escaped}'`;\n })\n .join(', ');\n}\n\n/**\n * One-line render of a validation issue with `(schema: <$id>)`,\n * `(discriminator: <field>='<value>')`, and `(hint: …)` suffixes when\n * the issue carries them. Used by both {@link formatIssues} and the\n * prose `message` field on `VALIDATION_ERROR` envelopes (issue #1283\n * for schema/discriminator, #1309 for hint), so adopters debugging from\n * the wire envelope alone see the rejecting schema, union discriminator,\n * and curated mistake-recipe without having to walk `issues[]`.\n *\n * The `(schema: ...)` suffix is suppressed for inline failures whose\n * `schemaId` is the response root — the tool name already conveys that,\n * and AdCP's bundled tree strips inner `$id`s so most issues land on the\n * root. Suppressing keeps the prose tight on the cases where the schema\n * field would just restate the tool the adopter already knows. Adopters\n * who want the field unconditionally read it from the structured\n * `issues[].schemaId`.\n */\nexport function formatIssueLine(issue: ValidationIssue, options: { rootSchemaId?: string } = {}): string {\n const parts: string[] = [`${issue.pointer} ${issue.message}`];\n if (issue.schemaId && issue.schemaId !== options.rootSchemaId) {\n parts.push(`(schema: ${issue.schemaId})`);\n }\n const discriminator = formatDiscriminator(issue.discriminator);\n if (discriminator) parts.push(`(discriminator: ${discriminator})`);\n if (issue.hint) parts.push(`(hint: ${issue.hint})`);\n return parts.join(' ');\n}\n\n/**\n * Render a compact one-line summary of the failures — useful for logs.\n *\n * `rootSchemaId`, when supplied, suppresses the `(schema: ...)` suffix on\n * issues whose `schemaId` matches it (typical for issues that landed on\n * the response root). Pass `undefined` to always emit the suffix.\n */\nexport function formatIssues(issues: ValidationIssue[], limit = 3, options: { rootSchemaId?: string } = {}): string {\n const head = issues\n .slice(0, limit)\n .map(i => formatIssueLine(i, options))\n .join('; ');\n const rest = issues.length - limit;\n return rest > 0 ? `${head} (+${rest} more)` : head;\n}\n"],"mappings":";;;;;;AAQA,SAAS,cAAc,8BAAoE;AAC3F,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AACzB,SAAS,kCAAkC;AAoJ3C,MAAM,KAAwB,OAAO,OAAO,EAAE,OAAO,MAAM,QAAQ,CAAC,GAAG,SAAS,UAAU,CAAC;AA2B3F,SAAS,gBACP,YACA,YACA,eACoB;AACpB,MAAI,WAAW,WAAW,GAAG,KAAK,eAAe,IAAI;AACnD,UAAM,KAAM,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AG,UAAqC,CAAC,GAAW;AAClH,QAAM,OAAO,OACV,MAAM,GAAG,KAAK,EACd,IAAI,OAAK,gBAAgB,GAAG,OAAO,CAAC,EACpC,KAAK,IAAI;AACZ,QAAM,OAAO,OAAO,SAAS;AAC7B,SAAO,OAAO,IAAI,GAAG,IAAI,MAAM,IAAI,WAAW;AAChD;","names":[]}
1
+ {"version":3,"sources":["../../../src/lib/validation/schema-validator.ts"],"sourcesContent":["/**\n * Schema-driven validation for AdCP tool requests and responses.\n *\n * The client uses this pre-send and post-receive; the opt-in server\n * middleware uses the same core to reject drift at the dispatcher.\n */\n\nimport type { ErrorObject } from 'ajv';\nimport { getValidator, getRegisteredSchemaIds, type Direction, type ResponseVariant } from './schema-loader';\nimport { parseAdcpMajorVersion } from '../version';\nimport { findHint } from './hints';\nimport { injectLegacyEnvelopeStatus } from '../utils/envelope-status-compat';\n\n/**\n * One variant of a `oneOf` / `anyOf` that the caller's payload could have\n * matched, summarized down to what a client (human or LLM) needs to know\n * to pick one. Attached to `ValidationIssue` when `keyword` is `oneOf`\n * or `anyOf`. Omitted otherwise.\n */\nexport interface ValidationIssueVariant {\n /** Zero-based index of the variant in the schema's `oneOf`/`anyOf` array. */\n index: number;\n /** Required property names on this variant (per its `required` array). */\n required: string[];\n /**\n * Keys declared in the variant's `properties`. Useful for clients that\n * want to show \"this variant accepts X, Y, Z\" without fetching the\n * full schema. Empty if the variant doesn't declare properties.\n */\n properties: string[];\n}\n\n/**\n * A single validation failure with a JSON Pointer to the offending field,\n * the AJV message, and the schema path that rejected it. Mirrors the\n * format a `VALIDATION_ERROR` carries at `adcp_error.issues` (top level)\n * and `adcp_error.details.issues` (spec-convention mirror).\n */\nexport interface ValidationIssue {\n /** RFC 6901 JSON Pointer to the offending field in the payload. */\n pointer: string;\n /** Human-readable message from the schema. */\n message: string;\n /** AJV keyword that rejected the payload (e.g., `required`, `type`). */\n keyword: string;\n /** Path inside the schema that rejected the payload. */\n schemaPath: string;\n /**\n * `$id` of the rejecting schema. Resolved by finding the longest\n * registered AJV `$id` that prefixes {@link schemaPath}.\n *\n * Bundling caveat: AdCP ships most tools through `schemas/cache/<v>/bundled/`\n * with `$ref`s pre-resolved and inner `$id`s stripped at bundle time. For\n * those tools, `schemaId` resolves to the response root (e.g.\n * `/schemas/3.0.4/bundled/signals/activate-signal-response.json`), not\n * the deeper sub-schema. Tools served from the flat tree (`governance/`,\n * `brand/`, etc.) preserve sub-schema `$id`s, so `schemaId` can land on\n * something deeper like `/schemas/3.0.4/core/activation-key.json`. Either\n * way, the field names exactly the schema the validator looked at.\n *\n * Always projected — the `$id` is the published spec URI, not internal\n * handler shape. (Same precedent as {@link ValidationIssue.variants} and\n * {@link ValidationIssue.allowedValues}, both of which already ship\n * always-on with the same rationale.)\n *\n * Absent only when the rejecting schema didn't declare an `$id`.\n */\n schemaId?: string;\n /**\n * Discriminator field/value pair(s) of a `oneOf`/`anyOf` that the payload\n * was inferred to be targeting. Populated by {@link compactUnionErrors}\n * when a const-discriminator collapse picks a \"best surviving variant\" —\n * the variant the user matched the discriminator of but missed required\n * fields or other constraints in. Compound discriminators like\n * `audience-selector`'s `(type, value_type)` produce multi-entry arrays.\n *\n * Names align with OpenAPI 3.x `discriminator.propertyName`.\n *\n * Absent when no discriminator could be resolved — either the keyword\n * isn't a union, the union has no `const`-asserting properties, or the\n * payload didn't match any branch's discriminator (in which case the\n * synthetic `enum`-keyword issue carries `allowedValues` instead).\n */\n discriminator?: ReadonlyArray<{ field: string; value: unknown }>;\n /**\n * Variants a caller can pick from when `keyword === 'oneOf'` or\n * `'anyOf'`. Each entry carries the variant's required fields + known\n * properties so a naive LLM client can recover without fetching the\n * full schema. Absent on non-union keywords.\n *\n * Unlike {@link ValidationIssue.schemaPath} (which is gated behind\n * `exposeSchemaPath` because it encodes which branch the seller's\n * handler rejected first — an implementation detail), `variants[]`\n * ships on the wire by default. Rationale: it reflects the PUBLIC\n * spec's union shape, which the bundled AdCP schemas under\n * `schemas/cache/<version>/` already make available to anyone with\n * `@adcp/sdk` installed. Gating would hurt naive LLM clients in\n * production — exactly the audience this field was built to help\n * (adcp-client#919).\n */\n variants?: ValidationIssueVariant[];\n /**\n * Closed enum values the payload MUST match for `keyword: 'enum'`\n * issues. AdCP wire schemas use enum heavily for status fields,\n * channels, pricing models, delivery types, etc. Without this list\n * on the wire envelope, both LLM-generated platforms and humans\n * have to fetch the schema just to discover the allowed values —\n * the most common self-correction failure surfaced by the Emma matrix.\n *\n * Absent on non-enum keywords. Always projected (not gated behind\n * `exposeSchemaPath`) — these are PUBLIC spec values, not internal\n * branch detail.\n */\n allowedValues?: readonly unknown[];\n /**\n * Curated one-sentence hint naming the most common adopter mistake for\n * a recognized failure pattern (e.g. \"type='key_value' requires\n * top-level `key` and `value` strings; do not nest under a `key_value`\n * field\"). Sourced from {@link import('./hints').findHint} — see\n * `validation/hints.ts` for the rule table and the\n * empirical-evidence quality bar for adding new entries.\n *\n * Absent for issues that don't match a curated rule. Most issues\n * won't have a hint, and that's fine — the structured `pointer` +\n * `keyword` + `discriminator` + `variants` already cover the long\n * tail. Hints are reserved for shape gotchas where the validator's\n * raw message reads as ambiguous to a first-time adopter.\n */\n hint?: string;\n}\n\nexport interface ValidationOutcome {\n valid: boolean;\n issues: ValidationIssue[];\n /** Which schema variant was selected — useful for logging/debugging. */\n variant: Direction | 'skipped';\n /**\n * `$id` of the root validator that produced this outcome (e.g.\n * `/schemas/3.0.4/bundled/signals/activate-signal-response.json`). Lets\n * downstream callers suppress redundant `(schema: ...)` prose suffixes\n * on issues that landed on the response root — typical for the bundled\n * tree, where most issues do. Absent when no schema was applied\n * (`variant: 'skipped'`) or the root schema didn't declare an `$id`.\n */\n schemaId?: string;\n /**\n * True when the response's `status` field named an async variant\n * (`submitted` / `working` / `input-required`) but no compiled schema\n * existed for that variant, so validation fell back to the sync\n * response schema. The agent is using an async shape that this tool\n * doesn't explicitly schema — a conformance signal the sync-fallback\n * validation can't render by itself. Absent on normal sync or\n * fully-schema-covered async flows.\n */\n variant_fallback_applied?: boolean;\n /** Variant requested by payload shape before fallback. Set iff `variant_fallback_applied`. */\n requested_variant?: ResponseVariant;\n}\n\nconst OK: ValidationOutcome = Object.freeze({ valid: true, issues: [], variant: 'skipped' });\n\n/**\n * Marker attached by {@link compactUnionErrors} to the residual errors of\n * the variant it picked as the best surviving branch. Carries the\n * discriminator field+value pair(s) that variant requires, so\n * {@link formatIssue} can surface the branch identifier on every issue\n * inherited from that variant. Marker key is namespaced with `__adcp_` to\n * avoid colliding with anything Ajv may add.\n */\ntype AdcpDiscriminatedError = ErrorObject & {\n __adcp_discriminator?: ReadonlyArray<{ field: string; value: unknown }>;\n};\n\n/**\n * Find the longest registered AJV `$id` that prefixes `schemaPath` — that\n * `$id` belongs to the schema (or `$ref`'d sub-schema) responsible for the\n * failure. Returns `undefined` for inline (`#/...`) paths when the root\n * schema doesn't declare an `$id`.\n *\n * AJV 8 prefixes a `$ref`'d schema's errors with the target schema's `$id`\n * (e.g. `/schemas/3.0.4/core/activation-key.json/oneOf/1/required`), so\n * the prefix search resolves cleanly without re-traversing the schema\n * graph. The match must end at a path boundary — `'/'` or `'#'` — so an\n * `$id` ending in `.json` can't false-match a sibling whose `$id` is a\n * proper extension of it.\n */\nfunction extractSchemaId(\n schemaPath: string,\n rootSchema: unknown,\n registeredIds: readonly string[]\n): string | undefined {\n if (schemaPath.startsWith('#') || schemaPath === '') {\n const id = (rootSchema as { $id?: unknown } | null | undefined)?.$id;\n return typeof id === 'string' ? id : undefined;\n }\n // The Ajv registry includes the JSON Schema meta-schema\n // (`http://json-schema.org/draft-07/schema`) alongside AdCP `$id`s. Ajv\n // never emits schemaPaths prefixed with the meta-schema URL — those\n // paths use the relative `#/...` form and take the branch above — so\n // the meta-schema entry never false-matches here.\n let best: string | undefined;\n for (const id of registeredIds) {\n if (!id) continue;\n if (schemaPath === id || schemaPath.startsWith(`${id}/`) || schemaPath.startsWith(`${id}#`)) {\n if (best === undefined || id.length > best.length) best = id;\n }\n }\n return best;\n}\n\ninterface FormatContext {\n rootSchema: unknown;\n registeredIds: readonly string[];\n /**\n * Tool name being validated. Threaded into {@link findHint} so curated\n * hints that gate on tool name can fire. Optional only because\n * `validateRequest` / `validateResponse` always pass it; tests that\n * call `formatIssue` directly are the rare exception.\n */\n toolName?: string;\n}\n\nfunction formatIssue(err: ErrorObject, ctx: FormatContext): ValidationIssue {\n const instancePath = err.instancePath || '';\n const missingProperty =\n err.keyword === 'required' &&\n err.params &&\n typeof (err.params as { missingProperty?: string }).missingProperty === 'string'\n ? `/${(err.params as { missingProperty: string }).missingProperty}`\n : '';\n\n // Enrich enum errors with the allowed values from AJV's params + replace\n // the opaque \"must be equal to one of the allowed values\" message with\n // the actual list. Without this, LLM-generated platforms can't self-\n // correct (Emma matrix v17, 2026-04-30): the validation cascade from\n // a single bad enum value swallows ~30 storyboard steps because no\n // self-correction signal is available without fetching the schema.\n const isEnum =\n err.keyword === 'enum' &&\n err.params != null &&\n Array.isArray((err.params as { allowedValues?: unknown[] }).allowedValues);\n const allowedValues = isEnum ? (err.params as { allowedValues: readonly unknown[] }).allowedValues : undefined;\n const message = isEnum\n ? `must be one of: ${allowedValues!.map(v => JSON.stringify(v)).join(', ')}`\n : (err.message ?? 'validation failed');\n\n const schemaId = extractSchemaId(err.schemaPath, ctx.rootSchema, ctx.registeredIds);\n const discriminator = (err as AdcpDiscriminatedError).__adcp_discriminator;\n const issue: ValidationIssue = {\n pointer: `${instancePath}${missingProperty}` || '/',\n message,\n keyword: err.keyword,\n schemaPath: err.schemaPath,\n ...(schemaId !== undefined && { schemaId }),\n ...(discriminator !== undefined && discriminator.length > 0 && { discriminator }),\n ...(allowedValues !== undefined && { allowedValues }),\n };\n // Attach a curated `hint` last so the matcher can read every other\n // resolved field (schemaId, discriminator, pointer, keyword) when\n // deciding whether to fire. Most issues won't match any rule —\n // findHint returns undefined, and the field stays absent.\n const hint = findHint(issue, ctx.toolName);\n if (hint !== undefined) issue.hint = hint;\n return issue;\n}\n\n// Path segments we refuse to walk into during schema-path resolution. AJV\n// emits trusted `schemaPath` strings today, but the function is exported in\n// shape (anything in this file is reachable via the compiled JS), so any\n// future caller passing user-influenced paths can't traverse into prototype\n// chains. Bundled schemas have no use for these names either.\nconst FORBIDDEN_SCHEMA_PATH_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/**\n * Resolve an AJV `schemaPath` like `\"#/properties/account/oneOf\"` against\n * the compiled validator's root schema. Returns `undefined` if the path\n * doesn't land on an object. Handles URI-encoded path segments (AJV\n * escapes `~` as `~0` and `/` as `~1` per RFC 6901).\n *\n * Refuses prototype-chain segments and uses own-property indexing so a\n * future caller (or a pathological future schema) can't induce a walk\n * into `Object.prototype`.\n */\nfunction resolveSchemaPath(rootSchema: unknown, schemaPath: string): unknown {\n if (rootSchema == null) return undefined;\n const clean = schemaPath.replace(/^#\\/?/, '');\n if (clean.length === 0) return rootSchema;\n let cursor: unknown = rootSchema;\n for (const raw of clean.split('/')) {\n if (cursor == null || (typeof cursor !== 'object' && !Array.isArray(cursor))) return undefined;\n const decoded = raw.replace(/~1/g, '/').replace(/~0/g, '~');\n if (FORBIDDEN_SCHEMA_PATH_SEGMENTS.has(decoded)) return undefined;\n if (!Object.prototype.hasOwnProperty.call(cursor, decoded)) return undefined;\n cursor = (cursor as Record<string, unknown>)[decoded];\n }\n return cursor;\n}\n\n/**\n * Compact AJV's `oneOf` / `anyOf` cascades before they reach the wire.\n *\n * AJV with `allErrors: true` emits one error per non-matching variant\n * plus a synthetic \"must match exactly one schema\" root. For a 9-way\n * `pricing_options` union with a single bad `pricing_model` value that\n * is 14+ errors per failed item, drowning real residual errors elsewhere\n * in the same payload (adcontextprotocol/adcp-client#1111).\n *\n * Strategy:\n * 1. For each union root, group variant errors by variant index.\n * 2. Inspect each variant's schema for `const`-constrained properties.\n * A property where ≥2 variants assert `const` at the same path is a\n * candidate discriminator (covers single-field discriminators like\n * `pricing_model` and composite ones like `audience-selector`'s\n * `(type, value_type)`).\n * 3. Collapse a candidate path iff EVERY variant that asserts `const`\n * there emitted a `const` error. (If some variants silently passed,\n * the user's value matched some allowed const — collapsing would\n * hide that and tell them their valid value was wrong.)\n * 4. Each collapse becomes a synthetic `enum`-keyword issue carrying\n * the union of allowed const values; the existing `formatIssue`\n * enrichment then renders \"must be one of: A, B, ...\".\n * 5. After collapse, if any variant has zero residual errors, the\n * discriminator collapse fully explains the failure — drop the\n * synthetic union root and the residuals from the other variants.\n * 6. Otherwise pick the variant with the fewest residual errors,\n * tie-breaking by fewest residual `const` errors so a variant the\n * user's discriminator value satisfied wins over a sibling whose\n * discriminator they violated. Drop the rest.\n */\nfunction compactUnionErrors(errors: readonly ErrorObject[], rootSchema: unknown): ErrorObject[] {\n if (errors.length === 0) return [...errors];\n\n // Pre-bucket once so each error is scanned a constant number of times even\n // when a malicious or pathological payload pushes Ajv to emit thousands of\n // errors across many union failures. The naive `for root in unionRoots: for\n // e in errors` form is O(U·N) — at K=100 product items each producing a\n // 14-error pricing-options cascade that's ~140k iterations on the\n // request-validation hot path.\n const errorsByOneOfPath = new Map<string, ErrorObject[]>();\n for (const e of errors) {\n const m = e.schemaPath.match(/^(.*\\/(?:oneOf|anyOf))\\/\\d+(?:\\/|$)/);\n if (!m) continue;\n const root = m[1]!;\n const bucket = errorsByOneOfPath.get(root);\n if (bucket) bucket.push(e);\n else errorsByOneOfPath.set(root, [e]);\n }\n\n const dropped = new Set<ErrorObject>();\n const added: ErrorObject[] = [];\n\n // Deepest-first ordering matters for nested unions: by the time the outer\n // root is evaluated, the inner cascade has already been replaced by a\n // synthetic enum at a `<...>/discriminator/<field>` schemaPath that won't\n // match the outer's `oneOfPath + '/'` prefix and stays independent.\n const unionRoots = errors\n .filter(e => e.keyword === 'oneOf' || e.keyword === 'anyOf')\n .slice()\n .sort((a, b) => b.schemaPath.length - a.schemaPath.length);\n\n for (const root of unionRoots) {\n if (dropped.has(root)) continue;\n const oneOfPath = root.schemaPath;\n const rootInstance = root.instancePath;\n\n // Variant errors: pulled from the prebuilt index (constant per-error work\n // above), then grouped by variant index. instancePath scoping keeps two\n // separate union failures sharing the same `schemaPath` but different\n // instancePaths — e.g., `products[0].pricing_options[0]` and\n // `products[1]...` — independent.\n const candidateErrors = errorsByOneOfPath.get(oneOfPath) ?? [];\n const byVariant = new Map<number, ErrorObject[]>();\n for (const e of candidateErrors) {\n if (e === root || dropped.has(e)) continue;\n const tail = e.schemaPath.slice(oneOfPath.length + 1);\n const m = tail.match(/^(\\d+)(?:\\/|$)/);\n if (!m) continue;\n if (e.instancePath !== rootInstance && !e.instancePath.startsWith(rootInstance + '/')) continue;\n const idx = parseInt(m[1]!, 10);\n const bucket = byVariant.get(idx);\n if (bucket) bucket.push(e);\n else byVariant.set(idx, [e]);\n }\n if (byVariant.size === 0) continue;\n\n // Resolve the variant schema array. Without it we fall back to a pure\n // error-shape collapse (still correct, just less precise on which\n // variants asserted const where the user happened to match).\n const variantSchemas = resolveSchemaPath(rootSchema, oneOfPath);\n const variantArr: readonly unknown[] = Array.isArray(variantSchemas) ? variantSchemas : [];\n\n // For each top-level property in each variant, record which variants\n // declare a `const` value there. Top-level only — composite\n // discriminators in AdCP (`audience-selector`, pricing-option) all\n // sit at the variant root.\n const constAsserters = new Map<string, Map<number, unknown>>();\n for (let i = 0; i < variantArr.length; i++) {\n const variant = variantArr[i];\n if (!variant || typeof variant !== 'object') continue;\n const props = (variant as { properties?: unknown }).properties;\n if (!props || typeof props !== 'object') continue;\n for (const [key, prop] of Object.entries(props as Record<string, unknown>)) {\n if (prop && typeof prop === 'object' && 'const' in prop) {\n const path = `/${key.replace(/~/g, '~0').replace(/\\//g, '~1')}`;\n let m = constAsserters.get(path);\n if (!m) constAsserters.set(path, (m = new Map()));\n m.set(i, (prop as { const: unknown }).const);\n }\n }\n }\n\n // For each candidate path with ≥2 asserters, did every asserter emit?\n const collapsedPaths = new Set<string>();\n for (const [relPath, asserters] of constAsserters) {\n if (asserters.size < 2) continue;\n const absolutePath = rootInstance + relPath;\n const emittersByVariant = new Map<number, ErrorObject>();\n for (const [idx, errs] of byVariant) {\n for (const e of errs) {\n if (e.keyword === 'const' && e.instancePath === absolutePath) {\n emittersByVariant.set(idx, e);\n break;\n }\n }\n }\n let allEmitted = true;\n for (const idx of asserters.keys()) {\n if (!emittersByVariant.has(idx)) {\n allEmitted = false;\n break;\n }\n }\n if (!allEmitted) continue;\n\n const allowedValues: unknown[] = [];\n for (const v of asserters.values()) {\n const already = allowedValues.some(existing => existing === v);\n if (!already) allowedValues.push(v);\n }\n const sample = emittersByVariant.values().next().value as ErrorObject;\n // Synthetic enum issue. `schemaPath: ''` keeps it out of any caller\n // that walks the path back to a real schema location (the synthesized\n // `<oneOfPath>/discriminator/<field>` would dangle if dereferenced)\n // while still satisfying the wire shape — the response-side errors\n // helper already gates `schemaPath` exposure via `exposeSchemaPath`.\n // `JSON.stringify` on the const values is safe: they come from the\n // bundled (trusted) schema and the outer wire envelope re-encodes\n // anyway, so control characters or quotes can't break framing.\n added.push({\n ...sample,\n keyword: 'enum',\n schemaPath: '',\n message: `must be one of: ${allowedValues.map(v => JSON.stringify(v)).join(', ')}`,\n params: { allowedValues },\n } as ErrorObject);\n for (const e of emittersByVariant.values()) dropped.add(e);\n collapsedPaths.add(absolutePath);\n }\n\n // Compute residuals after the collapse.\n const residualByVariant = new Map<number, ErrorObject[]>();\n for (const [idx, errs] of byVariant) {\n residualByVariant.set(\n idx,\n errs.filter(e => !dropped.has(e))\n );\n }\n\n if (collapsedPaths.size > 0) {\n const anyZeroResidual = [...residualByVariant.values()].some(r => r.length === 0);\n if (anyZeroResidual) {\n for (const errs of residualByVariant.values()) for (const e of errs) dropped.add(e);\n dropped.add(root);\n continue;\n }\n }\n\n // Variants with a `not` keyword failure are excluded from candidacy:\n // the payload populates fields the variant forbids by design (e.g. an\n // Error variant whose `not` clause rejects payloads that carry the\n // Success variant's `account` / `currency` / `period` fields). The\n // adopter's actionable lever is the OTHER variant's residuals (missing\n // required fields they need to add) — surfacing the `not` failure\n // points at a path the adopter shouldn't take. See adcp-client#1337.\n //\n // **Spec assumption.** AdCP 3.x uses `not` only as an envelope-level\n // mutual-exclusion guard between Success ↔ Error arms of a response\n // oneOf — never as an intra-arm discriminator (those use `const` on a\n // tag field, e.g. async `status: 'submitted' | 'working' | ...`).\n // The exclusion logic here targets that dominant pattern. If a future\n // spec ever inverts the convention (a Success arm using `not` to\n // discriminate sub-variants), this heuristic would suppress an\n // actionable diagnostic — re-evaluate the assumption when adopting\n // any AdCP version that does so.\n //\n // If every variant has a `not` failure, fall back to the unconstrained\n // pick — preserves diagnostic on contrived schemas where mutual-\n // exclusion is the only signal.\n const variantsWithNotFailure = new Set<number>();\n for (const [idx, errs] of byVariant) {\n for (const e of errs) {\n if (e.keyword === 'not') {\n variantsWithNotFailure.add(idx);\n break;\n }\n }\n }\n const allVariantsHaveNot = variantsWithNotFailure.size === byVariant.size && byVariant.size > 0;\n\n // Pick the best surviving variant; prefer fewest residuals, tie-break\n // by fewest residual `const` errors (so variants whose discriminator\n // the user actually picked win over siblings whose discriminator they\n // violated). Excluded variants (mutual-exclusion `not` rejections) are\n // skipped unless all variants are excluded.\n let bestIdx = -1;\n let bestCount = Infinity;\n let bestConsts = Infinity;\n for (const [idx, residual] of residualByVariant) {\n if (!allVariantsHaveNot && variantsWithNotFailure.has(idx)) continue;\n const constCount = residual.reduce((n, e) => (e.keyword === 'const' ? n + 1 : n), 0);\n if (residual.length < bestCount || (residual.length === bestCount && constCount < bestConsts)) {\n bestIdx = idx;\n bestCount = residual.length;\n bestConsts = constCount;\n }\n }\n for (const [idx, residual] of residualByVariant) {\n if (idx !== bestIdx) for (const e of residual) dropped.add(e);\n }\n\n // Tag the surviving variant's residuals with the discriminator\n // field+value pair(s) it requires. Adopters reading the projected\n // issue see \"branch: type='key_value'\" alongside the missing-required\n // error, so they know which branch the seller's payload was inferred\n // to be targeting (issue #1283). Compound discriminators (e.g.,\n // `audience-selector`'s (type, value_type)) become multi-entry\n // arrays — order follows iteration of `constAsserters`, which mirrors\n // the variant's `properties` declaration order.\n if (bestIdx >= 0) {\n const pairs: Array<{ field: string; value: unknown }> = [];\n for (const [relPath, asserters] of constAsserters) {\n const constValue = asserters.get(bestIdx);\n if (constValue === undefined) continue;\n const field = relPath.startsWith('/') ? relPath.slice(1) : relPath;\n pairs.push({ field, value: constValue });\n }\n if (pairs.length > 0) {\n const surviving = residualByVariant.get(bestIdx) ?? [];\n for (const e of surviving) {\n // Deepest-first ordering means inner unions tag first; if a\n // residual is already tagged it carries the more specific\n // (deeper) discriminator, which is what the adopter needs to\n // fix. Don't clobber it with the outer union's tag — the outer\n // discriminator is context, not the actionable lever.\n // Bucketing-by-deepest-prefix in `errorsByOneOfPath` already\n // protects most leaf errors from entering this loop, but the\n // explicit guard makes the invariant resilient to future\n // changes in that bucket scheme.\n if ((e as AdcpDiscriminatedError).__adcp_discriminator !== undefined) continue;\n (e as AdcpDiscriminatedError).__adcp_discriminator = pairs;\n }\n }\n }\n }\n\n return [...errors.filter(e => !dropped.has(e)), ...added];\n}\n\n/**\n * When an AJV error has `keyword: 'oneOf' | 'anyOf'`, resolve the\n * schema's variant array and summarize each variant so a client can\n * pick one without fetching the full schema. See {@link ValidationIssueVariant}.\n * Returns the issue unchanged when the keyword doesn't match or the\n * resolution fails (e.g. the variant list is inlined in an unexpected\n * way).\n */\nfunction enrichWithVariants(issue: ValidationIssue, rootSchema: unknown): ValidationIssue {\n if (issue.keyword !== 'oneOf' && issue.keyword !== 'anyOf') return issue;\n const resolved = resolveSchemaPath(rootSchema, issue.schemaPath);\n if (!Array.isArray(resolved)) return issue;\n const variants: ValidationIssueVariant[] = resolved.map((variant: unknown, index: number) => {\n if (variant == null || typeof variant !== 'object') {\n return { index, required: [], properties: [] };\n }\n const v = variant as Record<string, unknown>;\n const required = Array.isArray(v.required) ? (v.required.filter(r => typeof r === 'string') as string[]) : [];\n const properties =\n v.properties != null && typeof v.properties === 'object' ? Object.keys(v.properties as object) : [];\n return { index, required, properties };\n });\n return { ...issue, variants };\n}\n\n/**\n * Validate an outgoing request against `{tool}-request.json`.\n *\n * `version` selects which AdCP version's schema bundle to validate against;\n * defaults to the SDK-pinned `ADCP_VERSION`. Pass the per-instance value\n * from `getAdcpVersion()` to validate against a pinned-version client/server's\n * schema.\n */\nexport function validateRequest(toolName: string, payload: unknown, version?: string): ValidationOutcome {\n const validator = getValidator(toolName, 'request', version);\n if (!validator) return OK;\n const valid = validator(payload) as boolean;\n const rootSchema = (validator as { schema?: unknown }).schema;\n const rootSchemaId =\n rootSchema && typeof rootSchema === 'object' && typeof (rootSchema as { $id?: unknown }).$id === 'string'\n ? ((rootSchema as { $id: string }).$id as string)\n : undefined;\n if (valid) return { valid: true, issues: [], variant: 'request', ...(rootSchemaId && { schemaId: rootSchemaId }) };\n const registeredIds = getRegisteredSchemaIds(version);\n const ctx: FormatContext = { rootSchema, registeredIds, toolName };\n const compacted = compactUnionErrors(validator.errors ?? [], rootSchema);\n return {\n valid: false,\n issues: compacted.map(e => formatIssue(e, ctx)).map(i => enrichWithVariants(i, rootSchema)),\n variant: 'request',\n ...(rootSchemaId && { schemaId: rootSchemaId }),\n };\n}\n\n/**\n * Strip top-level optional fields whose value is `null` but whose declared\n * schema type is not nullable (`type` does not include `'null'`).\n *\n * Applies only when validating against a v2.x schema bundle. v2.5 sellers\n * (Pydantic-origin) commonly emit `errors: null`, `context: null`, `ext: null`\n * to signal \"nothing here\" rather than omitting the key. The v2.5 schemas\n * don't include `null` in those types, so Ajv spuriously rejects them.\n *\n * Gated to v2.x only — in v3, `errors` is a required field on failure\n * branches, and silently stripping it across all versions would mask real\n * bugs in v3 seller responses.\n *\n * Returns a shallow clone with the offending keys removed, or the original\n * object unchanged if nothing was stripped. Safe to pass to an Ajv validator:\n * Ajv 8 (without `removeAdditional`/`useDefaults`/`coerceTypes`) does not\n * mutate its input.\n */\nfunction stripEnvelopeNulls(payload: unknown, schema: unknown): unknown {\n if (payload == null || typeof payload !== 'object' || Array.isArray(payload)) return payload;\n const s = schema as Record<string, unknown> | null;\n if (!s) return payload;\n const properties = s.properties as Record<string, unknown> | undefined;\n if (!properties) return payload;\n const required = new Set<string>(Array.isArray(s.required) ? (s.required as string[]) : []);\n const payloadObj = payload as Record<string, unknown>;\n let cloned: Record<string, unknown> | null = null;\n for (const [key, value] of Object.entries(payloadObj)) {\n if (value !== null) continue;\n if (required.has(key)) continue;\n const propSchema = properties[key] as Record<string, unknown> | undefined;\n if (!propSchema) continue;\n const type = propSchema.type;\n const isNullable = type === 'null' || (Array.isArray(type) && (type as string[]).includes('null'));\n if (!isNullable) {\n if (!cloned) cloned = { ...payloadObj };\n delete cloned[key];\n }\n }\n return cloned ?? payload;\n}\n\n/**\n * Select the response variant by payload shape (per issue #688: choose by\n * `status` field, not just the tool name). Matches the AdCP 3.0 async\n * contract: `submitted`, `working`, `input-required`, and the sync\n * terminal states (`completed` / no status).\n */\nfunction selectResponseVariant(payload: unknown): ResponseVariant {\n if (payload && typeof payload === 'object' && 'status' in (payload as Record<string, unknown>)) {\n const status = (payload as Record<string, unknown>).status;\n if (status === 'submitted') return 'submitted';\n if (status === 'working') return 'working';\n if (status === 'input-required') return 'input-required';\n }\n return 'sync';\n}\n\n/**\n * Validate an incoming response; picks the async variant by payload shape.\n *\n * `version` selects which AdCP version's schema bundle to validate against;\n * defaults to the SDK-pinned `ADCP_VERSION`. See {@link validateRequest} for\n * the per-instance use case.\n */\nexport function validateResponse(toolName: string, payload: unknown, version?: string): ValidationOutcome {\n // 3.0.x back-compat: synthesize envelope `status` when the payload\n // declares itself as 3.0.x (or carries no version field at all). 3.1+\n // payloads remain unchanged so the strict validator still rejects a\n // 3.1 peer that omits `status`. Applied before variant selection so a\n // synthesized `completed` doesn't get misrouted to the async-variant\n // schema. See `utils/envelope-status-compat.ts`.\n const compatPayload =\n payload && typeof payload === 'object' && !Array.isArray(payload)\n ? injectLegacyEnvelopeStatus(payload as Record<string, unknown>, { toolName })\n : payload;\n const variant = selectResponseVariant(compatPayload);\n const validator = getValidator(toolName, variant, version);\n // If an async variant schema is missing, fall back to the sync one —\n // some tools declare `-response.json` only and use `status` as an\n // in-band marker without a dedicated variant schema.\n const effective = validator ?? (variant !== 'sync' ? getValidator(toolName, 'sync', version) : undefined);\n if (!effective) return OK;\n const rootSchema = (effective as { schema?: unknown }).schema;\n // v2.x sellers (Pydantic-origin) emit optional envelope fields as null instead\n // of omitting them. Strip before Ajv to avoid spurious type errors on `errors`,\n // `context`, and `ext`. Gated to v2.x only — see stripEnvelopeNulls JSDoc.\n const isV2Bundle = version != null && parseAdcpMajorVersion(version) === 2;\n const normalizedPayload = isV2Bundle ? stripEnvelopeNulls(compatPayload, rootSchema) : compatPayload;\n const valid = effective(normalizedPayload) as boolean;\n const usedVariant: Direction = validator ? variant : 'sync';\n const variantFallback = !validator && variant !== 'sync';\n const fallbackFields: Pick<ValidationOutcome, 'variant_fallback_applied' | 'requested_variant'> = variantFallback\n ? { variant_fallback_applied: true, requested_variant: variant }\n : {};\n const rootSchemaId =\n rootSchema && typeof rootSchema === 'object' && typeof (rootSchema as { $id?: unknown }).$id === 'string'\n ? ((rootSchema as { $id: string }).$id as string)\n : undefined;\n if (valid) {\n return {\n valid: true,\n issues: [],\n variant: usedVariant,\n ...(rootSchemaId && { schemaId: rootSchemaId }),\n ...fallbackFields,\n };\n }\n const registeredIds = getRegisteredSchemaIds(version);\n const ctx: FormatContext = { rootSchema, registeredIds, toolName };\n const compacted = compactUnionErrors(effective.errors ?? [], rootSchema);\n return {\n valid: false,\n issues: compacted.map(e => formatIssue(e, ctx)).map(i => enrichWithVariants(i, rootSchema)),\n variant: usedVariant,\n ...(rootSchemaId && { schemaId: rootSchemaId }),\n ...fallbackFields,\n };\n}\n\n/**\n * Render `discriminator[]` as `field='value', other='x'`. Strings are\n * single-quoted (matches the issue #1283 example shape) with embedded\n * apostrophes backslash-escaped so a future spec const containing `'`\n * can't produce ambiguous output. Other JSON-safe values use\n * `JSON.stringify` so booleans and numbers stay unambiguous. Returns an\n * empty string when the array is empty so callers can compose\n * conditionally.\n */\nexport function formatDiscriminator(\n discriminator: ReadonlyArray<{ field: string; value: unknown }> | undefined\n): string {\n if (!discriminator || discriminator.length === 0) return '';\n return discriminator\n .map(({ field, value }) => {\n if (typeof value !== 'string') return `${field}=${JSON.stringify(value)}`;\n const escaped = value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n return `${field}='${escaped}'`;\n })\n .join(', ');\n}\n\n/**\n * One-line render of a validation issue with `(schema: <$id>)`,\n * `(discriminator: <field>='<value>')`, and `(hint: …)` suffixes when\n * the issue carries them. Used by both {@link formatIssues} and the\n * prose `message` field on `VALIDATION_ERROR` envelopes (issue #1283\n * for schema/discriminator, #1309 for hint), so adopters debugging from\n * the wire envelope alone see the rejecting schema, union discriminator,\n * and curated mistake-recipe without having to walk `issues[]`.\n *\n * The `(schema: ...)` suffix is suppressed for inline failures whose\n * `schemaId` is the response root — the tool name already conveys that,\n * and AdCP's bundled tree strips inner `$id`s so most issues land on the\n * root. Suppressing keeps the prose tight on the cases where the schema\n * field would just restate the tool the adopter already knows. Adopters\n * who want the field unconditionally read it from the structured\n * `issues[].schemaId`.\n */\nexport function formatIssueLine(issue: ValidationIssue, options: { rootSchemaId?: string } = {}): string {\n const parts: string[] = [`${issue.pointer} ${issue.message}`];\n if (issue.schemaId && issue.schemaId !== options.rootSchemaId) {\n parts.push(`(schema: ${issue.schemaId})`);\n }\n const discriminator = formatDiscriminator(issue.discriminator);\n if (discriminator) parts.push(`(discriminator: ${discriminator})`);\n if (issue.hint) parts.push(`(hint: ${issue.hint})`);\n return parts.join(' ');\n}\n\n/**\n * Render a compact one-line summary of the failures — useful for logs.\n *\n * `rootSchemaId`, when supplied, suppresses the `(schema: ...)` suffix on\n * issues whose `schemaId` matches it (typical for issues that landed on\n * the response root). Pass `undefined` to always emit the suffix.\n */\nexport function formatIssues(issues: ValidationIssue[], limit = 3, options: { rootSchemaId?: string } = {}): string {\n const head = issues\n .slice(0, limit)\n .map(i => formatIssueLine(i, options))\n .join('; ');\n const rest = issues.length - limit;\n return rest > 0 ? `${head} (+${rest} more)` : head;\n}\n"],"mappings":"AAQA,SAAS,cAAc,8BAAoE;AAC3F,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AACzB,SAAS,kCAAkC;AAoJ3C,MAAM,KAAwB,OAAO,OAAO,EAAE,OAAO,MAAM,QAAQ,CAAC,GAAG,SAAS,UAAU,CAAC;AA2B3F,SAAS,gBACP,YACA,YACA,eACoB;AACpB,MAAI,WAAW,WAAW,GAAG,KAAK,eAAe,IAAI;AACnD,UAAM,KAAM,YAAqD;AACjE,WAAO,OAAO,OAAO,WAAW,KAAK;AAAA,EACvC;AAMA,MAAI;AACJ,aAAW,MAAM,eAAe;AAC9B,QAAI,CAAC,GAAI;AACT,QAAI,eAAe,MAAM,WAAW,WAAW,GAAG,EAAE,GAAG,KAAK,WAAW,WAAW,GAAG,EAAE,GAAG,GAAG;AAC3F,UAAI,SAAS,UAAa,GAAG,SAAS,KAAK,OAAQ,QAAO;AAAA,IAC5D;AAAA,EACF;AACA,SAAO;AACT;AAcA,SAAS,YAAY,KAAkB,KAAqC;AAC1E,QAAM,eAAe,IAAI,gBAAgB;AACzC,QAAM,kBACJ,IAAI,YAAY,cAChB,IAAI,UACJ,OAAQ,IAAI,OAAwC,oBAAoB,WACpE,IAAK,IAAI,OAAuC,eAAe,KAC/D;AAQN,QAAM,SACJ,IAAI,YAAY,UAChB,IAAI,UAAU,QACd,MAAM,QAAS,IAAI,OAAyC,aAAa;AAC3E,QAAM,gBAAgB,SAAU,IAAI,OAAiD,gBAAgB;AACrG,QAAM,UAAU,SACZ,mBAAmB,cAAe,IAAI,OAAK,KAAK,UAAU,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,KACvE,IAAI,WAAW;AAEpB,QAAM,WAAW,gBAAgB,IAAI,YAAY,IAAI,YAAY,IAAI,aAAa;AAClF,QAAM,gBAAiB,IAA+B;AACtD,Q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,QAAM,QAAkB,CAAC,GAAG,MAAM,OAAO,IAAI,MAAM,OAAO,EAAE;AAC5D,MAAI,MAAM,YAAY,MAAM,aAAa,QAAQ,cAAc;AAC7D,UAAM,KAAK,YAAY,MAAM,QAAQ,GAAG;AAAA,EAC1C;AACA,QAAM,gBAAgB,oBAAoB,MAAM,aAAa;AAC7D,MAAI,cAAe,OAAM,KAAK,mBAAmB,aAAa,GAAG;AACjE,MAAI,MAAM,KAAM,OAAM,KAAK,UAAU,MAAM,IAAI,GAAG;AAClD,SAAO,MAAM,KAAK,GAAG;AACvB;AASO,SAAS,aAAa,QAA2B,QAAQ,GAAG,UAAqC,CAAC,GAAW;AAClH,QAAM,OAAO,OACV,MAAM,GAAG,KAAK,EACd,IAAI,OAAK,gBAAgB,GAAG,OAAO,CAAC,EACpC,KAAK,IAAI;AACZ,QAAM,OAAO,OAAO,SAAS;AAC7B,SAAO,OAAO,IAAI,GAAG,IAAI,MAAM,IAAI,WAAW;AAChD;","names":[]}
@@ -1,9 +1,3 @@
1
- import { fileURLToPath as __adcpFileURLToPath } from 'node:url';
2
- import { dirname as __adcpDirname } from 'node:path';
3
- import { createRequire as __adcpCreateRequire } from 'node:module';
4
- const __filename = __adcpFileURLToPath(import.meta.url);
5
- const __dirname = __adcpDirname(__filename);
6
- const require = __adcpCreateRequire(import.meta.url);
7
1
  import { z } from "zod";
8
2
  import {
9
3
  AccountSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/validation/sync-creatives.ts"],"sourcesContent":["import { z } from 'zod';\nimport {\n AccountSchema,\n CreativeStatusSchema,\n ErrorSchema,\n ContextObjectSchema,\n ExtensionObjectSchema,\n SyncCreativesErrorSchema,\n SyncCreativesSubmittedSchema,\n} from '../types/schemas.generated';\n\nexport const SyncCreativesActionSchema = z.union([\n z.literal('created'),\n z.literal('updated'),\n z.literal('unchanged'),\n z.literal('failed'),\n z.literal('deleted'),\n]);\n\nconst ASSIGNMENT_ERROR_KEY = /^[a-zA-Z0-9_-]+$/;\n\nconst HttpUrlSchema = z\n .string()\n .url()\n .refine(v => /^https?:\\/\\//i.test(v), {\n message: 'URL must use http(s) scheme',\n });\n\nexport const SyncCreativesItemSchema = z\n .object({\n creative_id: z.string(),\n action: SyncCreativesActionSchema,\n account: AccountSchema.optional(),\n status: CreativeStatusSchema.optional(),\n platform_id: z.string().optional(),\n changes: z.array(z.string()).optional(),\n errors: z.array(ErrorSchema).optional(),\n warnings: z.array(z.string()).optional(),\n preview_url: HttpUrlSchema.optional(),\n expires_at: z.string().datetime({ offset: true }).optional(),\n assigned_to: z.array(z.string()).optional(),\n assignment_errors: z\n .record(z.string().regex(ASSIGNMENT_ERROR_KEY, 'assignment_errors key must match ^[a-zA-Z0-9_-]+$'), z.string())\n .optional(),\n })\n .passthrough()\n .superRefine((item, ctx) => {\n // Spec: when action ∈ {failed, deleted}, `status` MUST be absent.\n if ((item.action === 'failed' || item.action === 'deleted') && item.status !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['status'],\n message: `status must be omitted when action is '${item.action}'`,\n });\n }\n });\n\nexport type SyncCreativesItem = z.infer<typeof SyncCreativesItemSchema>;\n\nexport const SyncCreativesSuccessStrictSchema = z\n .object({\n dry_run: z.boolean().optional(),\n creatives: z.array(SyncCreativesItemSchema),\n sandbox: z.boolean().optional(),\n context: ContextObjectSchema.optional(),\n ext: ExtensionObjectSchema.optional(),\n })\n .passthrough();\n\nexport type SyncCreativesSuccessStrict = z.infer<typeof SyncCreativesSuccessStrictSchema>;\n\n/**\n * Strict response schema for sync_creatives.\n *\n * The generated `SyncCreativesResponseSchema` degrades `creatives[]` to\n * `z.array(z.record(z.string(), z.unknown()))` because the upstream JSON\n * Schema inlines the item shape without a named $ref. This schema supplies\n * the per-item shape (creative_id + action required, plus the spec's\n * conditional that forbids `status` on failed/deleted items) so strict\n * response validation catches per-item drift at the SDK boundary.\n */\nexport const SyncCreativesResponseStrictSchema = z.union([\n SyncCreativesSuccessStrictS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W,YAAY,KAAK,WAAW,cAAc,KAAK,WAAW,QAAW;AACxF,QAAI,SAAS;AAAA,MACX,MAAM,EAAE,aAAa;AAAA,MACrB,MAAM,CAAC,QAAQ;AAAA,MACf,SAAS,0CAA0C,KAAK,MAAM;AAAA,IAChE,CAAC;AAAA,EACH;AACF,CAAC;AAII,MAAM,mCAAmC,EAC7C,OAAO;AAAA,EACN,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,WAAW,EAAE,MAAM,uBAAuB;AAAA,EAC1C,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,SAAS,oBAAoB,SAAS;AAAA,EACtC,KAAK,sBAAsB,SAAS;AACtC,CAAC,EACA,YAAY;AAcR,MAAM,oCAAoC,EAAE,MAAM;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../src/lib/validation/sync-creatives.ts"],"sourcesContent":["import { z } from 'zod';\nimport {\n AccountSchema,\n CreativeStatusSchema,\n ErrorSchema,\n ContextObjectSchema,\n ExtensionObjectSchema,\n SyncCreativesErrorSchema,\n SyncCreativesSubmittedSchema,\n} from '../types/schemas.generated';\n\nexport const SyncCreativesActionSchema = z.union([\n z.literal('created'),\n z.literal('updated'),\n z.literal('unchanged'),\n z.literal('failed'),\n z.literal('deleted'),\n]);\n\nconst ASSIGNMENT_ERROR_KEY = /^[a-zA-Z0-9_-]+$/;\n\nconst HttpUrlSchema = z\n .string()\n .url()\n .refine(v => /^https?:\\/\\//i.test(v), {\n message: 'URL must use http(s) scheme',\n });\n\nexport const SyncCreativesItemSchema = z\n .object({\n creative_id: z.string(),\n action: SyncCreativesActionSchema,\n account: AccountSchema.optional(),\n status: CreativeStatusSchema.optional(),\n platform_id: z.string().optional(),\n changes: z.array(z.string()).optional(),\n errors: z.array(ErrorSchema).optional(),\n warnings: z.array(z.string()).optional(),\n preview_url: HttpUrlSchema.optional(),\n expires_at: z.string().datetime({ offset: true }).optional(),\n assigned_to: z.array(z.string()).optional(),\n assignment_errors: z\n .record(z.string().regex(ASSIGNMENT_ERROR_KEY, 'assignment_errors key must match ^[a-zA-Z0-9_-]+$'), z.string())\n .optional(),\n })\n .passthrough()\n .superRefine((item, ctx) => {\n // Spec: when action ∈ {failed, deleted}, `status` MUST be absent.\n if ((item.action === 'failed' || item.action === 'deleted') && item.status !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['status'],\n message: `status must be omitted when action is '${item.action}'`,\n });\n }\n });\n\nexport type SyncCreativesItem = z.infer<typeof SyncCreativesItemSchema>;\n\nexport const SyncCreativesSuccessStrictSchema = z\n .object({\n dry_run: z.boolean().optional(),\n creatives: z.array(SyncCreativesItemSchema),\n sandbox: z.boolean().optional(),\n context: ContextObjectSchema.optional(),\n ext: ExtensionObjectSchema.optional(),\n })\n .passthrough();\n\nexport type SyncCreativesSuccessStrict = z.infer<typeof SyncCreativesSuccessStrictSchema>;\n\n/**\n * Strict response schema for sync_creatives.\n *\n * The generated `SyncCreativesResponseSchema` degrades `creatives[]` to\n * `z.array(z.record(z.string(), z.unknown()))` because the upstream JSON\n * Schema inlines the item shape without a named $ref. This schema supplies\n * the per-item shape (creative_id + action required, plus the spec's\n * conditional that forbids `status` on failed/deleted items) so strict\n * response validation catches per-item drift at the SDK boundary.\n */\nexport const SyncCreativesResponseStrictSchema = z.union([\n SyncCreativesSuccessStrictSchema,\n SyncCreativesErrorSchema,\n SyncCreativesSubmittedSchema,\n]);\n"],"mappings":"AAAA,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,4BAA4B,EAAE,MAAM;AAAA,EAC/C,EAAE,QAAQ,SAAS;AAAA,EACnB,EAAE,QAAQ,SAAS;AAAA,EACnB,EAAE,QAAQ,WAAW;AAAA,EACrB,EAAE,QAAQ,QAAQ;AAAA,EAClB,EAAE,QAAQ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