@adcp/sdk 16.5.0 → 16.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/dist/lib/adapters/version/3.0/brand-fields.d.mts +7 -1
  2. package/dist/lib/adapters/version/3.0/brand-fields.d.ts +7 -1
  3. package/dist/lib/adapters/version/3.0/brand-fields.js +139 -3
  4. package/dist/lib/adapters/version/3.0/brand-fields.mjs +136 -2
  5. package/dist/lib/adapters/version/3.0/index.js +6 -0
  6. package/dist/lib/adapters/version/3.0/index.mjs +7 -1
  7. package/dist/lib/adapters/version/3.1/bidding.js +1 -1
  8. package/dist/lib/adapters/version/3.1/bidding.mjs +1 -1
  9. package/dist/lib/adapters/version/types.d.mts +5 -0
  10. package/dist/lib/adapters/version/types.d.ts +5 -0
  11. package/dist/lib/canonical-references/index.js +2 -0
  12. package/dist/lib/canonical-references/index.mjs +2 -0
  13. package/dist/lib/client/account-changes.d.mts +3 -1
  14. package/dist/lib/client/account-changes.d.ts +3 -1
  15. package/dist/lib/client/account-changes.js +22 -2
  16. package/dist/lib/client/account-changes.mjs +22 -2
  17. package/dist/lib/conformance/oracle.js +3 -2
  18. package/dist/lib/conformance/oracle.mjs +3 -2
  19. package/dist/lib/core/AgentClient.d.mts +165 -1
  20. package/dist/lib/core/AgentClient.d.ts +165 -1
  21. package/dist/lib/core/AgentClient.js +446 -8
  22. package/dist/lib/core/AgentClient.mjs +446 -8
  23. package/dist/lib/core/ConversationTypes.d.mts +8 -0
  24. package/dist/lib/core/ConversationTypes.d.ts +8 -0
  25. package/dist/lib/core/ProtocolResponseParser.d.mts +1 -1
  26. package/dist/lib/core/ProtocolResponseParser.d.ts +1 -1
  27. package/dist/lib/core/ProtocolResponseParser.js +28 -18
  28. package/dist/lib/core/ProtocolResponseParser.mjs +11 -1
  29. package/dist/lib/core/ResponseValidator.js +1 -1
  30. package/dist/lib/core/ResponseValidator.mjs +1 -1
  31. package/dist/lib/core/SingleAgentClient.d.mts +116 -6
  32. package/dist/lib/core/SingleAgentClient.d.ts +116 -6
  33. package/dist/lib/core/SingleAgentClient.js +556 -84
  34. package/dist/lib/core/SingleAgentClient.mjs +545 -72
  35. package/dist/lib/core/TaskExecutor.d.mts +7 -0
  36. package/dist/lib/core/TaskExecutor.d.ts +7 -0
  37. package/dist/lib/core/TaskExecutor.js +23 -8
  38. package/dist/lib/core/TaskExecutor.mjs +23 -8
  39. package/dist/lib/core/task-status.d.mts +2 -0
  40. package/dist/lib/core/task-status.d.ts +2 -0
  41. package/dist/lib/core/task-status.js +11 -2
  42. package/dist/lib/core/task-status.mjs +9 -1
  43. package/dist/lib/errors/index.d.mts +22 -0
  44. package/dist/lib/errors/index.d.ts +22 -0
  45. package/dist/lib/errors/index.js +43 -0
  46. package/dist/lib/errors/index.mjs +42 -0
  47. package/dist/lib/identity-3.3/trust.d.mts +1 -4
  48. package/dist/lib/identity-3.3/trust.d.ts +1 -4
  49. package/dist/lib/identity-3.3/trust.js +34 -21
  50. package/dist/lib/identity-3.3/trust.mjs +34 -21
  51. package/dist/lib/identity-3.3/validation.js +5 -3
  52. package/dist/lib/identity-3.3/validation.mjs +6 -4
  53. package/dist/lib/index.d.mts +8 -54
  54. package/dist/lib/index.d.ts +8 -54
  55. package/dist/lib/index.js +15 -0
  56. package/dist/lib/index.mjs +11 -0
  57. package/dist/lib/media-buy/action-assessment.js +29 -3
  58. package/dist/lib/media-buy/action-assessment.mjs +32 -4
  59. package/dist/lib/media-buy/action-contracts.d.mts +3 -0
  60. package/dist/lib/media-buy/action-contracts.d.ts +3 -0
  61. package/dist/lib/media-buy/action-contracts.js +24 -1
  62. package/dist/lib/media-buy/action-contracts.mjs +22 -1
  63. package/dist/lib/media-buy/compatibility.js +6 -1
  64. package/dist/lib/media-buy/compatibility.mjs +6 -1
  65. package/dist/lib/media-buy/preflight.js +1 -1
  66. package/dist/lib/media-buy/preflight.mjs +3 -2
  67. package/dist/lib/media-buy/types.d.mts +6 -1
  68. package/dist/lib/media-buy/types.d.ts +6 -1
  69. package/dist/lib/protocols/mcp-modern.d.mts +2 -0
  70. package/dist/lib/protocols/mcp-modern.d.ts +2 -0
  71. package/dist/lib/protocols/mcp-modern.js +31 -5
  72. package/dist/lib/protocols/mcp-modern.mjs +31 -5
  73. package/dist/lib/protocols/mcp-scope.d.mts +6 -1
  74. package/dist/lib/protocols/mcp-scope.d.ts +6 -1
  75. package/dist/lib/protocols/mcp-scope.js +25 -3
  76. package/dist/lib/protocols/mcp-scope.mjs +24 -3
  77. package/dist/lib/protocols/mcp.js +12 -6
  78. package/dist/lib/protocols/mcp.mjs +13 -6
  79. package/dist/lib/reporting/inspection.js +1 -0
  80. package/dist/lib/reporting/inspection.mjs +1 -0
  81. package/dist/lib/schemas/browser.d.mts +2 -0
  82. package/dist/lib/schemas/browser.d.ts +2 -0
  83. package/dist/lib/schemas/browser.js +3 -0
  84. package/dist/lib/schemas/browser.mjs +2 -0
  85. package/dist/lib/schemas/index.d.mts +5 -2
  86. package/dist/lib/schemas/index.d.ts +5 -2
  87. package/dist/lib/schemas/index.js +5 -0
  88. package/dist/lib/schemas/index.mjs +4 -0
  89. package/dist/lib/server/account-response-identity.d.mts +17 -0
  90. package/dist/lib/server/account-response-identity.d.ts +17 -0
  91. package/dist/lib/server/account-response-identity.js +52 -0
  92. package/dist/lib/server/account-response-identity.mjs +28 -0
  93. package/dist/lib/server/account-sync-contract.js +1 -0
  94. package/dist/lib/server/account-sync-contract.mjs +1 -0
  95. package/dist/lib/server/create-adcp-server.js +32 -19
  96. package/dist/lib/server/create-adcp-server.mjs +36 -12
  97. package/dist/lib/server/decisioning/account.d.mts +13 -6
  98. package/dist/lib/server/decisioning/account.d.ts +13 -6
  99. package/dist/lib/server/decisioning/account.js +37 -15
  100. package/dist/lib/server/decisioning/account.mjs +37 -15
  101. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +5 -5
  102. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +5 -5
  103. package/dist/lib/server/decisioning/runtime/from-platform.js +6 -6
  104. package/dist/lib/server/decisioning/runtime/from-platform.mjs +6 -6
  105. package/dist/lib/server/index.d.mts +1 -1
  106. package/dist/lib/server/index.d.ts +1 -1
  107. package/dist/lib/server/index.js +2 -0
  108. package/dist/lib/server/index.mjs +2 -0
  109. package/dist/lib/server/media-buy-action-resolver.d.mts +3 -0
  110. package/dist/lib/server/media-buy-action-resolver.d.ts +3 -0
  111. package/dist/lib/server/media-buy-action-resolver.js +32 -0
  112. package/dist/lib/server/media-buy-action-resolver.mjs +32 -0
  113. package/dist/lib/server/media-buy-store.d.mts +26 -12
  114. package/dist/lib/server/media-buy-store.d.ts +26 -12
  115. package/dist/lib/server/media-buy-store.js +69 -21
  116. package/dist/lib/server/media-buy-store.mjs +69 -21
  117. package/dist/lib/server/responses.js +9 -1
  118. package/dist/lib/server/responses.mjs +9 -1
  119. package/dist/lib/server/state-machine.d.mts +10 -11
  120. package/dist/lib/server/state-machine.d.ts +10 -11
  121. package/dist/lib/server/state-machine.js +20 -5
  122. package/dist/lib/server/state-machine.mjs +19 -5
  123. package/dist/lib/signing/agent-fetch.d.mts +1 -1
  124. package/dist/lib/signing/agent-fetch.d.ts +1 -1
  125. package/dist/lib/signing/agent-fetch.js +3 -3
  126. package/dist/lib/signing/agent-fetch.mjs +3 -3
  127. package/dist/lib/testing/client.d.mts +1 -0
  128. package/dist/lib/testing/client.d.ts +1 -0
  129. package/dist/lib/testing/client.js +6 -5
  130. package/dist/lib/testing/client.mjs +6 -5
  131. package/dist/lib/testing/storyboard/canonical-format-satisfaction.js +60 -14
  132. package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +60 -14
  133. package/dist/lib/testing/storyboard/compliance.d.mts +2 -5
  134. package/dist/lib/testing/storyboard/compliance.d.ts +2 -5
  135. package/dist/lib/testing/storyboard/compliance.js +62 -13
  136. package/dist/lib/testing/storyboard/compliance.mjs +63 -14
  137. package/dist/lib/testing/storyboard/context.d.mts +13 -3
  138. package/dist/lib/testing/storyboard/context.d.ts +13 -3
  139. package/dist/lib/testing/storyboard/context.js +15 -10
  140. package/dist/lib/testing/storyboard/context.mjs +15 -10
  141. package/dist/lib/testing/storyboard/default-invariants.js +10 -8
  142. package/dist/lib/testing/storyboard/default-invariants.mjs +11 -9
  143. package/dist/lib/testing/storyboard/request-signing/vector-loader.d.mts +2 -0
  144. package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts +2 -0
  145. package/dist/lib/testing/storyboard/request-signing/vector-loader.js +11 -0
  146. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +10 -0
  147. package/dist/lib/testing/storyboard/runner.js +23 -10
  148. package/dist/lib/testing/storyboard/runner.mjs +23 -10
  149. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  150. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  151. package/dist/lib/testing/storyboard/validations.js +4 -1
  152. package/dist/lib/testing/storyboard/validations.mjs +4 -1
  153. package/dist/lib/testing/test-controller.js +3 -0
  154. package/dist/lib/testing/test-controller.mjs +3 -0
  155. package/dist/lib/types/asset-instances.d.mts +1 -1
  156. package/dist/lib/types/asset-instances.d.ts +1 -1
  157. package/dist/lib/types/index.d.mts +5 -0
  158. package/dist/lib/types/index.d.ts +5 -0
  159. package/dist/lib/types/index.js +6 -1
  160. package/dist/lib/types/index.mjs +4 -1
  161. package/dist/lib/types/inline-enums.generated.d.mts +30 -4
  162. package/dist/lib/types/inline-enums.generated.d.ts +30 -4
  163. package/dist/lib/types/inline-enums.generated.js +41 -2
  164. package/dist/lib/types/inline-enums.generated.mjs +28 -2
  165. package/dist/lib/types/media-buy-delivery-report.d.mts +4 -0
  166. package/dist/lib/types/media-buy-delivery-report.d.ts +4 -0
  167. package/dist/lib/types/media-buy-delivery-report.js +16 -0
  168. package/dist/lib/types/media-buy-delivery-report.mjs +0 -0
  169. package/dist/lib/types/schemas.generated.d.ts +20 -69
  170. package/dist/lib/types/schemas.generated.js +29 -46
  171. package/dist/lib/types/schemas.generated.mjs +29 -46
  172. package/dist/lib/types/targeting-keys.generated.d.mts +4 -0
  173. package/dist/lib/types/targeting-keys.generated.d.ts +4 -0
  174. package/dist/lib/types/targeting-keys.generated.js +105 -0
  175. package/dist/lib/types/targeting-keys.generated.mjs +80 -0
  176. package/dist/lib/utils/adcp-version-config.js +5 -2
  177. package/dist/lib/utils/adcp-version-config.mjs +5 -2
  178. package/dist/lib/utils/envelope-status-compat.d.mts +18 -1
  179. package/dist/lib/utils/envelope-status-compat.d.ts +18 -1
  180. package/dist/lib/utils/envelope-status-compat.js +11 -5
  181. package/dist/lib/utils/envelope-status-compat.mjs +11 -5
  182. package/dist/lib/utils/response-unwrapper.js +18 -10
  183. package/dist/lib/utils/response-unwrapper.mjs +18 -10
  184. package/dist/lib/v2/format-schema/resolver.js +1 -1
  185. package/dist/lib/v2/format-schema/resolver.mjs +1 -1
  186. package/dist/lib/v2/projection/creative-delivery.js +123 -30
  187. package/dist/lib/v2/projection/creative-delivery.mjs +127 -30
  188. package/dist/lib/v2/projection/index.d.mts +1 -0
  189. package/dist/lib/v2/projection/index.d.ts +1 -0
  190. package/dist/lib/v2/projection/index.js +3 -0
  191. package/dist/lib/v2/projection/index.mjs +2 -0
  192. package/dist/lib/v2/projection/legacy-metadata.d.mts +19 -0
  193. package/dist/lib/v2/projection/legacy-metadata.d.ts +19 -0
  194. package/dist/lib/v2/projection/legacy-metadata.js +91 -0
  195. package/dist/lib/v2/projection/legacy-metadata.mjs +86 -0
  196. package/dist/lib/validation/compact-schema.d.mts +27 -0
  197. package/dist/lib/validation/compact-schema.d.ts +27 -0
  198. package/dist/lib/validation/compact-schema.js +276 -0
  199. package/dist/lib/validation/compact-schema.mjs +250 -0
  200. package/dist/lib/validation/media-buy-delivery-report.d.mts +8 -0
  201. package/dist/lib/validation/media-buy-delivery-report.d.ts +8 -0
  202. package/dist/lib/validation/media-buy-delivery-report.js +31 -0
  203. package/dist/lib/validation/media-buy-delivery-report.mjs +7 -0
  204. package/dist/lib/validation/schema-diagnostic-origins.d.mts +21 -0
  205. package/dist/lib/validation/schema-diagnostic-origins.d.ts +21 -0
  206. package/dist/lib/validation/schema-diagnostic-origins.js +193 -0
  207. package/dist/lib/validation/schema-diagnostic-origins.mjs +169 -0
  208. package/dist/lib/validation/schema-loader.js +86 -16
  209. package/dist/lib/validation/schema-loader.mjs +82 -16
  210. package/dist/lib/validation/schema-validator.d.mts +10 -19
  211. package/dist/lib/validation/schema-validator.d.ts +10 -19
  212. package/dist/lib/validation/schema-validator.js +136 -43
  213. package/dist/lib/validation/schema-validator.mjs +140 -44
  214. package/dist/lib/version.d.mts +3 -3
  215. package/dist/lib/version.d.ts +3 -3
  216. package/dist/lib/version.js +3 -3
  217. package/dist/lib/version.mjs +3 -3
  218. package/dist/lib/webhooks/index.d.mts +3 -0
  219. package/dist/lib/webhooks/index.d.ts +3 -0
  220. package/dist/lib/webhooks/index.js +3 -0
  221. package/dist/lib/webhooks/index.mjs +2 -0
  222. package/dist/lib/webhooks/media-buy-delivery.d.mts +43 -0
  223. package/dist/lib/webhooks/media-buy-delivery.d.ts +43 -0
  224. package/dist/lib/webhooks/media-buy-delivery.js +119 -0
  225. package/dist/lib/webhooks/media-buy-delivery.mjs +94 -0
  226. package/docs/TYPE-SUMMARY.md +2 -2
  227. package/docs/guides/BUILD-AN-AGENT.md +9 -1
  228. package/docs/guides/DELIVERY-WEBHOOK-PARSING.md +135 -0
  229. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +15 -0
  230. package/docs/guides/TYPED-CLIENT-TOOLS.md +49 -0
  231. package/docs/llms.txt +3 -3
  232. package/docs/migration-14.x-rc-worksheet.md +4 -4
  233. package/docs/migration-6.6-to-6.7.md +14 -0
  234. package/docs/migration-account-change-feed.md +19 -0
  235. package/docs/releases/sdk-16.6-adoption-fixes.md +33 -0
  236. package/package.json +2 -2
