@adcp/sdk 17.0.0-beta.21 → 17.0.0-beta.22

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 (209) hide show
  1. package/README.md +26 -2
  2. package/dist/lib/client/core.d.mts +4 -0
  3. package/dist/lib/client/core.d.ts +4 -0
  4. package/dist/lib/client/core.js +13 -0
  5. package/dist/lib/client/core.mjs +12 -0
  6. package/dist/lib/conformance/property-lists.d.mts +1 -1
  7. package/dist/lib/conformance/property-lists.d.ts +1 -1
  8. package/dist/lib/conformance/property-lists.js +1 -1
  9. package/dist/lib/conformance/property-lists.mjs +1 -1
  10. package/dist/lib/core/SingleAgentClient.d.mts +10 -1
  11. package/dist/lib/core/SingleAgentClient.d.ts +10 -1
  12. package/dist/lib/core/SingleAgentClient.js +56 -7
  13. package/dist/lib/core/SingleAgentClient.mjs +61 -7
  14. package/dist/lib/core/targeting-helpers.d.mts +123 -0
  15. package/dist/lib/core/targeting-helpers.d.ts +123 -0
  16. package/dist/lib/core/targeting-helpers.js +412 -0
  17. package/dist/lib/core/targeting-helpers.mjs +370 -0
  18. package/dist/lib/entrypoints/client-account-changes.d.mts +5 -0
  19. package/dist/lib/entrypoints/client-account-changes.d.ts +5 -0
  20. package/dist/lib/entrypoints/client-account-changes.js +28 -0
  21. package/dist/lib/entrypoints/client-account-changes.mjs +4 -0
  22. package/dist/lib/entrypoints/client-webhook-stores.d.mts +2 -0
  23. package/dist/lib/entrypoints/client-webhook-stores.d.ts +2 -0
  24. package/dist/lib/entrypoints/client-webhook-stores.js +37 -0
  25. package/dist/lib/entrypoints/client-webhook-stores.mjs +16 -0
  26. package/dist/lib/entrypoints/discovery.d.mts +9 -0
  27. package/dist/lib/entrypoints/discovery.d.ts +9 -0
  28. package/dist/lib/entrypoints/discovery.js +72 -0
  29. package/dist/lib/entrypoints/discovery.mjs +56 -0
  30. package/dist/lib/entrypoints/errors.d.mts +11 -0
  31. package/dist/lib/entrypoints/errors.d.ts +11 -0
  32. package/dist/lib/entrypoints/errors.js +159 -0
  33. package/dist/lib/entrypoints/errors.mjs +132 -0
  34. package/dist/lib/entrypoints/media-buy.d.mts +5 -0
  35. package/dist/lib/entrypoints/media-buy.d.ts +5 -0
  36. package/dist/lib/entrypoints/media-buy.js +119 -0
  37. package/dist/lib/entrypoints/media-buy.mjs +100 -0
  38. package/dist/lib/entrypoints/registry.d.mts +5 -0
  39. package/dist/lib/entrypoints/registry.d.ts +5 -0
  40. package/dist/lib/entrypoints/registry.js +61 -0
  41. package/dist/lib/entrypoints/registry.mjs +40 -0
  42. package/dist/lib/entrypoints/utils.d.mts +7 -0
  43. package/dist/lib/entrypoints/utils.d.ts +7 -0
  44. package/dist/lib/entrypoints/utils.js +100 -0
  45. package/dist/lib/entrypoints/utils.mjs +72 -0
  46. package/dist/lib/entrypoints/version.d.mts +3 -0
  47. package/dist/lib/entrypoints/version.d.ts +3 -0
  48. package/dist/lib/entrypoints/version.js +57 -0
  49. package/dist/lib/entrypoints/version.mjs +36 -0
  50. package/dist/lib/index.d.mts +1 -1
  51. package/dist/lib/index.d.ts +1 -1
  52. package/dist/lib/media-buy/action-contracts.js +3 -3
  53. package/dist/lib/media-buy/action-contracts.mjs +1 -1
  54. package/dist/lib/media-buy/creative-start-policy.d.mts +19 -0
  55. package/dist/lib/media-buy/creative-start-policy.d.ts +19 -0
  56. package/dist/lib/media-buy/creative-start-policy.js +59 -0
  57. package/dist/lib/media-buy/creative-start-policy.mjs +31 -0
  58. package/dist/lib/media-buy/valid-actions.d.mts +47 -0
  59. package/dist/lib/media-buy/valid-actions.d.ts +47 -0
  60. package/dist/lib/media-buy/valid-actions.js +42 -0
  61. package/dist/lib/media-buy/valid-actions.mjs +18 -0
  62. package/dist/lib/net/pin-and-bind-fetch.d.mts +121 -0
  63. package/dist/lib/net/pin-and-bind-fetch.d.ts +121 -0
  64. package/dist/lib/net/pin-and-bind-fetch.js +209 -0
  65. package/dist/lib/net/pin-and-bind-fetch.mjs +183 -0
  66. package/dist/lib/registry/types.generated.d.ts +18 -2
  67. package/dist/lib/reporting/ledger/index.d.mts +1 -0
  68. package/dist/lib/reporting/ledger/index.d.ts +1 -0
  69. package/dist/lib/reporting/ledger/index.js +3 -1
  70. package/dist/lib/reporting/ledger/index.mjs +1 -0
  71. package/dist/lib/reporting/ledger/instant.d.mts +5 -0
  72. package/dist/lib/reporting/ledger/instant.d.ts +5 -0
  73. package/dist/lib/reporting/ledger/instant.js +10 -0
  74. package/dist/lib/reporting/ledger/instant.mjs +9 -0
  75. package/dist/lib/reporting/ledger/issue-events.d.mts +333 -0
  76. package/dist/lib/reporting/ledger/issue-events.d.ts +333 -0
  77. package/dist/lib/reporting/ledger/issue-events.js +310 -0
  78. package/dist/lib/reporting/ledger/issue-events.mjs +282 -0
  79. package/dist/lib/reporting/service/index.d.mts +36 -1
  80. package/dist/lib/reporting/service/index.d.ts +36 -1
  81. package/dist/lib/reporting/service/index.js +51 -1
  82. package/dist/lib/reporting/service/index.mjs +52 -2
  83. package/dist/lib/reporting/service/scheduler-support.d.mts +1 -1
  84. package/dist/lib/reporting/service/scheduler-support.d.ts +1 -1
  85. package/dist/lib/reporting/service/scheduler-support.js +1 -1
  86. package/dist/lib/reporting/service/scheduler-support.mjs +1 -1
  87. package/dist/lib/server/capabilities-release-projection.d.mts +43 -0
  88. package/dist/lib/server/capabilities-release-projection.d.ts +43 -0
  89. package/dist/lib/server/capabilities-release-projection.js +128 -0
  90. package/dist/lib/server/capabilities-release-projection.mjs +112 -0
  91. package/dist/lib/server/create-adcp-server.d.mts +29 -5
  92. package/dist/lib/server/create-adcp-server.d.ts +29 -5
  93. package/dist/lib/server/create-adcp-server.js +95 -22
  94. package/dist/lib/server/create-adcp-server.mjs +106 -21
  95. package/dist/lib/server/decisioning/capabilities.d.mts +27 -0
  96. package/dist/lib/server/decisioning/capabilities.d.ts +27 -0
  97. package/dist/lib/server/decisioning/runtime/from-platform.js +99 -27
  98. package/dist/lib/server/decisioning/runtime/from-platform.mjs +103 -27
  99. package/dist/lib/server/declared-input-schema.d.mts +108 -0
  100. package/dist/lib/server/declared-input-schema.d.ts +108 -0
  101. package/dist/lib/server/declared-input-schema.js +167 -0
  102. package/dist/lib/server/declared-input-schema.mjs +137 -0
  103. package/dist/lib/server/envelope-allowlist.d.mts +1 -105
  104. package/dist/lib/server/envelope-allowlist.d.ts +1 -105
  105. package/dist/lib/server/envelope-allowlist.js +3 -79
  106. package/dist/lib/server/envelope-allowlist.mjs +1 -71
  107. package/dist/lib/server/errors.d.mts +1 -186
  108. package/dist/lib/server/errors.d.ts +1 -186
  109. package/dist/lib/server/errors.js +3 -98
  110. package/dist/lib/server/errors.mjs +1 -94
  111. package/dist/lib/server/index.d.mts +1 -1
  112. package/dist/lib/server/index.d.ts +1 -1
  113. package/dist/lib/server/mcp-modern-server.js +21 -4
  114. package/dist/lib/server/mcp-modern-server.mjs +21 -4
  115. package/dist/lib/server/media-buy-action-resolver.d.mts +7 -0
  116. package/dist/lib/server/media-buy-action-resolver.d.ts +7 -0
  117. package/dist/lib/server/media-buy-action-resolver.js +10 -1
  118. package/dist/lib/server/media-buy-action-resolver.mjs +10 -1
  119. package/dist/lib/server/media-buy-helpers.d.mts +1 -47
  120. package/dist/lib/server/media-buy-helpers.d.ts +1 -47
  121. package/dist/lib/server/media-buy-helpers.js +3 -23
  122. package/dist/lib/server/media-buy-helpers.mjs +1 -18
  123. package/dist/lib/server/pick-safe-details.d.mts +1 -89
  124. package/dist/lib/server/pick-safe-details.d.ts +1 -89
  125. package/dist/lib/server/pick-safe-details.js +3 -61
  126. package/dist/lib/server/pick-safe-details.mjs +1 -56
  127. package/dist/lib/server/pin-and-bind-fetch.d.mts +1 -121
  128. package/dist/lib/server/pin-and-bind-fetch.d.ts +1 -121
  129. package/dist/lib/server/pin-and-bind-fetch.js +3 -190
  130. package/dist/lib/server/pin-and-bind-fetch.mjs +1 -183
  131. package/dist/lib/server/targeting-helpers.d.mts +1 -123
  132. package/dist/lib/server/targeting-helpers.d.ts +1 -123
  133. package/dist/lib/server/targeting-helpers.js +3 -393
  134. package/dist/lib/server/targeting-helpers.mjs +1 -370
  135. package/dist/lib/server/test-controller.js +7 -3
  136. package/dist/lib/server/test-controller.mjs +7 -3
  137. package/dist/lib/storage/memory-ledger.js +219 -1
  138. package/dist/lib/storage/memory-ledger.mjs +223 -1
  139. package/dist/lib/testing/compliance/storyboard-tracks.js +0 -4
  140. package/dist/lib/testing/compliance/storyboard-tracks.mjs +0 -4
  141. package/dist/lib/testing/comply-controller.js +7 -2
  142. package/dist/lib/testing/comply-controller.mjs +7 -2
  143. package/dist/lib/testing/storyboard/request-signing/grader.d.mts +21 -0
  144. package/dist/lib/testing/storyboard/request-signing/grader.d.ts +21 -0
  145. package/dist/lib/testing/storyboard/request-signing/grader.js +31 -0
  146. package/dist/lib/testing/storyboard/request-signing/grader.mjs +30 -0
  147. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.js +1 -1
  148. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs +2 -1
  149. package/dist/lib/testing/storyboard/request-signing/types.d.mts +12 -0
  150. package/dist/lib/testing/storyboard/request-signing/types.d.ts +12 -0
  151. package/dist/lib/testing/storyboard/request-signing/vector-loader.js +7 -2
  152. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +7 -2
  153. package/dist/lib/testing/storyboard/runner.js +2 -2
  154. package/dist/lib/testing/storyboard/runner.mjs +2 -2
  155. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  156. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  157. package/dist/lib/utils/adcp-error-response.d.mts +196 -0
  158. package/dist/lib/utils/adcp-error-response.d.ts +196 -0
  159. package/dist/lib/utils/adcp-error-response.js +118 -0
  160. package/dist/lib/utils/adcp-error-response.mjs +95 -0
  161. package/dist/lib/utils/buyer-retry-policy.js +2 -2
  162. package/dist/lib/utils/buyer-retry-policy.mjs +1 -1
  163. package/dist/lib/utils/capabilities.d.mts +6 -0
  164. package/dist/lib/utils/capabilities.d.ts +6 -0
  165. package/dist/lib/utils/capabilities.js +6 -2
  166. package/dist/lib/utils/capabilities.mjs +6 -2
  167. package/dist/lib/utils/envelope-allowlist.d.mts +105 -0
  168. package/dist/lib/utils/envelope-allowlist.d.ts +105 -0
  169. package/dist/lib/utils/envelope-allowlist.js +98 -0
  170. package/dist/lib/utils/envelope-allowlist.mjs +71 -0
  171. package/dist/lib/utils/pick-safe-details.d.mts +89 -0
  172. package/dist/lib/utils/pick-safe-details.d.ts +89 -0
  173. package/dist/lib/utils/pick-safe-details.js +80 -0
  174. package/dist/lib/utils/pick-safe-details.mjs +56 -0
  175. package/dist/lib/v2/projection/augment-response.d.mts +4 -0
  176. package/dist/lib/v2/projection/augment-response.d.ts +4 -0
  177. package/dist/lib/v2/projection/creative-delivery.d.mts +20 -3
  178. package/dist/lib/v2/projection/creative-delivery.d.ts +20 -3
  179. package/dist/lib/v2/projection/creative-delivery.js +20 -4
  180. package/dist/lib/v2/projection/creative-delivery.mjs +19 -4
  181. package/dist/lib/v2/projection/index.d.mts +2 -2
  182. package/dist/lib/v2/projection/index.d.ts +2 -2
  183. package/dist/lib/v2/projection/index.js +4 -0
  184. package/dist/lib/v2/projection/index.mjs +5 -1
  185. package/dist/lib/v2/projection/legacy-metadata.d.mts +7 -0
  186. package/dist/lib/v2/projection/legacy-metadata.d.ts +7 -0
  187. package/dist/lib/v2/projection/legacy-metadata.js +14 -0
  188. package/dist/lib/v2/projection/legacy-metadata.mjs +12 -0
  189. package/dist/lib/v2/projection/legacy-routes.d.mts +11 -0
  190. package/dist/lib/v2/projection/legacy-routes.d.ts +11 -0
  191. package/dist/lib/v2/projection/legacy-routes.js +2 -1
  192. package/dist/lib/v2/projection/legacy-routes.mjs +7 -2
  193. package/dist/lib/v2/projection/v1-to-v2.d.mts +21 -1
  194. package/dist/lib/v2/projection/v1-to-v2.d.ts +21 -1
  195. package/dist/lib/v2/projection/v1-to-v2.js +18 -11
  196. package/dist/lib/v2/projection/v1-to-v2.mjs +19 -11
  197. package/dist/lib/version.d.mts +3 -3
  198. package/dist/lib/version.d.ts +3 -3
  199. package/dist/lib/version.js +3 -3
  200. package/dist/lib/version.mjs +3 -3
  201. package/docs/TYPE-SUMMARY.md +2 -2
  202. package/docs/guides/CREATIVE-DELIVERY.md +12 -0
  203. package/docs/guides/REPORTING-LEDGER.md +121 -0
  204. package/docs/guides/VALIDATE-YOUR-AGENT.md +1 -0
  205. package/docs/llms.txt +2 -2
  206. package/docs/migration-14.x-rc-worksheet.md +4 -4
  207. package/docs/migration-16-to-17.md +149 -0
  208. package/docs/migration-reporting-storage-package.md +10 -0
  209. package/package.json +106 -1
