feat: flatten 7 discovery builders to kwargs; delete 10 *Input wrappers + convert 6 nested types to TypedDicts - #38
Merged
Conversation
Flattens the 7 discovery builders:
- build_well_known_x402(BuildWellKnownX402Input(resources=[WellKnownX402Resource(...)]))
→ build_well_known_x402(*, resources: list[WellKnownX402Resource])
(WellKnownX402Resource is now a TypedDict)
- build_well_known_mpp(WellKnownMppInput(...))
→ build_well_known_mpp(*, name, url, endpoints, purchase, ...)
(PaymentMethodConfig stays — carries nested compliance/x402 shape)
- build_bazaar_discovery_payload(BazaarDiscoveryConfig(...))
→ build_bazaar_discovery_payload(*, body_type=None, input=None, output=None, extra=None)
- build_discovery_probe_response(DiscoveryProbeOptions(...))
→ build_discovery_probe_response(*, realm, sample_rail, sample_amount_usd, sample_recipient, ...)
- llms_txt_identity_section(LlmsTxtIdentitySectionInput(...))
→ llms_txt_identity_section(*, agentscore=False, compliance=None)
- llms_txt_payment_section(LlmsTxtPaymentSectionInput(...))
→ llms_txt_payment_section(*, rails, app_url, verbose=False, ...)
- build_llms_txt(BuildLlmsTxtInput(...))
→ build_llms_txt(*, merchant_name, sections=None, tagline=None, agentscore_identity=None, payment=None)
(LlmsTxtSection becomes a TypedDict; agentscore_identity/payment are dict forwards to the section helpers)
- x_payment_info_extension(XPaymentInfoInput(price=..., protocols=...))
→ x_payment_info_extension(*, price, protocols)
- agentscore_openapi_snippets(BuildAgentScoreOpenApiSnippetsInput(...))
→ agentscore_openapi_snippets(*, security=True, denials=True, payment_required=True)
- build_skill_md(BuildSkillMdInput(...))
→ build_skill_md(*, name, description, homepage, ...) — 23 flat kwargs
(Internal _SkillCtx aggregates so 11 private section helpers stay typed; nested
SkillMdEndpoint/SkillMdLink/SkillMdIdentityRequirements/SkillMdShippingPolicy
become TypedDicts so callers stop double-wrapping.)
Deleted from exports: BuildWellKnownX402Input, WellKnownMppInput,
BazaarDiscoveryConfig, DiscoveryProbeOptions, LlmsTxtIdentitySectionInput,
LlmsTxtPaymentSectionInput, BuildLlmsTxtInput, XPaymentInfoInput,
BuildAgentScoreOpenApiSnippetsInput, BuildSkillMdInput.
Kept (data shapes consumers construct): PaymentMethodConfig, X402SampleProbe,
XPaymentInfoFixedPrice, XPaymentInfoDynamicPrice, XPaymentInfoMpp,
DiscoveryProbeResponse, LlmsTxtSection (TypedDict),
SkillMdEndpoint/SkillMdLink/SkillMdIdentityRequirements/SkillMdShippingPolicy
(TypedDicts), WellKnownX402Resource (TypedDict).
Tests: 1033 passed / 3 skipped, 95.02% coverage. ty + ruff + vulture
(modulo known false positives) clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Biggest single PR in the train. Flattens the 7 discovery builders and replaces their wrapper-constructor pattern with plain kwargs. Nested types (endpoint / link / identity / shipping rows) convert from
@dataclasstoTypedDictso callers stop wrapping rows that were really just dict-shaped data.build_well_known_x402(BuildWellKnownX402Input(resources=...))build_well_known_x402(*, resources)build_well_known_mpp(WellKnownMppInput(...))build_well_known_mpp(*, name, url, endpoints, purchase, ...)build_bazaar_discovery_payload(BazaarDiscoveryConfig(...))build_bazaar_discovery_payload(*, body_type, input, output, extra)build_discovery_probe_response(DiscoveryProbeOptions(...))build_discovery_probe_response(*, realm, sample_rail, ...)llms_txt_identity_section(LlmsTxtIdentitySectionInput(...))llms_txt_identity_section(*, agentscore=False, compliance=None)llms_txt_payment_section(LlmsTxtPaymentSectionInput(...))llms_txt_payment_section(*, rails, app_url, verbose=False, ...)build_llms_txt(BuildLlmsTxtInput(...))build_llms_txt(*, merchant_name, sections=None, ...)x_payment_info_extension(XPaymentInfoInput(price=..., protocols=...))x_payment_info_extension(*, price, protocols)agentscore_openapi_snippets(BuildAgentScoreOpenApiSnippetsInput(...))agentscore_openapi_snippets(*, security=True, denials=True, payment_required=True)build_skill_md(BuildSkillMdInput(...))build_skill_md(*, name, description, homepage, …)— 23 flat kwargsInternal note:
_SkillCtxbuild_skill_mdhas 11 private_section(input)helpers. To keep their signatures unchanged without ballooning the diff, the public surface flattens to kwargs but the function internally constructs a frozen_SkillCtxdataclass that gets passed to each helper. Public API is fully flat; private helpers stay focused.Deleted from exports
BuildWellKnownX402Input,WellKnownMppInput,BazaarDiscoveryConfig,DiscoveryProbeOptions,LlmsTxtIdentitySectionInput,LlmsTxtPaymentSectionInput,BuildLlmsTxtInput,XPaymentInfoInput,BuildAgentScoreOpenApiSnippetsInput,BuildSkillMdInput.Nested types converted to TypedDicts
LlmsTxtSection,WellKnownX402Resource,SkillMdEndpoint,SkillMdLink,SkillMdIdentityRequirements,SkillMdShippingPolicy. Consumers continue calling them by name with kwargs (TypedDict supports the same call shape), but they no longer need an extra import + constructor.Kept
PaymentMethodConfig(real nested compliance/x402 shape),X402SampleProbe,XPaymentInfoFixedPrice,XPaymentInfoDynamicPrice,XPaymentInfoMpp,DiscoveryProbeResponse.Test plan
uv run pytest tests/— 1033 passed / 3 skipped, 95.02% coverageuv run ty check agentscore_commerce/— cleanuv run ruff check . && uv run ruff format .— cleanuv run vulture agentscore_commerce/ --min-confidence 80— only known false positives remain