@adcp/sdk 14.0.0 → 14.2.0
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/dist/lib/adapters/implicit-account-store.d.mts +12 -7
- package/dist/lib/adapters/implicit-account-store.d.ts +12 -7
- package/dist/lib/adapters/implicit-account-store.js +69 -15
- package/dist/lib/adapters/implicit-account-store.mjs +69 -15
- package/dist/lib/core/AgentClient.d.mts +1 -0
- package/dist/lib/core/AgentClient.d.ts +1 -0
- package/dist/lib/core/AgentClient.js +3 -0
- package/dist/lib/core/AgentClient.mjs +3 -0
- package/dist/lib/core/SingleAgentClient.d.mts +35 -2
- package/dist/lib/core/SingleAgentClient.d.ts +35 -2
- package/dist/lib/core/SingleAgentClient.js +377 -36
- package/dist/lib/core/SingleAgentClient.mjs +387 -38
- package/dist/lib/core/TaskExecutor.d.mts +3 -1
- package/dist/lib/core/TaskExecutor.d.ts +3 -1
- package/dist/lib/core/TaskExecutor.js +17 -12
- package/dist/lib/core/TaskExecutor.mjs +17 -12
- package/dist/lib/core/account-key.d.mts +3 -0
- package/dist/lib/core/account-key.d.ts +3 -0
- package/dist/lib/core/account-key.js +41 -0
- package/dist/lib/core/account-key.mjs +17 -0
- package/dist/lib/core/account-resolution.d.mts +2 -0
- package/dist/lib/core/account-resolution.d.ts +2 -0
- package/dist/lib/core/buyer-account-registry.d.mts +93 -0
- package/dist/lib/core/buyer-account-registry.d.ts +93 -0
- package/dist/lib/core/buyer-account-registry.js +602 -0
- package/dist/lib/core/buyer-account-registry.mjs +578 -0
- package/dist/lib/core/product-cache.d.mts +18 -0
- package/dist/lib/core/product-cache.d.ts +18 -0
- package/dist/lib/core/product-cache.js +137 -0
- package/dist/lib/core/product-cache.mjs +112 -0
- package/dist/lib/errors/index.d.mts +40 -1
- package/dist/lib/errors/index.d.ts +40 -1
- package/dist/lib/errors/index.js +69 -3
- package/dist/lib/errors/index.mjs +64 -3
- package/dist/lib/governance/authorization.d.mts +17 -1
- package/dist/lib/governance/authorization.d.ts +17 -1
- package/dist/lib/governance/authorization.js +55 -7
- package/dist/lib/governance/authorization.mjs +59 -7
- package/dist/lib/governance/index.d.mts +2 -2
- package/dist/lib/governance/index.d.ts +2 -2
- package/dist/lib/governance/index.js +2 -0
- package/dist/lib/governance/index.mjs +3 -1
- package/dist/lib/index.d.mts +7 -4
- package/dist/lib/index.d.ts +7 -4
- package/dist/lib/index.js +29 -0
- package/dist/lib/index.mjs +31 -1
- package/dist/lib/net/agent-transport-fetch.d.mts +4 -0
- package/dist/lib/net/agent-transport-fetch.d.ts +4 -0
- package/dist/lib/net/agent-transport-fetch.js +18 -5
- package/dist/lib/net/agent-transport-fetch.mjs +17 -5
- package/dist/lib/protocols/a2a.js +9 -1
- package/dist/lib/protocols/a2a.mjs +9 -1
- package/dist/lib/protocols/index.js +9 -2
- package/dist/lib/protocols/index.mjs +9 -2
- package/dist/lib/protocols/mcp-modern.js +2 -1
- package/dist/lib/protocols/mcp-modern.mjs +2 -1
- package/dist/lib/protocols/mcp.js +5 -2
- package/dist/lib/protocols/mcp.mjs +5 -2
- package/dist/lib/protocols/rawResponseCapture.d.mts +6 -0
- package/dist/lib/protocols/rawResponseCapture.d.ts +6 -0
- package/dist/lib/protocols/rawResponseCapture.js +41 -29
- package/dist/lib/protocols/rawResponseCapture.mjs +40 -29
- package/dist/lib/protocols/signedRequestRejection.d.mts +9 -0
- package/dist/lib/protocols/signedRequestRejection.d.ts +9 -0
- package/dist/lib/protocols/signedRequestRejection.js +209 -0
- package/dist/lib/protocols/signedRequestRejection.mjs +189 -0
- package/dist/lib/protocols/transportDiagnostics.d.mts +1 -0
- package/dist/lib/protocols/transportDiagnostics.d.ts +1 -0
- package/dist/lib/protocols/transportDiagnostics.js +2 -0
- package/dist/lib/protocols/transportDiagnostics.mjs +1 -0
- package/dist/lib/registry/types.generated.d.mts +112 -45
- package/dist/lib/registry/types.generated.d.ts +112 -45
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/account-provisioning.d.mts +2 -0
- package/dist/lib/server/account-provisioning.d.ts +2 -0
- package/dist/lib/server/account-provisioning.js +30 -0
- package/dist/lib/server/account-provisioning.mjs +6 -0
- package/dist/lib/server/account-reference-warnings.d.mts +12 -0
- package/dist/lib/server/account-reference-warnings.d.ts +12 -0
- package/dist/lib/server/account-reference-warnings.js +48 -0
- package/dist/lib/server/account-reference-warnings.mjs +23 -0
- package/dist/lib/server/auth-signature.js +1 -0
- package/dist/lib/server/auth-signature.mjs +1 -0
- package/dist/lib/server/create-adcp-server.d.mts +34 -0
- package/dist/lib/server/create-adcp-server.d.ts +34 -0
- package/dist/lib/server/create-adcp-server.js +225 -14
- package/dist/lib/server/create-adcp-server.mjs +225 -14
- package/dist/lib/server/decisioning/account.d.mts +2 -0
- package/dist/lib/server/decisioning/account.d.ts +2 -0
- package/dist/lib/server/decisioning/runtime/from-platform.js +49 -10
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +49 -10
- package/dist/lib/server/index.d.mts +2 -2
- package/dist/lib/server/index.d.ts +2 -2
- package/dist/lib/server/index.js +2 -0
- package/dist/lib/server/index.mjs +3 -1
- package/dist/lib/signing/agent-resolver/consistency.d.mts +6 -13
- package/dist/lib/signing/agent-resolver/consistency.d.ts +6 -13
- package/dist/lib/signing/agent-resolver/consistency.js +0 -1
- package/dist/lib/signing/agent-resolver/consistency.mjs +0 -1
- package/dist/lib/signing/agent-resolver/errors.d.mts +3 -1
- package/dist/lib/signing/agent-resolver/errors.d.ts +3 -1
- package/dist/lib/signing/agent-resolver/errors.js +6 -0
- package/dist/lib/signing/agent-resolver/errors.mjs +6 -0
- package/dist/lib/signing/agent-resolver/fetch-helpers.d.mts +11 -0
- package/dist/lib/signing/agent-resolver/fetch-helpers.d.ts +11 -0
- package/dist/lib/signing/agent-resolver/fetch-helpers.js +37 -2
- package/dist/lib/signing/agent-resolver/fetch-helpers.mjs +40 -3
- package/dist/lib/signing/agent-resolver/jwks-set.js +24 -3
- package/dist/lib/signing/agent-resolver/jwks-set.mjs +24 -3
- package/dist/lib/signing/agent-resolver/legacy-brand.d.mts +15 -0
- package/dist/lib/signing/agent-resolver/legacy-brand.d.ts +15 -0
- package/dist/lib/signing/agent-resolver/legacy-brand.js +60 -0
- package/dist/lib/signing/agent-resolver/legacy-brand.mjs +36 -0
- package/dist/lib/signing/agent-resolver/operator-authorization.d.mts +13 -0
- package/dist/lib/signing/agent-resolver/operator-authorization.d.ts +13 -0
- package/dist/lib/signing/agent-resolver/operator-authorization.js +108 -0
- package/dist/lib/signing/agent-resolver/operator-authorization.mjs +84 -0
- package/dist/lib/signing/agent-resolver/resolve-agent.d.mts +14 -4
- package/dist/lib/signing/agent-resolver/resolve-agent.d.ts +14 -4
- package/dist/lib/signing/agent-resolver/resolve-agent.js +148 -137
- package/dist/lib/signing/agent-resolver/resolve-agent.mjs +157 -139
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.mts +7 -1
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.ts +7 -1
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.js +50 -17
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.mjs +50 -17
- package/dist/lib/signing/agent-resolver/select-agent.d.mts +14 -15
- package/dist/lib/signing/agent-resolver/select-agent.d.ts +14 -15
- package/dist/lib/signing/agent-resolver/select-agent.js +98 -13
- package/dist/lib/signing/agent-resolver/select-agent.mjs +95 -13
- package/dist/lib/signing/brand-jwks.d.mts +29 -75
- package/dist/lib/signing/brand-jwks.d.ts +29 -75
- package/dist/lib/signing/brand-jwks.js +120 -182
- package/dist/lib/signing/brand-jwks.mjs +120 -182
- package/dist/lib/signing/errors.d.mts +7 -3
- package/dist/lib/signing/errors.d.ts +7 -3
- package/dist/lib/signing/errors.js +7 -2
- package/dist/lib/signing/errors.mjs +7 -2
- package/dist/lib/signing/jwks-https.d.mts +7 -0
- package/dist/lib/signing/jwks-https.d.ts +7 -0
- package/dist/lib/signing/jwks-https.js +31 -8
- package/dist/lib/signing/jwks-https.mjs +31 -8
- package/dist/lib/signing/jwks.d.mts +8 -0
- package/dist/lib/signing/jwks.d.ts +8 -0
- package/dist/lib/signing/middleware.js +2 -1
- package/dist/lib/signing/middleware.mjs +2 -1
- package/dist/lib/signing/publisher-pins.d.mts +11 -0
- package/dist/lib/signing/publisher-pins.d.ts +11 -0
- package/dist/lib/signing/publisher-pins.js +125 -0
- package/dist/lib/signing/publisher-pins.mjs +101 -0
- package/dist/lib/signing/server.d.mts +1 -0
- package/dist/lib/signing/server.d.ts +1 -0
- package/dist/lib/signing/types.d.mts +5 -0
- package/dist/lib/signing/types.d.ts +5 -0
- package/dist/lib/signing/verifier.js +50 -5
- package/dist/lib/signing/verifier.mjs +50 -5
- package/dist/lib/signing/webhook-verifier.d.mts +7 -2
- package/dist/lib/signing/webhook-verifier.d.ts +7 -2
- package/dist/lib/signing/webhook-verifier.js +42 -2
- package/dist/lib/signing/webhook-verifier.mjs +42 -2
- package/dist/lib/testing/storyboard/account-policy.d.mts +2 -0
- package/dist/lib/testing/storyboard/account-policy.d.ts +2 -0
- package/dist/lib/testing/storyboard/account-policy.js +35 -0
- package/dist/lib/testing/storyboard/account-policy.mjs +11 -0
- package/dist/lib/testing/storyboard/context.js +6 -0
- package/dist/lib/testing/storyboard/context.mjs +6 -0
- package/dist/lib/testing/storyboard/request-builder.js +12 -2
- package/dist/lib/testing/storyboard/request-builder.mjs +12 -2
- package/dist/lib/testing/storyboard/runner.js +3 -2
- package/dist/lib/testing/storyboard/runner.mjs +3 -2
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/types/accept-proposal.d.ts +19 -1
- package/dist/lib/types/buy-products.d.ts +19 -1
- package/dist/lib/types/check-governance.d.ts +19 -1
- package/dist/lib/types/comply-test-controller.d.ts +19 -1
- package/dist/lib/types/control-media-buy.d.ts +19 -1
- package/dist/lib/types/core.generated.d.mts +14 -1
- package/dist/lib/types/core.generated.d.ts +14 -1
- package/dist/lib/types/create-media-buy.d.ts +14 -1
- package/dist/lib/types/get-media-buys.d.ts +14 -1
- package/dist/lib/types/get-products.d.ts +19 -1
- package/dist/lib/types/list-products.d.ts +19 -1
- package/dist/lib/types/refine-proposals.d.ts +19 -1
- package/dist/lib/types/request-proposals.d.ts +19 -1
- package/dist/lib/types/schemas.generated.d.ts +12 -3
- package/dist/lib/types/schemas.generated.js +4 -1
- package/dist/lib/types/schemas.generated.mjs +4 -1
- package/dist/lib/types/tools.generated.d.mts +14 -1
- package/dist/lib/types/tools.generated.d.ts +14 -1
- package/dist/lib/types/update-media-buy.d.ts +14 -1
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/webhooks/index.d.mts +24 -0
- package/dist/lib/webhooks/index.d.ts +24 -0
- package/dist/lib/webhooks/index.js +50 -24
- package/dist/lib/webhooks/index.mjs +49 -24
- package/dist/lib/wholesale-feed-sync/index.d.mts +2 -0
- package/dist/lib/wholesale-feed-sync/index.d.ts +2 -0
- package/dist/lib/wholesale-feed-sync/index.js +7 -0
- package/dist/lib/wholesale-feed-sync/index.mjs +4 -0
- package/dist/lib/wholesale-feed-sync/mirror.d.mts +97 -0
- package/dist/lib/wholesale-feed-sync/mirror.d.ts +97 -0
- package/dist/lib/wholesale-feed-sync/mirror.js +350 -0
- package/dist/lib/wholesale-feed-sync/mirror.mjs +322 -0
- package/dist/lib/wholesale-feed-sync/sync.d.mts +13 -29
- package/dist/lib/wholesale-feed-sync/sync.d.ts +13 -29
- package/dist/lib/wholesale-feed-sync/sync.js +208 -281
- package/dist/lib/wholesale-feed-sync/sync.mjs +213 -281
- package/dist/lib/wholesale-feed-sync/types.d.mts +4 -3
- package/dist/lib/wholesale-feed-sync/types.d.ts +4 -3
- package/docs/README.md +6 -0
- package/docs/TYPE-SUMMARY.md +2 -2
- package/docs/guides/BUILD-AN-AGENT.md +2 -2
- package/docs/guides/BUYER-QUICKSTART-3.2.md +2 -0
- package/docs/guides/BUYER-STORAGE.md +3 -0
- package/docs/guides/FIRST-CALL-TO-A-SELLER.md +106 -0
- package/docs/guides/SIGNING-GUIDE.md +16 -7
- package/docs/guides/account-resolution.md +132 -10
- package/docs/llms.txt +3 -2
- package/docs/migration-14.0-to-14.1.md +85 -0
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-4.x-to-5.x.md +1 -0
- package/docs/migration-agent-resolution-3.3.md +125 -0
- package/docs/recipes/verifying-inbound-webhooks.md +60 -15
- package/package.json +3 -2
- package/skills/adcp-brand.previous/SKILL.md +0 -200
- package/skills/adcp-creative.previous/SKILL.md +0 -305
- package/skills/adcp-governance.previous/SKILL.md +0 -566
- package/skills/adcp-measurement.previous/SKILL.md +0 -136
- package/skills/adcp-media-buy.previous/SKILL.md +0 -556
- package/skills/adcp-si.previous/SKILL.md +0 -206
- package/skills/adcp-signals.previous/SKILL.md +0 -204
|
@@ -50,6 +50,7 @@ var import_request_proposals_guard = require('./request-proposals-guard.js');
|
|
|
50
50
|
var import_task_deadline = require('./task-deadline.js');
|
|
51
51
|
var import_auth = require('../auth/index.js');
|
|
52
52
|
var import_abort = require('../protocols/abort.js');
|
|
53
|
+
var import_signedRequestRejection = require('../protocols/signedRequestRejection.js');
|
|
53
54
|
var import_protocols = require('../protocols/index.js');
|
|
54
55
|
var import_errors = require('../errors/index.js');
|
|
55
56
|
var import_net = require('../net/index.js');
|
|
@@ -69,6 +70,7 @@ var crypto = __toESM(require("crypto"));
|
|
|
69
70
|
var import_abort2 = require('../protocols/abort.js');
|
|
70
71
|
var import_capabilities = require('../utils/capabilities.js');
|
|
71
72
|
var import_errors3 = require('../errors/index.js');
|
|
73
|
+
var import_buyer_account_registry = require('./buyer-account-registry.js');
|
|
72
74
|
var import_account_resolution = require('./account-resolution.js');
|
|
73
75
|
var import_request_normalizer = require('../utils/request-normalizer.js');
|
|
74
76
|
var import_global_async_local_storage = require('../utils/global-async-local-storage.js');
|
|
@@ -83,6 +85,8 @@ var import_augment_response = require('../v2/projection/augment-response.js');
|
|
|
83
85
|
var import_legacy_metadata = require('../v2/projection/legacy-metadata.js');
|
|
84
86
|
var import_types = require('../v2/projection/types.js');
|
|
85
87
|
var import_jcs = require('../utils/jcs.js');
|
|
88
|
+
const SKIP_PRODUCT_CACHE = /* @__PURE__ */ Symbol("adcp.skipProductCache");
|
|
89
|
+
const SKIP_ACCOUNT_REGISTRY_OBSERVATION = /* @__PURE__ */ Symbol("adcp.skipAccountRegistryObservation");
|
|
86
90
|
function presentedStaticTransportCredential(authToken, headers, authProvider) {
|
|
87
91
|
if (authProvider) return false;
|
|
88
92
|
if (authToken) return true;
|
|
@@ -765,6 +769,8 @@ class SingleAgentClient {
|
|
|
765
769
|
};
|
|
766
770
|
}
|
|
767
771
|
this.normalizedAgent = this.normalizeAgentConfig(this.agent);
|
|
772
|
+
if (this.normalizedAgent.oauth_tokens && !this.normalizedAgent.oauth_client_credentials)
|
|
773
|
+
this.initialOAuthGrantMaterial = JSON.stringify(this.normalizedAgent.oauth_tokens);
|
|
768
774
|
this.capabilityEvidenceAuthMaterial = this.currentCapabilityEvidenceAuthMaterial();
|
|
769
775
|
this.executor = new import_TaskExecutor.TaskExecutor({
|
|
770
776
|
workingTimeout: config.workingTimeout || 12e4,
|
|
@@ -833,6 +839,179 @@ class SingleAgentClient {
|
|
|
833
839
|
}
|
|
834
840
|
agent;
|
|
835
841
|
config;
|
|
842
|
+
_accounts;
|
|
843
|
+
accountRegistryExplicitlyAccessed = false;
|
|
844
|
+
initialOAuthGrantMaterial;
|
|
845
|
+
accountCredentialMaterial;
|
|
846
|
+
accountCredentialScope;
|
|
847
|
+
credentialScope(material) {
|
|
848
|
+
if (this.accountCredentialMaterial !== material) {
|
|
849
|
+
this.accountCredentialScope = (0, import_node_crypto.scryptSync)(material, "adcp-sdk/account-registry-scope/v1", 32).toString("hex");
|
|
850
|
+
this.accountCredentialMaterial = material;
|
|
851
|
+
}
|
|
852
|
+
return this.accountCredentialScope;
|
|
853
|
+
}
|
|
854
|
+
accountScope() {
|
|
855
|
+
const agent = this.normalizedAgent ?? this.agent;
|
|
856
|
+
const cc = agent.oauth_client_credentials;
|
|
857
|
+
if (!cc && agent.oauth_tokens && !this.initialOAuthGrantMaterial)
|
|
858
|
+
this.initialOAuthGrantMaterial = JSON.stringify(agent.oauth_tokens);
|
|
859
|
+
const oauthIdentity = cc ? { client_id: cc.client_id, token_endpoint: cc.token_endpoint, scope: cc.scope, resource: cc.resource } : this.initialOAuthGrantMaterial;
|
|
860
|
+
const signing = agent.request_signing;
|
|
861
|
+
const signingIdentity = signing ? signing.kind === "provider" ? {
|
|
862
|
+
keyid: signing.provider.keyid,
|
|
863
|
+
algorithm: signing.provider.algorithm,
|
|
864
|
+
fingerprint: signing.provider.fingerprint,
|
|
865
|
+
purpose: signing.provider.adcpUse
|
|
866
|
+
} : { keyid: signing.kid, algorithm: signing.alg, key: signing.private_key } : void 0;
|
|
867
|
+
const credential = this.config.accountRegistryScope ?? this.credentialScope(
|
|
868
|
+
JSON.stringify({
|
|
869
|
+
token: agent.auth_token,
|
|
870
|
+
oauth: oauthIdentity,
|
|
871
|
+
oauthClient: agent.oauth_client?.client_id,
|
|
872
|
+
oauthResource: agent.oauth_resource,
|
|
873
|
+
headers: agent.headers,
|
|
874
|
+
signing: signingIdentity
|
|
875
|
+
})
|
|
876
|
+
);
|
|
877
|
+
return JSON.stringify([this.agent.agent_uri, this.agent.protocol, credential]);
|
|
878
|
+
}
|
|
879
|
+
get accounts() {
|
|
880
|
+
this.accountRegistryExplicitlyAccessed = true;
|
|
881
|
+
return this.getAccountRegistry();
|
|
882
|
+
}
|
|
883
|
+
getAccountRegistry() {
|
|
884
|
+
return this._accounts ??= new import_buyer_account_registry.BuyerAccountRegistry(
|
|
885
|
+
() => this.accountScope(),
|
|
886
|
+
async (account, options, taskOptions, dispatch) => {
|
|
887
|
+
const caps = await this.getCapabilities(taskOptions);
|
|
888
|
+
const supported = caps.account?.supportedBilling ?? [];
|
|
889
|
+
const billing = options.billing ?? caps.account?.defaultBilling ?? (supported.length === 1 ? supported[0] : void 0);
|
|
890
|
+
if (!billing || supported.length && !supported.includes(billing)) {
|
|
891
|
+
throw new import_errors3.AccountRequiredError(
|
|
892
|
+
"implicit",
|
|
893
|
+
"sync_accounts",
|
|
894
|
+
"Choose a supported billing party before provisioning."
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
return this.syncAccounts(
|
|
898
|
+
{
|
|
899
|
+
...dispatch && { idempotency_key: dispatch.idempotencyKey },
|
|
900
|
+
accounts: [
|
|
901
|
+
{
|
|
902
|
+
...account,
|
|
903
|
+
billing,
|
|
904
|
+
...options.paymentTerms !== void 0 && { payment_terms: options.paymentTerms },
|
|
905
|
+
...options.billingEntity !== void 0 && { billing_entity: options.billingEntity }
|
|
906
|
+
}
|
|
907
|
+
]
|
|
908
|
+
},
|
|
909
|
+
void 0,
|
|
910
|
+
{ ...taskOptions, [SKIP_ACCOUNT_REGISTRY_OBSERVATION]: true },
|
|
911
|
+
dispatch
|
|
912
|
+
);
|
|
913
|
+
},
|
|
914
|
+
this.config.accountStorage,
|
|
915
|
+
async (accountId, options) => {
|
|
916
|
+
const rows = [];
|
|
917
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
918
|
+
let cursor;
|
|
919
|
+
for (let page = 0; page < 100; page++) {
|
|
920
|
+
const result = await this.listAccounts(
|
|
921
|
+
{ account: { account_id: accountId }, ...cursor && { pagination: { cursor } } },
|
|
922
|
+
void 0,
|
|
923
|
+
{ ...options, [SKIP_ACCOUNT_REGISTRY_OBSERVATION]: true }
|
|
924
|
+
);
|
|
925
|
+
if (!result.success || result.status !== "completed" || !result.data || !("accounts" in result.data))
|
|
926
|
+
throw new Error("Account status reconciliation failed.");
|
|
927
|
+
rows.push(...result.data.accounts);
|
|
928
|
+
if (rows.some((row) => row.account_id === accountId) || !result.data.pagination?.has_more)
|
|
929
|
+
return rows.filter((row) => row.account_id === accountId);
|
|
930
|
+
const next = result.data.pagination.cursor;
|
|
931
|
+
if (!next || cursors.has(next)) break;
|
|
932
|
+
cursors.add(next);
|
|
933
|
+
cursor = next;
|
|
934
|
+
}
|
|
935
|
+
throw new Error("Account status reconciliation could not complete pagination.");
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
...this.config.accountRegistryOptions,
|
|
939
|
+
provisionOwnsDispatchBoundary: true,
|
|
940
|
+
maxEntries: this.config.accountRegistryMaxEntries,
|
|
941
|
+
normalizeOptions: async (options, taskOptions) => {
|
|
942
|
+
if (options.billing) return options;
|
|
943
|
+
const caps = await this.getCapabilities(taskOptions);
|
|
944
|
+
const supported = caps.account?.supportedBilling ?? [];
|
|
945
|
+
const billing = caps.account?.defaultBilling ?? (supported.length === 1 ? supported[0] : void 0);
|
|
946
|
+
return { ...options, ...billing && { billing } };
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* The memoized registry backs `resolveAccount()` only when the caller opts
|
|
953
|
+
* in with an account policy or registry configuration. Otherwise
|
|
954
|
+
* `resolveAccount()` keeps the SDK 14.0 sync-on-every-call behavior.
|
|
955
|
+
*/
|
|
956
|
+
accountRegistryOptedIn() {
|
|
957
|
+
return (this.config.accountPolicy ?? "off") !== "off" || this.config.accountStorage !== void 0 || this.config.accountRegistryScope !== void 0 || this.config.accountRegistryMaxEntries !== void 0 || this.config.accountRegistryOptions !== void 0;
|
|
958
|
+
}
|
|
959
|
+
accountRegistryContext(task, params, options) {
|
|
960
|
+
const knownOnly = !this.accountRegistryExplicitlyAccessed && (this.config.accountPolicy ?? "off") === "off" && !this.config.accountStorage;
|
|
961
|
+
if (knownOnly && !this._accounts) return void 0;
|
|
962
|
+
if (options?.[SKIP_ACCOUNT_REGISTRY_OBSERVATION])
|
|
963
|
+
return void 0;
|
|
964
|
+
if (task !== "sync_accounts" && task !== "list_accounts") return void 0;
|
|
965
|
+
return {
|
|
966
|
+
scope: this.accountScope(),
|
|
967
|
+
...knownOnly && { knownOnly: true },
|
|
968
|
+
observationEpoch: this.getAccountRegistry().captureObservation(),
|
|
969
|
+
...task === "list_accounts" && params.account && { refs: [params.account] },
|
|
970
|
+
...task === "sync_accounts" && {
|
|
971
|
+
refs: Array.isArray(params.accounts) ? params.accounts.flatMap((value) => {
|
|
972
|
+
const ref = canonicalAccountRoutingSnapshot(value);
|
|
973
|
+
return ref ? [ref] : [];
|
|
974
|
+
}) : [],
|
|
975
|
+
dryRun: params.dry_run === true
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
async applyAccountPolicy(task, params, options) {
|
|
980
|
+
const policy = this.config.accountPolicy ?? "off";
|
|
981
|
+
const ref = params?.account ?? (typeof params?.account_id === "string" ? { account_id: params.account_id } : void 0);
|
|
982
|
+
if (policy === "off" || options?.skipAccountValidation || options?.preserveGovernedPayload || !ref || task === "list_accounts")
|
|
983
|
+
return params;
|
|
984
|
+
if (typeof ref !== "object" || ref === null || !("account_id" in ref) && (typeof ref.brand?.domain !== "string" || typeof ref.operator !== "string"))
|
|
985
|
+
return params;
|
|
986
|
+
const known = await this.getAccountRegistry().get(ref);
|
|
987
|
+
if (known && !["unknown", "provisioning", "failed_provisioning"].includes(known.status)) {
|
|
988
|
+
if (["create_media_buy", "buy_products", "accept_proposal", "activate_signal", "acquire_rights"].includes(task) && known.status !== "active") {
|
|
989
|
+
if (known.status === "pending_approval") throw new import_errors3.AccountPendingApprovalError(ref, known.account_id);
|
|
990
|
+
if (known.status === "payment_required") throw new import_errors3.AccountPaymentRequiredError();
|
|
991
|
+
throw new import_errors3.AccountSetupRequiredError(
|
|
992
|
+
`Account status is ${known.status}. Refresh it with client.accounts.applyStatusChange or complete seller setup.`
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
return params;
|
|
996
|
+
}
|
|
997
|
+
if (policy === "strict" || ![
|
|
998
|
+
"get_products",
|
|
999
|
+
"list_products",
|
|
1000
|
+
"get_signals",
|
|
1001
|
+
"request_proposals",
|
|
1002
|
+
"refine_proposals",
|
|
1003
|
+
"decline_proposals"
|
|
1004
|
+
].includes(task)) {
|
|
1005
|
+
throw new import_errors3.AccountNotProvisionedError(ref, task);
|
|
1006
|
+
}
|
|
1007
|
+
const caps = await this.getCapabilities(options);
|
|
1008
|
+
if (caps._synthetic || ["get_products", "list_products"].includes(task) && caps.account?.requiredForProducts || params.push_notification_config || !(0, import_schema_loader.schemaAllowsTopLevelField)(task, "brand")) {
|
|
1009
|
+
throw new import_errors3.AccountNotProvisionedError(ref, task);
|
|
1010
|
+
}
|
|
1011
|
+
if (!("brand" in ref)) throw new import_errors3.AccountNotProvisionedError(ref, task);
|
|
1012
|
+
const { account, ...publicRequest } = params;
|
|
1013
|
+
return { ...publicRequest, brand: params.brand ?? ref.brand };
|
|
1014
|
+
}
|
|
836
1015
|
executor;
|
|
837
1016
|
asyncHandler;
|
|
838
1017
|
normalizedAgent;
|
|
@@ -999,6 +1178,7 @@ class SingleAgentClient {
|
|
|
999
1178
|
} = configuredResolverOptions ?? {};
|
|
1000
1179
|
const resolver = new import_server.ResolvedAgentJwksResolver(registration.agentUrl, registration.protocol, {
|
|
1001
1180
|
...resolverOptionsWithoutOperatorContext,
|
|
1181
|
+
legacyWebhookFallback: configuredResolverOptions?.legacyWebhookFallback ?? true,
|
|
1002
1182
|
...delegatedOperatorAuthorization?.brand !== void 0 && {
|
|
1003
1183
|
requiredOperatorBrand: delegatedOperatorAuthorization.brand
|
|
1004
1184
|
},
|
|
@@ -1766,6 +1946,8 @@ class SingleAgentClient {
|
|
|
1766
1946
|
}
|
|
1767
1947
|
return { success: true };
|
|
1768
1948
|
} catch (error) {
|
|
1949
|
+
const signedRejection = (0, import_signedRequestRejection.getSignedRequestRejection)(error);
|
|
1950
|
+
if (signedRejection) throw signedRejection;
|
|
1769
1951
|
if ((0, import_abort.isAbortOrTimeoutError)(error)) {
|
|
1770
1952
|
throw error;
|
|
1771
1953
|
}
|
|
@@ -2078,6 +2260,8 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
2078
2260
|
},
|
|
2079
2261
|
{
|
|
2080
2262
|
jwks: this.webhookJwksFor(registration),
|
|
2263
|
+
publisherPins: await this.config.webhookVerification?.publisherPins?.(registration),
|
|
2264
|
+
onKeyResolutionError: this.config.webhookVerification?.onKeyResolutionError,
|
|
2081
2265
|
replayStore: this.webhookReplayStore,
|
|
2082
2266
|
revocationStore: this.webhookRevocationStore,
|
|
2083
2267
|
...this.config.webhookVerification?.now && { now: this.config.webhookVerification.now },
|
|
@@ -2089,6 +2273,13 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
2089
2273
|
);
|
|
2090
2274
|
} catch (cause) {
|
|
2091
2275
|
if (cause instanceof import_server.WebhookSignatureError) {
|
|
2276
|
+
if (cause.retryable)
|
|
2277
|
+
return {
|
|
2278
|
+
ok: false,
|
|
2279
|
+
code: "webhook_verification_unavailable",
|
|
2280
|
+
message: "Seller signing keys could not be resolved for webhook verification.",
|
|
2281
|
+
cause
|
|
2282
|
+
};
|
|
2092
2283
|
return { ok: false, code: cause.code, message: cause.message, cause };
|
|
2093
2284
|
}
|
|
2094
2285
|
if (cause instanceof import_errors2.AgentResolverError && import_enums.RequestSigningErrorCodeMetadata[cause.code].recovery !== "transient") {
|
|
@@ -2910,6 +3101,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
2910
3101
|
async executeAndHandleWithinDeadline(taskType, handlerName, params, inputHandler, options, transformCompletedResponse, legacyFormatConverter, canonicalRequest, projectionCatalogs) {
|
|
2911
3102
|
(0, import_abort2.throwIfAborted)(options?.signal);
|
|
2912
3103
|
const canonicalCreativeInvocation = CANONICAL_CREATIVE_ACTIVITY_TASKS.has(taskType) || canonicalRequest !== void 0;
|
|
3104
|
+
params = await this.applyAccountPolicy(taskType, params, options);
|
|
2913
3105
|
let normalizedParams = options?.preserveGovernedPayload ? params : (0, import_request_normalizer.normalizeRequestParams)(taskType, params, {
|
|
2914
3106
|
skipIdempotencyAutoInject: options?.skipIdempotencyAutoInject,
|
|
2915
3107
|
skipAccountValidation: options?.skipAccountValidation
|
|
@@ -2993,6 +3185,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
2993
3185
|
serverVersionSynthetic: capabilityDiscoveryContext.capabilities._synthetic
|
|
2994
3186
|
},
|
|
2995
3187
|
productPolicyRequest: productPolicyRequestSnapshot(normalizedParams),
|
|
3188
|
+
accountRegistry: this.accountRegistryContext(taskType, normalizedParams, effectiveOptions),
|
|
2996
3189
|
...projectionCatalogs !== void 0 && { projectionCatalogs },
|
|
2997
3190
|
...routingSnapshot !== void 0 && { routingSnapshot },
|
|
2998
3191
|
...effectiveOptions?.taskId !== void 0 && { optionTaskId: effectiveOptions.taskId },
|
|
@@ -3057,6 +3250,53 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
3057
3250
|
const completionHandlerAlreadyPublished = (0, import_TaskExecutor.hasCompletionHandlerAlreadyPublished)(result);
|
|
3058
3251
|
const settlementAcknowledger = result[import_TaskExecutor.DEFERRED_SETTLEMENT_ACK];
|
|
3059
3252
|
const taskType = context.taskType;
|
|
3253
|
+
if (context.accountRegistry !== void 0 && context.accountRegistry.scope === this.accountScope() && result.success && result.status === "completed" && result.data && typeof result.data === "object" && "accounts" in result.data && Array.isArray(result.data.accounts)) {
|
|
3254
|
+
try {
|
|
3255
|
+
const registry = this.getAccountRegistry();
|
|
3256
|
+
let refs = context.accountRegistry.refs ?? [];
|
|
3257
|
+
let rows = result.data.accounts;
|
|
3258
|
+
if (context.accountRegistry.knownOnly) {
|
|
3259
|
+
refs = (await Promise.all(refs.map(async (ref) => await registry.get(ref) ? ref : void 0))).filter(
|
|
3260
|
+
(ref) => ref !== void 0
|
|
3261
|
+
);
|
|
3262
|
+
if (taskType === "list_accounts") {
|
|
3263
|
+
rows = (await Promise.all(
|
|
3264
|
+
result.data.accounts.map(async (row) => {
|
|
3265
|
+
const ref = canonicalAccountRoutingSnapshot(row);
|
|
3266
|
+
if (ref && await registry.get(ref)) return row;
|
|
3267
|
+
const natural = canonicalAccountRoutingSnapshot({ ...row, account_id: void 0 });
|
|
3268
|
+
return natural && await registry.get(natural) ? row : void 0;
|
|
3269
|
+
})
|
|
3270
|
+
)).filter((row) => row !== void 0);
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
if (context.accountRegistry.scope !== this.accountScope()) return result;
|
|
3274
|
+
if (taskType === "sync_accounts")
|
|
3275
|
+
await registry.observeSync(
|
|
3276
|
+
refs,
|
|
3277
|
+
rows,
|
|
3278
|
+
context.accountRegistry.dryRun,
|
|
3279
|
+
context.accountRegistry.observationEpoch
|
|
3280
|
+
);
|
|
3281
|
+
if (taskType === "list_accounts") {
|
|
3282
|
+
const ref = refs[0];
|
|
3283
|
+
await registry.observeList(
|
|
3284
|
+
rows,
|
|
3285
|
+
ref && "account_id" in ref && (!result.data.pagination?.has_more || result.data.accounts.some((row) => row.account_id === ref.account_id)) ? ref.account_id : void 0,
|
|
3286
|
+
context.accountRegistry.observationEpoch
|
|
3287
|
+
);
|
|
3288
|
+
}
|
|
3289
|
+
} catch {
|
|
3290
|
+
result.debug_logs = [
|
|
3291
|
+
...result.debug_logs ?? [],
|
|
3292
|
+
{
|
|
3293
|
+
level: "warn",
|
|
3294
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3295
|
+
message: "Account registry observation failed. The seller operation completed; reconcile with listAccounts before relying on the registry."
|
|
3296
|
+
}
|
|
3297
|
+
];
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3060
3300
|
const resumedOptions = {
|
|
3061
3301
|
...options ?? {},
|
|
3062
3302
|
...context.optionTaskId !== void 0 && { taskId: context.optionTaskId },
|
|
@@ -4076,7 +4316,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4076
4316
|
);
|
|
4077
4317
|
return (0, import_task_deadline.withTaskDeadline)(snapshotTaskOptions(taskOptions), async (effectiveOptions) => {
|
|
4078
4318
|
this.assertRequestSupportedByConfiguredVersion("get_products", params, effectiveOptions);
|
|
4079
|
-
let request = params;
|
|
4319
|
+
let request = await this.applyAccountPolicy("get_products", params, effectiveOptions);
|
|
4080
4320
|
const legacyAccountId = request.account_id;
|
|
4081
4321
|
const accountReference = request.account ?? (typeof legacyAccountId === "string" && legacyAccountId ? { account_id: legacyAccountId } : void 0);
|
|
4082
4322
|
if (!request.account && typeof legacyAccountId === "string" && legacyAccountId) {
|
|
@@ -4113,10 +4353,36 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4113
4353
|
request = { ...request, buying_mode: "wholesale" };
|
|
4114
4354
|
}
|
|
4115
4355
|
const account = canonicalAccountRoutingSnapshot(accountReference);
|
|
4116
|
-
|
|
4356
|
+
const cache = !effectiveOptions.skipRequestValidation && !effectiveOptions.preserveGovernedPayload && !inputHandler && !request.push_notification_config && !this.config.webhookUrlTemplate && !this.config.handlers?.onGetProductsStatusChange ? this.config.productCache : void 0;
|
|
4357
|
+
const cacheScope = cache ? JSON.stringify([
|
|
4358
|
+
this.accountScope(),
|
|
4359
|
+
this.resolvedAdcpVersion,
|
|
4360
|
+
this.capabilityEvidenceScopeKey,
|
|
4361
|
+
effectiveOptions.contextId
|
|
4362
|
+
]) : "";
|
|
4363
|
+
const cacheParams = request;
|
|
4364
|
+
const skipCacheRead = options?.[SKIP_PRODUCT_CACHE];
|
|
4365
|
+
if (cache && !skipCacheRead && cacheParams.if_wholesale_feed_version === void 0 && cacheParams.if_pricing_version === void 0) {
|
|
4366
|
+
const hit = cache.read(cacheScope, cacheParams);
|
|
4367
|
+
if (hit) {
|
|
4368
|
+
(0, import_abort2.throwIfAborted)(effectiveOptions.signal);
|
|
4369
|
+
if (hit.success && hit.status === "completed")
|
|
4370
|
+
this.rememberCanonicalProductRoutes(hit.data.products ?? [], account, hit.data.products ?? []);
|
|
4371
|
+
return (0, import_match.attachMatch)(
|
|
4372
|
+
await this.applyProductPropertyPolicy(
|
|
4373
|
+
hit,
|
|
4374
|
+
"get_products",
|
|
4375
|
+
productPolicyRequestSnapshot(request),
|
|
4376
|
+
effectiveOptions.signal
|
|
4377
|
+
)
|
|
4378
|
+
);
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4381
|
+
const conditionalSnapshot = skipCacheRead ? void 0 : cache?.read(cacheScope, cacheParams, true);
|
|
4382
|
+
const result = await this.executeAndHandle(
|
|
4117
4383
|
"get_products",
|
|
4118
4384
|
"onGetProductsStatusChange",
|
|
4119
|
-
request,
|
|
4385
|
+
cache && !skipCacheRead ? cache.conditionalParams(cacheScope, cacheParams) : request,
|
|
4120
4386
|
inputHandler,
|
|
4121
4387
|
effectiveOptions,
|
|
4122
4388
|
(data) => {
|
|
@@ -4134,6 +4400,37 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4134
4400
|
void 0,
|
|
4135
4401
|
projectionCatalogs
|
|
4136
4402
|
);
|
|
4403
|
+
const finishCache = async (completed) => {
|
|
4404
|
+
if (!cache) return completed;
|
|
4405
|
+
const cachedResult = cache.write(cacheScope, cacheParams, completed, conditionalSnapshot);
|
|
4406
|
+
if (cachedResult.success && cachedResult.status === "completed") {
|
|
4407
|
+
if (!skipCacheRead && cacheParams.if_wholesale_feed_version === void 0 && cacheParams.if_pricing_version === void 0 && cachedResult.data.unchanged === true) {
|
|
4408
|
+
return this.getProducts(params, inputHandler, {
|
|
4409
|
+
...options,
|
|
4410
|
+
...effectiveOptions,
|
|
4411
|
+
[SKIP_PRODUCT_CACHE]: true
|
|
4412
|
+
});
|
|
4413
|
+
}
|
|
4414
|
+
this.rememberCanonicalProductRoutes(
|
|
4415
|
+
cachedResult.data.products ?? [],
|
|
4416
|
+
account,
|
|
4417
|
+
cachedResult.data.products ?? []
|
|
4418
|
+
);
|
|
4419
|
+
}
|
|
4420
|
+
if (cachedResult.submitted) {
|
|
4421
|
+
const submitted = cachedResult.submitted;
|
|
4422
|
+
cachedResult.submitted = {
|
|
4423
|
+
...submitted,
|
|
4424
|
+
waitForCompletion: (interval, signal) => submitted.waitForCompletion(interval, signal).then(finishCache)
|
|
4425
|
+
};
|
|
4426
|
+
}
|
|
4427
|
+
if (cachedResult.deferred) {
|
|
4428
|
+
const deferred = cachedResult.deferred;
|
|
4429
|
+
cachedResult.deferred = { ...deferred, resume: (input) => deferred.resume(input).then(finishCache) };
|
|
4430
|
+
}
|
|
4431
|
+
return (0, import_match.attachMatch)(cachedResult);
|
|
4432
|
+
};
|
|
4433
|
+
return finishCache(result);
|
|
4137
4434
|
});
|
|
4138
4435
|
}
|
|
4139
4436
|
/** Discover products through the compact AdCP 3.2 catalog task. */
|
|
@@ -4872,7 +5169,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4872
5169
|
const seenCursors = /* @__PURE__ */ new Set();
|
|
4873
5170
|
let cursor;
|
|
4874
5171
|
for (let page = 0; page < 100; page++) {
|
|
4875
|
-
const
|
|
5172
|
+
const result = await this.listAccounts(
|
|
4876
5173
|
{
|
|
4877
5174
|
status: "active",
|
|
4878
5175
|
sandbox: hints.sandbox ?? false,
|
|
@@ -4881,13 +5178,13 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4881
5178
|
void 0,
|
|
4882
5179
|
effectiveOptions
|
|
4883
5180
|
);
|
|
4884
|
-
onTaskResult?.(
|
|
4885
|
-
if (!
|
|
5181
|
+
onTaskResult?.(result);
|
|
5182
|
+
if (!result.success || result.status !== "completed" || !result.data || !("accounts" in result.data) || !Array.isArray(result.data.accounts)) {
|
|
4886
5183
|
throw new Error("list_accounts did not return a completed account list.");
|
|
4887
5184
|
}
|
|
4888
|
-
accounts.push(...
|
|
4889
|
-
if (!
|
|
4890
|
-
const nextCursor =
|
|
5185
|
+
accounts.push(...result.data.accounts);
|
|
5186
|
+
if (!result.data.pagination?.has_more) return (0, import_account_resolution.selectListedAccount)(accounts, hints);
|
|
5187
|
+
const nextCursor = result.data.pagination.cursor;
|
|
4891
5188
|
if (!nextCursor || seenCursors.has(nextCursor)) break;
|
|
4892
5189
|
seenCursors.add(nextCursor);
|
|
4893
5190
|
cursor = nextCursor;
|
|
@@ -4954,42 +5251,84 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4954
5251
|
`Choose a supported billing party for sync_accounts (seller supports: ${supportedBilling.join(", ") || "(none)"}).`
|
|
4955
5252
|
);
|
|
4956
5253
|
}
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
5254
|
+
if (!this.accountRegistryOptedIn()) {
|
|
5255
|
+
const result = await this.syncAccounts(
|
|
5256
|
+
{
|
|
5257
|
+
accounts: [
|
|
5258
|
+
{
|
|
5259
|
+
...account,
|
|
5260
|
+
billing,
|
|
5261
|
+
...hints.paymentTerms !== void 0 && { payment_terms: hints.paymentTerms },
|
|
5262
|
+
...hints.billingEntity !== void 0 && { billing_entity: hints.billingEntity }
|
|
5263
|
+
}
|
|
5264
|
+
]
|
|
5265
|
+
},
|
|
5266
|
+
void 0,
|
|
5267
|
+
effectiveOptions
|
|
5268
|
+
);
|
|
5269
|
+
onTaskResult?.(result);
|
|
5270
|
+
if (!result.success || result.status !== "completed" || !result.data || !("accounts" in result.data) || !Array.isArray(result.data.accounts)) {
|
|
5271
|
+
throw new Error("sync_accounts did not return a completed account result.");
|
|
5272
|
+
}
|
|
5273
|
+
const syncedRow = result.data.accounts.find(
|
|
5274
|
+
(row) => row.brand?.domain === hints.brand.domain && row.operator === hints.operator && (!hints.brand.brand_id || row.brand.brand_id === hints.brand.brand_id) && (0, import_account_resolution.sameCountrySet)(hints.brand.countries, row.brand.countries) && (!hints.operatorUnit || row.operator_unit?.id === hints.operatorUnit.id) && (!hints.currency || row.currency === hints.currency) && (!hints.timezone || row.timezone === hints.timezone) && (row.sandbox === void 0 || row.sandbox === true === (hints.sandbox === true))
|
|
5275
|
+
);
|
|
5276
|
+
if (syncedRow?.status === "pending_approval") {
|
|
5277
|
+
throw new import_errors3.AccountPendingApprovalError(account, syncedRow.account_id);
|
|
5278
|
+
}
|
|
5279
|
+
if (!syncedRow || syncedRow.action === "failed" || syncedRow.status !== "active") {
|
|
5280
|
+
throw new import_errors3.AccountRequiredError(
|
|
5281
|
+
"implicit",
|
|
5282
|
+
"resolveAccount",
|
|
5283
|
+
"sync_accounts did not establish an active account for the requested brand and operator."
|
|
5284
|
+
);
|
|
5285
|
+
}
|
|
5286
|
+
return account;
|
|
4978
5287
|
}
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
5288
|
+
let synced;
|
|
5289
|
+
try {
|
|
5290
|
+
synced = await this.getAccountRegistry().ensure(
|
|
5291
|
+
account,
|
|
5292
|
+
{
|
|
5293
|
+
billing,
|
|
5294
|
+
paymentTerms: hints.paymentTerms,
|
|
5295
|
+
billingEntity: hints.billingEntity
|
|
5296
|
+
},
|
|
5297
|
+
effectiveOptions,
|
|
5298
|
+
onTaskResult
|
|
4984
5299
|
);
|
|
5300
|
+
} catch (error) {
|
|
5301
|
+
if (error instanceof import_errors3.AccountNotFoundError)
|
|
5302
|
+
throw new import_errors3.AccountRequiredError("implicit", "resolveAccount", error.message);
|
|
5303
|
+
throw error;
|
|
4985
5304
|
}
|
|
5305
|
+
if (synced.status === "pending_approval") throw new import_errors3.AccountPendingApprovalError(account, synced.account_id);
|
|
5306
|
+
if (synced.status !== "active")
|
|
5307
|
+
throw new import_errors3.AccountRequiredError("implicit", "resolveAccount", "The account is not active.");
|
|
4986
5308
|
return account;
|
|
4987
5309
|
});
|
|
4988
5310
|
}
|
|
4989
5311
|
/**
|
|
4990
5312
|
* Sync accounts
|
|
4991
5313
|
*/
|
|
4992
|
-
async syncAccounts(params, inputHandler, options) {
|
|
5314
|
+
async syncAccounts(params, inputHandler, options, dispatch) {
|
|
5315
|
+
if (dispatch)
|
|
5316
|
+
return this.executeTaskUnprojected(
|
|
5317
|
+
"sync_accounts",
|
|
5318
|
+
params,
|
|
5319
|
+
inputHandler,
|
|
5320
|
+
options,
|
|
5321
|
+
"onSyncAccountsStatusChange",
|
|
5322
|
+
Object.assign(
|
|
5323
|
+
async (effectiveParams) => {
|
|
5324
|
+
if (dispatch.requireIdempotencyKey !== false && effectiveParams.idempotency_key !== dispatch.idempotencyKey)
|
|
5325
|
+
throw new import_errors.ConfigurationError("Account provisioning idempotency key changed before dispatch.");
|
|
5326
|
+
await dispatch.beforeDispatch();
|
|
5327
|
+
return { action: "dispatch_ready" };
|
|
5328
|
+
},
|
|
5329
|
+
{ terminalSettlement: "executor" }
|
|
5330
|
+
)
|
|
5331
|
+
);
|
|
4993
5332
|
return this.executeAndHandle(
|
|
4994
5333
|
"sync_accounts",
|
|
4995
5334
|
"onSyncAccountsStatusChange",
|
|
@@ -5253,6 +5592,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5253
5592
|
const startTime = Date.now();
|
|
5254
5593
|
let detectedServerVersion;
|
|
5255
5594
|
let detectedServerVersionSynthetic;
|
|
5595
|
+
params = await this.applyAccountPolicy(taskName, params, options);
|
|
5256
5596
|
try {
|
|
5257
5597
|
const normalizedParams = options?.preserveGovernedPayload ? params : (0, import_request_normalizer.normalizeRequestParams)(taskName, params, {
|
|
5258
5598
|
skipIdempotencyAutoInject: options?.skipIdempotencyAutoInject,
|
|
@@ -5318,6 +5658,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5318
5658
|
serverVersionSynthetic: capabilityDiscoveryContext.capabilities._synthetic
|
|
5319
5659
|
},
|
|
5320
5660
|
productPolicyRequest: productPolicyRequestSnapshot(normalizedParams),
|
|
5661
|
+
accountRegistry: this.accountRegistryContext(taskName, normalizedParams, effectiveOptions),
|
|
5321
5662
|
...effectiveOptions?.taskId !== void 0 && { optionTaskId: effectiveOptions.taskId },
|
|
5322
5663
|
...effectiveOptions?.contextId !== void 0 && { optionContextId: effectiveOptions.contextId }
|
|
5323
5664
|
};
|