@@ -1,370 +1 @@
1
- import { createHash } from "node:crypto";
2
- import { lookup as dnsLookup } from "node:dns/promises";
3
- import { callMCPTool } from "../protocols/mcp.mjs";
4
- import { isAlwaysBlocked, isPrivateIp } from "../net/index.mjs";
5
- import { isInternalProbesAllowed } from "../utils/probe-policy.mjs";
6
- import { createPinAndBindFetch } from "./pin-and-bind-fetch.mjs";
7
- import { unwrapProtocolResponse } from "../utils/response-unwrapper.mjs";
8
- const DEFAULT_RESOLVE_LIST_PAGE_SIZE = 1e3;
9
- class MemoryResolvedListCache {
10
- entries = /* @__PURE__ */ new Map();
11
- get(key, nowMs = Date.now()) {
12
- const entry = this.entries.get(key);
13
- if (!entry) return void 0;
14
- if (entry.expiresAtMs <= nowMs) {
15
- this.entries.delete(key);
16
- return void 0;
17
- }
18
- return cloneResolvedList(entry.value);
19
- }
20
- set(key, entry) {
21
- this.entries.set(key, {
22
- expiresAtMs: entry.expiresAtMs,
23
- value: cloneResolvedList(entry.value)
24
- });
25
- }
26
- delete(key) {
27
- return this.entries.delete(key);
28
- }
29
- clear() {
30
- this.entries.clear();
31
- }
32
- }
33
- function createResolvedListCache() {
34
- return new MemoryResolvedListCache();
35
- }
36
- const defaultResolvedListCache = createResolvedListCache();
37
- function clearDefaultResolvedListCache() {
38
- defaultResolvedListCache.clear();
39
- }
40
- const defaultResolveListFetchBase = createPinAndBindFetch();
41
- const defaultResolveListFetch = (input, init) => defaultResolveListFetchBase(input, { ...init, redirect: "manual" });
42
- const defaultResolveListCallTool = (agentUrl, toolName, args, authToken) => callMCPTool(agentUrl, toolName, args, authToken, [], void 0, void 0, defaultResolveListFetch);
43
- function resolvedListPayload(result, kind) {
44
- if (!result || typeof result !== "object" || Array.isArray(result)) return result;
45
- const envelope = result;
46
- const isMcp = "structuredContent" in envelope || "content" in envelope || "isError" in envelope;
47
- let payload;
48
- try {
49
- payload = isMcp ? unwrapProtocolResponse(envelope, void 0, "mcp") : envelope;
50
- } catch (cause) {
51
- throw new Error(`${kind}_list_invalid_response`, { cause });
52
- }
53
- const data = payload && typeof payload === "object" ? payload : void 0;
54
- if (envelope.isError === true || data?.adcp_error !== void 0) {
55
- throw Object.assign(new Error(`${kind}_list_invalid_response`, { cause: data?.adcp_error }), {
56
- adcp_error: data?.adcp_error
57
- });
58
- }
59
- return payload;
60
- }
61
- async function resolvePropertyList(ref, options = {}) {
62
- const structurallyNormalizedRef = await normalizePropertyListReference(ref, { resolveDns: false });
63
- const cache = cacheForOptions(options);
64
- const nowMs = nowMsForOptions(options);
65
- const cacheKey = resolvedListCacheKey("property", structurallyNormalizedRef, options);
66
- const cached = cacheKey && !options.strictResponseValidation ? cache?.get(cacheKey, nowMs) : void 0;
67
- if (cached) return cached;
68
- const normalizedRef = options.callTool ? structurallyNormalizedRef : await normalizePropertyListReference(structurallyNormalizedRef, { resolveDns: false });
69
- const result = await fetchResolvedPropertyList(normalizedRef, options);
70
- cacheResolvedList(cache, cacheKey, result, nowMs);
71
- return result;
72
- }
73
- async function fetchResolvedPropertyList(ref, options) {
74
- const callTool = options.callTool ?? defaultResolveListCallTool;
75
- const identifiers = [];
76
- let listId;
77
- let cacheValidUntil;
78
- let missingCacheValidUntil = false;
79
- let cursor;
80
- const seenCursors = /* @__PURE__ */ new Set();
81
- for (let pageIndex = 0; pageIndex < maxPagesForOptions(options); pageIndex += 1) {
82
- const args = buildResolveListArgs(ref.list_id, pageSizeForOptions(options), cursor);
83
- const raw = resolvedListPayload(
84
- await callTool(ref.agent_url, "get_property_list", args, ref.auth_token),
85
- "property"
86
- );
87
- if (!raw || typeof raw !== "object" || !("list" in raw)) {
88
- throw new Error("property_list_invalid_response");
89
- }
90
- const response = raw;
91
- if (response.status !== void 0 && response.status !== "completed" || raw.errors !== void 0 && (!Array.isArray(raw.errors) || raw.errors.some((error) => !error || typeof error !== "object" || error.severity !== "warning")) || raw.adcp_error !== void 0 || !Array.isArray(response.identifiers)) {
92
- throw new Error("property_list_invalid_response");
93
- }
94
- if (options.strictResponseValidation) {
95
- const { GetPropertyListResponseSchema } = await import("../types/schemas.generated.mjs");
96
- if (!GetPropertyListResponseSchema.safeParse(raw).success || response.status !== "completed" || response.identifiers.length > pageSizeForOptions(options)) {
97
- throw new Error("property_list_invalid_response");
98
- }
99
- }
100
- if (!response.list || response.list.list_id !== ref.list_id || response.identifiers !== void 0 && (!Array.isArray(response.identifiers) || response.identifiers.some(
101
- (identifier) => !identifier || typeof identifier !== "object" || typeof identifier.type !== "string" || typeof identifier.value !== "string"
102
- ))) {
103
- throw new Error("property_list_invalid_response");
104
- }
105
- listId = response.list.list_id;
106
- identifiers.push(...response.identifiers ?? []);
107
- if (typeof response.cache_valid_until === "string") {
108
- cacheValidUntil = earliestIsoTimestamp(cacheValidUntil, response.cache_valid_until);
109
- } else {
110
- missingCacheValidUntil = true;
111
- }
112
- const pagination = readPagination(response.pagination);
113
- if (pagination.invalid) {
114
- throw new Error("property_list_invalid_pagination");
115
- }
116
- if (!pagination.hasMore) {
117
- return {
118
- listId,
119
- agentUrl: ref.agent_url,
120
- identifiers,
121
- cacheValidUntil: missingCacheValidUntil ? void 0 : cacheValidUntil
122
- };
123
- }
124
- if (!pagination.cursor) {
125
- throw new Error("property_list_invalid_pagination");
126
- }
127
- if (seenCursors.has(pagination.cursor)) throw new Error("property_list_invalid_pagination");
128
- seenCursors.add(pagination.cursor);
129
- cursor = pagination.cursor;
130
- }
131
- throw new Error("property_list_pagination_limit_exceeded");
132
- }
133
- async function resolveCollectionList(ref, options = {}) {
134
- const structurallyNormalizedRef = await normalizeCollectionListReference(ref, { resolveDns: false });
135
- const cache = cacheForOptions(options);
136
- const nowMs = nowMsForOptions(options);
137
- const cacheKey = resolvedListCacheKey("collection", structurallyNormalizedRef, options);
138
- const cached = cacheKey && !options.strictResponseValidation ? cache?.get(cacheKey, nowMs) : void 0;
139
- if (cached) return cached;
140
- const normalizedRef = options.callTool ? structurallyNormalizedRef : await normalizeCollectionListReference(structurallyNormalizedRef, { resolveDns: false });
141
- const result = await fetchResolvedCollectionList(normalizedRef, options);
142
- cacheResolvedList(cache, cacheKey, result, nowMs);
143
- return result;
144
- }
145
- async function fetchResolvedCollectionList(ref, options) {
146
- const callTool = options.callTool ?? defaultResolveListCallTool;
147
- const collections = [];
148
- let listId;
149
- let cacheValidUntil;
150
- let missingCacheValidUntil = false;
151
- let cursor;
152
- for (let pageIndex = 0; pageIndex < maxPagesForOptions(options); pageIndex += 1) {
153
- const args = buildResolveListArgs(ref.list_id, pageSizeForOptions(options), cursor);
154
- const raw = resolvedListPayload(
155
- await callTool(ref.agent_url, "get_collection_list", args, ref.auth_token),
156
- "collection"
157
- );
158
- if (!raw || typeof raw !== "object" || !("list" in raw)) {
159
- throw new Error("collection_list_invalid_response");
160
- }
161
- const response = raw;
162
- if (response.status !== void 0 && response.status !== "completed" || raw.errors !== void 0 && (!Array.isArray(raw.errors) || raw.errors.some((error) => !error || typeof error !== "object" || error.severity !== "warning")) || !response.list || response.list.list_id !== ref.list_id || !Array.isArray(response.collections) || response.collections.some(
163
- (collection) => !collection || typeof collection !== "object" || Array.isArray(collection) || ["publisher_domain", "collection_id", "collection_rid", "name"].some(
164
- (field) => field in collection && typeof collection[field] !== "string"
165
- ) || collection.distribution_ids !== void 0 && (!Array.isArray(collection.distribution_ids) || collection.distribution_ids.some(
166
- (identifier) => !identifier || typeof identifier !== "object" || typeof identifier.type !== "string" || typeof identifier.value !== "string"
167
- ))
168
- )) {
169
- throw new Error("collection_list_invalid_response");
170
- }
171
- if (options.strictResponseValidation) {
172
- const { GetCollectionListResponseSchema } = await import("../types/schemas.generated.mjs");
173
- if (!GetCollectionListResponseSchema.safeParse(raw).success || response.status !== "completed" || response.collections.length > pageSizeForOptions(options)) {
174
- throw new Error("collection_list_invalid_response");
175
- }
176
- }
177
- listId = response.list.list_id;
178
- collections.push(...response.collections ?? []);
179
- if (typeof response.cache_valid_until === "string") {
180
- cacheValidUntil = earliestIsoTimestamp(cacheValidUntil, response.cache_valid_until);
181
- } else {
182
- missingCacheValidUntil = true;
183
- }
184
- const pagination = readPagination(response.pagination);
185
- if (pagination.invalid) {
186
- throw new Error("collection_list_invalid_pagination");
187
- }
188
- if (!pagination.hasMore) {
189
- return {
190
- listId,
191
- agentUrl: ref.agent_url,
192
- collections,
193
- cacheValidUntil: missingCacheValidUntil ? void 0 : cacheValidUntil
194
- };
195
- }
196
- if (!pagination.cursor) {
197
- throw new Error("collection_list_invalid_pagination");
198
- }
199
- cursor = pagination.cursor;
200
- }
201
- throw new Error("collection_list_pagination_limit_exceeded");
202
- }
203
- function resolvedListCacheKey(kind, ref, options = {}) {
204
- const scope = ref.auth_token ?? options.cacheScopeKey;
205
- if (!scope) return void 0;
206
- const material = JSON.stringify({
207
- kind,
208
- agent_url: ref.agent_url,
209
- list_id: ref.list_id,
210
- scope_sha256: sha256(scope),
211
- page_size: options.pageSize ?? DEFAULT_RESOLVE_LIST_PAGE_SIZE,
212
- resolve: true
213
- });
214
- return `adcp-resolved-list:${sha256(material)}`;
215
- }
216
- async function normalizePropertyListReference(ref, options) {
217
- return {
218
- ...ref,
219
- agent_url: await normalizeListAgentUrl(ref.agent_url, options)
220
- };
221
- }
222
- async function normalizeCollectionListReference(ref, options) {
223
- return {
224
- ...ref,
225
- agent_url: await normalizeListAgentUrl(ref.agent_url, options)
226
- };
227
- }
228
- async function normalizeListAgentUrl(raw, options) {
229
- let url;
230
- try {
231
- url = new URL(raw);
232
- } catch {
233
- throw new Error("list_agent_url_invalid");
234
- }
235
- if (url.username || url.password || url.search || url.hash) {
236
- throw new Error("list_agent_url_malformed");
237
- }
238
- const allowInternal = isInternalProbesAllowed();
239
- if (url.protocol !== "https:" && !(allowInternal && url.protocol === "http:")) {
240
- throw new Error("list_agent_url_insecure");
241
- }
242
- const hostname = url.hostname.replace(/^\[|\]$/g, "");
243
- if (isAlwaysBlocked(hostname)) {
244
- throw new Error("list_agent_url_always_blocked");
245
- }
246
- if (!allowInternal && isPrivateIp(hostname)) {
247
- throw new Error("list_agent_url_private_address");
248
- }
249
- if (options.resolveDns) {
250
- let addresses;
251
- try {
252
- addresses = await dnsLookup(hostname, { all: true });
253
- } catch {
254
- throw new Error("list_agent_url_dns_failed");
255
- }
256
- if (addresses.length === 0) {
257
- throw new Error("list_agent_url_dns_empty");
258
- }
259
- for (const { address } of addresses) {
260
- if (isAlwaysBlocked(address)) {
261
- throw new Error("list_agent_url_always_blocked");
262
- }
263
- if (!allowInternal && isPrivateIp(address)) {
264
- throw new Error("list_agent_url_private_address");
265
- }
266
- }
267
- }
268
- return url.toString();
269
- }
270
- function buildResolveListArgs(listId, pageSize, cursor) {
271
- const args = {
272
- list_id: listId,
273
- resolve: true
274
- };
275
- const pagination = {};
276
- pagination.max_results = pageSize;
277
- if (cursor) pagination.cursor = cursor;
278
- if (Object.keys(pagination).length > 0) args.pagination = pagination;
279
- return args;
280
- }
281
- function cacheForOptions(options) {
282
- if (options.callTool && options.cache === void 0) return void 0;
283
- return options.cache === false ? void 0 : options.cache ?? defaultResolvedListCache;
284
- }
285
- function cacheResolvedList(cache, cacheKey, value, nowMs) {
286
- if (!cache || !cacheKey || !value.cacheValidUntil) return;
287
- const expiresAtMs = Date.parse(value.cacheValidUntil);
288
- if (!Number.isFinite(expiresAtMs) || expiresAtMs <= nowMs) return;
289
- cache.set(cacheKey, { value, expiresAtMs });
290
- }
291
- function nowMsForOptions(options) {
292
- const now = options.now?.();
293
- if (now instanceof Date) return now.getTime();
294
- if (typeof now === "number") return now;
295
- return Date.now();
296
- }
297
- function maxPagesForOptions(options) {
298
- return options.maxPages ?? 100;
299
- }
300
- function pageSizeForOptions(options) {
301
- return options.pageSize ?? DEFAULT_RESOLVE_LIST_PAGE_SIZE;
302
- }
303
- function readPagination(value) {
304
- if (!value || typeof value !== "object" || Array.isArray(value)) return { hasMore: false, invalid: false };
305
- const pagination = value;
306
- const cursor = typeof pagination.cursor === "string" && pagination.cursor.length > 0 ? pagination.cursor : void 0;
307
- const invalid = pagination.has_more !== void 0 && typeof pagination.has_more !== "boolean" || cursor !== void 0 && pagination.has_more !== true;
308
- return {
309
- hasMore: pagination.has_more === true,
310
- cursor,
311
- invalid
312
- };
313
- }
314
- function earliestIsoTimestamp(current, next) {
315
- if (!current) return next;
316
- const currentMs = Date.parse(current);
317
- const nextMs = Date.parse(next);
318
- if (!Number.isFinite(currentMs)) return next;
319
- if (!Number.isFinite(nextMs)) return current;
320
- return nextMs < currentMs ? next : current;
321
- }
322
- function cloneResolvedList(value) {
323
- return structuredClone(value);
324
- }
325
- function sha256(value) {
326
- return createHash("sha256").update(value, "utf8").digest("hex");
327
- }
328
- function matchesPropertyList(property, list) {
329
- return list.identifiers.some((entry) => identifiersMatch(property, entry));
330
- }
331
- function identifiersMatch(property, entry) {
332
- if (property.type !== entry.type) return false;
333
- if (property.type !== "domain") {
334
- return property.value === entry.value;
335
- }
336
- return domainMatches(property.value, entry.value);
337
- }
338
- function domainMatches(candidate, pattern) {
339
- const c = candidate.toLowerCase();
340
- const p = pattern.toLowerCase();
341
- if (c === p) return true;
342
- if (p.startsWith("*.")) {
343
- const suffix = p.slice(1);
344
- return c.endsWith(suffix) && c !== p.slice(2);
345
- }
346
- return c === `www.${p}` || c === `m.${p}`;
347
- }
348
- function matchesCollectionList(collection, list) {
349
- return list.collections.some((entry) => collectionsMatch(collection, entry));
350
- }
351
- function collectionsMatch(a, b) {
352
- if (a.collection_rid && b.collection_rid && a.collection_rid === b.collection_rid) {
353
- return true;
354
- }
355
- if (!a.distribution_ids?.length || !b.distribution_ids?.length) return false;
356
- return a.distribution_ids.some(
357
- (aid) => b.distribution_ids.some((bid) => aid.type === bid.type && aid.value === bid.value)
358
- );
359
- }
360
- export {
361
- DEFAULT_RESOLVE_LIST_PAGE_SIZE,
362
- clearDefaultResolvedListCache,
363
- createResolvedListCache,
364
- defaultResolvedListCache,
365
- matchesCollectionList,
366
- matchesPropertyList,
367
- resolveCollectionList,
368
- resolvePropertyList,
369
- resolvedListCacheKey
370
- };
1
+ export * from "../core/targeting-helpers.mjs";
@@ -39,6 +39,7 @@ __export(test_controller_exports, {
39
39
  module.exports = __toCommonJS(test_controller_exports);
40
40
  var import_zod = require("zod");
41
41
  var import_adcp_server = require('./adcp-server.js');
42
+ var import_declared_input_schema = require('./declared-input-schema.js');
42
43
  var import_schemas = require('../types/schemas.generated.js');
43
44
  var import_responses = require('./responses.js');
44
45
  const CONTROLLER_SCENARIOS = {
@@ -901,20 +902,23 @@ function registerTestController(server, storeOrFactory, options) {
901
902
  capsBag.compliance_testing = { scenarios: merged };
902
903
  }
903
904
  }
904
- mcp.registerTool(
905
+ const registered = mcp.registerTool(
905
906
  "comply_test_controller",
906
907
  {
907
908
  description: "Triggers seller-side state transitions for compliance testing. Sandbox only.",
908
909
  inputSchema: TOOL_INPUT_SHAPE
909
910
  },
910
- (async (input) => {
911
- const response = await handleTestControllerRequest(storeOrFactory, input, {
911
+ (async (rawInput) => {
912
+ const parsed = await (0, import_declared_input_schema.parseDeclaredToolInput)(mcp, "comply_test_controller", rawInput);
913
+ if (!parsed.success) return parsed.response;
914
+ const response = await handleTestControllerRequest(storeOrFactory, parsed.data, {
912
915
  seedCache,
913
916
  ...options?.seedScopePrefix !== void 0 && { seedScopePrefix: options.seedScopePrefix }
914
917
  });
915
918
  return toMcpResponse(response);
916
919
  })
917
920
  );
921
+ (0, import_declared_input_schema.validateToolInputAtAdcpLayer)(mcp, "comply_test_controller", registered);
918
922
  }
919
923
  // Annotate the CommonJS export names for ESM import in node:
920
924
  0 && (module.exports = {
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { ADCP_CAPABILITIES, getSdkServer } from "./adcp-server.mjs";
3
+ import { parseDeclaredToolInput, validateToolInputAtAdcpLayer } from "./declared-input-schema.mjs";
3
4
  import {
4
5
  AccountStatusSchema,
5
6
  AudienceStatusSchema,
@@ -869,20 +870,23 @@ function registerTestController(server, storeOrFactory, options) {
869
870
  capsBag.compliance_testing = { scenarios: merged };
870
871
  }
871
872
  }
872
- mcp.registerTool(
873
+ const registered = mcp.registerTool(
873
874
  "comply_test_controller",
874
875
  {
875
876
  description: "Triggers seller-side state transitions for compliance testing. Sandbox only.",
876
877
  inputSchema: TOOL_INPUT_SHAPE
877
878
  },
878
- (async (input) => {
879
- const response = await handleTestControllerRequest(storeOrFactory, input, {
879
+ (async (rawInput) => {
880
+ const parsed = await parseDeclaredToolInput(mcp, "comply_test_controller", rawInput);
881
+ if (!parsed.success) return parsed.response;
882
+ const response = await handleTestControllerRequest(storeOrFactory, parsed.data, {
880
883
  seedCache,
881
884
  ...options?.seedScopePrefix !== void 0 && { seedScopePrefix: options.seedScopePrefix }
882
885
  });
883
886
  return toMcpResponse(response);
884
887
  })
885
888
  );
889
+ validateToolInputAtAdcpLayer(mcp, "comply_test_controller", registered);
886
890
  }
887
891
  export {
888
892
  CONTROLLER_SCENARIOS,