@@ -0,0 +1,169 @@
1
+ function object(value) {
2
+ return value !== null && typeof value === "object";
3
+ }
4
+ function schemaPathLiterals(source) {
5
+ const paths = [];
6
+ const stringEnd = (start) => {
7
+ const quote = source[start];
8
+ for (let index = start + 1; index < source.length; index++) {
9
+ if (source[index] === "\\") index++;
10
+ else if (source[index] === quote) return index + 1;
11
+ }
12
+ return -1;
13
+ };
14
+ for (let index = 0; index < source.length; ) {
15
+ const start = index;
16
+ let key;
17
+ if (source[index] === '"' || source[index] === "'") {
18
+ index = stringEnd(index);
19
+ if (index < 0) return void 0;
20
+ try {
21
+ key = JSON.parse(source.slice(start, index));
22
+ } catch {
23
+ }
24
+ } else if (/[A-Za-z_$]/.test(source[index])) {
25
+ while (index < source.length && /[\w$]/.test(source[index])) index++;
26
+ key = source.slice(start, index);
27
+ } else if (source.startsWith("//", index)) {
28
+ index = source.indexOf("\n", index + 2);
29
+ if (index < 0) break;
30
+ } else if (source.startsWith("/*", index)) {
31
+ index = source.indexOf("*/", index + 2);
32
+ if (index < 0) return void 0;
33
+ index += 2;
34
+ } else {
35
+ if (source[index] === "`") return void 0;
36
+ if (source[index] === "/") {
37
+ const pointerEscape = source.startsWith("/~/g", index) ? "/~/g" : source.startsWith("/\\//g", index) ? "/\\//g" : void 0;
38
+ if (pointerEscape && /\.replace\(\s*$/.test(source.slice(0, index))) {
39
+ index += pointerEscape.length;
40
+ continue;
41
+ }
42
+ const previous = source.slice(0, index).match(/(?:^|[^\w$])(data\d*)\s*$/);
43
+ if (!previous) return void 0;
44
+ }
45
+ index++;
46
+ }
47
+ if (key !== "schemaPath") continue;
48
+ let valueStart = index;
49
+ while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
50
+ if (source[valueStart] !== ":") continue;
51
+ valueStart++;
52
+ while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
53
+ if (source[valueStart] !== '"') return void 0;
54
+ const end = stringEnd(valueStart);
55
+ if (end < 0) return void 0;
56
+ let value;
57
+ try {
58
+ value = JSON.parse(source.slice(valueStart, end));
59
+ } catch {
60
+ return void 0;
61
+ }
62
+ if (typeof value !== "string" || !value.startsWith("#")) return void 0;
63
+ paths.push({ start: valueStart, end, value });
64
+ index = end;
65
+ }
66
+ return paths;
67
+ }
68
+ function createSchemaDiagnosticOrigins() {
69
+ const indexes = /* @__PURE__ */ new WeakMap();
70
+ const anonymousIds = /* @__PURE__ */ new WeakMap();
71
+ const origins = /* @__PURE__ */ new Map();
72
+ let anonymousId = 0;
73
+ const indexRoot = (root) => {
74
+ const cached = indexes.get(root);
75
+ if (cached) return cached;
76
+ const paths = /* @__PURE__ */ new WeakMap();
77
+ const pending = [[root, "#"]];
78
+ while (pending.length) {
79
+ const [node, pointer] = pending.pop();
80
+ if (paths.has(node)) continue;
81
+ paths.set(node, pointer);
82
+ for (const [key, child] of Object.entries(node)) {
83
+ if (object(child))
84
+ pending.push([child, `${pointer}/${encodeURIComponent(key.replace(/~/g, "~0").replace(/\//g, "~1"))}`]);
85
+ }
86
+ }
87
+ indexes.set(root, paths);
88
+ return paths;
89
+ };
90
+ const origin = (schemaPath) => {
91
+ const hash = schemaPath.indexOf("#");
92
+ if (hash < 0) return void 0;
93
+ let prefix = schemaPath;
94
+ while (prefix.length >= hash + 1) {
95
+ if (origins.has(prefix)) {
96
+ const entry = origins.get(prefix);
97
+ if (!entry) return void 0;
98
+ let cursor = entry.schema;
99
+ let schemaId = entry.schemaId;
100
+ const relative = schemaPath.slice(prefix.length);
101
+ if (relative)
102
+ for (const segment of relative.slice(1).split("/")) {
103
+ let key;
104
+ try {
105
+ key = decodeURIComponent(segment).replace(/~1/g, "/").replace(/~0/g, "~");
106
+ } catch {
107
+ return void 0;
108
+ }
109
+ if (key === "__proto__" || key === "constructor" || key === "prototype" || !object(cursor) || !Object.hasOwn(cursor, key))
110
+ return void 0;
111
+ cursor = cursor[key];
112
+ if (object(cursor) && typeof cursor.$id === "string") {
113
+ try {
114
+ schemaId = new URL(cursor.$id, schemaId).href;
115
+ } catch {
116
+ schemaId = cursor.$id;
117
+ }
118
+ }
119
+ }
120
+ return { schema: cursor, ...schemaId && { schemaId }, schemaPath: `#${relative}` };
121
+ }
122
+ const slash = prefix.lastIndexOf("/");
123
+ if (slash <= hash) {
124
+ if (prefix.length === hash + 1) break;
125
+ prefix = prefix.slice(0, hash + 1);
126
+ } else prefix = prefix.slice(0, slash);
127
+ }
128
+ return void 0;
129
+ };
130
+ return {
131
+ process(source, environment) {
132
+ const literals = schemaPathLiterals(source);
133
+ if (!environment || !literals?.length || !object(environment.schema) || !object(environment.root.schema))
134
+ return source;
135
+ const root = environment.root.schema;
136
+ const pointer = indexRoot(root).get(environment.schema);
137
+ const document = pointer !== void 0 ? root : environment.schema;
138
+ let id = typeof document.$id === "string" ? document.$id.replace(/#.*$/, "") : void 0;
139
+ if (!id) {
140
+ id = anonymousIds.get(document);
141
+ if (!id) {
142
+ id = `urn:adcp:schema-origin:${anonymousId++}`;
143
+ anonymousIds.set(document, id);
144
+ }
145
+ }
146
+ const prefix = `${id}${pointer ?? "#"}`;
147
+ if (origins.has(prefix) && origins.get(prefix)?.schema !== environment.schema) origins.set(prefix, void 0);
148
+ else if (!origins.has(prefix)) {
149
+ const schemaId = environment.baseId || (typeof environment.schema.$id === "string" ? environment.schema.$id : void 0);
150
+ origins.set(prefix, { schema: environment.schema, ...schemaId && { schemaId } });
151
+ }
152
+ const fragments = [];
153
+ let cursor = 0;
154
+ for (const literal of literals) {
155
+ fragments.push(source.slice(cursor, literal.start), JSON.stringify(prefix + literal.value.slice(1)));
156
+ cursor = literal.end;
157
+ }
158
+ fragments.push(source.slice(cursor));
159
+ return fragments.join("");
160
+ },
161
+ resolve(schemaPath) {
162
+ return origin(schemaPath)?.schema;
163
+ },
164
+ origin
165
+ };
166
+ }
167
+ export {
168
+ createSchemaDiagnosticOrigins
169
+ };
@@ -36,6 +36,7 @@ __export(schema_loader_exports, {
36
36
  getMcpProfileInputSchema: () => getMcpProfileInputSchema,
37
37
  getMcpToolSchema: () => getMcpToolSchema,
38
38
  getMcpToolSummary: () => getMcpToolSummary,
39
+ getMediaBuyDeliveryEnvelopeValidator: () => getMediaBuyDeliveryEnvelopeValidator,
39
40
  getRegisteredSchemaIds: () => getRegisteredSchemaIds,
40
41
  getRequestSchemaEntityPaths: () => getRequestSchemaEntityPaths,
41
42
  getSchemaDefaultByPath: () => getSchemaDefaultByPath,
@@ -44,14 +45,17 @@ __export(schema_loader_exports, {
44
45
  getSchemaValidatorByRef: () => getSchemaValidatorByRef,
45
46
  getToolSchemaDocument: () => getToolSchemaDocument,
46
47
  getValidator: () => getValidator,
48
+ getValidatorDiagnosticOrigin: () => getValidatorDiagnosticOrigin,
47
49
  hasSchemaBundle: () => hasSchemaBundle,
48
50
  isExternalSchemaRootActive: () => isExternalSchemaRootActive,
49
51
  isIdentity33SchemaScope: () => isIdentity33SchemaScope,
50
52
  listValidatorKeys: () => listValidatorKeys,
51
53
  registerExternalSchemaRoot: () => registerExternalSchemaRoot,
54
+ relaxResponseRoot: () => relaxResponseRoot,
52
55
  resolveBundleKey: () => resolveBundleKey,
53
56
  resolveSchemaRoot: () => resolveSchemaRoot,
54
57
  resolveServedValidationVersion: () => resolveServedValidationVersion,
58
+ resolveValidatorDiagnosticPath: () => resolveValidatorDiagnosticPath,
55
59
  schemaAllowsTopLevelField: () => schemaAllowsTopLevelField,
56
60
  toReleasePrecisionWire: () => toReleasePrecisionWire,
57
61
  unregisterExternalSchemaRoot: () => unregisterExternalSchemaRoot,
@@ -208,6 +212,13 @@ function compareBundleNamesDesc(a, b) {
208
212
  return b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" });
209
213
  }
210
214
  const states = /* @__PURE__ */ new Map();
215
+ const validatorDiagnosticOrigins = /* @__PURE__ */ new WeakMap();
216
+ function resolveValidatorDiagnosticPath(validator, schemaPath) {
217
+ return validatorDiagnosticOrigins.get(validator)?.resolve(schemaPath);
218
+ }
219
+ function getValidatorDiagnosticOrigin(validator, schemaPath) {
220
+ return validatorDiagnosticOrigins.get(validator)?.origin(schemaPath);
221
+ }
211
222
  const schemaRefValidators = /* @__PURE__ */ new Map();
212
223
  const keywordSchemaRefValidators = /* @__PURE__ */ new WeakMap();
213
224
  let keywordCacheGeneration = 0;
@@ -472,21 +483,30 @@ function ensureInit(version) {
472
483
  const cacheKey = stateCacheKey(key, root);
473
484
  const cached = states.get(cacheKey);
474
485
  if (cached) return cached;
486
+ const { createSchemaDiagnosticOrigins } = require('./schema-diagnostic-origins.js');
487
+ const diagnosticOrigins = createSchemaDiagnosticOrigins();
488
+ const bundledDiagnosticOrigins = createSchemaDiagnosticOrigins();
475
489
  const ajv = new import_ajv.default({
490
+ inlineRefs: false,
476
491
  strict: false,
477
492
  allErrors: true,
478
- allowUnionTypes: true
493
+ allowUnionTypes: true,
494
+ code: { process: diagnosticOrigins.process }
479
495
  });
480
496
  (0, import_ajv_formats.default)(ajv);
481
497
  const bundledAjv = new import_ajv.default({
498
+ inlineRefs: false,
482
499
  strict: false,
483
500
  allErrors: true,
484
- allowUnionTypes: true
501
+ allowUnionTypes: true,
502
+ code: { process: bundledDiagnosticOrigins.process }
485
503
  });
486
504
  (0, import_ajv_formats.default)(bundledAjv);
487
505
  const state = {
488
506
  ajv,
489
507
  bundledAjv,
508
+ diagnosticOrigins,
509
+ bundledDiagnosticOrigins,
490
510
  canonicalValidators: /* @__PURE__ */ new Map(),
491
511
  fileIndex: buildFileIndex(root),
492
512
  validators: /* @__PURE__ */ new Map(),
@@ -503,7 +523,8 @@ function ensureCoreLoaded(s) {
503
523
  if (s.coreLoaded) return;
504
524
  const selectedToolsById = /* @__PURE__ */ new Map();
505
525
  const responseToolFiles = /* @__PURE__ */ new Set();
506
- for (const [key, file] of s.fileIndex) {
526
+ for (const [key, indexedFile] of s.fileIndex) {
527
+ const file = authoredToolSchemaFile(s, indexedFile);
507
528
  const response = !key.endsWith("::request");
508
529
  if (response) responseToolFiles.add(file);
509
530
  const schema = loadJson(file);
@@ -538,17 +559,20 @@ function getValidator(toolName, direction, version = import_version.ADCP_VERSION
538
559
  const cacheKey = `${toolName}::${direction}`;
539
560
  const cached = s.validators.get(cacheKey);
540
561
  if (cached) return cached;
541
- const file = s.fileIndex.get(cacheKey);
542
- if (!file) return void 0;
562
+ const indexedFile = s.fileIndex.get(cacheKey);
563
+ if (!indexedFile) return void 0;
564
+ const file = runtimeToolSchemaFile(s, indexedFile, direction);
543
565
  const fromBundled = file.includes(`${import_path.default.sep}bundled${import_path.default.sep}`);
544
566
  if (!fromBundled) ensureCoreLoaded(s);
545
567
  const rawSchema = loadJson(file);
546
568
  const prepared = fromBundled ? stripNestedIds(rawSchema) : rawSchema;
547
- const schema = direction === "request" ? prepared : relaxResponseRoot(prepared);
569
+ const envelope = direction === "request" ? prepared : relaxResponseRoot(prepared);
570
+ const schema = fromBundled ? compactSchemaForValidation(envelope) : envelope;
548
571
  const ajv = fromBundled ? s.bundledAjv : s.ajv;
549
572
  const existing = typeof schema.$id === "string" ? ajv.getSchema(schema.$id) : void 0;
550
573
  const compiled = existing ?? ajv.compile(schema);
551
574
  s.validators.set(cacheKey, compiled);
575
+ validatorDiagnosticOrigins.set(compiled, fromBundled ? s.bundledDiagnosticOrigins : s.diagnosticOrigins);
552
576
  return compiled;
553
577
  }
554
578
  function authoredToolSchemaFile(state, indexedFile) {
@@ -558,6 +582,23 @@ function authoredToolSchemaFile(state, indexedFile) {
558
582
  const authoredFile = import_path.default.join(state.root, relative);
559
583
  return (0, import_fs.existsSync)(authoredFile) ? authoredFile : indexedFile;
560
584
  }
585
+ function runtimeToolSchemaFile(state, indexedFile, direction) {
586
+ const authoredFile = authoredToolSchemaFile(state, indexedFile);
587
+ if (direction === "request" || authoredFile === indexedFile) return authoredFile;
588
+ const hasCompositionReference = (node) => {
589
+ if (!node || typeof node !== "object" || Array.isArray(node)) return false;
590
+ const schema = node;
591
+ if (typeof schema.$ref === "string") return true;
592
+ return ["allOf", "oneOf", "anyOf"].some(
593
+ (keyword) => Array.isArray(schema[keyword]) && schema[keyword].some(hasCompositionReference)
594
+ );
595
+ };
596
+ return hasCompositionReference(loadJson(authoredFile)) ? indexedFile : authoredFile;
597
+ }
598
+ function compactSchemaForValidation(schema) {
599
+ const compactor = require('./compact-schema.js');
600
+ return compactor.compactSchemaForValidation(schema);
601
+ }
561
602
  function getToolSchemaDocument(toolName, direction, version = import_version.ADCP_VERSION) {
562
603
  const state = ensureInit(version);
563
604
  const file = state.fileIndex.get(`${toolName}::${direction}`);
@@ -616,6 +657,33 @@ function getSchemaDocumentByRef(schemaRef, version = import_version.ADCP_VERSION
616
657
  };
617
658
  }
618
659
  function getSchemaValidatorByRef(schemaRef, version = import_version.ADCP_VERSION, keywords, options = {}) {
660
+ return compileSchemaReference(schemaRef, version, keywords, options);
661
+ }
662
+ function getMediaBuyDeliveryEnvelopeValidator(version) {
663
+ return compileSchemaReference(
664
+ "core/mcp-webhook-payload.json",
665
+ version,
666
+ void 0,
667
+ {},
668
+ {
669
+ key: "media-buy-delivery-envelope",
670
+ project: (schema) => ({
671
+ ...schema,
672
+ properties: {
673
+ ...schema.properties,
674
+ // The 3.0 task-type enum predates this documented reporting task. All
675
+ // releases use the same concrete discriminator on delivery envelopes.
676
+ task_type: { const: "media_buy_delivery" },
677
+ // The caller validates this independently against the served report
678
+ // schema, so result errors cannot masquerade as envelope errors.
679
+ result: {}
680
+ },
681
+ required: [.../* @__PURE__ */ new Set([...schema.required ?? [], "task_type", "result"])]
682
+ })
683
+ }
684
+ );
685
+ }
686
+ function compileSchemaReference(schemaRef, version, keywords, options, projection) {
619
687
  const bundleKey = resolveBundleKey(version);
620
688
  const root = resolveSchemaRoot(version);
621
689
  const normalized = normalizeSchemaRef(schemaRef);
@@ -630,12 +698,13 @@ function getSchemaValidatorByRef(schemaRef, version = import_version.ADCP_VERSIO
630
698
  cache = entry.validators;
631
699
  }
632
700
  const allErrors = options.allErrors ?? false;
633
- const cacheKey = `${stateCacheKey(bundleKey, root)}\0schema-ref::${normalized}\0all-errors::${allErrors}`;
701
+ const cacheKey = `${stateCacheKey(bundleKey, root)}\0schema-ref::${normalized}\0all-errors::${allErrors}\0projection::${projection?.key ?? "raw"}`;
634
702
  const cached = cache.get(cacheKey);
635
703
  if (cached) return cached;
636
704
  const file = import_path.default.join(root, normalized);
637
705
  if (!(0, import_fs.existsSync)(file)) return void 0;
638
706
  const ajv = new import_ajv.default({
707
+ inlineRefs: false,
639
708
  strict: false,
640
709
  // Schema-ref validators process remote webhook payloads. By default they
641
710
  // fail on the first violation so deeply nested hostile input cannot
@@ -646,7 +715,8 @@ function getSchemaValidatorByRef(schemaRef, version = import_version.ADCP_VERSIO
646
715
  });
647
716
  (0, import_ajv_formats.default)(ajv);
648
717
  for (const keyword of keywords ?? []) ajv.addKeyword(keyword);
649
- const rawSchema = identity33ReferenceSchema(loadJson(file), version);
718
+ const authoredSchema = identity33ReferenceSchema(loadJson(file), version);
719
+ const rawSchema = projection ? projection.project(authoredSchema) : authoredSchema;
650
720
  const dependencySchemas = [];
651
721
  const registeredIds = /* @__PURE__ */ new Map();
652
722
  for (const schemaFile of walkJsonFiles(root)) {
@@ -656,8 +726,8 @@ function getSchemaValidatorByRef(schemaRef, version = import_version.ADCP_VERSIO
656
726
  }
657
727
  if (schemaFile === file) continue;
658
728
  const schema = identity33ReferenceSchema(loadJson(schemaFile), version);
659
- if ((keywords || allErrors) && typeof schema.$id === "string") {
660
- const previous = schema.$id === rawSchema.$id ? rawSchema : registeredIds.get(schema.$id);
729
+ if (typeof schema.$id === "string") {
730
+ const previous = schema.$id === authoredSchema.$id ? authoredSchema : registeredIds.get(schema.$id);
661
731
  if (previous && !(0, import_node_util.isDeepStrictEqual)(previous, schema)) {
662
732
  throw new import_errors.ConfigurationError("Schema validation requires unambiguous schema identities", "schemaRoot");
663
733
  }
@@ -687,17 +757,13 @@ function getCanonicalToolValidatorForVersion(toolName, direction, version = impo
687
757
  const ajv = ensureCanonicalAjv(state);
688
758
  const existing = typeof rawSchema.$id === "string" ? ajv.getSchema(rawSchema.$id) : void 0;
689
759
  const fromBundled = file.includes(`${import_path.default.sep}bundled${import_path.default.sep}`);
690
- const compiled = existing ?? ajv.compile(fromBundled ? stripNestedIds(rawSchema) : rawSchema);
760
+ const compiled = existing ?? ajv.compile(fromBundled ? compactSchemaForValidation(stripNestedIds(rawSchema)) : rawSchema);
691
761
  state.canonicalValidators.set(cacheKey, compiled);
692
762
  return compiled;
693
763
  }
694
764
  function ensureCanonicalAjv(state) {
695
765
  if (state.canonicalAjv) return state.canonicalAjv;
696
- const ajv = new import_ajv.default({
697
- strict: false,
698
- allErrors: true,
699
- allowUnionTypes: true
700
- });
766
+ const ajv = new import_ajv.default({ inlineRefs: false, strict: false, allErrors: true, allowUnionTypes: true });
701
767
  (0, import_ajv_formats.default)(ajv);
702
768
  const schemasById = /* @__PURE__ */ new Map();
703
769
  for (const schemaFile of walkJsonFiles(state.root)) {
@@ -1133,6 +1199,7 @@ function cloneJsonValue(value) {
1133
1199
  getMcpProfileInputSchema,
1134
1200
  getMcpToolSchema,
1135
1201
  getMcpToolSummary,
1202
+ getMediaBuyDeliveryEnvelopeValidator,
1136
1203
  getRegisteredSchemaIds,
1137
1204
  getRequestSchemaEntityPaths,
1138
1205
  getSchemaDefaultByPath,
@@ -1141,14 +1208,17 @@ function cloneJsonValue(value) {
1141
1208
  getSchemaValidatorByRef,
1142
1209
  getToolSchemaDocument,
1143
1210
  getValidator,
1211
+ getValidatorDiagnosticOrigin,
1144
1212
  hasSchemaBundle,
1145
1213
  isExternalSchemaRootActive,
1146
1214
  isIdentity33SchemaScope,
1147
1215
  listValidatorKeys,
1148
1216
  registerExternalSchemaRoot,
1217
+ relaxResponseRoot,
1149
1218
  resolveBundleKey,
1150
1219
  resolveSchemaRoot,
1151
1220
  resolveServedValidationVersion,
1221
+ resolveValidatorDiagnosticPath,
1152
1222
  schemaAllowsTopLevelField,
1153
1223
  toReleasePrecisionWire,
1154
1224
  unregisterExternalSchemaRoot,
@@ -154,6 +154,13 @@ function compareBundleNamesDesc(a, b) {
154
154
  return b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" });
155
155
  }
156
156
  const states = /* @__PURE__ */ new Map();
157
+ const validatorDiagnosticOrigins = /* @__PURE__ */ new WeakMap();
158
+ function resolveValidatorDiagnosticPath(validator, schemaPath) {
159
+ return validatorDiagnosticOrigins.get(validator)?.resolve(schemaPath);
160
+ }
161
+ function getValidatorDiagnosticOrigin(validator, schemaPath) {
162
+ return validatorDiagnosticOrigins.get(validator)?.origin(schemaPath);
163
+ }
157
164
  const schemaRefValidators = /* @__PURE__ */ new Map();
158
165
  const keywordSchemaRefValidators = /* @__PURE__ */ new WeakMap();
159
166
  let keywordCacheGeneration = 0;
@@ -418,21 +425,30 @@ function ensureInit(version) {
418
425
  const cacheKey = stateCacheKey(key, root);
419
426
  const cached = states.get(cacheKey);
420
427
  if (cached) return cached;
428
+ const { createSchemaDiagnosticOrigins } = require2("./schema-diagnostic-origins");
429
+ const diagnosticOrigins = createSchemaDiagnosticOrigins();
430
+ const bundledDiagnosticOrigins = createSchemaDiagnosticOrigins();
421
431
  const ajv = new Ajv({
432
+ inlineRefs: false,
422
433
  strict: false,
423
434
  allErrors: true,
424
- allowUnionTypes: true
435
+ allowUnionTypes: true,
436
+ code: { process: diagnosticOrigins.process }
425
437
  });
426
438
  addFormats(ajv);
427
439
  const bundledAjv = new Ajv({
440
+ inlineRefs: false,
428
441
  strict: false,
429
442
  allErrors: true,
430
- allowUnionTypes: true
443
+ allowUnionTypes: true,
444
+ code: { process: bundledDiagnosticOrigins.process }
431
445
  });
432
446
  addFormats(bundledAjv);
433
447
  const state = {
434
448
  ajv,
435
449
  bundledAjv,
450
+ diagnosticOrigins,
451
+ bundledDiagnosticOrigins,
436
452
  canonicalValidators: /* @__PURE__ */ new Map(),
437
453
  fileIndex: buildFileIndex(root),
438
454
  validators: /* @__PURE__ */ new Map(),
@@ -449,7 +465,8 @@ function ensureCoreLoaded(s) {
449
465
  if (s.coreLoaded) return;
450
466
  const selectedToolsById = /* @__PURE__ */ new Map();
451
467
  const responseToolFiles = /* @__PURE__ */ new Set();
452
- for (const [key, file] of s.fileIndex) {
468
+ for (const [key, indexedFile] of s.fileIndex) {
469
+ const file = authoredToolSchemaFile(s, indexedFile);
453
470
  const response = !key.endsWith("::request");
454
471
  if (response) responseToolFiles.add(file);
455
472
  const schema = loadJson(file);
@@ -484,17 +501,20 @@ function getValidator(toolName, direction, version = ADCP_VERSION) {
484
501
  const cacheKey = `${toolName}::${direction}`;
485
502
  const cached = s.validators.get(cacheKey);
486
503
  if (cached) return cached;
487
- const file = s.fileIndex.get(cacheKey);
488
- if (!file) return void 0;
504
+ const indexedFile = s.fileIndex.get(cacheKey);
505
+ if (!indexedFile) return void 0;
506
+ const file = runtimeToolSchemaFile(s, indexedFile, direction);
489
507
  const fromBundled = file.includes(`${path.sep}bundled${path.sep}`);
490
508
  if (!fromBundled) ensureCoreLoaded(s);
491
509
  const rawSchema = loadJson(file);
492
510
  const prepared = fromBundled ? stripNestedIds(rawSchema) : rawSchema;
493
- const schema = direction === "request" ? prepared : relaxResponseRoot(prepared);
511
+ const envelope = direction === "request" ? prepared : relaxResponseRoot(prepared);
512
+ const schema = fromBundled ? compactSchemaForValidation(envelope) : envelope;
494
513
  const ajv = fromBundled ? s.bundledAjv : s.ajv;
495
514
  const existing = typeof schema.$id === "string" ? ajv.getSchema(schema.$id) : void 0;
496
515
  const compiled = existing ?? ajv.compile(schema);
497
516
  s.validators.set(cacheKey, compiled);
517
+ validatorDiagnosticOrigins.set(compiled, fromBundled ? s.bundledDiagnosticOrigins : s.diagnosticOrigins);
498
518
  return compiled;
499
519
  }
500
520
  function authoredToolSchemaFile(state, indexedFile) {
@@ -504,6 +524,23 @@ function authoredToolSchemaFile(state, indexedFile) {
504
524
  const authoredFile = path.join(state.root, relative);
505
525
  return existsSync(authoredFile) ? authoredFile : indexedFile;
506
526
  }
527
+ function runtimeToolSchemaFile(state, indexedFile, direction) {
528
+ const authoredFile = authoredToolSchemaFile(state, indexedFile);
529
+ if (direction === "request" || authoredFile === indexedFile) return authoredFile;
530
+ const hasCompositionReference = (node) => {
531
+ if (!node || typeof node !== "object" || Array.isArray(node)) return false;
532
+ const schema = node;
533
+ if (typeof schema.$ref === "string") return true;
534
+ return ["allOf", "oneOf", "anyOf"].some(
535
+ (keyword) => Array.isArray(schema[keyword]) && schema[keyword].some(hasCompositionReference)
536
+ );
537
+ };
538
+ return hasCompositionReference(loadJson(authoredFile)) ? indexedFile : authoredFile;
539
+ }
540
+ function compactSchemaForValidation(schema) {
541
+ const compactor = require2("./compact-schema");
542
+ return compactor.compactSchemaForValidation(schema);
543
+ }
507
544
  function getToolSchemaDocument(toolName, direction, version = ADCP_VERSION) {
508
545
  const state = ensureInit(version);
509
546
  const file = state.fileIndex.get(`${toolName}::${direction}`);
@@ -562,6 +599,33 @@ function getSchemaDocumentByRef(schemaRef, version = ADCP_VERSION) {
562
599
  };
563
600
  }
564
601
  function getSchemaValidatorByRef(schemaRef, version = ADCP_VERSION, keywords, options = {}) {
602
+ return compileSchemaReference(schemaRef, version, keywords, options);
603
+ }
604
+ function getMediaBuyDeliveryEnvelopeValidator(version) {
605
+ return compileSchemaReference(
606
+ "core/mcp-webhook-payload.json",
607
+ version,
608
+ void 0,
609
+ {},
610
+ {
611
+ key: "media-buy-delivery-envelope",
612
+ project: (schema) => ({
613
+ ...schema,
614
+ properties: {
615
+ ...schema.properties,
616
+ // The 3.0 task-type enum predates this documented reporting task. All
617
+ // releases use the same concrete discriminator on delivery envelopes.
618
+ task_type: { const: "media_buy_delivery" },
619
+ // The caller validates this independently against the served report
620
+ // schema, so result errors cannot masquerade as envelope errors.
621
+ result: {}
622
+ },
623
+ required: [.../* @__PURE__ */ new Set([...schema.required ?? [], "task_type", "result"])]
624
+ })
625
+ }
626
+ );
627
+ }
628
+ function compileSchemaReference(schemaRef, version, keywords, options, projection) {
565
629
  const bundleKey = resolveBundleKey(version);
566
630
  const root = resolveSchemaRoot(version);
567
631
  const normalized = normalizeSchemaRef(schemaRef);
@@ -576,12 +640,13 @@ function getSchemaValidatorByRef(schemaRef, version = ADCP_VERSION, keywords, op
576
640
  cache = entry.validators;
577
641
  }
578
642
  const allErrors = options.allErrors ?? false;
579
- const cacheKey = `${stateCacheKey(bundleKey, root)}\0schema-ref::${normalized}\0all-errors::${allErrors}`;
643
+ const cacheKey = `${stateCacheKey(bundleKey, root)}\0schema-ref::${normalized}\0all-errors::${allErrors}\0projection::${projection?.key ?? "raw"}`;
580
644
  const cached = cache.get(cacheKey);
581
645
  if (cached) return cached;
582
646
  const file = path.join(root, normalized);
583
647
  if (!existsSync(file)) return void 0;
584
648
  const ajv = new Ajv({
649
+ inlineRefs: false,
585
650
  strict: false,
586
651
  // Schema-ref validators process remote webhook payloads. By default they
587
652
  // fail on the first violation so deeply nested hostile input cannot
@@ -592,7 +657,8 @@ function getSchemaValidatorByRef(schemaRef, version = ADCP_VERSION, keywords, op
592
657
  });
593
658
  addFormats(ajv);
594
659
  for (const keyword of keywords ?? []) ajv.addKeyword(keyword);
595
- const rawSchema = identity33ReferenceSchema(loadJson(file), version);
660
+ const authoredSchema = identity33ReferenceSchema(loadJson(file), version);
661
+ const rawSchema = projection ? projection.project(authoredSchema) : authoredSchema;
596
662
  const dependencySchemas = [];
597
663
  const registeredIds = /* @__PURE__ */ new Map();
598
664
  for (const schemaFile of walkJsonFiles(root)) {
@@ -602,8 +668,8 @@ function getSchemaValidatorByRef(schemaRef, version = ADCP_VERSION, keywords, op
602
668
  }
603
669
  if (schemaFile === file) continue;
604
670
  const schema = identity33ReferenceSchema(loadJson(schemaFile), version);
605
- if ((keywords || allErrors) && typeof schema.$id === "string") {
606
- const previous = schema.$id === rawSchema.$id ? rawSchema : registeredIds.get(schema.$id);
671
+ if (typeof schema.$id === "string") {
672
+ const previous = schema.$id === authoredSchema.$id ? authoredSchema : registeredIds.get(schema.$id);
607
673
  if (previous && !isDeepStrictEqual(previous, schema)) {
608
674
  throw new ConfigurationError("Schema validation requires unambiguous schema identities", "schemaRoot");
609
675
  }
@@ -633,17 +699,13 @@ function getCanonicalToolValidatorForVersion(toolName, direction, version = ADCP
633
699
  const ajv = ensureCanonicalAjv(state);
634
700
  const existing = typeof rawSchema.$id === "string" ? ajv.getSchema(rawSchema.$id) : void 0;
635
701
  const fromBundled = file.includes(`${path.sep}bundled${path.sep}`);
636
- const compiled = existing ?? ajv.compile(fromBundled ? stripNestedIds(rawSchema) : rawSchema);
702
+ const compiled = existing ?? ajv.compile(fromBundled ? compactSchemaForValidation(stripNestedIds(rawSchema)) : rawSchema);
637
703
  state.canonicalValidators.set(cacheKey, compiled);
638
704
  return compiled;
639
705
  }
640
706
  function ensureCanonicalAjv(state) {
641
707
  if (state.canonicalAjv) return state.canonicalAjv;
642
- const ajv = new Ajv({
643
- strict: false,
644
- allErrors: true,
645
- allowUnionTypes: true
646
- });
708
+ const ajv = new Ajv({ inlineRefs: false, strict: false, allErrors: true, allowUnionTypes: true });
647
709
  addFormats(ajv);
648
710
  const schemasById = /* @__PURE__ */ new Map();
649
711
  for (const schemaFile of walkJsonFiles(state.root)) {
@@ -1078,6 +1140,7 @@ export {
1078
1140
  getMcpProfileInputSchema,
1079
1141
  getMcpToolSchema,
1080
1142
  getMcpToolSummary,
1143
+ getMediaBuyDeliveryEnvelopeValidator,
1081
1144
  getRegisteredSchemaIds,
1082
1145
  getRequestSchemaEntityPaths,
1083
1146
  getSchemaDefaultByPath,
@@ -1086,14 +1149,17 @@ export {
1086
1149
  getSchemaValidatorByRef,
1087
1150
  getToolSchemaDocument,
1088
1151
  getValidator,
1152
+ getValidatorDiagnosticOrigin,
1089
1153
  hasSchemaBundle,
1090
1154
  isExternalSchemaRootActive,
1091
1155
  isIdentity33SchemaScope,
1092
1156
  listValidatorKeys,
1093
1157
  registerExternalSchemaRoot,
1158
+ relaxResponseRoot,
1094
1159
  resolveBundleKey,
1095
1160
  resolveSchemaRoot,
1096
1161
  resolveServedValidationVersion,
1162
+ resolveValidatorDiagnosticPath,
1097
1163
  schemaAllowsTopLevelField,
1098
1164
  toReleasePrecisionWire,
1099
1165
  unregisterExternalSchemaRoot,
@@ -36,27 +36,18 @@ export interface ValidationIssue {
36
36
  message: string;
37
37
  /** AJV keyword that rejected the payload (e.g., `required`, `type`). */
38
38
  keyword: string;
39
- /** Path inside the schema that rejected the payload. */
39
+ /**
40
+ * AJV's original function-relative path in the compiled runtime schema.
41
+ * Factoring can change paths; they are diagnostic details rather than stable
42
+ * selectors into the public bundled document. Synthetic origin IDs stay internal.
43
+ */
40
44
  schemaPath: string;
41
45
  /**
42
- * `$id` of the rejecting schema. Resolved by finding the longest
43
- * registered AJV `$id` that prefixes {@link schemaPath}.
44
- *
45
- * Bundling caveat: AdCP ships most tools through `schemas/cache/<v>/bundled/`
46
- * with `$ref`s pre-resolved and inner `$id`s stripped at bundle time. For
47
- * those tools, `schemaId` resolves to the response root (e.g.
48
- * `/schemas/3.0.4/bundled/signals/activate-signal-response.json`), not
49
- * the deeper sub-schema. Tools served from the flat tree (`governance/`,
50
- * `brand/`, etc.) preserve sub-schema `$id`s, so `schemaId` can land on
51
- * something deeper like `/schemas/3.0.4/core/activation-key.json`. Either
52
- * way, the field names exactly the schema the validator looked at.
53
- *
54
- * Always projected — the `$id` is the published spec URI, not internal
55
- * handler shape. (Same precedent as {@link ValidationIssue.variants} and
56
- * {@link ValidationIssue.allowedValues}, both of which already ship
57
- * always-on with the same rationale.)
58
- *
59
- * Absent only when the rejecting schema didn't declare an `$id`.
46
+ * Effective `$id` of the rejecting resource, including embedded resources.
47
+ * Bundled documents may strip nested IDs, in which case the tool root is
48
+ * the available identity. Unsupported origin metadata conservatively falls
49
+ * back to the compiled root ID; anonymous resources can omit this field.
50
+ * Always projected because published schema IDs are protocol metadata.
60
51
  */
61
52
  schemaId?: string;
62
53
  /**