@adcp/sdk 12.1.0 → 13.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (464) hide show
  1. package/README.md +19 -3
  2. package/bin/adcp-fuzz.js +3 -1
  3. package/dist/lib/adapters/content-standards-adapter.d.mts +9 -9
  4. package/dist/lib/adapters/content-standards-adapter.d.ts +9 -9
  5. package/dist/lib/adapters/content-standards-adapter.d.ts.map +1 -1
  6. package/dist/lib/adapters/content-standards-adapter.js +22 -22
  7. package/dist/lib/adapters/content-standards-adapter.js.map +1 -1
  8. package/dist/lib/adapters/content-standards-adapter.mjs +18 -18
  9. package/dist/lib/adapters/content-standards-adapter.mjs.map +1 -1
  10. package/dist/lib/adapters/index.d.mts +2 -2
  11. package/dist/lib/adapters/index.d.ts +2 -2
  12. package/dist/lib/adapters/index.d.ts.map +1 -1
  13. package/dist/lib/adapters/index.js +10 -10
  14. package/dist/lib/adapters/index.js.map +1 -1
  15. package/dist/lib/adapters/index.mjs +9 -9
  16. package/dist/lib/adapters/index.mjs.map +1 -1
  17. package/dist/lib/auth/oauth/authorization-required.d.mts +3 -0
  18. package/dist/lib/auth/oauth/authorization-required.d.ts +3 -0
  19. package/dist/lib/auth/oauth/authorization-required.d.ts.map +1 -1
  20. package/dist/lib/auth/oauth/authorization-required.js +12 -9
  21. package/dist/lib/auth/oauth/authorization-required.js.map +1 -1
  22. package/dist/lib/auth/oauth/authorization-required.mjs +12 -9
  23. package/dist/lib/auth/oauth/authorization-required.mjs.map +1 -1
  24. package/dist/lib/auth/oauth/provider-cache.d.mts +7 -0
  25. package/dist/lib/auth/oauth/provider-cache.d.ts +8 -0
  26. package/dist/lib/auth/oauth/provider-cache.d.ts.map +1 -0
  27. package/dist/lib/auth/oauth/provider-cache.js +44 -0
  28. package/dist/lib/auth/oauth/provider-cache.js.map +1 -0
  29. package/dist/lib/auth/oauth/provider-cache.mjs +19 -0
  30. package/dist/lib/auth/oauth/provider-cache.mjs.map +1 -0
  31. package/dist/lib/conformance/invariants/uniformError.js +1 -1
  32. package/dist/lib/conformance/invariants/uniformError.js.map +1 -1
  33. package/dist/lib/conformance/invariants/uniformError.mjs +1 -1
  34. package/dist/lib/conformance/invariants/uniformError.mjs.map +1 -1
  35. package/dist/lib/conformance/runners.js +1 -1
  36. package/dist/lib/conformance/runners.js.map +1 -1
  37. package/dist/lib/conformance/runners.mjs +1 -1
  38. package/dist/lib/conformance/runners.mjs.map +1 -1
  39. package/dist/lib/conformance/seeder.js +5 -5
  40. package/dist/lib/conformance/seeder.js.map +1 -1
  41. package/dist/lib/conformance/seeder.mjs +5 -5
  42. package/dist/lib/conformance/seeder.mjs.map +1 -1
  43. package/dist/lib/core/ADCPMultiAgentClient.d.mts +26 -29
  44. package/dist/lib/core/ADCPMultiAgentClient.d.ts +26 -29
  45. package/dist/lib/core/ADCPMultiAgentClient.d.ts.map +1 -1
  46. package/dist/lib/core/ADCPMultiAgentClient.js +27 -19
  47. package/dist/lib/core/ADCPMultiAgentClient.js.map +1 -1
  48. package/dist/lib/core/ADCPMultiAgentClient.mjs +27 -19
  49. package/dist/lib/core/ADCPMultiAgentClient.mjs.map +1 -1
  50. package/dist/lib/core/AgentClient.d.mts +148 -138
  51. package/dist/lib/core/AgentClient.d.ts +148 -138
  52. package/dist/lib/core/AgentClient.d.ts.map +1 -1
  53. package/dist/lib/core/AgentClient.js +174 -85
  54. package/dist/lib/core/AgentClient.js.map +1 -1
  55. package/dist/lib/core/AgentClient.mjs +174 -85
  56. package/dist/lib/core/AgentClient.mjs.map +1 -1
  57. package/dist/lib/core/AsyncHandler.d.mts +18 -16
  58. package/dist/lib/core/AsyncHandler.d.ts +18 -16
  59. package/dist/lib/core/AsyncHandler.d.ts.map +1 -1
  60. package/dist/lib/core/AsyncHandler.js +22 -1
  61. package/dist/lib/core/AsyncHandler.js.map +1 -1
  62. package/dist/lib/core/AsyncHandler.mjs +22 -1
  63. package/dist/lib/core/AsyncHandler.mjs.map +1 -1
  64. package/dist/lib/core/ConversationTypes.d.mts +6 -2
  65. package/dist/lib/core/ConversationTypes.d.ts +6 -2
  66. package/dist/lib/core/ConversationTypes.d.ts.map +1 -1
  67. package/dist/lib/core/ConversationTypes.js.map +1 -1
  68. package/dist/lib/core/CreativeAgentClient.d.mts +41 -17
  69. package/dist/lib/core/CreativeAgentClient.d.ts +41 -17
  70. package/dist/lib/core/CreativeAgentClient.d.ts.map +1 -1
  71. package/dist/lib/core/CreativeAgentClient.js +39 -12
  72. package/dist/lib/core/CreativeAgentClient.js.map +1 -1
  73. package/dist/lib/core/CreativeAgentClient.mjs +39 -12
  74. package/dist/lib/core/CreativeAgentClient.mjs.map +1 -1
  75. package/dist/lib/core/SingleAgentClient.d.mts +129 -52
  76. package/dist/lib/core/SingleAgentClient.d.ts +129 -52
  77. package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
  78. package/dist/lib/core/SingleAgentClient.js +1748 -218
  79. package/dist/lib/core/SingleAgentClient.js.map +1 -1
  80. package/dist/lib/core/SingleAgentClient.mjs +1758 -218
  81. package/dist/lib/core/SingleAgentClient.mjs.map +1 -1
  82. package/dist/lib/core/TaskExecutor.d.mts +9 -0
  83. package/dist/lib/core/TaskExecutor.d.ts +9 -0
  84. package/dist/lib/core/TaskExecutor.d.ts.map +1 -1
  85. package/dist/lib/core/TaskExecutor.js +137 -44
  86. package/dist/lib/core/TaskExecutor.js.map +1 -1
  87. package/dist/lib/core/TaskExecutor.mjs +137 -44
  88. package/dist/lib/core/TaskExecutor.mjs.map +1 -1
  89. package/dist/lib/index.d.mts +111 -17
  90. package/dist/lib/index.d.ts +111 -17
  91. package/dist/lib/index.d.ts.map +1 -1
  92. package/dist/lib/index.js +94 -94
  93. package/dist/lib/index.js.map +1 -1
  94. package/dist/lib/index.mjs +93 -94
  95. package/dist/lib/index.mjs.map +1 -1
  96. package/dist/lib/net/ssrf-fetch.d.mts +13 -1
  97. package/dist/lib/net/ssrf-fetch.d.ts +13 -1
  98. package/dist/lib/net/ssrf-fetch.d.ts.map +1 -1
  99. package/dist/lib/net/ssrf-fetch.js +14 -7
  100. package/dist/lib/net/ssrf-fetch.js.map +1 -1
  101. package/dist/lib/net/ssrf-fetch.mjs +14 -7
  102. package/dist/lib/net/ssrf-fetch.mjs.map +1 -1
  103. package/dist/lib/protocols/a2a.d.mts +2 -2
  104. package/dist/lib/protocols/a2a.d.ts +2 -2
  105. package/dist/lib/protocols/a2a.d.ts.map +1 -1
  106. package/dist/lib/protocols/a2a.js +14 -9
  107. package/dist/lib/protocols/a2a.js.map +1 -1
  108. package/dist/lib/protocols/a2a.mjs +14 -9
  109. package/dist/lib/protocols/a2a.mjs.map +1 -1
  110. package/dist/lib/protocols/index.d.mts +20 -3
  111. package/dist/lib/protocols/index.d.ts +20 -3
  112. package/dist/lib/protocols/index.d.ts.map +1 -1
  113. package/dist/lib/protocols/index.js +44 -31
  114. package/dist/lib/protocols/index.js.map +1 -1
  115. package/dist/lib/protocols/index.mjs +44 -32
  116. package/dist/lib/protocols/index.mjs.map +1 -1
  117. package/dist/lib/protocols/mcp-modern.d.ts.map +1 -1
  118. package/dist/lib/protocols/mcp-modern.js +87 -12
  119. package/dist/lib/protocols/mcp-modern.js.map +1 -1
  120. package/dist/lib/protocols/mcp-modern.mjs +89 -12
  121. package/dist/lib/protocols/mcp-modern.mjs.map +1 -1
  122. package/dist/lib/protocols/mcp-tasks.d.mts +3 -0
  123. package/dist/lib/protocols/mcp-tasks.d.ts +3 -0
  124. package/dist/lib/protocols/mcp-tasks.d.ts.map +1 -1
  125. package/dist/lib/protocols/mcp-tasks.js +21 -11
  126. package/dist/lib/protocols/mcp-tasks.js.map +1 -1
  127. package/dist/lib/protocols/mcp-tasks.mjs +21 -11
  128. package/dist/lib/protocols/mcp-tasks.mjs.map +1 -1
  129. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  130. package/dist/lib/server/create-adcp-server.d.mts +6 -0
  131. package/dist/lib/server/create-adcp-server.d.ts +6 -0
  132. package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
  133. package/dist/lib/server/create-adcp-server.js +295 -48
  134. package/dist/lib/server/create-adcp-server.js.map +1 -1
  135. package/dist/lib/server/create-adcp-server.mjs +301 -50
  136. package/dist/lib/server/create-adcp-server.mjs.map +1 -1
  137. package/dist/lib/server/decisioning/assembly-helpers.d.mts +27 -13
  138. package/dist/lib/server/decisioning/assembly-helpers.d.ts +27 -13
  139. package/dist/lib/server/decisioning/assembly-helpers.d.ts.map +1 -1
  140. package/dist/lib/server/decisioning/assembly-helpers.js +136 -14
  141. package/dist/lib/server/decisioning/assembly-helpers.js.map +1 -1
  142. package/dist/lib/server/decisioning/assembly-helpers.mjs +134 -13
  143. package/dist/lib/server/decisioning/assembly-helpers.mjs.map +1 -1
  144. package/dist/lib/server/decisioning/index.d.mts +13 -12
  145. package/dist/lib/server/decisioning/index.d.ts +13 -12
  146. package/dist/lib/server/decisioning/index.d.ts.map +1 -1
  147. package/dist/lib/server/decisioning/index.js +6 -0
  148. package/dist/lib/server/decisioning/index.js.map +1 -1
  149. package/dist/lib/server/decisioning/index.mjs +9 -3
  150. package/dist/lib/server/decisioning/index.mjs.map +1 -1
  151. package/dist/lib/server/decisioning/list-helpers.d.mts +13 -3
  152. package/dist/lib/server/decisioning/list-helpers.d.ts +13 -3
  153. package/dist/lib/server/decisioning/list-helpers.d.ts.map +1 -1
  154. package/dist/lib/server/decisioning/list-helpers.js +13 -3
  155. package/dist/lib/server/decisioning/list-helpers.js.map +1 -1
  156. package/dist/lib/server/decisioning/list-helpers.mjs +11 -2
  157. package/dist/lib/server/decisioning/list-helpers.mjs.map +1 -1
  158. package/dist/lib/server/decisioning/manifest-helpers.d.mts +5 -3
  159. package/dist/lib/server/decisioning/manifest-helpers.d.ts +5 -3
  160. package/dist/lib/server/decisioning/manifest-helpers.d.ts.map +1 -1
  161. package/dist/lib/server/decisioning/manifest-helpers.js.map +1 -1
  162. package/dist/lib/server/decisioning/manifest-helpers.mjs.map +1 -1
  163. package/dist/lib/server/decisioning/proposal/dispatch.d.mts +2 -2
  164. package/dist/lib/server/decisioning/proposal/dispatch.d.ts +2 -2
  165. package/dist/lib/server/decisioning/proposal/dispatch.d.ts.map +1 -1
  166. package/dist/lib/server/decisioning/proposal/dispatch.js.map +1 -1
  167. package/dist/lib/server/decisioning/proposal/dispatch.mjs.map +1 -1
  168. package/dist/lib/server/decisioning/proposal/index.d.mts +1 -1
  169. package/dist/lib/server/decisioning/proposal/index.d.ts +1 -1
  170. package/dist/lib/server/decisioning/proposal/index.d.ts.map +1 -1
  171. package/dist/lib/server/decisioning/proposal/index.js.map +1 -1
  172. package/dist/lib/server/decisioning/proposal/index.mjs.map +1 -1
  173. package/dist/lib/server/decisioning/proposal/lifecycle.d.mts +3 -2
  174. package/dist/lib/server/decisioning/proposal/lifecycle.d.ts +3 -2
  175. package/dist/lib/server/decisioning/proposal/lifecycle.d.ts.map +1 -1
  176. package/dist/lib/server/decisioning/proposal/lifecycle.js.map +1 -1
  177. package/dist/lib/server/decisioning/proposal/lifecycle.mjs.map +1 -1
  178. package/dist/lib/server/decisioning/proposal/mock-manager.d.mts +3 -3
  179. package/dist/lib/server/decisioning/proposal/mock-manager.d.ts +3 -3
  180. package/dist/lib/server/decisioning/proposal/mock-manager.d.ts.map +1 -1
  181. package/dist/lib/server/decisioning/proposal/mock-manager.js.map +1 -1
  182. package/dist/lib/server/decisioning/proposal/mock-manager.mjs.map +1 -1
  183. package/dist/lib/server/decisioning/proposal/types.d.mts +10 -6
  184. package/dist/lib/server/decisioning/proposal/types.d.ts +10 -6
  185. package/dist/lib/server/decisioning/proposal/types.d.ts.map +1 -1
  186. package/dist/lib/server/decisioning/proposal/types.js.map +1 -1
  187. package/dist/lib/server/decisioning/proposal/types.mjs.map +1 -1
  188. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +21 -2
  189. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +21 -2
  190. package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
  191. package/dist/lib/server/decisioning/runtime/from-platform.js +754 -81
  192. package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
  193. package/dist/lib/server/decisioning/runtime/from-platform.mjs +763 -81
  194. package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
  195. package/dist/lib/server/decisioning/specialisms/brand-rights.d.mts +9 -9
  196. package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts +9 -9
  197. package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts.map +1 -1
  198. package/dist/lib/server/decisioning/specialisms/brand-rights.js.map +1 -1
  199. package/dist/lib/server/decisioning/specialisms/content-standards.d.mts +16 -16
  200. package/dist/lib/server/decisioning/specialisms/content-standards.d.ts +16 -16
  201. package/dist/lib/server/decisioning/specialisms/content-standards.d.ts.map +1 -1
  202. package/dist/lib/server/decisioning/specialisms/content-standards.js.map +1 -1
  203. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.mts +15 -13
  204. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts +15 -13
  205. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts.map +1 -1
  206. package/dist/lib/server/decisioning/specialisms/creative-ad-server.js.map +1 -1
  207. package/dist/lib/server/decisioning/specialisms/creative.d.mts +12 -11
  208. package/dist/lib/server/decisioning/specialisms/creative.d.ts +12 -11
  209. package/dist/lib/server/decisioning/specialisms/creative.d.ts.map +1 -1
  210. package/dist/lib/server/decisioning/specialisms/creative.js.map +1 -1
  211. package/dist/lib/server/decisioning/specialisms/sales.d.mts +25 -15
  212. package/dist/lib/server/decisioning/specialisms/sales.d.ts +25 -15
  213. package/dist/lib/server/decisioning/specialisms/sales.d.ts.map +1 -1
  214. package/dist/lib/server/decisioning/specialisms/sales.js.map +1 -1
  215. package/dist/lib/server/index.d.mts +3 -3
  216. package/dist/lib/server/index.d.ts +3 -3
  217. package/dist/lib/server/index.d.ts.map +1 -1
  218. package/dist/lib/server/index.js +72 -72
  219. package/dist/lib/server/index.js.map +1 -1
  220. package/dist/lib/server/index.mjs +36 -36
  221. package/dist/lib/server/index.mjs.map +1 -1
  222. package/dist/lib/server/legacy/v5/index.d.mts +1 -0
  223. package/dist/lib/server/legacy/v5/index.d.ts +1 -0
  224. package/dist/lib/server/legacy/v5/index.d.ts.map +1 -1
  225. package/dist/lib/server/legacy/v5/index.js +74 -1
  226. package/dist/lib/server/legacy/v5/index.js.map +1 -1
  227. package/dist/lib/server/legacy/v5/index.mjs +75 -1
  228. package/dist/lib/server/legacy/v5/index.mjs.map +1 -1
  229. package/dist/lib/server/responses.d.mts +2 -2
  230. package/dist/lib/server/responses.d.ts +2 -2
  231. package/dist/lib/server/responses.js.map +1 -1
  232. package/dist/lib/server/responses.mjs.map +1 -1
  233. package/dist/lib/testing/client.d.ts.map +1 -1
  234. package/dist/lib/testing/client.js +13 -5
  235. package/dist/lib/testing/client.js.map +1 -1
  236. package/dist/lib/testing/client.mjs +13 -5
  237. package/dist/lib/testing/client.mjs.map +1 -1
  238. package/dist/lib/testing/compliance/comply.d.mts +1 -1
  239. package/dist/lib/testing/compliance/comply.d.ts +1 -1
  240. package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
  241. package/dist/lib/testing/compliance/comply.js +16 -6
  242. package/dist/lib/testing/compliance/comply.js.map +1 -1
  243. package/dist/lib/testing/compliance/comply.mjs +16 -6
  244. package/dist/lib/testing/compliance/comply.mjs.map +1 -1
  245. package/dist/lib/testing/scenarios/brand-rights.js +6 -6
  246. package/dist/lib/testing/scenarios/brand-rights.js.map +1 -1
  247. package/dist/lib/testing/scenarios/brand-rights.mjs +6 -6
  248. package/dist/lib/testing/scenarios/brand-rights.mjs.map +1 -1
  249. package/dist/lib/testing/scenarios/creative.js +7 -7
  250. package/dist/lib/testing/scenarios/creative.js.map +1 -1
  251. package/dist/lib/testing/scenarios/creative.mjs +7 -7
  252. package/dist/lib/testing/scenarios/creative.mjs.map +1 -1
  253. package/dist/lib/testing/scenarios/discovery.js +2 -2
  254. package/dist/lib/testing/scenarios/discovery.js.map +1 -1
  255. package/dist/lib/testing/scenarios/discovery.mjs +2 -2
  256. package/dist/lib/testing/scenarios/discovery.mjs.map +1 -1
  257. package/dist/lib/testing/scenarios/edge-cases.js +11 -11
  258. package/dist/lib/testing/scenarios/edge-cases.js.map +1 -1
  259. package/dist/lib/testing/scenarios/edge-cases.mjs +11 -11
  260. package/dist/lib/testing/scenarios/edge-cases.mjs.map +1 -1
  261. package/dist/lib/testing/scenarios/governance.d.ts.map +1 -1
  262. package/dist/lib/testing/scenarios/governance.js +16 -22
  263. package/dist/lib/testing/scenarios/governance.js.map +1 -1
  264. package/dist/lib/testing/scenarios/governance.mjs +16 -22
  265. package/dist/lib/testing/scenarios/governance.mjs.map +1 -1
  266. package/dist/lib/testing/scenarios/media-buy.js +5 -5
  267. package/dist/lib/testing/scenarios/media-buy.js.map +1 -1
  268. package/dist/lib/testing/scenarios/media-buy.mjs +5 -5
  269. package/dist/lib/testing/scenarios/media-buy.mjs.map +1 -1
  270. package/dist/lib/testing/scenarios/schema-compliance.js +1 -1
  271. package/dist/lib/testing/scenarios/schema-compliance.js.map +1 -1
  272. package/dist/lib/testing/scenarios/schema-compliance.mjs +1 -1
  273. package/dist/lib/testing/scenarios/schema-compliance.mjs.map +1 -1
  274. package/dist/lib/testing/scenarios/trusted-match.d.ts.map +1 -1
  275. package/dist/lib/testing/scenarios/trusted-match.js +4 -3
  276. package/dist/lib/testing/scenarios/trusted-match.js.map +1 -1
  277. package/dist/lib/testing/scenarios/trusted-match.mjs +4 -3
  278. package/dist/lib/testing/scenarios/trusted-match.mjs.map +1 -1
  279. package/dist/lib/testing/storyboard/probes.d.mts +6 -0
  280. package/dist/lib/testing/storyboard/probes.d.ts +6 -0
  281. package/dist/lib/testing/storyboard/probes.d.ts.map +1 -1
  282. package/dist/lib/testing/storyboard/probes.js +16 -5
  283. package/dist/lib/testing/storyboard/probes.js.map +1 -1
  284. package/dist/lib/testing/storyboard/probes.mjs +16 -5
  285. package/dist/lib/testing/storyboard/probes.mjs.map +1 -1
  286. package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
  287. package/dist/lib/testing/storyboard/runner.js +6 -2
  288. package/dist/lib/testing/storyboard/runner.js.map +1 -1
  289. package/dist/lib/testing/storyboard/runner.mjs +6 -2
  290. package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
  291. package/dist/lib/testing/storyboard/shape-drift-hints.d.mts +3 -4
  292. package/dist/lib/testing/storyboard/shape-drift-hints.d.ts +3 -4
  293. package/dist/lib/testing/storyboard/shape-drift-hints.d.ts.map +1 -1
  294. package/dist/lib/testing/storyboard/shape-drift-hints.js +27 -27
  295. package/dist/lib/testing/storyboard/shape-drift-hints.js.map +1 -1
  296. package/dist/lib/testing/storyboard/shape-drift-hints.mjs +27 -27
  297. package/dist/lib/testing/storyboard/shape-drift-hints.mjs.map +1 -1
  298. package/dist/lib/testing/storyboard/task-map.d.ts.map +1 -1
  299. package/dist/lib/testing/storyboard/task-map.js +43 -5
  300. package/dist/lib/testing/storyboard/task-map.js.map +1 -1
  301. package/dist/lib/testing/storyboard/task-map.mjs +43 -5
  302. package/dist/lib/testing/storyboard/task-map.mjs.map +1 -1
  303. package/dist/lib/testing/test-helpers.d.mts +2 -2
  304. package/dist/lib/testing/test-helpers.d.ts +2 -2
  305. package/dist/lib/testing/test-helpers.js.map +1 -1
  306. package/dist/lib/testing/test-helpers.mjs.map +1 -1
  307. package/dist/lib/testing/types.d.mts +7 -1
  308. package/dist/lib/testing/types.d.ts +7 -1
  309. package/dist/lib/testing/types.d.ts.map +1 -1
  310. package/dist/lib/testing/types.js.map +1 -1
  311. package/dist/lib/types/adcp.d.mts +14 -14
  312. package/dist/lib/types/adcp.d.ts +14 -14
  313. package/dist/lib/types/adcp.d.ts.map +1 -1
  314. package/dist/lib/types/adcp.js.map +1 -1
  315. package/dist/lib/types/adcp.mjs.map +1 -1
  316. package/dist/lib/types/index.d.mts +2 -2
  317. package/dist/lib/types/index.d.ts +2 -2
  318. package/dist/lib/types/index.d.ts.map +1 -1
  319. package/dist/lib/types/index.js.map +1 -1
  320. package/dist/lib/types/index.mjs.map +1 -1
  321. package/dist/lib/utils/capabilities.d.mts +6 -0
  322. package/dist/lib/utils/capabilities.d.ts +6 -0
  323. package/dist/lib/utils/capabilities.d.ts.map +1 -1
  324. package/dist/lib/utils/capabilities.js +4 -0
  325. package/dist/lib/utils/capabilities.js.map +1 -1
  326. package/dist/lib/utils/capabilities.mjs +4 -0
  327. package/dist/lib/utils/capabilities.mjs.map +1 -1
  328. package/dist/lib/utils/creative-delivery.d.mts +52 -10
  329. package/dist/lib/utils/creative-delivery.d.ts +52 -10
  330. package/dist/lib/utils/creative-delivery.d.ts.map +1 -1
  331. package/dist/lib/utils/creative-delivery.js +104 -9
  332. package/dist/lib/utils/creative-delivery.js.map +1 -1
  333. package/dist/lib/utils/creative-delivery.mjs +104 -8
  334. package/dist/lib/utils/creative-delivery.mjs.map +1 -1
  335. package/dist/lib/utils/format-assets.d.mts +41 -38
  336. package/dist/lib/utils/format-assets.d.ts +41 -38
  337. package/dist/lib/utils/format-assets.d.ts.map +1 -1
  338. package/dist/lib/utils/format-assets.js +3 -1
  339. package/dist/lib/utils/format-assets.js.map +1 -1
  340. package/dist/lib/utils/format-assets.mjs +3 -1
  341. package/dist/lib/utils/format-assets.mjs.map +1 -1
  342. package/dist/lib/utils/index.d.mts +8 -8
  343. package/dist/lib/utils/index.d.ts +8 -8
  344. package/dist/lib/utils/index.d.ts.map +1 -1
  345. package/dist/lib/utils/index.js +11 -9
  346. package/dist/lib/utils/index.js.map +1 -1
  347. package/dist/lib/utils/index.mjs +9 -8
  348. package/dist/lib/utils/index.mjs.map +1 -1
  349. package/dist/lib/utils/preview-utils.d.mts +11 -8
  350. package/dist/lib/utils/preview-utils.d.ts +11 -8
  351. package/dist/lib/utils/preview-utils.d.ts.map +1 -1
  352. package/dist/lib/utils/preview-utils.js +4 -4
  353. package/dist/lib/utils/preview-utils.js.map +1 -1
  354. package/dist/lib/utils/preview-utils.mjs +3 -3
  355. package/dist/lib/utils/preview-utils.mjs.map +1 -1
  356. package/dist/lib/utils/tool-request-schemas.d.mts +2 -2
  357. package/dist/lib/utils/tool-request-schemas.d.ts +2 -2
  358. package/dist/lib/v2/projection/aao-reference-formats.json +492 -0
  359. package/dist/lib/v2/projection/augment-response.d.mts +31 -11
  360. package/dist/lib/v2/projection/augment-response.d.ts +31 -11
  361. package/dist/lib/v2/projection/augment-response.d.ts.map +1 -1
  362. package/dist/lib/v2/projection/augment-response.js +233 -27
  363. package/dist/lib/v2/projection/augment-response.js.map +1 -1
  364. package/dist/lib/v2/projection/augment-response.mjs +232 -27
  365. package/dist/lib/v2/projection/augment-response.mjs.map +1 -1
  366. package/dist/lib/v2/projection/builders.d.mts +7 -6
  367. package/dist/lib/v2/projection/builders.d.ts +7 -6
  368. package/dist/lib/v2/projection/builders.d.ts.map +1 -1
  369. package/dist/lib/v2/projection/builders.js +11 -8
  370. package/dist/lib/v2/projection/builders.js.map +1 -1
  371. package/dist/lib/v2/projection/builders.mjs +9 -6
  372. package/dist/lib/v2/projection/builders.mjs.map +1 -1
  373. package/dist/lib/v2/projection/catalog-snapshot.d.mts +47 -0
  374. package/dist/lib/v2/projection/catalog-snapshot.d.ts +48 -0
  375. package/dist/lib/v2/projection/catalog-snapshot.d.ts.map +1 -0
  376. package/dist/lib/v2/projection/catalog-snapshot.js +291 -0
  377. package/dist/lib/v2/projection/catalog-snapshot.js.map +1 -0
  378. package/dist/lib/v2/projection/catalog-snapshot.mjs +265 -0
  379. package/dist/lib/v2/projection/catalog-snapshot.mjs.map +1 -0
  380. package/dist/lib/v2/projection/catalog.d.mts +23 -2
  381. package/dist/lib/v2/projection/catalog.d.ts +23 -2
  382. package/dist/lib/v2/projection/catalog.d.ts.map +1 -1
  383. package/dist/lib/v2/projection/catalog.js +34 -10
  384. package/dist/lib/v2/projection/catalog.js.map +1 -1
  385. package/dist/lib/v2/projection/catalog.mjs +33 -10
  386. package/dist/lib/v2/projection/catalog.mjs.map +1 -1
  387. package/dist/lib/v2/projection/creative-delivery.d.mts +157 -0
  388. package/dist/lib/v2/projection/creative-delivery.d.ts +158 -0
  389. package/dist/lib/v2/projection/creative-delivery.d.ts.map +1 -0
  390. package/dist/lib/v2/projection/creative-delivery.js +967 -0
  391. package/dist/lib/v2/projection/creative-delivery.js.map +1 -0
  392. package/dist/lib/v2/projection/creative-delivery.mjs +941 -0
  393. package/dist/lib/v2/projection/creative-delivery.mjs.map +1 -0
  394. package/dist/lib/v2/projection/index.d.mts +8 -6
  395. package/dist/lib/v2/projection/index.d.ts +8 -6
  396. package/dist/lib/v2/projection/index.d.ts.map +1 -1
  397. package/dist/lib/v2/projection/index.js +26 -4
  398. package/dist/lib/v2/projection/index.js.map +1 -1
  399. package/dist/lib/v2/projection/index.mjs +28 -4
  400. package/dist/lib/v2/projection/index.mjs.map +1 -1
  401. package/dist/lib/v2/projection/legacy-metadata.d.mts +21 -0
  402. package/dist/lib/v2/projection/legacy-metadata.d.ts +22 -0
  403. package/dist/lib/v2/projection/legacy-metadata.d.ts.map +1 -0
  404. package/dist/lib/v2/projection/legacy-metadata.js +73 -0
  405. package/dist/lib/v2/projection/legacy-metadata.js.map +1 -0
  406. package/dist/lib/v2/projection/legacy-metadata.mjs +45 -0
  407. package/dist/lib/v2/projection/legacy-metadata.mjs.map +1 -0
  408. package/dist/lib/v2/projection/types.d.mts +29 -23
  409. package/dist/lib/v2/projection/types.d.ts +29 -23
  410. package/dist/lib/v2/projection/types.d.ts.map +1 -1
  411. package/dist/lib/v2/projection/types.js.map +1 -1
  412. package/dist/lib/v2/projection/v1-to-v2.d.mts +29 -6
  413. package/dist/lib/v2/projection/v1-to-v2.d.ts +29 -6
  414. package/dist/lib/v2/projection/v1-to-v2.d.ts.map +1 -1
  415. package/dist/lib/v2/projection/v1-to-v2.js +218 -9
  416. package/dist/lib/v2/projection/v1-to-v2.js.map +1 -1
  417. package/dist/lib/v2/projection/v1-to-v2.mjs +219 -10
  418. package/dist/lib/v2/projection/v1-to-v2.mjs.map +1 -1
  419. package/dist/lib/v2/projection/v2-to-v1.d.mts +31 -2
  420. package/dist/lib/v2/projection/v2-to-v1.d.ts +31 -2
  421. package/dist/lib/v2/projection/v2-to-v1.d.ts.map +1 -1
  422. package/dist/lib/v2/projection/v2-to-v1.js +138 -7
  423. package/dist/lib/v2/projection/v2-to-v1.js.map +1 -1
  424. package/dist/lib/v2/projection/v2-to-v1.mjs +135 -6
  425. package/dist/lib/v2/projection/v2-to-v1.mjs.map +1 -1
  426. package/dist/lib/v2/projection/write-side.d.mts +12 -13
  427. package/dist/lib/v2/projection/write-side.d.ts +12 -13
  428. package/dist/lib/v2/projection/write-side.d.ts.map +1 -1
  429. package/dist/lib/v2/projection/write-side.js +16 -12
  430. package/dist/lib/v2/projection/write-side.js.map +1 -1
  431. package/dist/lib/v2/projection/write-side.mjs +16 -12
  432. package/dist/lib/v2/projection/write-side.mjs.map +1 -1
  433. package/dist/lib/version.d.mts +3 -3
  434. package/dist/lib/version.d.ts +3 -3
  435. package/dist/lib/version.d.ts.map +1 -1
  436. package/dist/lib/version.js +3 -3
  437. package/dist/lib/version.js.map +1 -1
  438. package/dist/lib/version.mjs +3 -3
  439. package/dist/lib/version.mjs.map +1 -1
  440. package/docs/guides/BUILD-AN-AGENT.md +7 -2
  441. package/docs/guides/PREVIEW-ASSET-DURABILITY.md +6 -2
  442. package/docs/llms.txt +1 -0
  443. package/examples/README.md +1 -1
  444. package/examples/batch-preview-test.ts +3 -3
  445. package/examples/conversation-client.ts +2 -2
  446. package/examples/debug-preview-response.ts +1 -1
  447. package/examples/decisioning-platform-broadcast-tv.ts +10 -4
  448. package/examples/decisioning-platform-mock-seller.ts +16 -9
  449. package/examples/decisioning-platform-programmatic.ts +18 -7
  450. package/examples/error-compliant-server.ts +26 -16
  451. package/examples/generative-creative-demo.ts +7 -19
  452. package/examples/hello_creative_adapter_ad_server.ts +37 -16
  453. package/examples/hello_creative_adapter_template.ts +12 -10
  454. package/examples/hello_seller_adapter_guaranteed.ts +52 -23
  455. package/examples/hello_seller_adapter_multi_tenant.ts +6 -3
  456. package/examples/hello_seller_adapter_non_guaranteed.ts +54 -26
  457. package/examples/hello_seller_adapter_proposal_mode.ts +40 -14
  458. package/examples/hello_seller_adapter_social.ts +2 -7
  459. package/examples/inspect-card-formats.ts +1 -1
  460. package/examples/simple-getting-started.ts +1 -1
  461. package/examples/test-helpers-demo.ts +1 -1
  462. package/package.json +2 -2
  463. package/skills/build-decisioning-creative-template/SKILL.md +11 -11
  464. package/skills/build-decisioning-platform/advanced/REFERENCE.md +8 -2
