@adcp/sdk 17.0.0-beta.13 → 17.0.0-beta.16
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/brand/index.d.mts +2 -0
- package/dist/lib/brand/index.d.ts +2 -0
- package/dist/lib/brand/index.js +3 -0
- package/dist/lib/brand/index.mjs +2 -0
- package/dist/lib/brand/selection.d.mts +13 -0
- package/dist/lib/brand/selection.d.ts +13 -0
- package/dist/lib/brand/selection.js +83 -0
- package/dist/lib/brand/selection.mjs +59 -0
- package/dist/lib/index.d.mts +2 -2
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.mjs +2 -0
- package/dist/lib/registry/types.d.mts +5 -0
- package/dist/lib/registry/types.d.ts +5 -0
- package/dist/lib/registry/types.generated.d.ts +4 -0
- package/dist/lib/server/decisioning/runtime/from-platform.js +12 -2
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +12 -2
- package/dist/lib/server/test-controller.d.mts +9 -35
- package/dist/lib/server/test-controller.d.ts +9 -35
- package/dist/lib/server/test-controller.js +4 -0
- package/dist/lib/server/test-controller.mjs +4 -0
- package/dist/lib/testing/comply-controller.d.mts +7 -10
- package/dist/lib/testing/comply-controller.d.ts +7 -10
- package/dist/lib/testing/reporting/doctor.js +2 -1
- package/dist/lib/testing/reporting/doctor.mjs +2 -1
- package/dist/lib/testing/storyboard/account-policy.d.mts +42 -0
- package/dist/lib/testing/storyboard/account-policy.d.ts +42 -0
- package/dist/lib/testing/storyboard/account-policy.js +41 -2
- package/dist/lib/testing/storyboard/account-policy.mjs +38 -1
- package/dist/lib/testing/storyboard/path.d.mts +6 -0
- package/dist/lib/testing/storyboard/path.d.ts +6 -0
- package/dist/lib/testing/storyboard/path.js +22 -0
- package/dist/lib/testing/storyboard/path.mjs +21 -0
- package/dist/lib/testing/storyboard/request-builder.js +1 -1
- package/dist/lib/testing/storyboard/request-builder.mjs +1 -1
- package/dist/lib/testing/storyboard/runner-owned-task.d.mts +3 -0
- package/dist/lib/testing/storyboard/runner-owned-task.d.ts +3 -0
- package/dist/lib/testing/storyboard/runner-owned-task.js +38 -0
- package/dist/lib/testing/storyboard/runner-owned-task.mjs +13 -0
- package/dist/lib/testing/storyboard/runner.d.mts +1 -42
- package/dist/lib/testing/storyboard/runner.d.ts +1 -42
- package/dist/lib/testing/storyboard/runner.js +14 -47
- package/dist/lib/testing/storyboard/runner.mjs +6 -39
- package/dist/lib/testing/storyboard/seeding.js +169 -2
- package/dist/lib/testing/storyboard/seeding.mjs +169 -2
- package/dist/lib/testing/storyboard/types.d.mts +4 -2
- package/dist/lib/testing/storyboard/types.d.ts +4 -2
- package/dist/lib/testing/storyboard/types.js +1 -0
- package/dist/lib/testing/storyboard/types.mjs +1 -0
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/testing/storyboard/validations.js +60 -1
- package/dist/lib/testing/storyboard/validations.mjs +61 -1
- package/dist/lib/testing/storyboard/webhook-assertions.js +10 -9
- package/dist/lib/testing/storyboard/webhook-assertions.mjs +11 -10
- package/dist/lib/v2/projection/creative-delivery.js +62 -16
- package/dist/lib/v2/projection/creative-delivery.mjs +62 -16
- 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/docs/TYPE-SUMMARY.md +1 -1
- package/docs/guides/BRAND-ENTRY-SELECTION.md +56 -0
- package/docs/guides/REPORTING-LEDGER.md +142 -12
- package/docs/guides/REPORTING-OPERATIONS.md +18 -5
- package/docs/guides/VALIDATE-YOUR-AGENT.md +44 -0
- package/docs/llms.txt +1 -1
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-reporting-row-storage-alignment.md +4 -2
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var runner_exports = {};
|
|
30
30
|
__export(runner_exports, {
|
|
31
|
-
BRAND_SUBJECT_TASKS: () => BRAND_SUBJECT_TASKS,
|
|
31
|
+
BRAND_SUBJECT_TASKS: () => import_account_policy2.BRAND_SUBJECT_TASKS,
|
|
32
32
|
__defaultAuthHeadersForRawProbeForTest: () => __defaultAuthHeadersForRawProbeForTest,
|
|
33
33
|
__filterResponseHeadersForTest: () => __filterResponseHeadersForTest,
|
|
34
34
|
__protectedToolCandidatesForTest: () => __protectedToolCandidatesForTest,
|
|
@@ -36,7 +36,7 @@ __export(runner_exports, {
|
|
|
36
36
|
__selectProtectedToolTargetForTest: () => __selectProtectedToolTargetForTest,
|
|
37
37
|
__sessionControlCredentialsForTest: () => __sessionControlCredentialsForTest,
|
|
38
38
|
applyAdcpVersionRunOptions: () => applyAdcpVersionRunOptions,
|
|
39
|
-
applyBrandInvariant: () => applyBrandInvariant,
|
|
39
|
+
applyBrandInvariant: () => import_account_policy2.applyBrandInvariant,
|
|
40
40
|
applyDisableSandboxHint: () => applyDisableSandboxHint,
|
|
41
41
|
applyFixtureBindingsSafely: () => applyFixtureBindingsSafely,
|
|
42
42
|
applyIdempotencyInvariant: () => applyIdempotencyInvariant,
|
|
@@ -71,6 +71,7 @@ var import_node_fs = require("node:fs");
|
|
|
71
71
|
var import_node_path = require("node:path");
|
|
72
72
|
var import_node_util = require("node:util");
|
|
73
73
|
var import_account_policy = require('./account-policy.js');
|
|
74
|
+
var import_runner_owned_task = require('./runner-owned-task.js');
|
|
74
75
|
var import_creative_build_probe = require('./creative-build-probe.js');
|
|
75
76
|
var import_client = require('../client.js');
|
|
76
77
|
var import_protocols = require('../../protocols/index.js');
|
|
@@ -128,6 +129,7 @@ var import_acceptance_policy_discovery = require('./acceptance-policy-discovery.
|
|
|
128
129
|
var import_agent_routing = require('./agent-routing.js');
|
|
129
130
|
var import_types = require('./types.js');
|
|
130
131
|
var import_assertions = require('./assertions.js');
|
|
132
|
+
var import_account_policy2 = require('./account-policy.js');
|
|
131
133
|
const PREPARED_TRUSTED_MATCH_PUBLISHER_AUTH = /* @__PURE__ */ Symbol("preparedTrustedMatchPublisherAuth");
|
|
132
134
|
function getPreparedTrustedMatchPublisherAuth(options) {
|
|
133
135
|
return options[PREPARED_TRUSTED_MATCH_PUBLISHER_AUTH];
|
|
@@ -249,10 +251,6 @@ const CANONICAL_SKIP_DETAILS = {
|
|
|
249
251
|
signing_transport_unavailable: "signing_transport_unavailable"
|
|
250
252
|
};
|
|
251
253
|
const MCP_SESSION_PROBE_REQUEST_TIMEOUT_MS = 5e3;
|
|
252
|
-
const REPLAY_WEBHOOK_VECTOR_TASK = "replay_webhook_vector";
|
|
253
|
-
function isRunnerOwnedTask(task) {
|
|
254
|
-
return task === import_loader.VALIDATION_ONLY_TASK || task === import_types.MCP_SESSION_PROBE_TASK || task === "assert_contribution" || task === REPLAY_WEBHOOK_VECTOR_TASK || import_trusted_match_publisher_auth.TRUSTED_MATCH_PUBLISHER_AUTH_TASKS.has(task) || import_probes.PROBE_TASKS.has(task) || import_webhook_assertions.WEBHOOK_ASSERTION_TASKS.has(task);
|
|
255
|
-
}
|
|
256
254
|
const REPLAY_TRUSTED_MATCH_CONTEXT_VECTOR_TASK = "replay_trusted_match_context_vector";
|
|
257
255
|
const WEBHOOK_REPLAY_DEFAULT_TIMEOUT_MS = 1e4;
|
|
258
256
|
function selectionForProbeSkip(reason, detail) {
|
|
@@ -1148,6 +1146,7 @@ function buildPhaseCapabilitySkippedSteps(storyboard, phase, detail, context) {
|
|
|
1148
1146
|
const REQUIREMENT_TO_SKIP_REASON = {
|
|
1149
1147
|
controller: "missing_test_controller",
|
|
1150
1148
|
collect_product_pages_runner: "requirement_unmet",
|
|
1149
|
+
field_excludes_runner: "requirement_unmet",
|
|
1151
1150
|
seeded_state: "requirement_unmet",
|
|
1152
1151
|
real_wire: "requirement_unmet",
|
|
1153
1152
|
webhook_receiver: "requirement_unmet",
|
|
@@ -1281,6 +1280,7 @@ async function checkRequires(requires, storyboard, options, profile, precomputed
|
|
|
1281
1280
|
continue;
|
|
1282
1281
|
}
|
|
1283
1282
|
switch (requirement) {
|
|
1283
|
+
case "field_excludes_runner":
|
|
1284
1284
|
case "collect_product_pages_runner":
|
|
1285
1285
|
break;
|
|
1286
1286
|
case "controller": {
|
|
@@ -1436,7 +1436,7 @@ function detectImplicitRequires(storyboard, options = {}) {
|
|
|
1436
1436
|
if (!needsSigner && step.task === "request_signing_probe") {
|
|
1437
1437
|
needsSigner = true;
|
|
1438
1438
|
}
|
|
1439
|
-
if (!needsWebhookReplayReceiver && stepContractInScope && step.task === REPLAY_WEBHOOK_VECTOR_TASK) {
|
|
1439
|
+
if (!needsWebhookReplayReceiver && stepContractInScope && step.task === import_runner_owned_task.REPLAY_WEBHOOK_VECTOR_TASK) {
|
|
1440
1440
|
needsWebhookReplayReceiver = true;
|
|
1441
1441
|
}
|
|
1442
1442
|
if (!needsTrustedMatchContextRouterRunner && stepContractInScope && step.task === REPLAY_TRUSTED_MATCH_CONTEXT_VECTOR_TASK) {
|
|
@@ -3430,7 +3430,7 @@ async function executeStoryboardPass(agentUrls, storyboard, options, dispatchOff
|
|
|
3430
3430
|
const cascade = step.stateful ? cascadeForPhase(phase, priorPhaseIds) : { tripped: false };
|
|
3431
3431
|
if (cascade.tripped && step.stateful && routedCapabilityDetail === void 0) {
|
|
3432
3432
|
const resolvedTask = (0, import_agent_routing.resolveTaskName)(step, selectedOptions);
|
|
3433
|
-
const missingTool = selectedOptions.agentTools && (routingContext && step.requires_tool && !selectedOptions.agentTools.includes(step.requires_tool) ? step.requires_tool : resolvedTask && !isRunnerOwnedTask(resolvedTask) && !selectedOptions.agentTools.includes(resolvedTask) ? resolvedTask : void 0);
|
|
3433
|
+
const missingTool = selectedOptions.agentTools && (routingContext && step.requires_tool && !selectedOptions.agentTools.includes(step.requires_tool) ? step.requires_tool : resolvedTask && !(0, import_runner_owned_task.isRunnerOwnedTask)(resolvedTask) && !selectedOptions.agentTools.includes(resolvedTask) ? resolvedTask : void 0);
|
|
3434
3434
|
if (missingTool) {
|
|
3435
3435
|
const missingReason = routingContext && missingTool === "comply_test_controller" ? "missing_test_controller" : "missing_tool";
|
|
3436
3436
|
const toolDetail = `Agent did not advertise tool "${missingTool}"; agent tools: [${selectedOptions.agentTools.join(", ")}].`;
|
|
@@ -3461,7 +3461,7 @@ async function executeStoryboardPass(agentUrls, storyboard, options, dispatchOff
|
|
|
3461
3461
|
const trigger = cascade.trigger;
|
|
3462
3462
|
let detail = trigger ? trigger.substitution_chain ? `Skipped: prior stateful step "${trigger.stepId}" skipped (${trigger.reason}); ${trigger.substitution_chain}; state never materialized.` : `Skipped: prior stateful step "${trigger.stepId}" skipped (${trigger.reason}); state never materialized.` : "Skipped: prior stateful step failed.";
|
|
3463
3463
|
let capabilityUnavailable = trigger?.capabilityUnavailable === true;
|
|
3464
|
-
if (capabilityUnavailable && routingContext && !import_trusted_match_publisher_auth.TRUSTED_MATCH_PUBLISHER_AUTH_TASKS.has(step.task) && !import_probes.PROBE_TASKS.has(step.task) && !import_webhook_assertions.WEBHOOK_ASSERTION_TASKS.has(step.task) && step.task !== REPLAY_WEBHOOK_VECTOR_TASK && (!step.requires_contract || (selectedOptions.contracts ?? []).includes(step.requires_contract))) {
|
|
3464
|
+
if (capabilityUnavailable && routingContext && !import_trusted_match_publisher_auth.TRUSTED_MATCH_PUBLISHER_AUTH_TASKS.has(step.task) && !import_probes.PROBE_TASKS.has(step.task) && !import_webhook_assertions.WEBHOOK_ASSERTION_TASKS.has(step.task) && step.task !== import_runner_owned_task.REPLAY_WEBHOOK_VECTOR_TASK && (!step.requires_contract || (selectedOptions.contracts ?? []).includes(step.requires_contract))) {
|
|
3465
3465
|
const hardKeys = unavailableContextKeysForPhase(phase, priorPhaseIds, missingPrerequisiteContextKeysByPhase);
|
|
3466
3466
|
if (hardKeys.size > 0) {
|
|
3467
3467
|
const effectiveRequest = buildEffectiveStepRequest(
|
|
@@ -4788,7 +4788,7 @@ async function runStoryboardStepBody(agentUrl, storyboard, stepId, options) {
|
|
|
4788
4788
|
if (storyboard.prerequisites?.controller_seeding === true && storyboard.fixture_resolution === void 0 && options.skip_controller_seeding !== true && runState.preparedFixtures === void 0 && options.agentTools !== void 0 && !options.agentTools.includes("comply_test_controller")) {
|
|
4789
4789
|
const seeds = (0, import_seeding.buildSeedCalls)(storyboard.fixtures);
|
|
4790
4790
|
const resolvedTask = (0, import_agent_routing.resolveTaskName)(found.step, options);
|
|
4791
|
-
const intrinsicSkip = found.step.requires_tool !== void 0 && !options.agentTools.includes(found.step.requires_tool) || found.step.requires_contract !== void 0 && !(options.contracts ?? []).includes(found.step.requires_contract) || resolvedTask !== void 0 && !isRunnerOwnedTask(resolvedTask) && !options.agentTools.includes(resolvedTask);
|
|
4791
|
+
const intrinsicSkip = found.step.requires_tool !== void 0 && !options.agentTools.includes(found.step.requires_tool) || found.step.requires_contract !== void 0 && !(options.contracts ?? []).includes(found.step.requires_contract) || resolvedTask !== void 0 && !(0, import_runner_owned_task.isRunnerOwnedTask)(resolvedTask) && !options.agentTools.includes(resolvedTask);
|
|
4792
4792
|
if (seeds.length > 0 && !seeds.some((seed) => seed.authoring_error !== void 0) && resolvedTask !== void 0 && resolvedTask !== "get_adcp_capabilities" && !intrinsicSkip) {
|
|
4793
4793
|
const capabilityDetail = collectPhaseCapabilitySkipDetails(
|
|
4794
4794
|
storyboard,
|
|
@@ -5004,17 +5004,17 @@ function buildStepRequest(step, effectiveStep, context, options, runnerVars) {
|
|
|
5004
5004
|
request = (0, import_context.applyContextInputs)(request, step.context_inputs, context);
|
|
5005
5005
|
}
|
|
5006
5006
|
if (governedFixture) {
|
|
5007
|
-
request = applyBrandInvariant(request, options, effectiveStep.task, { omit_account: true });
|
|
5007
|
+
request = (0, import_account_policy.applyBrandInvariant)(request, options, effectiveStep.task, { omit_account: true });
|
|
5008
5008
|
return options.disable_sandbox === true ? applyDisableSandboxHint(request, effectiveStep.task) : request;
|
|
5009
5009
|
}
|
|
5010
|
-
request = applyBrandInvariant(request, options, effectiveStep.task, { omit_account: step.omit_account });
|
|
5010
|
+
request = (0, import_account_policy.applyBrandInvariant)(request, options, effectiveStep.task, { omit_account: step.omit_account });
|
|
5011
5011
|
if (options.disable_sandbox === true) {
|
|
5012
5012
|
request = applyDisableSandboxHint(request, effectiveStep.task);
|
|
5013
5013
|
}
|
|
5014
5014
|
request = applyIdempotencyInvariant(request, effectiveStep.task, step);
|
|
5015
5015
|
if (payloadBoundGovernance && effectiveStep.task === "check_governance" && request.phase !== "delivery" && request.payload !== null && typeof request.payload === "object" && !Array.isArray(request.payload)) {
|
|
5016
5016
|
const toolName = typeof request.tool === "string" ? request.tool : void 0;
|
|
5017
|
-
const brandedPayload = applyBrandInvariant(request.payload, options, toolName, {
|
|
5017
|
+
const brandedPayload = (0, import_account_policy.applyBrandInvariant)(request.payload, options, toolName, {
|
|
5018
5018
|
omit_account: true
|
|
5019
5019
|
});
|
|
5020
5020
|
let payload = prepareGovernedStoryboardWireArgs(
|
|
@@ -5072,7 +5072,7 @@ async function executeStep(client, step, storyboardId, phaseId, context, allStep
|
|
|
5072
5072
|
if (import_webhook_assertions.WEBHOOK_ASSERTION_TASKS.has(step.task)) {
|
|
5073
5073
|
return (0, import_webhook_assertions.executeWebhookAssertionStep)(step, phaseId, context, allSteps, options, runState);
|
|
5074
5074
|
}
|
|
5075
|
-
if (step.task === REPLAY_WEBHOOK_VECTOR_TASK) {
|
|
5075
|
+
if (step.task === import_runner_owned_task.REPLAY_WEBHOOK_VECTOR_TASK) {
|
|
5076
5076
|
return executeReplayWebhookVectorStep(step, phaseId, context, allSteps, options, runState);
|
|
5077
5077
|
}
|
|
5078
5078
|
if (step.requires_contract && !new Set(options.contracts ?? []).has(step.requires_contract)) {
|
|
@@ -8230,39 +8230,6 @@ function evalContributesIf(expr, priorStepResults) {
|
|
|
8230
8230
|
const prior = priorStepResults.get(stepId);
|
|
8231
8231
|
return !!prior?.passed && !prior.skipped;
|
|
8232
8232
|
}
|
|
8233
|
-
const BRAND_SUBJECT_TASKS = /* @__PURE__ */ new Set(["request_account"]);
|
|
8234
|
-
function applyBrandInvariant(request, options, taskName, stepFlags) {
|
|
8235
|
-
if (!options.brand && !options.brand_manifest) return request;
|
|
8236
|
-
if (taskName !== void 0 && BRAND_SUBJECT_TASKS.has(taskName)) return request;
|
|
8237
|
-
const brand = (0, import_client2.resolveBrand)(options);
|
|
8238
|
-
const topBrandOk = !taskName || (0, import_schema_loader.schemaAllowsTopLevelField)(taskName, "brand");
|
|
8239
|
-
const topAccountOk = !taskName || (0, import_schema_loader.schemaAllowsTopLevelField)(taskName, "account");
|
|
8240
|
-
const result = { ...request };
|
|
8241
|
-
if (topBrandOk) result.brand = brand;
|
|
8242
|
-
if (stepFlags?.omit_account) return result;
|
|
8243
|
-
if ("account" in request) {
|
|
8244
|
-
const existingAccount = request.account;
|
|
8245
|
-
if (existingAccount && typeof existingAccount === "object" && !Array.isArray(existingAccount)) {
|
|
8246
|
-
const acct = existingAccount;
|
|
8247
|
-
const isNaturalKeyVariant = "brand" in acct || "operator" in acct;
|
|
8248
|
-
if (isNaturalKeyVariant) {
|
|
8249
|
-
const preserveWholesaleAccountBrand = (taskName === "get_products" && request.buying_mode === "wholesale" || taskName === "get_signals" && request.discovery_mode === "wholesale") && acct.brand !== void 0;
|
|
8250
|
-
const merged = {
|
|
8251
|
-
...acct,
|
|
8252
|
-
brand: preserveWholesaleAccountBrand ? acct.brand : brand
|
|
8253
|
-
};
|
|
8254
|
-
const accountBrand = merged.brand;
|
|
8255
|
-
if (typeof merged.operator !== "string" && typeof accountBrand?.domain === "string") {
|
|
8256
|
-
merged.operator = accountBrand.domain;
|
|
8257
|
-
}
|
|
8258
|
-
result.account = merged;
|
|
8259
|
-
}
|
|
8260
|
-
}
|
|
8261
|
-
} else if (topAccountOk && taskName !== "list_accounts" && !import_account_policy.ACCOUNT_FREE_DISCOVERY_TASKS.has(taskName ?? "")) {
|
|
8262
|
-
result.account = (0, import_client2.resolveAccount)(options);
|
|
8263
|
-
}
|
|
8264
|
-
return result;
|
|
8265
|
-
}
|
|
8266
8233
|
function applyDisableSandboxHint(request, taskName) {
|
|
8267
8234
|
if (taskName && !(0, import_schema_loader.schemaAllowsTopLevelField)(taskName, "ext")) return request;
|
|
8268
8235
|
const existingExt = request.ext;
|
|
@@ -6,7 +6,8 @@ import { createHash, createHmac } from "node:crypto";
|
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
7
|
import { basename, join } from "node:path";
|
|
8
8
|
import { isDeepStrictEqual } from "node:util";
|
|
9
|
-
import {
|
|
9
|
+
import { applyBrandInvariant } from "./account-policy.mjs";
|
|
10
|
+
import { isRunnerOwnedTask, REPLAY_WEBHOOK_VECTOR_TASK } from "./runner-owned-task.mjs";
|
|
10
11
|
import { prepareCreativeBuildProbe } from "./creative-build-probe.mjs";
|
|
11
12
|
import {
|
|
12
13
|
createTestClient,
|
|
@@ -292,10 +293,6 @@ const CANONICAL_SKIP_DETAILS = {
|
|
|
292
293
|
signing_transport_unavailable: "signing_transport_unavailable"
|
|
293
294
|
};
|
|
294
295
|
const MCP_SESSION_PROBE_REQUEST_TIMEOUT_MS = 5e3;
|
|
295
|
-
const REPLAY_WEBHOOK_VECTOR_TASK = "replay_webhook_vector";
|
|
296
|
-
function isRunnerOwnedTask(task) {
|
|
297
|
-
return task === VALIDATION_ONLY_TASK || task === MCP_SESSION_PROBE_TASK || task === "assert_contribution" || task === REPLAY_WEBHOOK_VECTOR_TASK || TRUSTED_MATCH_PUBLISHER_AUTH_TASKS.has(task) || PROBE_TASKS.has(task) || WEBHOOK_ASSERTION_TASKS.has(task);
|
|
298
|
-
}
|
|
299
296
|
const REPLAY_TRUSTED_MATCH_CONTEXT_VECTOR_TASK = "replay_trusted_match_context_vector";
|
|
300
297
|
const WEBHOOK_REPLAY_DEFAULT_TIMEOUT_MS = 1e4;
|
|
301
298
|
function selectionForProbeSkip(reason, detail) {
|
|
@@ -1191,6 +1188,7 @@ function buildPhaseCapabilitySkippedSteps(storyboard, phase, detail, context) {
|
|
|
1191
1188
|
const REQUIREMENT_TO_SKIP_REASON = {
|
|
1192
1189
|
controller: "missing_test_controller",
|
|
1193
1190
|
collect_product_pages_runner: "requirement_unmet",
|
|
1191
|
+
field_excludes_runner: "requirement_unmet",
|
|
1194
1192
|
seeded_state: "requirement_unmet",
|
|
1195
1193
|
real_wire: "requirement_unmet",
|
|
1196
1194
|
webhook_receiver: "requirement_unmet",
|
|
@@ -1324,6 +1322,7 @@ async function checkRequires(requires, storyboard, options, profile, precomputed
|
|
|
1324
1322
|
continue;
|
|
1325
1323
|
}
|
|
1326
1324
|
switch (requirement) {
|
|
1325
|
+
case "field_excludes_runner":
|
|
1327
1326
|
case "collect_product_pages_runner":
|
|
1328
1327
|
break;
|
|
1329
1328
|
case "controller": {
|
|
@@ -8273,39 +8272,7 @@ function evalContributesIf(expr, priorStepResults) {
|
|
|
8273
8272
|
const prior = priorStepResults.get(stepId);
|
|
8274
8273
|
return !!prior?.passed && !prior.skipped;
|
|
8275
8274
|
}
|
|
8276
|
-
|
|
8277
|
-
function applyBrandInvariant(request, options, taskName, stepFlags) {
|
|
8278
|
-
if (!options.brand && !options.brand_manifest) return request;
|
|
8279
|
-
if (taskName !== void 0 && BRAND_SUBJECT_TASKS.has(taskName)) return request;
|
|
8280
|
-
const brand = resolveBrand(options);
|
|
8281
|
-
const topBrandOk = !taskName || schemaAllowsTopLevelField(taskName, "brand");
|
|
8282
|
-
const topAccountOk = !taskName || schemaAllowsTopLevelField(taskName, "account");
|
|
8283
|
-
const result = { ...request };
|
|
8284
|
-
if (topBrandOk) result.brand = brand;
|
|
8285
|
-
if (stepFlags?.omit_account) return result;
|
|
8286
|
-
if ("account" in request) {
|
|
8287
|
-
const existingAccount = request.account;
|
|
8288
|
-
if (existingAccount && typeof existingAccount === "object" && !Array.isArray(existingAccount)) {
|
|
8289
|
-
const acct = existingAccount;
|
|
8290
|
-
const isNaturalKeyVariant = "brand" in acct || "operator" in acct;
|
|
8291
|
-
if (isNaturalKeyVariant) {
|
|
8292
|
-
const preserveWholesaleAccountBrand = (taskName === "get_products" && request.buying_mode === "wholesale" || taskName === "get_signals" && request.discovery_mode === "wholesale") && acct.brand !== void 0;
|
|
8293
|
-
const merged = {
|
|
8294
|
-
...acct,
|
|
8295
|
-
brand: preserveWholesaleAccountBrand ? acct.brand : brand
|
|
8296
|
-
};
|
|
8297
|
-
const accountBrand = merged.brand;
|
|
8298
|
-
if (typeof merged.operator !== "string" && typeof accountBrand?.domain === "string") {
|
|
8299
|
-
merged.operator = accountBrand.domain;
|
|
8300
|
-
}
|
|
8301
|
-
result.account = merged;
|
|
8302
|
-
}
|
|
8303
|
-
}
|
|
8304
|
-
} else if (topAccountOk && taskName !== "list_accounts" && !ACCOUNT_FREE_DISCOVERY_TASKS.has(taskName ?? "")) {
|
|
8305
|
-
result.account = resolveAccount(options);
|
|
8306
|
-
}
|
|
8307
|
-
return result;
|
|
8308
|
-
}
|
|
8275
|
+
import { applyBrandInvariant as applyBrandInvariant2, BRAND_SUBJECT_TASKS } from "./account-policy.mjs";
|
|
8309
8276
|
function applyDisableSandboxHint(request, taskName) {
|
|
8310
8277
|
if (taskName && !schemaAllowsTopLevelField(taskName, "ext")) return request;
|
|
8311
8278
|
const existingExt = request.ext;
|
|
@@ -8664,7 +8631,7 @@ export {
|
|
|
8664
8631
|
__selectProtectedToolTargetForTest,
|
|
8665
8632
|
__sessionControlCredentialsForTest,
|
|
8666
8633
|
applyAdcpVersionRunOptions,
|
|
8667
|
-
applyBrandInvariant,
|
|
8634
|
+
applyBrandInvariant2 as applyBrandInvariant,
|
|
8668
8635
|
applyDisableSandboxHint,
|
|
8669
8636
|
applyFixtureBindingsSafely,
|
|
8670
8637
|
applyIdempotencyInvariant,
|
|
@@ -36,9 +36,164 @@ var import_rawResponseCapture = require('../../protocols/rawResponseCapture.js')
|
|
|
36
36
|
var import_fixture_resolution = require('./fixture-resolution.js');
|
|
37
37
|
var import_collection_selection = require('./collection-selection.js');
|
|
38
38
|
var import_path = require('./path.js');
|
|
39
|
+
var import_context = require('./context.js');
|
|
40
|
+
var import_account_policy = require('./account-policy.js');
|
|
41
|
+
var import_runner_owned_task = require('./runner-owned-task.js');
|
|
39
42
|
var import_redact_secrets = require('../../utils/redact-secrets.js');
|
|
43
|
+
var import_jcs = require('../../utils/jcs.js');
|
|
40
44
|
var import_discovery_evidence = require('../discovery-evidence.js');
|
|
41
45
|
var import_redact_credential_patterns = require('../../utils/redact-credential-patterns.js');
|
|
46
|
+
function storyboardSeedScope(storyboard, context, options, call) {
|
|
47
|
+
if (call.scenario !== "seed_product" && call.scenario !== "seed_pricing_option") return {};
|
|
48
|
+
if (context.account !== void 0) {
|
|
49
|
+
if (!isPlainRecord(context.account) || /\$(?:context\.|generate:)/.test(JSON.stringify(context.account))) {
|
|
50
|
+
throw new Error("Automatic fixture seeding needs a resolved context.account reference");
|
|
51
|
+
}
|
|
52
|
+
if (context.account.sandbox === false) throw new Error("Automatic fixture seeding requires a sandbox account");
|
|
53
|
+
if (typeof context.account.account_id !== "string" && (options.brand || options.brand_manifest) && (0, import_jcs.canonicalize)(context.account.brand) !== (0, import_jcs.canonicalize)((0, import_client.resolveBrand)(options))) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
"Explicit fixture context.account conflicts with the run-scoped brand; choose one account identity"
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
account: { ...context.account, sandbox: true }
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const provisioningAliases = /* @__PURE__ */ new Map();
|
|
63
|
+
const provisioningAccounts = [];
|
|
64
|
+
for (const phase of storyboard.phases)
|
|
65
|
+
for (const step of phase.steps) {
|
|
66
|
+
if (step.task !== "sync_accounts" || step.expect_error) continue;
|
|
67
|
+
const request = (0, import_context.injectContext)(step.sample_request ?? {}, context);
|
|
68
|
+
if (!Array.isArray(request.accounts) || request.accounts.length !== 1) continue;
|
|
69
|
+
const row = request.accounts[0];
|
|
70
|
+
if (!isPlainRecord(row) || !isPlainRecord(row.brand) || typeof row.operator !== "string") continue;
|
|
71
|
+
const { brand, operator, operator_unit, currency, timezone, sandbox } = row;
|
|
72
|
+
const account = {
|
|
73
|
+
brand,
|
|
74
|
+
operator,
|
|
75
|
+
...operator_unit !== void 0 && { operator_unit },
|
|
76
|
+
...currency !== void 0 && { currency },
|
|
77
|
+
...timezone !== void 0 && { timezone },
|
|
78
|
+
...sandbox !== void 0 && { sandbox }
|
|
79
|
+
};
|
|
80
|
+
provisioningAccounts.push(account);
|
|
81
|
+
for (const output of step.context_outputs ?? []) {
|
|
82
|
+
if (output.path === "accounts[0].account_id" && output.key) provisioningAliases.set(output.key, account);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const accounts = /* @__PURE__ */ new Map();
|
|
86
|
+
const resolvedScopes = /* @__PURE__ */ new Set();
|
|
87
|
+
const deferredScopes = /* @__PURE__ */ new Set();
|
|
88
|
+
const seedScopeSteps = [
|
|
89
|
+
...storyboard.phases.flatMap((phase) => phase.steps),
|
|
90
|
+
...provisioningAccounts.map((account, index) => ({
|
|
91
|
+
id: `seed-scope-${index}`,
|
|
92
|
+
title: "Seed scope from account provisioning",
|
|
93
|
+
task: "sync_accounts",
|
|
94
|
+
sample_request: { account }
|
|
95
|
+
}))
|
|
96
|
+
];
|
|
97
|
+
for (const authoredStep of seedScopeSteps) {
|
|
98
|
+
const step = authoredStep.task === "expect_rate_limit_not_replayed" && authoredStep.rate_limit_trip ? {
|
|
99
|
+
...authoredStep,
|
|
100
|
+
task: authoredStep.rate_limit_trip.trip_target_task,
|
|
101
|
+
sample_request: authoredStep.rate_limit_trip.trip_target_sample_request
|
|
102
|
+
} : authoredStep;
|
|
103
|
+
if ((0, import_runner_owned_task.isRunnerOwnedTask)(step.task)) continue;
|
|
104
|
+
if (step.expect_error || step.omit_account) continue;
|
|
105
|
+
const source = options.request ?? step.sample_request ?? {};
|
|
106
|
+
if (JSON.stringify(source.account ?? {}).includes("$generate:")) {
|
|
107
|
+
throw new Error("Automatic fixture seeding needs an explicit resolved account for generated identities");
|
|
108
|
+
}
|
|
109
|
+
let request = (0, import_context.injectContext)(
|
|
110
|
+
{
|
|
111
|
+
...source.account !== void 0 && { account: source.account },
|
|
112
|
+
buying_mode: source.buying_mode,
|
|
113
|
+
discovery_mode: source.discovery_mode,
|
|
114
|
+
...step.task === "validate_input" && { targets: source.targets },
|
|
115
|
+
...step.task === "comply_test_controller" && { scenario: source.scenario }
|
|
116
|
+
},
|
|
117
|
+
context
|
|
118
|
+
);
|
|
119
|
+
if (step.context_inputs?.length) request = (0, import_context.applyContextInputs)(request, step.context_inputs, context);
|
|
120
|
+
const formatOnlyValidation = step.task === "validate_input" && Array.isArray(request.targets) && request.targets.length > 0 && request.targets.every(
|
|
121
|
+
(target) => isPlainRecord(target) && ["canonical", "third_party_format", "capability"].includes(String(target.kind))
|
|
122
|
+
);
|
|
123
|
+
const controllerMetadata = step.task === "comply_test_controller" && request.scenario === "list_scenarios";
|
|
124
|
+
if (request.account === void 0 && (controllerMetadata || formatOnlyValidation)) continue;
|
|
125
|
+
if (request.account === void 0 && step.task === "comply_test_controller") {
|
|
126
|
+
request.account = { ...(0, import_client.resolveAccount)(options), sandbox: true };
|
|
127
|
+
}
|
|
128
|
+
request = (0, import_account_policy.applyBrandInvariant)(request, options, step.task, { omit_account: step.omit_account });
|
|
129
|
+
if (request.account === void 0) continue;
|
|
130
|
+
if (JSON.stringify(request.account).includes("$generate:")) {
|
|
131
|
+
throw new Error("Automatic fixture seeding needs an explicit resolved account for generated identities");
|
|
132
|
+
}
|
|
133
|
+
let injected = request.account;
|
|
134
|
+
if (isPlainRecord(injected) && typeof injected.account_id === "string") {
|
|
135
|
+
const capture = /^\$context\.(\w+)$/.exec(injected.account_id)?.[1];
|
|
136
|
+
if (capture && provisioningAliases.has(capture)) injected = provisioningAliases.get(capture);
|
|
137
|
+
}
|
|
138
|
+
if (!isPlainRecord(injected)) throw new Error("Automatic fixture seeding needs a resolved account reference");
|
|
139
|
+
const account = { ...injected };
|
|
140
|
+
let deferred = false;
|
|
141
|
+
for (const key2 of ["currency", "timezone"]) {
|
|
142
|
+
if (typeof account[key2] === "string" && /^\$context\./.test(account[key2])) {
|
|
143
|
+
delete account[key2];
|
|
144
|
+
deferred = true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (JSON.stringify(account).includes("$context.")) {
|
|
148
|
+
throw new Error("Automatic fixture seeding needs a resolved account reference");
|
|
149
|
+
}
|
|
150
|
+
const hasIdentity = typeof account.account_id === "string" && account.account_id.length > 0 || isPlainRecord(account.brand) && typeof account.brand.domain === "string" && account.brand.domain.length > 0 && typeof account.operator === "string" && account.operator.length > 0;
|
|
151
|
+
if (!hasIdentity) continue;
|
|
152
|
+
if (account.sandbox === false) throw new Error("Automatic fixture seeding requires a sandbox account");
|
|
153
|
+
const sandboxAccount = { ...account, sandbox: true };
|
|
154
|
+
const { currency: _currency, timezone: _timezone, ...identity } = sandboxAccount;
|
|
155
|
+
const key = (0, import_jcs.canonicalize)(identity);
|
|
156
|
+
(deferred ? deferredScopes : resolvedScopes).add(key);
|
|
157
|
+
const prior = accounts.get(key);
|
|
158
|
+
if (prior) {
|
|
159
|
+
for (const dimension of ["currency", "timezone"]) {
|
|
160
|
+
if (prior[dimension] !== void 0 && sandboxAccount[dimension] !== void 0 && prior[dimension] !== sandboxAccount[dimension]) {
|
|
161
|
+
throw new Error(
|
|
162
|
+
"Automatic fixture seeding needs an explicit context.account when a storyboard uses multiple accounts"
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
accounts.set(key, { ...prior, ...sandboxAccount });
|
|
168
|
+
}
|
|
169
|
+
if ([...deferredScopes].some((key) => !resolvedScopes.has(key))) {
|
|
170
|
+
throw new Error("Automatic fixture seeding needs a resolved account reference before later account enrichment");
|
|
171
|
+
}
|
|
172
|
+
if (accounts.size === 1) return { account: [...accounts.values()][0] };
|
|
173
|
+
if (accounts.size > 1) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
"Automatic fixture seeding needs an explicit context.account when a storyboard uses multiple accounts"
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
const sandboxAccounts = (storyboard.fixtures?.accounts ?? []).flatMap((entry) => {
|
|
179
|
+
const fixture = isPlainRecord(entry.fixture) ? entry.fixture : entry;
|
|
180
|
+
if (fixture.sandbox !== true || !isPlainRecord(fixture.brand) || typeof fixture.operator !== "string") return [];
|
|
181
|
+
const { brand, operator, operator_unit, currency, timezone } = fixture;
|
|
182
|
+
return [
|
|
183
|
+
{
|
|
184
|
+
brand,
|
|
185
|
+
operator,
|
|
186
|
+
...operator_unit !== void 0 && { operator_unit },
|
|
187
|
+
...currency !== void 0 && { currency },
|
|
188
|
+
...timezone !== void 0 && { timezone },
|
|
189
|
+
sandbox: true
|
|
190
|
+
}
|
|
191
|
+
];
|
|
192
|
+
});
|
|
193
|
+
if (sandboxAccounts.length === 1) return { account: sandboxAccounts[0] };
|
|
194
|
+
if (sandboxAccounts.length > 1) throw new Error("Automatic fixture seeding needs an explicit context.account");
|
|
195
|
+
return {};
|
|
196
|
+
}
|
|
42
197
|
const CONTROLLER_SEEDING_PHASE_ID = "__controller_seeding__";
|
|
43
198
|
function buildSeedCalls(fixtures) {
|
|
44
199
|
if (!fixtures) return [];
|
|
@@ -267,7 +422,12 @@ async function runControllerSeeding(client, storyboard, options, context, discov
|
|
|
267
422
|
try {
|
|
268
423
|
const raw = await (0, import_test_controller.callControllerRaw)(
|
|
269
424
|
client,
|
|
270
|
-
{
|
|
425
|
+
{
|
|
426
|
+
...storyboardSeedScope(storyboard, context, options, call),
|
|
427
|
+
scenario: call.scenario,
|
|
428
|
+
params: call.params,
|
|
429
|
+
context: seedContext
|
|
430
|
+
},
|
|
271
431
|
options
|
|
272
432
|
);
|
|
273
433
|
const data = raw.data;
|
|
@@ -560,6 +720,7 @@ async function runDeclaredFixtureResolution(seedClient, discoveryClient, storybo
|
|
|
560
720
|
const raw = await (0, import_test_controller.callControllerRaw)(
|
|
561
721
|
seedClient,
|
|
562
722
|
{
|
|
723
|
+
...storyboardSeedScope(storyboard, context, seedOptions, call),
|
|
563
724
|
scenario: call.scenario,
|
|
564
725
|
params: isPlainRecord(controllerRequest.params) ? controllerRequest.params : call.params,
|
|
565
726
|
context: seedContext
|
|
@@ -590,6 +751,7 @@ async function runDeclaredFixtureResolution(seedClient, discoveryClient, storybo
|
|
|
590
751
|
// `call.params` when the bound params are not a plain
|
|
591
752
|
// record, and adds the seeding correlation context.
|
|
592
753
|
payload: (0, import_redact_secrets.redactSecrets)({
|
|
754
|
+
...storyboardSeedScope(storyboard, context, seedOptions, call),
|
|
593
755
|
scenario: call.scenario,
|
|
594
756
|
params: isPlainRecord(controllerRequest.params) ? controllerRequest.params : call.params,
|
|
595
757
|
context: seedContext
|
|
@@ -956,7 +1118,12 @@ async function executeLegacySeedCall(client, storyboard, call, options, context,
|
|
|
956
1118
|
try {
|
|
957
1119
|
const raw = await (0, import_test_controller.callControllerRaw)(
|
|
958
1120
|
client,
|
|
959
|
-
{
|
|
1121
|
+
{
|
|
1122
|
+
...storyboardSeedScope(storyboard, context, options, call),
|
|
1123
|
+
scenario: call.scenario,
|
|
1124
|
+
params: call.params,
|
|
1125
|
+
context: seedContext
|
|
1126
|
+
},
|
|
960
1127
|
options
|
|
961
1128
|
);
|
|
962
1129
|
const data = raw.data;
|