@adcp/sdk 13.0.0-rc.2 → 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 +14 -0
  9. package/dist/lib/protocols/mcp-modern.js.map +1 -1
  10. package/dist/lib/protocols/mcp-modern.mjs +14 -0
  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
@@ -20,7 +20,6 @@ const DEFAULT_LARGE_RESPONSE_MAX_BODY_BYTES = 2 * 1024 * 1024;
20
20
  const ERROR_BODY_PREVIEW_CHARS = 200;
21
21
  const MAX_BRAND_BULK_DOMAINS = 25;
22
22
  const MAX_BULK_DOMAINS = 100;
23
- const MAX_BRAND_HIERARCHY_CACHE_ENTRIES = 1e3;
24
23
  const MAX_CHECK_DOMAINS = 1e4;
25
24
  const COMMUNITY_MIRROR_PLATFORM_RE = /^[a-z0-9_-]{1,64}$/;
26
25
  function buildCommunityMirrorAdagents(config) {
@@ -53,7 +52,6 @@ class RegistryClient {
53
52
  hasCustomMaxBodyBytes;
54
53
  redirect;
55
54
  fetchImpl;
56
- brandHierarchyCache = /* @__PURE__ */ new Map();
57
55
  constructor(config) {
58
56
  this.baseUrl = (config?.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
59
57
  this.apiKey = config?.apiKey ?? process.env.ADCP_REGISTRY_API_KEY;
@@ -71,11 +69,13 @@ class RegistryClient {
71
69
  * Resolved registry data may include `brand_manifest` and `source` fields
72
70
  * suitable for downstream request construction. Treat all registry-supplied
73
71
  * strings as untrusted input and sanitize before injecting them into LLM
74
- * prompts, instructions, or tool-planning context.
72
+ * prompts, instructions, or tool-planning context. Pass `{ fresh: true }` to
73
+ * bypass the registry cache and attempt a live origin read.
75
74
  */
76
- async lookupBrand(domain) {
75
+ async lookupBrand(domain, options) {
77
76
  if (!domain?.trim()) throw new Error("domain is required");
78
- const url = `${this.baseUrl}/api/brands/resolve?domain=${encodeURIComponent(domain)}`;
77
+ const fresh = options?.fresh ? "&fresh=true" : "";
78
+ const url = `${this.baseUrl}/api/brands/resolve?domain=${encodeURIComponent(domain)}${fresh}`;
79
79
  return this.get(url, { nullOn404: true });
80
80
  }
81
81
  /** Search for companies by name or keyword, resolving colloquial names to canonical brand forms. */
@@ -94,84 +94,6 @@ class RegistryClient {
94
94
  const data = await this.post(`${this.baseUrl}/api/brands/resolve/bulk`, { domains });
95
95
  return data.results;
96
96
  }
97
- /**
98
- * Resolve a domain to its ordered corporate brand hierarchy.
99
- *
100
- * The returned `chain` is ordered from the resolved brand itself through each
101
- * parent to the house brand. A 404 from the registry returns `null`.
102
- */
103
- async resolveBrandHierarchy(domain, options) {
104
- const normalizedDomain = this.normalizeBrandHierarchyDomain(domain);
105
- const ttlMs = this.resolveBrandHierarchyCacheTtlMs(options);
106
- const cacheKey = this.brandHierarchyCacheKey(normalizedDomain);
107
- const cached = this.getCachedBrandHierarchy(cacheKey, options, ttlMs);
108
- if (cached !== void 0) return cached;
109
- const params = new URLSearchParams({ domain: normalizedDomain });
110
- if (options?.fresh) params.set("fresh", "true");
111
- const value = await this.get(`${this.baseUrl}/api/brands/hierarchy?${params}`, {
112
- nullOn404: true
113
- });
114
- this.setCachedBrandHierarchy(cacheKey, value, options, ttlMs);
115
- return this.cloneBrandHierarchy(value);
116
- }
117
- /**
118
- * Resolve up to 100 domains to ordered corporate brand hierarchies.
119
- *
120
- * Results are keyed by the caller-supplied domain. Unknown domains map to
121
- * `null`, matching `lookupBrands()`.
122
- */
123
- async resolveBrandHierarchies(domains, options) {
124
- if (domains.length === 0) return {};
125
- if (domains.length > MAX_BULK_DOMAINS) {
126
- throw new Error(`Cannot resolve more than ${MAX_BULK_DOMAINS} domains at once (got ${domains.length})`);
127
- }
128
- const normalizedDomains = domains.map((domain) => this.normalizeBrandHierarchyDomain(domain));
129
- const ttlMs = this.resolveBrandHierarchyCacheTtlMs(options);
130
- const results = /* @__PURE__ */ Object.create(null);
131
- const unresolved = [];
132
- const unresolvedInputsByKey = /* @__PURE__ */ new Map();
133
- for (let i = 0; i < domains.length; i++) {
134
- const domain = domains[i];
135
- const normalizedDomain = normalizedDomains[i];
136
- const cacheKey = this.brandHierarchyCacheKey(normalizedDomain);
137
- const cached = this.getCachedBrandHierarchy(cacheKey, options, ttlMs);
138
- if (cached !== void 0) {
139
- results[domain] = cached;
140
- continue;
141
- }
142
- const inputs = unresolvedInputsByKey.get(cacheKey);
143
- if (inputs) {
144
- inputs.push(domain);
145
- } else {
146
- unresolved.push(normalizedDomain);
147
- unresolvedInputsByKey.set(cacheKey, [domain]);
148
- }
149
- }
150
- if (unresolved.length > 0) {
151
- const body = { domains: unresolved };
152
- if (options?.fresh) body.fresh = true;
153
- const data = await this.post(`${this.baseUrl}/api/brands/hierarchy/bulk`, body);
154
- if (!data || typeof data !== "object" || !data.results || typeof data.results !== "object") {
155
- throw new Error("Registry hierarchy bulk response missing results");
156
- }
157
- const matchedKeys = /* @__PURE__ */ new Set();
158
- for (const [domain, value] of Object.entries(data.results)) {
159
- const cacheKey = this.brandHierarchyCacheKey(domain);
160
- const inputs = unresolvedInputsByKey.get(cacheKey);
161
- if (!inputs) continue;
162
- matchedKeys.add(cacheKey);
163
- for (const input of inputs) {
164
- results[input] = this.cloneBrandHierarchy(value);
165
- }
166
- this.setCachedBrandHierarchy(cacheKey, value, options, ttlMs);
167
- }
168
- for (const [cacheKey, inputs] of unresolvedInputsByKey.entries()) {
169
- if (matchedKeys.has(cacheKey)) continue;
170
- throw new Error(`Registry hierarchy bulk response missing result for ${inputs[0]}`);
171
- }
172
- }
173
- return results;
174
- }
175
97
  /** List brands in the registry with optional search and pagination. */
176
98
  async listBrands(options) {
177
99
  const params = this.buildParams(options);
@@ -1013,53 +935,6 @@ class RegistryClient {
1013
935
  }
1014
936
  return normalizedPlatform;
1015
937
  }
1016
- brandHierarchyCacheKey(domain) {
1017
- return domain.trim().toLowerCase();
1018
- }
1019
- normalizeBrandHierarchyDomain(domain) {
1020
- const normalized = domain?.trim();
1021
- if (!normalized) throw new Error("domain is required");
1022
- if (normalized.length > 253) throw new Error("domain must be 253 characters or fewer");
1023
- return normalized;
1024
- }
1025
- resolveBrandHierarchyCacheTtlMs(options) {
1026
- if (options?.ttlMs == null) return void 0;
1027
- if (!Number.isFinite(options.ttlMs) || options.ttlMs < 0) {
1028
- throw new Error("ttlMs must be a finite non-negative number");
1029
- }
1030
- return options.ttlMs;
1031
- }
1032
- getCachedBrandHierarchy(cacheKey, options, ttlMs) {
1033
- if (options?.fresh || ttlMs == null || ttlMs === 0) return void 0;
1034
- const cached = this.brandHierarchyCache.get(cacheKey);
1035
- if (!cached) return void 0;
1036
- if (cached.expiresAt <= Date.now()) {
1037
- this.brandHierarchyCache.delete(cacheKey);
1038
- return void 0;
1039
- }
1040
- this.brandHierarchyCache.delete(cacheKey);
1041
- this.brandHierarchyCache.set(cacheKey, cached);
1042
- return this.cloneBrandHierarchy(cached.value);
1043
- }
1044
- setCachedBrandHierarchy(cacheKey, value, options, ttlMs) {
1045
- if (ttlMs == null || ttlMs === 0) {
1046
- if (options?.fresh) this.brandHierarchyCache.delete(cacheKey);
1047
- return;
1048
- }
1049
- this.brandHierarchyCache.delete(cacheKey);
1050
- this.brandHierarchyCache.set(cacheKey, {
1051
- expiresAt: Date.now() + ttlMs,
1052
- value: this.cloneBrandHierarchy(value)
1053
- });
1054
- while (this.brandHierarchyCache.size > MAX_BRAND_HIERARCHY_CACHE_ENTRIES) {
1055
- const oldest = this.brandHierarchyCache.keys().next().value;
1056
- if (oldest == null) break;
1057
- this.brandHierarchyCache.delete(oldest);
1058
- }
1059
- }
1060
- cloneBrandHierarchy(value) {
1061
- return value == null ? null : { ...value, chain: value.chain.map((brand) => ({ ...brand })) };
1062
- }
1063
938
  resolveCommunityMirrorPublishArgs(platformOrConfig, maybeConfig) {
1064
939
  if (typeof platformOrConfig === "string") {
1065
940
  if (!maybeConfig) throw new Error("config is required");