@adcp/sdk 13.0.0-rc.21 → 13.0.0-rc.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.
@@ -4,5 +4,5 @@
4
4
  "source_sha": "4e553ad955f83b49c7d221ab5c3ff78237ad02e3",
5
5
  "source_tarball_sha256": "580656d6466ef9f0d1119985e6726c2efea718dc671e2ad30957fcb2fd54af0f",
6
6
  "upstream_adcp_version": "2.5.3",
7
- "synced_at": "2026-08-15T04:54:44.918Z"
7
+ "synced_at": "2026-08-15T13:42:51.741Z"
8
8
  }
@@ -195,7 +195,7 @@ export interface UpstreamTrafficQueryResult {
195
195
  */
196
196
  export declare function runValidations(validations: StoryboardValidation[], context: ValidationContext): ValidationResult[];
197
197
  /** Capability semver emitted in run summaries and used for advisory expiry. */
198
- export declare const RUNNER_CAPABILITY_VERSION = "13.0.0-rc.21";
198
+ export declare const RUNNER_CAPABILITY_VERSION = "13.0.0-rc.22";
199
199
  /** True when a failed validation contributes to the owning step's grade. */
200
200
  export declare function validationFailsStep(result: ValidationResult): boolean;
201
201
  /**
@@ -195,7 +195,7 @@ export interface UpstreamTrafficQueryResult {
195
195
  */
196
196
  export declare function runValidations(validations: StoryboardValidation[], context: ValidationContext): ValidationResult[];
197
197
  /** Capability semver emitted in run summaries and used for advisory expiry. */
198
- export declare const RUNNER_CAPABILITY_VERSION = "13.0.0-rc.21";
198
+ export declare const RUNNER_CAPABILITY_VERSION = "13.0.0-rc.22";
199
199
  /** True when a failed validation contributes to the owning step's grade. */
200
200
  export declare function validationFailsStep(result: ValidationResult): boolean;
201
201
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"creative-delivery.d.ts","sourceRoot":"","sources":["../../../../src/lib/v2/projection/creative-delivery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3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W,CAAC,GAAG,4BAA4B,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAuG5F,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,OAAO,EACrB,iBAAiB,CAAC,EAAE,MAAM,GACzB,sBAAsB,CAuCxB"}
1
+ {"version":3,"file":"creative-delivery.d.ts","sourceRoot":"","sources":["../../../../src/lib/v2/projection/creative-delivery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,OAAO,EACP,SAAS,EACT,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAMrF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAEpE,KAAK,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,OAAO,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AAE3G,sFAAsF;AACtF,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,yBAAyB,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,GAAG;IACnG,WAAW,EAAE,mBAAmB,CAAC;IACjC,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,CAAC;AAEF,iFAAiF;AACjF,MA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AAG,SAAS,EAC9B,qBAAqB,CAAC,EAAE,qBAAqB,EAC7C,6BAA6B,CAAC,EAAE,6BAA6B,GAC5D,4BAA4B,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC7C,wBAAgB,+BAA+B,CAAC,CAAC,EAC/C,OAAO,EAAE,CAAC,EACV,kBAAkB,EAAE,aAAa,CAAC,+BAA+B,CAAC,EAClE,QAAQ,EAAE,sBAAsB,EAChC,qBAAqB,CAAC,EAAE,qBAAqB,EAC7C,6BAA6B,CAAC,EAAE,6BAA6B,GAC5D,4BAA4B,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,4BAA4B,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAuG5F,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,OAAO,EACrB,iBAAiB,CAAC,EAAE,MAAM,GACzB,sBAAsB,CAuCxB"}
@@ -597,6 +597,7 @@ function projectPackageSelectors(pkg, wireMode, operation, legacyFormatConverter
597
597
  next.format_ids = resolved;
598
598
  delete next.format_option_refs;
599
599
  delete next.format_kind;
600
+ delete next.params;
600
601
  return next;
601
602
  }
602
603
  next.format_ids = dedupeLegacyRefs(selectedCandidates.map((candidate) => candidate.ref));
@@ -640,6 +641,7 @@ function projectPackageSelectors(pkg, wireMode, operation, legacyFormatConverter
640
641
  }
641
642
  }
642
643
  delete next.format_kind;
644
+ delete next.params;
643
645
  }
644
646
  return next;