@@ -0,0 +1,265 @@
1
+ import { canonicalizeAgentUrl } from "../../discovery/resolve-agent-properties.mjs";
2
+ import { isCanonicalV1Translatable } from "./canonical-properties.mjs";
3
+ const compiledSnapshotCache = /* @__PURE__ */ new WeakMap();
4
+ function normalizedAgentUrl(value) {
5
+ return canonicalizeAgentUrl(value) ?? value;
6
+ }
7
+ function legacyRefKey(ref) {
8
+ return JSON.stringify([
9
+ normalizedAgentUrl(ref.agent_url),
10
+ ref.id,
11
+ ref.width ?? null,
12
+ ref.height ?? null,
13
+ ref.duration_ms ?? null
14
+ ]);
15
+ }
16
+ function normalizedPublisherDomain(value) {
17
+ return (value ?? "").trim().toLowerCase().replace(/\.$/, "");
18
+ }
19
+ function formatOptionRefKey(formatOptionId, publisherDomain) {
20
+ return JSON.stringify([normalizedPublisherDomain(publisherDomain), formatOptionId]);
21
+ }
22
+ function formatOptionRefFromValue(value) {
23
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
24
+ const record = value;
25
+ if (typeof record.format_option_id !== "string" || record.format_option_id.length === 0) return void 0;
26
+ if (record.scope === "publisher" || record.scope === void 0 && typeof record.publisher_domain === "string") {
27
+ if (typeof record.publisher_domain !== "string" || record.publisher_domain.length === 0) return void 0;
28
+ return { format_option_id: record.format_option_id, publisher_domain: record.publisher_domain };
29
+ }
30
+ return { format_option_id: record.format_option_id };
31
+ }
32
+ function semanticFields(value) {
33
+ return {
34
+ ...typeof value.format_kind === "string" ? { format_kind: value.format_kind } : {},
35
+ ...value.params !== null && typeof value.params === "object" && !Array.isArray(value.params) ? { params: value.params } : {}
36
+ };
37
+ }
38
+ function collectFormatOptionRefs(value, seen = /* @__PURE__ */ new WeakSet()) {
39
+ if (value === null || typeof value !== "object" || seen.has(value)) return [];
40
+ seen.add(value);
41
+ const record = value;
42
+ const refs = [];
43
+ const direct = formatOptionRefFromValue(record.format_option_ref);
44
+ if (direct) refs.push({ ...direct, ...semanticFields(record) });
45
+ for (const key of ["format_option_refs", "format_options"]) {
46
+ if (!Array.isArray(record[key])) continue;
47
+ for (const item of record[key]) {
48
+ const ref = formatOptionRefFromValue(item);
49
+ const itemRecord = item !== null && typeof item === "object" && !Array.isArray(item) ? item : record;
50
+ if (ref) refs.push({ ...ref, ...semanticFields(itemRecord) });
51
+ }
52
+ }
53
+ if (Array.isArray(record.selector_containers)) {
54
+ for (const container of record.selector_containers) refs.push(...collectFormatOptionRefs(container, seen));
55
+ }
56
+ return refs;
57
+ }
58
+ function resolutionContextFormatOptionRefs(context) {
59
+ if (context.source === "product") {
60
+ const declaration = context.declaration;
61
+ if (typeof declaration.format_option_id !== "string" || declaration.format_option_id.length === 0) return [];
62
+ return [
63
+ {
64
+ format_option_id: declaration.format_option_id,
65
+ ...typeof declaration.publisher_domain === "string" ? { publisher_domain: declaration.publisher_domain } : {},
66
+ format_kind: declaration.format_kind,
67
+ params: declaration.params
68
+ }
69
+ ];
70
+ }
71
+ if (context.source === "creative") {
72
+ const creativeRefs = collectFormatOptionRefs(context.creative);
73
+ return creativeRefs.length > 0 ? creativeRefs : collectFormatOptionRefs(context.selector);
74
+ }
75
+ return collectFormatOptionRefs(context.selector);
76
+ }
77
+ function dataValuesEqual(left, right) {
78
+ if (Object.is(left, right)) return true;
79
+ if (Array.isArray(left) || Array.isArray(right)) {
80
+ return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((item, index) => dataValuesEqual(item, right[index]));
81
+ }
82
+ if (left === null || right === null || typeof left !== "object" || typeof right !== "object") return false;
83
+ const leftRecord = left;
84
+ const rightRecord = right;
85
+ const leftKeys = Object.keys(leftRecord).sort();
86
+ const rightKeys = Object.keys(rightRecord).sort();
87
+ return leftKeys.length === rightKeys.length && leftKeys.every((key, index) => key === rightKeys[index] && dataValuesEqual(leftRecord[key], rightRecord[key]));
88
+ }
89
+ function sharedParamsAgree(declarationParams, contextParams) {
90
+ if (!contextParams) return true;
91
+ return Object.keys(contextParams).every(
92
+ (key) => !(key in declarationParams) || dataValuesEqual(declarationParams[key], contextParams[key])
93
+ );
94
+ }
95
+ function routeMatchesContext(route, ref, context) {
96
+ if (ref.format_kind !== void 0 && ref.format_kind !== route.declaration.format_kind) return false;
97
+ if (!sharedParamsAgree(route.declaration.params, ref.params)) return false;
98
+ const records = context.source === "creative" ? [context.creative, context.selector] : context.source === "selector" ? [context.selector] : [];
99
+ return records.every((record) => {
100
+ const fields = semanticFields(record);
101
+ return (fields.format_kind === void 0 || fields.format_kind === route.declaration.format_kind) && sharedParamsAgree(route.declaration.params, fields.params);
102
+ });
103
+ }
104
+ function immutableClone(value) {
105
+ const clone = structuredClone(value);
106
+ const freeze = (candidate, seen = /* @__PURE__ */ new WeakSet()) => {
107
+ if (candidate === null || typeof candidate !== "object" || seen.has(candidate)) return;
108
+ seen.add(candidate);
109
+ for (const child of Object.values(candidate)) freeze(child, seen);
110
+ Object.freeze(candidate);
111
+ };
112
+ freeze(clone);
113
+ return clone;
114
+ }
115
+ function declarationWithoutLegacyIdentity(declaration, publisherDomain) {
116
+ const { v1_format_ref: _dropRefs, canonical_formats_only: _dropCanonicalOnly, ...canonical } = declaration;
117
+ void _dropRefs;
118
+ void _dropCanonicalOnly;
119
+ return {
120
+ ...canonical,
121
+ ...canonical.publisher_domain === void 0 && publisherDomain ? { publisher_domain: publisherDomain } : {}
122
+ };
123
+ }
124
+ function compileProjectionCatalogSnapshots(snapshots) {
125
+ const cached = compiledSnapshotCache.get(snapshots);
126
+ if (cached) return cached;
127
+ const compiled = snapshots.map((snapshot) => {
128
+ const byLegacyRef = /* @__PURE__ */ new Map();
129
+ const byFormatOptionRef = /* @__PURE__ */ new Map();
130
+ for (const sourceDeclaration of snapshot.formats) {
131
+ const declaration = immutableClone(sourceDeclaration);
132
+ if (declaration.canonical_formats_only === true || !isCanonicalV1Translatable(declaration.format_kind) || !Array.isArray(declaration.v1_format_ref) || declaration.v1_format_ref.length === 0) {
133
+ continue;
134
+ }
135
+ const canonical = immutableClone(declarationWithoutLegacyIdentity(declaration, snapshot.publisher_domain));
136
+ const legacyRefs = immutableClone([
137
+ ...new Map(declaration.v1_format_ref.map((ref) => [legacyRefKey(ref), { ...ref }])).values()
138
+ ]);
139
+ const declarationKeys = new Set(declaration.v1_format_ref.map(legacyRefKey));
140
+ for (const key of declarationKeys) {
141
+ const matches = byLegacyRef.get(key) ?? [];
142
+ matches.push(canonical);
143
+ byLegacyRef.set(key, matches);
144
+ }
145
+ if (typeof canonical.format_option_id === "string" && canonical.format_option_id.length > 0 && typeof canonical.publisher_domain === "string" && canonical.publisher_domain.length > 0) {
146
+ const key = formatOptionRefKey(canonical.format_option_id, canonical.publisher_domain);
147
+ const matches = byFormatOptionRef.get(key) ?? [];
148
+ matches.push(Object.freeze({ declaration: canonical, legacyRefs }));
149
+ byFormatOptionRef.set(key, matches);
150
+ }
151
+ }
152
+ for (const matches of byLegacyRef.values()) Object.freeze(matches);
153
+ for (const matches of byFormatOptionRef.values()) Object.freeze(matches);
154
+ return Object.freeze({ byLegacyRef, byFormatOptionRef });
155
+ });
156
+ Object.freeze(compiled);
157
+ compiledSnapshotCache.set(snapshots, compiled);
158
+ return compiled;
159
+ }
160
+ function legacyFormatConverterFromCatalogSnapshots(snapshots, fallback) {
161
+ if (!snapshots || snapshots.length === 0) return fallback;
162
+ const compiled = compileProjectionCatalogSnapshots(snapshots);
163
+ return (context) => {
164
+ const key = legacyRefKey(context.formatId);
165
+ for (const snapshot of compiled) {
166
+ const matches = snapshot.byLegacyRef.get(key) ?? [];
167
+ if (matches.length > 1) {
168
+ throw new Error("projection catalog contains ambiguous legacy aliases");
169
+ }
170
+ if (matches.length === 1) {
171
+ return matches[0];
172
+ }
173
+ }
174
+ return fallback?.(context);
175
+ };
176
+ }
177
+ function canonicalFormatLegacyResolverFromCatalogSnapshots(snapshots, fallback) {
178
+ if (!snapshots || snapshots.length === 0) return fallback;
179
+ const compiled = compileProjectionCatalogSnapshots(snapshots);
180
+ return (context) => {
181
+ const refs = resolutionContextFormatOptionRefs(context);
182
+ if (refs.length === 0) return fallback?.(context);
183
+ const resolved = [];
184
+ for (const ref of refs) {
185
+ const key = formatOptionRefKey(ref.format_option_id, ref.publisher_domain);
186
+ let matched;
187
+ for (const snapshot of compiled) {
188
+ const matches = snapshot.byFormatOptionRef.get(key) ?? [];
189
+ if (matches.length > 1) {
190
+ throw new Error("projection catalog contains ambiguous canonical format option aliases");
191
+ }
192
+ if (matches.length === 1) {
193
+ matched = matches[0];
194
+ break;
195
+ }
196
+ }
197
+ if (!matched) return fallback?.(context);
198
+ if (!routeMatchesContext(matched, ref, context)) return fallback?.(context);
199
+ resolved.push(...matched.legacyRefs.map((item) => ({ ...item })));
200
+ }
201
+ return [...new Map(resolved.map((ref) => [legacyRefKey(ref), ref])).values()];
202
+ };
203
+ }
204
+ function assertBidirectionalProjectionCatalogs(snapshots) {
205
+ const routeByCanonicalOption = /* @__PURE__ */ new Map();
206
+ const canonicalOptionByLegacyRoute = /* @__PURE__ */ new Map();
207
+ for (const snapshot of snapshots) {
208
+ const declarationsAtThisTier = /* @__PURE__ */ new Set();
209
+ for (const declaration of snapshot.formats) {
210
+ if (declaration.canonical_formats_only === true || !Array.isArray(declaration.v1_format_ref) || declaration.v1_format_ref.length === 0) {
211
+ continue;
212
+ }
213
+ if (!isCanonicalV1Translatable(declaration.format_kind)) {
214
+ throw new Error("bidirectional projection adapters cannot downgrade a canonical-only format kind");
215
+ }
216
+ const canonical = declarationWithoutLegacyIdentity(declaration, snapshot.publisher_domain);
217
+ if (typeof canonical.format_option_id !== "string" || canonical.format_option_id.length === 0) {
218
+ throw new Error("bidirectional projection adapters require a stable format_option_id");
219
+ }
220
+ if (typeof canonical.publisher_domain !== "string" || canonical.publisher_domain.length === 0) {
221
+ throw new Error("bidirectional projection adapters require publisher-scoped format options");
222
+ }
223
+ const uniqueLegacyKeys = new Set(declaration.v1_format_ref.map(legacyRefKey));
224
+ if (uniqueLegacyKeys.size !== 1) {
225
+ throw new Error(
226
+ "bidirectional projection adapters require exactly one legacy route per canonical format option"
227
+ );
228
+ }
229
+ const canonicalKey = formatOptionRefKey(canonical.format_option_id, canonical.publisher_domain);
230
+ const legacyKey = [...uniqueLegacyKeys][0];
231
+ const declarationKey = JSON.stringify([canonicalKey, legacyKey]);
232
+ if (declarationsAtThisTier.has(declarationKey)) {
233
+ throw new Error("bidirectional projection adapters contain duplicate declarations at one precedence tier");
234
+ }
235
+ declarationsAtThisTier.add(declarationKey);
236
+ const existing = routeByCanonicalOption.get(canonicalKey);
237
+ if (existing !== void 0 && existing !== legacyKey) {
238
+ throw new Error("bidirectional projection adapters contain conflicting reverse routes");
239
+ }
240
+ const existingCanonical = canonicalOptionByLegacyRoute.get(legacyKey);
241
+ if (existingCanonical !== void 0 && existingCanonical !== canonicalKey) {
242
+ throw new Error("bidirectional projection adapters contain conflicting forward routes");
243
+ }
244
+ routeByCanonicalOption.set(canonicalKey, legacyKey);
245
+ canonicalOptionByLegacyRoute.set(legacyKey, canonicalKey);
246
+ }
247
+ }
248
+ }
249
+ function projectionAdaptersFromCatalogSnapshots(snapshots, fallbackCanonicalResolver) {
250
+ assertBidirectionalProjectionCatalogs(snapshots);
251
+ const canonicalFormatLegacyResolver = canonicalFormatLegacyResolverFromCatalogSnapshots(
252
+ snapshots,
253
+ fallbackCanonicalResolver
254
+ );
255
+ if (!canonicalFormatLegacyResolver) {
256
+ throw new Error("projection adapters require at least one catalog snapshot or a fallback resolver");
257
+ }
258
+ return { projectionCatalogs: snapshots, canonicalFormatLegacyResolver };
259
+ }
260
+ export {
261
+ canonicalFormatLegacyResolverFromCatalogSnapshots,
262
+ legacyFormatConverterFromCatalogSnapshots,
263
+ projectionAdaptersFromCatalogSnapshots
264
+ };
265
+ //# sourceMappingURL=catalog-snapshot.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/v2/projection/catalog-snapshot.ts"],"sourcesContent":["import type { LegacyFormatConverter } from './v1-to-v2';\nimport type { V1FormatId, V2ProductFormatDeclaration } from './types';\nimport type { CanonicalFormatLegacyResolutionContext, CanonicalFormatLegacyResolver } from './v2-to-v1';\nimport { canonicalizeAgentUrl } from '../../discovery/resolve-agent-properties';\nimport { isCanonicalV1Translatable } from './canonical-properties';\n\n/** Provenance tier for a pre-resolved immutable format catalog snapshot. */\nexport type ProjectionCatalogSource = 'publisher' | 'aao_mirror' | 'agent_derived' | 'configured';\n\n/**\n * Canonical catalog data resolved outside the pure projector.\n *\n * Network discovery deliberately does not happen inside projection. Callers\n * may resolve publisher/community catalogs asynchronously, then inject the\n * immutable result here for synchronous reads, writes, continuations, and\n * webhook handling. Array order is precedence order (most specific first).\n */\nexport interface ProjectionCatalogSnapshot {\n source: ProjectionCatalogSource;\n /** Canonical publisher scope applied when declarations omit it. */\n publisher_domain?: string;\n formats: readonly V2ProductFormatDeclaration[];\n}\n\ninterface CompiledProjectionCatalogSnapshot {\n byLegacyRef: ReadonlyMap<string, readonly V2ProductFormatDeclaration[]>;\n byFormatOptionRef: ReadonlyMap<string, readonly CompiledReverseRoute[]>;\n}\n\ninterface CompiledReverseRoute {\n declaration: Readonly<V2ProductFormatDeclaration>;\n legacyRefs: readonly V1FormatId[];\n}\n\ninterface ContextFormatOptionRef {\n format_option_id: string;\n publisher_domain?: string;\n format_kind?: string;\n params?: Readonly<Record<string, unknown>>;\n}\n\nconst compiledSnapshotCache = new WeakMap<object, readonly CompiledProjectionCatalogSnapshot[]>();\n\n/** Preserve protocol URL identity, including a distinct terminal slash. */\nfunction normalizedAgentUrl(value: string): string {\n return canonicalizeAgentUrl(value) ?? value;\n}\n\nfunction legacyRefKey(ref: V1FormatId): string {\n return JSON.stringify([\n normalizedAgentUrl(ref.agent_url),\n ref.id,\n ref.width ?? null,\n ref.height ?? null,\n ref.duration_ms ?? null,\n ]);\n}\n\nfunction normalizedPublisherDomain(value: string | undefined): string {\n return (value ?? '').trim().toLowerCase().replace(/\\.$/, '');\n}\n\nfunction formatOptionRefKey(formatOptionId: string, publisherDomain?: string): string {\n return JSON.stringify([normalizedPublisherDomain(publisherDomain), formatOptionId]);\n}\n\nfunction formatOptionRefFromValue(value: unknown): { format_option_id: string; publisher_domain?: string } | undefined {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (typeof record.format_option_id !== 'string' || record.format_option_id.length === 0) return undefined;\n if (record.scope === 'publisher' || (record.scope === undefined && typeof record.publisher_domain === 'string')) {\n if (typeof record.publisher_domain !== 'string' || record.publisher_domain.length === 0) return undefined;\n return { format_option_id: record.format_option_id, publisher_domain: record.publisher_domain };\n }\n return { format_option_id: record.format_option_id };\n}\n\nfunction semanticFields(value: Record<string, unknown>): Pick<ContextFormatOptionRef, 'format_kind' | 'params'> {\n return {\n ...(typeof value.format_kind === 'string' ? { format_kind: value.format_kind } : {}),\n ...(value.params !== null && typeof value.params === 'object' && !Array.isArray(value.params)\n ? { params: value.params as Record<string, unknown> }\n : {}),\n };\n}\n\nfunction collectFormatOptionRefs(value: unknown, seen = new WeakSet<object>()): ContextFormatOptionRef[] {\n if (value === null || typeof value !== 'object' || seen.has(value as object)) return [];\n seen.add(value as object);\n const record = value as Record<string, unknown>;\n const refs: ContextFormatOptionRef[] = [];\n const direct = formatOptionRefFromValue(record.format_option_ref);\n if (direct) refs.push({ ...direct, ...semanticFields(record) });\n for (const key of ['format_option_refs', 'format_options'] as const) {\n if (!Array.isArray(record[key])) continue;\n for (const item of record[key]) {\n const ref = formatOptionRefFromValue(item);\n const itemRecord = item !== null && typeof item === 'object' && !Array.isArray(item) ? item : record;\n if (ref) refs.push({ ...ref, ...semanticFields(itemRecord as Record<string, unknown>) });\n }\n }\n if (Array.isArray(record.selector_containers)) {\n for (const container of record.selector_containers) refs.push(...collectFormatOptionRefs(container, seen));\n }\n return refs;\n}\n\nfunction resolutionContextFormatOptionRefs(context: CanonicalFormatLegacyResolutionContext): ContextFormatOptionRef[] {\n if (context.source === 'product') {\n const declaration = context.declaration;\n if (typeof declaration.format_option_id !== 'string' || declaration.format_option_id.length === 0) return [];\n return [\n {\n format_option_id: declaration.format_option_id,\n ...(typeof declaration.publisher_domain === 'string' ? { publisher_domain: declaration.publisher_domain } : {}),\n format_kind: declaration.format_kind,\n params: declaration.params,\n },\n ];\n }\n if (context.source === 'creative') {\n const creativeRefs = collectFormatOptionRefs(context.creative);\n return creativeRefs.length > 0 ? creativeRefs : collectFormatOptionRefs(context.selector);\n }\n return collectFormatOptionRefs(context.selector);\n}\n\nfunction dataValuesEqual(left: unknown, right: unknown): boolean {\n if (Object.is(left, right)) return true;\n if (Array.isArray(left) || Array.isArray(right)) {\n return (\n Array.isArray(left) &&\n Array.isArray(right) &&\n left.length === right.length &&\n left.every((item, index) => dataValuesEqual(item, right[index]))\n );\n }\n if (left === null || right === null || typeof left !== 'object' || typeof right !== 'object') return false;\n const leftRecord = left as Record<string, unknown>;\n const rightRecord = right as Record<string, unknown>;\n const leftKeys = Object.keys(leftRecord).sort();\n const rightKeys = Object.keys(rightRecord).sort();\n return (\n leftKeys.length === rightKeys.length &&\n leftKeys.every((key, index) => key === rightKeys[index] && dataValuesEqual(leftRecord[key], rightRecord[key]))\n );\n}\n\nfunction sharedParamsAgree(\n declarationParams: Readonly<Record<string, unknown>>,\n contextParams: Readonly<Record<string, unknown>> | undefined\n): boolean {\n if (!contextParams) return true;\n return Object.keys(contextParams).every(\n key => !(key in declarationParams) || dataValuesEqual(declarationParams[key], contextParams[key])\n );\n}\n\nfunction routeMatchesContext(\n route: CompiledReverseRoute,\n ref: ContextFormatOptionRef,\n context: CanonicalFormatLegacyResolutionContext\n): boolean {\n if (ref.format_kind !== undefined && ref.format_kind !== route.declaration.format_kind) return false;\n if (!sharedParamsAgree(route.declaration.params, ref.params)) return false;\n\n const records =\n context.source === 'creative'\n ? [context.creative, context.selector]\n : context.source === 'selector'\n ? [context.selector]\n : [];\n return records.every(record => {\n const fields = semanticFields(record as Record<string, unknown>);\n return (\n (fields.format_kind === undefined || fields.format_kind === route.declaration.format_kind) &&\n sharedParamsAgree(route.declaration.params, fields.params)\n );\n });\n}\n\nfunction immutableClone<T>(value: T): T {\n const clone = structuredClone(value);\n const freeze = (candidate: unknown, seen = new WeakSet<object>()): void => {\n if (candidate === null || typeof candidate !== 'object' || seen.has(candidate)) return;\n seen.add(candidate);\n for (const child of Object.values(candidate)) freeze(child, seen);\n Object.freeze(candidate);\n };\n freeze(clone);\n return clone;\n}\n\nfunction declarationWithoutLegacyIdentity(\n declaration: V2ProductFormatDeclaration,\n publisherDomain?: string\n): V2ProductFormatDeclaration {\n const { v1_format_ref: _dropRefs, canonical_formats_only: _dropCanonicalOnly, ...canonical } = declaration;\n void _dropRefs;\n void _dropCanonicalOnly;\n return {\n ...canonical,\n ...(canonical.publisher_domain === undefined && publisherDomain ? { publisher_domain: publisherDomain } : {}),\n };\n}\n\nfunction compileProjectionCatalogSnapshots(\n snapshots: readonly ProjectionCatalogSnapshot[]\n): readonly CompiledProjectionCatalogSnapshot[] {\n const cached = compiledSnapshotCache.get(snapshots);\n if (cached) return cached;\n\n const compiled = snapshots.map(snapshot => {\n const byLegacyRef = new Map<string, V2ProductFormatDeclaration[]>();\n const byFormatOptionRef = new Map<string, CompiledReverseRoute[]>();\n for (const sourceDeclaration of snapshot.formats) {\n const declaration = immutableClone(sourceDeclaration);\n if (\n declaration.canonical_formats_only === true ||\n !isCanonicalV1Translatable(declaration.format_kind) ||\n !Array.isArray(declaration.v1_format_ref) ||\n declaration.v1_format_ref.length === 0\n ) {\n continue;\n }\n\n const canonical = immutableClone(declarationWithoutLegacyIdentity(declaration, snapshot.publisher_domain));\n const legacyRefs = immutableClone([\n ...new Map(declaration.v1_format_ref.map(ref => [legacyRefKey(ref), { ...ref }])).values(),\n ]);\n // Repeating one alias on a declaration does not make it ambiguous. Two\n // distinct declarations at the same precedence tier still do.\n const declarationKeys = new Set(declaration.v1_format_ref.map(legacyRefKey));\n for (const key of declarationKeys) {\n const matches = byLegacyRef.get(key) ?? [];\n matches.push(canonical);\n byLegacyRef.set(key, matches);\n }\n if (\n typeof canonical.format_option_id === 'string' &&\n canonical.format_option_id.length > 0 &&\n typeof canonical.publisher_domain === 'string' &&\n canonical.publisher_domain.length > 0\n ) {\n const key = formatOptionRefKey(canonical.format_option_id, canonical.publisher_domain);\n const matches = byFormatOptionRef.get(key) ?? [];\n matches.push(Object.freeze({ declaration: canonical, legacyRefs }));\n byFormatOptionRef.set(key, matches);\n }\n }\n for (const matches of byLegacyRef.values()) Object.freeze(matches);\n for (const matches of byFormatOptionRef.values()) Object.freeze(matches);\n return Object.freeze({ byLegacyRef, byFormatOptionRef });\n });\n\n Object.freeze(compiled);\n compiledSnapshotCache.set(snapshots, compiled);\n return compiled;\n}\n\n/**\n * Convert exact, catalog-authored `v1_format_ref` aliases into the existing\n * converter seam. Canonical-only declarations never become legacy aliases,\n * and matching is always owner + id + dimensional discriminators—never ID\n * alone. Duplicate aliases at the same precedence tier fail closed.\n */\nexport function legacyFormatConverterFromCatalogSnapshots(\n snapshots: readonly ProjectionCatalogSnapshot[] | undefined,\n fallback?: LegacyFormatConverter\n): LegacyFormatConverter | undefined {\n if (!snapshots || snapshots.length === 0) return fallback;\n const compiled = compileProjectionCatalogSnapshots(snapshots);\n return context => {\n const key = legacyRefKey(context.formatId);\n for (const snapshot of compiled) {\n const matches = snapshot.byLegacyRef.get(key) ?? [];\n if (matches.length > 1) {\n throw new Error('projection catalog contains ambiguous legacy aliases');\n }\n if (matches.length === 1) {\n return matches[0];\n }\n }\n return fallback?.(context);\n };\n}\n\n/**\n * Build the canonical → legacy half of an exact catalog-authored adapter.\n *\n * Only stable `format_option_id` references participate. Snapshot precedence\n * mirrors the forward projector, duplicate declarations at one tier fail\n * closed, and a multi-option selector is returned only when every option has\n * an exact mapping. This makes the resolver safe to use after canonical\n * objects have crossed a process or persistence boundary and lost the SDK's\n * private in-memory route metadata.\n */\nexport function canonicalFormatLegacyResolverFromCatalogSnapshots(\n snapshots: readonly ProjectionCatalogSnapshot[] | undefined,\n fallback?: CanonicalFormatLegacyResolver\n): CanonicalFormatLegacyResolver | undefined {\n if (!snapshots || snapshots.length === 0) return fallback;\n const compiled = compileProjectionCatalogSnapshots(snapshots);\n return context => {\n const refs = resolutionContextFormatOptionRefs(context);\n if (refs.length === 0) return fallback?.(context);\n\n const resolved: V1FormatId[] = [];\n for (const ref of refs) {\n const key = formatOptionRefKey(ref.format_option_id, ref.publisher_domain);\n let matched: CompiledReverseRoute | undefined;\n for (const snapshot of compiled) {\n const matches = snapshot.byFormatOptionRef.get(key) ?? [];\n if (matches.length > 1) {\n throw new Error('projection catalog contains ambiguous canonical format option aliases');\n }\n if (matches.length === 1) {\n matched = matches[0];\n break;\n }\n }\n if (!matched) return fallback?.(context);\n if (!routeMatchesContext(matched, ref, context)) return fallback?.(context);\n resolved.push(...matched.legacyRefs.map(item => ({ ...item })));\n }\n\n return [...new Map(resolved.map(ref => [legacyRefKey(ref), ref])).values()];\n };\n}\n\n/** Client configuration generated from one bidirectional, owner-scoped catalog. */\nexport interface ProjectionCatalogAdapters {\n projectionCatalogs: readonly ProjectionCatalogSnapshot[];\n canonicalFormatLegacyResolver: CanonicalFormatLegacyResolver;\n}\n\nfunction assertBidirectionalProjectionCatalogs(snapshots: readonly ProjectionCatalogSnapshot[]): void {\n const routeByCanonicalOption = new Map<string, string>();\n const canonicalOptionByLegacyRoute = new Map<string, string>();\n for (const snapshot of snapshots) {\n const declarationsAtThisTier = new Set<string>();\n for (const declaration of snapshot.formats) {\n if (\n declaration.canonical_formats_only === true ||\n !Array.isArray(declaration.v1_format_ref) ||\n declaration.v1_format_ref.length === 0\n ) {\n continue;\n }\n if (!isCanonicalV1Translatable(declaration.format_kind)) {\n throw new Error('bidirectional projection adapters cannot downgrade a canonical-only format kind');\n }\n const canonical = declarationWithoutLegacyIdentity(declaration, snapshot.publisher_domain);\n if (typeof canonical.format_option_id !== 'string' || canonical.format_option_id.length === 0) {\n throw new Error('bidirectional projection adapters require a stable format_option_id');\n }\n if (typeof canonical.publisher_domain !== 'string' || canonical.publisher_domain.length === 0) {\n throw new Error('bidirectional projection adapters require publisher-scoped format options');\n }\n const uniqueLegacyKeys = new Set(declaration.v1_format_ref.map(legacyRefKey));\n if (uniqueLegacyKeys.size !== 1) {\n throw new Error(\n 'bidirectional projection adapters require exactly one legacy route per canonical format option'\n );\n }\n const canonicalKey = formatOptionRefKey(canonical.format_option_id, canonical.publisher_domain);\n const legacyKey = [...uniqueLegacyKeys][0]!;\n const declarationKey = JSON.stringify([canonicalKey, legacyKey]);\n if (declarationsAtThisTier.has(declarationKey)) {\n throw new Error('bidirectional projection adapters contain duplicate declarations at one precedence tier');\n }\n declarationsAtThisTier.add(declarationKey);\n const existing = routeByCanonicalOption.get(canonicalKey);\n if (existing !== undefined && existing !== legacyKey) {\n throw new Error('bidirectional projection adapters contain conflicting reverse routes');\n }\n const existingCanonical = canonicalOptionByLegacyRoute.get(legacyKey);\n if (existingCanonical !== undefined && existingCanonical !== canonicalKey) {\n throw new Error('bidirectional projection adapters contain conflicting forward routes');\n }\n routeByCanonicalOption.set(canonicalKey, legacyKey);\n canonicalOptionByLegacyRoute.set(legacyKey, canonicalKey);\n }\n }\n}\n\n/**\n * Configure both discovery upgrade and legacy delivery downgrade from one\n * immutable catalog. Spread the result into `AgentClient` configuration.\n */\nexport function projectionAdaptersFromCatalogSnapshots(\n snapshots: readonly ProjectionCatalogSnapshot[],\n fallbackCanonicalResolver?: CanonicalFormatLegacyResolver\n): ProjectionCatalogAdapters {\n assertBidirectionalProjectionCatalogs(snapshots);\n const canonicalFormatLegacyResolver = canonicalFormatLegacyResolverFromCatalogSnapshots(\n snapshots,\n fallbackCanonicalResolver\n );\n if (!canonicalFormatLegacyResolver) {\n throw new Error('projection adapters require at least one catalog snapshot or a fallback resolver');\n }\n return { projectionCatalogs: snapshots, canonicalFormatLegacyResolver };\n}\n"],"mappings":"AAGA,SAAS,4BAA4B;AACrC,SAAS,iCAAiC;AAqC1C,MAAM,wBAAwB,oBAAI,QAA8D;AAGhG,SAAS,mBAAmB,OAAuB;AACjD,SAAO,qBAAqB,KAAK,KAAK;AACxC;AAEA,SAAS,aAAa,KAAyB;AAC7C,SAAO,KAAK,UAAU;AAAA,IACpB,mBAAmB,IAAI,SAAS;AAAA,IAChC,IAAI;AAAA,IACJ,IAAI,SAAS;AAAA,IACb,IAAI,UAAU;AAAA,IACd,IAAI,eAAe;AAAA,EACrB,CAAC;AACH;AAEA,SAAS,0BAA0B,OAAmC;AACpE,UAAQ,SAAS,IAAI,KAAK,EAAE,YAAY,EAAE,QAAQ,OAAO,EAAE;AAC7D;AAEA,SAAS,mBAAmB,gBAAwB,iBAAkC;AACpF,SAAO,KAAK,UAAU,CAAC,0BAA0B,eAAe,GAAG,cAAc,CAAC;AACpF;AAEA,SAAS,yBAAyB,OAAqF;AACrH,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAS;AACf,MAAI,OAAO,OAAO,qBAAqB,YAAY,OAAO,iBAAiB,WAAW,EAAG,QAAO;AAChG,MAAI,OAAO,UAAU,eAAgB,OAAO,UAAU,UAAa,OAAO,OAAO,qBAAqB,UAAW;AAC/G,QAAI,OAAO,OAAO,qBAAqB,YAAY,OAAO,iBAAiB,WAAW,EAAG,QAAO;AAChG,WAAO,EAAE,kBAAkB,OAAO,kBAAk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B,EAAE,CAAC;AACzC,YAAM,iBAAiB,KAAK,UAAU,CAAC,cAAc,SAAS,CAAC;AAC/D,UAAI,uBAAuB,IAAI,cAAc,GAAG;AAC9C,cAAM,IAAI,MAAM,yFAAyF;AAAA,MAC3G;AACA,6BAAuB,IAAI,cAAc;AACzC,YAAM,WAAW,uBAAuB,IAAI,YAAY;AACxD,UAAI,aAAa,UAAa,aAAa,WAAW;AACpD,cAAM,IAAI,MAAM,sEAAsE;AAAA,MACxF;AACA,YAAM,oBAAoB,6BAA6B,IAAI,SAAS;AACpE,UAAI,sBAAsB,UAAa,sBAAsB,cAAc;AACzE,cAAM,IAAI,MAAM,sEAAsE;AAAA,MACxF;AACA,6BAAuB,IAAI,cAAc,SAAS;AAClD,mCAA6B,IAAI,WAAW,YAAY;AAAA,IAC1D;AAAA,EACF;AACF;AAMO,SAAS,uCACd,WACA,2BAC2B;AAC3B,wCAAsC,SAAS;AAC/C,QAAM,gCAAgC;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AACA,MAAI,CAAC,+BAA+B;AAClC,UAAM,IAAI,MAAM,kFAAkF;AAAA,EACpG;AACA,SAAO,EAAE,oBAAoB,WAAW,8BAA8B;AACxE;","names":[]}
@@ -11,8 +11,10 @@
11
11
  * format projects to. This is the spec's resolution-order step 2 —
