@adcp/sdk 13.0.0-rc.3 → 13.0.0-rc.4

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 (61) hide show
  1. package/README.md +11 -14
  2. package/dist/lib/index.d.mts +1 -1
  3. package/dist/lib/index.d.ts +1 -1
  4. package/dist/lib/index.d.ts.map +1 -1
  5. package/dist/lib/index.js.map +1 -1
  6. package/dist/lib/index.mjs.map +1 -1
  7. package/dist/lib/protocols/mcp-modern.d.ts.map +1 -1
  8. package/dist/lib/protocols/mcp-modern.js +6 -3
  9. package/dist/lib/protocols/mcp-modern.js.map +1 -1
  10. package/dist/lib/protocols/mcp-modern.mjs +6 -3
  11. package/dist/lib/protocols/mcp-modern.mjs.map +1 -1
  12. package/dist/lib/registry/index.d.mts +5 -25
  13. package/dist/lib/registry/index.d.ts +5 -25
  14. package/dist/lib/registry/index.d.ts.map +1 -1
  15. package/dist/lib/registry/index.js +5 -130
  16. package/dist/lib/registry/index.js.map +1 -1
  17. package/dist/lib/registry/index.mjs +5 -130
  18. package/dist/lib/registry/index.mjs.map +1 -1
  19. package/dist/lib/registry/sync.d.mts +8 -2
  20. package/dist/lib/registry/sync.d.ts +8 -2
  21. package/dist/lib/registry/sync.d.ts.map +1 -1
  22. package/dist/lib/registry/sync.js +8 -2
  23. package/dist/lib/registry/sync.js.map +1 -1
  24. package/dist/lib/registry/sync.mjs +8 -2
  25. package/dist/lib/registry/sync.mjs.map +1 -1
  26. package/dist/lib/registry/types.d.mts +15 -29
  27. package/dist/lib/registry/types.d.ts +15 -29
  28. package/dist/lib/registry/types.d.ts.map +1 -1
  29. package/dist/lib/registry/types.generated.d.mts +20 -5
  30. package/dist/lib/registry/types.generated.d.ts +20 -5
  31. package/dist/lib/registry/types.generated.d.ts.map +1 -1
  32. package/dist/lib/registry/types.generated.js.map +1 -1
  33. package/dist/lib/registry/types.js.map +1 -1
  34. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  35. package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
  36. package/dist/lib/testing/storyboard/runner.js +40 -6
  37. package/dist/lib/testing/storyboard/runner.js.map +1 -1
  38. package/dist/lib/testing/storyboard/runner.mjs +40 -6
  39. package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
  40. package/dist/lib/types/core.generated.d.mts +105 -58
  41. package/dist/lib/types/core.generated.d.ts +105 -58
  42. package/dist/lib/types/core.generated.d.ts.map +1 -1
  43. package/dist/lib/types/core.generated.js.map +1 -1
  44. package/dist/lib/types/schemas.generated.d.mts +2352 -473
  45. package/dist/lib/types/schemas.generated.d.ts +2352 -473
  46. package/dist/lib/types/schemas.generated.d.ts.map +1 -1
  47. package/dist/lib/types/schemas.generated.js +78 -45
  48. package/dist/lib/types/schemas.generated.js.map +1 -1
  49. package/dist/lib/types/schemas.generated.mjs +71 -45
  50. package/dist/lib/types/schemas.generated.mjs.map +1 -1
  51. package/dist/lib/types/tools.generated.d.mts +48 -44
  52. package/dist/lib/types/tools.generated.d.ts +48 -44
  53. package/dist/lib/types/tools.generated.d.ts.map +1 -1
  54. package/dist/lib/types/tools.generated.js.map +1 -1
  55. package/dist/lib/version.d.mts +3 -3
  56. package/dist/lib/version.d.ts +3 -3
  57. package/dist/lib/version.js +3 -3
  58. package/dist/lib/version.js.map +1 -1
  59. package/dist/lib/version.mjs +3 -3
  60. package/dist/lib/version.mjs.map +1 -1
  61. package/package.json +4 -4
@@ -47,7 +47,6 @@ const DEFAULT_LARGE_RESPONSE_MAX_BODY_BYTES = 2 * 1024 * 1024;
47
47
  const ERROR_BODY_PREVIEW_CHARS = 200;
48
48
  const MAX_BRAND_BULK_DOMAINS = 25;
49
49
  const MAX_BULK_DOMAINS = 100;
50
- const MAX_BRAND_HIERARCHY_CACHE_ENTRIES = 1e3;
51
50
  const MAX_CHECK_DOMAINS = 1e4;