645
647
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/v2/projection/creative-delivery.ts"],"sourcesContent":["import type {\n CreativeAsset,\n CreateMediaBuyRequest,\n CreateMediaBuyResponse,\n FormatOptionReference,\n GetProductsRequest,\n GetProductsResponse,\n GetCreativeDeliveryResponse,\n GetMediaBuyDeliveryResponse,\n GetMediaBuysResponse,\n CreativeFilters,\n ListCreativesResponse,\n ListCreativesRequest,\n PackageRequest,\n PackageUpdate,\n Package,\n Placement,\n Product,\n SyncCreativesRequest,\n SyncCreativesResponse,\n UpdateMediaBuyRequest,\n UpdateMediaBuyResponse,\n} from '../../types/tools.generated';\nimport { projectV1ProductToV2, resolveCanonicalFormatKind } from './v1-to-v2';\nimport type { LegacyFormatConverter } from './v1-to-v2';\nimport { CanonicalFormatLegacyResolutionError, resolveCanonicalFormatLegacyRefs } from './v2-to-v1';\nimport type { CanonicalFormatLegacyResolver } from './v2-to-v1';\nimport type { CanonicalFormatKind, ProjectionDiagnostic, V1FormatId } from './types';\nimport {\n legacyFormatRefsForDeclaration,\n selectedFormatOptions,\n transferLegacyCreativeMetadata,\n} from './legacy-metadata';\nimport type { CanonicalFormatDeclaration } from './legacy-metadata';\n\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, Extract<keyof T, K>> : never;\n\n/** Primary SDK creative shape. Legacy creative identity is a wire-adapter concern. */\nexport type CanonicalCreativeAsset = Omit<CanonicalCreativeResponse<CreativeAsset>, 'format_kind'> & {\n format_kind: CanonicalFormatKind;\n format_id?: never;\n};\n\n/** Explicit compatibility-only creative shape used at a legacy wire boundary. */\nexport type LegacyCreativeAsset = Omit<CreativeAsset, 'format_id' | 'format_kind' | 'format_option_ref'> & {\n format_id: V1FormatId;\n format_kind?: never;\n format_option_ref?: never;\n};\n\nexport type CanonicalPackageRequest = DistributiveOmit<\n CanonicalCreativeResponse<PackageRequest>,\n 'creatives' | 'format_ids'\n> & {\n creatives?: CanonicalCreativeAsset[];\n format_ids?: never;\n};\nexport type NonEmptyCanonicalFormatDeclarations = [CanonicalFormatDeclaration, ...CanonicalFormatDeclaration[]];\nexport type CanonicalPlacement = Omit<CanonicalCreativeResponse<Placement>, 'format_ids' | 'format_options'> & {\n format_ids?: never;\n format_options?: NonEmptyCanonicalFormatDeclarations;\n};\nexport type CanonicalProduct = Omit<\n CanonicalCreativeResponse<Product>,\n 'format_ids' | 'format_options' | 'placements'\n> & {\n product_id: string;\n format_ids?: never;\n format_options: NonEmptyCanonicalFormatDeclarations;\n placements?: CanonicalPlacement[];\n};\ntype CanonicalGetProductsField = Exclude<NonNullable<GetProductsRequest['fields']>[number], 'format_ids'>;\n/** Primary product discovery request cannot ask the SDK to expose legacy format IDs. */\nexport type CanonicalGetProductsRequest = Omit<GetProductsRequest, 'fields'> & {\n fields?: CanonicalGetProductsField[];\n};\nexport type CanonicalGetProductsResponse = Omit<CanonicalCreativeResponse<GetProductsResponse>, 'products'> & {\n products: CanonicalProduct[];\n projection: { diagnostics: ProjectionDiagnostic[] };\n};\nexport type CanonicalPackageUpdate = Omit<CanonicalCreativeResponse<PackageUpdate>, 'creatives'> & {\n creatives?: CanonicalCreativeAsset[];\n};\nexport type CanonicalPackage = CanonicalCreativeResponse<Package>;\nexport type CanonicalCreateMediaBuyRequest = Omit<CanonicalCreativeResponse<CreateMediaBuyRequest>, 'packages'> & {\n packages?: CanonicalPackageRequest[];\n};\nexport type CanonicalUpdateMediaBuyRequest = Omit<\n CanonicalCreativeResponse<UpdateMediaBuyRequest>,\n 'packages' | 'new_packages'\n> & {\n packages?: CanonicalPackageUpdate[];\n new_packages?: CanonicalPackageRequest[];\n};\nexport type CanonicalSyncCreativesRequest = Omit<CanonicalCreativeResponse<SyncCreativesRequest>, 'creatives'> & {\n creatives: CanonicalCreativeAsset[];\n};\nexport type CanonicalListedCreative = Omit<\n CanonicalCreativeResponse<ListCreativesResponse['creatives'][number]>,\n 'format_id' | 'format_kind' | 'format_option_ref'\n> & {\n format_kind: CanonicalFormatKind;\n format_option_ref?: FormatOptionReference;\n format_id?: never;\n};\nexport type CanonicalListCreativesResponse = Omit<CanonicalCreativeResponse<ListCreativesResponse>, 'creatives'> & {\n creatives: CanonicalListedCreative[];\n};\nexport type CanonicalCreateMediaBuyResponse = CanonicalCreativeResponse<CreateMediaBuyResponse>;\nexport type CanonicalUpdateMediaBuyResponse = CanonicalCreativeResponse<UpdateMediaBuyResponse>;\nexport type CanonicalSyncCreativesResponse = CanonicalCreativeResponse<SyncCreativesResponse>;\nexport type CanonicalGetMediaBuysResponse = CanonicalCreativeResponse<GetMediaBuysResponse>;\nexport type CanonicalGetMediaBuyDeliveryResponse = CanonicalCreativeResponse<GetMediaBuyDeliveryResponse>;\nexport type CanonicalGetCreativeDeliveryResponse = CanonicalCreativeResponse<GetCreativeDeliveryResponse>;\n\nexport type CanonicalCreativeFilters = Omit<CanonicalCreativeResponse<CreativeFilters>, 'format_ids'> & {\n format_ids?: never;\n};\n\ntype CanonicalListCreativeField = Exclude<NonNullable<ListCreativesRequest['fields']>[number], 'format_id'>;\n\n/** Primary list request: legacy named-format filters and response fields are migration-only. */\nexport type CanonicalListCreativesRequest = Omit<\n CanonicalCreativeResponse<ListCreativesRequest>,\n 'filters' | 'fields'\n> & {\n filters?: CanonicalCreativeFilters;\n fields?: CanonicalListCreativeField[];\n};\n\ntype IsLegacyCreativeIdentityKey<K extends PropertyKey> = K extends string\n ? K extends '_message' | `${string}format_id${string}` | `${string}v1_format_ref${string}`\n ? true\n : false\n : false;\n\n/** Recursively removes legacy creative routing identity from primary response types. */\nexport type CanonicalCreativeResponse<T> = T extends (...args: never[]) => unknown\n ? T\n : T extends readonly (infer TItem)[]\n ? CanonicalCreativeResponse<TItem>[]\n : T extends object\n ? {\n [K in keyof T as IsLegacyCreativeIdentityKey<K> extends true ? never : K]: CanonicalCreativeResponse<T[K]>;\n }\n : T;\n\n/** Runtime counterpart to {@link CanonicalCreativeResponse}. */\nexport function stripLegacyCreativeIdentity<T>(value: T): CanonicalCreativeResponse<T> {\n const legacyTokens = new Set<string>();\n const legacyUrlTokens = new Set<string>();\n const canonicalKinds = new Set<string>([\n 'image',\n 'html5',\n 'display_tag',\n 'image_carousel',\n 'video_hosted',\n 'video_vast',\n 'audio_hosted',\n 'audio_daast',\n 'sponsored_placement',\n 'native_in_feed',\n 'responsive_creative',\n 'agent_placement',\n 'custom',\n ]);\n const creativeIdentityKey = (key: string): boolean =>\n key === '_message' || /(^|_)(?:format_ids?|v1_format_ref)($|_)/.test(key);\n const ownDataValue = (owner: Record<string, unknown>, key: string): unknown => {\n const descriptor = Object.getOwnPropertyDescriptor(owner, key);\n return descriptor && 'value' in descriptor ? descriptor.value : undefined;\n };\n const nonCreativeAgentContext = (key: string | undefined): boolean =>\n typeof key === 'string' &&\n !/(^|_)(?:creative|format|legacy)($|_)/.test(key) &&\n /(^|_)(?:agents?|agent_details|agent_info)($|_)/.test(key);\n const nonCreativeSignalContext = (owner: Record<string, unknown>, key: string | undefined): boolean =>\n ownDataValue(owner, 'source') === 'agent' && typeof key === 'string' && /(^|_)signal_ids?($|_)/.test(key);\n const nonCreativeListContext = (owner: Record<string, unknown>, key: string | undefined): boolean =>\n typeof ownDataValue(owner, 'list_id') === 'string' &&\n typeof key === 'string' &&\n /(^|_)(?:property_list|collection_list|list_ref)($|_)/.test(key);\n const explicitNonCreativeContextKey = (key: string | undefined): boolean =>\n nonCreativeAgentContext(key) ||\n (typeof key === 'string' && /(^|_)(?:signal_ids?|property_list|collection_list|list_ref)($|_)/.test(key));\n const standaloneLegacyTuple = (owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (\n nonCreativeAgentContext(ownerKey) ||\n nonCreativeSignalContext(owner, ownerKey) ||\n nonCreativeListContext(owner, ownerKey)\n ) {\n return false;\n }\n if (typeof ownDataValue(owner, 'agent_url') !== 'string' || typeof ownDataValue(owner, 'id') !== 'string') {\n return false;\n }\n return true;\n };\n const preservesNonCreativeAgentUrl = (key: string, owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (!/(^|_)agent_url($|_)/.test(key)) return false;\n if (key === 'agent_url') {\n return (\n nonCreativeAgentContext(ownerKey) ||\n nonCreativeSignalContext(owner, ownerKey) ||\n nonCreativeListContext(owner, ownerKey) ||\n (typeof ownDataValue(owner, 'id') === 'string' && !standaloneLegacyTuple(owner, ownerKey))\n );\n }\n return !/(^|_)(?:creative|format|legacy|offending|target|input|output)($|_)/.test(key);\n };\n const legacyKey = (key: string, owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (creativeIdentityKey(key)) return true;\n if (!/(^|_)agent_url($|_)/.test(key)) return false;\n if (preservesNonCreativeAgentUrl(key, owner, ownerKey)) return false;\n const value = ownDataValue(owner, key);\n // Composite agent URL fields are used by several non-creative protocol\n // domains. Remove them only when their value is known to belong to a\n // legacy creative identity collected elsewhere in this payload.\n return typeof value === 'string' && legacyTokens.has(value);\n };\n const collectStrings = (current: unknown, seen = new WeakSet<object>(), ownerKey?: string): void => {\n if (typeof current === 'string') {\n if (current.length > 1) {\n legacyTokens.add(current);\n if (ownerKey === 'agent_url' || /^https?:\\/\\//i.test(current)) legacyUrlTokens.add(current);\n }\n return;\n }\n if (current === null || typeof current !== 'object' || seen.has(current)) return;\n seen.add(current);\n if (Array.isArray(current)) {\n for (const child of current) collectStrings(child, seen, ownerKey);\n return;\n }\n for (const key of Reflect.ownKeys(current)) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor || !('value' in descriptor)) continue;\n collectStrings(descriptor.value, seen, typeof key === 'string' ? key : ownerKey);\n }\n };\n const tokenSeenByContext = {\n default: new WeakSet<object>(),\n nonCreativeAgent: new WeakSet<object>(),\n };\n const collectLegacyTokens = (current: unknown, ownerKey?: string): void => {\n const seen = explicitNonCreativeContextKey(ownerKey)\n ? tokenSeenByContext.nonCreativeAgent\n : tokenSeenByContext.default;\n if (current === null || typeof current !== 'object' || seen.has(current)) return;\n seen.add(current);\n if (Array.isArray(current)) {\n for (const child of current) collectLegacyTokens(child, ownerKey);\n return;\n }\n const owner = current as Record<string, unknown>;\n if (standaloneLegacyTuple(owner, ownerKey)) collectStrings(owner, new WeakSet<object>(), ownerKey);\n for (const key of Object.getOwnPropertyNames(owner)) {\n const descriptor = Object.getOwnPropertyDescriptor(owner, key);\n if (!descriptor || !('value' in descriptor)) continue;\n const child = descriptor.value;\n if (creativeIdentityKey(key)) collectStrings(child);\n else collectLegacyTokens(child, key);\n }\n };\n collectLegacyTokens(value);\n\n const sanitizeText = (text: string, ownerKey?: string): string => {\n const mentionsLegacyIdentity =\n /\\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\\b/.test(\n text\n );\n let safe = text;\n if (mentionsLegacyIdentity) {\n // Diagnostics sometimes repeat only the flattened identity and omit the\n // structured field that supplied it. Fail closed for those orphan\n // values while leaving unrelated URLs in ordinary messages untouched.\n safe = safe.replace(/\\bhttps?:\\/\\/[^\\s\"'`<>]+/g, '[legacy creative identity]');\n safe = safe.replace(\n /(\\b(?:format_ids?|v1_format_ref|agent_url)\\b(?:\\s+(?:was|is|from))?\\s*[:=]?\\s*[\"'`]?)\\b[a-zA-Z0-9][a-zA-Z0-9_.-]{1,}/g,\n '$1[legacy creative identity]'\n );\n }\n safe = safe.replace(\n /\\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\\b/g,\n 'legacy creative identity'\n );\n for (const token of [...legacyUrlTokens].sort((left, right) => right.length - left.length)) {\n safe = safe.split(token).join('[legacy creative identity]');\n }\n const diagnosticContext =\n mentionsLegacyIdentity ||\n (typeof ownerKey === 'string' &&\n /(^|_)(?:message|question|prompt|error|reason|summary|context|stack|diagnostic)($|_)/.test(ownerKey));\n if (diagnosticContext) {\n for (const token of [...legacyTokens].sort((left, right) => right.length - left.length)) {\n if (legacyUrlTokens.has(token) || canonicalKinds.has(token)) continue;\n if (token.length < 8 && !/[_:/. -]/.test(token)) continue;\n safe = safe.split(token).join('[legacy creative identity]');\n }\n }\n return safe;\n };\n\n // The same object can appear once under an explicit agent field and once\n // under an ambiguous extension field. Cache by policy context so an allowed\n // agent occurrence cannot make a later ambiguous tuple fail open (or vice\n // versa based on property order).\n const seenByContext = {\n default: new WeakMap<object, unknown>(),\n nonCreativeAgent: new WeakMap<object, unknown>(),\n };\n const hasCustomToJSON = (candidate: object): boolean => {\n let cursor: object | null = candidate;\n while (cursor) {\n const descriptor = Object.getOwnPropertyDescriptor(cursor, 'toJSON');\n if (descriptor) return !('value' in descriptor) || typeof descriptor.value === 'function';\n cursor = Object.getPrototypeOf(cursor) as object | null;\n }\n return false;\n };\n const strip = (current: unknown, ownerKey?: string): unknown => {\n if (typeof current === 'string') return sanitizeText(current, ownerKey);\n if (current === null || typeof current !== 'object') return current;\n const seen = explicitNonCreativeContextKey(ownerKey) ? seenByContext.nonCreativeAgent : seenByContext.default;\n const cached = seen.get(current);\n if (cached !== undefined) return cached;\n if (Array.isArray(current)) {\n const result: unknown[] = [];\n seen.set(current, result);\n const needsSafeToJSON = hasCustomToJSON(current);\n let changed = needsSafeToJSON || Object.getPrototypeOf(current) !== Array.prototype;\n for (const key of Reflect.ownKeys(current)) {\n if (key === 'length') continue;\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor) continue;\n if (!('value' in descriptor)) {\n changed = true;\n continue;\n }\n if (key === 'toJSON' && typeof descriptor.value === 'function') {\n changed = true;\n continue;\n }\n if (typeof key === 'string' && legacyKey(key, current as unknown as Record<string, unknown>, ownerKey)) {\n changed = true;\n continue;\n }\n const safe = strip(descriptor.value, typeof key === 'string' && !/^\\d+$/.test(key) ? key : ownerKey);\n if (safe !== descriptor.value) changed = true;\n Object.defineProperty(result, key, { ...descriptor, value: safe });\n }\n result.length = current.length;\n if (!changed) {\n seen.set(current, current);\n return current;\n }\n if (needsSafeToJSON) {\n Object.defineProperty(result, 'toJSON', {\n configurable: true,\n enumerable: false,\n value: () => Array.from(result),\n });\n }\n transferLegacyCreativeMetadata(current, result);\n return result;\n }\n const prototype = Object.getPrototypeOf(current);\n const plain = prototype === Object.prototype || prototype === null;\n const safePrototype =\n prototype === null ? null : Error.prototype.isPrototypeOf(current) ? Error.prototype : Object.prototype;\n // Never retain an adopter-controlled prototype. Inherited getters and\n // methods are behavior, not inspected data, and can reveal legacy identity\n // after this boundary has supposedly been sanitized.\n const result: Record<string | symbol, unknown> = Object.create(safePrototype);\n seen.set(current, result);\n const owner = current as Record<string, unknown>;\n if (standaloneLegacyTuple(owner, ownerKey)) {\n const empty = {};\n seen.set(current, empty);\n return empty;\n }\n const needsSafeToJSON = hasCustomToJSON(current);\n let changed = !plain || needsSafeToJSON;\n const keys: Array<string | symbol> = Reflect.ownKeys(current);\n for (const key of keys) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor) continue;\n if (!('value' in descriptor)) {\n // Never reflect accessors across the canonical boundary. Evaluating a\n // retained getter later could reveal a legacy identity that was not\n // present while this object was inspected (and may run adopter code).\n changed = true;\n continue;\n }\n const child = descriptor.value;\n if (typeof key === 'symbol') {\n const safe = strip(child);\n if (safe !== child) changed = true;\n if (!plain) Object.defineProperty(result, key, { ...descriptor, value: safe });\n continue;\n }\n if (key === 'toJSON' && typeof child === 'function') {\n changed = true;\n continue;\n }\n if (legacyKey(key, owner, ownerKey)) {\n changed = true;\n continue;\n }\n const safe = preservesNonCreativeAgentUrl(key, owner, ownerKey) ? child : strip(child, key);\n if (safe !== child) changed = true;\n if (plain && typeof key === 'string' && descriptor.enumerable) result[key] = safe;\n else Object.defineProperty(result, key, { ...descriptor, value: safe });\n }\n if (!changed) {\n seen.set(current, current);\n return current;\n }\n if (needsSafeToJSON) {\n Object.defineProperty(result, 'toJSON', {\n configurable: true,\n enumerable: false,\n value: () => {\n const serialized: Record<string, unknown> = {};\n for (const key of Object.keys(result)) serialized[key] = result[key];\n return serialized;\n },\n });\n }\n transferLegacyCreativeMetadata(current, result);\n return result;\n };\n return strip(value) as CanonicalCreativeResponse<T>;\n}\n\nexport type CanonicalProjectedCreative<T> = Omit<T, 'format_id' | 'format_kind'> & {\n format_kind: CanonicalFormatKind;\n format_id?: never;\n};\nexport type LegacyProjectedCreative<T> = Omit<T, 'format_id' | 'format_kind' | 'format_option_ref'> & {\n format_id: V1FormatId;\n format_kind?: never;\n format_option_ref?: never;\n};\n\ntype ProjectedCreativeArray<T, TMode extends 'canonical' | 'legacy'> =\n T extends ReadonlyArray<infer TCreative>\n ? Array<TMode extends 'canonical' ? CanonicalProjectedCreative<TCreative> : LegacyProjectedCreative<TCreative>>\n : T;\ntype ReplaceCreatives<T, TMode extends 'canonical' | 'legacy'> = T extends object\n ? 'creatives' extends keyof T\n ? Omit<T, 'creatives'> &\n (Record<never, never> extends Pick<T, 'creatives'>\n ? { creatives?: ProjectedCreativeArray<T['creatives'], TMode> }\n : { creatives: ProjectedCreativeArray<T['creatives'], TMode> })\n : T\n : T;\ntype ProjectedContainerArray<T, TMode extends 'canonical' | 'legacy'> =\n T extends ReadonlyArray<infer TContainer> ? Array<ReplaceCreatives<TContainer, TMode>> : T;\ntype ReplaceContainerKey<\n T,\n TKey extends 'packages' | 'new_packages',\n TMode extends 'canonical' | 'legacy',\n> = TKey extends keyof T\n ? Record<never, never> extends Pick<T, TKey>\n ? { [K in TKey]?: ProjectedContainerArray<T[TKey], TMode> }\n : { [K in TKey]: ProjectedContainerArray<T[TKey], TMode> }\n : Record<never, never>;\n\nexport type ProjectedMediaBuyCreativeRequest<T, TMode extends 'canonical' | 'legacy'> = Omit<\n T,\n 'packages' | 'new_packages'\n> &\n ReplaceContainerKey<T, 'packages', TMode> &\n ReplaceContainerKey<T, 'new_packages', TMode>;\nexport type ProjectedSyncCreativeRequest<T, TMode extends 'canonical' | 'legacy'> = ReplaceCreatives<T, TMode>;\n\nexport type CreativeFormatWireMode = 'canonical' | 'legacy' | 'unknown';\n\nexport interface CreativeFormatSelectorContainer {\n package_id?: string;\n format_ids?: unknown[];\n formats?: unknown[];\n format_options?: unknown[];\n format_option_refs?: unknown[];\n format_kind?: unknown;\n params?: unknown;\n /** Internal composition seam used to preserve per-package selector constraints. */\n selector_containers?: ReadonlyArray<CreativeFormatSelectorContainer>;\n [key: string]: unknown;\n}\n\n/** Canonical package/product selectors accepted by the primary sync API. */\nexport interface CanonicalCreativeFormatSelectorContainer {\n package_id?: string;\n format_options?: ReadonlyArray<CanonicalFormatDeclaration>;\n format_option_refs?: ReadonlyArray<FormatOptionReference>;\n format_kind?: CanonicalFormatKind;\n params?: CanonicalFormatDeclaration['params'];\n selector_containers?: ReadonlyArray<CanonicalCreativeFormatSelectorContainer>;\n}\n\nexport interface SyncCreativeFormatProjection {\n selectorContainers: ReadonlyArray<CanonicalCreativeFormatSelectorContainer>;\n legacyFormatConverter?: LegacyFormatConverter;\n}\n\nexport class CreativeFormatProjectionError extends Error {\n readonly code = 'ADCP_CREATIVE_FORMAT_PROJECTION_FAILED';\n\n constructor(\n readonly operation: string,\n readonly creativeId: string,\n reason: string\n ) {\n super(`${operation}: cannot select a valid creative wire shape for ${creativeId}: ${reason}`);\n this.name = 'CreativeFormatProjectionError';\n }\n}\n\nexport class CreativeFormatCapabilityError extends Error {\n readonly code = 'ADCP_CREATIVE_FORMAT_CAPABILITY_CONTRADICTION';\n\n constructor(message: string) {\n super(message);\n this.name = 'CreativeFormatCapabilityError';\n }\n}\n\nconst CANONICAL_FORMAT_KINDS = new Set<CanonicalFormatKind>([\n 'image',\n 'html5',\n 'display_tag',\n 'image_carousel',\n 'video_hosted',\n 'video_vast',\n 'audio_hosted',\n 'audio_daast',\n 'sponsored_placement',\n 'native_in_feed',\n 'responsive_creative',\n 'agent_placement',\n 'custom',\n]);\n\ntype LegacyCandidate = {\n ref: V1FormatId;\n formatKind?: string;\n formatOptionRef?: FormatOptionReference;\n selectorParams?: unknown;\n};\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction legacyRef(value: unknown): V1FormatId | undefined {\n const candidate = record(value);\n if (!candidate || typeof candidate.agent_url !== 'string' || typeof candidate.id !== 'string') return undefined;\n if (candidate.agent_url.length === 0 || candidate.id.length === 0) return undefined;\n return {\n agent_url: candidate.agent_url,\n id: candidate.id,\n ...(typeof candidate.width === 'number' ? { width: candidate.width } : {}),\n ...(typeof candidate.height === 'number' ? { height: candidate.height } : {}),\n ...(typeof candidate.duration_ms === 'number' ? { duration_ms: candidate.duration_ms } : {}),\n };\n}\n\nfunction refsFromValue(value: unknown): V1FormatId[] {\n if (Array.isArray(value)) return value.flatMap(item => refsFromValue(item));\n const ref = legacyRef(value);\n return ref ? [ref] : [];\n}\n\ntype CanonicalFormatOptionReference = FormatOptionReference & { canonical_formats_only?: true };\n\nfunction optionReference(value: unknown): CanonicalFormatOptionReference | undefined {\n const option = record(value);\n if (!option || typeof option.format_option_id !== 'string' || option.format_option_id.length === 0) return undefined;\n const canonicalOnly = option.canonical_formats_only === true ? { canonical_formats_only: true as const } : {};\n if (typeof option.publisher_domain === 'string') {\n return {\n scope: 'publisher',\n publisher_domain: option.publisher_domain,\n format_option_id: option.format_option_id,\n ...canonicalOnly,\n };\n }\n return { scope: 'product', format_option_id: option.format_option_id, ...canonicalOnly };\n}\n\nfunction sameOptionReference(left: FormatOptionReference, right: FormatOptionReference): boolean {\n return (\n left.scope === right.scope &&\n left.format_option_id === right.format_option_id &&\n (left.scope !== 'publisher' || (right.scope === 'publisher' && left.publisher_domain === right.publisher_domain))\n );\n}\n\nfunction selectedOptionReferences(container: CreativeFormatSelectorContainer): CanonicalFormatOptionReference[] {\n const direct = Array.isArray(container.format_option_refs)\n ? container.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n const nested = Array.isArray(container.selector_containers)\n ? container.selector_containers.flatMap(selectedOptionReferences)\n : [];\n return [...direct, ...nested];\n}\n\nfunction agentIdentity(value: string): string {\n try {\n // URL parsing normalizes the scheme/host (the case-insensitive pieces)\n // while preserving case-sensitive paths, queries, and fragments.\n return new URL(value).href;\n } catch {\n return value;\n }\n}\n\nfunction sameLegacyIdentity(left: V1FormatId, right: V1FormatId): boolean {\n return agentIdentity(left.agent_url) === agentIdentity(right.agent_url) && left.id === right.id;\n}\n\nfunction candidatesFromContainer(\n container: CreativeFormatSelectorContainer,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver,\n operation = 'creative_delivery'\n): LegacyCandidate[] {\n if (Array.isArray(container.selector_containers)) {\n return uniqueCandidates(\n container.selector_containers.flatMap(candidate =>\n candidatesFromContainer(candidate, canonicalFormatLegacyResolver, operation)\n )\n );\n }\n const candidates: LegacyCandidate[] = [];\n const containerKind = typeof container.format_kind === 'string' ? container.format_kind : undefined;\n for (const key of ['format_ids', 'formats'] as const) {\n for (const ref of refsFromValue(container[key])) {\n candidates.push({\n ref,\n formatKind: resolveCanonicalFormatKind(ref.id) ?? containerKind,\n selectorParams: container.params,\n });\n }\n }\n const formatOptions = [\n ...(Array.isArray(container.format_options) ? container.format_options : []),\n ...selectedFormatOptions(container),\n ];\n for (const optionValue of formatOptions) {\n const option = record(optionValue);\n if (!option) continue;\n const formatKind = typeof option.format_kind === 'string' ? option.format_kind : undefined;\n const formatOptionRef = optionReference(option);\n let refs = [...legacyFormatRefsForDeclaration(option)];\n if (refs.length === 0 && option.canonical_formats_only !== true && formatKind) {\n try {\n refs =\n resolveCanonicalFormatLegacyRefs(canonicalFormatLegacyResolver, {\n source: 'product',\n declaration: option as unknown as import('./types').V2ProductFormatDeclaration,\n productId: typeof container.product_id === 'string' ? container.product_id : '<selector>',\n field: formatOptionRef?.format_option_id ?? '(format option)',\n }) ?? [];\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(format option)',\n 'canonical format legacy resolver returned an invalid product mapping'\n );\n }\n }\n for (const ref of refs) {\n candidates.push({ ref, formatKind, formatOptionRef, selectorParams: option.params ?? container.params });\n }\n }\n return uniqueCandidates(candidates);\n}\n\nfunction containerOptsOutOfLegacy(\n container: CreativeFormatSelectorContainer,\n formatKind?: string,\n formatOptionRef?: FormatOptionReference\n): boolean {\n if ((formatOptionRef as CanonicalFormatOptionReference | undefined)?.canonical_formats_only === true) return true;\n if (\n Array.isArray(container.selector_containers) &&\n container.selector_containers.some(candidate => containerOptsOutOfLegacy(candidate, formatKind, formatOptionRef))\n ) {\n return true;\n }\n const selectedRefs = selectedOptionReferences(container);\n if (\n selectedRefs.some(ref => {\n if (ref.canonical_formats_only !== true) return false;\n return formatOptionRef === undefined || sameOptionReference(ref, formatOptionRef);\n })\n ) {\n return true;\n }\n const formatOptions = [\n ...(Array.isArray(container.format_options) ? container.format_options : []),\n ...selectedFormatOptions(container),\n ];\n return formatOptions.some(value => {\n const option = record(value);\n if (!option || option.canonical_formats_only !== true) return false;\n if (formatKind && option.format_kind !== formatKind) return false;\n if (formatOptionRef) {\n const optionRef = optionReference(option);\n if (!optionRef || !sameOptionReference(optionRef, formatOptionRef)) return false;\n }\n return true;\n });\n}\n\nfunction candidateKey(candidate: LegacyCandidate): string {\n const ref = candidate.ref;\n return [\n agentIdentity(ref.agent_url),\n ref.id,\n ref.width ?? '',\n ref.height ?? '',\n ref.duration_ms ?? '',\n candidate.formatOptionRef?.scope ?? '',\n candidate.formatOptionRef?.format_option_id ?? '',\n candidate.formatOptionRef?.scope === 'publisher' ? candidate.formatOptionRef.publisher_domain : '',\n ].join('|');\n}\n\nfunction uniqueCandidates(candidates: LegacyCandidate[]): LegacyCandidate[] {\n return [...new Map(candidates.map(candidate => [candidateKey(candidate), candidate])).values()];\n}\n\nfunction refMatchesParams(ref: V1FormatId, paramsValue: unknown): boolean {\n const params = record(paramsValue);\n if (!params) return true;\n const sizes = Array.isArray(params.sizes) ? params.sizes.flatMap(size => (record(size) ? [record(size)!] : [])) : [];\n if (sizes.length === 1) {\n const size = sizes[0]!;\n if (typeof size.width === 'number' && ref.width !== size.width) return false;\n if (typeof size.height === 'number' && ref.height !== size.height) return false;\n }\n if (typeof params.width === 'number' && ref.width !== params.width) return false;\n if (typeof params.height === 'number' && ref.height !== params.height) return false;\n if (typeof params.duration_ms_exact === 'number' && ref.duration_ms !== params.duration_ms_exact) return false;\n return true;\n}\n\nfunction selectLegacyRef(\n creative: Record<string, unknown>,\n container: CreativeFormatSelectorContainer,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver,\n operation = 'creative_delivery'\n): V1FormatId | undefined {\n let candidates = candidatesFromContainer(container, canonicalFormatLegacyResolver, operation);\n const creativeOptionRef = optionReference(creative.format_option_ref);\n const selectedOptionRefs = Array.isArray(container.format_option_refs)\n ? container.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n if (creativeOptionRef) {\n if (selectedOptionRefs.length > 0 && !selectedOptionRefs.some(ref => sameOptionReference(ref, creativeOptionRef))) {\n return undefined;\n }\n candidates = candidates.filter(\n candidate => candidate.formatOptionRef && sameOptionReference(candidate.formatOptionRef, creativeOptionRef)\n );\n } else if (selectedOptionRefs.length > 0) {\n candidates = candidates.filter(\n candidate =>\n candidate.formatOptionRef &&\n selectedOptionRefs.some(ref => sameOptionReference(ref, candidate.formatOptionRef!))\n );\n }\n const existing = legacyRef(creative.format_id);\n if (existing) {\n const exact = candidates.filter(\n candidate =>\n sameLegacyIdentity(candidate.ref, existing) &&\n (existing.width === undefined || candidate.ref.width === existing.width) &&\n (existing.height === undefined || candidate.ref.height === existing.height) &&\n (existing.duration_ms === undefined || candidate.ref.duration_ms === existing.duration_ms)\n );\n if (exact.length === 1) return exact[0]!.ref;\n return candidates.length === 0 ? existing : undefined;\n }\n\n if (typeof creative.format_kind !== 'string') return undefined;\n let matching = candidates.filter(candidate => candidate.formatKind === creative.format_kind);\n const constrained = matching.filter(candidate => refMatchesParams(candidate.ref, candidate.selectorParams));\n if (constrained.length > 0) matching = constrained;\n return matching.length === 1 ? matching[0]!.ref : undefined;\n}\n\nfunction projectCreative<T extends Record<string, unknown>>(creative: T, formatId: V1FormatId): T {\n const next: Record<string, unknown> = { ...creative };\n delete next.format_kind;\n delete next.format_option_ref;\n next.format_id = { ...formatId };\n return next as T;\n}\n\nfunction dedupeLegacyRefs(refs: readonly V1FormatId[]): V1FormatId[] {\n return [...new Map(refs.map(ref => [candidateKey({ ref }), { ...ref }])).values()];\n}\n\nfunction projectPackageSelectors(\n pkg: Record<string | symbol, unknown>,\n wireMode: CreativeFormatWireMode,\n operation: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): Record<string | symbol, unknown> {\n const next = { ...pkg };\n const optionRefs = Array.isArray(pkg.format_option_refs)\n ? pkg.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n const legacyRefs = refsFromValue(pkg.format_ids);\n const candidates = candidatesFromContainer(\n pkg as CreativeFormatSelectorContainer,\n wireMode === 'canonical' ? undefined : canonicalFormatLegacyResolver,\n operation\n );\n const canonicalKind = typeof pkg.format_kind === 'string' ? pkg.format_kind : undefined;\n\n if (wireMode === 'canonical') {\n if (optionRefs.length > 0) {\n // Rebuild the array before transport so SDK-private downgrade metadata\n // never crosses the canonical wire boundary.\n next.format_option_refs = optionRefs.map(ref => ({ ...ref }));\n }\n if (legacyRefs.length > 0) {\n let mappedRefs = legacyRefs.flatMap(legacy => {\n const matches = candidates.filter(candidate => sameLegacyIdentity(candidate.ref, legacy));\n if (matches.length !== 1 || !matches[0]!.formatOptionRef) return [];\n return [matches[0]!.formatOptionRef];\n });\n if (optionRefs.length === 0 && mappedRefs.length !== legacyRefs.length) {\n const productId = typeof pkg.product_id === 'string' ? pkg.product_id : '<package-selector>';\n const projected = projectV1ProductToV2(\n {\n product_id: productId,\n name: productId,\n description: 'legacy package selector normalization',\n format_ids: legacyRefs,\n },\n { legacyFormatConverter }\n );\n const projectedRefs = projected.v2.format_options.flatMap(option => {\n const ref = optionReference(option);\n return ref ? [ref] : [];\n });\n if (projected.diagnostics.length > 0 || projectedRefs.length !== legacyRefs.length) {\n // Cannot convert this package's legacy format_ids to canonical format_option_refs.\n // Return the package unchanged rather than throwing so responses for existing\n // buys remain usable. These buys were created before canonical format_option_refs\n // were enforced at write time.\n return next;\n }\n mappedRefs = projectedRefs;\n }\n if (optionRefs.length === 0) next.format_option_refs = mappedRefs;\n }\n delete next.format_ids;\n } else {\n if (optionRefs.length > 0) {\n const selectedCandidates = candidates.filter(\n candidate =>\n candidate.formatOptionRef &&\n optionRefs.some(selected => sameOptionReference(selected, candidate.formatOptionRef!))\n );\n const everyOptionMapped = optionRefs.every(selected =>\n selectedCandidates.some(candidate =>\n candidate.formatOptionRef ? sameOptionReference(selected, candidate.formatOptionRef) : false\n )\n );\n if (!everyOptionMapped || selectedCandidates.length === 0) {\n let resolved: V1FormatId[] | undefined;\n try {\n if (!containerOptsOutOfLegacy(pkg as CreativeFormatSelectorContainer)) {\n resolved = resolveCanonicalFormatLegacyRefs(canonicalFormatLegacyResolver, {\n source: 'selector',\n selector: pkg as Record<string, unknown>,\n operation,\n field: '(package selector)',\n });\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format legacy resolver returned an invalid or ambiguous package mapping'\n );\n }\n if (!resolved) {\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format_option_refs have no complete legacy representation; re-run getProducts() or configure canonicalFormatLegacyResolver for persisted selections'\n );\n }\n next.format_ids = resolved;\n delete next.format_option_refs;\n delete next.format_kind;\n return next;\n }\n next.format_ids = dedupeLegacyRefs(selectedCandidates.map(candidate => candidate.ref));\n delete next.format_option_refs;\n } else if (canonicalKind) {\n const selectedCandidates = candidates.filter(candidate => candidate.formatKind === canonicalKind);\n if (selectedCandidates.length === 1) {\n next.format_ids = [{ ...selectedCandidates[0]!.ref }];\n } else {\n let resolved: V1FormatId[] | undefined;\n try {\n if (!containerOptsOutOfLegacy(pkg as CreativeFormatSelectorContainer, canonicalKind)) {\n resolved = resolveCanonicalFormatLegacyRefs(\n canonicalFormatLegacyResolver,\n {\n source: 'selector',\n selector: pkg as Record<string, unknown>,\n operation,\n field: '(package selector)',\n },\n true\n );\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format legacy resolver returned an invalid or ambiguous package mapping'\n );\n }\n if (resolved) {\n next.format_ids = resolved;\n } else {\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical package format_kind has no unambiguous legacy representation; select a format_option_ref from the product before delivery'\n );\n }\n }\n }\n delete next.format_kind;\n }\n\n return next;\n}\n\nfunction canonicalizeCreative<T extends Record<string, unknown>>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n operation: string,\n legacyFormatConverter?: LegacyFormatConverter\n): T {\n const creativeId = typeof creative.creative_id === 'string' ? creative.creative_id : '(unknown)';\n const hasCanonicalKind = typeof creative.format_kind === 'string';\n if (hasCanonicalKind && creative.format_id !== undefined) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative must not declare both canonical format_kind and legacy format_id'\n );\n }\n if (hasCanonicalKind && creative.format_id === undefined) {\n if (!CANONICAL_FORMAT_KINDS.has(creative.format_kind as CanonicalFormatKind)) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `unknown canonical format_kind ${creative.format_kind}`\n );\n }\n const creativeOptionRef = optionReference(creative.format_option_ref);\n const selectedRefs = selectedOptionReferences(selectorContainer);\n if (\n creativeOptionRef &&\n selectedRefs.length > 0 &&\n !selectedRefs.some(ref => sameOptionReference(ref, creativeOptionRef))\n ) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative format_option_ref conflicts with the package selected format_option_refs'\n );\n }\n return creative;\n }\n const existing = legacyRef(creative.format_id);\n if (!existing) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative must identify its format canonically with format_kind'\n );\n }\n\n const matchingCandidates = candidatesFromContainer(selectorContainer).filter(\n candidate =>\n sameLegacyIdentity(candidate.ref, existing) &&\n (existing.width === undefined || candidate.ref.width === existing.width) &&\n (existing.height === undefined || candidate.ref.height === existing.height) &&\n (existing.duration_ms === undefined || candidate.ref.duration_ms === existing.duration_ms)\n );\n if (matchingCandidates.length === 1 && matchingCandidates[0]!.formatKind) {\n const candidate = matchingCandidates[0]!;\n const next: Record<string, unknown> = { ...creative, format_kind: candidate.formatKind };\n delete next.format_id;\n if (candidate.formatOptionRef) next.format_option_ref = candidate.formatOptionRef;\n if (candidate.formatKind === 'custom' && !candidate.formatOptionRef) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'custom product format must provide format_option_id so the canonical creative retains a concrete identity'\n );\n }\n return next as T;\n }\n const selectorCandidates = candidatesFromContainer(selectorContainer);\n if (selectorCandidates.length > 0 && matchingCandidates.length !== 1) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n matchingCandidates.length === 0\n ? 'legacy format reference conflicts with the selected seller format identity or constraints'\n : 'legacy format reference is ambiguous within the selected seller format options'\n );\n }\n\n const { v2, diagnostics } = projectV1ProductToV2(\n {\n product_id: `<creative:${creativeId}>`,\n name: creativeId,\n description: 'legacy creative normalization',\n format_ids: [existing],\n },\n { legacyFormatConverter }\n );\n const declaration = v2.format_options[0];\n if (!declaration) {\n const diagnostic = diagnostics[0];\n const failure =\n diagnostic?.code === 'FORMAT_PROJECTION_FAILED' ? diagnostic.error.details.resolution_failure : undefined;\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `legacy creative format has no canonical conversion${failure ? ` (${failure})` : ''}`\n );\n }\n const next: Record<string, unknown> = { ...creative, format_kind: declaration.format_kind };\n delete next.format_id;\n const candidateOptionRef =\n matchingCandidates.length === 1 && matchingCandidates[0]!.formatKind === declaration.format_kind\n ? matchingCandidates[0]!.formatOptionRef\n : undefined;\n const convertedOptionRef = optionReference(declaration) ?? candidateOptionRef;\n if (convertedOptionRef) next.format_option_ref = convertedOptionRef;\n if (declaration.format_kind === 'custom' && !convertedOptionRef) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'custom legacy conversion must provide format_option_id so the canonical creative retains a concrete identity'\n );\n }\n return next as T;\n}\n\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode?: 'canonical',\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: 'legacy' | 'unknown',\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): LegacyProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: CreativeFormatWireMode,\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T> | LegacyProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: CreativeFormatWireMode = 'canonical',\n operation = 'creative_delivery',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T> | LegacyProjectedCreative<T> {\n const inputRecord = creative as unknown as Record<string, unknown>;\n const originalLegacyRef = legacyRef(inputRecord.format_id);\n const creativeRecord = canonicalizeCreative(inputRecord, selectorContainer, operation, legacyFormatConverter);\n if (wireMode === 'canonical') return creativeRecord as unknown as CanonicalProjectedCreative<T>;\n if (originalLegacyRef) {\n const selectedOriginal = selectLegacyRef(inputRecord, selectorContainer, canonicalFormatLegacyResolver, operation);\n if (selectedOriginal) {\n return projectCreative(creativeRecord, selectedOriginal) as unknown as LegacyProjectedCreative<T>;\n }\n throw new CreativeFormatProjectionError(\n operation,\n typeof inputRecord.creative_id === 'string' ? inputRecord.creative_id : '(unknown)',\n 'the original legacy format reference conflicts with the selected seller format identity or constraints'\n );\n }\n const formatId = selectLegacyRef(creativeRecord, selectorContainer, canonicalFormatLegacyResolver, operation);\n if (formatId) return projectCreative(creativeRecord, formatId) as unknown as LegacyProjectedCreative<T>;\n\n if (typeof creativeRecord.format_kind === 'string') {\n const creativeId = typeof creativeRecord.creative_id === 'string' ? creativeRecord.creative_id : '(unknown)';\n const allCandidates = candidatesFromContainer(selectorContainer, canonicalFormatLegacyResolver, operation);\n let candidates = allCandidates.filter(candidate => candidate.formatKind === creativeRecord.format_kind);\n const constrained = candidates.filter(candidate => refMatchesParams(candidate.ref, selectorContainer.params));\n if (constrained.length > 0) candidates = constrained;\n let resolved: V1FormatId[] | undefined;\n try {\n if (\n !containerOptsOutOfLegacy(\n selectorContainer,\n creativeRecord.format_kind,\n optionReference(creativeRecord.format_option_ref)\n )\n ) {\n resolved = resolveCanonicalFormatLegacyRefs(\n canonicalFormatLegacyResolver,\n {\n source: 'creative',\n creative: creativeRecord,\n selector: selectorContainer as Record<string, unknown>,\n operation,\n field: creativeId,\n },\n true\n );\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'canonical format legacy resolver returned an invalid or ambiguous creative mapping'\n );\n }\n if (resolved) return projectCreative(creativeRecord, resolved[0]!) as unknown as LegacyProjectedCreative<T>;\n if (candidates.length > 1) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `the seller advertised ${candidates.length} legacy refs for canonical kind ${creativeRecord.format_kind}`\n );\n }\n const reason = 'the selected seller product did not provide one unambiguous legacy format reference';\n throw new CreativeFormatProjectionError(operation, creativeId, reason);\n }\n return creative as unknown as LegacyProjectedCreative<T>;\n}\n\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: 'canonical',\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: 'legacy' | 'unknown',\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: CreativeFormatWireMode,\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'> | ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: CreativeFormatWireMode = 'canonical',\n operation: 'create_media_buy' | 'update_media_buy' = 'create_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'> | ProjectedMediaBuyCreativeRequest<T, 'legacy'> {\n const requestRecord = record(request);\n if (!requestRecord) return request as ProjectedMediaBuyCreativeRequest<T, 'canonical'>;\n let changed = false;\n const next = { ...requestRecord };\n for (const key of ['packages', 'new_packages'] as const) {\n const packages = requestRecord[key];\n if (!Array.isArray(packages)) continue;\n next[key] = packages.map(packageValue => {\n const pkg = record(packageValue);\n if (!pkg) return packageValue;\n const creatives = Array.isArray(pkg.creatives)\n ? pkg.creatives.map(creativeValue => {\n const creative = record(creativeValue);\n if (!creative) return creativeValue;\n const projected = projectCreativeForDelivery(\n creative as unknown as CreativeAsset,\n pkg as CreativeFormatSelectorContainer,\n wireMode,\n operation,\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projected !== creativeValue) changed = true;\n return projected;\n })\n : undefined;\n const projectedPackage = projectPackageSelectors(\n pkg,\n wireMode,\n operation,\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projectedPackage !== packageValue) changed = true;\n return creatives ? { ...projectedPackage, creatives } : projectedPackage;\n });\n }\n return (changed ? next : request) as\n | ProjectedMediaBuyCreativeRequest<T, 'canonical'>\n | ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\n}\n\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: 'canonical',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: 'legacy' | 'unknown',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'legacy'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: CreativeFormatWireMode,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'> | ProjectedSyncCreativeRequest<T, 'legacy'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: CreativeFormatWireMode = 'canonical',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'> | ProjectedSyncCreativeRequest<T, 'legacy'> {\n const requestRecord = record(request);\n if (!requestRecord || !Array.isArray(requestRecord.creatives)) {\n return request as ProjectedSyncCreativeRequest<T, 'canonical'>;\n }\n const assignments = Array.isArray(requestRecord.assignments) ? requestRecord.assignments : [];\n let changed = false;\n const creatives = requestRecord.creatives.map(creativeValue => {\n const creative = record(creativeValue);\n if (!creative) return creativeValue;\n const assignedPackageIds = new Set(\n assignments.flatMap(assignmentValue => {\n const assignment = record(assignmentValue);\n if (!assignment || assignment.creative_id !== creative.creative_id) return [];\n return typeof assignment.package_id === 'string' ? [assignment.package_id] : [];\n })\n );\n const relevant =\n assignedPackageIds.size === 0\n ? selectorContainers\n : selectorContainers.filter(\n container => typeof container.package_id === 'string' && assignedPackageIds.has(container.package_id)\n );\n const combined: CreativeFormatSelectorContainer = {\n selector_containers: relevant,\n };\n const projected = projectCreativeForDelivery(\n creative as unknown as CreativeAsset,\n combined,\n wireMode,\n 'sync_creatives',\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projected !== creativeValue) changed = true;\n return projected;\n });\n return (changed ? { ...requestRecord, creatives } : request) as\n | ProjectedSyncCreativeRequest<T, 'canonical'>\n | ProjectedSyncCreativeRequest<T, 'legacy'>;\n}\n\ntype CreativeProtocolRelease = { major: number; minor: number; label: string };\n\nfunction release(value: unknown): CreativeProtocolRelease | undefined {\n if (typeof value !== 'string') return undefined;\n const match = /^v?(\\d+)\\.(\\d+)(?:\\.|-|$)/.exec(value.trim());\n return match ? { major: Number(match[1]), minor: Number(match[2]), label: value } : undefined;\n}\n\nfunction mutuallyServedRelease(\n caps: Record<string, unknown> | undefined,\n raw: Record<string, unknown> | undefined,\n requestedVersion: string | undefined\n): CreativeProtocolRelease | undefined {\n const requested = release(requestedVersion);\n if (!requested) return undefined;\n const normalizedSupported = Array.isArray(caps?.supportedVersions) ? caps.supportedVersions : [];\n const directSupported = record(caps?.adcp)?.supported_versions;\n const rawSupported = record(raw?.adcp)?.supported_versions;\n const advertisedValues = [\n ...normalizedSupported,\n ...(Array.isArray(directSupported) ? directSupported : []),\n ...(Array.isArray(rawSupported) ? rawSupported : []),\n ];\n const advertised = advertisedValues.flatMap(value => {\n const parsed = release(value);\n return parsed ? [parsed] : [];\n });\n if (advertisedValues.length > 0 && advertised.length === 0) {\n throw new CreativeFormatCapabilityError(\n 'Seller advertised supported AdCP versions, but none were valid release identifiers'\n );\n }\n if (advertised.length === 0) {\n // A buyer pin is an upper bound, not evidence that the seller serves the\n // same release. Legacy 3.0 sellers commonly omit supported_versions; that\n // omission must not turn a 3.2 buyer pin into a false canonical guarantee.\n return requested.major < 3 || (requested.major === 3 && requested.minor === 0) ? requested : undefined;\n }\n const mutuallyServed = advertised\n .filter(\n candidate =>\n candidate.major === requested.major &&\n (candidate.minor < requested.minor || candidate.minor === requested.minor)\n )\n .sort((left, right) => right.minor - left.minor)[0];\n if (!mutuallyServed) {\n const supported = [...new Set(advertised.map(candidate => candidate.label))].join(', ');\n throw new CreativeFormatCapabilityError(\n `No mutually supported AdCP release: client requested ${requestedVersion}, seller advertised ${supported}`\n );\n }\n return mutuallyServed;\n}\n\nexport function resolveCreativeFormatWireMode(\n capabilities: unknown,\n negotiatedVersion?: string\n): CreativeFormatWireMode {\n const caps = record(capabilities);\n const raw = record(caps?._raw);\n const features = record(caps?.features);\n const mediaBuyFeatures = record(record(caps?.media_buy)?.features);\n const rawMediaBuyFeatures = record(record(raw?.media_buy)?.features);\n const declarations = [\n features?.canonicalCreatives,\n mediaBuyFeatures?.canonical_creatives,\n rawMediaBuyFeatures?.canonical_creatives,\n ].filter((value): value is boolean => typeof value === 'boolean');\n if (declarations.includes(true) && declarations.includes(false)) {\n throw new CreativeFormatCapabilityError(\n 'Seller capability response contains conflicting canonical_creatives declarations'\n );\n }\n const explicitCanonical = declarations[0];\n // `supported_versions` is the seller's wire-release contract. A newer\n // buyer can be downshifted within the same major, so a 3.2 client talking\n // to a 3.1-only seller must apply the 3.1 feature semantics rather than\n // assuming the 3.2 canonical guarantee. `build_version` is intentionally\n // absent here: the capability schema marks it advisory-only.\n const negotiated = mutuallyServedRelease(caps, raw, negotiatedVersion);\n if (caps?.version === 'v2') return 'legacy';\n if (negotiated && (negotiated.major > 3 || (negotiated.major === 3 && negotiated.minor >= 2))) {\n if (explicitCanonical === false) {\n throw new CreativeFormatCapabilityError(\n `AdCP ${negotiated.label} guarantees canonical creatives, but the seller advertised canonical_creatives: false`\n );\n }\n return 'canonical';\n }\n if (negotiated && (negotiated.major < 3 || (negotiated.major === 3 && negotiated.minor === 0))) {\n return 'legacy';\n }\n if (!caps) return 'unknown';\n if (explicitCanonical === true) return 'canonical';\n if (explicitCanonical === false) return 'legacy';\n return 'unknown';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,sBAAiE;AAEjE,sBAAuF;AAGvF,6BAIO;AAoHA,SAAS,4BAA+B,OAAwC;AACrF,QAAM,eAAe,oBAAI,IAAY;AACrC,QAAM,kBAAkB,oBAAI,IAAY;AACxC,QAAM,iBAAiB,oBAAI,IAAY;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,sBAAsB,CAAC,QAC3B,QAAQ,cAAc,0CAA0C,KAAK,GAAG;AAC1E,QAAM,eAAe,CAAC,OAAgC,QAAyB;AAC7E,UAAM,aAAa,OAAO,yBAAyB,OAAO,GAAG;AAC7D,WAAO,cAAc,WAAW,aAAa,WAAW,QAAQ;AAAA,EAClE;AACA,QAAM,0BAA0B,CAAC,QAC/B,OAAO,QAAQ,YACf,CAAC,uCAAuC,KAAK,GAAG,KAChD,iDAAiD,KAAK,GAAG;AAC3D,QAAM,2BAA2B,CAAC,OAAgC,QAChE,aAAa,OAAO,QAAQ,MAAM,WAAW,OAAO,QAAQ,YAAY,wBAAwB,KAAK,GAAG;AAC1G,QAAM,yBAAyB,CAAC,OAAgC,QAC9D,OAAO,aAAa,OAAO,SAAS,MAAM,YAC1C,OAAO,QAAQ,YACf,uDAAuD,KAAK,GAAG;AACjE,QAAM,gCAAgC,CAAC,QACrC,wBAAwB,GAAG,KAC1B,OAAO,QAAQ,YAAY,mEAAmE,KAAK,GAAG;AACz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O,QAAO;AACxC,SAAO;AACT;","names":["value","result","needsSafeToJSON","changed","safe","next"]}
1
+ {"version":3,"sources":["../../../../src/lib/v2/projection/creative-delivery.ts"],"sourcesContent":["import type {\n CreativeAsset,\n CreateMediaBuyRequest,\n CreateMediaBuyResponse,\n FormatOptionReference,\n GetProductsRequest,\n GetProductsResponse,\n GetCreativeDeliveryResponse,\n GetMediaBuyDeliveryResponse,\n GetMediaBuysResponse,\n CreativeFilters,\n ListCreativesResponse,\n ListCreativesRequest,\n PackageRequest,\n PackageUpdate,\n Package,\n Placement,\n Product,\n SyncCreativesRequest,\n SyncCreativesResponse,\n UpdateMediaBuyRequest,\n UpdateMediaBuyResponse,\n} from '../../types/tools.generated';\nimport { projectV1ProductToV2, resolveCanonicalFormatKind } from './v1-to-v2';\nimport type { LegacyFormatConverter } from './v1-to-v2';\nimport { CanonicalFormatLegacyResolutionError, resolveCanonicalFormatLegacyRefs } from './v2-to-v1';\nimport type { CanonicalFormatLegacyResolver } from './v2-to-v1';\nimport type { CanonicalFormatKind, ProjectionDiagnostic, V1FormatId } from './types';\nimport {\n legacyFormatRefsForDeclaration,\n selectedFormatOptions,\n transferLegacyCreativeMetadata,\n} from './legacy-metadata';\nimport type { CanonicalFormatDeclaration } from './legacy-metadata';\n\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, Extract<keyof T, K>> : never;\n\n/** Primary SDK creative shape. Legacy creative identity is a wire-adapter concern. */\nexport type CanonicalCreativeAsset = Omit<CanonicalCreativeResponse<CreativeAsset>, 'format_kind'> & {\n format_kind: CanonicalFormatKind;\n format_id?: never;\n};\n\n/** Explicit compatibility-only creative shape used at a legacy wire boundary. */\nexport type LegacyCreativeAsset = Omit<CreativeAsset, 'format_id' | 'format_kind' | 'format_option_ref'> & {\n format_id: V1FormatId;\n format_kind?: never;\n format_option_ref?: never;\n};\n\nexport type CanonicalPackageRequest = DistributiveOmit<\n CanonicalCreativeResponse<PackageRequest>,\n 'creatives' | 'format_ids'\n> & {\n creatives?: CanonicalCreativeAsset[];\n format_ids?: never;\n};\nexport type NonEmptyCanonicalFormatDeclarations = [CanonicalFormatDeclaration, ...CanonicalFormatDeclaration[]];\nexport type CanonicalPlacement = Omit<CanonicalCreativeResponse<Placement>, 'format_ids' | 'format_options'> & {\n format_ids?: never;\n format_options?: NonEmptyCanonicalFormatDeclarations;\n};\nexport type CanonicalProduct = Omit<\n CanonicalCreativeResponse<Product>,\n 'format_ids' | 'format_options' | 'placements'\n> & {\n product_id: string;\n format_ids?: never;\n format_options: NonEmptyCanonicalFormatDeclarations;\n placements?: CanonicalPlacement[];\n};\ntype CanonicalGetProductsField = Exclude<NonNullable<GetProductsRequest['fields']>[number], 'format_ids'>;\n/** Primary product discovery request cannot ask the SDK to expose legacy format IDs. */\nexport type CanonicalGetProductsRequest = Omit<GetProductsRequest, 'fields'> & {\n fields?: CanonicalGetProductsField[];\n};\nexport type CanonicalGetProductsResponse = Omit<CanonicalCreativeResponse<GetProductsResponse>, 'products'> & {\n products: CanonicalProduct[];\n projection: { diagnostics: ProjectionDiagnostic[] };\n};\nexport type CanonicalPackageUpdate = Omit<CanonicalCreativeResponse<PackageUpdate>, 'creatives'> & {\n creatives?: CanonicalCreativeAsset[];\n};\nexport type CanonicalPackage = CanonicalCreativeResponse<Package>;\nexport type CanonicalCreateMediaBuyRequest = Omit<CanonicalCreativeResponse<CreateMediaBuyRequest>, 'packages'> & {\n packages?: CanonicalPackageRequest[];\n};\nexport type CanonicalUpdateMediaBuyRequest = Omit<\n CanonicalCreativeResponse<UpdateMediaBuyRequest>,\n 'packages' | 'new_packages'\n> & {\n packages?: CanonicalPackageUpdate[];\n new_packages?: CanonicalPackageRequest[];\n};\nexport type CanonicalSyncCreativesRequest = Omit<CanonicalCreativeResponse<SyncCreativesRequest>, 'creatives'> & {\n creatives: CanonicalCreativeAsset[];\n};\nexport type CanonicalListedCreative = Omit<\n CanonicalCreativeResponse<ListCreativesResponse['creatives'][number]>,\n 'format_id' | 'format_kind' | 'format_option_ref'\n> & {\n format_kind: CanonicalFormatKind;\n format_option_ref?: FormatOptionReference;\n format_id?: never;\n};\nexport type CanonicalListCreativesResponse = Omit<CanonicalCreativeResponse<ListCreativesResponse>, 'creatives'> & {\n creatives: CanonicalListedCreative[];\n};\nexport type CanonicalCreateMediaBuyResponse = CanonicalCreativeResponse<CreateMediaBuyResponse>;\nexport type CanonicalUpdateMediaBuyResponse = CanonicalCreativeResponse<UpdateMediaBuyResponse>;\nexport type CanonicalSyncCreativesResponse = CanonicalCreativeResponse<SyncCreativesResponse>;\nexport type CanonicalGetMediaBuysResponse = CanonicalCreativeResponse<GetMediaBuysResponse>;\nexport type CanonicalGetMediaBuyDeliveryResponse = CanonicalCreativeResponse<GetMediaBuyDeliveryResponse>;\nexport type CanonicalGetCreativeDeliveryResponse = CanonicalCreativeResponse<GetCreativeDeliveryResponse>;\n\nexport type CanonicalCreativeFilters = Omit<CanonicalCreativeResponse<CreativeFilters>, 'format_ids'> & {\n format_ids?: never;\n};\n\ntype CanonicalListCreativeField = Exclude<NonNullable<ListCreativesRequest['fields']>[number], 'format_id'>;\n\n/** Primary list request: legacy named-format filters and response fields are migration-only. */\nexport type CanonicalListCreativesRequest = Omit<\n CanonicalCreativeResponse<ListCreativesRequest>,\n 'filters' | 'fields'\n> & {\n filters?: CanonicalCreativeFilters;\n fields?: CanonicalListCreativeField[];\n};\n\ntype IsLegacyCreativeIdentityKey<K extends PropertyKey> = K extends string\n ? K extends '_message' | `${string}format_id${string}` | `${string}v1_format_ref${string}`\n ? true\n : false\n : false;\n\n/** Recursively removes legacy creative routing identity from primary response types. */\nexport type CanonicalCreativeResponse<T> = T extends (...args: never[]) => unknown\n ? T\n : T extends readonly (infer TItem)[]\n ? CanonicalCreativeResponse<TItem>[]\n : T extends object\n ? {\n [K in keyof T as IsLegacyCreativeIdentityKey<K> extends true ? never : K]: CanonicalCreativeResponse<T[K]>;\n }\n : T;\n\n/** Runtime counterpart to {@link CanonicalCreativeResponse}. */\nexport function stripLegacyCreativeIdentity<T>(value: T): CanonicalCreativeResponse<T> {\n const legacyTokens = new Set<string>();\n const legacyUrlTokens = new Set<string>();\n const canonicalKinds = new Set<string>([\n 'image',\n 'html5',\n 'display_tag',\n 'image_carousel',\n 'video_hosted',\n 'video_vast',\n 'audio_hosted',\n 'audio_daast',\n 'sponsored_placement',\n 'native_in_feed',\n 'responsive_creative',\n 'agent_placement',\n 'custom',\n ]);\n const creativeIdentityKey = (key: string): boolean =>\n key === '_message' || /(^|_)(?:format_ids?|v1_format_ref)($|_)/.test(key);\n const ownDataValue = (owner: Record<string, unknown>, key: string): unknown => {\n const descriptor = Object.getOwnPropertyDescriptor(owner, key);\n return descriptor && 'value' in descriptor ? descriptor.value : undefined;\n };\n const nonCreativeAgentContext = (key: string | undefined): boolean =>\n typeof key === 'string' &&\n !/(^|_)(?:creative|format|legacy)($|_)/.test(key) &&\n /(^|_)(?:agents?|agent_details|agent_info)($|_)/.test(key);\n const nonCreativeSignalContext = (owner: Record<string, unknown>, key: string | undefined): boolean =>\n ownDataValue(owner, 'source') === 'agent' && typeof key === 'string' && /(^|_)signal_ids?($|_)/.test(key);\n const nonCreativeListContext = (owner: Record<string, unknown>, key: string | undefined): boolean =>\n typeof ownDataValue(owner, 'list_id') === 'string' &&\n typeof key === 'string' &&\n /(^|_)(?:property_list|collection_list|list_ref)($|_)/.test(key);\n const explicitNonCreativeContextKey = (key: string | undefined): boolean =>\n nonCreativeAgentContext(key) ||\n (typeof key === 'string' && /(^|_)(?:signal_ids?|property_list|collection_list|list_ref)($|_)/.test(key));\n const standaloneLegacyTuple = (owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (\n nonCreativeAgentContext(ownerKey) ||\n nonCreativeSignalContext(owner, ownerKey) ||\n nonCreativeListContext(owner, ownerKey)\n ) {\n return false;\n }\n if (typeof ownDataValue(owner, 'agent_url') !== 'string' || typeof ownDataValue(owner, 'id') !== 'string') {\n return false;\n }\n return true;\n };\n const preservesNonCreativeAgentUrl = (key: string, owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (!/(^|_)agent_url($|_)/.test(key)) return false;\n if (key === 'agent_url') {\n return (\n nonCreativeAgentContext(ownerKey) ||\n nonCreativeSignalContext(owner, ownerKey) ||\n nonCreativeListContext(owner, ownerKey) ||\n (typeof ownDataValue(owner, 'id') === 'string' && !standaloneLegacyTuple(owner, ownerKey))\n );\n }\n return !/(^|_)(?:creative|format|legacy|offending|target|input|output)($|_)/.test(key);\n };\n const legacyKey = (key: string, owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (creativeIdentityKey(key)) return true;\n if (!/(^|_)agent_url($|_)/.test(key)) return false;\n if (preservesNonCreativeAgentUrl(key, owner, ownerKey)) return false;\n const value = ownDataValue(owner, key);\n // Composite agent URL fields are used by several non-creative protocol\n // domains. Remove them only when their value is known to belong to a\n // legacy creative identity collected elsewhere in this payload.\n return typeof value === 'string' && legacyTokens.has(value);\n };\n const collectStrings = (current: unknown, seen = new WeakSet<object>(), ownerKey?: string): void => {\n if (typeof current === 'string') {\n if (current.length > 1) {\n legacyTokens.add(current);\n if (ownerKey === 'agent_url' || /^https?:\\/\\//i.test(current)) legacyUrlTokens.add(current);\n }\n return;\n }\n if (current === null || typeof current !== 'object' || seen.has(current)) return;\n seen.add(current);\n if (Array.isArray(current)) {\n for (const child of current) collectStrings(child, seen, ownerKey);\n return;\n }\n for (const key of Reflect.ownKeys(current)) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor || !('value' in descriptor)) continue;\n collectStrings(descriptor.value, seen, typeof key === 'string' ? key : ownerKey);\n }\n };\n const tokenSeenByContext = {\n default: new WeakSet<object>(),\n nonCreativeAgent: new WeakSet<object>(),\n };\n const collectLegacyTokens = (current: unknown, ownerKey?: string): void => {\n const seen = explicitNonCreativeContextKey(ownerKey)\n ? tokenSeenByContext.nonCreativeAgent\n : tokenSeenByContext.default;\n if (current === null || typeof current !== 'object' || seen.has(current)) return;\n seen.add(current);\n if (Array.isArray(current)) {\n for (const child of current) collectLegacyTokens(child, ownerKey);\n return;\n }\n const owner = current as Record<string, unknown>;\n if (standaloneLegacyTuple(owner, ownerKey)) collectStrings(owner, new WeakSet<object>(), ownerKey);\n for (const key of Object.getOwnPropertyNames(owner)) {\n const descriptor = Object.getOwnPropertyDescriptor(owner, key);\n if (!descriptor || !('value' in descriptor)) continue;\n const child = descriptor.value;\n if (creativeIdentityKey(key)) collectStrings(child);\n else collectLegacyTokens(child, key);\n }\n };\n collectLegacyTokens(value);\n\n const sanitizeText = (text: string, ownerKey?: string): string => {\n const mentionsLegacyIdentity =\n /\\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\\b/.test(\n text\n );\n let safe = text;\n if (mentionsLegacyIdentity) {\n // Diagnostics sometimes repeat only the flattened identity and omit the\n // structured field that supplied it. Fail closed for those orphan\n // values while leaving unrelated URLs in ordinary messages untouched.\n safe = safe.replace(/\\bhttps?:\\/\\/[^\\s\"'`<>]+/g, '[legacy creative identity]');\n safe = safe.replace(\n /(\\b(?:format_ids?|v1_format_ref|agent_url)\\b(?:\\s+(?:was|is|from))?\\s*[:=]?\\s*[\"'`]?)\\b[a-zA-Z0-9][a-zA-Z0-9_.-]{1,}/g,\n '$1[legacy creative identity]'\n );\n }\n safe = safe.replace(\n /\\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\\b/g,\n 'legacy creative identity'\n );\n for (const token of [...legacyUrlTokens].sort((left, right) => right.length - left.length)) {\n safe = safe.split(token).join('[legacy creative identity]');\n }\n const diagnosticContext =\n mentionsLegacyIdentity ||\n (typeof ownerKey === 'string' &&\n /(^|_)(?:message|question|prompt|error|reason|summary|context|stack|diagnostic)($|_)/.test(ownerKey));\n if (diagnosticContext) {\n for (const token of [...legacyTokens].sort((left, right) => right.length - left.length)) {\n if (legacyUrlTokens.has(token) || canonicalKinds.has(token)) continue;\n if (token.length < 8 && !/[_:/. -]/.test(token)) continue;\n safe = safe.split(token).join('[legacy creative identity]');\n }\n }\n return safe;\n };\n\n // The same object can appear once under an explicit agent field and once\n // under an ambiguous extension field. Cache by policy context so an allowed\n // agent occurrence cannot make a later ambiguous tuple fail open (or vice\n // versa based on property order).\n const seenByContext = {\n default: new WeakMap<object, unknown>(),\n nonCreativeAgent: new WeakMap<object, unknown>(),\n };\n const hasCustomToJSON = (candidate: object): boolean => {\n let cursor: object | null = candidate;\n while (cursor) {\n const descriptor = Object.getOwnPropertyDescriptor(cursor, 'toJSON');\n if (descriptor) return !('value' in descriptor) || typeof descriptor.value === 'function';\n cursor = Object.getPrototypeOf(cursor) as object | null;\n }\n return false;\n };\n const strip = (current: unknown, ownerKey?: string): unknown => {\n if (typeof current === 'string') return sanitizeText(current, ownerKey);\n if (current === null || typeof current !== 'object') return current;\n const seen = explicitNonCreativeContextKey(ownerKey) ? seenByContext.nonCreativeAgent : seenByContext.default;\n const cached = seen.get(current);\n if (cached !== undefined) return cached;\n if (Array.isArray(current)) {\n const result: unknown[] = [];\n seen.set(current, result);\n const needsSafeToJSON = hasCustomToJSON(current);\n let changed = needsSafeToJSON || Object.getPrototypeOf(current) !== Array.prototype;\n for (const key of Reflect.ownKeys(current)) {\n if (key === 'length') continue;\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor) continue;\n if (!('value' in descriptor)) {\n changed = true;\n continue;\n }\n if (key === 'toJSON' && typeof descriptor.value === 'function') {\n changed = true;\n continue;\n }\n if (typeof key === 'string' && legacyKey(key, current as unknown as Record<string, unknown>, ownerKey)) {\n changed = true;\n continue;\n }\n const safe = strip(descriptor.value, typeof key === 'string' && !/^\\d+$/.test(key) ? key : ownerKey);\n if (safe !== descriptor.value) changed = true;\n Object.defineProperty(result, key, { ...descriptor, value: safe });\n }\n result.length = current.length;\n if (!changed) {\n seen.set(current, current);\n return current;\n }\n if (needsSafeToJSON) {\n Object.defineProperty(result, 'toJSON', {\n configurable: true,\n enumerable: false,\n value: () => Array.from(result),\n });\n }\n transferLegacyCreativeMetadata(current, result);\n return result;\n }\n const prototype = Object.getPrototypeOf(current);\n const plain = prototype === Object.prototype || prototype === null;\n const safePrototype =\n prototype === null ? null : Error.prototype.isPrototypeOf(current) ? Error.prototype : Object.prototype;\n // Never retain an adopter-controlled prototype. Inherited getters and\n // methods are behavior, not inspected data, and can reveal legacy identity\n // after this boundary has supposedly been sanitized.\n const result: Record<string | symbol, unknown> = Object.create(safePrototype);\n seen.set(current, result);\n const owner = current as Record<string, unknown>;\n if (standaloneLegacyTuple(owner, ownerKey)) {\n const empty = {};\n seen.set(current, empty);\n return empty;\n }\n const needsSafeToJSON = hasCustomToJSON(current);\n let changed = !plain || needsSafeToJSON;\n const keys: Array<string | symbol> = Reflect.ownKeys(current);\n for (const key of keys) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor) continue;\n if (!('value' in descriptor)) {\n // Never reflect accessors across the canonical boundary. Evaluating a\n // retained getter later could reveal a legacy identity that was not\n // present while this object was inspected (and may run adopter code).\n changed = true;\n continue;\n }\n const child = descriptor.value;\n if (typeof key === 'symbol') {\n const safe = strip(child);\n if (safe !== child) changed = true;\n if (!plain) Object.defineProperty(result, key, { ...descriptor, value: safe });\n continue;\n }\n if (key === 'toJSON' && typeof child === 'function') {\n changed = true;\n continue;\n }\n if (legacyKey(key, owner, ownerKey)) {\n changed = true;\n continue;\n }\n const safe = preservesNonCreativeAgentUrl(key, owner, ownerKey) ? child : strip(child, key);\n if (safe !== child) changed = true;\n if (plain && typeof key === 'string' && descriptor.enumerable) result[key] = safe;\n else Object.defineProperty(result, key, { ...descriptor, value: safe });\n }\n if (!changed) {\n seen.set(current, current);\n return current;\n }\n if (needsSafeToJSON) {\n Object.defineProperty(result, 'toJSON', {\n configurable: true,\n enumerable: false,\n value: () => {\n const serialized: Record<string, unknown> = {};\n for (const key of Object.keys(result)) serialized[key] = result[key];\n return serialized;\n },\n });\n }\n transferLegacyCreativeMetadata(current, result);\n return result;\n };\n return strip(value) as CanonicalCreativeResponse<T>;\n}\n\nexport type CanonicalProjectedCreative<T> = Omit<T, 'format_id' | 'format_kind'> & {\n format_kind: CanonicalFormatKind;\n format_id?: never;\n};\nexport type LegacyProjectedCreative<T> = Omit<T, 'format_id' | 'format_kind' | 'format_option_ref'> & {\n format_id: V1FormatId;\n format_kind?: never;\n format_option_ref?: never;\n};\n\ntype ProjectedCreativeArray<T, TMode extends 'canonical' | 'legacy'> =\n T extends ReadonlyArray<infer TCreative>\n ? Array<TMode extends 'canonical' ? CanonicalProjectedCreative<TCreative> : LegacyProjectedCreative<TCreative>>\n : T;\ntype ReplaceCreatives<T, TMode extends 'canonical' | 'legacy'> = T extends object\n ? 'creatives' extends keyof T\n ? Omit<T, 'creatives'> &\n (Record<never, never> extends Pick<T, 'creatives'>\n ? { creatives?: ProjectedCreativeArray<T['creatives'], TMode> }\n : { creatives: ProjectedCreativeArray<T['creatives'], TMode> })\n : T\n : T;\ntype ProjectedContainerArray<T, TMode extends 'canonical' | 'legacy'> =\n T extends ReadonlyArray<infer TContainer> ? Array<ReplaceCreatives<TContainer, TMode>> : T;\ntype ReplaceContainerKey<\n T,\n TKey extends 'packages' | 'new_packages',\n TMode extends 'canonical' | 'legacy',\n> = TKey extends keyof T\n ? Record<never, never> extends Pick<T, TKey>\n ? { [K in TKey]?: ProjectedContainerArray<T[TKey], TMode> }\n : { [K in TKey]: ProjectedContainerArray<T[TKey], TMode> }\n : Record<never, never>;\n\nexport type ProjectedMediaBuyCreativeRequest<T, TMode extends 'canonical' | 'legacy'> = Omit<\n T,\n 'packages' | 'new_packages'\n> &\n ReplaceContainerKey<T, 'packages', TMode> &\n ReplaceContainerKey<T, 'new_packages', TMode>;\nexport type ProjectedSyncCreativeRequest<T, TMode extends 'canonical' | 'legacy'> = ReplaceCreatives<T, TMode>;\n\nexport type CreativeFormatWireMode = 'canonical' | 'legacy' | 'unknown';\n\nexport interface CreativeFormatSelectorContainer {\n package_id?: string;\n format_ids?: unknown[];\n formats?: unknown[];\n format_options?: unknown[];\n format_option_refs?: unknown[];\n format_kind?: unknown;\n params?: unknown;\n /** Internal composition seam used to preserve per-package selector constraints. */\n selector_containers?: ReadonlyArray<CreativeFormatSelectorContainer>;\n [key: string]: unknown;\n}\n\n/** Canonical package/product selectors accepted by the primary sync API. */\nexport interface CanonicalCreativeFormatSelectorContainer {\n package_id?: string;\n format_options?: ReadonlyArray<CanonicalFormatDeclaration>;\n format_option_refs?: ReadonlyArray<FormatOptionReference>;\n format_kind?: CanonicalFormatKind;\n params?: CanonicalFormatDeclaration['params'];\n selector_containers?: ReadonlyArray<CanonicalCreativeFormatSelectorContainer>;\n}\n\nexport interface SyncCreativeFormatProjection {\n selectorContainers: ReadonlyArray<CanonicalCreativeFormatSelectorContainer>;\n legacyFormatConverter?: LegacyFormatConverter;\n}\n\nexport class CreativeFormatProjectionError extends Error {\n readonly code = 'ADCP_CREATIVE_FORMAT_PROJECTION_FAILED';\n\n constructor(\n readonly operation: string,\n readonly creativeId: string,\n reason: string\n ) {\n super(`${operation}: cannot select a valid creative wire shape for ${creativeId}: ${reason}`);\n this.name = 'CreativeFormatProjectionError';\n }\n}\n\nexport class CreativeFormatCapabilityError extends Error {\n readonly code = 'ADCP_CREATIVE_FORMAT_CAPABILITY_CONTRADICTION';\n\n constructor(message: string) {\n super(message);\n this.name = 'CreativeFormatCapabilityError';\n }\n}\n\nconst CANONICAL_FORMAT_KINDS = new Set<CanonicalFormatKind>([\n 'image',\n 'html5',\n 'display_tag',\n 'image_carousel',\n 'video_hosted',\n 'video_vast',\n 'audio_hosted',\n 'audio_daast',\n 'sponsored_placement',\n 'native_in_feed',\n 'responsive_creative',\n 'agent_placement',\n 'custom',\n]);\n\ntype LegacyCandidate = {\n ref: V1FormatId;\n formatKind?: string;\n formatOptionRef?: FormatOptionReference;\n selectorParams?: unknown;\n};\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction legacyRef(value: unknown): V1FormatId | undefined {\n const candidate = record(value);\n if (!candidate || typeof candidate.agent_url !== 'string' || typeof candidate.id !== 'string') return undefined;\n if (candidate.agent_url.length === 0 || candidate.id.length === 0) return undefined;\n return {\n agent_url: candidate.agent_url,\n id: candidate.id,\n ...(typeof candidate.width === 'number' ? { width: candidate.width } : {}),\n ...(typeof candidate.height === 'number' ? { height: candidate.height } : {}),\n ...(typeof candidate.duration_ms === 'number' ? { duration_ms: candidate.duration_ms } : {}),\n };\n}\n\nfunction refsFromValue(value: unknown): V1FormatId[] {\n if (Array.isArray(value)) return value.flatMap(item => refsFromValue(item));\n const ref = legacyRef(value);\n return ref ? [ref] : [];\n}\n\ntype CanonicalFormatOptionReference = FormatOptionReference & { canonical_formats_only?: true };\n\nfunction optionReference(value: unknown): CanonicalFormatOptionReference | undefined {\n const option = record(value);\n if (!option || typeof option.format_option_id !== 'string' || option.format_option_id.length === 0) return undefined;\n const canonicalOnly = option.canonical_formats_only === true ? { canonical_formats_only: true as const } : {};\n if (typeof option.publisher_domain === 'string') {\n return {\n scope: 'publisher',\n publisher_domain: option.publisher_domain,\n format_option_id: option.format_option_id,\n ...canonicalOnly,\n };\n }\n return { scope: 'product', format_option_id: option.format_option_id, ...canonicalOnly };\n}\n\nfunction sameOptionReference(left: FormatOptionReference, right: FormatOptionReference): boolean {\n return (\n left.scope === right.scope &&\n left.format_option_id === right.format_option_id &&\n (left.scope !== 'publisher' || (right.scope === 'publisher' && left.publisher_domain === right.publisher_domain))\n );\n}\n\nfunction selectedOptionReferences(container: CreativeFormatSelectorContainer): CanonicalFormatOptionReference[] {\n const direct = Array.isArray(container.format_option_refs)\n ? container.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n const nested = Array.isArray(container.selector_containers)\n ? container.selector_containers.flatMap(selectedOptionReferences)\n : [];\n return [...direct, ...nested];\n}\n\nfunction agentIdentity(value: string): string {\n try {\n // URL parsing normalizes the scheme/host (the case-insensitive pieces)\n // while preserving case-sensitive paths, queries, and fragments.\n return new URL(value).href;\n } catch {\n return value;\n }\n}\n\nfunction sameLegacyIdentity(left: V1FormatId, right: V1FormatId): boolean {\n return agentIdentity(left.agent_url) === agentIdentity(right.agent_url) && left.id === right.id;\n}\n\nfunction candidatesFromContainer(\n container: CreativeFormatSelectorContainer,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver,\n operation = 'creative_delivery'\n): LegacyCandidate[] {\n if (Array.isArray(container.selector_containers)) {\n return uniqueCandidates(\n container.selector_containers.flatMap(candidate =>\n candidatesFromContainer(candidate, canonicalFormatLegacyResolver, operation)\n )\n );\n }\n const candidates: LegacyCandidate[] = [];\n const containerKind = typeof container.format_kind === 'string' ? container.format_kind : undefined;\n for (const key of ['format_ids', 'formats'] as const) {\n for (const ref of refsFromValue(container[key])) {\n candidates.push({\n ref,\n formatKind: resolveCanonicalFormatKind(ref.id) ?? containerKind,\n selectorParams: container.params,\n });\n }\n }\n const formatOptions = [\n ...(Array.isArray(container.format_options) ? container.format_options : []),\n ...selectedFormatOptions(container),\n ];\n for (const optionValue of formatOptions) {\n const option = record(optionValue);\n if (!option) continue;\n const formatKind = typeof option.format_kind === 'string' ? option.format_kind : undefined;\n const formatOptionRef = optionReference(option);\n let refs = [...legacyFormatRefsForDeclaration(option)];\n if (refs.length === 0 && option.canonical_formats_only !== true && formatKind) {\n try {\n refs =\n resolveCanonicalFormatLegacyRefs(canonicalFormatLegacyResolver, {\n source: 'product',\n declaration: option as unknown as import('./types').V2ProductFormatDeclaration,\n productId: typeof container.product_id === 'string' ? container.product_id : '<selector>',\n field: formatOptionRef?.format_option_id ?? '(format option)',\n }) ?? [];\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(format option)',\n 'canonical format legacy resolver returned an invalid product mapping'\n );\n }\n }\n for (const ref of refs) {\n candidates.push({ ref, formatKind, formatOptionRef, selectorParams: option.params ?? container.params });\n }\n }\n return uniqueCandidates(candidates);\n}\n\nfunction containerOptsOutOfLegacy(\n container: CreativeFormatSelectorContainer,\n formatKind?: string,\n formatOptionRef?: FormatOptionReference\n): boolean {\n if ((formatOptionRef as CanonicalFormatOptionReference | undefined)?.canonical_formats_only === true) return true;\n if (\n Array.isArray(container.selector_containers) &&\n container.selector_containers.some(candidate => containerOptsOutOfLegacy(candidate, formatKind, formatOptionRef))\n ) {\n return true;\n }\n const selectedRefs = selectedOptionReferences(container);\n if (\n selectedRefs.some(ref => {\n if (ref.canonical_formats_only !== true) return false;\n return formatOptionRef === undefined || sameOptionReference(ref, formatOptionRef);\n })\n ) {\n return true;\n }\n const formatOptions = [\n ...(Array.isArray(container.format_options) ? container.format_options : []),\n ...selectedFormatOptions(container),\n ];\n return formatOptions.some(value => {\n const option = record(value);\n if (!option || option.canonical_formats_only !== true) return false;\n if (formatKind && option.format_kind !== formatKind) return false;\n if (formatOptionRef) {\n const optionRef = optionReference(option);\n if (!optionRef || !sameOptionReference(optionRef, formatOptionRef)) return false;\n }\n return true;\n });\n}\n\nfunction candidateKey(candidate: LegacyCandidate): string {\n const ref = candidate.ref;\n return [\n agentIdentity(ref.agent_url),\n ref.id,\n ref.width ?? '',\n ref.height ?? '',\n ref.duration_ms ?? '',\n candidate.formatOptionRef?.scope ?? '',\n candidate.formatOptionRef?.format_option_id ?? '',\n candidate.formatOptionRef?.scope === 'publisher' ? candidate.formatOptionRef.publisher_domain : '',\n ].join('|');\n}\n\nfunction uniqueCandidates(candidates: LegacyCandidate[]): LegacyCandidate[] {\n return [...new Map(candidates.map(candidate => [candidateKey(candidate), candidate])).values()];\n}\n\nfunction refMatchesParams(ref: V1FormatId, paramsValue: unknown): boolean {\n const params = record(paramsValue);\n if (!params) return true;\n const sizes = Array.isArray(params.sizes) ? params.sizes.flatMap(size => (record(size) ? [record(size)!] : [])) : [];\n if (sizes.length === 1) {\n const size = sizes[0]!;\n if (typeof size.width === 'number' && ref.width !== size.width) return false;\n if (typeof size.height === 'number' && ref.height !== size.height) return false;\n }\n if (typeof params.width === 'number' && ref.width !== params.width) return false;\n if (typeof params.height === 'number' && ref.height !== params.height) return false;\n if (typeof params.duration_ms_exact === 'number' && ref.duration_ms !== params.duration_ms_exact) return false;\n return true;\n}\n\nfunction selectLegacyRef(\n creative: Record<string, unknown>,\n container: CreativeFormatSelectorContainer,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver,\n operation = 'creative_delivery'\n): V1FormatId | undefined {\n let candidates = candidatesFromContainer(container, canonicalFormatLegacyResolver, operation);\n const creativeOptionRef = optionReference(creative.format_option_ref);\n const selectedOptionRefs = Array.isArray(container.format_option_refs)\n ? container.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n if (creativeOptionRef) {\n if (selectedOptionRefs.length > 0 && !selectedOptionRefs.some(ref => sameOptionReference(ref, creativeOptionRef))) {\n return undefined;\n }\n candidates = candidates.filter(\n candidate => candidate.formatOptionRef && sameOptionReference(candidate.formatOptionRef, creativeOptionRef)\n );\n } else if (selectedOptionRefs.length > 0) {\n candidates = candidates.filter(\n candidate =>\n candidate.formatOptionRef &&\n selectedOptionRefs.some(ref => sameOptionReference(ref, candidate.formatOptionRef!))\n );\n }\n const existing = legacyRef(creative.format_id);\n if (existing) {\n const exact = candidates.filter(\n candidate =>\n sameLegacyIdentity(candidate.ref, existing) &&\n (existing.width === undefined || candidate.ref.width === existing.width) &&\n (existing.height === undefined || candidate.ref.height === existing.height) &&\n (existing.duration_ms === undefined || candidate.ref.duration_ms === existing.duration_ms)\n );\n if (exact.length === 1) return exact[0]!.ref;\n return candidates.length === 0 ? existing : undefined;\n }\n\n if (typeof creative.format_kind !== 'string') return undefined;\n let matching = candidates.filter(candidate => candidate.formatKind === creative.format_kind);\n const constrained = matching.filter(candidate => refMatchesParams(candidate.ref, candidate.selectorParams));\n if (constrained.length > 0) matching = constrained;\n return matching.length === 1 ? matching[0]!.ref : undefined;\n}\n\nfunction projectCreative<T extends Record<string, unknown>>(creative: T, formatId: V1FormatId): T {\n const next: Record<string, unknown> = { ...creative };\n delete next.format_kind;\n delete next.format_option_ref;\n next.format_id = { ...formatId };\n return next as T;\n}\n\nfunction dedupeLegacyRefs(refs: readonly V1FormatId[]): V1FormatId[] {\n return [...new Map(refs.map(ref => [candidateKey({ ref }), { ...ref }])).values()];\n}\n\nfunction projectPackageSelectors(\n pkg: Record<string | symbol, unknown>,\n wireMode: CreativeFormatWireMode,\n operation: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): Record<string | symbol, unknown> {\n const next = { ...pkg };\n const optionRefs = Array.isArray(pkg.format_option_refs)\n ? pkg.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n const legacyRefs = refsFromValue(pkg.format_ids);\n const candidates = candidatesFromContainer(\n pkg as CreativeFormatSelectorContainer,\n wireMode === 'canonical' ? undefined : canonicalFormatLegacyResolver,\n operation\n );\n const canonicalKind = typeof pkg.format_kind === 'string' ? pkg.format_kind : undefined;\n\n if (wireMode === 'canonical') {\n if (optionRefs.length > 0) {\n // Rebuild the array before transport so SDK-private downgrade metadata\n // never crosses the canonical wire boundary.\n next.format_option_refs = optionRefs.map(ref => ({ ...ref }));\n }\n if (legacyRefs.length > 0) {\n let mappedRefs = legacyRefs.flatMap(legacy => {\n const matches = candidates.filter(candidate => sameLegacyIdentity(candidate.ref, legacy));\n if (matches.length !== 1 || !matches[0]!.formatOptionRef) return [];\n return [matches[0]!.formatOptionRef];\n });\n if (optionRefs.length === 0 && mappedRefs.length !== legacyRefs.length) {\n const productId = typeof pkg.product_id === 'string' ? pkg.product_id : '<package-selector>';\n const projected = projectV1ProductToV2(\n {\n product_id: productId,\n name: productId,\n description: 'legacy package selector normalization',\n format_ids: legacyRefs,\n },\n { legacyFormatConverter }\n );\n const projectedRefs = projected.v2.format_options.flatMap(option => {\n const ref = optionReference(option);\n return ref ? [ref] : [];\n });\n if (projected.diagnostics.length > 0 || projectedRefs.length !== legacyRefs.length) {\n // Cannot convert this package's legacy format_ids to canonical format_option_refs.\n // Return the package unchanged rather than throwing so responses for existing\n // buys remain usable. These buys were created before canonical format_option_refs\n // were enforced at write time.\n return next;\n }\n mappedRefs = projectedRefs;\n }\n if (optionRefs.length === 0) next.format_option_refs = mappedRefs;\n }\n delete next.format_ids;\n } else {\n if (optionRefs.length > 0) {\n const selectedCandidates = candidates.filter(\n candidate =>\n candidate.formatOptionRef &&\n optionRefs.some(selected => sameOptionReference(selected, candidate.formatOptionRef!))\n );\n const everyOptionMapped = optionRefs.every(selected =>\n selectedCandidates.some(candidate =>\n candidate.formatOptionRef ? sameOptionReference(selected, candidate.formatOptionRef) : false\n )\n );\n if (!everyOptionMapped || selectedCandidates.length === 0) {\n let resolved: V1FormatId[] | undefined;\n try {\n if (!containerOptsOutOfLegacy(pkg as CreativeFormatSelectorContainer)) {\n resolved = resolveCanonicalFormatLegacyRefs(canonicalFormatLegacyResolver, {\n source: 'selector',\n selector: pkg as Record<string, unknown>,\n operation,\n field: '(package selector)',\n });\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format legacy resolver returned an invalid or ambiguous package mapping'\n );\n }\n if (!resolved) {\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format_option_refs have no complete legacy representation; re-run getProducts() or configure canonicalFormatLegacyResolver for persisted selections'\n );\n }\n next.format_ids = resolved;\n delete next.format_option_refs;\n delete next.format_kind;\n delete next.params;\n return next;\n }\n next.format_ids = dedupeLegacyRefs(selectedCandidates.map(candidate => candidate.ref));\n delete next.format_option_refs;\n } else if (canonicalKind) {\n const selectedCandidates = candidates.filter(candidate => candidate.formatKind === canonicalKind);\n if (selectedCandidates.length === 1) {\n next.format_ids = [{ ...selectedCandidates[0]!.ref }];\n } else {\n let resolved: V1FormatId[] | undefined;\n try {\n if (!containerOptsOutOfLegacy(pkg as CreativeFormatSelectorContainer, canonicalKind)) {\n resolved = resolveCanonicalFormatLegacyRefs(\n canonicalFormatLegacyResolver,\n {\n source: 'selector',\n selector: pkg as Record<string, unknown>,\n operation,\n field: '(package selector)',\n },\n true\n );\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format legacy resolver returned an invalid or ambiguous package mapping'\n );\n }\n if (resolved) {\n next.format_ids = resolved;\n } else {\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical package format_kind has no unambiguous legacy representation; select a format_option_ref from the product before delivery'\n );\n }\n }\n }\n delete next.format_kind;\n delete next.params;\n }\n\n return next;\n}\n\nfunction canonicalizeCreative<T extends Record<string, unknown>>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n operation: string,\n legacyFormatConverter?: LegacyFormatConverter\n): T {\n const creativeId = typeof creative.creative_id === 'string' ? creative.creative_id : '(unknown)';\n const hasCanonicalKind = typeof creative.format_kind === 'string';\n if (hasCanonicalKind && creative.format_id !== undefined) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative must not declare both canonical format_kind and legacy format_id'\n );\n }\n if (hasCanonicalKind && creative.format_id === undefined) {\n if (!CANONICAL_FORMAT_KINDS.has(creative.format_kind as CanonicalFormatKind)) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `unknown canonical format_kind ${creative.format_kind}`\n );\n }\n const creativeOptionRef = optionReference(creative.format_option_ref);\n const selectedRefs = selectedOptionReferences(selectorContainer);\n if (\n creativeOptionRef &&\n selectedRefs.length > 0 &&\n !selectedRefs.some(ref => sameOptionReference(ref, creativeOptionRef))\n ) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative format_option_ref conflicts with the package selected format_option_refs'\n );\n }\n return creative;\n }\n const existing = legacyRef(creative.format_id);\n if (!existing) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative must identify its format canonically with format_kind'\n );\n }\n\n const matchingCandidates = candidatesFromContainer(selectorContainer).filter(\n candidate =>\n sameLegacyIdentity(candidate.ref, existing) &&\n (existing.width === undefined || candidate.ref.width === existing.width) &&\n (existing.height === undefined || candidate.ref.height === existing.height) &&\n (existing.duration_ms === undefined || candidate.ref.duration_ms === existing.duration_ms)\n );\n if (matchingCandidates.length === 1 && matchingCandidates[0]!.formatKind) {\n const candidate = matchingCandidates[0]!;\n const next: Record<string, unknown> = { ...creative, format_kind: candidate.formatKind };\n delete next.format_id;\n if (candidate.formatOptionRef) next.format_option_ref = candidate.formatOptionRef;\n if (candidate.formatKind === 'custom' && !candidate.formatOptionRef) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'custom product format must provide format_option_id so the canonical creative retains a concrete identity'\n );\n }\n return next as T;\n }\n const selectorCandidates = candidatesFromContainer(selectorContainer);\n if (selectorCandidates.length > 0 && matchingCandidates.length !== 1) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n matchingCandidates.length === 0\n ? 'legacy format reference conflicts with the selected seller format identity or constraints'\n : 'legacy format reference is ambiguous within the selected seller format options'\n );\n }\n\n const { v2, diagnostics } = projectV1ProductToV2(\n {\n product_id: `<creative:${creativeId}>`,\n name: creativeId,\n description: 'legacy creative normalization',\n format_ids: [existing],\n },\n { legacyFormatConverter }\n );\n const declaration = v2.format_options[0];\n if (!declaration) {\n const diagnostic = diagnostics[0];\n const failure =\n diagnostic?.code === 'FORMAT_PROJECTION_FAILED' ? diagnostic.error.details.resolution_failure : undefined;\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `legacy creative format has no canonical conversion${failure ? ` (${failure})` : ''}`\n );\n }\n const next: Record<string, unknown> = { ...creative, format_kind: declaration.format_kind };\n delete next.format_id;\n const candidateOptionRef =\n matchingCandidates.length === 1 && matchingCandidates[0]!.formatKind === declaration.format_kind\n ? matchingCandidates[0]!.formatOptionRef\n : undefined;\n const convertedOptionRef = optionReference(declaration) ?? candidateOptionRef;\n if (convertedOptionRef) next.format_option_ref = convertedOptionRef;\n if (declaration.format_kind === 'custom' && !convertedOptionRef) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'custom legacy conversion must provide format_option_id so the canonical creative retains a concrete identity'\n );\n }\n return next as T;\n}\n\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode?: 'canonical',\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: 'legacy' | 'unknown',\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): LegacyProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: CreativeFormatWireMode,\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T> | LegacyProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: CreativeFormatWireMode = 'canonical',\n operation = 'creative_delivery',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T> | LegacyProjectedCreative<T> {\n const inputRecord = creative as unknown as Record<string, unknown>;\n const originalLegacyRef = legacyRef(inputRecord.format_id);\n const creativeRecord = canonicalizeCreative(inputRecord, selectorContainer, operation, legacyFormatConverter);\n if (wireMode === 'canonical') return creativeRecord as unknown as CanonicalProjectedCreative<T>;\n if (originalLegacyRef) {\n const selectedOriginal = selectLegacyRef(inputRecord, selectorContainer, canonicalFormatLegacyResolver, operation);\n if (selectedOriginal) {\n return projectCreative(creativeRecord, selectedOriginal) as unknown as LegacyProjectedCreative<T>;\n }\n throw new CreativeFormatProjectionError(\n operation,\n typeof inputRecord.creative_id === 'string' ? inputRecord.creative_id : '(unknown)',\n 'the original legacy format reference conflicts with the selected seller format identity or constraints'\n );\n }\n const formatId = selectLegacyRef(creativeRecord, selectorContainer, canonicalFormatLegacyResolver, operation);\n if (formatId) return projectCreative(creativeRecord, formatId) as unknown as LegacyProjectedCreative<T>;\n\n if (typeof creativeRecord.format_kind === 'string') {\n const creativeId = typeof creativeRecord.creative_id === 'string' ? creativeRecord.creative_id : '(unknown)';\n const allCandidates = candidatesFromContainer(selectorContainer, canonicalFormatLegacyResolver, operation);\n let candidates = allCandidates.filter(candidate => candidate.formatKind === creativeRecord.format_kind);\n const constrained = candidates.filter(candidate => refMatchesParams(candidate.ref, selectorContainer.params));\n if (constrained.length > 0) candidates = constrained;\n let resolved: V1FormatId[] | undefined;\n try {\n if (\n !containerOptsOutOfLegacy(\n selectorContainer,\n creativeRecord.format_kind,\n optionReference(creativeRecord.format_option_ref)\n )\n ) {\n resolved = resolveCanonicalFormatLegacyRefs(\n canonicalFormatLegacyResolver,\n {\n source: 'creative',\n creative: creativeRecord,\n selector: selectorContainer as Record<string, unknown>,\n operation,\n field: creativeId,\n },\n true\n );\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'canonical format legacy resolver returned an invalid or ambiguous creative mapping'\n );\n }\n if (resolved) return projectCreative(creativeRecord, resolved[0]!) as unknown as LegacyProjectedCreative<T>;\n if (candidates.length > 1) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `the seller advertised ${candidates.length} legacy refs for canonical kind ${creativeRecord.format_kind}`\n );\n }\n const reason = 'the selected seller product did not provide one unambiguous legacy format reference';\n throw new CreativeFormatProjectionError(operation, creativeId, reason);\n }\n return creative as unknown as LegacyProjectedCreative<T>;\n}\n\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: 'canonical',\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: 'legacy' | 'unknown',\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: CreativeFormatWireMode,\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'> | ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: CreativeFormatWireMode = 'canonical',\n operation: 'create_media_buy' | 'update_media_buy' = 'create_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'> | ProjectedMediaBuyCreativeRequest<T, 'legacy'> {\n const requestRecord = record(request);\n if (!requestRecord) return request as ProjectedMediaBuyCreativeRequest<T, 'canonical'>;\n let changed = false;\n const next = { ...requestRecord };\n for (const key of ['packages', 'new_packages'] as const) {\n const packages = requestRecord[key];\n if (!Array.isArray(packages)) continue;\n next[key] = packages.map(packageValue => {\n const pkg = record(packageValue);\n if (!pkg) return packageValue;\n const creatives = Array.isArray(pkg.creatives)\n ? pkg.creatives.map(creativeValue => {\n const creative = record(creativeValue);\n if (!creative) return creativeValue;\n const projected = projectCreativeForDelivery(\n creative as unknown as CreativeAsset,\n pkg as CreativeFormatSelectorContainer,\n wireMode,\n operation,\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projected !== creativeValue) changed = true;\n return projected;\n })\n : undefined;\n const projectedPackage = projectPackageSelectors(\n pkg,\n wireMode,\n operation,\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projectedPackage !== packageValue) changed = true;\n return creatives ? { ...projectedPackage, creatives } : projectedPackage;\n });\n }\n return (changed ? next : request) as\n | ProjectedMediaBuyCreativeRequest<T, 'canonical'>\n | ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\n}\n\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: 'canonical',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: 'legacy' | 'unknown',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'legacy'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: CreativeFormatWireMode,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'> | ProjectedSyncCreativeRequest<T, 'legacy'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: CreativeFormatWireMode = 'canonical',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'> | ProjectedSyncCreativeRequest<T, 'legacy'> {\n const requestRecord = record(request);\n if (!requestRecord || !Array.isArray(requestRecord.creatives)) {\n return request as ProjectedSyncCreativeRequest<T, 'canonical'>;\n }\n const assignments = Array.isArray(requestRecord.assignments) ? requestRecord.assignments : [];\n let changed = false;\n const creatives = requestRecord.creatives.map(creativeValue => {\n const creative = record(creativeValue);\n if (!creative) return creativeValue;\n const assignedPackageIds = new Set(\n assignments.flatMap(assignmentValue => {\n const assignment = record(assignmentValue);\n if (!assignment || assignment.creative_id !== creative.creative_id) return [];\n return typeof assignment.package_id === 'string' ? [assignment.package_id] : [];\n })\n );\n const relevant =\n assignedPackageIds.size === 0\n ? selectorContainers\n : selectorContainers.filter(\n container => typeof container.package_id === 'string' && assignedPackageIds.has(container.package_id)\n );\n const combined: CreativeFormatSelectorContainer = {\n selector_containers: relevant,\n };\n const projected = projectCreativeForDelivery(\n creative as unknown as CreativeAsset,\n combined,\n wireMode,\n 'sync_creatives',\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projected !== creativeValue) changed = true;\n return projected;\n });\n return (changed ? { ...requestRecord, creatives } : request) as\n | ProjectedSyncCreativeRequest<T, 'canonical'>\n | ProjectedSyncCreativeRequest<T, 'legacy'>;\n}\n\ntype CreativeProtocolRelease = { major: number; minor: number; label: string };\n\nfunction release(value: unknown): CreativeProtocolRelease | undefined {\n if (typeof value !== 'string') return undefined;\n const match = /^v?(\\d+)\\.(\\d+)(?:\\.|-|$)/.exec(value.trim());\n return match ? { major: Number(match[1]), minor: Number(match[2]), label: value } : undefined;\n}\n\nfunction mutuallyServedRelease(\n caps: Record<string, unknown> | undefined,\n raw: Record<string, unknown> | undefined,\n requestedVersion: string | undefined\n): CreativeProtocolRelease | undefined {\n const requested = release(requestedVersion);\n if (!requested) return undefined;\n const normalizedSupported = Array.isArray(caps?.supportedVersions) ? caps.supportedVersions : [];\n const directSupported = record(caps?.adcp)?.supported_versions;\n const rawSupported = record(raw?.adcp)?.supported_versions;\n const advertisedValues = [\n ...normalizedSupported,\n ...(Array.isArray(directSupported) ? directSupported : []),\n ...(Array.isArray(rawSupported) ? rawSupported : []),\n ];\n const advertised = advertisedValues.flatMap(value => {\n const parsed = release(value);\n return parsed ? [parsed] : [];\n });\n if (advertisedValues.length > 0 && advertised.length === 0) {\n throw new CreativeFormatCapabilityError(\n 'Seller advertised supported AdCP versions, but none were valid release identifiers'\n );\n }\n if (advertised.length === 0) {\n // A buyer pin is an upper bound, not evidence that the seller serves the\n // same release. Legacy 3.0 sellers commonly omit supported_versions; that\n // omission must not turn a 3.2 buyer pin into a false canonical guarantee.\n return requested.major < 3 || (requested.major === 3 && requested.minor === 0) ? requested : undefined;\n }\n const mutuallyServed = advertised\n .filter(\n candidate =>\n candidate.major === requested.major &&\n (candidate.minor < requested.minor || candidate.minor === requested.minor)\n )\n .sort((left, right) => right.minor - left.minor)[0];\n if (!mutuallyServed) {\n const supported = [...new Set(advertised.map(candidate => candidate.label))].join(', ');\n throw new CreativeFormatCapabilityError(\n `No mutually supported AdCP release: client requested ${requestedVersion}, seller advertised ${supported}`\n );\n }\n return mutuallyServed;\n}\n\nexport function resolveCreativeFormatWireMode(\n capabilities: unknown,\n negotiatedVersion?: string\n): CreativeFormatWireMode {\n const caps = record(capabilities);\n const raw = record(caps?._raw);\n const features = record(caps?.features);\n const mediaBuyFeatures = record(record(caps?.media_buy)?.features);\n const rawMediaBuyFeatures = record(record(raw?.media_buy)?.features);\n const declarations = [\n features?.canonicalCreatives,\n mediaBuyFeatures?.canonical_creatives,\n rawMediaBuyFeatures?.canonical_creatives,\n ].filter((value): value is boolean => typeof value === 'boolean');\n if (declarations.includes(true) && declarations.includes(false)) {\n throw new CreativeFormatCapabilityError(\n 'Seller capability response contains conflicting canonical_creatives declarations'\n );\n }\n const explicitCanonical = declarations[0];\n // `supported_versions` is the seller's wire-release contract. A newer\n // buyer can be downshifted within the same major, so a 3.2 client talking\n // to a 3.1-only seller must apply the 3.1 feature semantics rather than\n // assuming the 3.2 canonical guarantee. `build_version` is intentionally\n // absent here: the capability schema marks it advisory-only.\n const negotiated = mutuallyServedRelease(caps, raw, negotiatedVersion);\n if (caps?.version === 'v2') return 'legacy';\n if (negotiated && (negotiated.major > 3 || (negotiated.major === 3 && negotiated.minor >= 2))) {\n if (explicitCanonical === false) {\n throw new CreativeFormatCapabilityError(\n `AdCP ${negotiated.label} guarantees canonical creatives, but the seller advertised canonical_creatives: false`\n );\n }\n return 'canonical';\n }\n if (negotiated && (negotiated.major < 3 || (negotiated.major === 3 && negotiated.minor === 0))) {\n return 'legacy';\n }\n if (!caps) return 'unknown';\n if (explicitCanonical === true) return 'canonical';\n if (explicitCanonical === false) return 'legacy';\n return 'unknown';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,sBAAiE;AAEjE,sBAAuF;AAGvF,6BAIO;AAoHA,SAAS,4BAA+B,OAAwC;AACrF,QAAM,eAAe,oBAAI,IAAY;AACrC,QAAM,kBAAkB,oBAAI,IAAY;AACxC,QAAM,iBAAiB,oBAAI,IAAY;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,sBAAsB,CAAC,QAC3B,QAAQ,cAAc,0CAA0C,KAAK,GAAG;AAC1E,QAAM,eAAe,CAAC,OAAgC,QAAyB;AAC7E,UAAM,aAAa,OAAO,yBAAyB,OAAO,GAAG;AAC7D,WAAO,cAAc,WAAW,aAAa,WAAW,QAAQ;AAAA,EAClE;AACA,QAAM,0BAA0B,CA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a,sBAAsB,MAAM,KAAK,iBAAiB;AACrE,MAAI,MAAM,YAAY,KAAM,QAAO;AACnC,MAAI,eAAe,WAAW,QAAQ,KAAM,WAAW,UAAU,KAAK,WAAW,SAAS,IAAK;AAC7F,QAAI,sBAAsB,OAAO;AAC/B,YAAM,IAAI;AAAA,QACR,QAAQ,WAAW,KAAK;AAAA,MAC1B;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACA,MAAI,eAAe,WAAW,QAAQ,KAAM,WAAW,UAAU,KAAK,WAAW,UAAU,IAAK;AAC9F,WAAO;AAAA,EACT;AACA,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,sBAAsB,KAAM,QAAO;AACvC,MAAI,sBAAsB,MAAO,QAAO;AACxC,SAAO;AACT;","names":["value","result","needsSafeToJSON","changed","safe","next"]}
@@ -572,6 +572,7 @@ function projectPackageSelectors(pkg, wireMode, operation, legacyFormatConverter
572
572
  next.format_ids = resolved;
573
573
  delete next.format_option_refs;
574
574
  delete next.format_kind;
575
+ delete next.params;
575
576
  return next;
576
577
  }
577
578
  next.format_ids = dedupeLegacyRefs(selectedCandidates.map((candidate) => candidate.ref));
@@ -615,6 +616,7 @@ function projectPackageSelectors(pkg, wireMode, operation, legacyFormatConverter
615
616
  }
616
617
  }
617
618
  delete next.format_kind;
619
+ delete next.params;
618
620
  }
619
621
  return next;
620
622
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/v2/projection/creative-delivery.ts"],"sourcesContent":["import type {\n CreativeAsset,\n CreateMediaBuyRequest,\n CreateMediaBuyResponse,\n FormatOptionReference,\n GetProductsRequest,\n GetProductsResponse,\n GetCreativeDeliveryResponse,\n GetMediaBuyDeliveryResponse,\n GetMediaBuysResponse,\n CreativeFilters,\n ListCreativesResponse,\n ListCreativesRequest,\n PackageRequest,\n PackageUpdate,\n Package,\n Placement,\n Product,\n SyncCreativesRequest,\n SyncCreativesResponse,\n UpdateMediaBuyRequest,\n UpdateMediaBuyResponse,\n} from '../../types/tools.generated';\nimport { projectV1ProductToV2, resolveCanonicalFormatKind } from './v1-to-v2';\nimport type { LegacyFormatConverter } from './v1-to-v2';\nimport { CanonicalFormatLegacyResolutionError, resolveCanonicalFormatLegacyRefs } from './v2-to-v1';\nimport type { CanonicalFormatLegacyResolver } from './v2-to-v1';\nimport type { CanonicalFormatKind, ProjectionDiagnostic, V1FormatId } from './types';\nimport {\n legacyFormatRefsForDeclaration,\n selectedFormatOptions,\n transferLegacyCreativeMetadata,\n} from './legacy-metadata';\nimport type { CanonicalFormatDeclaration } from './legacy-metadata';\n\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, Extract<keyof T, K>> : never;\n\n/** Primary SDK creative shape. Legacy creative identity is a wire-adapter concern. */\nexport type CanonicalCreativeAsset = Omit<CanonicalCreativeResponse<CreativeAsset>, 'format_kind'> & {\n format_kind: CanonicalFormatKind;\n format_id?: never;\n};\n\n/** Explicit compatibility-only creative shape used at a legacy wire boundary. */\nexport type LegacyCreativeAsset = Omit<CreativeAsset, 'format_id' | 'format_kind' | 'format_option_ref'> & {\n format_id: V1FormatId;\n format_kind?: never;\n format_option_ref?: never;\n};\n\nexport type CanonicalPackageRequest = DistributiveOmit<\n CanonicalCreativeResponse<PackageRequest>,\n 'creatives' | 'format_ids'\n> & {\n creatives?: CanonicalCreativeAsset[];\n format_ids?: never;\n};\nexport type NonEmptyCanonicalFormatDeclarations = [CanonicalFormatDeclaration, ...CanonicalFormatDeclaration[]];\nexport type CanonicalPlacement = Omit<CanonicalCreativeResponse<Placement>, 'format_ids' | 'format_options'> & {\n format_ids?: never;\n format_options?: NonEmptyCanonicalFormatDeclarations;\n};\nexport type CanonicalProduct = Omit<\n CanonicalCreativeResponse<Product>,\n 'format_ids' | 'format_options' | 'placements'\n> & {\n product_id: string;\n format_ids?: never;\n format_options: NonEmptyCanonicalFormatDeclarations;\n placements?: CanonicalPlacement[];\n};\ntype CanonicalGetProductsField = Exclude<NonNullable<GetProductsRequest['fields']>[number], 'format_ids'>;\n/** Primary product discovery request cannot ask the SDK to expose legacy format IDs. */\nexport type CanonicalGetProductsRequest = Omit<GetProductsRequest, 'fields'> & {\n fields?: CanonicalGetProductsField[];\n};\nexport type CanonicalGetProductsResponse = Omit<CanonicalCreativeResponse<GetProductsResponse>, 'products'> & {\n products: CanonicalProduct[];\n projection: { diagnostics: ProjectionDiagnostic[] };\n};\nexport type CanonicalPackageUpdate = Omit<CanonicalCreativeResponse<PackageUpdate>, 'creatives'> & {\n creatives?: CanonicalCreativeAsset[];\n};\nexport type CanonicalPackage = CanonicalCreativeResponse<Package>;\nexport type CanonicalCreateMediaBuyRequest = Omit<CanonicalCreativeResponse<CreateMediaBuyRequest>, 'packages'> & {\n packages?: CanonicalPackageRequest[];\n};\nexport type CanonicalUpdateMediaBuyRequest = Omit<\n CanonicalCreativeResponse<UpdateMediaBuyRequest>,\n 'packages' | 'new_packages'\n> & {\n packages?: CanonicalPackageUpdate[];\n new_packages?: CanonicalPackageRequest[];\n};\nexport type CanonicalSyncCreativesRequest = Omit<CanonicalCreativeResponse<SyncCreativesRequest>, 'creatives'> & {\n creatives: CanonicalCreativeAsset[];\n};\nexport type CanonicalListedCreative = Omit<\n CanonicalCreativeResponse<ListCreativesResponse['creatives'][number]>,\n 'format_id' | 'format_kind' | 'format_option_ref'\n> & {\n format_kind: CanonicalFormatKind;\n format_option_ref?: FormatOptionReference;\n format_id?: never;\n};\nexport type CanonicalListCreativesResponse = Omit<CanonicalCreativeResponse<ListCreativesResponse>, 'creatives'> & {\n creatives: CanonicalListedCreative[];\n};\nexport type CanonicalCreateMediaBuyResponse = CanonicalCreativeResponse<CreateMediaBuyResponse>;\nexport type CanonicalUpdateMediaBuyResponse = CanonicalCreativeResponse<UpdateMediaBuyResponse>;\nexport type CanonicalSyncCreativesResponse = CanonicalCreativeResponse<SyncCreativesResponse>;\nexport type CanonicalGetMediaBuysResponse = CanonicalCreativeResponse<GetMediaBuysResponse>;\nexport type CanonicalGetMediaBuyDeliveryResponse = CanonicalCreativeResponse<GetMediaBuyDeliveryResponse>;\nexport type CanonicalGetCreativeDeliveryResponse = CanonicalCreativeResponse<GetCreativeDeliveryResponse>;\n\nexport type CanonicalCreativeFilters = Omit<CanonicalCreativeResponse<CreativeFilters>, 'format_ids'> & {\n format_ids?: never;\n};\n\ntype CanonicalListCreativeField = Exclude<NonNullable<ListCreativesRequest['fields']>[number], 'format_id'>;\n\n/** Primary list request: legacy named-format filters and response fields are migration-only. */\nexport type CanonicalListCreativesRequest = Omit<\n CanonicalCreativeResponse<ListCreativesRequest>,\n 'filters' | 'fields'\n> & {\n filters?: CanonicalCreativeFilters;\n fields?: CanonicalListCreativeField[];\n};\n\ntype IsLegacyCreativeIdentityKey<K extends PropertyKey> = K extends string\n ? K extends '_message' | `${string}format_id${string}` | `${string}v1_format_ref${string}`\n ? true\n : false\n : false;\n\n/** Recursively removes legacy creative routing identity from primary response types. */\nexport type CanonicalCreativeResponse<T> = T extends (...args: never[]) => unknown\n ? T\n : T extends readonly (infer TItem)[]\n ? CanonicalCreativeResponse<TItem>[]\n : T extends object\n ? {\n [K in keyof T as IsLegacyCreativeIdentityKey<K> extends true ? never : K]: CanonicalCreativeResponse<T[K]>;\n }\n : T;\n\n/** Runtime counterpart to {@link CanonicalCreativeResponse}. */\nexport function stripLegacyCreativeIdentity<T>(value: T): CanonicalCreativeResponse<T> {\n const legacyTokens = new Set<string>();\n const legacyUrlTokens = new Set<string>();\n const canonicalKinds = new Set<string>([\n 'image',\n 'html5',\n 'display_tag',\n 'image_carousel',\n 'video_hosted',\n 'video_vast',\n 'audio_hosted',\n 'audio_daast',\n 'sponsored_placement',\n 'native_in_feed',\n 'responsive_creative',\n 'agent_placement',\n 'custom',\n ]);\n const creativeIdentityKey = (key: string): boolean =>\n key === '_message' || /(^|_)(?:format_ids?|v1_format_ref)($|_)/.test(key);\n const ownDataValue = (owner: Record<string, unknown>, key: string): unknown => {\n const descriptor = Object.getOwnPropertyDescriptor(owner, key);\n return descriptor && 'value' in descriptor ? descriptor.value : undefined;\n };\n const nonCreativeAgentContext = (key: string | undefined): boolean =>\n typeof key === 'string' &&\n !/(^|_)(?:creative|format|legacy)($|_)/.test(key) &&\n /(^|_)(?:agents?|agent_details|agent_info)($|_)/.test(key);\n const nonCreativeSignalContext = (owner: Record<string, unknown>, key: string | undefined): boolean =>\n ownDataValue(owner, 'source') === 'agent' && typeof key === 'string' && /(^|_)signal_ids?($|_)/.test(key);\n const nonCreativeListContext = (owner: Record<string, unknown>, key: string | undefined): boolean =>\n typeof ownDataValue(owner, 'list_id') === 'string' &&\n typeof key === 'string' &&\n /(^|_)(?:property_list|collection_list|list_ref)($|_)/.test(key);\n const explicitNonCreativeContextKey = (key: string | undefined): boolean =>\n nonCreativeAgentContext(key) ||\n (typeof key === 'string' && /(^|_)(?:signal_ids?|property_list|collection_list|list_ref)($|_)/.test(key));\n const standaloneLegacyTuple = (owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (\n nonCreativeAgentContext(ownerKey) ||\n nonCreativeSignalContext(owner, ownerKey) ||\n nonCreativeListContext(owner, ownerKey)\n ) {\n return false;\n }\n if (typeof ownDataValue(owner, 'agent_url') !== 'string' || typeof ownDataValue(owner, 'id') !== 'string') {\n return false;\n }\n return true;\n };\n const preservesNonCreativeAgentUrl = (key: string, owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (!/(^|_)agent_url($|_)/.test(key)) return false;\n if (key === 'agent_url') {\n return (\n nonCreativeAgentContext(ownerKey) ||\n nonCreativeSignalContext(owner, ownerKey) ||\n nonCreativeListContext(owner, ownerKey) ||\n (typeof ownDataValue(owner, 'id') === 'string' && !standaloneLegacyTuple(owner, ownerKey))\n );\n }\n return !/(^|_)(?:creative|format|legacy|offending|target|input|output)($|_)/.test(key);\n };\n const legacyKey = (key: string, owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (creativeIdentityKey(key)) return true;\n if (!/(^|_)agent_url($|_)/.test(key)) return false;\n if (preservesNonCreativeAgentUrl(key, owner, ownerKey)) return false;\n const value = ownDataValue(owner, key);\n // Composite agent URL fields are used by several non-creative protocol\n // domains. Remove them only when their value is known to belong to a\n // legacy creative identity collected elsewhere in this payload.\n return typeof value === 'string' && legacyTokens.has(value);\n };\n const collectStrings = (current: unknown, seen = new WeakSet<object>(), ownerKey?: string): void => {\n if (typeof current === 'string') {\n if (current.length > 1) {\n legacyTokens.add(current);\n if (ownerKey === 'agent_url' || /^https?:\\/\\//i.test(current)) legacyUrlTokens.add(current);\n }\n return;\n }\n if (current === null || typeof current !== 'object' || seen.has(current)) return;\n seen.add(current);\n if (Array.isArray(current)) {\n for (const child of current) collectStrings(child, seen, ownerKey);\n return;\n }\n for (const key of Reflect.ownKeys(current)) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor || !('value' in descriptor)) continue;\n collectStrings(descriptor.value, seen, typeof key === 'string' ? key : ownerKey);\n }\n };\n const tokenSeenByContext = {\n default: new WeakSet<object>(),\n nonCreativeAgent: new WeakSet<object>(),\n };\n const collectLegacyTokens = (current: unknown, ownerKey?: string): void => {\n const seen = explicitNonCreativeContextKey(ownerKey)\n ? tokenSeenByContext.nonCreativeAgent\n : tokenSeenByContext.default;\n if (current === null || typeof current !== 'object' || seen.has(current)) return;\n seen.add(current);\n if (Array.isArray(current)) {\n for (const child of current) collectLegacyTokens(child, ownerKey);\n return;\n }\n const owner = current as Record<string, unknown>;\n if (standaloneLegacyTuple(owner, ownerKey)) collectStrings(owner, new WeakSet<object>(), ownerKey);\n for (const key of Object.getOwnPropertyNames(owner)) {\n const descriptor = Object.getOwnPropertyDescriptor(owner, key);\n if (!descriptor || !('value' in descriptor)) continue;\n const child = descriptor.value;\n if (creativeIdentityKey(key)) collectStrings(child);\n else collectLegacyTokens(child, key);\n }\n };\n collectLegacyTokens(value);\n\n const sanitizeText = (text: string, ownerKey?: string): string => {\n const mentionsLegacyIdentity =\n /\\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\\b/.test(\n text\n );\n let safe = text;\n if (mentionsLegacyIdentity) {\n // Diagnostics sometimes repeat only the flattened identity and omit the\n // structured field that supplied it. Fail closed for those orphan\n // values while leaving unrelated URLs in ordinary messages untouched.\n safe = safe.replace(/\\bhttps?:\\/\\/[^\\s\"'`<>]+/g, '[legacy creative identity]');\n safe = safe.replace(\n /(\\b(?:format_ids?|v1_format_ref|agent_url)\\b(?:\\s+(?:was|is|from))?\\s*[:=]?\\s*[\"'`]?)\\b[a-zA-Z0-9][a-zA-Z0-9_.-]{1,}/g,\n '$1[legacy creative identity]'\n );\n }\n safe = safe.replace(\n /\\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\\b/g,\n 'legacy creative identity'\n );\n for (const token of [...legacyUrlTokens].sort((left, right) => right.length - left.length)) {\n safe = safe.split(token).join('[legacy creative identity]');\n }\n const diagnosticContext =\n mentionsLegacyIdentity ||\n (typeof ownerKey === 'string' &&\n /(^|_)(?:message|question|prompt|error|reason|summary|context|stack|diagnostic)($|_)/.test(ownerKey));\n if (diagnosticContext) {\n for (const token of [...legacyTokens].sort((left, right) => right.length - left.length)) {\n if (legacyUrlTokens.has(token) || canonicalKinds.has(token)) continue;\n if (token.length < 8 && !/[_:/. -]/.test(token)) continue;\n safe = safe.split(token).join('[legacy creative identity]');\n }\n }\n return safe;\n };\n\n // The same object can appear once under an explicit agent field and once\n // under an ambiguous extension field. Cache by policy context so an allowed\n // agent occurrence cannot make a later ambiguous tuple fail open (or vice\n // versa based on property order).\n const seenByContext = {\n default: new WeakMap<object, unknown>(),\n nonCreativeAgent: new WeakMap<object, unknown>(),\n };\n const hasCustomToJSON = (candidate: object): boolean => {\n let cursor: object | null = candidate;\n while (cursor) {\n const descriptor = Object.getOwnPropertyDescriptor(cursor, 'toJSON');\n if (descriptor) return !('value' in descriptor) || typeof descriptor.value === 'function';\n cursor = Object.getPrototypeOf(cursor) as object | null;\n }\n return false;\n };\n const strip = (current: unknown, ownerKey?: string): unknown => {\n if (typeof current === 'string') return sanitizeText(current, ownerKey);\n if (current === null || typeof current !== 'object') return current;\n const seen = explicitNonCreativeContextKey(ownerKey) ? seenByContext.nonCreativeAgent : seenByContext.default;\n const cached = seen.get(current);\n if (cached !== undefined) return cached;\n if (Array.isArray(current)) {\n const result: unknown[] = [];\n seen.set(current, result);\n const needsSafeToJSON = hasCustomToJSON(current);\n let changed = needsSafeToJSON || Object.getPrototypeOf(current) !== Array.prototype;\n for (const key of Reflect.ownKeys(current)) {\n if (key === 'length') continue;\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor) continue;\n if (!('value' in descriptor)) {\n changed = true;\n continue;\n }\n if (key === 'toJSON' && typeof descriptor.value === 'function') {\n changed = true;\n continue;\n }\n if (typeof key === 'string' && legacyKey(key, current as unknown as Record<string, unknown>, ownerKey)) {\n changed = true;\n continue;\n }\n const safe = strip(descriptor.value, typeof key === 'string' && !/^\\d+$/.test(key) ? key : ownerKey);\n if (safe !== descriptor.value) changed = true;\n Object.defineProperty(result, key, { ...descriptor, value: safe });\n }\n result.length = current.length;\n if (!changed) {\n seen.set(current, current);\n return current;\n }\n if (needsSafeToJSON) {\n Object.defineProperty(result, 'toJSON', {\n configurable: true,\n enumerable: false,\n value: () => Array.from(result),\n });\n }\n transferLegacyCreativeMetadata(current, result);\n return result;\n }\n const prototype = Object.getPrototypeOf(current);\n const plain = prototype === Object.prototype || prototype === null;\n const safePrototype =\n prototype === null ? null : Error.prototype.isPrototypeOf(current) ? Error.prototype : Object.prototype;\n // Never retain an adopter-controlled prototype. Inherited getters and\n // methods are behavior, not inspected data, and can reveal legacy identity\n // after this boundary has supposedly been sanitized.\n const result: Record<string | symbol, unknown> = Object.create(safePrototype);\n seen.set(current, result);\n const owner = current as Record<string, unknown>;\n if (standaloneLegacyTuple(owner, ownerKey)) {\n const empty = {};\n seen.set(current, empty);\n return empty;\n }\n const needsSafeToJSON = hasCustomToJSON(current);\n let changed = !plain || needsSafeToJSON;\n const keys: Array<string | symbol> = Reflect.ownKeys(current);\n for (const key of keys) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor) continue;\n if (!('value' in descriptor)) {\n // Never reflect accessors across the canonical boundary. Evaluating a\n // retained getter later could reveal a legacy identity that was not\n // present while this object was inspected (and may run adopter code).\n changed = true;\n continue;\n }\n const child = descriptor.value;\n if (typeof key === 'symbol') {\n const safe = strip(child);\n if (safe !== child) changed = true;\n if (!plain) Object.defineProperty(result, key, { ...descriptor, value: safe });\n continue;\n }\n if (key === 'toJSON' && typeof child === 'function') {\n changed = true;\n continue;\n }\n if (legacyKey(key, owner, ownerKey)) {\n changed = true;\n continue;\n }\n const safe = preservesNonCreativeAgentUrl(key, owner, ownerKey) ? child : strip(child, key);\n if (safe !== child) changed = true;\n if (plain && typeof key === 'string' && descriptor.enumerable) result[key] = safe;\n else Object.defineProperty(result, key, { ...descriptor, value: safe });\n }\n if (!changed) {\n seen.set(current, current);\n return current;\n }\n if (needsSafeToJSON) {\n Object.defineProperty(result, 'toJSON', {\n configurable: true,\n enumerable: false,\n value: () => {\n const serialized: Record<string, unknown> = {};\n for (const key of Object.keys(result)) serialized[key] = result[key];\n return serialized;\n },\n });\n }\n transferLegacyCreativeMetadata(current, result);\n return result;\n };\n return strip(value) as CanonicalCreativeResponse<T>;\n}\n\nexport type CanonicalProjectedCreative<T> = Omit<T, 'format_id' | 'format_kind'> & {\n format_kind: CanonicalFormatKind;\n format_id?: never;\n};\nexport type LegacyProjectedCreative<T> = Omit<T, 'format_id' | 'format_kind' | 'format_option_ref'> & {\n format_id: V1FormatId;\n format_kind?: never;\n format_option_ref?: never;\n};\n\ntype ProjectedCreativeArray<T, TMode extends 'canonical' | 'legacy'> =\n T extends ReadonlyArray<infer TCreative>\n ? Array<TMode extends 'canonical' ? CanonicalProjectedCreative<TCreative> : LegacyProjectedCreative<TCreative>>\n : T;\ntype ReplaceCreatives<T, TMode extends 'canonical' | 'legacy'> = T extends object\n ? 'creatives' extends keyof T\n ? Omit<T, 'creatives'> &\n (Record<never, never> extends Pick<T, 'creatives'>\n ? { creatives?: ProjectedCreativeArray<T['creatives'], TMode> }\n : { creatives: ProjectedCreativeArray<T['creatives'], TMode> })\n : T\n : T;\ntype ProjectedContainerArray<T, TMode extends 'canonical' | 'legacy'> =\n T extends ReadonlyArray<infer TContainer> ? Array<ReplaceCreatives<TContainer, TMode>> : T;\ntype ReplaceContainerKey<\n T,\n TKey extends 'packages' | 'new_packages',\n TMode extends 'canonical' | 'legacy',\n> = TKey extends keyof T\n ? Record<never, never> extends Pick<T, TKey>\n ? { [K in TKey]?: ProjectedContainerArray<T[TKey], TMode> }\n : { [K in TKey]: ProjectedContainerArray<T[TKey], TMode> }\n : Record<never, never>;\n\nexport type ProjectedMediaBuyCreativeRequest<T, TMode extends 'canonical' | 'legacy'> = Omit<\n T,\n 'packages' | 'new_packages'\n> &\n ReplaceContainerKey<T, 'packages', TMode> &\n ReplaceContainerKey<T, 'new_packages', TMode>;\nexport type ProjectedSyncCreativeRequest<T, TMode extends 'canonical' | 'legacy'> = ReplaceCreatives<T, TMode>;\n\nexport type CreativeFormatWireMode = 'canonical' | 'legacy' | 'unknown';\n\nexport interface CreativeFormatSelectorContainer {\n package_id?: string;\n format_ids?: unknown[];\n formats?: unknown[];\n format_options?: unknown[];\n format_option_refs?: unknown[];\n format_kind?: unknown;\n params?: unknown;\n /** Internal composition seam used to preserve per-package selector constraints. */\n selector_containers?: ReadonlyArray<CreativeFormatSelectorContainer>;\n [key: string]: unknown;\n}\n\n/** Canonical package/product selectors accepted by the primary sync API. */\nexport interface CanonicalCreativeFormatSelectorContainer {\n package_id?: string;\n format_options?: ReadonlyArray<CanonicalFormatDeclaration>;\n format_option_refs?: ReadonlyArray<FormatOptionReference>;\n format_kind?: CanonicalFormatKind;\n params?: CanonicalFormatDeclaration['params'];\n selector_containers?: ReadonlyArray<CanonicalCreativeFormatSelectorContainer>;\n}\n\nexport interface SyncCreativeFormatProjection {\n selectorContainers: ReadonlyArray<CanonicalCreativeFormatSelectorContainer>;\n legacyFormatConverter?: LegacyFormatConverter;\n}\n\nexport class CreativeFormatProjectionError extends Error {\n readonly code = 'ADCP_CREATIVE_FORMAT_PROJECTION_FAILED';\n\n constructor(\n readonly operation: string,\n readonly creativeId: string,\n reason: string\n ) {\n super(`${operation}: cannot select a valid creative wire shape for ${creativeId}: ${reason}`);\n this.name = 'CreativeFormatProjectionError';\n }\n}\n\nexport class CreativeFormatCapabilityError extends Error {\n readonly code = 'ADCP_CREATIVE_FORMAT_CAPABILITY_CONTRADICTION';\n\n constructor(message: string) {\n super(message);\n this.name = 'CreativeFormatCapabilityError';\n }\n}\n\nconst CANONICAL_FORMAT_KINDS = new Set<CanonicalFormatKind>([\n 'image',\n 'html5',\n 'display_tag',\n 'image_carousel',\n 'video_hosted',\n 'video_vast',\n 'audio_hosted',\n 'audio_daast',\n 'sponsored_placement',\n 'native_in_feed',\n 'responsive_creative',\n 'agent_placement',\n 'custom',\n]);\n\ntype LegacyCandidate = {\n ref: V1FormatId;\n formatKind?: string;\n formatOptionRef?: FormatOptionReference;\n selectorParams?: unknown;\n};\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction legacyRef(value: unknown): V1FormatId | undefined {\n const candidate = record(value);\n if (!candidate || typeof candidate.agent_url !== 'string' || typeof candidate.id !== 'string') return undefined;\n if (candidate.agent_url.length === 0 || candidate.id.length === 0) return undefined;\n return {\n agent_url: candidate.agent_url,\n id: candidate.id,\n ...(typeof candidate.width === 'number' ? { width: candidate.width } : {}),\n ...(typeof candidate.height === 'number' ? { height: candidate.height } : {}),\n ...(typeof candidate.duration_ms === 'number' ? { duration_ms: candidate.duration_ms } : {}),\n };\n}\n\nfunction refsFromValue(value: unknown): V1FormatId[] {\n if (Array.isArray(value)) return value.flatMap(item => refsFromValue(item));\n const ref = legacyRef(value);\n return ref ? [ref] : [];\n}\n\ntype CanonicalFormatOptionReference = FormatOptionReference & { canonical_formats_only?: true };\n\nfunction optionReference(value: unknown): CanonicalFormatOptionReference | undefined {\n const option = record(value);\n if (!option || typeof option.format_option_id !== 'string' || option.format_option_id.length === 0) return undefined;\n const canonicalOnly = option.canonical_formats_only === true ? { canonical_formats_only: true as const } : {};\n if (typeof option.publisher_domain === 'string') {\n return {\n scope: 'publisher',\n publisher_domain: option.publisher_domain,\n format_option_id: option.format_option_id,\n ...canonicalOnly,\n };\n }\n return { scope: 'product', format_option_id: option.format_option_id, ...canonicalOnly };\n}\n\nfunction sameOptionReference(left: FormatOptionReference, right: FormatOptionReference): boolean {\n return (\n left.scope === right.scope &&\n left.format_option_id === right.format_option_id &&\n (left.scope !== 'publisher' || (right.scope === 'publisher' && left.publisher_domain === right.publisher_domain))\n );\n}\n\nfunction selectedOptionReferences(container: CreativeFormatSelectorContainer): CanonicalFormatOptionReference[] {\n const direct = Array.isArray(container.format_option_refs)\n ? container.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n const nested = Array.isArray(container.selector_containers)\n ? container.selector_containers.flatMap(selectedOptionReferences)\n : [];\n return [...direct, ...nested];\n}\n\nfunction agentIdentity(value: string): string {\n try {\n // URL parsing normalizes the scheme/host (the case-insensitive pieces)\n // while preserving case-sensitive paths, queries, and fragments.\n return new URL(value).href;\n } catch {\n return value;\n }\n}\n\nfunction sameLegacyIdentity(left: V1FormatId, right: V1FormatId): boolean {\n return agentIdentity(left.agent_url) === agentIdentity(right.agent_url) && left.id === right.id;\n}\n\nfunction candidatesFromContainer(\n container: CreativeFormatSelectorContainer,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver,\n operation = 'creative_delivery'\n): LegacyCandidate[] {\n if (Array.isArray(container.selector_containers)) {\n return uniqueCandidates(\n container.selector_containers.flatMap(candidate =>\n candidatesFromContainer(candidate, canonicalFormatLegacyResolver, operation)\n )\n );\n }\n const candidates: LegacyCandidate[] = [];\n const containerKind = typeof container.format_kind === 'string' ? container.format_kind : undefined;\n for (const key of ['format_ids', 'formats'] as const) {\n for (const ref of refsFromValue(container[key])) {\n candidates.push({\n ref,\n formatKind: resolveCanonicalFormatKind(ref.id) ?? containerKind,\n selectorParams: container.params,\n });\n }\n }\n const formatOptions = [\n ...(Array.isArray(container.format_options) ? container.format_options : []),\n ...selectedFormatOptions(container),\n ];\n for (const optionValue of formatOptions) {\n const option = record(optionValue);\n if (!option) continue;\n const formatKind = typeof option.format_kind === 'string' ? option.format_kind : undefined;\n const formatOptionRef = optionReference(option);\n let refs = [...legacyFormatRefsForDeclaration(option)];\n if (refs.length === 0 && option.canonical_formats_only !== true && formatKind) {\n try {\n refs =\n resolveCanonicalFormatLegacyRefs(canonicalFormatLegacyResolver, {\n source: 'product',\n declaration: option as unknown as import('./types').V2ProductFormatDeclaration,\n productId: typeof container.product_id === 'string' ? container.product_id : '<selector>',\n field: formatOptionRef?.format_option_id ?? '(format option)',\n }) ?? [];\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(format option)',\n 'canonical format legacy resolver returned an invalid product mapping'\n );\n }\n }\n for (const ref of refs) {\n candidates.push({ ref, formatKind, formatOptionRef, selectorParams: option.params ?? container.params });\n }\n }\n return uniqueCandidates(candidates);\n}\n\nfunction containerOptsOutOfLegacy(\n container: CreativeFormatSelectorContainer,\n formatKind?: string,\n formatOptionRef?: FormatOptionReference\n): boolean {\n if ((formatOptionRef as CanonicalFormatOptionReference | undefined)?.canonical_formats_only === true) return true;\n if (\n Array.isArray(container.selector_containers) &&\n container.selector_containers.some(candidate => containerOptsOutOfLegacy(candidate, formatKind, formatOptionRef))\n ) {\n return true;\n }\n const selectedRefs = selectedOptionReferences(container);\n if (\n selectedRefs.some(ref => {\n if (ref.canonical_formats_only !== true) return false;\n return formatOptionRef === undefined || sameOptionReference(ref, formatOptionRef);\n })\n ) {\n return true;\n }\n const formatOptions = [\n ...(Array.isArray(container.format_options) ? container.format_options : []),\n ...selectedFormatOptions(container),\n ];\n return formatOptions.some(value => {\n const option = record(value);\n if (!option || option.canonical_formats_only !== true) return false;\n if (formatKind && option.format_kind !== formatKind) return false;\n if (formatOptionRef) {\n const optionRef = optionReference(option);\n if (!optionRef || !sameOptionReference(optionRef, formatOptionRef)) return false;\n }\n return true;\n });\n}\n\nfunction candidateKey(candidate: LegacyCandidate): string {\n const ref = candidate.ref;\n return [\n agentIdentity(ref.agent_url),\n ref.id,\n ref.width ?? '',\n ref.height ?? '',\n ref.duration_ms ?? '',\n candidate.formatOptionRef?.scope ?? '',\n candidate.formatOptionRef?.format_option_id ?? '',\n candidate.formatOptionRef?.scope === 'publisher' ? candidate.formatOptionRef.publisher_domain : '',\n ].join('|');\n}\n\nfunction uniqueCandidates(candidates: LegacyCandidate[]): LegacyCandidate[] {\n return [...new Map(candidates.map(candidate => [candidateKey(candidate), candidate])).values()];\n}\n\nfunction refMatchesParams(ref: V1FormatId, paramsValue: unknown): boolean {\n const params = record(paramsValue);\n if (!params) return true;\n const sizes = Array.isArray(params.sizes) ? params.sizes.flatMap(size => (record(size) ? [record(size)!] : [])) : [];\n if (sizes.length === 1) {\n const size = sizes[0]!;\n if (typeof size.width === 'number' && ref.width !== size.width) return false;\n if (typeof size.height === 'number' && ref.height !== size.height) return false;\n }\n if (typeof params.width === 'number' && ref.width !== params.width) return false;\n if (typeof params.height === 'number' && ref.height !== params.height) return false;\n if (typeof params.duration_ms_exact === 'number' && ref.duration_ms !== params.duration_ms_exact) return false;\n return true;\n}\n\nfunction selectLegacyRef(\n creative: Record<string, unknown>,\n container: CreativeFormatSelectorContainer,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver,\n operation = 'creative_delivery'\n): V1FormatId | undefined {\n let candidates = candidatesFromContainer(container, canonicalFormatLegacyResolver, operation);\n const creativeOptionRef = optionReference(creative.format_option_ref);\n const selectedOptionRefs = Array.isArray(container.format_option_refs)\n ? container.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n if (creativeOptionRef) {\n if (selectedOptionRefs.length > 0 && !selectedOptionRefs.some(ref => sameOptionReference(ref, creativeOptionRef))) {\n return undefined;\n }\n candidates = candidates.filter(\n candidate => candidate.formatOptionRef && sameOptionReference(candidate.formatOptionRef, creativeOptionRef)\n );\n } else if (selectedOptionRefs.length > 0) {\n candidates = candidates.filter(\n candidate =>\n candidate.formatOptionRef &&\n selectedOptionRefs.some(ref => sameOptionReference(ref, candidate.formatOptionRef!))\n );\n }\n const existing = legacyRef(creative.format_id);\n if (existing) {\n const exact = candidates.filter(\n candidate =>\n sameLegacyIdentity(candidate.ref, existing) &&\n (existing.width === undefined || candidate.ref.width === existing.width) &&\n (existing.height === undefined || candidate.ref.height === existing.height) &&\n (existing.duration_ms === undefined || candidate.ref.duration_ms === existing.duration_ms)\n );\n if (exact.length === 1) return exact[0]!.ref;\n return candidates.length === 0 ? existing : undefined;\n }\n\n if (typeof creative.format_kind !== 'string') return undefined;\n let matching = candidates.filter(candidate => candidate.formatKind === creative.format_kind);\n const constrained = matching.filter(candidate => refMatchesParams(candidate.ref, candidate.selectorParams));\n if (constrained.length > 0) matching = constrained;\n return matching.length === 1 ? matching[0]!.ref : undefined;\n}\n\nfunction projectCreative<T extends Record<string, unknown>>(creative: T, formatId: V1FormatId): T {\n const next: Record<string, unknown> = { ...creative };\n delete next.format_kind;\n delete next.format_option_ref;\n next.format_id = { ...formatId };\n return next as T;\n}\n\nfunction dedupeLegacyRefs(refs: readonly V1FormatId[]): V1FormatId[] {\n return [...new Map(refs.map(ref => [candidateKey({ ref }), { ...ref }])).values()];\n}\n\nfunction projectPackageSelectors(\n pkg: Record<string | symbol, unknown>,\n wireMode: CreativeFormatWireMode,\n operation: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): Record<string | symbol, unknown> {\n const next = { ...pkg };\n const optionRefs = Array.isArray(pkg.format_option_refs)\n ? pkg.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n const legacyRefs = refsFromValue(pkg.format_ids);\n const candidates = candidatesFromContainer(\n pkg as CreativeFormatSelectorContainer,\n wireMode === 'canonical' ? undefined : canonicalFormatLegacyResolver,\n operation\n );\n const canonicalKind = typeof pkg.format_kind === 'string' ? pkg.format_kind : undefined;\n\n if (wireMode === 'canonical') {\n if (optionRefs.length > 0) {\n // Rebuild the array before transport so SDK-private downgrade metadata\n // never crosses the canonical wire boundary.\n next.format_option_refs = optionRefs.map(ref => ({ ...ref }));\n }\n if (legacyRefs.length > 0) {\n let mappedRefs = legacyRefs.flatMap(legacy => {\n const matches = candidates.filter(candidate => sameLegacyIdentity(candidate.ref, legacy));\n if (matches.length !== 1 || !matches[0]!.formatOptionRef) return [];\n return [matches[0]!.formatOptionRef];\n });\n if (optionRefs.length === 0 && mappedRefs.length !== legacyRefs.length) {\n const productId = typeof pkg.product_id === 'string' ? pkg.product_id : '<package-selector>';\n const projected = projectV1ProductToV2(\n {\n product_id: productId,\n name: productId,\n description: 'legacy package selector normalization',\n format_ids: legacyRefs,\n },\n { legacyFormatConverter }\n );\n const projectedRefs = projected.v2.format_options.flatMap(option => {\n const ref = optionReference(option);\n return ref ? [ref] : [];\n });\n if (projected.diagnostics.length > 0 || projectedRefs.length !== legacyRefs.length) {\n // Cannot convert this package's legacy format_ids to canonical format_option_refs.\n // Return the package unchanged rather than throwing so responses for existing\n // buys remain usable. These buys were created before canonical format_option_refs\n // were enforced at write time.\n return next;\n }\n mappedRefs = projectedRefs;\n }\n if (optionRefs.length === 0) next.format_option_refs = mappedRefs;\n }\n delete next.format_ids;\n } else {\n if (optionRefs.length > 0) {\n const selectedCandidates = candidates.filter(\n candidate =>\n candidate.formatOptionRef &&\n optionRefs.some(selected => sameOptionReference(selected, candidate.formatOptionRef!))\n );\n const everyOptionMapped = optionRefs.every(selected =>\n selectedCandidates.some(candidate =>\n candidate.formatOptionRef ? sameOptionReference(selected, candidate.formatOptionRef) : false\n )\n );\n if (!everyOptionMapped || selectedCandidates.length === 0) {\n let resolved: V1FormatId[] | undefined;\n try {\n if (!containerOptsOutOfLegacy(pkg as CreativeFormatSelectorContainer)) {\n resolved = resolveCanonicalFormatLegacyRefs(canonicalFormatLegacyResolver, {\n source: 'selector',\n selector: pkg as Record<string, unknown>,\n operation,\n field: '(package selector)',\n });\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format legacy resolver returned an invalid or ambiguous package mapping'\n );\n }\n if (!resolved) {\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format_option_refs have no complete legacy representation; re-run getProducts() or configure canonicalFormatLegacyResolver for persisted selections'\n );\n }\n next.format_ids = resolved;\n delete next.format_option_refs;\n delete next.format_kind;\n return next;\n }\n next.format_ids = dedupeLegacyRefs(selectedCandidates.map(candidate => candidate.ref));\n delete next.format_option_refs;\n } else if (canonicalKind) {\n const selectedCandidates = candidates.filter(candidate => candidate.formatKind === canonicalKind);\n if (selectedCandidates.length === 1) {\n next.format_ids = [{ ...selectedCandidates[0]!.ref }];\n } else {\n let resolved: V1FormatId[] | undefined;\n try {\n if (!containerOptsOutOfLegacy(pkg as CreativeFormatSelectorContainer, canonicalKind)) {\n resolved = resolveCanonicalFormatLegacyRefs(\n canonicalFormatLegacyResolver,\n {\n source: 'selector',\n selector: pkg as Record<string, unknown>,\n operation,\n field: '(package selector)',\n },\n true\n );\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format legacy resolver returned an invalid or ambiguous package mapping'\n );\n }\n if (resolved) {\n next.format_ids = resolved;\n } else {\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical package format_kind has no unambiguous legacy representation; select a format_option_ref from the product before delivery'\n );\n }\n }\n }\n delete next.format_kind;\n }\n\n return next;\n}\n\nfunction canonicalizeCreative<T extends Record<string, unknown>>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n operation: string,\n legacyFormatConverter?: LegacyFormatConverter\n): T {\n const creativeId = typeof creative.creative_id === 'string' ? creative.creative_id : '(unknown)';\n const hasCanonicalKind = typeof creative.format_kind === 'string';\n if (hasCanonicalKind && creative.format_id !== undefined) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative must not declare both canonical format_kind and legacy format_id'\n );\n }\n if (hasCanonicalKind && creative.format_id === undefined) {\n if (!CANONICAL_FORMAT_KINDS.has(creative.format_kind as CanonicalFormatKind)) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `unknown canonical format_kind ${creative.format_kind}`\n );\n }\n const creativeOptionRef = optionReference(creative.format_option_ref);\n const selectedRefs = selectedOptionReferences(selectorContainer);\n if (\n creativeOptionRef &&\n selectedRefs.length > 0 &&\n !selectedRefs.some(ref => sameOptionReference(ref, creativeOptionRef))\n ) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative format_option_ref conflicts with the package selected format_option_refs'\n );\n }\n return creative;\n }\n const existing = legacyRef(creative.format_id);\n if (!existing) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative must identify its format canonically with format_kind'\n );\n }\n\n const matchingCandidates = candidatesFromContainer(selectorContainer).filter(\n candidate =>\n sameLegacyIdentity(candidate.ref, existing) &&\n (existing.width === undefined || candidate.ref.width === existing.width) &&\n (existing.height === undefined || candidate.ref.height === existing.height) &&\n (existing.duration_ms === undefined || candidate.ref.duration_ms === existing.duration_ms)\n );\n if (matchingCandidates.length === 1 && matchingCandidates[0]!.formatKind) {\n const candidate = matchingCandidates[0]!;\n const next: Record<string, unknown> = { ...creative, format_kind: candidate.formatKind };\n delete next.format_id;\n if (candidate.formatOptionRef) next.format_option_ref = candidate.formatOptionRef;\n if (candidate.formatKind === 'custom' && !candidate.formatOptionRef) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'custom product format must provide format_option_id so the canonical creative retains a concrete identity'\n );\n }\n return next as T;\n }\n const selectorCandidates = candidatesFromContainer(selectorContainer);\n if (selectorCandidates.length > 0 && matchingCandidates.length !== 1) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n matchingCandidates.length === 0\n ? 'legacy format reference conflicts with the selected seller format identity or constraints'\n : 'legacy format reference is ambiguous within the selected seller format options'\n );\n }\n\n const { v2, diagnostics } = projectV1ProductToV2(\n {\n product_id: `<creative:${creativeId}>`,\n name: creativeId,\n description: 'legacy creative normalization',\n format_ids: [existing],\n },\n { legacyFormatConverter }\n );\n const declaration = v2.format_options[0];\n if (!declaration) {\n const diagnostic = diagnostics[0];\n const failure =\n diagnostic?.code === 'FORMAT_PROJECTION_FAILED' ? diagnostic.error.details.resolution_failure : undefined;\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `legacy creative format has no canonical conversion${failure ? ` (${failure})` : ''}`\n );\n }\n const next: Record<string, unknown> = { ...creative, format_kind: declaration.format_kind };\n delete next.format_id;\n const candidateOptionRef =\n matchingCandidates.length === 1 && matchingCandidates[0]!.formatKind === declaration.format_kind\n ? matchingCandidates[0]!.formatOptionRef\n : undefined;\n const convertedOptionRef = optionReference(declaration) ?? candidateOptionRef;\n if (convertedOptionRef) next.format_option_ref = convertedOptionRef;\n if (declaration.format_kind === 'custom' && !convertedOptionRef) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'custom legacy conversion must provide format_option_id so the canonical creative retains a concrete identity'\n );\n }\n return next as T;\n}\n\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode?: 'canonical',\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: 'legacy' | 'unknown',\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): LegacyProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: CreativeFormatWireMode,\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T> | LegacyProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: CreativeFormatWireMode = 'canonical',\n operation = 'creative_delivery',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T> | LegacyProjectedCreative<T> {\n const inputRecord = creative as unknown as Record<string, unknown>;\n const originalLegacyRef = legacyRef(inputRecord.format_id);\n const creativeRecord = canonicalizeCreative(inputRecord, selectorContainer, operation, legacyFormatConverter);\n if (wireMode === 'canonical') return creativeRecord as unknown as CanonicalProjectedCreative<T>;\n if (originalLegacyRef) {\n const selectedOriginal = selectLegacyRef(inputRecord, selectorContainer, canonicalFormatLegacyResolver, operation);\n if (selectedOriginal) {\n return projectCreative(creativeRecord, selectedOriginal) as unknown as LegacyProjectedCreative<T>;\n }\n throw new CreativeFormatProjectionError(\n operation,\n typeof inputRecord.creative_id === 'string' ? inputRecord.creative_id : '(unknown)',\n 'the original legacy format reference conflicts with the selected seller format identity or constraints'\n );\n }\n const formatId = selectLegacyRef(creativeRecord, selectorContainer, canonicalFormatLegacyResolver, operation);\n if (formatId) return projectCreative(creativeRecord, formatId) as unknown as LegacyProjectedCreative<T>;\n\n if (typeof creativeRecord.format_kind === 'string') {\n const creativeId = typeof creativeRecord.creative_id === 'string' ? creativeRecord.creative_id : '(unknown)';\n const allCandidates = candidatesFromContainer(selectorContainer, canonicalFormatLegacyResolver, operation);\n let candidates = allCandidates.filter(candidate => candidate.formatKind === creativeRecord.format_kind);\n const constrained = candidates.filter(candidate => refMatchesParams(candidate.ref, selectorContainer.params));\n if (constrained.length > 0) candidates = constrained;\n let resolved: V1FormatId[] | undefined;\n try {\n if (\n !containerOptsOutOfLegacy(\n selectorContainer,\n creativeRecord.format_kind,\n optionReference(creativeRecord.format_option_ref)\n )\n ) {\n resolved = resolveCanonicalFormatLegacyRefs(\n canonicalFormatLegacyResolver,\n {\n source: 'creative',\n creative: creativeRecord,\n selector: selectorContainer as Record<string, unknown>,\n operation,\n field: creativeId,\n },\n true\n );\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'canonical format legacy resolver returned an invalid or ambiguous creative mapping'\n );\n }\n if (resolved) return projectCreative(creativeRecord, resolved[0]!) as unknown as LegacyProjectedCreative<T>;\n if (candidates.length > 1) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `the seller advertised ${candidates.length} legacy refs for canonical kind ${creativeRecord.format_kind}`\n );\n }\n const reason = 'the selected seller product did not provide one unambiguous legacy format reference';\n throw new CreativeFormatProjectionError(operation, creativeId, reason);\n }\n return creative as unknown as LegacyProjectedCreative<T>;\n}\n\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: 'canonical',\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: 'legacy' | 'unknown',\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: CreativeFormatWireMode,\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'> | ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: CreativeFormatWireMode = 'canonical',\n operation: 'create_media_buy' | 'update_media_buy' = 'create_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'> | ProjectedMediaBuyCreativeRequest<T, 'legacy'> {\n const requestRecord = record(request);\n if (!requestRecord) return request as ProjectedMediaBuyCreativeRequest<T, 'canonical'>;\n let changed = false;\n const next = { ...requestRecord };\n for (const key of ['packages', 'new_packages'] as const) {\n const packages = requestRecord[key];\n if (!Array.isArray(packages)) continue;\n next[key] = packages.map(packageValue => {\n const pkg = record(packageValue);\n if (!pkg) return packageValue;\n const creatives = Array.isArray(pkg.creatives)\n ? pkg.creatives.map(creativeValue => {\n const creative = record(creativeValue);\n if (!creative) return creativeValue;\n const projected = projectCreativeForDelivery(\n creative as unknown as CreativeAsset,\n pkg as CreativeFormatSelectorContainer,\n wireMode,\n operation,\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projected !== creativeValue) changed = true;\n return projected;\n })\n : undefined;\n const projectedPackage = projectPackageSelectors(\n pkg,\n wireMode,\n operation,\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projectedPackage !== packageValue) changed = true;\n return creatives ? { ...projectedPackage, creatives } : projectedPackage;\n });\n }\n return (changed ? next : request) as\n | ProjectedMediaBuyCreativeRequest<T, 'canonical'>\n | ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\n}\n\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: 'canonical',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: 'legacy' | 'unknown',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'legacy'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: CreativeFormatWireMode,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'> | ProjectedSyncCreativeRequest<T, 'legacy'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: CreativeFormatWireMode = 'canonical',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'> | ProjectedSyncCreativeRequest<T, 'legacy'> {\n const requestRecord = record(request);\n if (!requestRecord || !Array.isArray(requestRecord.creatives)) {\n return request as ProjectedSyncCreativeRequest<T, 'canonical'>;\n }\n const assignments = Array.isArray(requestRecord.assignments) ? requestRecord.assignments : [];\n let changed = false;\n const creatives = requestRecord.creatives.map(creativeValue => {\n const creative = record(creativeValue);\n if (!creative) return creativeValue;\n const assignedPackageIds = new Set(\n assignments.flatMap(assignmentValue => {\n const assignment = record(assignmentValue);\n if (!assignment || assignment.creative_id !== creative.creative_id) return [];\n return typeof assignment.package_id === 'string' ? [assignment.package_id] : [];\n })\n );\n const relevant =\n assignedPackageIds.size === 0\n ? selectorContainers\n : selectorContainers.filter(\n container => typeof container.package_id === 'string' && assignedPackageIds.has(container.package_id)\n );\n const combined: CreativeFormatSelectorContainer = {\n selector_containers: relevant,\n };\n const projected = projectCreativeForDelivery(\n creative as unknown as CreativeAsset,\n combined,\n wireMode,\n 'sync_creatives',\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projected !== creativeValue) changed = true;\n return projected;\n });\n return (changed ? { ...requestRecord, creatives } : request) as\n | ProjectedSyncCreativeRequest<T, 'canonical'>\n | ProjectedSyncCreativeRequest<T, 'legacy'>;\n}\n\ntype CreativeProtocolRelease = { major: number; minor: number; label: string };\n\nfunction release(value: unknown): CreativeProtocolRelease | undefined {\n if (typeof value !== 'string') return undefined;\n const match = /^v?(\\d+)\\.(\\d+)(?:\\.|-|$)/.exec(value.trim());\n return match ? { major: Number(match[1]), minor: Number(match[2]), label: value } : undefined;\n}\n\nfunction mutuallyServedRelease(\n caps: Record<string, unknown> | undefined,\n raw: Record<string, unknown> | undefined,\n requestedVersion: string | undefined\n): CreativeProtocolRelease | undefined {\n const requested = release(requestedVersion);\n if (!requested) return undefined;\n const normalizedSupported = Array.isArray(caps?.supportedVersions) ? caps.supportedVersions : [];\n const directSupported = record(caps?.adcp)?.supported_versions;\n const rawSupported = record(raw?.adcp)?.supported_versions;\n const advertisedValues = [\n ...normalizedSupported,\n ...(Array.isArray(directSupported) ? directSupported : []),\n ...(Array.isArray(rawSupported) ? rawSupported : []),\n ];\n const advertised = advertisedValues.flatMap(value => {\n const parsed = release(value);\n return parsed ? [parsed] : [];\n });\n if (advertisedValues.length > 0 && advertised.length === 0) {\n throw new CreativeFormatCapabilityError(\n 'Seller advertised supported AdCP versions, but none were valid release identifiers'\n );\n }\n if (advertised.length === 0) {\n // A buyer pin is an upper bound, not evidence that the seller serves the\n // same release. Legacy 3.0 sellers commonly omit supported_versions; that\n // omission must not turn a 3.2 buyer pin into a false canonical guarantee.\n return requested.major < 3 || (requested.major === 3 && requested.minor === 0) ? requested : undefined;\n }\n const mutuallyServed = advertised\n .filter(\n candidate =>\n candidate.major === requested.major &&\n (candidate.minor < requested.minor || candidate.minor === requested.minor)\n )\n .sort((left, right) => right.minor - left.minor)[0];\n if (!mutuallyServed) {\n const supported = [...new Set(advertised.map(candidate => candidate.label))].join(', ');\n throw new CreativeFormatCapabilityError(\n `No mutually supported AdCP release: client requested ${requestedVersion}, seller advertised ${supported}`\n );\n }\n return mutuallyServed;\n}\n\nexport function resolveCreativeFormatWireMode(\n capabilities: unknown,\n negotiatedVersion?: string\n): CreativeFormatWireMode {\n const caps = record(capabilities);\n const raw = record(caps?._raw);\n const features = record(caps?.features);\n const mediaBuyFeatures = record(record(caps?.media_buy)?.features);\n const rawMediaBuyFeatures = record(record(raw?.media_buy)?.features);\n const declarations = [\n features?.canonicalCreatives,\n mediaBuyFeatures?.canonical_creatives,\n rawMediaBuyFeatures?.canonical_creatives,\n ].filter((value): value is boolean => typeof value === 'boolean');\n if (declarations.includes(true) && declarations.includes(false)) {\n throw new CreativeFormatCapabilityError(\n 'Seller capability response contains conflicting canonical_creatives declarations'\n );\n }\n const explicitCanonical = declarations[0];\n // `supported_versions` is the seller's wire-release contract. A newer\n // buyer can be downshifted within the same major, so a 3.2 client talking\n // to a 3.1-only seller must apply the 3.1 feature semantics rather than\n // assuming the 3.2 canonical guarantee. `build_version` is intentionally\n // absent here: the capability schema marks it advisory-only.\n const negotiated = mutuallyServedRelease(caps, raw, negotiatedVersion);\n if (caps?.version === 'v2') return 'legacy';\n if (negotiated && (negotiated.major > 3 || (negotiated.major === 3 && negotiated.minor >= 2))) {\n if (explicitCanonical === false) {\n throw new CreativeFormatCapabilityError(\n `AdCP ${negotiated.label} guarantees canonical creatives, but the seller advertised canonical_creatives: false`\n );\n }\n return 'canonical';\n }\n if (negotiated && (negotiated.major < 3 || (negotiated.major === 3 && negotiated.minor === 0))) {\n return 'legacy';\n }\n if (!caps) return 'unknown';\n if (explicitCanonical === true) return 'canonical';\n if (explicitCanonical === false) return 'legacy';\n return 'unknown';\n}\n"],"mappings":"AAuBA,SAAS,sBAAsB,kCAAkC;AAEjE,SAAS,sCAAsC,wCAAwC;AAGvF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAoHA,SAAS,4BAA+B,OAAwC;AACrF,QAAM,eAAe,oBAAI,IAAY;AACrC,QAAM,kBAAkB,oBAAI,IAAY;AACxC,QAAM,iBAAiB,oBAAI,IAAY;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,sBAAsB,CAAC,QAC3B,QAAQ,cAAc,0CAA0C,KAAK,GAAG;AAC1E,QAAM,eAAe,CAAC,OAAgC,QAAyB;AAC7E,UAAM,aAAa,OAAO,yBAAyB,OAAO,GAAG;AAC7D,WAAO,cAAc,WAAW,aAAa,WAAW,QAAQ;AAAA,EAClE;AACA,QAAM,0BAA0B,CAAC,QAC/B,OAAO,QAAQ,YACf,CAAC,uCAAuC,KAAK,GAAG,KAChD,iDAAiD,KAAK,GAAG;AAC3D,QAAM,2BAA2B,CAAC,OAAgC,QAChE,aAAa,OAAO,QAAQ,MAAM,WAAW,OAAO,QAAQ,YAAY,wBAAwB,KAAK,GAAG;AAC1G,QAAM,yBAAyB,CAAC,OAAgC,QAC9D,OAAO,aAAa,OAAO,SAAS,MAAM,YAC1C,OAAO,QAAQ,YACf,uDAAuD,KAAK,GAAG;AACjE,QAAM,gCAAgC,CAAC,QACrC,wBAAwB,GAAG,KAC1B,OAAO,QAAQ,YAAY,mEAAmE,KAAK,GAAG;AACzG,QAAM,wBAAwB,CAAC,OAAgC,aAA+B;AAC5F,QACE,wBAAwB,QAAQ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version":3,"sources":["../../../../src/lib/v2/projection/creative-delivery.ts"],"sourcesContent":["import type {\n CreativeAsset,\n CreateMediaBuyRequest,\n CreateMediaBuyResponse,\n FormatOptionReference,\n GetProductsRequest,\n GetProductsResponse,\n GetCreativeDeliveryResponse,\n GetMediaBuyDeliveryResponse,\n GetMediaBuysResponse,\n CreativeFilters,\n ListCreativesResponse,\n ListCreativesRequest,\n PackageRequest,\n PackageUpdate,\n Package,\n Placement,\n Product,\n SyncCreativesRequest,\n SyncCreativesResponse,\n UpdateMediaBuyRequest,\n UpdateMediaBuyResponse,\n} from '../../types/tools.generated';\nimport { projectV1ProductToV2, resolveCanonicalFormatKind } from './v1-to-v2';\nimport type { LegacyFormatConverter } from './v1-to-v2';\nimport { CanonicalFormatLegacyResolutionError, resolveCanonicalFormatLegacyRefs } from './v2-to-v1';\nimport type { CanonicalFormatLegacyResolver } from './v2-to-v1';\nimport type { CanonicalFormatKind, ProjectionDiagnostic, V1FormatId } from './types';\nimport {\n legacyFormatRefsForDeclaration,\n selectedFormatOptions,\n transferLegacyCreativeMetadata,\n} from './legacy-metadata';\nimport type { CanonicalFormatDeclaration } from './legacy-metadata';\n\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, Extract<keyof T, K>> : never;\n\n/** Primary SDK creative shape. Legacy creative identity is a wire-adapter concern. */\nexport type CanonicalCreativeAsset = Omit<CanonicalCreativeResponse<CreativeAsset>, 'format_kind'> & {\n format_kind: CanonicalFormatKind;\n format_id?: never;\n};\n\n/** Explicit compatibility-only creative shape used at a legacy wire boundary. */\nexport type LegacyCreativeAsset = Omit<CreativeAsset, 'format_id' | 'format_kind' | 'format_option_ref'> & {\n format_id: V1FormatId;\n format_kind?: never;\n format_option_ref?: never;\n};\n\nexport type CanonicalPackageRequest = DistributiveOmit<\n CanonicalCreativeResponse<PackageRequest>,\n 'creatives' | 'format_ids'\n> & {\n creatives?: CanonicalCreativeAsset[];\n format_ids?: never;\n};\nexport type NonEmptyCanonicalFormatDeclarations = [CanonicalFormatDeclaration, ...CanonicalFormatDeclaration[]];\nexport type CanonicalPlacement = Omit<CanonicalCreativeResponse<Placement>, 'format_ids' | 'format_options'> & {\n format_ids?: never;\n format_options?: NonEmptyCanonicalFormatDeclarations;\n};\nexport type CanonicalProduct = Omit<\n CanonicalCreativeResponse<Product>,\n 'format_ids' | 'format_options' | 'placements'\n> & {\n product_id: string;\n format_ids?: never;\n format_options: NonEmptyCanonicalFormatDeclarations;\n placements?: CanonicalPlacement[];\n};\ntype CanonicalGetProductsField = Exclude<NonNullable<GetProductsRequest['fields']>[number], 'format_ids'>;\n/** Primary product discovery request cannot ask the SDK to expose legacy format IDs. */\nexport type CanonicalGetProductsRequest = Omit<GetProductsRequest, 'fields'> & {\n fields?: CanonicalGetProductsField[];\n};\nexport type CanonicalGetProductsResponse = Omit<CanonicalCreativeResponse<GetProductsResponse>, 'products'> & {\n products: CanonicalProduct[];\n projection: { diagnostics: ProjectionDiagnostic[] };\n};\nexport type CanonicalPackageUpdate = Omit<CanonicalCreativeResponse<PackageUpdate>, 'creatives'> & {\n creatives?: CanonicalCreativeAsset[];\n};\nexport type CanonicalPackage = CanonicalCreativeResponse<Package>;\nexport type CanonicalCreateMediaBuyRequest = Omit<CanonicalCreativeResponse<CreateMediaBuyRequest>, 'packages'> & {\n packages?: CanonicalPackageRequest[];\n};\nexport type CanonicalUpdateMediaBuyRequest = Omit<\n CanonicalCreativeResponse<UpdateMediaBuyRequest>,\n 'packages' | 'new_packages'\n> & {\n packages?: CanonicalPackageUpdate[];\n new_packages?: CanonicalPackageRequest[];\n};\nexport type CanonicalSyncCreativesRequest = Omit<CanonicalCreativeResponse<SyncCreativesRequest>, 'creatives'> & {\n creatives: CanonicalCreativeAsset[];\n};\nexport type CanonicalListedCreative = Omit<\n CanonicalCreativeResponse<ListCreativesResponse['creatives'][number]>,\n 'format_id' | 'format_kind' | 'format_option_ref'\n> & {\n format_kind: CanonicalFormatKind;\n format_option_ref?: FormatOptionReference;\n format_id?: never;\n};\nexport type CanonicalListCreativesResponse = Omit<CanonicalCreativeResponse<ListCreativesResponse>, 'creatives'> & {\n creatives: CanonicalListedCreative[];\n};\nexport type CanonicalCreateMediaBuyResponse = CanonicalCreativeResponse<CreateMediaBuyResponse>;\nexport type CanonicalUpdateMediaBuyResponse = CanonicalCreativeResponse<UpdateMediaBuyResponse>;\nexport type CanonicalSyncCreativesResponse = CanonicalCreativeResponse<SyncCreativesResponse>;\nexport type CanonicalGetMediaBuysResponse = CanonicalCreativeResponse<GetMediaBuysResponse>;\nexport type CanonicalGetMediaBuyDeliveryResponse = CanonicalCreativeResponse<GetMediaBuyDeliveryResponse>;\nexport type CanonicalGetCreativeDeliveryResponse = CanonicalCreativeResponse<GetCreativeDeliveryResponse>;\n\nexport type CanonicalCreativeFilters = Omit<CanonicalCreativeResponse<CreativeFilters>, 'format_ids'> & {\n format_ids?: never;\n};\n\ntype CanonicalListCreativeField = Exclude<NonNullable<ListCreativesRequest['fields']>[number], 'format_id'>;\n\n/** Primary list request: legacy named-format filters and response fields are migration-only. */\nexport type CanonicalListCreativesRequest = Omit<\n CanonicalCreativeResponse<ListCreativesRequest>,\n 'filters' | 'fields'\n> & {\n filters?: CanonicalCreativeFilters;\n fields?: CanonicalListCreativeField[];\n};\n\ntype IsLegacyCreativeIdentityKey<K extends PropertyKey> = K extends string\n ? K extends '_message' | `${string}format_id${string}` | `${string}v1_format_ref${string}`\n ? true\n : false\n : false;\n\n/** Recursively removes legacy creative routing identity from primary response types. */\nexport type CanonicalCreativeResponse<T> = T extends (...args: never[]) => unknown\n ? T\n : T extends readonly (infer TItem)[]\n ? CanonicalCreativeResponse<TItem>[]\n : T extends object\n ? {\n [K in keyof T as IsLegacyCreativeIdentityKey<K> extends true ? never : K]: CanonicalCreativeResponse<T[K]>;\n }\n : T;\n\n/** Runtime counterpart to {@link CanonicalCreativeResponse}. */\nexport function stripLegacyCreativeIdentity<T>(value: T): CanonicalCreativeResponse<T> {\n const legacyTokens = new Set<string>();\n const legacyUrlTokens = new Set<string>();\n const canonicalKinds = new Set<string>([\n 'image',\n 'html5',\n 'display_tag',\n 'image_carousel',\n 'video_hosted',\n 'video_vast',\n 'audio_hosted',\n 'audio_daast',\n 'sponsored_placement',\n 'native_in_feed',\n 'responsive_creative',\n 'agent_placement',\n 'custom',\n ]);\n const creativeIdentityKey = (key: string): boolean =>\n key === '_message' || /(^|_)(?:format_ids?|v1_format_ref)($|_)/.test(key);\n const ownDataValue = (owner: Record<string, unknown>, key: string): unknown => {\n const descriptor = Object.getOwnPropertyDescriptor(owner, key);\n return descriptor && 'value' in descriptor ? descriptor.value : undefined;\n };\n const nonCreativeAgentContext = (key: string | undefined): boolean =>\n typeof key === 'string' &&\n !/(^|_)(?:creative|format|legacy)($|_)/.test(key) &&\n /(^|_)(?:agents?|agent_details|agent_info)($|_)/.test(key);\n const nonCreativeSignalContext = (owner: Record<string, unknown>, key: string | undefined): boolean =>\n ownDataValue(owner, 'source') === 'agent' && typeof key === 'string' && /(^|_)signal_ids?($|_)/.test(key);\n const nonCreativeListContext = (owner: Record<string, unknown>, key: string | undefined): boolean =>\n typeof ownDataValue(owner, 'list_id') === 'string' &&\n typeof key === 'string' &&\n /(^|_)(?:property_list|collection_list|list_ref)($|_)/.test(key);\n const explicitNonCreativeContextKey = (key: string | undefined): boolean =>\n nonCreativeAgentContext(key) ||\n (typeof key === 'string' && /(^|_)(?:signal_ids?|property_list|collection_list|list_ref)($|_)/.test(key));\n const standaloneLegacyTuple = (owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (\n nonCreativeAgentContext(ownerKey) ||\n nonCreativeSignalContext(owner, ownerKey) ||\n nonCreativeListContext(owner, ownerKey)\n ) {\n return false;\n }\n if (typeof ownDataValue(owner, 'agent_url') !== 'string' || typeof ownDataValue(owner, 'id') !== 'string') {\n return false;\n }\n return true;\n };\n const preservesNonCreativeAgentUrl = (key: string, owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (!/(^|_)agent_url($|_)/.test(key)) return false;\n if (key === 'agent_url') {\n return (\n nonCreativeAgentContext(ownerKey) ||\n nonCreativeSignalContext(owner, ownerKey) ||\n nonCreativeListContext(owner, ownerKey) ||\n (typeof ownDataValue(owner, 'id') === 'string' && !standaloneLegacyTuple(owner, ownerKey))\n );\n }\n return !/(^|_)(?:creative|format|legacy|offending|target|input|output)($|_)/.test(key);\n };\n const legacyKey = (key: string, owner: Record<string, unknown>, ownerKey?: string): boolean => {\n if (creativeIdentityKey(key)) return true;\n if (!/(^|_)agent_url($|_)/.test(key)) return false;\n if (preservesNonCreativeAgentUrl(key, owner, ownerKey)) return false;\n const value = ownDataValue(owner, key);\n // Composite agent URL fields are used by several non-creative protocol\n // domains. Remove them only when their value is known to belong to a\n // legacy creative identity collected elsewhere in this payload.\n return typeof value === 'string' && legacyTokens.has(value);\n };\n const collectStrings = (current: unknown, seen = new WeakSet<object>(), ownerKey?: string): void => {\n if (typeof current === 'string') {\n if (current.length > 1) {\n legacyTokens.add(current);\n if (ownerKey === 'agent_url' || /^https?:\\/\\//i.test(current)) legacyUrlTokens.add(current);\n }\n return;\n }\n if (current === null || typeof current !== 'object' || seen.has(current)) return;\n seen.add(current);\n if (Array.isArray(current)) {\n for (const child of current) collectStrings(child, seen, ownerKey);\n return;\n }\n for (const key of Reflect.ownKeys(current)) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor || !('value' in descriptor)) continue;\n collectStrings(descriptor.value, seen, typeof key === 'string' ? key : ownerKey);\n }\n };\n const tokenSeenByContext = {\n default: new WeakSet<object>(),\n nonCreativeAgent: new WeakSet<object>(),\n };\n const collectLegacyTokens = (current: unknown, ownerKey?: string): void => {\n const seen = explicitNonCreativeContextKey(ownerKey)\n ? tokenSeenByContext.nonCreativeAgent\n : tokenSeenByContext.default;\n if (current === null || typeof current !== 'object' || seen.has(current)) return;\n seen.add(current);\n if (Array.isArray(current)) {\n for (const child of current) collectLegacyTokens(child, ownerKey);\n return;\n }\n const owner = current as Record<string, unknown>;\n if (standaloneLegacyTuple(owner, ownerKey)) collectStrings(owner, new WeakSet<object>(), ownerKey);\n for (const key of Object.getOwnPropertyNames(owner)) {\n const descriptor = Object.getOwnPropertyDescriptor(owner, key);\n if (!descriptor || !('value' in descriptor)) continue;\n const child = descriptor.value;\n if (creativeIdentityKey(key)) collectStrings(child);\n else collectLegacyTokens(child, key);\n }\n };\n collectLegacyTokens(value);\n\n const sanitizeText = (text: string, ownerKey?: string): string => {\n const mentionsLegacyIdentity =\n /\\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\\b/.test(\n text\n );\n let safe = text;\n if (mentionsLegacyIdentity) {\n // Diagnostics sometimes repeat only the flattened identity and omit the\n // structured field that supplied it. Fail closed for those orphan\n // values while leaving unrelated URLs in ordinary messages untouched.\n safe = safe.replace(/\\bhttps?:\\/\\/[^\\s\"'`<>]+/g, '[legacy creative identity]');\n safe = safe.replace(\n /(\\b(?:format_ids?|v1_format_ref|agent_url)\\b(?:\\s+(?:was|is|from))?\\s*[:=]?\\s*[\"'`]?)\\b[a-zA-Z0-9][a-zA-Z0-9_.-]{1,}/g,\n '$1[legacy creative identity]'\n );\n }\n safe = safe.replace(\n /\\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\\b/g,\n 'legacy creative identity'\n );\n for (const token of [...legacyUrlTokens].sort((left, right) => right.length - left.length)) {\n safe = safe.split(token).join('[legacy creative identity]');\n }\n const diagnosticContext =\n mentionsLegacyIdentity ||\n (typeof ownerKey === 'string' &&\n /(^|_)(?:message|question|prompt|error|reason|summary|context|stack|diagnostic)($|_)/.test(ownerKey));\n if (diagnosticContext) {\n for (const token of [...legacyTokens].sort((left, right) => right.length - left.length)) {\n if (legacyUrlTokens.has(token) || canonicalKinds.has(token)) continue;\n if (token.length < 8 && !/[_:/. -]/.test(token)) continue;\n safe = safe.split(token).join('[legacy creative identity]');\n }\n }\n return safe;\n };\n\n // The same object can appear once under an explicit agent field and once\n // under an ambiguous extension field. Cache by policy context so an allowed\n // agent occurrence cannot make a later ambiguous tuple fail open (or vice\n // versa based on property order).\n const seenByContext = {\n default: new WeakMap<object, unknown>(),\n nonCreativeAgent: new WeakMap<object, unknown>(),\n };\n const hasCustomToJSON = (candidate: object): boolean => {\n let cursor: object | null = candidate;\n while (cursor) {\n const descriptor = Object.getOwnPropertyDescriptor(cursor, 'toJSON');\n if (descriptor) return !('value' in descriptor) || typeof descriptor.value === 'function';\n cursor = Object.getPrototypeOf(cursor) as object | null;\n }\n return false;\n };\n const strip = (current: unknown, ownerKey?: string): unknown => {\n if (typeof current === 'string') return sanitizeText(current, ownerKey);\n if (current === null || typeof current !== 'object') return current;\n const seen = explicitNonCreativeContextKey(ownerKey) ? seenByContext.nonCreativeAgent : seenByContext.default;\n const cached = seen.get(current);\n if (cached !== undefined) return cached;\n if (Array.isArray(current)) {\n const result: unknown[] = [];\n seen.set(current, result);\n const needsSafeToJSON = hasCustomToJSON(current);\n let changed = needsSafeToJSON || Object.getPrototypeOf(current) !== Array.prototype;\n for (const key of Reflect.ownKeys(current)) {\n if (key === 'length') continue;\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor) continue;\n if (!('value' in descriptor)) {\n changed = true;\n continue;\n }\n if (key === 'toJSON' && typeof descriptor.value === 'function') {\n changed = true;\n continue;\n }\n if (typeof key === 'string' && legacyKey(key, current as unknown as Record<string, unknown>, ownerKey)) {\n changed = true;\n continue;\n }\n const safe = strip(descriptor.value, typeof key === 'string' && !/^\\d+$/.test(key) ? key : ownerKey);\n if (safe !== descriptor.value) changed = true;\n Object.defineProperty(result, key, { ...descriptor, value: safe });\n }\n result.length = current.length;\n if (!changed) {\n seen.set(current, current);\n return current;\n }\n if (needsSafeToJSON) {\n Object.defineProperty(result, 'toJSON', {\n configurable: true,\n enumerable: false,\n value: () => Array.from(result),\n });\n }\n transferLegacyCreativeMetadata(current, result);\n return result;\n }\n const prototype = Object.getPrototypeOf(current);\n const plain = prototype === Object.prototype || prototype === null;\n const safePrototype =\n prototype === null ? null : Error.prototype.isPrototypeOf(current) ? Error.prototype : Object.prototype;\n // Never retain an adopter-controlled prototype. Inherited getters and\n // methods are behavior, not inspected data, and can reveal legacy identity\n // after this boundary has supposedly been sanitized.\n const result: Record<string | symbol, unknown> = Object.create(safePrototype);\n seen.set(current, result);\n const owner = current as Record<string, unknown>;\n if (standaloneLegacyTuple(owner, ownerKey)) {\n const empty = {};\n seen.set(current, empty);\n return empty;\n }\n const needsSafeToJSON = hasCustomToJSON(current);\n let changed = !plain || needsSafeToJSON;\n const keys: Array<string | symbol> = Reflect.ownKeys(current);\n for (const key of keys) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (!descriptor) continue;\n if (!('value' in descriptor)) {\n // Never reflect accessors across the canonical boundary. Evaluating a\n // retained getter later could reveal a legacy identity that was not\n // present while this object was inspected (and may run adopter code).\n changed = true;\n continue;\n }\n const child = descriptor.value;\n if (typeof key === 'symbol') {\n const safe = strip(child);\n if (safe !== child) changed = true;\n if (!plain) Object.defineProperty(result, key, { ...descriptor, value: safe });\n continue;\n }\n if (key === 'toJSON' && typeof child === 'function') {\n changed = true;\n continue;\n }\n if (legacyKey(key, owner, ownerKey)) {\n changed = true;\n continue;\n }\n const safe = preservesNonCreativeAgentUrl(key, owner, ownerKey) ? child : strip(child, key);\n if (safe !== child) changed = true;\n if (plain && typeof key === 'string' && descriptor.enumerable) result[key] = safe;\n else Object.defineProperty(result, key, { ...descriptor, value: safe });\n }\n if (!changed) {\n seen.set(current, current);\n return current;\n }\n if (needsSafeToJSON) {\n Object.defineProperty(result, 'toJSON', {\n configurable: true,\n enumerable: false,\n value: () => {\n const serialized: Record<string, unknown> = {};\n for (const key of Object.keys(result)) serialized[key] = result[key];\n return serialized;\n },\n });\n }\n transferLegacyCreativeMetadata(current, result);\n return result;\n };\n return strip(value) as CanonicalCreativeResponse<T>;\n}\n\nexport type CanonicalProjectedCreative<T> = Omit<T, 'format_id' | 'format_kind'> & {\n format_kind: CanonicalFormatKind;\n format_id?: never;\n};\nexport type LegacyProjectedCreative<T> = Omit<T, 'format_id' | 'format_kind' | 'format_option_ref'> & {\n format_id: V1FormatId;\n format_kind?: never;\n format_option_ref?: never;\n};\n\ntype ProjectedCreativeArray<T, TMode extends 'canonical' | 'legacy'> =\n T extends ReadonlyArray<infer TCreative>\n ? Array<TMode extends 'canonical' ? CanonicalProjectedCreative<TCreative> : LegacyProjectedCreative<TCreative>>\n : T;\ntype ReplaceCreatives<T, TMode extends 'canonical' | 'legacy'> = T extends object\n ? 'creatives' extends keyof T\n ? Omit<T, 'creatives'> &\n (Record<never, never> extends Pick<T, 'creatives'>\n ? { creatives?: ProjectedCreativeArray<T['creatives'], TMode> }\n : { creatives: ProjectedCreativeArray<T['creatives'], TMode> })\n : T\n : T;\ntype ProjectedContainerArray<T, TMode extends 'canonical' | 'legacy'> =\n T extends ReadonlyArray<infer TContainer> ? Array<ReplaceCreatives<TContainer, TMode>> : T;\ntype ReplaceContainerKey<\n T,\n TKey extends 'packages' | 'new_packages',\n TMode extends 'canonical' | 'legacy',\n> = TKey extends keyof T\n ? Record<never, never> extends Pick<T, TKey>\n ? { [K in TKey]?: ProjectedContainerArray<T[TKey], TMode> }\n : { [K in TKey]: ProjectedContainerArray<T[TKey], TMode> }\n : Record<never, never>;\n\nexport type ProjectedMediaBuyCreativeRequest<T, TMode extends 'canonical' | 'legacy'> = Omit<\n T,\n 'packages' | 'new_packages'\n> &\n ReplaceContainerKey<T, 'packages', TMode> &\n ReplaceContainerKey<T, 'new_packages', TMode>;\nexport type ProjectedSyncCreativeRequest<T, TMode extends 'canonical' | 'legacy'> = ReplaceCreatives<T, TMode>;\n\nexport type CreativeFormatWireMode = 'canonical' | 'legacy' | 'unknown';\n\nexport interface CreativeFormatSelectorContainer {\n package_id?: string;\n format_ids?: unknown[];\n formats?: unknown[];\n format_options?: unknown[];\n format_option_refs?: unknown[];\n format_kind?: unknown;\n params?: unknown;\n /** Internal composition seam used to preserve per-package selector constraints. */\n selector_containers?: ReadonlyArray<CreativeFormatSelectorContainer>;\n [key: string]: unknown;\n}\n\n/** Canonical package/product selectors accepted by the primary sync API. */\nexport interface CanonicalCreativeFormatSelectorContainer {\n package_id?: string;\n format_options?: ReadonlyArray<CanonicalFormatDeclaration>;\n format_option_refs?: ReadonlyArray<FormatOptionReference>;\n format_kind?: CanonicalFormatKind;\n params?: CanonicalFormatDeclaration['params'];\n selector_containers?: ReadonlyArray<CanonicalCreativeFormatSelectorContainer>;\n}\n\nexport interface SyncCreativeFormatProjection {\n selectorContainers: ReadonlyArray<CanonicalCreativeFormatSelectorContainer>;\n legacyFormatConverter?: LegacyFormatConverter;\n}\n\nexport class CreativeFormatProjectionError extends Error {\n readonly code = 'ADCP_CREATIVE_FORMAT_PROJECTION_FAILED';\n\n constructor(\n readonly operation: string,\n readonly creativeId: string,\n reason: string\n ) {\n super(`${operation}: cannot select a valid creative wire shape for ${creativeId}: ${reason}`);\n this.name = 'CreativeFormatProjectionError';\n }\n}\n\nexport class CreativeFormatCapabilityError extends Error {\n readonly code = 'ADCP_CREATIVE_FORMAT_CAPABILITY_CONTRADICTION';\n\n constructor(message: string) {\n super(message);\n this.name = 'CreativeFormatCapabilityError';\n }\n}\n\nconst CANONICAL_FORMAT_KINDS = new Set<CanonicalFormatKind>([\n 'image',\n 'html5',\n 'display_tag',\n 'image_carousel',\n 'video_hosted',\n 'video_vast',\n 'audio_hosted',\n 'audio_daast',\n 'sponsored_placement',\n 'native_in_feed',\n 'responsive_creative',\n 'agent_placement',\n 'custom',\n]);\n\ntype LegacyCandidate = {\n ref: V1FormatId;\n formatKind?: string;\n formatOptionRef?: FormatOptionReference;\n selectorParams?: unknown;\n};\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction legacyRef(value: unknown): V1FormatId | undefined {\n const candidate = record(value);\n if (!candidate || typeof candidate.agent_url !== 'string' || typeof candidate.id !== 'string') return undefined;\n if (candidate.agent_url.length === 0 || candidate.id.length === 0) return undefined;\n return {\n agent_url: candidate.agent_url,\n id: candidate.id,\n ...(typeof candidate.width === 'number' ? { width: candidate.width } : {}),\n ...(typeof candidate.height === 'number' ? { height: candidate.height } : {}),\n ...(typeof candidate.duration_ms === 'number' ? { duration_ms: candidate.duration_ms } : {}),\n };\n}\n\nfunction refsFromValue(value: unknown): V1FormatId[] {\n if (Array.isArray(value)) return value.flatMap(item => refsFromValue(item));\n const ref = legacyRef(value);\n return ref ? [ref] : [];\n}\n\ntype CanonicalFormatOptionReference = FormatOptionReference & { canonical_formats_only?: true };\n\nfunction optionReference(value: unknown): CanonicalFormatOptionReference | undefined {\n const option = record(value);\n if (!option || typeof option.format_option_id !== 'string' || option.format_option_id.length === 0) return undefined;\n const canonicalOnly = option.canonical_formats_only === true ? { canonical_formats_only: true as const } : {};\n if (typeof option.publisher_domain === 'string') {\n return {\n scope: 'publisher',\n publisher_domain: option.publisher_domain,\n format_option_id: option.format_option_id,\n ...canonicalOnly,\n };\n }\n return { scope: 'product', format_option_id: option.format_option_id, ...canonicalOnly };\n}\n\nfunction sameOptionReference(left: FormatOptionReference, right: FormatOptionReference): boolean {\n return (\n left.scope === right.scope &&\n left.format_option_id === right.format_option_id &&\n (left.scope !== 'publisher' || (right.scope === 'publisher' && left.publisher_domain === right.publisher_domain))\n );\n}\n\nfunction selectedOptionReferences(container: CreativeFormatSelectorContainer): CanonicalFormatOptionReference[] {\n const direct = Array.isArray(container.format_option_refs)\n ? container.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n const nested = Array.isArray(container.selector_containers)\n ? container.selector_containers.flatMap(selectedOptionReferences)\n : [];\n return [...direct, ...nested];\n}\n\nfunction agentIdentity(value: string): string {\n try {\n // URL parsing normalizes the scheme/host (the case-insensitive pieces)\n // while preserving case-sensitive paths, queries, and fragments.\n return new URL(value).href;\n } catch {\n return value;\n }\n}\n\nfunction sameLegacyIdentity(left: V1FormatId, right: V1FormatId): boolean {\n return agentIdentity(left.agent_url) === agentIdentity(right.agent_url) && left.id === right.id;\n}\n\nfunction candidatesFromContainer(\n container: CreativeFormatSelectorContainer,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver,\n operation = 'creative_delivery'\n): LegacyCandidate[] {\n if (Array.isArray(container.selector_containers)) {\n return uniqueCandidates(\n container.selector_containers.flatMap(candidate =>\n candidatesFromContainer(candidate, canonicalFormatLegacyResolver, operation)\n )\n );\n }\n const candidates: LegacyCandidate[] = [];\n const containerKind = typeof container.format_kind === 'string' ? container.format_kind : undefined;\n for (const key of ['format_ids', 'formats'] as const) {\n for (const ref of refsFromValue(container[key])) {\n candidates.push({\n ref,\n formatKind: resolveCanonicalFormatKind(ref.id) ?? containerKind,\n selectorParams: container.params,\n });\n }\n }\n const formatOptions = [\n ...(Array.isArray(container.format_options) ? container.format_options : []),\n ...selectedFormatOptions(container),\n ];\n for (const optionValue of formatOptions) {\n const option = record(optionValue);\n if (!option) continue;\n const formatKind = typeof option.format_kind === 'string' ? option.format_kind : undefined;\n const formatOptionRef = optionReference(option);\n let refs = [...legacyFormatRefsForDeclaration(option)];\n if (refs.length === 0 && option.canonical_formats_only !== true && formatKind) {\n try {\n refs =\n resolveCanonicalFormatLegacyRefs(canonicalFormatLegacyResolver, {\n source: 'product',\n declaration: option as unknown as import('./types').V2ProductFormatDeclaration,\n productId: typeof container.product_id === 'string' ? container.product_id : '<selector>',\n field: formatOptionRef?.format_option_id ?? '(format option)',\n }) ?? [];\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(format option)',\n 'canonical format legacy resolver returned an invalid product mapping'\n );\n }\n }\n for (const ref of refs) {\n candidates.push({ ref, formatKind, formatOptionRef, selectorParams: option.params ?? container.params });\n }\n }\n return uniqueCandidates(candidates);\n}\n\nfunction containerOptsOutOfLegacy(\n container: CreativeFormatSelectorContainer,\n formatKind?: string,\n formatOptionRef?: FormatOptionReference\n): boolean {\n if ((formatOptionRef as CanonicalFormatOptionReference | undefined)?.canonical_formats_only === true) return true;\n if (\n Array.isArray(container.selector_containers) &&\n container.selector_containers.some(candidate => containerOptsOutOfLegacy(candidate, formatKind, formatOptionRef))\n ) {\n return true;\n }\n const selectedRefs = selectedOptionReferences(container);\n if (\n selectedRefs.some(ref => {\n if (ref.canonical_formats_only !== true) return false;\n return formatOptionRef === undefined || sameOptionReference(ref, formatOptionRef);\n })\n ) {\n return true;\n }\n const formatOptions = [\n ...(Array.isArray(container.format_options) ? container.format_options : []),\n ...selectedFormatOptions(container),\n ];\n return formatOptions.some(value => {\n const option = record(value);\n if (!option || option.canonical_formats_only !== true) return false;\n if (formatKind && option.format_kind !== formatKind) return false;\n if (formatOptionRef) {\n const optionRef = optionReference(option);\n if (!optionRef || !sameOptionReference(optionRef, formatOptionRef)) return false;\n }\n return true;\n });\n}\n\nfunction candidateKey(candidate: LegacyCandidate): string {\n const ref = candidate.ref;\n return [\n agentIdentity(ref.agent_url),\n ref.id,\n ref.width ?? '',\n ref.height ?? '',\n ref.duration_ms ?? '',\n candidate.formatOptionRef?.scope ?? '',\n candidate.formatOptionRef?.format_option_id ?? '',\n candidate.formatOptionRef?.scope === 'publisher' ? candidate.formatOptionRef.publisher_domain : '',\n ].join('|');\n}\n\nfunction uniqueCandidates(candidates: LegacyCandidate[]): LegacyCandidate[] {\n return [...new Map(candidates.map(candidate => [candidateKey(candidate), candidate])).values()];\n}\n\nfunction refMatchesParams(ref: V1FormatId, paramsValue: unknown): boolean {\n const params = record(paramsValue);\n if (!params) return true;\n const sizes = Array.isArray(params.sizes) ? params.sizes.flatMap(size => (record(size) ? [record(size)!] : [])) : [];\n if (sizes.length === 1) {\n const size = sizes[0]!;\n if (typeof size.width === 'number' && ref.width !== size.width) return false;\n if (typeof size.height === 'number' && ref.height !== size.height) return false;\n }\n if (typeof params.width === 'number' && ref.width !== params.width) return false;\n if (typeof params.height === 'number' && ref.height !== params.height) return false;\n if (typeof params.duration_ms_exact === 'number' && ref.duration_ms !== params.duration_ms_exact) return false;\n return true;\n}\n\nfunction selectLegacyRef(\n creative: Record<string, unknown>,\n container: CreativeFormatSelectorContainer,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver,\n operation = 'creative_delivery'\n): V1FormatId | undefined {\n let candidates = candidatesFromContainer(container, canonicalFormatLegacyResolver, operation);\n const creativeOptionRef = optionReference(creative.format_option_ref);\n const selectedOptionRefs = Array.isArray(container.format_option_refs)\n ? container.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n if (creativeOptionRef) {\n if (selectedOptionRefs.length > 0 && !selectedOptionRefs.some(ref => sameOptionReference(ref, creativeOptionRef))) {\n return undefined;\n }\n candidates = candidates.filter(\n candidate => candidate.formatOptionRef && sameOptionReference(candidate.formatOptionRef, creativeOptionRef)\n );\n } else if (selectedOptionRefs.length > 0) {\n candidates = candidates.filter(\n candidate =>\n candidate.formatOptionRef &&\n selectedOptionRefs.some(ref => sameOptionReference(ref, candidate.formatOptionRef!))\n );\n }\n const existing = legacyRef(creative.format_id);\n if (existing) {\n const exact = candidates.filter(\n candidate =>\n sameLegacyIdentity(candidate.ref, existing) &&\n (existing.width === undefined || candidate.ref.width === existing.width) &&\n (existing.height === undefined || candidate.ref.height === existing.height) &&\n (existing.duration_ms === undefined || candidate.ref.duration_ms === existing.duration_ms)\n );\n if (exact.length === 1) return exact[0]!.ref;\n return candidates.length === 0 ? existing : undefined;\n }\n\n if (typeof creative.format_kind !== 'string') return undefined;\n let matching = candidates.filter(candidate => candidate.formatKind === creative.format_kind);\n const constrained = matching.filter(candidate => refMatchesParams(candidate.ref, candidate.selectorParams));\n if (constrained.length > 0) matching = constrained;\n return matching.length === 1 ? matching[0]!.ref : undefined;\n}\n\nfunction projectCreative<T extends Record<string, unknown>>(creative: T, formatId: V1FormatId): T {\n const next: Record<string, unknown> = { ...creative };\n delete next.format_kind;\n delete next.format_option_ref;\n next.format_id = { ...formatId };\n return next as T;\n}\n\nfunction dedupeLegacyRefs(refs: readonly V1FormatId[]): V1FormatId[] {\n return [...new Map(refs.map(ref => [candidateKey({ ref }), { ...ref }])).values()];\n}\n\nfunction projectPackageSelectors(\n pkg: Record<string | symbol, unknown>,\n wireMode: CreativeFormatWireMode,\n operation: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): Record<string | symbol, unknown> {\n const next = { ...pkg };\n const optionRefs = Array.isArray(pkg.format_option_refs)\n ? pkg.format_option_refs.flatMap(value => {\n const ref = optionReference(value);\n return ref ? [ref] : [];\n })\n : [];\n const legacyRefs = refsFromValue(pkg.format_ids);\n const candidates = candidatesFromContainer(\n pkg as CreativeFormatSelectorContainer,\n wireMode === 'canonical' ? undefined : canonicalFormatLegacyResolver,\n operation\n );\n const canonicalKind = typeof pkg.format_kind === 'string' ? pkg.format_kind : undefined;\n\n if (wireMode === 'canonical') {\n if (optionRefs.length > 0) {\n // Rebuild the array before transport so SDK-private downgrade metadata\n // never crosses the canonical wire boundary.\n next.format_option_refs = optionRefs.map(ref => ({ ...ref }));\n }\n if (legacyRefs.length > 0) {\n let mappedRefs = legacyRefs.flatMap(legacy => {\n const matches = candidates.filter(candidate => sameLegacyIdentity(candidate.ref, legacy));\n if (matches.length !== 1 || !matches[0]!.formatOptionRef) return [];\n return [matches[0]!.formatOptionRef];\n });\n if (optionRefs.length === 0 && mappedRefs.length !== legacyRefs.length) {\n const productId = typeof pkg.product_id === 'string' ? pkg.product_id : '<package-selector>';\n const projected = projectV1ProductToV2(\n {\n product_id: productId,\n name: productId,\n description: 'legacy package selector normalization',\n format_ids: legacyRefs,\n },\n { legacyFormatConverter }\n );\n const projectedRefs = projected.v2.format_options.flatMap(option => {\n const ref = optionReference(option);\n return ref ? [ref] : [];\n });\n if (projected.diagnostics.length > 0 || projectedRefs.length !== legacyRefs.length) {\n // Cannot convert this package's legacy format_ids to canonical format_option_refs.\n // Return the package unchanged rather than throwing so responses for existing\n // buys remain usable. These buys were created before canonical format_option_refs\n // were enforced at write time.\n return next;\n }\n mappedRefs = projectedRefs;\n }\n if (optionRefs.length === 0) next.format_option_refs = mappedRefs;\n }\n delete next.format_ids;\n } else {\n if (optionRefs.length > 0) {\n const selectedCandidates = candidates.filter(\n candidate =>\n candidate.formatOptionRef &&\n optionRefs.some(selected => sameOptionReference(selected, candidate.formatOptionRef!))\n );\n const everyOptionMapped = optionRefs.every(selected =>\n selectedCandidates.some(candidate =>\n candidate.formatOptionRef ? sameOptionReference(selected, candidate.formatOptionRef) : false\n )\n );\n if (!everyOptionMapped || selectedCandidates.length === 0) {\n let resolved: V1FormatId[] | undefined;\n try {\n if (!containerOptsOutOfLegacy(pkg as CreativeFormatSelectorContainer)) {\n resolved = resolveCanonicalFormatLegacyRefs(canonicalFormatLegacyResolver, {\n source: 'selector',\n selector: pkg as Record<string, unknown>,\n operation,\n field: '(package selector)',\n });\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format legacy resolver returned an invalid or ambiguous package mapping'\n );\n }\n if (!resolved) {\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format_option_refs have no complete legacy representation; re-run getProducts() or configure canonicalFormatLegacyResolver for persisted selections'\n );\n }\n next.format_ids = resolved;\n delete next.format_option_refs;\n delete next.format_kind;\n delete next.params;\n return next;\n }\n next.format_ids = dedupeLegacyRefs(selectedCandidates.map(candidate => candidate.ref));\n delete next.format_option_refs;\n } else if (canonicalKind) {\n const selectedCandidates = candidates.filter(candidate => candidate.formatKind === canonicalKind);\n if (selectedCandidates.length === 1) {\n next.format_ids = [{ ...selectedCandidates[0]!.ref }];\n } else {\n let resolved: V1FormatId[] | undefined;\n try {\n if (!containerOptsOutOfLegacy(pkg as CreativeFormatSelectorContainer, canonicalKind)) {\n resolved = resolveCanonicalFormatLegacyRefs(\n canonicalFormatLegacyResolver,\n {\n source: 'selector',\n selector: pkg as Record<string, unknown>,\n operation,\n field: '(package selector)',\n },\n true\n );\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical format legacy resolver returned an invalid or ambiguous package mapping'\n );\n }\n if (resolved) {\n next.format_ids = resolved;\n } else {\n throw new CreativeFormatProjectionError(\n operation,\n '(package selector)',\n 'canonical package format_kind has no unambiguous legacy representation; select a format_option_ref from the product before delivery'\n );\n }\n }\n }\n delete next.format_kind;\n delete next.params;\n }\n\n return next;\n}\n\nfunction canonicalizeCreative<T extends Record<string, unknown>>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n operation: string,\n legacyFormatConverter?: LegacyFormatConverter\n): T {\n const creativeId = typeof creative.creative_id === 'string' ? creative.creative_id : '(unknown)';\n const hasCanonicalKind = typeof creative.format_kind === 'string';\n if (hasCanonicalKind && creative.format_id !== undefined) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative must not declare both canonical format_kind and legacy format_id'\n );\n }\n if (hasCanonicalKind && creative.format_id === undefined) {\n if (!CANONICAL_FORMAT_KINDS.has(creative.format_kind as CanonicalFormatKind)) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `unknown canonical format_kind ${creative.format_kind}`\n );\n }\n const creativeOptionRef = optionReference(creative.format_option_ref);\n const selectedRefs = selectedOptionReferences(selectorContainer);\n if (\n creativeOptionRef &&\n selectedRefs.length > 0 &&\n !selectedRefs.some(ref => sameOptionReference(ref, creativeOptionRef))\n ) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative format_option_ref conflicts with the package selected format_option_refs'\n );\n }\n return creative;\n }\n const existing = legacyRef(creative.format_id);\n if (!existing) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'creative must identify its format canonically with format_kind'\n );\n }\n\n const matchingCandidates = candidatesFromContainer(selectorContainer).filter(\n candidate =>\n sameLegacyIdentity(candidate.ref, existing) &&\n (existing.width === undefined || candidate.ref.width === existing.width) &&\n (existing.height === undefined || candidate.ref.height === existing.height) &&\n (existing.duration_ms === undefined || candidate.ref.duration_ms === existing.duration_ms)\n );\n if (matchingCandidates.length === 1 && matchingCandidates[0]!.formatKind) {\n const candidate = matchingCandidates[0]!;\n const next: Record<string, unknown> = { ...creative, format_kind: candidate.formatKind };\n delete next.format_id;\n if (candidate.formatOptionRef) next.format_option_ref = candidate.formatOptionRef;\n if (candidate.formatKind === 'custom' && !candidate.formatOptionRef) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'custom product format must provide format_option_id so the canonical creative retains a concrete identity'\n );\n }\n return next as T;\n }\n const selectorCandidates = candidatesFromContainer(selectorContainer);\n if (selectorCandidates.length > 0 && matchingCandidates.length !== 1) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n matchingCandidates.length === 0\n ? 'legacy format reference conflicts with the selected seller format identity or constraints'\n : 'legacy format reference is ambiguous within the selected seller format options'\n );\n }\n\n const { v2, diagnostics } = projectV1ProductToV2(\n {\n product_id: `<creative:${creativeId}>`,\n name: creativeId,\n description: 'legacy creative normalization',\n format_ids: [existing],\n },\n { legacyFormatConverter }\n );\n const declaration = v2.format_options[0];\n if (!declaration) {\n const diagnostic = diagnostics[0];\n const failure =\n diagnostic?.code === 'FORMAT_PROJECTION_FAILED' ? diagnostic.error.details.resolution_failure : undefined;\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `legacy creative format has no canonical conversion${failure ? ` (${failure})` : ''}`\n );\n }\n const next: Record<string, unknown> = { ...creative, format_kind: declaration.format_kind };\n delete next.format_id;\n const candidateOptionRef =\n matchingCandidates.length === 1 && matchingCandidates[0]!.formatKind === declaration.format_kind\n ? matchingCandidates[0]!.formatOptionRef\n : undefined;\n const convertedOptionRef = optionReference(declaration) ?? candidateOptionRef;\n if (convertedOptionRef) next.format_option_ref = convertedOptionRef;\n if (declaration.format_kind === 'custom' && !convertedOptionRef) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'custom legacy conversion must provide format_option_id so the canonical creative retains a concrete identity'\n );\n }\n return next as T;\n}\n\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode?: 'canonical',\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: 'legacy' | 'unknown',\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): LegacyProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: CreativeFormatWireMode,\n operation?: string,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T> | LegacyProjectedCreative<T>;\nexport function projectCreativeForDelivery<T extends CreativeAsset>(\n creative: T,\n selectorContainer: CreativeFormatSelectorContainer,\n wireMode: CreativeFormatWireMode = 'canonical',\n operation = 'creative_delivery',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): CanonicalProjectedCreative<T> | LegacyProjectedCreative<T> {\n const inputRecord = creative as unknown as Record<string, unknown>;\n const originalLegacyRef = legacyRef(inputRecord.format_id);\n const creativeRecord = canonicalizeCreative(inputRecord, selectorContainer, operation, legacyFormatConverter);\n if (wireMode === 'canonical') return creativeRecord as unknown as CanonicalProjectedCreative<T>;\n if (originalLegacyRef) {\n const selectedOriginal = selectLegacyRef(inputRecord, selectorContainer, canonicalFormatLegacyResolver, operation);\n if (selectedOriginal) {\n return projectCreative(creativeRecord, selectedOriginal) as unknown as LegacyProjectedCreative<T>;\n }\n throw new CreativeFormatProjectionError(\n operation,\n typeof inputRecord.creative_id === 'string' ? inputRecord.creative_id : '(unknown)',\n 'the original legacy format reference conflicts with the selected seller format identity or constraints'\n );\n }\n const formatId = selectLegacyRef(creativeRecord, selectorContainer, canonicalFormatLegacyResolver, operation);\n if (formatId) return projectCreative(creativeRecord, formatId) as unknown as LegacyProjectedCreative<T>;\n\n if (typeof creativeRecord.format_kind === 'string') {\n const creativeId = typeof creativeRecord.creative_id === 'string' ? creativeRecord.creative_id : '(unknown)';\n const allCandidates = candidatesFromContainer(selectorContainer, canonicalFormatLegacyResolver, operation);\n let candidates = allCandidates.filter(candidate => candidate.formatKind === creativeRecord.format_kind);\n const constrained = candidates.filter(candidate => refMatchesParams(candidate.ref, selectorContainer.params));\n if (constrained.length > 0) candidates = constrained;\n let resolved: V1FormatId[] | undefined;\n try {\n if (\n !containerOptsOutOfLegacy(\n selectorContainer,\n creativeRecord.format_kind,\n optionReference(creativeRecord.format_option_ref)\n )\n ) {\n resolved = resolveCanonicalFormatLegacyRefs(\n canonicalFormatLegacyResolver,\n {\n source: 'creative',\n creative: creativeRecord,\n selector: selectorContainer as Record<string, unknown>,\n operation,\n field: creativeId,\n },\n true\n );\n }\n } catch (error) {\n if (!(error instanceof CanonicalFormatLegacyResolutionError)) throw error;\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n 'canonical format legacy resolver returned an invalid or ambiguous creative mapping'\n );\n }\n if (resolved) return projectCreative(creativeRecord, resolved[0]!) as unknown as LegacyProjectedCreative<T>;\n if (candidates.length > 1) {\n throw new CreativeFormatProjectionError(\n operation,\n creativeId,\n `the seller advertised ${candidates.length} legacy refs for canonical kind ${creativeRecord.format_kind}`\n );\n }\n const reason = 'the selected seller product did not provide one unambiguous legacy format reference';\n throw new CreativeFormatProjectionError(operation, creativeId, reason);\n }\n return creative as unknown as LegacyProjectedCreative<T>;\n}\n\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: 'canonical',\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: 'legacy' | 'unknown',\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: CreativeFormatWireMode,\n operation?: 'create_media_buy' | 'update_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'> | ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\nexport function projectMediaBuyCreativesForDelivery<T>(\n request: T,\n wireMode: CreativeFormatWireMode = 'canonical',\n operation: 'create_media_buy' | 'update_media_buy' = 'create_media_buy',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedMediaBuyCreativeRequest<T, 'canonical'> | ProjectedMediaBuyCreativeRequest<T, 'legacy'> {\n const requestRecord = record(request);\n if (!requestRecord) return request as ProjectedMediaBuyCreativeRequest<T, 'canonical'>;\n let changed = false;\n const next = { ...requestRecord };\n for (const key of ['packages', 'new_packages'] as const) {\n const packages = requestRecord[key];\n if (!Array.isArray(packages)) continue;\n next[key] = packages.map(packageValue => {\n const pkg = record(packageValue);\n if (!pkg) return packageValue;\n const creatives = Array.isArray(pkg.creatives)\n ? pkg.creatives.map(creativeValue => {\n const creative = record(creativeValue);\n if (!creative) return creativeValue;\n const projected = projectCreativeForDelivery(\n creative as unknown as CreativeAsset,\n pkg as CreativeFormatSelectorContainer,\n wireMode,\n operation,\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projected !== creativeValue) changed = true;\n return projected;\n })\n : undefined;\n const projectedPackage = projectPackageSelectors(\n pkg,\n wireMode,\n operation,\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projectedPackage !== packageValue) changed = true;\n return creatives ? { ...projectedPackage, creatives } : projectedPackage;\n });\n }\n return (changed ? next : request) as\n | ProjectedMediaBuyCreativeRequest<T, 'canonical'>\n | ProjectedMediaBuyCreativeRequest<T, 'legacy'>;\n}\n\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: 'canonical',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: 'legacy' | 'unknown',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'legacy'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: CreativeFormatWireMode,\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'> | ProjectedSyncCreativeRequest<T, 'legacy'>;\nexport function projectSyncCreativesForDelivery<T>(\n request: T,\n selectorContainers: ReadonlyArray<CreativeFormatSelectorContainer>,\n wireMode: CreativeFormatWireMode = 'canonical',\n legacyFormatConverter?: LegacyFormatConverter,\n canonicalFormatLegacyResolver?: CanonicalFormatLegacyResolver\n): ProjectedSyncCreativeRequest<T, 'canonical'> | ProjectedSyncCreativeRequest<T, 'legacy'> {\n const requestRecord = record(request);\n if (!requestRecord || !Array.isArray(requestRecord.creatives)) {\n return request as ProjectedSyncCreativeRequest<T, 'canonical'>;\n }\n const assignments = Array.isArray(requestRecord.assignments) ? requestRecord.assignments : [];\n let changed = false;\n const creatives = requestRecord.creatives.map(creativeValue => {\n const creative = record(creativeValue);\n if (!creative) return creativeValue;\n const assignedPackageIds = new Set(\n assignments.flatMap(assignmentValue => {\n const assignment = record(assignmentValue);\n if (!assignment || assignment.creative_id !== creative.creative_id) return [];\n return typeof assignment.package_id === 'string' ? [assignment.package_id] : [];\n })\n );\n const relevant =\n assignedPackageIds.size === 0\n ? selectorContainers\n : selectorContainers.filter(\n container => typeof container.package_id === 'string' && assignedPackageIds.has(container.package_id)\n );\n const combined: CreativeFormatSelectorContainer = {\n selector_containers: relevant,\n };\n const projected = projectCreativeForDelivery(\n creative as unknown as CreativeAsset,\n combined,\n wireMode,\n 'sync_creatives',\n legacyFormatConverter,\n canonicalFormatLegacyResolver\n );\n if (projected !== creativeValue) changed = true;\n return projected;\n });\n return (changed ? { ...requestRecord, creatives } : request) as\n | ProjectedSyncCreativeRequest<T, 'canonical'>\n | ProjectedSyncCreativeRequest<T, 'legacy'>;\n}\n\ntype CreativeProtocolRelease = { major: number; minor: number; label: string };\n\nfunction release(value: unknown): CreativeProtocolRelease | undefined {\n if (typeof value !== 'string') return undefined;\n const match = /^v?(\\d+)\\.(\\d+)(?:\\.|-|$)/.exec(value.trim());\n return match ? { major: Number(match[1]), minor: Number(match[2]), label: value } : undefined;\n}\n\nfunction mutuallyServedRelease(\n caps: Record<string, unknown> | undefined,\n raw: Record<string, unknown> | undefined,\n requestedVersion: string | undefined\n): CreativeProtocolRelease | undefined {\n const requested = release(requestedVersion);\n if (!requested) return undefined;\n const normalizedSupported = Array.isArray(caps?.supportedVersions) ? caps.supportedVersions : [];\n const directSupported = record(caps?.adcp)?.supported_versions;\n const rawSupported = record(raw?.adcp)?.supported_versions;\n const advertisedValues = [\n ...normalizedSupported,\n ...(Array.isArray(directSupported) ? directSupported : []),\n ...(Array.isArray(rawSupported) ? rawSupported : []),\n ];\n const advertised = advertisedValues.flatMap(value => {\n const parsed = release(value);\n return parsed ? [parsed] : [];\n });\n if (advertisedValues.length > 0 && advertised.length === 0) {\n throw new CreativeFormatCapabilityError(\n 'Seller advertised supported AdCP versions, but none were valid release identifiers'\n );\n }\n if (advertised.length === 0) {\n // A buyer pin is an upper bound, not evidence that the seller serves the\n // same release. Legacy 3.0 sellers commonly omit supported_versions; that\n // omission must not turn a 3.2 buyer pin into a false canonical guarantee.\n return requested.major < 3 || (requested.major === 3 && requested.minor === 0) ? requested : undefined;\n }\n const mutuallyServed = advertised\n .filter(\n candidate =>\n candidate.major === requested.major &&\n (candidate.minor < requested.minor || candidate.minor === requested.minor)\n )\n .sort((left, right) => right.minor - left.minor)[0];\n if (!mutuallyServed) {\n const supported = [...new Set(advertised.map(candidate => candidate.label))].join(', ');\n throw new CreativeFormatCapabilityError(\n `No mutually supported AdCP release: client requested ${requestedVersion}, seller advertised ${supported}`\n );\n }\n return mutuallyServed;\n}\n\nexport function resolveCreativeFormatWireMode(\n capabilities: unknown,\n negotiatedVersion?: string\n): CreativeFormatWireMode {\n const caps = record(capabilities);\n const raw = record(caps?._raw);\n const features = record(caps?.features);\n const mediaBuyFeatures = record(record(caps?.media_buy)?.features);\n const rawMediaBuyFeatures = record(record(raw?.media_buy)?.features);\n const declarations = [\n features?.canonicalCreatives,\n mediaBuyFeatures?.canonical_creatives,\n rawMediaBuyFeatures?.canonical_creatives,\n ].filter((value): value is boolean => typeof value === 'boolean');\n if (declarations.includes(true) && declarations.includes(false)) {\n throw new CreativeFormatCapabilityError(\n 'Seller capability response contains conflicting canonical_creatives declarations'\n );\n }\n const explicitCanonical = declarations[0];\n // `supported_versions` is the seller's wire-release contract. A newer\n // buyer can be downshifted within the same major, so a 3.2 client talking\n // to a 3.1-only seller must apply the 3.1 feature semantics rather than\n // assuming the 3.2 canonical guarantee. `build_version` is intentionally\n // absent here: the capability schema marks it advisory-only.\n const negotiated = mutuallyServedRelease(caps, raw, negotiatedVersion);\n if (caps?.version === 'v2') return 'legacy';\n if (negotiated && (negotiated.major > 3 || (negotiated.major === 3 && negotiated.minor >= 2))) {\n if (explicitCanonical === false) {\n throw new CreativeFormatCapabilityError(\n `AdCP ${negotiated.label} guarantees canonical creatives, but the seller advertised canonical_creatives: false`\n );\n }\n return 'canonical';\n }\n if (negotiated && (negotiated.major < 3 || (negotiated.major === 3 && negotiated.minor === 0))) {\n return 'legacy';\n }\n if (!caps) return 'unknown';\n if (explicitCanonical === true) return 'canonical';\n if (explicitCanonical === false) return 'legacy';\n return 'unknown';\n}\n"],"mappings":"AAuBA,SAAS,sBAAsB,kCAAkC;AAEjE,SAAS,sCAAsC,wCAAwC;AAGvF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAoHA,SAAS,4BAA+B,OAAwC;AACrF,QAAM,eAAe,oBAAI,IAAY;AACrC,QAAM,kBAAkB,oBAAI,IAAY;AACxC,QAAM,iBAAiB,oBAAI,IAAY;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,sBAAsB,CAAC,QAC3B,QAAQ,cAAc,0CAA0C,KAAK,GAAG;AAC1E,QAAM,eAAe,CAAC,OAAgC,QAAyB;AAC7E,UAAM,aAAa,OAAO,yBAAyB,OAAO,GAAG;AAC7D,WAAO,cAAc,WAAW,aAAa,WAAW,QAAQ;AAAA,EAClE;AACA,QAAM,0BAA0B,CAAC,QAC/B,OAAO,QAAQ,YACf,CAAC,uCAAuC,KAAK,GAAG,KAChD,iDAAiD,KAAK,GAAG;AAC3D,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AAQ,KAAM,WAAW,UAAU,KAAK,WAAW,SAAS,IAAK;AAC7F,QAAI,sBAAsB,OAAO;AAC/B,YAAM,IAAI;AAAA,QACR,QAAQ,WAAW,KAAK;AAAA,MAC1B;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACA,MAAI,eAAe,WAAW,QAAQ,KAAM,WAAW,UAAU,KAAK,WAAW,UAAU,IAAK;AAC9F,WAAO;AAAA,EACT;AACA,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,sBAAsB,KAAM,QAAO;AACvC,MAAI,sBAAsB,MAAO,QAAO;AACxC,SAAO;AACT;","names":["value","result","needsSafeToJSON","changed","safe","next"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * AdCP SDK library version
3
3
  */
4
- export declare const LIBRARY_VERSION = "13.0.0-rc.21";
4
+ export declare const LIBRARY_VERSION = "13.0.0-rc.22";
5
5
  /**
6
6
  * AdCP specification version this library is built for
7
7
  */
@@ -33,10 +33,10 @@ export type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];
33
33
  * Full version information
34
34
  */
35
35
  export declare const VERSION_INFO: {
36
- readonly library: "13.0.0-rc.21";
36
+ readonly library: "13.0.0-rc.22";
37
37
  readonly adcp: "3.1.13";
38
38
  readonly compatibleVersions: readonly ["v2.5", "v2.6", "v3", "3.0.0-beta.1", "3.0-beta.1", "3.0-beta", "3.0.0-beta.3", "3.0-beta.3", "3.0.0", "3.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4", "3.0.5", "3.0.6", "3.0.7", "3.0.8", "3.0.9", "3.0.10", "3.0.11", "3.0.12", "3.1.0", "3.1", "3.1.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", "3.1.9", "3.1.10", "3.1.11", "3.1.12", "3.1.13"];
39
- readonly generatedAt: "2026-08-14T13:07:22.553Z";
39
+ readonly generatedAt: "2026-08-15T13:32:14.193Z";
40
40
  };
41
41
  /**
42
42
  * Get the AdCP specification version this library is built for
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * AdCP SDK library version
3
3
  */
4
- export declare const LIBRARY_VERSION = "13.0.0-rc.21";
4
+ export declare const LIBRARY_VERSION = "13.0.0-rc.22";
5
5
  /**
6
6
  * AdCP specification version this library is built for
7
7
  */
@@ -33,10 +33,10 @@ export type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];
33
33
  * Full version information
34
34
  */
35
35
  export declare const VERSION_INFO: {
36
- readonly library: "13.0.0-rc.21";
36
+ readonly library: "13.0.0-rc.22";
37
37
  readonly adcp: "3.1.13";
38
38
  readonly compatibleVersions: readonly ["v2.5", "v2.6", "v3", "3.0.0-beta.1", "3.0-beta.1", "3.0-beta", "3.0.0-beta.3", "3.0-beta.3", "3.0.0", "3.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4", "3.0.5", "3.0.6", "3.0.7", "3.0.8", "3.0.9", "3.0.10", "3.0.11", "3.0.12", "3.1.0", "3.1", "3.1.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", "3.1.9", "3.1.10", "3.1.11", "3.1.12", "3.1.13"];
39
- readonly generatedAt: "2026-08-14T13:07:22.553Z";
39
+ readonly generatedAt: "2026-08-15T13:32:14.193Z";
40
40
  };
41
41
  /**
42
42
  * Get the AdCP specification version this library is built for
@@ -31,7 +31,7 @@ __export(version_exports, {
31
31
  toReleasePrecisionVersion: () => toReleasePrecisionVersion
32
32
  });
33
33
  module.exports = __toCommonJS(version_exports);
34
- const LIBRARY_VERSION = "13.0.0-rc.21";
34
+ const LIBRARY_VERSION = "13.0.0-rc.22";
35
35
  const ADCP_VERSION = "3.1.13";
36
36
  const ADCP_MAJOR_VERSION = 3;
37
37
  const COMPATIBLE_ADCP_VERSIONS = [
@@ -74,10 +74,10 @@ const COMPATIBLE_ADCP_VERSIONS = [
74
74
  "3.1.13"
75
75
  ];
76
76
  const VERSION_INFO = {
77
- library: "13.0.0-rc.21",
77
+ library: "13.0.0-rc.22",
78
78
  adcp: "3.1.13",
79
79
  compatibleVersions: COMPATIBLE_ADCP_VERSIONS,
80
- generatedAt: "2026-08-14T13:07:22.553Z"
80
+ generatedAt: "2026-08-15T13:32:14.193Z"
81
81
  };
82
82
  function getAdcpVersion() {
83
83
  return ADCP_VERSION;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/version.ts"],"sourcesContent":["// Generated version information\n// This file is auto-generated by sync-version.ts\n\n/**\n * AdCP SDK library version\n */\nexport const LIBRARY_VERSION = '13.0.0-rc.21';\n\n/**\n * AdCP specification version this library is built for\n */\nexport const ADCP_VERSION = '3.1.13';\n\n/**\n * AdCP major version sent with every request (adcp_major_version field).\n * Sellers validate this against their supported versions and return\n * VERSION_UNSUPPORTED if the version is not in range.\n */\nexport const ADCP_MAJOR_VERSION = 3;\n\n/**\n * AdCP versions this library maintains backward compatibility with.\n *\n * Auto-derived from `ADCP_VERSION` by scripts/sync-version.ts. Do not edit\n * this list by hand; bumping the AdCP pin via `npm run sync-version`\n * extends it.\n */\nexport const COMPATIBLE_ADCP_VERSIONS = [\n 'v2.5',\n 'v2.6',\n 'v3',\n '3.0.0-beta.1',\n '3.0-beta.1',\n '3.0-beta',\n '3.0.0-beta.3',\n '3.0-beta.3',\n '3.0.0',\n '3.0',\n '3.0.1',\n '3.0.2',\n '3.0.3',\n '3.0.4',\n '3.0.5',\n '3.0.6',\n '3.0.7',\n '3.0.8',\n '3.0.9',\n '3.0.10',\n '3.0.11',\n '3.0.12',\n '3.1.0',\n '3.1',\n '3.1.1',\n '3.1.2',\n '3.1.3',\n '3.1.4',\n '3.1.5',\n '3.1.6',\n '3.1.7',\n '3.1.8',\n '3.1.9',\n '3.1.10',\n '3.1.11',\n '3.1.12',\n '3.1.13',\n] as const;\n\n/**\n * String literal union of every AdCP version the SDK formally supports.\n *\n * Used by the per-instance `adcpVersion` constructor option to give callers\n * autocomplete in editors. The intersection with `(string & {})` in the\n * config type preserves the escape hatch — any string is still accepted at\n * the type level — while the literal union surfaces canonical values first.\n */\nexport type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];\n\n/**\n * Full version information\n */\nexport const VERSION_INFO = {\n library: '13.0.0-rc.21',\n adcp: '3.1.13',\n compatibleVersions: COMPATIBLE_ADCP_VERSIONS,\n generatedAt: '2026-08-14T13:07:22.553Z',\n} as const;\n\n/**\n * Get the AdCP specification version this library is built for\n */\nexport function getAdcpVersion(): string {\n return ADCP_VERSION;\n}\n\n/**\n * Get the library version\n */\nexport function getLibraryVersion(): string {\n return LIBRARY_VERSION;\n}\n\n/**\n * Check if this library version is compatible with a given AdCP version\n */\nexport function isCompatibleWith(adcpVersion: string): boolean {\n return (COMPATIBLE_ADCP_VERSIONS as readonly string[]).includes(adcpVersion);\n}\n\n/**\n * Get all AdCP versions this library is compatible with\n */\nexport function getCompatibleVersions(): readonly string[] {\n return COMPATIBLE_ADCP_VERSIONS;\n}\n\n/**\n * Extract the major version number from an AdCP version string.\n *\n * Accepts:\n * - Semver: '3.0.0', '3.0.1', '3.1.0-beta.1' → 3\n * - Legacy aliases: 'v3' → 3, 'v2.5' / 'v2.6' → 2\n *\n * Returns NaN for unrecognized strings — callers should validate before passing.\n */\nexport function parseAdcpMajorVersion(version: string): number {\n const trimmed = version.trim();\n const semverLike = trimmed.startsWith('v') ? trimmed.slice(1) : trimmed;\n const major = parseInt(semverLike.split('.')[0] ?? '', 10);\n return Number.isFinite(major) ? major : NaN;\n}\n\n/**\n * Normalize a full-semver AdCP version (`MAJOR.MINOR.PATCH[-prerelease]`) to\n * the release-precision form that AdCP 3.1+ requires on the wire:\n * `MAJOR.MINOR[-prerelease]` — the patch digit is dropped.\n *\n * Per the spec note on `adcp_version`: \"SDKs that read full-semver values\n * from bundle metadata (e.g. `ComplianceIndex.published_version =\n * \"3.1.0-beta.1\"`) MUST normalize to release-precision (`\"3.1-beta.1\"`)\n * before emitting on the wire — meta-field values are NOT valid wire\n * values.\" The wire regex (`^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$`) rejects strings\n * with a patch digit.\n *\n * Behavior:\n * - `\"3.1.0-beta.7\"` → `\"3.1-beta.7\"`\n * - `\"3.1.0\"` → `\"3.1\"`\n * - `\"3.0.12\"` → `\"3.0\"`\n * - Already-release-precision input (`\"3.1\"`, `\"3.1-beta.7\"`) passes through\n * - Legacy aliases (`\"v2.5\"`, `\"v3\"`) pass through unchanged — the wire\n * regex doesn't accept them anyway; the v2.5 path uses\n * `adcp_major_version` instead of `adcp_version` for transport.\n * - Unrecognized strings pass through unchanged so callers can detect drift\n * via the wire validator rather than have it masked by this helper.\n */\nexport function toReleasePrecisionVersion(version: string): string {\n const trimmed = version.trim();\n // Pre-release form `MAJOR.MINOR.PATCH-prerelease` → `MAJOR.MINOR-prerelease`\n const semverMatch = trimmed.match(/^(\\d+)\\.(\\d+)\\.\\d+(-[A-Za-z0-9.-]+)?$/);\n if (semverMatch) {\n const [, major, minor, pre = ''] = semverMatch;\n return `${major}.${minor}${pre}`;\n }\n // Already release-precision (no patch digit). Includes `3.1`, `3.1-beta.7`.\n if (/^\\d+\\.\\d+(-[A-Za-z0-9.-]+)?$/.test(trimmed)) return trimmed;\n // Legacy aliases (`v3`, `v2.5`, `v2.6`) and anything we don't recognize —\n // pass through so the wire validator can flag genuine drift.\n return version;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,kBAAkB;AAKxB,MAAM,eAAe;AAOrB,MAAM,qBAAqB;AAS3B,MAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAeO,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,oBAAoB;AAAA,EACpB,aAAa;AACf;AAKO,SAAS,iBAAyB;AACvC,SAAO;AACT;AAKO,SAAS,oBAA4B;AAC1C,SAAO;AACT;AAKO,SAAS,iBAAiB,aAA8B;AAC7D,SAAQ,yBAA+C,SAAS,WAAW;AAC7E;AAKO,SAAS,wBAA2C;AACzD,SAAO;AACT;AAWO,SAAS,sBAAsB,SAAyB;AAC7D,QAAM,UAAU,QAAQ,KAAK;AAC7B,QAAM,aAAa,QAAQ,WAAW,GAAG,IAAI,QAAQ,MAAM,CAAC,IAAI;AAChE,QAAM,QAAQ,SAAS,WAAW,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE;AACzD,SAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAyBO,SAAS,0BAA0B,SAAyB;AACjE,QAAM,UAAU,QAAQ,KAAK;AAE7B,QAAM,cAAc,QAAQ,MAAM,uCAAuC;AACzE,MAAI,aAAa;AACf,UAAM,CAAC,EAAE,OAAO,OAAO,MAAM,EAAE,IAAI;AACnC,WAAO,GAAG,KAAK,IAAI,KAAK,GAAG,GAAG;AAAA,EAChC;AAEA,MAAI,+BAA+B,KAAK,OAAO,EAAG,QAAO;AAGzD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/lib/version.ts"],"sourcesContent":["// Generated version information\n// This file is auto-generated by sync-version.ts\n\n/**\n * AdCP SDK library version\n */\nexport const LIBRARY_VERSION = '13.0.0-rc.22';\n\n/**\n * AdCP specification version this library is built for\n */\nexport const ADCP_VERSION = '3.1.13';\n\n/**\n * AdCP major version sent with every request (adcp_major_version field).\n * Sellers validate this against their supported versions and return\n * VERSION_UNSUPPORTED if the version is not in range.\n */\nexport const ADCP_MAJOR_VERSION = 3;\n\n/**\n * AdCP versions this library maintains backward compatibility with.\n *\n * Auto-derived from `ADCP_VERSION` by scripts/sync-version.ts. Do not edit\n * this list by hand; bumping the AdCP pin via `npm run sync-version`\n * extends it.\n */\nexport const COMPATIBLE_ADCP_VERSIONS = [\n 'v2.5',\n 'v2.6',\n 'v3',\n '3.0.0-beta.1',\n '3.0-beta.1',\n '3.0-beta',\n '3.0.0-beta.3',\n '3.0-beta.3',\n '3.0.0',\n '3.0',\n '3.0.1',\n '3.0.2',\n '3.0.3',\n '3.0.4',\n '3.0.5',\n '3.0.6',\n '3.0.7',\n '3.0.8',\n '3.0.9',\n '3.0.10',\n '3.0.11',\n '3.0.12',\n '3.1.0',\n '3.1',\n '3.1.1',\n '3.1.2',\n '3.1.3',\n '3.1.4',\n '3.1.5',\n '3.1.6',\n '3.1.7',\n '3.1.8',\n '3.1.9',\n '3.1.10',\n '3.1.11',\n '3.1.12',\n '3.1.13',\n] as const;\n\n/**\n * String literal union of every AdCP version the SDK formally supports.\n *\n * Used by the per-instance `adcpVersion` constructor option to give callers\n * autocomplete in editors. The intersection with `(string & {})` in the\n * config type preserves the escape hatch — any string is still accepted at\n * the type level — while the literal union surfaces canonical values first.\n */\nexport type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];\n\n/**\n * Full version information\n */\nexport const VERSION_INFO = {\n library: '13.0.0-rc.22',\n adcp: '3.1.13',\n compatibleVersions: COMPATIBLE_ADCP_VERSIONS,\n generatedAt: '2026-08-15T13:32:14.193Z',\n} as const;\n\n/**\n * Get the AdCP specification version this library is built for\n */\nexport function getAdcpVersion(): string {\n return ADCP_VERSION;\n}\n\n/**\n * Get the library version\n */\nexport function getLibraryVersion(): string {\n return LIBRARY_VERSION;\n}\n\n/**\n * Check if this library version is compatible with a given AdCP version\n */\nexport function isCompatibleWith(adcpVersion: string): boolean {\n return (COMPATIBLE_ADCP_VERSIONS as readonly string[]).includes(adcpVersion);\n}\n\n/**\n * Get all AdCP versions this library is compatible with\n */\nexport function getCompatibleVersions(): readonly string[] {\n return COMPATIBLE_ADCP_VERSIONS;\n}\n\n/**\n * Extract the major version number from an AdCP version string.\n *\n * Accepts:\n * - Semver: '3.0.0', '3.0.1', '3.1.0-beta.1' → 3\n * - Legacy aliases: 'v3' → 3, 'v2.5' / 'v2.6' → 2\n *\n * Returns NaN for unrecognized strings — callers should validate before passing.\n */\nexport function parseAdcpMajorVersion(version: string): number {\n const trimmed = version.trim();\n const semverLike = trimmed.startsWith('v') ? trimmed.slice(1) : trimmed;\n const major = parseInt(semverLike.split('.')[0] ?? '', 10);\n return Number.isFinite(major) ? major : NaN;\n}\n\n/**\n * Normalize a full-semver AdCP version (`MAJOR.MINOR.PATCH[-prerelease]`) to\n * the release-precision form that AdCP 3.1+ requires on the wire:\n * `MAJOR.MINOR[-prerelease]` — the patch digit is dropped.\n *\n * Per the spec note on `adcp_version`: \"SDKs that read full-semver values\n * from bundle metadata (e.g. `ComplianceIndex.published_version =\n * \"3.1.0-beta.1\"`) MUST normalize to release-precision (`\"3.1-beta.1\"`)\n * before emitting on the wire — meta-field values are NOT valid wire\n * values.\" The wire regex (`^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$`) rejects strings\n * with a patch digit.\n *\n * Behavior:\n * - `\"3.1.0-beta.7\"` → `\"3.1-beta.7\"`\n * - `\"3.1.0\"` → `\"3.1\"`\n * - `\"3.0.12\"` → `\"3.0\"`\n * - Already-release-precision input (`\"3.1\"`, `\"3.1-beta.7\"`) passes through\n * - Legacy aliases (`\"v2.5\"`, `\"v3\"`) pass through unchanged — the wire\n * regex doesn't accept them anyway; the v2.5 path uses\n * `adcp_major_version` instead of `adcp_version` for transport.\n * - Unrecognized strings pass through unchanged so callers can detect drift\n * via the wire validator rather than have it masked by this helper.\n */\nexport function toReleasePrecisionVersion(version: string): string {\n const trimmed = version.trim();\n // Pre-release form `MAJOR.MINOR.PATCH-prerelease` → `MAJOR.MINOR-prerelease`\n const semverMatch = trimmed.match(/^(\\d+)\\.(\\d+)\\.\\d+(-[A-Za-z0-9.-]+)?$/);\n if (semverMatch) {\n const [, major, minor, pre = ''] = semverMatch;\n return `${major}.${minor}${pre}`;\n }\n // Already release-precision (no patch digit). Includes `3.1`, `3.1-beta.7`.\n if (/^\\d+\\.\\d+(-[A-Za-z0-9.-]+)?$/.test(trimmed)) return trimmed;\n // Legacy aliases (`v3`, `v2.5`, `v2.6`) and anything we don't recognize —\n // pass through so the wire validator can flag genuine drift.\n return version;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,kBAAkB;AAKxB,MAAM,eAAe;AAOrB,MAAM,qBAAqB;AAS3B,MAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAeO,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,oBAAoB;AAAA,EACpB,aAAa;AACf;AAKO,SAAS,iBAAyB;AACvC,SAAO;AACT;AAKO,SAAS,oBAA4B;AAC1C,SAAO;AACT;AAKO,SAAS,iBAAiB,aAA8B;AAC7D,SAAQ,yBAA+C,SAAS,WAAW;AAC7E;AAKO,SAAS,wBAA2C;AACzD,SAAO;AACT;AAWO,SAAS,sBAAsB,SAAyB;AAC7D,QAAM,UAAU,QAAQ,KAAK;AAC7B,QAAM,aAAa,QAAQ,WAAW,GAAG,IAAI,QAAQ,MAAM,CAAC,IAAI;AAChE,QAAM,QAAQ,SAAS,WAAW,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE;AACzD,SAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAyBO,SAAS,0BAA0B,SAAyB;AACjE,QAAM,UAAU,QAAQ,KAAK;AAE7B,QAAM,cAAc,QAAQ,MAAM,uCAAuC;AACzE,MAAI,aAAa;AACf,UAAM,CAAC,EAAE,OAAO,OAAO,MAAM,EAAE,IAAI;AACnC,WAAO,GAAG,KAAK,IAAI,KAAK,GAAG,GAAG;AAAA,EAChC;AAEA,MAAI,+BAA+B,KAAK,OAAO,EAAG,QAAO;AAGzD,SAAO;AACT;","names":[]}
@@ -1,4 +1,4 @@
1
- const LIBRARY_VERSION = "13.0.0-rc.21";
1
+ const LIBRARY_VERSION = "13.0.0-rc.22";
2
2
  const ADCP_VERSION = "3.1.13";
3
3
  const ADCP_MAJOR_VERSION = 3;
4
4
  const COMPATIBLE_ADCP_VERSIONS = [
@@ -41,10 +41,10 @@ const COMPATIBLE_ADCP_VERSIONS = [
41
41
  "3.1.13"
42
42
  ];
43
43
  const VERSION_INFO = {
44
- library: "13.0.0-rc.21",
44
+ library: "13.0.0-rc.22",
45
45
  adcp: "3.1.13",
46
46
  compatibleVersions: COMPATIBLE_ADCP_VERSIONS,
47
- generatedAt: "2026-08-14T13:07:22.553Z"
47
+ generatedAt: "2026-08-15T13:32:14.193Z"
48
48
  };
49
49
  function getAdcpVersion() {
50
50
  return ADCP_VERSION;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/version.ts"],"sourcesContent":["// Generated version information\n// This file is auto-generated by sync-version.ts\n\n/**\n * AdCP SDK library version\n */\nexport const LIBRARY_VERSION = '13.0.0-rc.21';\n\n/**\n * AdCP specification version this library is built for\n */\nexport const ADCP_VERSION = '3.1.13';\n\n/**\n * AdCP major version sent with every request (adcp_major_version field).\n * Sellers validate this against their supported versions and return\n * VERSION_UNSUPPORTED if the version is not in range.\n */\nexport const ADCP_MAJOR_VERSION = 3;\n\n/**\n * AdCP versions this library maintains backward compatibility with.\n *\n * Auto-derived from `ADCP_VERSION` by scripts/sync-version.ts. Do not edit\n * this list by hand; bumping the AdCP pin via `npm run sync-version`\n * extends it.\n */\nexport const COMPATIBLE_ADCP_VERSIONS = [\n 'v2.5',\n 'v2.6',\n 'v3',\n '3.0.0-beta.1',\n '3.0-beta.1',\n '3.0-beta',\n '3.0.0-beta.3',\n '3.0-beta.3',\n '3.0.0',\n '3.0',\n '3.0.1',\n '3.0.2',\n '3.0.3',\n '3.0.4',\n '3.0.5',\n '3.0.6',\n '3.0.7',\n '3.0.8',\n '3.0.9',\n '3.0.10',\n '3.0.11',\n '3.0.12',\n '3.1.0',\n '3.1',\n '3.1.1',\n '3.1.2',\n '3.1.3',\n '3.1.4',\n '3.1.5',\n '3.1.6',\n '3.1.7',\n '3.1.8',\n '3.1.9',\n '3.1.10',\n '3.1.11',\n '3.1.12',\n '3.1.13',\n] as const;\n\n/**\n * String literal union of every AdCP version the SDK formally supports.\n *\n * Used by the per-instance `adcpVersion` constructor option to give callers\n * autocomplete in editors. The intersection with `(string & {})` in the\n * config type preserves the escape hatch — any string is still accepted at\n * the type level — while the literal union surfaces canonical values first.\n */\nexport type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];\n\n/**\n * Full version information\n */\nexport const VERSION_INFO = {\n library: '13.0.0-rc.21',\n adcp: '3.1.13',\n compatibleVersions: COMPATIBLE_ADCP_VERSIONS,\n generatedAt: '2026-08-14T13:07:22.553Z',\n} as const;\n\n/**\n * Get the AdCP specification version this library is built for\n */\nexport function getAdcpVersion(): string {\n return ADCP_VERSION;\n}\n\n/**\n * Get the library version\n */\nexport function getLibraryVersion(): string {\n return LIBRARY_VERSION;\n}\n\n/**\n * Check if this library version is compatible with a given AdCP version\n */\nexport function isCompatibleWith(adcpVersion: string): boolean {\n return (COMPATIBLE_ADCP_VERSIONS as readonly string[]).includes(adcpVersion);\n}\n\n/**\n * Get all AdCP versions this library is compatible with\n */\nexport function getCompatibleVersions(): readonly string[] {\n return COMPATIBLE_ADCP_VERSIONS;\n}\n\n/**\n * Extract the major version number from an AdCP version string.\n *\n * Accepts:\n * - Semver: '3.0.0', '3.0.1', '3.1.0-beta.1' → 3\n * - Legacy aliases: 'v3' → 3, 'v2.5' / 'v2.6' → 2\n *\n * Returns NaN for unrecognized strings — callers should validate before passing.\n */\nexport function parseAdcpMajorVersion(version: string): number {\n const trimmed = version.trim();\n const semverLike = trimmed.startsWith('v') ? trimmed.slice(1) : trimmed;\n const major = parseInt(semverLike.split('.')[0] ?? '', 10);\n return Number.isFinite(major) ? major : NaN;\n}\n\n/**\n * Normalize a full-semver AdCP version (`MAJOR.MINOR.PATCH[-prerelease]`) to\n * the release-precision form that AdCP 3.1+ requires on the wire:\n * `MAJOR.MINOR[-prerelease]` — the patch digit is dropped.\n *\n * Per the spec note on `adcp_version`: \"SDKs that read full-semver values\n * from bundle metadata (e.g. `ComplianceIndex.published_version =\n * \"3.1.0-beta.1\"`) MUST normalize to release-precision (`\"3.1-beta.1\"`)\n * before emitting on the wire — meta-field values are NOT valid wire\n * values.\" The wire regex (`^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$`) rejects strings\n * with a patch digit.\n *\n * Behavior:\n * - `\"3.1.0-beta.7\"` → `\"3.1-beta.7\"`\n * - `\"3.1.0\"` → `\"3.1\"`\n * - `\"3.0.12\"` → `\"3.0\"`\n * - Already-release-precision input (`\"3.1\"`, `\"3.1-beta.7\"`) passes through\n * - Legacy aliases (`\"v2.5\"`, `\"v3\"`) pass through unchanged — the wire\n * regex doesn't accept them anyway; the v2.5 path uses\n * `adcp_major_version` instead of `adcp_version` for transport.\n * - Unrecognized strings pass through unchanged so callers can detect drift\n * via the wire validator rather than have it masked by this helper.\n */\nexport function toReleasePrecisionVersion(version: string): string {\n const trimmed = version.trim();\n // Pre-release form `MAJOR.MINOR.PATCH-prerelease` → `MAJOR.MINOR-prerelease`\n const semverMatch = trimmed.match(/^(\\d+)\\.(\\d+)\\.\\d+(-[A-Za-z0-9.-]+)?$/);\n if (semverMatch) {\n const [, major, minor, pre = ''] = semverMatch;\n return `${major}.${minor}${pre}`;\n }\n // Already release-precision (no patch digit). Includes `3.1`, `3.1-beta.7`.\n if (/^\\d+\\.\\d+(-[A-Za-z0-9.-]+)?$/.test(trimmed)) return trimmed;\n // Legacy aliases (`v3`, `v2.5`, `v2.6`) and anything we don't recognize —\n // pass through so the wire validator can flag genuine drift.\n return version;\n}\n"],"mappings":"AAMO,MAAM,kBAAkB;AAKxB,MAAM,eAAe;AAOrB,MAAM,qBAAqB;AAS3B,MAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAeO,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,oBAAoB;AAAA,EACpB,aAAa;AACf;AAKO,SAAS,iBAAyB;AACvC,SAAO;AACT;AAKO,SAAS,oBAA4B;AAC1C,SAAO;AACT;AAKO,SAAS,iBAAiB,aAA8B;AAC7D,SAAQ,yBAA+C,SAAS,WAAW;AAC7E;AAKO,SAAS,wBAA2C;AACzD,SAAO;AACT;AAWO,SAAS,sBAAsB,SAAyB;AAC7D,QAAM,UAAU,QAAQ,KAAK;AAC7B,QAAM,aAAa,QAAQ,WAAW,GAAG,IAAI,QAAQ,MAAM,CAAC,IAAI;AAChE,QAAM,QAAQ,SAAS,WAAW,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE;AACzD,SAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAyBO,SAAS,0BAA0B,SAAyB;AACjE,QAAM,UAAU,QAAQ,KAAK;AAE7B,QAAM,cAAc,QAAQ,MAAM,uCAAuC;AACzE,MAAI,aAAa;AACf,UAAM,CAAC,EAAE,OAAO,OAAO,MAAM,EAAE,IAAI;AACnC,WAAO,GAAG,KAAK,IAAI,KAAK,GAAG,GAAG;AAAA,EAChC;AAEA,MAAI,+BAA+B,KAAK,OAAO,EAAG,QAAO;AAGzD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/lib/version.ts"],"sourcesContent":["// Generated version information\n// This file is auto-generated by sync-version.ts\n\n/**\n * AdCP SDK library version\n */\nexport const LIBRARY_VERSION = '13.0.0-rc.22';\n\n/**\n * AdCP specification version this library is built for\n */\nexport const ADCP_VERSION = '3.1.13';\n\n/**\n * AdCP major version sent with every request (adcp_major_version field).\n * Sellers validate this against their supported versions and return\n * VERSION_UNSUPPORTED if the version is not in range.\n */\nexport const ADCP_MAJOR_VERSION = 3;\n\n/**\n * AdCP versions this library maintains backward compatibility with.\n *\n * Auto-derived from `ADCP_VERSION` by scripts/sync-version.ts. Do not edit\n * this list by hand; bumping the AdCP pin via `npm run sync-version`\n * extends it.\n */\nexport const COMPATIBLE_ADCP_VERSIONS = [\n 'v2.5',\n 'v2.6',\n 'v3',\n '3.0.0-beta.1',\n '3.0-beta.1',\n '3.0-beta',\n '3.0.0-beta.3',\n '3.0-beta.3',\n '3.0.0',\n '3.0',\n '3.0.1',\n '3.0.2',\n '3.0.3',\n '3.0.4',\n '3.0.5',\n '3.0.6',\n '3.0.7',\n '3.0.8',\n '3.0.9',\n '3.0.10',\n '3.0.11',\n '3.0.12',\n '3.1.0',\n '3.1',\n '3.1.1',\n '3.1.2',\n '3.1.3',\n '3.1.4',\n '3.1.5',\n '3.1.6',\n '3.1.7',\n '3.1.8',\n '3.1.9',\n '3.1.10',\n '3.1.11',\n '3.1.12',\n '3.1.13',\n] as const;\n\n/**\n * String literal union of every AdCP version the SDK formally supports.\n *\n * Used by the per-instance `adcpVersion` constructor option to give callers\n * autocomplete in editors. The intersection with `(string & {})` in the\n * config type preserves the escape hatch — any string is still accepted at\n * the type level — while the literal union surfaces canonical values first.\n */\nexport type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];\n\n/**\n * Full version information\n */\nexport const VERSION_INFO = {\n library: '13.0.0-rc.22',\n adcp: '3.1.13',\n compatibleVersions: COMPATIBLE_ADCP_VERSIONS,\n generatedAt: '2026-08-15T13:32:14.193Z',\n} as const;\n\n/**\n * Get the AdCP specification version this library is built for\n */\nexport function getAdcpVersion(): string {\n return ADCP_VERSION;\n}\n\n/**\n * Get the library version\n */\nexport function getLibraryVersion(): string {\n return LIBRARY_VERSION;\n}\n\n/**\n * Check if this library version is compatible with a given AdCP version\n */\nexport function isCompatibleWith(adcpVersion: string): boolean {\n return (COMPATIBLE_ADCP_VERSIONS as readonly string[]).includes(adcpVersion);\n}\n\n/**\n * Get all AdCP versions this library is compatible with\n */\nexport function getCompatibleVersions(): readonly string[] {\n return COMPATIBLE_ADCP_VERSIONS;\n}\n\n/**\n * Extract the major version number from an AdCP version string.\n *\n * Accepts:\n * - Semver: '3.0.0', '3.0.1', '3.1.0-beta.1' → 3\n * - Legacy aliases: 'v3' → 3, 'v2.5' / 'v2.6' → 2\n *\n * Returns NaN for unrecognized strings — callers should validate before passing.\n */\nexport function parseAdcpMajorVersion(version: string): number {\n const trimmed = version.trim();\n const semverLike = trimmed.startsWith('v') ? trimmed.slice(1) : trimmed;\n const major = parseInt(semverLike.split('.')[0] ?? '', 10);\n return Number.isFinite(major) ? major : NaN;\n}\n\n/**\n * Normalize a full-semver AdCP version (`MAJOR.MINOR.PATCH[-prerelease]`) to\n * the release-precision form that AdCP 3.1+ requires on the wire:\n * `MAJOR.MINOR[-prerelease]` — the patch digit is dropped.\n *\n * Per the spec note on `adcp_version`: \"SDKs that read full-semver values\n * from bundle metadata (e.g. `ComplianceIndex.published_version =\n * \"3.1.0-beta.1\"`) MUST normalize to release-precision (`\"3.1-beta.1\"`)\n * before emitting on the wire — meta-field values are NOT valid wire\n * values.\" The wire regex (`^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$`) rejects strings\n * with a patch digit.\n *\n * Behavior:\n * - `\"3.1.0-beta.7\"` → `\"3.1-beta.7\"`\n * - `\"3.1.0\"` → `\"3.1\"`\n * - `\"3.0.12\"` → `\"3.0\"`\n * - Already-release-precision input (`\"3.1\"`, `\"3.1-beta.7\"`) passes through\n * - Legacy aliases (`\"v2.5\"`, `\"v3\"`) pass through unchanged — the wire\n * regex doesn't accept them anyway; the v2.5 path uses\n * `adcp_major_version` instead of `adcp_version` for transport.\n * - Unrecognized strings pass through unchanged so callers can detect drift\n * via the wire validator rather than have it masked by this helper.\n */\nexport function toReleasePrecisionVersion(version: string): string {\n const trimmed = version.trim();\n // Pre-release form `MAJOR.MINOR.PATCH-prerelease` → `MAJOR.MINOR-prerelease`\n const semverMatch = trimmed.match(/^(\\d+)\\.(\\d+)\\.\\d+(-[A-Za-z0-9.-]+)?$/);\n if (semverMatch) {\n const [, major, minor, pre = ''] = semverMatch;\n return `${major}.${minor}${pre}`;\n }\n // Already release-precision (no patch digit). Includes `3.1`, `3.1-beta.7`.\n if (/^\\d+\\.\\d+(-[A-Za-z0-9.-]+)?$/.test(trimmed)) return trimmed;\n // Legacy aliases (`v3`, `v2.5`, `v2.6`) and anything we don't recognize —\n // pass through so the wire validator can fl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AAO,GAAG,KAAK,IAAI,KAAK,GAAG,GAAG;AAAA,EAChC;AAEA,MAAI,+BAA+B,KAAK,OAAO,EAAG,QAAO;AAGzD,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adcp/sdk",
3
- "version": "13.0.0-rc.21",
3
+ "version": "13.0.0-rc.22",
4
4
  "description": "AdCP SDK — client, server, and compliance harnesses for the AdContext Protocol (MCP + A2A)",
5
5
  "workspaces": [
6
6
  ".",