Repository navigation
feat(types): TypeScript codegen for AdCP v2.5 wire shape - #1134
Merged
Merged
Conversation
Adds @adcp/sdk/types/v2-5 — request/response interfaces for every tool in the v2.5 schema bundle (13 tools across media-buy, creative, signals protocols). Foundation for the adapter-registry refactor where adapter signatures become (V3Request) => V25Request and wire-format bugs become TypeScript errors instead of runtime warnings. scripts/generate-v2-5-types.ts compiles every v2.5 tool as a single mega-schema with shared `definitions` and runs json-schema-to-typescript once. The mega-schema approach naturally deduplicates shared types (BrandID, FormatID, AssetContentType, etc) instead of producing per-tool copies that collide at the type level — what tripped up the first attempt with per-tool compilation. Output: src/lib/types/v2-5/tools.generated.ts (4226 LOC, 164 exports, clean tsc check). Checked in alongside src/lib/types/tools.generated.ts for v3. CI's "Validate generated files in sync" step runs both v3 and v2.5 generation, so a forgotten regeneration after a schema refresh fails the build. scripts/generate-types.ts: enforceStrictSchema is now exported so the v2.5 generator can apply the same JSON-Schema preprocessing (strip additionalProperties:true, drop if/then/else conditionals, recurse into combinators). No v3 behavior change. package.json: - exports./types/v2-5 → dist/lib/types/v2-5/index - typesVersions entry for ./types/v2-5 - generate-types:v2.5 + generate-types:all umbrella ci.yml: validate-step now also runs generate-types:v2.5 and diffs the v2-5 directory. Test: dist artifacts present, declarations include all 13 tools' request/response, package.json exports the path. 5555 lib tests pass / 7 pre-existing skipped / 0 fail. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
| }, | ||
| }; | ||
|
|
||
| async function compileSchema(name: string, schema: any): Promise<string> { |
| * multi-line union types (`export type Foo =\n | 'a'\n | 'b';`) that | ||
| * have no braces but span many lines. | ||
| */ | ||
| function dedupeExports(allCode: string): string { |
The warn-only post-adapter v2.5 validation pass shipped in #1121 ran on every v2-detected request but its drift entries had nowhere to go — SingleAgentClient call sites passed no debugLogs array, so the warning silently dropped on the floor. Adapter regressions could land in production unnoticed until a v2 seller reported a wire-shape rejection. Both executeAndHandle and executeTask now collect drift into a local array, then merge into result.debug_logs after executor.executeTask returns. Adopters reading result.debug_logs see post-adapter v2.5 warnings alongside the executor's own logs, so a malformed adapted shape becomes a debuggable signal instead of an invisible bug. No public API change — executor.validateAdaptedRequestAgainstV2 already accepted an optional debugLogs parameter; only the call sites changed. End-to-end test verifies sync_creatives (known-drift, #1116) emits a warning entry for v2-detected agents, clean payloads emit nothing, and v3-detected agents never trigger the v2.5 pass. Closes the observability hole deferred in the v2.5 foundation PR. Lays groundwork for the broader compatibility-matrix work that needs reliable drift signal across version pairs. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 1, 2026
Merged
json-schema-to-typescript emits Foo, Foo1, Foo2 when the same enum or type is referenced from multiple places. Reuse the existing removeNumberedTypeDuplicates pass from generate-types.ts so v2.5 ships a single canonical export per concept. 32 numbered duplicates collapse — FormatID11 and friends are gone, and the generated bundle drops ~570 lines of redundant declarations. Two distinct degenerate fillers (UpdateMediaBuyRequest1 + ProvidePerformanceFeedbackRequest1) survive because their bodies are genuinely different from the canonical name; the dedupe pass correctly preserves them rather than silently merging incompatible types. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
@adcp/sdk/types/v2-5— request/response interfaces for every tool in the v2.5 schema bundle (13 tools across media-buy, creative, signals protocols). Foundation for the upcoming adapter-registry refactor where adapter signatures become(V3Request) => V25Requestand wire-format bugs become TypeScript errors instead of runtime warnings.Why
After the foundation PRs (#1121, #1123, #1133) landed, the v2.5 schemas were runtime-loadable for AJV validation but had no compile-time presence. Adapter functions like
adaptCreateMediaBuyRequestForV2still takeanyand returnany. The buyer_ref bug (#1115) that we fixed was a runtime warning catch — TypeScript couldn't have caught it because there was noV25CreateMediaBuyRequesttype to match against.This PR adds that type surface. The next PR (adapter-registry refactor) will retype the adapter functions to use it.
How
scripts/generate-v2-5-types.tscompiles every v2.5 tool as a single mega-schema with shareddefinitionsand runsjson-schema-to-typescriptonce. The mega-schema approach naturally deduplicates shared types (BrandID,FormatID,AssetContentType, etc.) instead of producing per-tool copies that collide at the type level — what tripped up the first attempt with per-tool compilation.Output:
src/lib/types/v2-5/tools.generated.ts(4226 LOC, 164 exports, cleantsccheck). Checked in alongsidesrc/lib/types/tools.generated.tsfor v3.Pipeline integration
package.json:./types/v2-5export entry,typesVersionsmapping,generate-types:v2.5+generate-types:allumbrella scripts..github/workflows/ci.yml: "Validate generated files in sync" now runsgenerate-types:v2.5too. Forgotten regen after a schema refresh fails the build.scripts/generate-types.ts:enforceStrictSchemais now exported so the v2.5 generator can apply the same JSON-Schema preprocessing (stripadditionalProperties: true, dropif/then/elseconditionals, recurse into combinators). No v3 behavior change.Consumer surface
13 tools × 2 (request, response) = 26 entry-point types, plus the per-tool sub-types (e.g.
CreateMediaBuySuccess,CreateMediaBuyError).Test plan
npm run generate-types:v2.5— produces stable, deterministic outputnpx tsc --noEmiton the generated file — cleantest/lib/v2-5-types-import.test.js— 3/3 pass: dist artifacts present, declarations include all 13 tool pairs,package.jsonexports./types/v2-5npm run test:lib— 5555 pass / 7 pre-existing skipped / 0 failnpm run typecheck— cleanCompatibility
Patch-level + new export entry. No existing import path changes. Adopters who don't
importfrom./types/v2-5see no diff.Related
(V3Request) => V25Request), v2 adapter: flatten v3 manifest to v2.5 single-asset payload in adaptSyncCreativesRequestForV2 #1116 sync-creatives manifest flatten, compat-matrix playbook🤖 Generated with Claude Code