12
12
  * "seller-asserted on the v1 file" — applied to AAO-published v1 formats.
13
13
  *
14
- * Loader is keyed by `agent_url` (with trailing-slash normalization) +
15
- * `format_id.id`. Same scope as the v2→v1 registry: AAO catalog only.
14
+ * Primary lookup is keyed by `agent_url` (with trailing-slash normalization) +
15
+ * `format_id.id`. The inbound migration path may also use an exact bare ID
16
+ * when it has one unique meaning in the AAO catalog; the source owner is
17
+ * preserved for reverse delivery. Same scope as the v2→v1 registry: AAO catalog only.
16
18
  * Seller-specific catalogs (from a publisher's
17
19
  * `list_creative_formats`) are out of scope for the prototype — the
18
20
  * full 8.0 enablement would fetch them via an `AgentClient` injected
@@ -53,6 +55,15 @@ export interface V1FormatDefinition {
53
55
  description?: string;
54
56
  type?: string;
55
57
  accepts_parameters?: string[];
58
+ renders?: Array<{
59
+ role?: string;
60
+ dimensions?: {
61
+ width?: number;
62
+ height?: number;
63
+ [k: string]: unknown;
64
+ };
65
+ [k: string]: unknown;
66
+ }>;
56
67
  assets?: Array<{
57
68
  item_type?: string;
58
69
  asset_id?: string;
@@ -72,6 +83,8 @@ export interface V1FormatDefinition {
72
83
  interface CatalogIndex {
73
84
  /** Keyed by `<normalized-agent-url>::<id>` for O(1) lookup. */
74
85
  byKey: Map<string, V1FormatDefinition>;
86
+ /** Exact bare IDs with one AAO-published meaning; `null` marks a collision. */
87
+ byUniqueId: Map<string, V1FormatDefinition | null>;
75
88
  entries: V1FormatDefinition[];
76
89
  }
77
90
  /**
@@ -99,6 +112,14 @@ export declare function loadCatalog(explicitPath?: string): CatalogIndex;
99
112
  * match per the resolution order.
100
113
  */
101
114
  export declare function lookupV1Format(formatId: V1FormatId, explicitPath?: string): V1FormatDefinition | undefined;
115
+ /**
116
+ * Resolve an AAO-published bare ID only when the bundled catalog gives that
117
+ * ID exactly one meaning. This is an inbound legacy compatibility seam for
118
+ * sellers that copied an AAO standard ID but incorrectly emitted their own
119
+ * creative-agent URL. It never rewrites the source ref, so a later downgrade
120
+ * returns the seller's original owner tuple. Duplicate IDs fail closed.
121
+ */
122
+ export declare function lookupUniqueV1FormatById(id: string, explicitPath?: string): V1FormatDefinition | undefined;
102
123
  /** Test hook: reset the memoized catalog. */
103
124
  export declare function _resetCatalogCache(): void;
104
125
  /**
@@ -11,8 +11,10 @@
11
11
  * format projects to. This is the spec's resolution-order step 2 —
12
12
  * "seller-asserted on the v1 file" — applied to AAO-published v1 formats.
13
13
  *
14
- * Loader is keyed by `agent_url` (with trailing-slash normalization) +
15
- * `format_id.id`. Same scope as the v2→v1 registry: AAO catalog only.
14
+ * Primary lookup is keyed by `agent_url` (with trailing-slash normalization) +
15
+ * `format_id.id`. The inbound migration path may also use an exact bare ID
16
+ * when it has one unique meaning in the AAO catalog; the source owner is
17
+ * preserved for reverse delivery. Same scope as the v2→v1 registry: AAO catalog only.
16
18
  * Seller-specific catalogs (from a publisher's
17
19
  * `list_creative_formats`) are out of scope for the prototype — the
18
20
  * full 8.0 enablement would fetch them via an `AgentClient` injected
@@ -53,6 +55,15 @@ export interface V1FormatDefinition {
53
55
  description?: string;
54
56
  type?: string;
55
57
  accepts_parameters?: string[];
58
+ renders?: Array<{
59
+ role?: string;
60
+ dimensions?: {
61
+ width?: number;
62
+ height?: number;
63
+ [k: string]: unknown;
64
+ };
65
+ [k: string]: unknown;
66
+ }>;
56
67
  assets?: Array<{
57
68
  item_type?: string;
58
69
  asset_id?: string;
@@ -72,6 +83,8 @@ export interface V1FormatDefinition {
72
83
  interface CatalogIndex {
73
84
  /** Keyed by `<normalized-agent-url>::<id>` for O(1) lookup. */
74
85
  byKey: Map<string, V1FormatDefinition>;
86
+ /** Exact bare IDs with one AAO-published meaning; `null` marks a collision. */
87
+ byUniqueId: Map<string, V1FormatDefinition | null>;
75
88
  entries: V1FormatDefinition[];
76
89
  }
77
90
  /**
@@ -99,6 +112,14 @@ export declare function loadCatalog(explicitPath?: string): CatalogIndex;
99
112
  * match per the resolution order.
100
113
  */
101
114
  export declare function lookupV1Format(formatId: V1FormatId, explicitPath?: string): V1FormatDefinition | undefined;
115
+ /**
116
+ * Resolve an AAO-published bare ID only when the bundled catalog gives that
117
+ * ID exactly one meaning. This is an inbound legacy compatibility seam for
118
+ * sellers that copied an AAO standard ID but incorrectly emitted their own
119
+ * creative-agent URL. It never rewrites the source ref, so a later downgrade
120
+ * returns the seller's original owner tuple. Duplicate IDs fail closed.
121
+ */
122
+ export declare function lookupUniqueV1FormatById(id: string, explicitPath?: string): V1FormatDefinition | undefined;
102
123
  /** Test hook: reset the memoized catalog. */
103
124
  export declare function _resetCatalogCache(): void;
104
125
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../../src/lib/v2/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;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CA8C/D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAI1G;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAG1G;AAED,6CAA6C;AAC7C,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAI/F;AAED,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACpE,kBAAkB,GAAG,SAAS,CAkBhC"}
@@ -31,22 +31,32 @@ __export(catalog_exports, {
31
31
  _resetCatalogCache: () => _resetCatalogCache,
32
32
  findCatalogEntryByCanonicalAndSize: () => findCatalogEntryByCanonicalAndSize,
33
33
  loadCatalog: () => loadCatalog,
34
+ lookupUniqueV1FormatById: () => lookupUniqueV1FormatById,
34
35
  lookupV1Format: () => lookupV1Format,
35
36
  parseSizedIdTemplate: () => parseSizedIdTemplate
36
37
  });
37
38
  module.exports = __toCommonJS(catalog_exports);
38
39
  var import_fs = require("fs");
39
40
  var import_path = __toESM(require("path"));
40
- let cached = null;
41
+ var import_constants = require('./constants.js');
42
+ var import_resolve_agent_properties = require('../../discovery/resolve-agent-properties.js');
43
+ const cachedByPath = /* @__PURE__ */ new Map();
44
+ const AAO_LEGACY_AGENT_URL_ALIASES = /* @__PURE__ */ new Set([
45
+ // Early AAO reference implementations, including Optimera's deployed
46
+ // catalog, used the protocol root before creative.adcontextprotocol.org
47
+ // became the canonical format-agent host.
48
+ "https://adcontextprotocol.org/"
49
+ ]);
41
50
  function normalizeAgentUrl(u) {
42
- if (!u) return u;
43
- return u.endsWith("/") ? u : u + "/";
51
+ const canonical = (0, import_resolve_agent_properties.canonicalizeAgentUrl)(u);
52
+ if (canonical === null) return void 0;
53
+ return AAO_LEGACY_AGENT_URL_ALIASES.has(canonical) ? import_constants.AAO_CANONICAL_AGENT_URL : canonical;
44
54
  }
45
55
  function indexKey(agentUrl, id) {
46
- return `${normalizeAgentUrl(agentUrl)}::${id}`;
56
+ const normalized = normalizeAgentUrl(agentUrl);
57
+ return normalized === void 0 ? void 0 : `${normalized}::${id}`;
47
58
  }
48
59
  function loadCatalog(explicitPath) {
49
- if (cached) return cached;
50
60
  const candidates = explicitPath ? [explicitPath] : [
51
61
  import_path.default.join(__dirname, "aao-reference-formats.json"),
52
62
  import_path.default.join(
@@ -63,15 +73,22 @@ function loadCatalog(explicitPath) {
63
73
  ];
64
74
  for (const file of candidates) {
65
75
  if ((0, import_fs.existsSync)(file)) {
76
+ const cached = cachedByPath.get(file);
77
+ if (cached) return cached;
66
78
  const raw = JSON.parse((0, import_fs.readFileSync)(file, "utf-8"));
67
79
  const byKey = /* @__PURE__ */ new Map();
80
+ const byUniqueId = /* @__PURE__ */ new Map();
68
81
  for (const entry of raw) {
69
82
  if (entry?.format_id?.agent_url && entry?.format_id?.id) {
70
- byKey.set(indexKey(entry.format_id.agent_url, entry.format_id.id), entry);
83
+ const key = indexKey(entry.format_id.agent_url, entry.format_id.id);
84
+ if (key !== void 0) byKey.set(key, entry);
85
+ if (byUniqueId.has(entry.format_id.id)) byUniqueId.set(entry.format_id.id, null);
86
+ else byUniqueId.set(entry.format_id.id, entry);
71
87
  }
72
88
  }
73
- cached = { byKey, entries: raw };
74
- return cached;
89
+ const compiled = { byKey, byUniqueId, entries: raw };
90
+ cachedByPath.set(file, compiled);
91
+ return compiled;
75
92
  }
76
93
  }
77
94
  throw new Error(
@@ -80,10 +97,15 @@ function loadCatalog(explicitPath) {
80
97
  }
81
98
  function lookupV1Format(formatId, explicitPath) {
82
99
  const catalog = loadCatalog(explicitPath);
83
- return catalog.byKey.get(indexKey(formatId.agent_url, formatId.id));
100
+ const key = indexKey(formatId.agent_url, formatId.id);
101
+ return key === void 0 ? void 0 : catalog.byKey.get(key);
102
+ }
103
+ function lookupUniqueV1FormatById(id, explicitPath) {
104
+ const match = loadCatalog(explicitPath).byUniqueId.get(id);
105
+ return match ?? void 0;
84
106
  }
85
107
  function _resetCatalogCache() {
86
- cached = null;
108
+ cachedByPath.clear();
87
109
  }
88
110
  const SIZED_ID_RE = /^([a-z]+)_(\d+)x(\d+)_([a-z]+)$/;
89
111
  function parseSizedIdTemplate(id) {
@@ -94,6 +116,7 @@ function parseSizedIdTemplate(id) {
94
116
  function findCatalogEntryByCanonicalAndSize(canonical, width, height, agentUrl, options) {
95
117
  const catalog = loadCatalog(options?.explicitPath);
96
118
  const normalizedAgentUrl = normalizeAgentUrl(agentUrl);
119
+ if (normalizedAgentUrl === void 0) return void 0;
97
120
  for (const entry of catalog.entries) {
98
121
  if (entry.canonical?.kind !== canonical) continue;
99
122
  if (!entry.format_id?.id || !entry.format_id?.agent_url) continue;
@@ -114,6 +137,7 @@ function findCatalogEntryByCanonicalAndSize(canonical, width, height, agentUrl,
114
137
  _resetCatalogCache,
115
138
  findCatalogEntryByCanonicalAndSize,
116
139
  loadCatalog,
140
+ lookupUniqueV1FormatById,
117
141
  lookupV1Format,
118
142
  parseSizedIdTemplate
119
143
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/v2/projection/catalog.ts"],"sourcesContent":["/**\n * Loader for the AAO canonical-formats catalog (`reference-formats.json`).\n * Source of truth: `server/src/creative-agent/reference-formats.json` in\n * the adcontextprotocol/adcp repo — published by the AAO with the\n * `canonical` annotation on entries that have a v2 canonical-format\n * equivalent.\n *\n * The catalog is the v1→v2 direction's primary lookup table: each entry\n * is a v1 format definition, and 32 of the 57 entries in 3.1-beta carry\n * a `canonical: <kind>` annotation that names the v2 canonical the v1\n * format projects to. This is the spec's resolution-order step 2 —\n * \"seller-asserted on the v1 file\" — applied to AAO-published v1 formats.\n *\n * Loader is keyed by `agent_url` (with trailing-slash normalization) +\n * `format_id.id`. Same scope as the v2→v1 registry: AAO catalog only.\n * Seller-specific catalogs (from a publisher's\n * `list_creative_formats`) are out of scope for the prototype — the\n * full 8.0 enablement would fetch them via an `AgentClient` injected\n * by the auto-negotiation surface.\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport type { CanonicalFormatKind, V1FormatId } from './types';\n\n/**\n * Canonical projection reference (`canonical-projection-ref.json` in the\n * 3.1 spec). Always object-shaped: required `kind` + optional\n * `asset_source` + optional `slots_override`. Carries the v2 canonical-\n * format projection for a v1 catalog entry. Generative-AI v1 entries\n * use the rich form (`asset_source: 'agent_synthesized'` +\n * slots_override) so the v2 declaration produced from them carries the\n * generative contract; standard entries use the minimal form\n * (`{ kind }`) and inherit the canonical's default slots.\n */\nexport interface CanonicalProjectionRef {\n kind: CanonicalFormatKind;\n /** Narrows how the asset is produced (e.g., agent_synthesized for AI generation, buyer_uploaded for native). */\n asset_source?: 'agent_synthesized' | 'buyer_uploaded' | string;\n /** When set, replaces the canonical's default slots with these specifics. */\n slots_override?: Array<{\n asset_group_id: string;\n asset_type?: string;\n required?: boolean;\n [k: string]: unknown;\n }>;\n}\n\n/**\n * v1 format definition shape from `reference-formats.json`. Only carries\n * the fields the projection algorithm reads — name/description and the\n * full asset/macro/requirement bodies are passed through opaquely when\n * the caller wants them.\n */\nexport interface V1FormatDefinition {\n format_id: V1FormatId;\n name?: string;\n description?: string;\n type?: string;\n accepts_parameters?: string[];\n assets?: Array<{\n item_type?: string;\n asset_id?: string;\n required?: boolean;\n asset_type?: string;\n requirements?: Record<string, unknown>;\n }>;\n /**\n * v2 canonical projection. Always object-shaped per\n * `canonical-projection-ref.json`. Absent on entries that have no\n * v2 mapping yet (none at 3.1.0-beta.1 GA — the AAO catalog is\n * 100% annotated; absence is reserved for future un-blessed entries).\n */\n canonical?: CanonicalProjectionRef;\n // Pass-through for caller code that wants the rest.\n [k: string]: unknown;\n}\n\ninterface CatalogIndex {\n /** Keyed by `<normalized-agent-url>::<id>` for O(1) lookup. */\n byKey: Map<string, V1FormatDefinition>;\n entries: V1FormatDefinition[];\n}\n\nlet cached: CatalogIndex | null = null;\n\n/**\n * Normalize agent_url for indexing. Adds trailing slash when missing.\n * The AAO publishes the canonical form as `https://creative.adcontextprotocol.org/`\n * (with slash); some v2 fixtures use the no-slash form. Both refer to\n * the same agent; this lookup folds them.\n */\nfunction normalizeAgentUrl(u: string): string {\n if (!u) return u;\n return u.endsWith('/') ? u : u + '/';\n}\n\nfunction indexKey(agentUrl: string, id: string): string {\n return `${normalizeAgentUrl(agentUrl)}::${id}`;\n}\n\n/**\n * Load the catalog from a known path. Resolution order:\n *\n * 1. Caller-supplied `explicitPath` (test hook).\n * 2. Adjacent to the compiled loader — `dist/lib/v2/projection/\n * aao-reference-formats.json`. This is the path that ships in the\n * published npm tarball; `scripts/copy-v2-projection-catalog.ts`\n * vendors the file here during `build:lib`.\n * 3. Source-tree test fixture at\n * `test/lib/v2-projection-fixtures/aao-reference-formats.json`,\n * relative to the loader's source location. Used when running from\n * a source checkout (e.g., `tsx` / vitest) before `build:lib`.\n *\n * Memoized — catalog is small and immutable per spec version.\n *\n * @param explicitPath caller-supplied path; takes precedence over\n * fallback resolution.\n */\nexport function loadCatalog(explicitPath?: string): CatalogIndex {\n if (cached) return cached;\n\n const candidates = explicitPath\n ? [explicitPath]\n : [\n path.join(__dirname, 'aao-reference-formats.json'),\n path.join(\n __dirname,\n '..',\n '..',\n '..',\n '..',\n 'test',\n 'lib',\n 'v2-projection-fixtures',\n 'aao-reference-formats.json'\n ),\n ];\n\n for (const file of candidates) {\n if (existsSync(file)) {\n const raw = JSON.parse(readFileSync(file, 'utf-8')) as V1FormatDefinition[];\n const byKey = new Map<string, V1FormatDefinition>();\n for (const entry of raw) {\n if (entry?.format_id?.agent_url && entry?.format_id?.id) {\n byKey.set(indexKey(entry.format_id.agent_url, entry.format_id.id), entry);\n }\n }\n cached = { byKey, entries: raw };\n return cached;\n }\n }\n\n throw new Error(\n `AAO catalog (aao-reference-formats.json) not found. Looked in: ${candidates.join(', ')}. ` +\n `This indicates a corrupted @adcp/sdk install or an SDK packaging regression — ` +\n `please file an issue at https://github.com/adcontextprotocol/adcp-client/issues with ` +\n `your install method (npm/yarn/pnpm) and Node version. ` +\n `If you're working from a source checkout, run \\`npm run build:lib\\` first.`\n );\n}\n\n/**\n * Look up a v1 format definition by its format_id. Returns undefined\n * when not in the catalog — caller falls through to registry / structural\n * match per the resolution order.\n */\nexport function lookupV1Format(formatId: V1FormatId, explicitPath?: string): V1FormatDefinition | undefined {\n const catalog = loadCatalog(explicitPath);\n return catalog.byKey.get(indexKey(formatId.agent_url, formatId.id));\n}\n\n/** Test hook: reset the memoized catalog. */\nexport function _resetCatalogCache(): void {\n cached = null;\n}\n\n/**\n * Find a catalog entry matching `(canonical, width, height)` at the same\n * publisher domain as `agentUrl`. Used by the v2 → v1 multi-size fan-out:\n * when a v2 declaration says `sizes: [W1×H1, W2×H2, ...]` and the\n * seller-asserted `v1_format_ref` points at the catalog entry for one of\n * those sizes, the SDK can look up the entries for the OTHER sizes and\n * emit additional v1 format_ids — giving v1 buyers full size coverage\n * instead of just the rep.\n *\n * The catalog uses a stable id-pattern convention\n * (`<prefix>_<W>x<H>_<suffix>`) for per-size entries — image, html5, and\n * generative all follow it. This function parses ids matching that\n * pattern and matches on extracted dimensions, so the lookup is\n * dimensionally honest without requiring the spec to add explicit\n * width/height fields to catalog entries.\n *\n * Returns undefined when no matching entry exists at this publisher.\n * Caller falls back to the seller-asserted rep + lossy advisory.\n */\nconst SIZED_ID_RE = /^([a-z]+)_(\\d+)x(\\d+)_([a-z]+)$/;\n\n/**\n * Extract the `<prefix>_<W>x<H>_<suffix>` template from a sized catalog\n * id. Used by `findCatalogEntryByCanonicalAndSize` to filter fan-out\n * candidates to siblings of the seller-asserted ref. Multiple catalog\n * entries can share the same `canonical:` annotation but represent\n * different families (e.g., `image` is both `display_*_image` and\n * `display_*_generative`); without a suffix filter, fan-out would\n * collide families.\n */\nexport function parseSizedIdTemplate(id: string): { prefix: string; suffix: string } | undefined {\n const m = id.match(SIZED_ID_RE);\n if (!m) return undefined;\n return { prefix: m[1]!, suffix: m[4]! };\n}\n\nexport function findCatalogEntryByCanonicalAndSize(\n canonical: CanonicalFormatKind,\n width: number,\n height: number,\n agentUrl: string,\n options?: { prefix?: string; suffix?: string; explicitPath?: string }\n): V1FormatDefinition | undefined {\n const catalog = loadCatalog(options?.explicitPath);\n const normalizedAgentUrl = normalizeAgentUrl(agentUrl);\n for (const entry of catalog.entries) {\n if (entry.canonical?.kind !== canonical) continue;\n if (!entry.format_id?.id || !entry.format_id?.agent_url) continue;\n if (normalizeAgentUrl(entry.format_id.agent_url) !== normalizedAgentUrl) continue;\n const m = entry.format_id.id.match(SIZED_ID_RE);\n if (!m) continue;\n const [, prefix, wStr, hStr, suffix] = m;\n if (options?.prefix && prefix !== options.prefix) continue;\n if (options?.suffix && suffix !== options.suffix) continue;\n if (parseInt(wStr!, 10) === width && parseInt(hStr!, 10) === height) {\n return entry;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBA,gBAAyC;AACzC,kBAAiB;AA8DjB,IAAI,SAA8B;AAQlC,SAAS,kBAAkB,GAAmB;AAC5C,MAAI,CAAC,EAA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AI,QAAQ,EAAE,CAAC,EAAG;AACxC;AAEO,SAAS,mCACd,WACA,OACA,QACA,UACA,SACgC;AAChC,QAAM,UAAU,YAAY,SAAS,YAAY;AACjD,QAAM,qBAAqB,kBAAkB,QAAQ;AACrD,aAAW,SAAS,QAAQ,SAAS;AACnC,QAAI,MAAM,WAAW,SAAS,UAAW;AACzC,QAAI,CAAC,MAAM,WAAW,MAAM,CAAC,MAAM,WAAW,UAAW;AACzD,QAAI,kBAAkB,MAAM,UAAU,SAAS,MAAM,mBAAoB;AACzE,UAAM,IAAI,MAAM,UAAU,GAAG,MAAM,WAAW;AAC9C,QAAI,CAAC,EAAG;AACR,UAAM,CAAC,EAAE,QAAQ,MAAM,MAAM,MAAM,IAAI;AACvC,QAAI,SAAS,UAAU,WAAW,QAAQ,OAAQ;AAClD,QAAI,SAAS,UAAU,WAAW,QAAQ,OAAQ;AAClD,QAAI,SAAS,MAAO,EAAE,MAAM,SAAS,SAAS,MAAO,EAAE,MAAM,QAAQ;AACnE,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":["path"]}
1
+ {"version":3,"sources":["../../../../src/lib/v2/projection/catalog.ts"],"sourcesContent":["/**\n * Loader for the AAO canonical-formats catalog (`reference-formats.json`).\n * Source of truth: `server/src/creative-agent/reference-formats.json` in\n * the adcontextprotocol/adcp repo — published by the AAO with the\n * `canonical` annotation on entries that have a v2 canonical-format\n * equivalent.\n *\n * The catalog is the v1→v2 direction's primary lookup table: each entry\n * is a v1 format definition, and 32 of the 57 entries in 3.1-beta carry\n * a `canonical: <kind>` annotation that names the v2 canonical the v1\n * format projects to. This is the spec's resolution-order step 2 —\n * \"seller-asserted on the v1 file\" — applied to AAO-published v1 formats.\n *\n * Primary lookup is keyed by `agent_url` (with trailing-slash normalization) +\n * `format_id.id`. The inbound migration path may also use an exact bare ID\n * when it has one unique meaning in the AAO catalog; the source owner is\n * preserved for reverse delivery. Same scope as the v2→v1 registry: AAO catalog only.\n * Seller-specific catalogs (from a publisher's\n * `list_creative_formats`) are out of scope for the prototype — the\n * full 8.0 enablement would fetch them via an `AgentClient` injected\n * by the auto-negotiation surface.\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport type { CanonicalFormatKind, V1FormatId } from './types';\nimport { AAO_CANONICAL_AGENT_URL } from './constants';\nimport { canonicalizeAgentUrl } from '../../discovery/resolve-agent-properties';\n\n/**\n * Canonical projection reference (`canonical-projection-ref.json` in the\n * 3.1 spec). Always object-shaped: required `kind` + optional\n * `asset_source` + optional `slots_override`. Carries the v2 canonical-\n * format projection for a v1 catalog entry. Generative-AI v1 entries\n * use the rich form (`asset_source: 'agent_synthesized'` +\n * slots_override) so the v2 declaration produced from them carries the\n * generative contract; standard entries use the minimal form\n * (`{ kind }`) and inherit the canonical's default slots.\n */\nexport interface CanonicalProjectionRef {\n kind: CanonicalFormatKind;\n /** Narrows how the asset is produced (e.g., agent_synthesized for AI generation, buyer_uploaded for native). */\n asset_source?: 'agent_synthesized' | 'buyer_uploaded' | string;\n /** When set, replaces the canonical's default slots with these specifics. */\n slots_override?: Array<{\n asset_group_id: string;\n asset_type?: string;\n required?: boolean;\n [k: string]: unknown;\n }>;\n}\n\n/**\n * v1 format definition shape from `reference-formats.json`. Only carries\n * the fields the projection algorithm reads — name/description and the\n * full asset/macro/requirement bodies are passed through opaquely when\n * the caller wants them.\n */\nexport interface V1FormatDefinition {\n format_id: V1FormatId;\n name?: string;\n description?: string;\n type?: string;\n accepts_parameters?: string[];\n renders?: Array<{\n role?: string;\n dimensions?: {\n width?: number;\n height?: number;\n [k: string]: unknown;\n };\n [k: string]: unknown;\n }>;\n assets?: Array<{\n item_type?: string;\n asset_id?: string;\n required?: boolean;\n asset_type?: string;\n requirements?: Record<string, unknown>;\n }>;\n /**\n * v2 canonical projection. Always object-shaped per\n * `canonical-projection-ref.json`. Absent on entries that have no\n * v2 mapping yet (none at 3.1.0-beta.1 GA — the AAO catalog is\n * 100% annotated; absence is reserved for future un-blessed entries).\n */\n canonical?: CanonicalProjectionRef;\n // Pass-through for caller code that wants the rest.\n [k: string]: unknown;\n}\n\ninterface CatalogIndex {\n /** Keyed by `<normalized-agent-url>::<id>` for O(1) lookup. */\n byKey: Map<string, V1FormatDefinition>;\n /** Exact bare IDs with one AAO-published meaning; `null` marks a collision. */\n byUniqueId: Map<string, V1FormatDefinition | null>;\n entries: V1FormatDefinition[];\n}\n\nconst cachedByPath = new Map<string, CatalogIndex>();\n\n/**\n * Normalize agent_url for indexing. Adds trailing slash when missing and\n * folds only explicitly known historical AAO hosts into the current host.\n * The AAO publishes the canonical form as `https://creative.adcontextprotocol.org/`\n * (with slash); some v2 fixtures use the no-slash form. Both refer to\n * the same agent; this lookup folds them. This composite-identity lookup\n * never ignores ownership. The separate unique-bare-ID compatibility lookup\n * is fail-closed on collisions and never changes this index.\n */\nconst AAO_LEGACY_AGENT_URL_ALIASES = new Set([\n // Early AAO reference implementations, including Optimera's deployed\n // catalog, used the protocol root before creative.adcontextprotocol.org\n // became the canonical format-agent host.\n 'https://adcontextprotocol.org/',\n]);\n\nfunction normalizeAgentUrl(u: string): string | undefined {\n const canonical = canonicalizeAgentUrl(u);\n if (canonical === null) return undefined;\n return AAO_LEGACY_AGENT_URL_ALIASES.has(canonical) ? AAO_CANONICAL_AGENT_URL : canonical;\n}\n\nfunction indexKey(agentUrl: string, id: string): string | undefined {\n const normalized = normalizeAgentUrl(agentUrl);\n return normalized === undefined ? undefined : `${normalized}::${id}`;\n}\n\n/**\n * Load the catalog from a known path. Resolution order:\n *\n * 1. Caller-supplied `explicitPath` (test hook).\n * 2. Adjacent to the compiled loader — `dist/lib/v2/projection/\n * aao-reference-formats.json`. This is the path that ships in the\n * published npm tarball; `scripts/copy-v2-projection-catalog.ts`\n * vendors the file here during `build:lib`.\n * 3. Source-tree test fixture at\n * `test/lib/v2-projection-fixtures/aao-reference-formats.json`,\n * relative to the loader's source location. Used when running from\n * a source checkout (e.g., `tsx` / vitest) before `build:lib`.\n *\n * Memoized — catalog is small and immutable per spec version.\n *\n * @param explicitPath caller-supplied path; takes precedence over\n * fallback resolution.\n */\nexport function loadCatalog(explicitPath?: string): CatalogIndex {\n const candidates = explicitPath\n ? [explicitPath]\n : [\n path.join(__dirname, 'aao-reference-formats.json'),\n path.join(\n __dirname,\n '..',\n '..',\n '..',\n '..',\n 'test',\n 'lib',\n 'v2-projection-fixtures',\n 'aao-reference-formats.json'\n ),\n ];\n\n for (const file of candidates) {\n if (existsSync(file)) {\n const cached = cachedByPath.get(file);\n if (cached) return cached;\n const raw = JSON.parse(readFileSync(file, 'utf-8')) as V1FormatDefinition[];\n const byKey = new Map<string, V1FormatDefinition>();\n const byUniqueId = new Map<string, V1FormatDefinition | null>();\n for (const entry of raw) {\n if (entry?.format_id?.agent_url && entry?.format_id?.id) {\n const key = indexKey(entry.format_id.agent_url, entry.format_id.id);\n if (key !== undefined) byKey.set(key, entry);\n if (byUniqueId.has(entry.format_id.id)) byUniqueId.set(entry.format_id.id, null);\n else byUniqueId.set(entry.format_id.id, entry);\n }\n }\n const compiled = { byKey, byUniqueId, entries: raw };\n cachedByPath.set(file, compiled);\n return compiled;\n }\n }\n\n throw new Error(\n `AAO catalog (aao-reference-formats.json) not found. Looked in: ${candidates.join(', ')}. ` +\n `This indicates a corrupted @adcp/sdk install or an SDK packaging regression — ` +\n `please file an issue at https://github.com/adcontextprotocol/adcp-client/issues with ` +\n `your install method (npm/yarn/pnpm) and Node version. ` +\n `If you're working from a source checkout, run \\`npm run build:lib\\` first.`\n );\n}\n\n/**\n * Look up a v1 format definition by its format_id. Returns undefined\n * when not in the catalog — caller falls through to registry / structural\n * match per the resolution order.\n */\nexport function lookupV1Format(formatId: V1FormatId, explicitPath?: string): V1FormatDefinition | undefined {\n const catalog = loadCatalog(explicitPath);\n const key = indexKey(formatId.agent_url, formatId.id);\n return key === undefined ? undefined : catalog.byKey.get(key);\n}\n\n/**\n * Resolve an AAO-published bare ID only when the bundled catalog gives that\n * ID exactly one meaning. This is an inbound legacy compatibility seam for\n * sellers that copied an AAO standard ID but incorrectly emitted their own\n * creative-agent URL. It never rewrites the source ref, so a later downgrade\n * returns the seller's original owner tuple. Duplicate IDs fail closed.\n */\nexport function lookupUniqueV1FormatById(id: string, explicitPath?: string): V1FormatDefinition | undefined {\n const match = loadCatalog(explicitPath).byUniqueId.get(id);\n return match ?? undefined;\n}\n\n/** Test hook: reset the memoized catalog. */\nexport function _resetCatalogCache(): void {\n cachedByPath.clear();\n}\n\n/**\n * Find a catalog entry matching `(canonical, width, height)` at the same\n * publisher domain as `agentUrl`. Used by the v2 → v1 multi-size fan-out:\n * when a v2 declaration says `sizes: [W1×H1, W2×H2, ...]` and the\n * seller-asserted `v1_format_ref` points at the catalog entry for one of\n * those sizes, the SDK can look up the entries for the OTHER sizes and\n * emit additional v1 format_ids — giving v1 buyers full size coverage\n * instead of just the rep.\n *\n * The catalog uses a stable id-pattern convention\n * (`<prefix>_<W>x<H>_<suffix>`) for per-size entries — image, html5, and\n * generative all follow it. This function parses ids matching that\n * pattern and matches on extracted dimensions, so the lookup is\n * dimensionally honest without requiring the spec to add explicit\n * width/height fields to catalog entries.\n *\n * Returns undefined when no matching entry exists at this publisher.\n * Caller falls back to the seller-asserted rep + lossy advisory.\n */\nconst SIZED_ID_RE = /^([a-z]+)_(\\d+)x(\\d+)_([a-z]+)$/;\n\n/**\n * Extract the `<prefix>_<W>x<H>_<suffix>` template from a sized catalog\n * id. Used by `findCatalogEntryByCanonicalAndSize` to filter fan-out\n * candidates to siblings of the seller-asserted ref. Multiple catalog\n * entries can share the same `canonical:` annotation but represent\n * different families (e.g., `image` is both `display_*_image` and\n * `display_*_generative`); without a suffix filter, fan-out would\n * collide families.\n */\nexport function parseSizedIdTemplate(id: string): { prefix: string; suffix: string } | undefined {\n const m = id.match(SIZED_ID_RE);\n if (!m) return undefined;\n return { prefix: m[1]!, suffix: m[4]! };\n}\n\nexport function findCatalogEntryByCanonicalAndSize(\n canonical: CanonicalFormatKind,\n width: number,\n height: number,\n agentUrl: string,\n options?: { prefix?: string; suffix?: string; explicitPath?: string }\n): V1FormatDefinition | undefined {\n const catalog = loadCatalog(options?.explicitPath);\n const normalizedAgentUrl = normalizeAgentUrl(agentUrl);\n if (normalizedAgentUrl === undefined) return undefined;\n for (const entry of catalog.entries) {\n if (entry.canonical?.kind !== canonical) continue;\n if (!entry.format_id?.id || !entry.format_id?.agent_url) continue;\n if (normalizeAgentUrl(entry.format_id.agent_url) !== normalizedAgentUrl) continue;\n const m = entry.format_id.id.match(SIZED_ID_RE);\n if (!m) continue;\n const [, prefix, wStr, hStr, suffix] = m;\n if (options?.prefix && prefix !== options.prefix) continue;\n if (options?.suffix && suffix !== options.suffix) continue;\n if (parseInt(wStr!, 10) === width && parseInt(hStr!, 10) === height) {\n return entry;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,gBAAyC;AACzC,kBAAiB;AAEjB,uBAAwC;AACxC,sCAAqC;AAwErC,MAAM,eAAe,oBAAI,IAA0B;AAWnD,MAAM,+BAA+B,oBAAI,IAAI;AAAA;AAAA;AAAA;AAAA,EAI3C;AACF,CAAC;AAED,SAAS,kBAAkB,GAA+B;AACxD,QAAM,gBAAY,sDAAqB,CAAC;AACxC,MAAI,cAAc,KAAM,QAAO;AAC/B,SAAO,6BAA6B,IAAI,SAAS,IAAI,2CAA0B;AACjF;AAEA,SAAS,SAAS,UAAkB,IAAgC;AAClE,QAAM,aAAa,kBAAkB,QAAQ;AAC7C,SAAO,eAAe,SAAY,SAAY,GAAG,UAAU,KAAK,EAAE;AACpE;AAoBO,SAAS,YAAY,cAAqC;AAC/D,QAAM,aAAa,eACf,CAAC,YAAY,IACb;AAAA,IACE,YAAAA,QAAK,KAAK,WAAW,4BAA4B;AAAA,IACjD,YAAAA,QAAK;AAAA,MACH;AAAA,MACA;AAAA,M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