52
51
  const COMMUNITY_MIRROR_PLATFORM_RE = /^[a-z0-9_-]{1,64}$/;
53
52
  function buildCommunityMirrorAdagents(config) {
@@ -80,7 +79,6 @@ class RegistryClient {
80
79
  hasCustomMaxBodyBytes;
81
80
  redirect;
82
81
  fetchImpl;
83
- brandHierarchyCache = /* @__PURE__ */ new Map();
84
82
  constructor(config) {
85
83
  this.baseUrl = (config?.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
86
84
  this.apiKey = config?.apiKey ?? process.env.ADCP_REGISTRY_API_KEY;
@@ -98,11 +96,13 @@ class RegistryClient {
98
96
  * Resolved registry data may include `brand_manifest` and `source` fields
99
97
  * suitable for downstream request construction. Treat all registry-supplied
100
98
  * strings as untrusted input and sanitize before injecting them into LLM
101
- * prompts, instructions, or tool-planning context.
99
+ * prompts, instructions, or tool-planning context. Pass `{ fresh: true }` to
100
+ * bypass the registry cache and attempt a live origin read.
102
101
  */
103
- async lookupBrand(domain) {
102
+ async lookupBrand(domain, options) {
104
103
  if (!domain?.trim()) throw new Error("domain is required");
105
- const url = `${this.baseUrl}/api/brands/resolve?domain=${encodeURIComponent(domain)}`;
104
+ const fresh = options?.fresh ? "&fresh=true" : "";
105
+ const url = `${this.baseUrl}/api/brands/resolve?domain=${encodeURIComponent(domain)}${fresh}`;
106
106
  return this.get(url, { nullOn404: true });
107
107
  }
108
108
  /** Search for companies by name or keyword, resolving colloquial names to canonical brand forms. */
@@ -121,84 +121,6 @@ class RegistryClient {
121
121
  const data = await this.post(`${this.baseUrl}/api/brands/resolve/bulk`, { domains });
122
122
  return data.results;
123
123
  }
124
- /**
125
- * Resolve a domain to its ordered corporate brand hierarchy.
126
- *
127
- * The returned `chain` is ordered from the resolved brand itself through each
128
- * parent to the house brand. A 404 from the registry returns `null`.
129
- */
130
- async resolveBrandHierarchy(domain, options) {
131
- const normalizedDomain = this.normalizeBrandHierarchyDomain(domain);
132
- const ttlMs = this.resolveBrandHierarchyCacheTtlMs(options);
133
- const cacheKey = this.brandHierarchyCacheKey(normalizedDomain);
134
- const cached = this.getCachedBrandHierarchy(cacheKey, options, ttlMs);
135
- if (cached !== void 0) return cached;
136
- const params = new URLSearchParams({ domain: normalizedDomain });
137
- if (options?.fresh) params.set("fresh", "true");
138
- const value = await this.get(`${this.baseUrl}/api/brands/hierarchy?${params}`, {
139
- nullOn404: true
140
- });
141
- this.setCachedBrandHierarchy(cacheKey, value, options, ttlMs);
142
- return this.cloneBrandHierarchy(value);
143
- }
144
- /**
145
- * Resolve up to 100 domains to ordered corporate brand hierarchies.
146
- *
147
- * Results are keyed by the caller-supplied domain. Unknown domains map to
148
- * `null`, matching `lookupBrands()`.
149
- */
150
- async resolveBrandHierarchies(domains, options) {
151
- if (domains.length === 0) return {};
152
- if (domains.length > MAX_BULK_DOMAINS) {
153
- throw new Error(`Cannot resolve more than ${MAX_BULK_DOMAINS} domains at once (got ${domains.length})`);
154
- }
155
- const normalizedDomains = domains.map((domain) => this.normalizeBrandHierarchyDomain(domain));
156
- const ttlMs = this.resolveBrandHierarchyCacheTtlMs(options);
157
- const results = /* @__PURE__ */ Object.create(null);
158
- const unresolved = [];
159
- const unresolvedInputsByKey = /* @__PURE__ */ new Map();
160
- for (let i = 0; i < domains.length; i++) {
161
- const domain = domains[i];
162
- const normalizedDomain = normalizedDomains[i];
163
- const cacheKey = this.brandHierarchyCacheKey(normalizedDomain);
164
- const cached = this.getCachedBrandHierarchy(cacheKey, options, ttlMs);
165
- if (cached !== void 0) {
166
- results[domain] = cached;
167
- continue;
168
- }
169
- const inputs = unresolvedInputsByKey.get(cacheKey);
170
- if (inputs) {
171
- inputs.push(domain);
172
- } else {
173
- unresolved.push(normalizedDomain);
174
- unresolvedInputsByKey.set(cacheKey, [domain]);
175
- }
176
- }
177
- if (unresolved.length > 0) {
178
- const body = { domains: unresolved };
179
- if (options?.fresh) body.fresh = true;
180
- const data = await this.post(`${this.baseUrl}/api/brands/hierarchy/bulk`, body);
181
- if (!data || typeof data !== "object" || !data.results || typeof data.results !== "object") {
182
- throw new Error("Registry hierarchy bulk response missing results");
183
- }
184
- const matchedKeys = /* @__PURE__ */ new Set();
185
- for (const [domain, value] of Object.entries(data.results)) {
186
- const cacheKey = this.brandHierarchyCacheKey(domain);
187
- const inputs = unresolvedInputsByKey.get(cacheKey);
188
- if (!inputs) continue;
189
- matchedKeys.add(cacheKey);
190
- for (const input of inputs) {
191
- results[input] = this.cloneBrandHierarchy(value);
192
- }
193
- this.setCachedBrandHierarchy(cacheKey, value, options, ttlMs);
194
- }
195
- for (const [cacheKey, inputs] of unresolvedInputsByKey.entries()) {
196
- if (matchedKeys.has(cacheKey)) continue;
197
- throw new Error(`Registry hierarchy bulk response missing result for ${inputs[0]}`);
198
- }
199
- }
200
- return results;
201
- }
202
124
  /** List brands in the registry with optional search and pagination. */
203
125
  async listBrands(options) {
204
126
  const params = this.buildParams(options);
@@ -1040,53 +962,6 @@ class RegistryClient {
1040
962
  }
1041
963
  return normalizedPlatform;
1042
964
  }
1043
- brandHierarchyCacheKey(domain) {
1044
- return domain.trim().toLowerCase();
1045
- }
1046
- normalizeBrandHierarchyDomain(domain) {
1047
- const normalized = domain?.trim();
1048
- if (!normalized) throw new Error("domain is required");
1049
- if (normalized.length > 253) throw new Error("domain must be 253 characters or fewer");
1050
- return normalized;
1051
- }
1052
- resolveBrandHierarchyCacheTtlMs(options) {
1053
- if (options?.ttlMs == null) return void 0;
1054
- if (!Number.isFinite(options.ttlMs) || options.ttlMs < 0) {
1055
- throw new Error("ttlMs must be a finite non-negative number");
1056
- }
1057
- return options.ttlMs;
1058
- }
1059
- getCachedBrandHierarchy(cacheKey, options, ttlMs) {
1060
- if (options?.fresh || ttlMs == null || ttlMs === 0) return void 0;
1061
- const cached = this.brandHierarchyCache.get(cacheKey);
1062
- if (!cached) return void 0;
1063
- if (cached.expiresAt <= Date.now()) {
1064
- this.brandHierarchyCache.delete(cacheKey);
1065
- return void 0;
1066
- }
1067
- this.brandHierarchyCache.delete(cacheKey);
1068
- this.brandHierarchyCache.set(cacheKey, cached);
1069
- return this.cloneBrandHierarchy(cached.value);
1070
- }
1071
- setCachedBrandHierarchy(cacheKey, value, options, ttlMs) {
1072
- if (ttlMs == null || ttlMs === 0) {
1073
- if (options?.fresh) this.brandHierarchyCache.delete(cacheKey);
1074
- return;
1075
- }
1076
- this.brandHierarchyCache.delete(cacheKey);
1077
- this.brandHierarchyCache.set(cacheKey, {
1078
- expiresAt: Date.now() + ttlMs,
1079
- value: this.cloneBrandHierarchy(value)
1080
- });
1081
- while (this.brandHierarchyCache.size > MAX_BRAND_HIERARCHY_CACHE_ENTRIES) {
1082
- const oldest = this.brandHierarchyCache.keys().next().value;
1083
- if (oldest == null) break;
1084
- this.brandHierarchyCache.delete(oldest);
1085
- }
1086
- }
1087
- cloneBrandHierarchy(value) {
1088
- return value == null ? null : { ...value, chain: value.chain.map((brand) => ({ ...brand })) };
1089
- }
1090
965
  resolveCommunityMirrorPublishArgs(platformOrConfig, maybeConfig) {
1091
966
  if (typeof platformOrConfig === "string") {
1092
967
  if (!maybeConfig) throw new Error("config is required");