Skip to content

feat(types): export BrandJson / AdagentsJson from public surface#1740

Merged
bokelley merged 3 commits into
mainfrom
bokelley/export-brand-adagents-types
May 14, 2026
Merged

feat(types): export BrandJson / AdagentsJson from public surface#1740
bokelley merged 3 commits into
mainfrom
bokelley/export-brand-adagents-types

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

The wellknown-schemas.generated.ts module already emits these inferred types from the canonical Zod schemas, but every public entry point omitted them. Consumers wanting a typed brand.json shape had to either deep-import dist/lib/types/wellknown-schemas.generated (fragile across SDK versions) or hand-roll an interface that drifts from the spec — exactly what bit adcontextprotocol/adcp#4512, where a pre-unify BrandDefinition snapshot was missing 13+ fields added by the schema unify commit, causing /api/brands/resolve to return an empty brand_manifest.

With this PR, server code can derive its types directly from the spec:

import type { BrandJson } from '@adcp/sdk';
type BrandJsonHousePortfolio = Extract<BrandJson, { brands: unknown[] }>;
export type BrandDefinition = BrandJsonHousePortfolio['brands'][number];

Test plan

  • npm run build succeeds; dist/lib/types/index.d.ts now contains export type { BrandJson, AdagentsJson } and the two schema re-exports.
  • npx tsc --noEmit clean.
  • npm run format:check clean.
  • CI green on changeset check + build + tests.

🤖 Generated with Claude Code

bokelley and others added 3 commits May 14, 2026 04:09
The `wellknown-schemas.generated.ts` module emits inferred types from the
canonical Zod schemas for brand.json and adagents.json, but those exports
were unreachable from any public entry point — adopters had to deep-import
a `dist/` path or hand-roll interfaces that drift from the spec (which is
exactly what bit adcp#4512: a pre-unify `BrandDefinition` snapshot missed
13+ fields added by the schema bump).

Re-export `BrandJson`, `AdagentsJson`, `BrandJsonSchema`, `AdagentsJsonSchema`
from `src/lib/types/index.ts` so consumers can derive their server-side
types directly from the schema:

  import type { BrandJson } from '@adcp/sdk';
  type BrandJsonHousePortfolio = Extract<BrandJson, { brands: unknown[] }>;
  type BrandDefinition = BrandJsonHousePortfolio['brands'][number];

Closes #1739.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per dx-expert review of #1740: the BrandJson union is a common foot-gun
(adopters assume `.brands` exists unconditionally — it's only one of three
union arms). A short worked example in the curated TYPE-SUMMARY makes the
discriminant key visible and shows the `Extract<BrandJson, ...>` recipe
for narrowing to the portfolio shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
docs/TYPE-SUMMARY.md is regenerated by scripts/generate-agent-docs.ts on
every CI run; manually appended content gets wiped. Move the Well-Known
Files section (added in b78b173 for #1740 / closes #1739) into the
generator so it survives regeneration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit 2a265bb into main May 14, 2026
10 checks passed
@bokelley bokelley deleted the bokelley/export-brand-adagents-types branch May 14, 2026 08:27
bokelley added a commit that referenced this pull request May 17, 2026
…#1798)

The wellknown-schemas.generated.ts module emits BrandJson / AdagentsJson
(inferred types) and BrandJsonSchema / AdagentsJsonSchema (runtime Zod
validators) for the brand.json and adagents.json well-known formats, but
at 7.1.0-7.2.0 those exports were unreachable from `@adcp/sdk` — only
`@adcp/sdk/types` and `@adcp/sdk/testing` carried them. Consumers doing
`import type { BrandJson } from '@adcp/sdk'` (e.g. adcontextprotocol/adcp
server/src/types.ts:1, see adcp#4604) failed with `TS2305: Module
'"@adcp/sdk"' has no exported member 'BrandJson'`.

#1740 fixed this in src/lib/types/index.ts (the sub-barrel) and the main
barrel picks it up transitively via `export * from './types'`. This change
pins the contract explicitly at src/lib/index.ts so it is visible at the
top-level public API surface and not dependent on the sub-barrel's
wildcard re-export, plus adds a smoke test asserting both the runtime
exports and the .d.ts type declarations resolve from dist/lib/index.{js,d.ts}.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot mentioned this pull request May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export BrandJson / AdagentsJson types from @adcp/sdk public surface

1 participant