@adcp/sdk 14.0.0-beta.12 → 14.0.0-beta.13
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/index.d.mts +3 -3
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +3 -1
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/create-adcp-server.d.mts +2 -2
- package/dist/lib/server/create-adcp-server.d.ts +2 -2
- package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
- package/dist/lib/server/create-adcp-server.js +6 -1
- package/dist/lib/server/create-adcp-server.js.map +1 -1
- package/dist/lib/server/create-adcp-server.mjs +6 -1
- package/dist/lib/server/create-adcp-server.mjs.map +1 -1
- package/dist/lib/server/decisioning/index.d.mts +3 -3
- package/dist/lib/server/decisioning/index.d.ts +3 -3
- package/dist/lib/server/decisioning/index.d.ts.map +1 -1
- package/dist/lib/server/decisioning/index.js.map +1 -1
- package/dist/lib/server/decisioning/index.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.d.mts +24 -17
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts +24 -17
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.js +71 -42
- package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +75 -43
- package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.mts +15 -21
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts +15 -21
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.js +100 -30
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs +100 -30
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/task-registry.d.mts +30 -16
- package/dist/lib/server/decisioning/runtime/task-registry.d.ts +30 -16
- package/dist/lib/server/decisioning/runtime/task-registry.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/task-registry.js +40 -20
- package/dist/lib/server/decisioning/runtime/task-registry.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/task-registry.mjs +38 -19
- package/dist/lib/server/decisioning/runtime/task-registry.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.d.mts +2 -2
- package/dist/lib/server/decisioning/runtime/to-context.d.ts +2 -2
- package/dist/lib/server/decisioning/runtime/to-context.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.js +2 -2
- package/dist/lib/server/decisioning/runtime/to-context.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.mjs +2 -2
- package/dist/lib/server/decisioning/runtime/to-context.mjs.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.mts +3 -2
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts +3 -2
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.js.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative.d.mts +10 -10
- package/dist/lib/server/decisioning/specialisms/creative.d.ts +10 -10
- package/dist/lib/server/decisioning/specialisms/creative.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative.js.map +1 -1
- package/dist/lib/server/index.d.mts +1 -1
- package/dist/lib/server/index.d.ts +1 -1
- package/dist/lib/server/index.d.ts.map +1 -1
- package/dist/lib/server/index.js.map +1 -1
- package/dist/lib/server/index.mjs.map +1 -1
- package/dist/lib/testing/storyboard/default-invariants.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/default-invariants.js +11 -2
- package/dist/lib/testing/storyboard/default-invariants.js.map +1 -1
- package/dist/lib/testing/storyboard/default-invariants.mjs +11 -2
- package/dist/lib/testing/storyboard/default-invariants.mjs.map +1 -1
- package/dist/lib/testing/storyboard/index.d.mts +1 -1
- package/dist/lib/testing/storyboard/index.d.ts +1 -1
- package/dist/lib/testing/storyboard/index.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/index.js.map +1 -1
- package/dist/lib/testing/storyboard/index.mjs.map +1 -1
- package/dist/lib/testing/storyboard/loader.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/loader.js +14 -0
- package/dist/lib/testing/storyboard/loader.js.map +1 -1
- package/dist/lib/testing/storyboard/loader.mjs +14 -0
- package/dist/lib/testing/storyboard/loader.mjs.map +1 -1
- package/dist/lib/testing/storyboard/phase-condition.d.mts +41 -0
- package/dist/lib/testing/storyboard/phase-condition.d.ts +42 -0
- package/dist/lib/testing/storyboard/phase-condition.d.ts.map +1 -0
- package/dist/lib/testing/storyboard/phase-condition.js +215 -0
- package/dist/lib/testing/storyboard/phase-condition.js.map +1 -0
- package/dist/lib/testing/storyboard/phase-condition.mjs +189 -0
- package/dist/lib/testing/storyboard/phase-condition.mjs.map +1 -0
- package/dist/lib/testing/storyboard/request-builder.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/request-builder.js +15 -2
- package/dist/lib/testing/storyboard/request-builder.js.map +1 -1
- package/dist/lib/testing/storyboard/request-builder.mjs +15 -2
- package/dist/lib/testing/storyboard/request-builder.mjs.map +1 -1
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +57 -23
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/testing/storyboard/runner.mjs +57 -23
- package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
- package/dist/lib/testing/storyboard/task-map.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/task-map.js +6 -2
- package/dist/lib/testing/storyboard/task-map.js.map +1 -1
- package/dist/lib/testing/storyboard/task-map.mjs +6 -2
- package/dist/lib/testing/storyboard/task-map.mjs.map +1 -1
- package/dist/lib/testing/storyboard/types.d.mts +5 -4
- package/dist/lib/testing/storyboard/types.d.ts +5 -4
- package/dist/lib/testing/storyboard/types.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/types.js.map +1 -1
- package/dist/lib/testing/storyboard/types.mjs.map +1 -1
- 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/webhook-assertions.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/webhook-assertions.js +60 -4
- package/dist/lib/testing/storyboard/webhook-assertions.js.map +1 -1
- package/dist/lib/testing/storyboard/webhook-assertions.mjs +60 -4
- package/dist/lib/testing/storyboard/webhook-assertions.mjs.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.d.mts +15 -0
- package/dist/lib/testing/storyboard/webhook-receiver.d.ts +15 -0
- package/dist/lib/testing/storyboard/webhook-receiver.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.js +57 -6
- package/dist/lib/testing/storyboard/webhook-receiver.js.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.mjs +57 -6
- package/dist/lib/testing/storyboard/webhook-receiver.mjs.map +1 -1
- package/dist/lib/testing/types.d.mts +2 -0
- package/dist/lib/testing/types.d.ts +2 -0
- package/dist/lib/testing/types.d.ts.map +1 -1
- package/dist/lib/testing/types.js.map +1 -1
- package/dist/lib/types/core.generated.d.mts +5 -2
- package/dist/lib/types/core.generated.d.ts +5 -2
- package/dist/lib/types/core.generated.d.ts.map +1 -1
- package/dist/lib/types/core.generated.js.map +1 -1
- package/dist/lib/types/index.d.mts +1 -1
- package/dist/lib/types/index.d.ts +1 -1
- package/dist/lib/types/index.d.ts.map +1 -1
- package/dist/lib/types/index.js.map +1 -1
- package/dist/lib/types/index.mjs.map +1 -1
- package/dist/lib/types/list-transformers.d.ts +9 -5
- package/dist/lib/types/schemas.generated.d.ts +21 -298
- package/dist/lib/types/schemas.generated.d.ts.map +1 -1
- package/dist/lib/types/schemas.generated.js +5 -2
- package/dist/lib/types/schemas.generated.js.map +1 -1
- package/dist/lib/types/schemas.generated.mjs +4 -2
- package/dist/lib/types/schemas.generated.mjs.map +1 -1
- package/dist/lib/types/server-payload-aliases.d.mts +2 -1
- package/dist/lib/types/server-payload-aliases.d.ts +2 -1
- package/dist/lib/types/server-payload-aliases.d.ts.map +1 -1
- package/dist/lib/types/server-payload-aliases.js.map +1 -1
- package/dist/lib/types/tools.generated.d.mts +5 -2
- package/dist/lib/types/tools.generated.d.ts +5 -2
- package/dist/lib/types/tools.generated.d.ts.map +1 -1
- package/dist/lib/types/tools.generated.js.map +1 -1
- package/dist/lib/utils/build-creative-return-builders.d.mts +5 -1
- package/dist/lib/utils/build-creative-return-builders.d.ts +5 -1
- package/dist/lib/utils/build-creative-return-builders.d.ts.map +1 -1
- package/dist/lib/utils/build-creative-return-builders.js +9 -3
- package/dist/lib/utils/build-creative-return-builders.js.map +1 -1
- package/dist/lib/utils/build-creative-return-builders.mjs +7 -2
- package/dist/lib/utils/build-creative-return-builders.mjs.map +1 -1
- package/dist/lib/utils/response-unwrapper.js +1 -1
- package/dist/lib/utils/response-unwrapper.js.map +1 -1
- package/dist/lib/utils/response-unwrapper.mjs +1 -1
- package/dist/lib/utils/response-unwrapper.mjs.map +1 -1
- package/dist/lib/validation/schema-loader.d.ts.map +1 -1
- package/dist/lib/validation/schema-loader.js +16 -7
- package/dist/lib/validation/schema-loader.js.map +1 -1
- package/dist/lib/validation/schema-loader.mjs +16 -7
- package/dist/lib/validation/schema-loader.mjs.map +1 -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.js.map +1 -1
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/version.mjs.map +1 -1
- package/docs/llms.txt +2 -2
- package/docs/migration-5.x-to-6.x.md +3 -2
- package/docs/migration-task-registry-scoping.md +61 -0
- package/examples/hello_seller_adapter_guaranteed.ts +1 -1
- package/package.json +4 -4
- package/skills/build-decisioning-creative-template/SKILL.md +2 -2
- package/skills/build-decisioning-platform/SKILL.md +4 -2
- package/skills/build-decisioning-platform/advanced/REFERENCE.md +7 -6
|
@@ -1324,10 +1324,20 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1324
1324
|
}
|
|
1325
1325
|
const pooledIdempotency = opts.pool && opts.idempotency === void 0 ? (0, import_idempotency.createIdempotencyStore)({ backend: (0, import_pg.pgBackend)(opts.pool) }) : void 0;
|
|
1326
1326
|
const pooledCtxMetadata = opts.pool && opts.ctxMetadata === void 0 ? (0, import_ctx_metadata.createCtxMetadataStore)({ backend: (0, import_ctx_metadata.pgCtxMetadataStore)(opts.pool) }) : void 0;
|
|
1327
|
-
|
|
1327
|
+
if (opts.pool && opts.taskRegistry === void 0 && opts.taskRegistryNamespace === void 0) {
|
|
1328
|
+
throw new import_validate_platform.PlatformConfigError(
|
|
1329
|
+
"taskRegistryNamespace is required when opts.pool supplies the task registry. Use the same trusted namespace with getAllAdcpMigrations({ taskRegistryNamespace }) or getDecisioningTaskRegistryMigration({ namespace })."
|
|
1330
|
+
);
|
|
1331
|
+
}
|
|
1332
|
+
const pooledTaskRegistry = opts.pool && opts.taskRegistry === void 0 ? (0, import_postgres_task_registry.createPostgresTaskRegistry)({ pool: opts.pool, namespace: opts.taskRegistryNamespace }) : void 0;
|
|
1328
1333
|
const effectiveIdempotency = opts.idempotency ?? pooledIdempotency;
|
|
1329
1334
|
const effectiveCtxMetadata = opts.ctxMetadata ?? pooledCtxMetadata;
|
|
1330
1335
|
const taskRegistry = opts.taskRegistry ?? pooledTaskRegistry ?? buildDefaultTaskRegistry();
|
|
1336
|
+
if (taskRegistry.scopeVersion !== 1) {
|
|
1337
|
+
throw new import_validate_platform.PlatformConfigError(
|
|
1338
|
+
"taskRegistry.scopeVersion must be 1. Migrate custom registries to the account/principal-scoped TaskRegistry signatures before use."
|
|
1339
|
+
);
|
|
1340
|
+
}
|
|
1331
1341
|
const baseBus = opts.statusChangeBus ?? (0, import_status_changes.createInMemoryStatusChangeBus)();
|
|
1332
1342
|
const taskWebhookEmit = opts.taskWebhookEmitter?.emit;
|
|
1333
1343
|
const observability = opts.observability;
|
|
@@ -1994,15 +2004,13 @@ function createAdcpServerFromPlatform(platform, opts) {
|
|
|
1994
2004
|
}
|
|
1995
2005
|
}
|
|
1996
2006
|
return Object.assign(server, {
|
|
1997
|
-
getTaskState: async (taskId,
|
|
1998
|
-
const record = await taskRegistry.getTask(taskId);
|
|
1999
|
-
|
|
2000
|
-
if (expectedAccountId !== void 0 && record.accountId !== expectedAccountId) {
|
|
2001
|
-
return null;
|
|
2002
|
-
}
|
|
2003
|
-
return record;
|
|
2007
|
+
getTaskState: async (taskId, scope) => {
|
|
2008
|
+
const record = await taskRegistry.getTask(taskId, scope);
|
|
2009
|
+
return record && (0, import_task_registry.taskRecordMatchesScope)(record, scope) ? record : null;
|
|
2004
2010
|
},
|
|
2005
|
-
|
|
2011
|
+
getTaskStateUnsafe: (taskId) => taskRegistry._getTaskUnsafe(taskId),
|
|
2012
|
+
awaitTask: (taskId, scope) => taskRegistry.awaitTask(taskId, scope),
|
|
2013
|
+
awaitTaskUnsafe: (taskId) => taskRegistry._awaitTaskUnsafe(taskId),
|
|
2006
2014
|
statusChange: statusChangeBus
|
|
2007
2015
|
});
|
|
2008
2016
|
}
|
|
@@ -2175,9 +2183,26 @@ function buildTasksGetTool(platform, taskRegistry, agentRegistry, logger, resolv
|
|
|
2175
2183
|
});
|
|
2176
2184
|
}
|
|
2177
2185
|
}
|
|
2186
|
+
if (resolvedAccountId === void 0) {
|
|
2187
|
+
return (0, import_errors.adcpError)("REFERENCE_NOT_FOUND", {
|
|
2188
|
+
message: `Task ${args.task_id} not found`,
|
|
2189
|
+
field: "task_id"
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
const ownerCtx = {
|
|
2193
|
+
store: {},
|
|
2194
|
+
...extra?.authInfo !== void 0 && { authInfo: extra.authInfo },
|
|
2195
|
+
...agent !== void 0 && { agent },
|
|
2196
|
+
...sessionKey !== void 0 && { sessionKey },
|
|
2197
|
+
account: resolvedAccount ?? { id: resolvedAccountId }
|
|
2198
|
+
};
|
|
2199
|
+
const expectedOwnerScope = taskOwnerScopeFor(ownerCtx, resolvedAccountId);
|
|
2178
2200
|
let record;
|
|
2179
2201
|
try {
|
|
2180
|
-
record = await taskRegistry.getTask(args.task_id
|
|
2202
|
+
record = await taskRegistry.getTask(args.task_id, {
|
|
2203
|
+
accountId: resolvedAccountId,
|
|
2204
|
+
ownerScope: expectedOwnerScope
|
|
2205
|
+
});
|
|
2181
2206
|
} catch (err) {
|
|
2182
2207
|
logger.error?.("Task registry read failed during tasks_get poll", {
|
|
2183
2208
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -2190,34 +2215,15 @@ function buildTasksGetTool(platform, taskRegistry, agentRegistry, logger, resolv
|
|
|
2190
2215
|
field: "task_id"
|
|
2191
2216
|
});
|
|
2192
2217
|
}
|
|
2193
|
-
if (
|
|
2218
|
+
if (!(0, import_task_registry.taskRecordMatchesScope)(record, {
|
|
2219
|
+
accountId: resolvedAccountId,
|
|
2220
|
+
ownerScope: expectedOwnerScope
|
|
2221
|
+
})) {
|
|
2194
2222
|
return (0, import_errors.adcpError)("REFERENCE_NOT_FOUND", {
|
|
2195
2223
|
message: `Task ${args.task_id} not found`,
|
|
2196
2224
|
field: "task_id"
|
|
2197
2225
|
});
|
|
2198
2226
|
}
|
|
2199
|
-
if (resolvedAccountId !== void 0 && record.accountId !== resolvedAccountId) {
|
|
2200
|
-
return (0, import_errors.adcpError)("REFERENCE_NOT_FOUND", {
|
|
2201
|
-
message: `Task ${args.task_id} not found`,
|
|
2202
|
-
field: "task_id"
|
|
2203
|
-
});
|
|
2204
|
-
}
|
|
2205
|
-
if (resolvedAccountId !== void 0) {
|
|
2206
|
-
const ownerCtx = {
|
|
2207
|
-
store: {},
|
|
2208
|
-
...extra?.authInfo !== void 0 && { authInfo: extra.authInfo },
|
|
2209
|
-
...agent !== void 0 && { agent },
|
|
2210
|
-
...sessionKey !== void 0 && { sessionKey },
|
|
2211
|
-
account: resolvedAccount ?? { id: resolvedAccountId }
|
|
2212
|
-
};
|
|
2213
|
-
const expectedOwnerScope = taskOwnerScopeFor(ownerCtx, resolvedAccountId);
|
|
2214
|
-
if (record.ownerScope === void 0 ? expectedOwnerScope !== `account:${resolvedAccountId}` : record.ownerScope !== expectedOwnerScope) {
|
|
2215
|
-
return (0, import_errors.adcpError)("REFERENCE_NOT_FOUND", {
|
|
2216
|
-
message: `Task ${args.task_id} not found`,
|
|
2217
|
-
field: "task_id"
|
|
2218
|
-
});
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
2227
|
const payload = {
|
|
2222
2228
|
task_id: record.taskId,
|
|
2223
2229
|
task_type: record.tool,
|
|
@@ -2361,8 +2367,17 @@ function wrapBusWithObservability(bus, observability) {
|
|
|
2361
2367
|
recent: bus.recent.bind(bus)
|
|
2362
2368
|
};
|
|
2363
2369
|
}
|
|
2364
|
-
function getAllAdcpMigrations() {
|
|
2365
|
-
|
|
2370
|
+
function getAllAdcpMigrations(options) {
|
|
2371
|
+
if (!options) {
|
|
2372
|
+
throw new import_validate_platform.PlatformConfigError(
|
|
2373
|
+
"getAllAdcpMigrations requires { taskRegistryNamespace }; use a stable, trusted deployment or tenant namespace."
|
|
2374
|
+
);
|
|
2375
|
+
}
|
|
2376
|
+
return [
|
|
2377
|
+
(0, import_pg.getIdempotencyMigration)(),
|
|
2378
|
+
(0, import_ctx_metadata.getCtxMetadataMigration)(),
|
|
2379
|
+
(0, import_postgres_task_registry.getDecisioningTaskRegistryMigration)({ namespace: options.taskRegistryNamespace })
|
|
2380
|
+
].join("\n\n");
|
|
2366
2381
|
}
|
|
2367
2382
|
function buildDefaultTaskRegistry() {
|
|
2368
2383
|
const env = process.env.NODE_ENV;
|
|
@@ -2370,7 +2385,7 @@ function buildDefaultTaskRegistry() {
|
|
|
2370
2385
|
const ack = process.env.ADCP_DECISIONING_ALLOW_INMEMORY_TASKS === "1";
|
|
2371
2386
|
if (!safe && !ack) {
|
|
2372
2387
|
throw new Error(
|
|
2373
|
-
'createAdcpServerFromPlatform: in-memory task registry refused outside {NODE_ENV=test, NODE_ENV=development}. Production deployments need a durable task registry \u2014 pick one of:\n 1. (Recommended) Pass `taskRegistry: createPostgresTaskRegistry({ pool })` to keep HITL tasks across restarts. See `@adcp/sdk/server/decisioning` for `getDecisioningTaskRegistryMigration()` \u2014 run it once against your DB.\n 2. Pass `taskRegistry: createInMemoryTaskRegistry()` explicitly if you accept that in-flight tasks are lost on process restart. The explicit pass-in is the contract \u2014 saying "yes I want in-memory in production" in code is the right shape.\n 3. ADCP_DECISIONING_ALLOW_INMEMORY_TASKS=1 env flag is the ops escape hatch (same effect as #2 but config-only); prefer #2 in adopter code.'
|
|
2388
|
+
'createAdcpServerFromPlatform: in-memory task registry refused outside {NODE_ENV=test, NODE_ENV=development}. Production deployments need a durable task registry \u2014 pick one of:\n 1. (Recommended) Pass `taskRegistry: createPostgresTaskRegistry({ pool, namespace: tenantId })` to keep HITL tasks across restarts. See `@adcp/sdk/server/decisioning` for `getDecisioningTaskRegistryMigration({ namespace })` \u2014 run it once against your DB.\n 2. Pass `taskRegistry: createInMemoryTaskRegistry()` explicitly if you accept that in-flight tasks are lost on process restart. The explicit pass-in is the contract \u2014 saying "yes I want in-memory in production" in code is the right shape.\n 3. ADCP_DECISIONING_ALLOW_INMEMORY_TASKS=1 env flag is the ops escape hatch (same effect as #2 but config-only); prefer #2 in adopter code.'
|
|
2374
2389
|
);
|
|
2375
2390
|
}
|
|
2376
2391
|
return (0, import_task_registry.createInMemoryTaskRegistry)();
|
|
@@ -2505,7 +2520,12 @@ async function routeIfHandoff(taskRegistry, opts, result, project) {
|
|
|
2505
2520
|
taskRegistry,
|
|
2506
2521
|
opts,
|
|
2507
2522
|
async (taskId) => {
|
|
2508
|
-
const inner = await taskFn(
|
|
2523
|
+
const inner = await taskFn(
|
|
2524
|
+
(0, import_to_context.buildHandoffContext)(taskRegistry, taskId, {
|
|
2525
|
+
accountId: opts.accountId,
|
|
2526
|
+
ownerScope: opts.ownerScope ?? `account:${opts.accountId}`
|
|
2527
|
+
})
|
|
2528
|
+
);
|
|
2509
2529
|
rejectResponseSummary(inner);
|
|
2510
2530
|
return await project(inner);
|
|
2511
2531
|
},
|
|
@@ -2553,6 +2573,10 @@ async function dispatchHitl(taskRegistry, opts, taskFn, overrideTaskId) {
|
|
|
2553
2573
|
);
|
|
2554
2574
|
};
|
|
2555
2575
|
const completion = (async () => {
|
|
2576
|
+
const registryScope = {
|
|
2577
|
+
accountId: opts.accountId,
|
|
2578
|
+
ownerScope: opts.ownerScope ?? `account:${opts.accountId}`
|
|
2579
|
+
};
|
|
2556
2580
|
let result;
|
|
2557
2581
|
let taskFnError;
|
|
2558
2582
|
try {
|
|
@@ -2566,10 +2590,10 @@ async function dispatchHitl(taskRegistry, opts, taskFn, overrideTaskId) {
|
|
|
2566
2590
|
(0, import_ctx_metadata.stripImplementationConfig)(result);
|
|
2567
2591
|
}
|
|
2568
2592
|
try {
|
|
2569
|
-
await taskRegistry.complete(taskId, result);
|
|
2593
|
+
await taskRegistry.complete(taskId, registryScope, result);
|
|
2570
2594
|
} catch (registryErr) {
|
|
2571
2595
|
opts.logger.error(
|
|
2572
|
-
`[adcp/decisioning] task ${taskId} (${opts.tool}) completed but registry write failed \u2014 manual reconciliation required. Webhook not emitted; buyer state will diverge until resolved. Error: ${registryErr instanceof Error ?
|
|
2596
|
+
`[adcp/decisioning] task ${taskId} (${opts.tool}) completed but registry write failed \u2014 manual reconciliation required. Webhook not emitted; buyer state will diverge until resolved. Error type: ${registryErr instanceof Error ? "Error" : typeof registryErr}`
|
|
2573
2597
|
);
|
|
2574
2598
|
fireTransition("failed", "REGISTRY_WRITE_FAILED");
|
|
2575
2599
|
return;
|
|
@@ -2589,10 +2613,10 @@ async function dispatchHitl(taskRegistry, opts, taskFn, overrideTaskId) {
|
|
|
2589
2613
|
);
|
|
2590
2614
|
const failureArtifact = { errors: [structured] };
|
|
2591
2615
|
try {
|
|
2592
|
-
await taskRegistry.fail(taskId, structured, failureArtifact);
|
|
2616
|
+
await taskRegistry.fail(taskId, registryScope, structured, failureArtifact);
|
|
2593
2617
|
} catch (registryErr) {
|
|
2594
2618
|
opts.logger.error(
|
|
2595
|
-
`[adcp/decisioning] task ${taskId} (${opts.tool}) failed AND registry fail-write also failed \u2014 manual reconciliation required. Webhook not emitted.
|
|
2619
|
+
`[adcp/decisioning] task ${taskId} (${opts.tool}) failed AND registry fail-write also failed \u2014 manual reconciliation required. Webhook not emitted. Task error code: ${structured.code}; registry error type: ${registryErr instanceof Error ? "Error" : typeof registryErr}`
|
|
2596
2620
|
);
|
|
2597
2621
|
fireTransition("failed", "REGISTRY_WRITE_FAILED");
|
|
2598
2622
|
return;
|
|
@@ -2602,7 +2626,11 @@ async function dispatchHitl(taskRegistry, opts, taskFn, overrideTaskId) {
|
|
|
2602
2626
|
task: { task_id: taskId, status: "failed", result: failureArtifact, error: structured }
|
|
2603
2627
|
});
|
|
2604
2628
|
})();
|
|
2605
|
-
taskRegistry._registerBackground(
|
|
2629
|
+
taskRegistry._registerBackground(
|
|
2630
|
+
taskId,
|
|
2631
|
+
{ accountId: opts.accountId, ownerScope: opts.ownerScope ?? `account:${opts.accountId}` },
|
|
2632
|
+
completion
|
|
2633
|
+
);
|
|
2606
2634
|
return { status: "submitted", task_id: taskId };
|
|
2607
2635
|
}
|
|
2608
2636
|
function buildTaskWebhookPayload(opts, taskId, status, artifact) {
|
|
@@ -3821,6 +3849,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
|
|
|
3821
3849
|
}
|
|
3822
3850
|
function projectBuildCreativeReturn(ret) {
|
|
3823
3851
|
if (ret != null && typeof ret === "object" && !Array.isArray(ret)) {
|
|
3852
|
+
if ("creatives" in ret) return ret;
|
|
3824
3853
|
if ("creative_manifest" in ret) return ret;
|
|
3825
3854
|
if ("creative_manifests" in ret) return ret;
|
|
3826
3855
|
}
|