@adcp/sdk 8.1.0-beta.13 → 8.1.0-beta.14
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.
- package/README.md +1 -1
- package/bin/adcp-registry.js +2 -2
- package/dist/lib/canonical-references/index.d.ts +107 -0
- package/dist/lib/canonical-references/index.d.ts.map +1 -0
- package/dist/lib/canonical-references/index.js +551 -0
- package/dist/lib/canonical-references/index.js.map +1 -0
- package/dist/lib/core/ConversationTypes.d.ts +7 -0
- package/dist/lib/core/ConversationTypes.d.ts.map +1 -1
- package/dist/lib/core/ProtocolResponseParser.d.ts +10 -0
- package/dist/lib/core/ProtocolResponseParser.d.ts.map +1 -1
- package/dist/lib/core/ProtocolResponseParser.js +110 -0
- package/dist/lib/core/ProtocolResponseParser.js.map +1 -1
- package/dist/lib/core/ResponseValidator.d.ts +2 -0
- package/dist/lib/core/ResponseValidator.d.ts.map +1 -1
- package/dist/lib/core/ResponseValidator.js +3 -3
- package/dist/lib/core/ResponseValidator.js.map +1 -1
- package/dist/lib/core/TaskExecutor.d.ts +2 -0
- package/dist/lib/core/TaskExecutor.d.ts.map +1 -1
- package/dist/lib/core/TaskExecutor.js +32 -8
- package/dist/lib/core/TaskExecutor.js.map +1 -1
- package/dist/lib/index.d.ts +5 -4
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +27 -11
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/mock-server/creative-ad-server/server.d.ts +2 -0
- package/dist/lib/mock-server/creative-ad-server/server.d.ts.map +1 -1
- package/dist/lib/mock-server/creative-ad-server/server.js +37 -1
- package/dist/lib/mock-server/creative-ad-server/server.js.map +1 -1
- package/dist/lib/mock-server/creative-template/server.d.ts +2 -0
- package/dist/lib/mock-server/creative-template/server.d.ts.map +1 -1
- package/dist/lib/mock-server/creative-template/server.js +29 -2
- package/dist/lib/mock-server/creative-template/server.js.map +1 -1
- package/dist/lib/mock-server/index.d.ts +10 -1
- package/dist/lib/mock-server/index.d.ts.map +1 -1
- package/dist/lib/mock-server/index.js +38 -8
- package/dist/lib/mock-server/index.js.map +1 -1
- package/dist/lib/mock-server/sales-guaranteed/server.d.ts +2 -0
- package/dist/lib/mock-server/sales-guaranteed/server.d.ts.map +1 -1
- package/dist/lib/mock-server/sales-guaranteed/server.js +64 -7
- package/dist/lib/mock-server/sales-guaranteed/server.js.map +1 -1
- package/dist/lib/mock-server/sales-non-guaranteed/server.d.ts +2 -0
- package/dist/lib/mock-server/sales-non-guaranteed/server.d.ts.map +1 -1
- package/dist/lib/mock-server/sales-non-guaranteed/server.js +44 -1
- package/dist/lib/mock-server/sales-non-guaranteed/server.js.map +1 -1
- package/dist/lib/mock-server/sales-social/server.d.ts +2 -0
- package/dist/lib/mock-server/sales-social/server.d.ts.map +1 -1
- package/dist/lib/mock-server/sales-social/server.js +64 -4
- package/dist/lib/mock-server/sales-social/server.js.map +1 -1
- package/dist/lib/mock-server/scenario.d.ts +97 -0
- package/dist/lib/mock-server/scenario.d.ts.map +1 -0
- package/dist/lib/mock-server/scenario.js +464 -0
- package/dist/lib/mock-server/scenario.js.map +1 -0
- package/dist/lib/mock-server/signal-marketplace/server.d.ts +2 -0
- package/dist/lib/mock-server/signal-marketplace/server.d.ts.map +1 -1
- package/dist/lib/mock-server/signal-marketplace/server.js +29 -1
- package/dist/lib/mock-server/signal-marketplace/server.js.map +1 -1
- package/dist/lib/mock-server/sponsored-intelligence/server.d.ts +2 -0
- package/dist/lib/mock-server/sponsored-intelligence/server.d.ts.map +1 -1
- package/dist/lib/mock-server/sponsored-intelligence/server.js +47 -9
- package/dist/lib/mock-server/sponsored-intelligence/server.js.map +1 -1
- package/dist/lib/protocols/index.d.ts +4 -2
- package/dist/lib/protocols/index.d.ts.map +1 -1
- package/dist/lib/protocols/index.js +10 -3
- package/dist/lib/protocols/index.js.map +1 -1
- package/dist/lib/registry/index.d.ts +42 -16
- package/dist/lib/registry/index.d.ts.map +1 -1
- package/dist/lib/registry/index.js +191 -24
- package/dist/lib/registry/index.js.map +1 -1
- package/dist/lib/registry/types.d.ts +39 -8
- package/dist/lib/registry/types.d.ts.map +1 -1
- package/dist/lib/registry/types.generated.d.ts +2873 -699
- package/dist/lib/registry/types.generated.d.ts.map +1 -1
- package/dist/lib/registry/types.generated.js +2 -2
- package/dist/lib/registry/types.generated.js.map +1 -1
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/a2a-adapter.d.ts +3 -1
- package/dist/lib/server/a2a-adapter.d.ts.map +1 -1
- package/dist/lib/server/a2a-adapter.js +11 -2
- package/dist/lib/server/a2a-adapter.js.map +1 -1
- package/dist/lib/server/adcp-server.js +32 -0
- package/dist/lib/server/adcp-server.js.map +1 -1
- package/dist/lib/server/create-adcp-server.d.ts +12 -6
- package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
- package/dist/lib/server/create-adcp-server.js +72 -11
- package/dist/lib/server/create-adcp-server.js.map +1 -1
- package/dist/lib/server/decisioning/account.d.ts +17 -17
- package/dist/lib/server/decisioning/account.d.ts.map +1 -1
- package/dist/lib/server/decisioning/account.js.map +1 -1
- package/dist/lib/server/decisioning/buyer-agent.d.ts +27 -10
- package/dist/lib/server/decisioning/buyer-agent.d.ts.map +1 -1
- package/dist/lib/server/decisioning/buyer-agent.js +25 -7
- package/dist/lib/server/decisioning/buyer-agent.js.map +1 -1
- package/dist/lib/server/decisioning/capabilities.d.ts +35 -7
- package/dist/lib/server/decisioning/capabilities.d.ts.map +1 -1
- package/dist/lib/server/decisioning/errors-typed.d.ts +18 -16
- package/dist/lib/server/decisioning/errors-typed.d.ts.map +1 -1
- package/dist/lib/server/decisioning/errors-typed.js +26 -24
- package/dist/lib/server/decisioning/errors-typed.js.map +1 -1
- package/dist/lib/server/decisioning/index.d.ts +1 -1
- package/dist/lib/server/decisioning/index.d.ts.map +1 -1
- package/dist/lib/server/decisioning/index.js +4 -2
- package/dist/lib/server/decisioning/index.js.map +1 -1
- package/dist/lib/server/decisioning/platform-helpers.d.ts +3 -2
- package/dist/lib/server/decisioning/platform-helpers.d.ts.map +1 -1
- package/dist/lib/server/decisioning/platform-helpers.js +3 -2
- package/dist/lib/server/decisioning/platform-helpers.js.map +1 -1
- package/dist/lib/server/decisioning/platform.d.ts +27 -10
- package/dist/lib/server/decisioning/platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts +14 -10
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.js +374 -59
- package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/validate-platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/validate-platform.js +3 -8
- package/dist/lib/server/decisioning/runtime/validate-platform.js.map +1 -1
- package/dist/lib/server/decisioning/specialisms/sponsored-intelligence.d.ts +9 -11
- package/dist/lib/server/decisioning/specialisms/sponsored-intelligence.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/sponsored-intelligence.js +9 -11
- package/dist/lib/server/decisioning/specialisms/sponsored-intelligence.js.map +1 -1
- package/dist/lib/server/operational-platform.d.ts +6 -8
- package/dist/lib/server/operational-platform.d.ts.map +1 -1
- package/dist/lib/server/operational-platform.js +4 -6
- package/dist/lib/server/operational-platform.js.map +1 -1
- package/dist/lib/server/test-controller-bridge.d.ts +14 -14
- package/dist/lib/server/test-controller-bridge.d.ts.map +1 -1
- package/dist/lib/server/test-controller-bridge.js +16 -16
- package/dist/lib/server/test-controller-bridge.js.map +1 -1
- package/dist/lib/server/test-controller.d.ts +31 -9
- package/dist/lib/server/test-controller.d.ts.map +1 -1
- package/dist/lib/server/test-controller.js +106 -54
- package/dist/lib/server/test-controller.js.map +1 -1
- package/dist/lib/signing/canonicalize.d.ts +0 -53
- package/dist/lib/signing/canonicalize.d.ts.map +1 -1
- package/dist/lib/signing/canonicalize.js +1 -33
- package/dist/lib/signing/canonicalize.js.map +1 -1
- package/dist/lib/signing/client.d.ts +5 -5
- package/dist/lib/signing/client.d.ts.map +1 -1
- package/dist/lib/signing/client.js +1 -10
- package/dist/lib/signing/client.js.map +1 -1
- package/dist/lib/signing/errors.d.ts +0 -11
- package/dist/lib/signing/errors.d.ts.map +1 -1
- package/dist/lib/signing/errors.js +1 -11
- package/dist/lib/signing/errors.js.map +1 -1
- package/dist/lib/signing/jwks-helpers.d.ts +2 -4
- package/dist/lib/signing/jwks-helpers.d.ts.map +1 -1
- package/dist/lib/signing/jwks-helpers.js +9 -0
- package/dist/lib/signing/jwks-helpers.js.map +1 -1
- package/dist/lib/signing/provider.d.ts +11 -10
- package/dist/lib/signing/provider.d.ts.map +1 -1
- package/dist/lib/signing/request-context.d.ts +8 -11
- package/dist/lib/signing/request-context.d.ts.map +1 -1
- package/dist/lib/signing/request-context.js +7 -10
- package/dist/lib/signing/request-context.js.map +1 -1
- package/dist/lib/signing/server.d.ts +3 -4
- package/dist/lib/signing/server.d.ts.map +1 -1
- package/dist/lib/signing/server.js +1 -9
- package/dist/lib/signing/server.js.map +1 -1
- package/dist/lib/signing/signer-async.d.ts +2 -8
- package/dist/lib/signing/signer-async.d.ts.map +1 -1
- package/dist/lib/signing/signer-async.js +0 -12
- package/dist/lib/signing/signer-async.js.map +1 -1
- package/dist/lib/signing/signer.d.ts +4 -111
- package/dist/lib/signing/signer.d.ts.map +1 -1
- package/dist/lib/signing/signer.js +2 -98
- package/dist/lib/signing/signer.js.map +1 -1
- package/dist/lib/signing/testing.d.ts +10 -10
- package/dist/lib/signing/testing.d.ts.map +1 -1
- package/dist/lib/signing/testing.js +6 -13
- package/dist/lib/signing/testing.js.map +1 -1
- package/dist/lib/signing/types.d.ts +0 -36
- package/dist/lib/signing/types.d.ts.map +1 -1
- package/dist/lib/signing/types.js +1 -37
- package/dist/lib/signing/types.js.map +1 -1
- package/dist/lib/testing/agent-tester.d.ts +1 -0
- package/dist/lib/testing/agent-tester.d.ts.map +1 -1
- package/dist/lib/testing/agent-tester.js.map +1 -1
- package/dist/lib/testing/client.d.ts +1 -1
- package/dist/lib/testing/client.d.ts.map +1 -1
- package/dist/lib/testing/client.js +4 -2
- package/dist/lib/testing/client.js.map +1 -1
- package/dist/lib/testing/compliance/comply.d.ts +8 -0
- package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
- package/dist/lib/testing/compliance/comply.js +98 -7
- package/dist/lib/testing/compliance/comply.js.map +1 -1
- package/dist/lib/testing/compliance/spec-conformance.d.ts +6 -6
- package/dist/lib/testing/compliance/spec-conformance.d.ts.map +1 -1
- package/dist/lib/testing/compliance/spec-conformance.js +6 -6
- package/dist/lib/testing/compliance/spec-conformance.js.map +1 -1
- package/dist/lib/testing/compliance/summary.d.ts +5 -0
- package/dist/lib/testing/compliance/summary.d.ts.map +1 -1
- package/dist/lib/testing/compliance/summary.js +17 -0
- package/dist/lib/testing/compliance/summary.js.map +1 -1
- package/dist/lib/testing/comply-controller.d.ts +19 -0
- package/dist/lib/testing/comply-controller.d.ts.map +1 -1
- package/dist/lib/testing/comply-controller.js +11 -8
- package/dist/lib/testing/comply-controller.js.map +1 -1
- package/dist/lib/testing/index.d.ts +4 -3
- package/dist/lib/testing/index.d.ts.map +1 -1
- package/dist/lib/testing/index.js +13 -1
- package/dist/lib/testing/index.js.map +1 -1
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.d.ts +4 -0
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.d.ts.map +1 -0
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.js +881 -0
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.js.map +1 -0
- package/dist/lib/testing/storyboard/compliance.d.ts +6 -0
- package/dist/lib/testing/storyboard/compliance.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/compliance.js +8 -4
- package/dist/lib/testing/storyboard/compliance.js.map +1 -1
- package/dist/lib/testing/storyboard/index.d.ts +2 -1
- package/dist/lib/testing/storyboard/index.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/index.js +9 -1
- package/dist/lib/testing/storyboard/index.js.map +1 -1
- package/dist/lib/testing/storyboard/loader.d.ts +3 -2
- package/dist/lib/testing/storyboard/loader.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/loader.js +73 -2
- package/dist/lib/testing/storyboard/loader.js.map +1 -1
- package/dist/lib/testing/storyboard/path.d.ts +21 -0
- package/dist/lib/testing/storyboard/path.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/path.js +86 -0
- package/dist/lib/testing/storyboard/path.js.map +1 -1
- package/dist/lib/testing/storyboard/rate-limit-trip.d.ts +92 -0
- package/dist/lib/testing/storyboard/rate-limit-trip.d.ts.map +1 -0
- package/dist/lib/testing/storyboard/rate-limit-trip.js +276 -0
- package/dist/lib/testing/storyboard/rate-limit-trip.js.map +1 -0
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +361 -28
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/testing/storyboard/seeding.d.ts +5 -4
- package/dist/lib/testing/storyboard/seeding.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/seeding.js +23 -3
- package/dist/lib/testing/storyboard/seeding.js.map +1 -1
- package/dist/lib/testing/storyboard/types.d.ts +108 -20
- package/dist/lib/testing/storyboard/types.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/types.js +1 -0
- package/dist/lib/testing/storyboard/types.js.map +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +18 -0
- package/dist/lib/testing/storyboard/validations.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/validations.js +238 -33
- package/dist/lib/testing/storyboard/validations.js.map +1 -1
- package/dist/lib/testing/test-controller.d.ts +17 -25
- package/dist/lib/testing/test-controller.d.ts.map +1 -1
- package/dist/lib/testing/test-controller.js.map +1 -1
- package/dist/lib/testing/types.d.ts +13 -1
- package/dist/lib/testing/types.d.ts.map +1 -1
- package/dist/lib/types/check-governance.d.ts +1 -1
- package/dist/lib/types/comply-test-controller.d.ts +243 -3
- package/dist/lib/types/core.generated.d.ts +261 -21
- package/dist/lib/types/core.generated.d.ts.map +1 -1
- package/dist/lib/types/core.generated.js +1 -1
- package/dist/lib/types/create-media-buy.d.ts +107 -3
- package/dist/lib/types/error-codes.d.ts +2 -2
- package/dist/lib/types/get-adcp-capabilities.d.ts +1 -1
- package/dist/lib/types/get-media-buys.d.ts +107 -3
- package/dist/lib/types/get-plan-audit-logs.d.ts +1 -1
- package/dist/lib/types/get-products.d.ts +104 -3
- package/dist/lib/types/inline-enums.generated.d.ts +27 -17
- package/dist/lib/types/inline-enums.generated.d.ts.map +1 -1
- package/dist/lib/types/inline-enums.generated.js +39 -28
- package/dist/lib/types/inline-enums.generated.js.map +1 -1
- package/dist/lib/types/manifest.generated.d.ts +7 -4
- package/dist/lib/types/manifest.generated.d.ts.map +1 -1
- package/dist/lib/types/manifest.generated.js +2 -2
- package/dist/lib/types/manifest.generated.js.map +1 -1
- package/dist/lib/types/report-plan-outcome.d.ts +1 -1
- package/dist/lib/types/schemas.generated.d.ts +714 -193
- package/dist/lib/types/schemas.generated.d.ts.map +1 -1
- package/dist/lib/types/schemas.generated.js +194 -79
- package/dist/lib/types/schemas.generated.js.map +1 -1
- package/dist/lib/types/sync-plans.d.ts +1 -1
- package/dist/lib/types/tools.generated.d.ts +331 -28
- package/dist/lib/types/tools.generated.d.ts.map +1 -1
- package/dist/lib/types/update-media-buy.d.ts +107 -3
- package/dist/lib/types/v3-1-beta/tools.generated.d.ts +20 -0
- package/dist/lib/types/v3-1-beta/tools.generated.d.ts.map +1 -1
- package/dist/lib/upstream-recorder/constants.d.ts +2 -0
- package/dist/lib/upstream-recorder/constants.d.ts.map +1 -0
- package/dist/lib/upstream-recorder/constants.js +5 -0
- package/dist/lib/upstream-recorder/constants.js.map +1 -0
- package/dist/lib/upstream-recorder/index.d.ts +20 -10
- package/dist/lib/upstream-recorder/index.d.ts.map +1 -1
- package/dist/lib/upstream-recorder/index.js +21 -10
- package/dist/lib/upstream-recorder/index.js.map +1 -1
- package/dist/lib/upstream-recorder/recorder.d.ts +65 -0
- package/dist/lib/upstream-recorder/recorder.d.ts.map +1 -1
- package/dist/lib/upstream-recorder/recorder.js +500 -47
- package/dist/lib/upstream-recorder/recorder.js.map +1 -1
- package/dist/lib/upstream-recorder/types.d.ts +109 -13
- package/dist/lib/upstream-recorder/types.d.ts.map +1 -1
- package/dist/lib/upstream-recorder/types.js.map +1 -1
- package/dist/lib/utils/adcp-version-config.d.ts +1 -0
- package/dist/lib/utils/adcp-version-config.d.ts.map +1 -1
- package/dist/lib/utils/adcp-version-config.js +21 -0
- package/dist/lib/utils/adcp-version-config.js.map +1 -1
- package/dist/lib/utils/capability-rollups.d.ts +5 -5
- package/dist/lib/utils/capability-rollups.d.ts.map +1 -1
- package/dist/lib/utils/capability-rollups.js +1 -1
- package/dist/lib/utils/capability-rollups.js.map +1 -1
- package/dist/lib/utils/json-depth.d.ts +2 -0
- package/dist/lib/utils/json-depth.d.ts.map +1 -0
- package/dist/lib/utils/json-depth.js +5 -0
- package/dist/lib/utils/json-depth.js.map +1 -0
- package/dist/lib/utils/media-buy-delivery-notification-builders.d.ts +1 -1
- package/dist/lib/utils/media-buy-delivery-notification-builders.d.ts.map +1 -1
- package/dist/lib/utils/preview-creative-builders.d.ts +1 -1
- package/dist/lib/utils/preview-creative-builders.d.ts.map +1 -1
- package/dist/lib/utils/redact-secrets.d.ts +13 -2
- package/dist/lib/utils/redact-secrets.d.ts.map +1 -1
- package/dist/lib/utils/redact-secrets.js +40 -13
- package/dist/lib/utils/redact-secrets.js.map +1 -1
- package/dist/lib/utils/response-schemas.d.ts +1 -0
- package/dist/lib/utils/response-schemas.d.ts.map +1 -1
- package/dist/lib/utils/response-schemas.js +15 -0
- package/dist/lib/utils/response-schemas.js.map +1 -1
- package/dist/lib/utils/response-unwrapper.d.ts +2 -1
- package/dist/lib/utils/response-unwrapper.d.ts.map +1 -1
- package/dist/lib/utils/response-unwrapper.js +11 -3
- package/dist/lib/utils/response-unwrapper.js.map +1 -1
- package/dist/lib/utils/tool-request-schemas.d.ts +31 -1
- package/dist/lib/utils/tool-request-schemas.d.ts.map +1 -1
- package/dist/lib/v2/format-schema/fetch.d.ts +13 -5
- package/dist/lib/v2/format-schema/fetch.d.ts.map +1 -1
- package/dist/lib/v2/format-schema/fetch.js +27 -16
- package/dist/lib/v2/format-schema/fetch.js.map +1 -1
- package/dist/lib/v2/format-schema/index.d.ts +13 -11
- package/dist/lib/v2/format-schema/index.d.ts.map +1 -1
- package/dist/lib/v2/format-schema/index.js +19 -12
- package/dist/lib/v2/format-schema/index.js.map +1 -1
- package/dist/lib/v2/format-schema/resolver.d.ts +71 -0
- package/dist/lib/v2/format-schema/resolver.d.ts.map +1 -0
- package/dist/lib/v2/format-schema/resolver.js +284 -0
- package/dist/lib/v2/format-schema/resolver.js.map +1 -0
- package/dist/lib/v2/format-schema/sandbox-refs.d.ts +6 -0
- package/dist/lib/v2/format-schema/sandbox-refs.d.ts.map +1 -1
- package/dist/lib/v2/format-schema/sandbox-refs.js +36 -15
- package/dist/lib/v2/format-schema/sandbox-refs.js.map +1 -1
- package/dist/lib/validation/schema-loader.d.ts.map +1 -1
- package/dist/lib/validation/schema-loader.js +48 -3
- package/dist/lib/validation/schema-loader.js.map +1 -1
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/docs/guides/BUILD-AN-AGENT.md +7 -7
- package/docs/guides/CANONICAL-REFERENCE-RESOLVER.md +75 -0
- package/docs/llms.txt +37 -8
- package/examples/README.md +29 -16
- package/examples/hello_creative_adapter_ad_server.ts +8 -2
- package/examples/hello_seller_adapter_guaranteed.ts +26 -18
- package/examples/hello_seller_adapter_multi_tenant.ts +6 -6
- package/examples/hello_seller_adapter_social.ts +80 -4
- package/examples/hello_si_adapter_brand.ts +10 -21
- package/examples/hello_signals_adapter_marketplace.ts +184 -9
- package/examples/proxy-seller-snap/README.md +47 -0
- package/examples/proxy-seller-snap/index.ts +321 -0
- package/package.json +19 -4
- package/skills/build-creative-agent/SKILL.md +1 -15
- package/skills/build-decisioning-platform/SKILL.md +6 -1
- package/skills/build-seller-agent/SKILL.md +5 -2
- package/skills/build-si-agent/SKILL.md +2 -2
- package/skills/call-adcp-agent/SKILL.md +4 -1
- package/dist/lib/signing/response-verifier.d.ts +0 -105
- package/dist/lib/signing/response-verifier.d.ts.map +0 -1
- package/dist/lib/signing/response-verifier.js +0 -271
- package/dist/lib/signing/response-verifier.js.map +0 -1
|
@@ -55,10 +55,13 @@ exports.createAdcpServerFromPlatform = createAdcpServerFromPlatform;
|
|
|
55
55
|
exports._resetMergeSeamDedupe = _resetMergeSeamDedupe;
|
|
56
56
|
exports.getAllAdcpMigrations = getAllAdcpMigrations;
|
|
57
57
|
const node_crypto_1 = require("node:crypto");
|
|
58
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
58
59
|
const create_adcp_server_1 = require("../../create-adcp-server");
|
|
59
60
|
const account_1 = require("../account");
|
|
61
|
+
const buyer_agent_1 = require("../buyer-agent");
|
|
60
62
|
const async_outcome_1 = require("../async-outcome");
|
|
61
63
|
const proposal_1 = require("../proposal");
|
|
64
|
+
const capability_rollups_1 = require("../../../utils/capability-rollups");
|
|
62
65
|
const errors_1 = require("../../errors");
|
|
63
66
|
const validate_platform_1 = require("./validate-platform");
|
|
64
67
|
const validate_specialisms_1 = require("../validate-specialisms");
|
|
@@ -92,9 +95,9 @@ const comply_controller_1 = require("../../../testing/comply-controller");
|
|
|
92
95
|
const seed_merge_1 = require("../../../testing/seed-merge");
|
|
93
96
|
const adcp_server_1 = require("../../adcp-server");
|
|
94
97
|
const account_mode_1 = require("../../account-mode");
|
|
95
|
-
const test_controller_1 = require("../../test-controller");
|
|
96
98
|
const observed_modes_1 = require("./observed-modes");
|
|
97
99
|
const normalize_errors_1 = require("../../normalize-errors");
|
|
100
|
+
const redact_1 = require("../../redact");
|
|
98
101
|
/**
|
|
99
102
|
* Apply `normalizeErrors` to a sync_creatives row's optional `errors`
|
|
100
103
|
* field. Adopters often return errors as bare strings, native Error
|
|
@@ -343,7 +346,15 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
343
346
|
const at = platform.capabilities.audience_targeting;
|
|
344
347
|
const ct = platform.capabilities.conversion_tracking;
|
|
345
348
|
const cs = platform.capabilities.content_standards;
|
|
346
|
-
const
|
|
349
|
+
const explicitSom = platform.capabilities.supported_optimization_metrics;
|
|
350
|
+
const derivedSom = explicitSom == null && platform.capabilities.productCatalog != null
|
|
351
|
+
? (0, capability_rollups_1.rollupOptimizationMetricsFromProducts)(platform.capabilities.productCatalog)
|
|
352
|
+
: undefined;
|
|
353
|
+
const somCandidate = explicitSom ?? derivedSom;
|
|
354
|
+
// Empty arrays are an explicit "no seller-level rollup to advertise" signal,
|
|
355
|
+
// not a malformed capability. Omit the wire field so buyers do not see an
|
|
356
|
+
// empty support list as a positive 3.1 metric-optimization declaration.
|
|
357
|
+
const som = somCandidate != null && somCandidate.length > 0 ? somCandidate : undefined;
|
|
347
358
|
const fc = platform.capabilities.frequency_capping;
|
|
348
359
|
const hasSalesPlatform = platform.sales != null || platform.proposalManager != null;
|
|
349
360
|
const supportsProposals = platform.capabilities.supportsProposals ??
|
|
@@ -373,6 +384,14 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
373
384
|
},
|
|
374
385
|
}),
|
|
375
386
|
};
|
|
387
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
388
|
+
if (explicitSom != null && explicitSom.length > 0) {
|
|
389
|
+
fwLogger.info(`[adcp/decisioning] using explicit media_buy.supported_optimization_metrics override (${explicitSom.length} metric${explicitSom.length === 1 ? '' : 's'}).`);
|
|
390
|
+
}
|
|
391
|
+
else if (derivedSom != null) {
|
|
392
|
+
fwLogger.info(`[adcp/decisioning] derived media_buy.supported_optimization_metrics from productCatalog (${derivedSom.length} metric${derivedSom.length === 1 ? '' : 's'}).`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
376
395
|
// Brand-protocol capability projection. Adopters who declare
|
|
377
396
|
// `capabilities.brand` get the block projected via `overrides.brand`.
|
|
378
397
|
// When `BrandRightsPlatform` is supplied, `rights: true` is auto-
|
|
@@ -587,7 +606,7 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
587
606
|
// the `{ account_id }` arm is refused. Closes adcp-client#1364
|
|
588
607
|
// (implicit) and adcp-client#1468 (derived).
|
|
589
608
|
refuseInlineAccountIdWhenForbidden(platform.accounts.resolution, ref);
|
|
590
|
-
const account = await platform.accounts.resolve(ref, toResolveCtx(ctx, ctx.toolName));
|
|
609
|
+
const account = await platform.accounts.resolve(ref, toResolveCtx(ctx, ctx.toolName, ctx.input));
|
|
591
610
|
resolved = account != null;
|
|
592
611
|
resolvedAccountId = account?.id;
|
|
593
612
|
return account;
|
|
@@ -629,7 +648,7 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
629
648
|
let resolved = false;
|
|
630
649
|
let resolvedAccountId;
|
|
631
650
|
try {
|
|
632
|
-
const account = await platform.accounts.resolve(undefined, toResolveCtx(ctx, ctx.toolName));
|
|
651
|
+
const account = await platform.accounts.resolve(undefined, toResolveCtx(ctx, ctx.toolName, ctx.input));
|
|
633
652
|
resolved = account != null;
|
|
634
653
|
resolvedAccountId = account?.id;
|
|
635
654
|
return account;
|
|
@@ -688,6 +707,83 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
688
707
|
})(),
|
|
689
708
|
};
|
|
690
709
|
const server = (0, create_adcp_server_1.createAdcpServer)(config);
|
|
710
|
+
const mcp = (0, adcp_server_1.getSdkServer)(server);
|
|
711
|
+
const resolveComplyBuyerAgent = async (extra, input) => {
|
|
712
|
+
if (platform.agentRegistry === undefined)
|
|
713
|
+
return undefined;
|
|
714
|
+
try {
|
|
715
|
+
const inboundCredential = extra?.authInfo?.extra?.credential;
|
|
716
|
+
const credential = extra?.authInfo?.credential ?? inboundCredential;
|
|
717
|
+
const resolved = await platform.agentRegistry.resolve({
|
|
718
|
+
...(credential !== undefined && { credential }),
|
|
719
|
+
...(extra?.authInfo?.extra !== undefined && { extra: extra.authInfo.extra }),
|
|
720
|
+
...(input !== undefined && { input }),
|
|
721
|
+
});
|
|
722
|
+
if (resolved == null)
|
|
723
|
+
return undefined;
|
|
724
|
+
if (!Object.isFrozen(resolved)) {
|
|
725
|
+
if (resolved.billing_capabilities instanceof Set) {
|
|
726
|
+
Object.freeze(resolved.billing_capabilities);
|
|
727
|
+
}
|
|
728
|
+
Object.freeze(resolved);
|
|
729
|
+
}
|
|
730
|
+
return resolved;
|
|
731
|
+
}
|
|
732
|
+
catch (err) {
|
|
733
|
+
fwLogger.warn?.('Buyer-agent registry resolution failed during comply controller visibility check', {
|
|
734
|
+
error: (0, redact_1.redactCredentialPatterns)(err instanceof Error ? err.message : String(err)),
|
|
735
|
+
});
|
|
736
|
+
return undefined;
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
const resolveComplyControllerVisible = async (extra, toolName, input) => {
|
|
740
|
+
const agent = await resolveComplyBuyerAgent(extra, input);
|
|
741
|
+
let principalAccount = null;
|
|
742
|
+
try {
|
|
743
|
+
principalAccount = await platform.accounts.resolve(undefined, toResolveCtx({
|
|
744
|
+
...(extra?.authInfo !== undefined && { authInfo: extra.authInfo }),
|
|
745
|
+
...(agent !== undefined && { agent }),
|
|
746
|
+
}, toolName, input));
|
|
747
|
+
}
|
|
748
|
+
catch {
|
|
749
|
+
principalAccount = null;
|
|
750
|
+
}
|
|
751
|
+
(0, observed_modes_1.recordResolvedAccountMode)(principalAccount);
|
|
752
|
+
if ((0, account_mode_1.isSandboxOrMockAccount)(principalAccount))
|
|
753
|
+
return true;
|
|
754
|
+
if (process.env.ADCP_SANDBOX === '1') {
|
|
755
|
+
if ((0, observed_modes_1.hasObservedLiveMode)()) {
|
|
756
|
+
throw new Error('comply_test_controller: ADCP_SANDBOX=1 is set but this process has resolved at least one ' +
|
|
757
|
+
'live-mode account from platform.accounts.resolve. Remove ADCP_SANDBOX from your prod ' +
|
|
758
|
+
'environment; gate the controller via mode: "sandbox" on resolved sandbox accounts instead. ' +
|
|
759
|
+
'See docs/proposals/lifecycle-state-and-sandbox-authority.md.');
|
|
760
|
+
}
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
return false;
|
|
764
|
+
};
|
|
765
|
+
if (mcp != null && hasComplianceTestingProjection) {
|
|
766
|
+
const wrappedCapabilities = (0, adcp_server_1.wrapRegisteredToolHandler)(mcp, 'get_adcp_capabilities', async (orig, args, extra) => {
|
|
767
|
+
const response = await orig(args, extra);
|
|
768
|
+
if (await resolveComplyControllerVisible(extra, 'get_adcp_capabilities', args)) {
|
|
769
|
+
return response;
|
|
770
|
+
}
|
|
771
|
+
if (response == null || typeof response !== 'object')
|
|
772
|
+
return response;
|
|
773
|
+
const structured = response.structuredContent;
|
|
774
|
+
if (structured == null || typeof structured !== 'object')
|
|
775
|
+
return response;
|
|
776
|
+
if (!Object.hasOwn(structured, 'compliance_testing'))
|
|
777
|
+
return response;
|
|
778
|
+
const nextStructured = { ...structured };
|
|
779
|
+
delete nextStructured['compliance_testing'];
|
|
780
|
+
return { ...response, structuredContent: nextStructured };
|
|
781
|
+
});
|
|
782
|
+
if (!wrappedCapabilities) {
|
|
783
|
+
throw new Error('createAdcpServerFromPlatform: failed to wrap get_adcp_capabilities for comply_test_controller visibility. ' +
|
|
784
|
+
'The MCP SDK registered-tool internals may have changed.');
|
|
785
|
+
}
|
|
786
|
+
}
|
|
691
787
|
// Wire `comply_test_controller` if the adopter supplied adapters.
|
|
692
788
|
// `createComplyController` builds the tool definition + handler + raw
|
|
693
789
|
// dispatch. The framework registers the tool itself (bypassing
|
|
@@ -772,25 +868,23 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
772
868
|
// `account.sandbox === true` on the wire. The resolver is the only
|
|
773
869
|
// thing that names the account's mode; the gate refuses dispatch when
|
|
774
870
|
// mode is `live` (or the resolver fails to produce an account, modulo
|
|
775
|
-
// the
|
|
871
|
+
// the narrow fallbacks below).
|
|
776
872
|
//
|
|
777
873
|
// Fallback paths (deprecated):
|
|
778
|
-
// - `
|
|
779
|
-
//
|
|
780
|
-
//
|
|
781
|
-
//
|
|
782
|
-
// - `process.env.ADCP_SANDBOX === '1'` admits
|
|
783
|
-
//
|
|
784
|
-
//
|
|
785
|
-
//
|
|
786
|
-
//
|
|
787
|
-
//
|
|
874
|
+
// - `account.sandbox === true` admits only for unresolved target-account
|
|
875
|
+
// refs after a sandbox/mock principal has already passed the discovery
|
|
876
|
+
// visibility gate. A buyer wire claim never overrides a resolved live
|
|
877
|
+
// account and is never used for principal visibility.
|
|
878
|
+
// - `process.env.ADCP_SANDBOX === '1'` admits the principal visibility
|
|
879
|
+
// check and target dispatch for legacy conformance deployments. It
|
|
880
|
+
// fails closed if the same process has ever resolved an explicit
|
|
881
|
+
// `mode: 'live'` account from the resolver: that pairing is a
|
|
882
|
+
// misconfiguration (env var should be unset on prod) and leaving it
|
|
883
|
+
// open re-exposes the live principal we just gated against.
|
|
788
884
|
//
|
|
789
|
-
// `list_scenarios` is exempt
|
|
790
|
-
//
|
|
791
|
-
//
|
|
792
|
-
// the adopter advertised in capabilities.
|
|
793
|
-
const mcp = (0, adcp_server_1.getSdkServer)(server);
|
|
885
|
+
// `list_scenarios` is exempt from the target-account gate once the
|
|
886
|
+
// principal can see the controller. Read-only and reveals nothing beyond
|
|
887
|
+
// which scenarios the adopter advertised in capabilities.
|
|
794
888
|
if (mcp == null) {
|
|
795
889
|
// Non-MCP server — fall back to the controller's own registration so
|
|
796
890
|
// adopters wiring a custom transport keep the v5 behavior. The gate is
|
|
@@ -832,6 +926,9 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
832
926
|
description: controller.toolDefinition.description,
|
|
833
927
|
inputSchema: gatedInputSchema,
|
|
834
928
|
}, (async (input, extra) => {
|
|
929
|
+
if (!(await resolveComplyControllerVisible(extra, 'comply_test_controller', input))) {
|
|
930
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, 'Method not found');
|
|
931
|
+
}
|
|
835
932
|
// Probe exempt — capability discovery, no state mutation.
|
|
836
933
|
if (input.scenario === 'list_scenarios') {
|
|
837
934
|
return controller.handle(input);
|
|
@@ -843,10 +940,11 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
843
940
|
const accountRef = refFromTop ?? refFromContext;
|
|
844
941
|
let resolvedAccount = null;
|
|
845
942
|
try {
|
|
846
|
-
|
|
943
|
+
const agent = await resolveComplyBuyerAgent(extra, input);
|
|
944
|
+
resolvedAccount = await platform.accounts.resolve(accountRef, toResolveCtx({
|
|
847
945
|
...(extra?.authInfo !== undefined && { authInfo: extra.authInfo }),
|
|
848
|
-
|
|
849
|
-
});
|
|
946
|
+
...(agent !== undefined && { agent }),
|
|
947
|
+
}, 'comply_test_controller', input));
|
|
850
948
|
}
|
|
851
949
|
catch {
|
|
852
950
|
// Resolver failures fall through to the wire-ref / env fallbacks.
|
|
@@ -879,10 +977,10 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
879
977
|
}
|
|
880
978
|
const allowed = accountIsSandbox || (resolvedAccount == null && refSandbox) || envSandbox;
|
|
881
979
|
if (!allowed) {
|
|
882
|
-
//
|
|
883
|
-
//
|
|
884
|
-
//
|
|
885
|
-
//
|
|
980
|
+
// Refuse with the standard AdCP permission code once the
|
|
981
|
+
// sandbox/mock principal can see the controller but the target
|
|
982
|
+
// account is live or unresolved. Live principals never reach
|
|
983
|
+
// this branch: they get MCP method-not-found above.
|
|
886
984
|
//
|
|
887
985
|
// `context` and `ext` are open-object on the request schema, so a
|
|
888
986
|
// hostile caller could stuff arbitrarily large payloads. Self-
|
|
@@ -905,18 +1003,65 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
905
1003
|
};
|
|
906
1004
|
const requestContext = safeEcho(input.context);
|
|
907
1005
|
const requestExt = safeEcho(input.ext);
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
1006
|
+
const response = (0, errors_1.adcpError)('PERMISSION_DENIED', {
|
|
1007
|
+
message: 'comply_test_controller requires a sandbox or mock target account; ' +
|
|
1008
|
+
'resolved target account is live or unresolved.',
|
|
1009
|
+
recovery: 'terminal',
|
|
1010
|
+
details: {
|
|
1011
|
+
scope: 'sandbox-gate',
|
|
1012
|
+
tool: 'comply_test_controller',
|
|
1013
|
+
reason: 'sandbox-or-mock-required',
|
|
1014
|
+
},
|
|
916
1015
|
});
|
|
1016
|
+
if (requestContext !== undefined || requestExt !== undefined) {
|
|
1017
|
+
const structured = response.structuredContent;
|
|
1018
|
+
if (requestContext !== undefined)
|
|
1019
|
+
structured['context'] = requestContext;
|
|
1020
|
+
if (requestExt !== undefined)
|
|
1021
|
+
structured['ext'] = requestExt;
|
|
1022
|
+
response.content = [{ type: 'text', text: JSON.stringify(structured) }];
|
|
1023
|
+
}
|
|
1024
|
+
return response;
|
|
917
1025
|
}
|
|
918
1026
|
return controller.handle(input);
|
|
919
1027
|
}));
|
|
1028
|
+
const wrappedToolsCall = (0, adcp_server_1.wrapSdkRequestHandler)(mcp, 'tools/call', async (orig, req, extra) => {
|
|
1029
|
+
const params = (req.params ?? {});
|
|
1030
|
+
if (params.name === 'comply_test_controller') {
|
|
1031
|
+
const input = params.arguments != null && typeof params.arguments === 'object'
|
|
1032
|
+
? params.arguments
|
|
1033
|
+
: undefined;
|
|
1034
|
+
if (!(await resolveComplyControllerVisible(extra, 'comply_test_controller', input))) {
|
|
1035
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, 'Method not found');
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
return orig(req, extra);
|
|
1039
|
+
});
|
|
1040
|
+
if (!wrappedToolsCall) {
|
|
1041
|
+
throw new Error('createAdcpServerFromPlatform: failed to wrap MCP tools/call for comply_test_controller visibility. ' +
|
|
1042
|
+
'The MCP SDK request-handler internals may have changed.');
|
|
1043
|
+
}
|
|
1044
|
+
const wrappedToolsList = (0, adcp_server_1.wrapSdkRequestHandler)(mcp, 'tools/list', async (orig, req, extra) => {
|
|
1045
|
+
const response = await orig(req, extra);
|
|
1046
|
+
const input = req.params != null && typeof req.params === 'object'
|
|
1047
|
+
? req.params
|
|
1048
|
+
: undefined;
|
|
1049
|
+
if (await resolveComplyControllerVisible(extra, undefined, input))
|
|
1050
|
+
return response;
|
|
1051
|
+
if (response == null || typeof response !== 'object')
|
|
1052
|
+
return response;
|
|
1053
|
+
const tools = response.tools;
|
|
1054
|
+
if (!Array.isArray(tools))
|
|
1055
|
+
return response;
|
|
1056
|
+
return {
|
|
1057
|
+
...response,
|
|
1058
|
+
tools: tools.filter(tool => tool?.name !== 'comply_test_controller'),
|
|
1059
|
+
};
|
|
1060
|
+
});
|
|
1061
|
+
if (!wrappedToolsList) {
|
|
1062
|
+
throw new Error('createAdcpServerFromPlatform: failed to wrap MCP tools/list for comply_test_controller visibility. ' +
|
|
1063
|
+
'The MCP SDK request-handler internals may have changed.');
|
|
1064
|
+
}
|
|
920
1065
|
}
|
|
921
1066
|
}
|
|
922
1067
|
return Object.assign(server, {
|
|
@@ -1034,6 +1179,7 @@ function buildTasksGetTool(platform, taskRegistry, agentRegistry, logger) {
|
|
|
1034
1179
|
const resolved = await agentRegistry.resolve({
|
|
1035
1180
|
...(extra?.authInfo?.credential !== undefined && { credential: extra.authInfo.credential }),
|
|
1036
1181
|
...(extra?.authInfo?.extra !== undefined && { extra: extra.authInfo.extra }),
|
|
1182
|
+
input: args,
|
|
1037
1183
|
});
|
|
1038
1184
|
if (resolved != null) {
|
|
1039
1185
|
// Mirror the dispatcher's freeze contract: lock the resolved
|
|
@@ -1365,6 +1511,19 @@ function buildDefaultTaskRegistry() {
|
|
|
1365
1511
|
}
|
|
1366
1512
|
return (0, task_registry_1.createInMemoryTaskRegistry)();
|
|
1367
1513
|
}
|
|
1514
|
+
function cloneAccountForRequest(account) {
|
|
1515
|
+
try {
|
|
1516
|
+
return structuredClone(account);
|
|
1517
|
+
}
|
|
1518
|
+
catch (cause) {
|
|
1519
|
+
const publicError = new async_outcome_1.AdcpError('CONFIGURATION_ERROR', {
|
|
1520
|
+
message: 'Resolved account is not safely cloneable for request-local auth refresh.',
|
|
1521
|
+
recovery: 'terminal',
|
|
1522
|
+
});
|
|
1523
|
+
publicError.cause = cause;
|
|
1524
|
+
throw publicError;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1368
1527
|
/** Auth codes that signal "credentials missing, refresh and retry once." */
|
|
1369
1528
|
const REFRESHABLE_AUTH_CODES = new Set(['AUTH_REQUIRED', 'AUTH_MISSING']);
|
|
1370
1529
|
/**
|
|
@@ -1372,16 +1531,16 @@ const REFRESHABLE_AUTH_CODES = new Set(['AUTH_REQUIRED', 'AUTH_MISSING']);
|
|
|
1372
1531
|
* auth codes (`AUTH_REQUIRED` on 3.0.x sellers, `AUTH_MISSING` on 3.1+).
|
|
1373
1532
|
* Without a refresh fn (or no `refresh` at all) this passes the call
|
|
1374
1533
|
* through. With one, catches the refreshable code, calls `refresh.fn`,
|
|
1375
|
-
* mutates `account.authInfo
|
|
1376
|
-
* retries the inner call exactly once.
|
|
1534
|
+
* mutates or creates `account.authInfo` (including `expiresAt` when
|
|
1535
|
+
* returned), and retries the inner call exactly once.
|
|
1377
1536
|
*
|
|
1378
1537
|
* `AUTH_INVALID` is intentionally NOT refreshed — it's terminal by
|
|
1379
1538
|
* spec (credentials presented and rejected); refreshing creates the
|
|
1380
1539
|
* SSO retry-storm pattern adcp#3730 split the code to prevent.
|
|
1381
1540
|
*
|
|
1382
1541
|
* Failure modes:
|
|
1383
|
-
* - Refresh hook throws → re-throw `AUTH_REQUIRED` with
|
|
1384
|
-
* so the buyer re-links via their UI.
|
|
1542
|
+
* - Refresh hook throws → re-throw legacy-compatible `AUTH_REQUIRED` with
|
|
1543
|
+
* `recovery: 'correctable'` so the buyer re-links via their UI.
|
|
1385
1544
|
* - Retried call throws a refreshable auth code again → bubble out
|
|
1386
1545
|
* (don't refresh a second time).
|
|
1387
1546
|
*/
|
|
@@ -1399,29 +1558,30 @@ async function runWithTokenRefresh(fn, refresh) {
|
|
|
1399
1558
|
try {
|
|
1400
1559
|
refreshed = await refresh.fn(refresh.account, 'auth_required');
|
|
1401
1560
|
}
|
|
1402
|
-
catch {
|
|
1561
|
+
catch (cause) {
|
|
1403
1562
|
// Refresh-fn exception text is intentionally NOT echoed on the wire
|
|
1404
1563
|
// — upstream identity-provider error messages routinely embed
|
|
1405
1564
|
// refresh-token prefixes, internal hostnames, OAuth provider error
|
|
1406
1565
|
// codes, and stack-trace fragments. Adopters log details server-
|
|
1407
1566
|
// side; the buyer gets a fixed message + correctable recovery
|
|
1408
1567
|
// signaling they need to re-authorize.
|
|
1409
|
-
|
|
1568
|
+
const publicError = new async_outcome_1.AdcpError('AUTH_REQUIRED', {
|
|
1410
1569
|
message: 'Token refresh failed; re-authentication required',
|
|
1411
1570
|
recovery: 'correctable',
|
|
1412
1571
|
});
|
|
1572
|
+
publicError.cause = cause;
|
|
1573
|
+
throw publicError;
|
|
1413
1574
|
}
|
|
1414
|
-
// `authInfo` became optional in #1286.
|
|
1415
|
-
//
|
|
1416
|
-
//
|
|
1417
|
-
//
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
refresh.account.authInfo.expiresAt = refreshed.expiresAt;
|
|
1423
|
-
}
|
|
1575
|
+
// `authInfo` became optional in #1286. A 3.1-native AUTH_MISSING can mean
|
|
1576
|
+
// the upstream request had no usable credential at all, so attach the
|
|
1577
|
+
// freshly minted OAuth-style token even when the resolver omitted
|
|
1578
|
+
// account.authInfo.
|
|
1579
|
+
const authInfo = refresh.account.authInfo ?? { kind: 'oauth' };
|
|
1580
|
+
authInfo.token = refreshed.token;
|
|
1581
|
+
if (refreshed.expiresAt !== undefined) {
|
|
1582
|
+
authInfo.expiresAt = refreshed.expiresAt;
|
|
1424
1583
|
}
|
|
1584
|
+
refresh.account.authInfo = authInfo;
|
|
1425
1585
|
return fn();
|
|
1426
1586
|
}
|
|
1427
1587
|
}
|
|
@@ -1430,9 +1590,9 @@ async function runWithTokenRefresh(fn, refresh) {
|
|
|
1430
1590
|
* throws → wire `adcp_error` envelope; other thrown errors bubble to the
|
|
1431
1591
|
* framework's `SERVICE_UNAVAILABLE` mapping.
|
|
1432
1592
|
*
|
|
1433
|
-
* When `refresh` is provided and the call throws
|
|
1593
|
+
* When `refresh` is provided and the call throws a refreshable auth code, the
|
|
1434
1594
|
* framework calls `refresh.fn(refresh.account, 'auth_required')`, updates
|
|
1435
|
-
* `account.authInfo
|
|
1595
|
+
* `account.authInfo`, and retries the platform method once.
|
|
1436
1596
|
*/
|
|
1437
1597
|
async function projectSync(fn, mapResult, refresh) {
|
|
1438
1598
|
try {
|
|
@@ -1871,7 +2031,7 @@ function makeCtxFor(ctxMetadataStore) {
|
|
|
1871
2031
|
function toResolveCtx(ctx, toolName, input) {
|
|
1872
2032
|
return {
|
|
1873
2033
|
...(ctx.authInfo !== undefined && { authInfo: ctx.authInfo }),
|
|
1874
|
-
toolName,
|
|
2034
|
+
...(toolName !== undefined && { toolName }),
|
|
1875
2035
|
...(ctx.agent != null && { agent: ctx.agent }),
|
|
1876
2036
|
...(input != null && { input }),
|
|
1877
2037
|
};
|
|
@@ -3050,7 +3210,7 @@ function buildSignalsHandlers(platform, ctxFor, ctxMetadataStore, logger) {
|
|
|
3050
3210
|
};
|
|
3051
3211
|
}
|
|
3052
3212
|
/**
|
|
3053
|
-
* Adapt `SponsoredIntelligencePlatform` (v6
|
|
3213
|
+
* Adapt `SponsoredIntelligencePlatform` (v6 platform-specialism shape) onto the v5
|
|
3054
3214
|
* `SponsoredIntelligenceHandlers` handler-bag the dispatcher consumes.
|
|
3055
3215
|
*
|
|
3056
3216
|
* Auto-store on `initiateSession`: stash a session record keyed by
|
|
@@ -3332,6 +3492,136 @@ function buildGovernanceHandlers(platform, ctxFor) {
|
|
|
3332
3492
|
}
|
|
3333
3493
|
return handlers;
|
|
3334
3494
|
}
|
|
3495
|
+
const BILLING_VALUES = ['operator', 'agent', 'advertiser'];
|
|
3496
|
+
function isBillingParty(value) {
|
|
3497
|
+
return typeof value === 'string' && BILLING_VALUES.includes(value);
|
|
3498
|
+
}
|
|
3499
|
+
function isPaymentTerms(value) {
|
|
3500
|
+
return typeof value === 'string';
|
|
3501
|
+
}
|
|
3502
|
+
function supportedBillingsFor(platform) {
|
|
3503
|
+
const configured = platform.capabilities.supportedBillings;
|
|
3504
|
+
return configured?.length ? configured : ['agent'];
|
|
3505
|
+
}
|
|
3506
|
+
function entryBrandOperator(entry) {
|
|
3507
|
+
if (entry.brand !== undefined && typeof entry.operator === 'string') {
|
|
3508
|
+
return { brand: entry.brand, operator: entry.operator };
|
|
3509
|
+
}
|
|
3510
|
+
const account = entry.account;
|
|
3511
|
+
if (account !== undefined &&
|
|
3512
|
+
'brand' in account &&
|
|
3513
|
+
account.brand !== undefined &&
|
|
3514
|
+
'operator' in account &&
|
|
3515
|
+
typeof account.operator === 'string') {
|
|
3516
|
+
return { brand: account.brand, operator: account.operator };
|
|
3517
|
+
}
|
|
3518
|
+
return undefined;
|
|
3519
|
+
}
|
|
3520
|
+
function entryHasAccountId(entry) {
|
|
3521
|
+
if ((0, account_1.refAccountId)(entry) !== undefined)
|
|
3522
|
+
return true;
|
|
3523
|
+
return entry.account !== undefined && (0, account_1.refAccountId)(entry.account) !== undefined;
|
|
3524
|
+
}
|
|
3525
|
+
function failedSyncAccountRow(entry, error) {
|
|
3526
|
+
const key = entryBrandOperator(entry);
|
|
3527
|
+
if (key === undefined) {
|
|
3528
|
+
throw new async_outcome_1.AdcpError(error.code, {
|
|
3529
|
+
message: error.message,
|
|
3530
|
+
recovery: error.recovery,
|
|
3531
|
+
...(error.field !== undefined && { field: error.field }),
|
|
3532
|
+
...(error.suggestion !== undefined && { suggestion: error.suggestion }),
|
|
3533
|
+
...(error.retry_after !== undefined && { retry_after: error.retry_after }),
|
|
3534
|
+
...(error.details !== undefined && { details: error.details }),
|
|
3535
|
+
});
|
|
3536
|
+
}
|
|
3537
|
+
return {
|
|
3538
|
+
brand: key.brand,
|
|
3539
|
+
operator: key.operator,
|
|
3540
|
+
action: 'failed',
|
|
3541
|
+
status: 'rejected',
|
|
3542
|
+
errors: [error],
|
|
3543
|
+
};
|
|
3544
|
+
}
|
|
3545
|
+
function buildBillingNotSupportedError(opts) {
|
|
3546
|
+
return new async_outcome_1.AdcpError('BILLING_NOT_SUPPORTED', {
|
|
3547
|
+
message: `Billing value "${opts.requestedBilling}" is not supported for this account sync request.`,
|
|
3548
|
+
recovery: 'correctable',
|
|
3549
|
+
field: 'accounts[].billing',
|
|
3550
|
+
...(opts.exposeCapabilityScope && opts.supportedBillings !== undefined
|
|
3551
|
+
? { details: { scope: 'capability', supported_billing: [...opts.supportedBillings] } }
|
|
3552
|
+
: {}),
|
|
3553
|
+
}).toStructuredError();
|
|
3554
|
+
}
|
|
3555
|
+
function buildBillingNotPermittedError(agent, requestedBilling) {
|
|
3556
|
+
const fallback = (0, buyer_agent_1.suggestBilling)(agent.billing_capabilities, requestedBilling);
|
|
3557
|
+
return new async_outcome_1.AdcpError('BILLING_NOT_PERMITTED_FOR_AGENT', {
|
|
3558
|
+
message: `Billing value "${requestedBilling}" is not permitted for this buyer agent.`,
|
|
3559
|
+
recovery: 'correctable',
|
|
3560
|
+
field: 'accounts[].billing',
|
|
3561
|
+
details: {
|
|
3562
|
+
rejected_billing: requestedBilling,
|
|
3563
|
+
...(fallback !== undefined && { suggested_billing: fallback }),
|
|
3564
|
+
},
|
|
3565
|
+
}).toStructuredError();
|
|
3566
|
+
}
|
|
3567
|
+
function enforceSyncAccountsCommercialPolicy(platform, params, resolveCtx) {
|
|
3568
|
+
const entries = (params.accounts ?? []);
|
|
3569
|
+
const supportedBillings = supportedBillingsFor(platform);
|
|
3570
|
+
const supportedPaymentTerms = platform.capabilities.supportedPaymentTerms;
|
|
3571
|
+
const failedRows = new Map();
|
|
3572
|
+
const acceptedEntries = [];
|
|
3573
|
+
entries.forEach((entry, index) => {
|
|
3574
|
+
const hasBillableFields = entry.billing !== undefined || entry.payment_terms !== undefined || entry.billing_entity !== undefined;
|
|
3575
|
+
if (hasBillableFields && entryBrandOperator(entry) === undefined && !entryHasAccountId(entry)) {
|
|
3576
|
+
throw new async_outcome_1.AdcpError('BRAND_REQUIRED', {
|
|
3577
|
+
message: 'Billable account sync entries require a brand reference or account_id.',
|
|
3578
|
+
recovery: 'correctable',
|
|
3579
|
+
field: `accounts[${index}].brand`,
|
|
3580
|
+
});
|
|
3581
|
+
}
|
|
3582
|
+
let failure;
|
|
3583
|
+
if (isBillingParty(entry.billing)) {
|
|
3584
|
+
if (!supportedBillings.includes(entry.billing)) {
|
|
3585
|
+
failure = buildBillingNotSupportedError({
|
|
3586
|
+
requestedBilling: entry.billing,
|
|
3587
|
+
supportedBillings,
|
|
3588
|
+
exposeCapabilityScope: true,
|
|
3589
|
+
});
|
|
3590
|
+
}
|
|
3591
|
+
else if (platform.agentRegistry !== undefined && resolveCtx.agent === undefined) {
|
|
3592
|
+
failure = buildBillingNotSupportedError({
|
|
3593
|
+
requestedBilling: entry.billing,
|
|
3594
|
+
exposeCapabilityScope: false,
|
|
3595
|
+
});
|
|
3596
|
+
}
|
|
3597
|
+
else if (resolveCtx.agent !== undefined && !resolveCtx.agent.billing_capabilities.has(entry.billing)) {
|
|
3598
|
+
failure = buildBillingNotPermittedError(resolveCtx.agent, entry.billing);
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
if (failure === undefined &&
|
|
3602
|
+
supportedPaymentTerms !== undefined &&
|
|
3603
|
+
supportedPaymentTerms.length > 0 &&
|
|
3604
|
+
isPaymentTerms(entry.payment_terms) &&
|
|
3605
|
+
!supportedPaymentTerms.includes(entry.payment_terms)) {
|
|
3606
|
+
failure = new async_outcome_1.AdcpError('PAYMENT_TERMS_NOT_SUPPORTED', {
|
|
3607
|
+
message: `Payment terms "${entry.payment_terms}" are not supported for this account sync request.`,
|
|
3608
|
+
recovery: 'correctable',
|
|
3609
|
+
field: `accounts[${index}].payment_terms`,
|
|
3610
|
+
}).toStructuredError();
|
|
3611
|
+
}
|
|
3612
|
+
if (failure !== undefined) {
|
|
3613
|
+
failedRows.set(index, failedSyncAccountRow(entry, failure));
|
|
3614
|
+
}
|
|
3615
|
+
else {
|
|
3616
|
+
acceptedEntries.push(entry);
|
|
3617
|
+
}
|
|
3618
|
+
});
|
|
3619
|
+
return {
|
|
3620
|
+
acceptedEntries,
|
|
3621
|
+
acceptedParams: { ...params, accounts: acceptedEntries },
|
|
3622
|
+
failedRows,
|
|
3623
|
+
};
|
|
3624
|
+
}
|
|
3335
3625
|
function buildAccountHandlers(platform, ctxFor) {
|
|
3336
3626
|
const accounts = platform.accounts;
|
|
3337
3627
|
// Only emit framework-derived handlers for methods the platform actually
|
|
@@ -3347,9 +3637,30 @@ function buildAccountHandlers(platform, ctxFor) {
|
|
|
3347
3637
|
const handlers = {};
|
|
3348
3638
|
if (accounts.upsert) {
|
|
3349
3639
|
handlers.syncAccounts = async (params, ctx) => {
|
|
3350
|
-
const refs = (params.accounts ?? []);
|
|
3351
3640
|
const resolveCtx = toResolveCtx(ctx, 'sync_accounts', params);
|
|
3352
|
-
|
|
3641
|
+
const policy = enforceSyncAccountsCommercialPolicy(platform, params, resolveCtx);
|
|
3642
|
+
const dispatchCtx = policy.failedRows.size === 0 ? resolveCtx : toResolveCtx(ctx, 'sync_accounts', policy.acceptedParams);
|
|
3643
|
+
return projectSync(() => policy.acceptedEntries.length > 0
|
|
3644
|
+
? accounts.upsert(policy.acceptedEntries, dispatchCtx)
|
|
3645
|
+
: Promise.resolve([]), rows => {
|
|
3646
|
+
if (policy.failedRows.size === 0) {
|
|
3647
|
+
return { accounts: rows.map(account_1.toWireSyncAccountRow) };
|
|
3648
|
+
}
|
|
3649
|
+
const combined = [];
|
|
3650
|
+
let acceptedIndex = 0;
|
|
3651
|
+
const originalCount = (params.accounts ?? []).length;
|
|
3652
|
+
for (let index = 0; index < originalCount; index += 1) {
|
|
3653
|
+
const failed = policy.failedRows.get(index);
|
|
3654
|
+
if (failed !== undefined) {
|
|
3655
|
+
combined.push(failed);
|
|
3656
|
+
}
|
|
3657
|
+
else {
|
|
3658
|
+
combined.push(rows[acceptedIndex]);
|
|
3659
|
+
acceptedIndex += 1;
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
return { accounts: combined.map(account_1.toWireSyncAccountRow) };
|
|
3663
|
+
});
|
|
3353
3664
|
};
|
|
3354
3665
|
}
|
|
3355
3666
|
if (accounts.syncGovernance) {
|
|
@@ -3394,8 +3705,12 @@ function buildAccountHandlers(platform, ctxFor) {
|
|
|
3394
3705
|
recovery: 'terminal',
|
|
3395
3706
|
});
|
|
3396
3707
|
}
|
|
3397
|
-
|
|
3398
|
-
|
|
3708
|
+
// Request-local clone: refreshToken mutates account.authInfo before the
|
|
3709
|
+
// retry. Never write refreshed credentials onto a resolver-owned object;
|
|
3710
|
+
// adopters sometimes cache Account rows between requests.
|
|
3711
|
+
const account = cloneAccountForRequest(resolved);
|
|
3712
|
+
const toolCtx = { ...resolveCtx, account };
|
|
3713
|
+
return projectSync(() => accounts.getAccountFinancials(params, toolCtx), r => r, accounts.refreshToken ? { account, fn: accounts.refreshToken.bind(accounts) } : undefined);
|
|
3399
3714
|
};
|
|
3400
3715
|
}
|
|
3401
3716
|
return handlers;
|