@adcp/sdk 6.3.0 → 6.4.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/AGENTS.md +5 -0
- package/dist/lib/adapters/legacy/v2-5/sync_creatives.d.ts +4 -4
- package/dist/lib/adapters/legacy/v2-5/sync_creatives.js +4 -4
- package/dist/lib/adapters/legacy/v2-5/types.d.ts +1 -1
- package/dist/lib/adapters/legacy/v2-5/types.js +1 -1
- package/dist/lib/core/ConversationTypes.d.ts +3 -3
- package/dist/lib/core/ConversationTypes.d.ts.map +1 -1
- package/dist/lib/core/TaskExecutor.d.ts +4 -4
- package/dist/lib/core/TaskExecutor.d.ts.map +1 -1
- package/dist/lib/core/TaskExecutor.js +13 -13
- package/dist/lib/core/TaskExecutor.js.map +1 -1
- package/dist/lib/errors/index.d.ts +10 -8
- package/dist/lib/errors/index.d.ts.map +1 -1
- package/dist/lib/errors/index.js +10 -9
- package/dist/lib/errors/index.js.map +1 -1
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/decisioning/tenant-registry.d.ts +40 -12
- package/dist/lib/server/decisioning/tenant-registry.d.ts.map +1 -1
- package/dist/lib/server/decisioning/tenant-registry.js.map +1 -1
- package/dist/lib/testing/storyboard/assertions.d.ts +19 -1
- package/dist/lib/testing/storyboard/assertions.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/assertions.js.map +1 -1
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +50 -4
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/testing/storyboard/types.d.ts +32 -1
- 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/validations.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/validations.js +176 -0
- package/dist/lib/testing/storyboard/validations.js.map +1 -1
- package/dist/lib/utils/sync-creatives-adapter.d.ts +7 -7
- package/dist/lib/utils/sync-creatives-adapter.d.ts.map +1 -1
- package/dist/lib/utils/sync-creatives-adapter.js +28 -44
- package/dist/lib/utils/sync-creatives-adapter.js.map +1 -1
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/examples/decisioning-platform-broadcast-tv.ts +2 -8
- package/examples/decisioning-platform-mock-seller.ts +2 -4
- package/examples/decisioning-platform-programmatic.ts +4 -17
- package/package.json +1 -1
- package/skills/build-decisioning-platform/SKILL.md +62 -44
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
import {
|
|
30
30
|
AdcpError,
|
|
31
|
+
DEFAULT_REPORTING_CAPABILITIES,
|
|
31
32
|
publishStatusChange,
|
|
32
33
|
type DecisioningPlatform,
|
|
33
34
|
type SalesPlatform,
|
|
@@ -135,14 +136,7 @@ export class BroadcastTvSeller implements DecisioningPlatform<BroadcastTvConfig,
|
|
|
135
136
|
format_ids: [{ id: 'video_30s', agent_url: 'https://example.com/broadcast-creative-agent/mcp' }],
|
|
136
137
|
delivery_type: 'guaranteed',
|
|
137
138
|
publisher_properties: [{ publisher_domain: 'broadcast.example.com', selection_type: 'all' }],
|
|
138
|
-
reporting_capabilities:
|
|
139
|
-
available_reporting_frequencies: ['daily'],
|
|
140
|
-
expected_delay_minutes: 240,
|
|
141
|
-
timezone: 'UTC',
|
|
142
|
-
supports_webhooks: false,
|
|
143
|
-
available_metrics: [],
|
|
144
|
-
date_range_support: 'date_range',
|
|
145
|
-
},
|
|
139
|
+
reporting_capabilities: DEFAULT_REPORTING_CAPABILITIES,
|
|
146
140
|
pricing_options: [
|
|
147
141
|
{
|
|
148
142
|
pricing_option_id: 'cpm_42_00',
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
import {
|
|
42
42
|
AdcpError,
|
|
43
43
|
createAdcpServerFromPlatform,
|
|
44
|
+
DEFAULT_REPORTING_CAPABILITIES,
|
|
44
45
|
type DecisioningPlatform,
|
|
45
46
|
type SalesPlatform,
|
|
46
47
|
type AccountStore,
|
|
@@ -162,12 +163,9 @@ const SHARED_GET_PRODUCTS = async (_req: GetProductsRequest): Promise<GetProduct
|
|
|
162
163
|
},
|
|
163
164
|
],
|
|
164
165
|
reporting_capabilities: {
|
|
166
|
+
...DEFAULT_REPORTING_CAPABILITIES,
|
|
165
167
|
available_reporting_frequencies: ['hourly', 'daily'],
|
|
166
168
|
expected_delay_minutes: 30,
|
|
167
|
-
timezone: 'UTC',
|
|
168
|
-
supports_webhooks: false,
|
|
169
|
-
available_metrics: [],
|
|
170
|
-
date_range_support: 'date_range',
|
|
171
169
|
},
|
|
172
170
|
},
|
|
173
171
|
],
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
|
|
23
23
|
import {
|
|
24
24
|
AdcpError,
|
|
25
|
+
DEFAULT_REPORTING_CAPABILITIES,
|
|
25
26
|
publishStatusChange,
|
|
26
27
|
type DecisioningPlatform,
|
|
27
28
|
type SalesPlatform,
|
|
28
29
|
type AccountStore,
|
|
30
|
+
type SyncCreativesRow,
|
|
29
31
|
} from '@adcp/sdk/server';
|
|
30
|
-
import type { SyncCreativesRow } from '@adcp/sdk/server';
|
|
31
32
|
import type {
|
|
32
33
|
GetProductsRequest,
|
|
33
34
|
GetProductsResponse,
|
|
@@ -104,14 +105,7 @@ export class ProgrammaticSeller implements DecisioningPlatform<ProgrammaticConfi
|
|
|
104
105
|
format_ids: [{ id: 'display_300x250', agent_url: 'https://example.com/programmatic-creative-agent/mcp' }],
|
|
105
106
|
delivery_type: 'non_guaranteed',
|
|
106
107
|
publisher_properties: [{ publisher_domain: 'programmatic.example.com', selection_type: 'all' }],
|
|
107
|
-
reporting_capabilities: {
|
|
108
|
-
available_reporting_frequencies: ['daily'],
|
|
109
|
-
expected_delay_minutes: 60,
|
|
110
|
-
timezone: 'UTC',
|
|
111
|
-
supports_webhooks: false,
|
|
112
|
-
available_metrics: [],
|
|
113
|
-
date_range_support: 'date_range',
|
|
114
|
-
},
|
|
108
|
+
reporting_capabilities: { ...DEFAULT_REPORTING_CAPABILITIES, expected_delay_minutes: 60 },
|
|
115
109
|
pricing_options: [
|
|
116
110
|
{
|
|
117
111
|
pricing_option_id: 'cpm_2_50',
|
|
@@ -128,14 +122,7 @@ export class ProgrammaticSeller implements DecisioningPlatform<ProgrammaticConfi
|
|
|
128
122
|
format_ids: [{ id: 'video_15s', agent_url: 'https://example.com/programmatic-creative-agent/mcp' }],
|
|
129
123
|
delivery_type: 'non_guaranteed',
|
|
130
124
|
publisher_properties: [{ publisher_domain: 'programmatic.example.com', selection_type: 'all' }],
|
|
131
|
-
reporting_capabilities: {
|
|
132
|
-
available_reporting_frequencies: ['daily'],
|
|
133
|
-
expected_delay_minutes: 60,
|
|
134
|
-
timezone: 'UTC',
|
|
135
|
-
supports_webhooks: false,
|
|
136
|
-
available_metrics: [],
|
|
137
|
-
date_range_support: 'date_range',
|
|
138
|
-
},
|
|
125
|
+
reporting_capabilities: { ...DEFAULT_REPORTING_CAPABILITIES, expected_delay_minutes: 60 },
|
|
139
126
|
pricing_options: [
|
|
140
127
|
{
|
|
141
128
|
pricing_option_id: 'cpm_18_00',
|
package/package.json
CHANGED
|
@@ -18,19 +18,31 @@ For 95% of sales agents, these are the only `@adcp/sdk/server` imports you need:
|
|
|
18
18
|
```ts
|
|
19
19
|
import {
|
|
20
20
|
// Server entry + persistence
|
|
21
|
-
createAdcpServerFromPlatform,
|
|
21
|
+
createAdcpServerFromPlatform,
|
|
22
|
+
getAllAdcpMigrations,
|
|
23
|
+
serve,
|
|
22
24
|
// Wire-shape helpers (eliminate 30+ lines of boilerplate per Product)
|
|
23
|
-
buildProduct,
|
|
25
|
+
buildProduct,
|
|
26
|
+
buildPackage,
|
|
27
|
+
buildPricingOption,
|
|
28
|
+
DEFAULT_REPORTING_CAPABILITIES, // required field; override per-product
|
|
24
29
|
// Typed errors — pick from this catalog instead of `throw new AdcpError(...)`
|
|
25
|
-
PackageNotFoundError,
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
PackageNotFoundError,
|
|
31
|
+
MediaBuyNotFoundError,
|
|
32
|
+
ProductNotFoundError,
|
|
33
|
+
BudgetTooLowError,
|
|
34
|
+
BackwardsTimeRangeError,
|
|
35
|
+
InvalidStateError,
|
|
36
|
+
RateLimitedError,
|
|
37
|
+
UnsupportedFeatureError,
|
|
28
38
|
// Types
|
|
29
|
-
type DecisioningPlatform,
|
|
39
|
+
type DecisioningPlatform,
|
|
40
|
+
type SalesPlatform,
|
|
30
41
|
} from '@adcp/sdk/server';
|
|
31
42
|
```
|
|
32
43
|
|
|
33
44
|
For other agent shapes:
|
|
45
|
+
|
|
34
46
|
- **Creative agent (template / generative):** swap `SalesPlatform` for `CreativeBuilderPlatform`
|
|
35
47
|
- **Signals agent:** swap for `SignalsPlatform`
|
|
36
48
|
- **Brand-rights agent:** swap for `BrandRightsPlatform`
|
|
@@ -57,10 +69,17 @@ The full export list is in `@adcp/sdk/server`. Many surfaces are marked `@deprec
|
|
|
57
69
|
```ts
|
|
58
70
|
import {
|
|
59
71
|
createAdcpServerFromPlatform,
|
|
60
|
-
createCtxMetadataStore,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
createCtxMetadataStore,
|
|
73
|
+
memoryCtxMetadataStore,
|
|
74
|
+
DEFAULT_REPORTING_CAPABILITIES,
|
|
75
|
+
PackageNotFoundError,
|
|
76
|
+
MediaBuyNotFoundError,
|
|
77
|
+
ProductNotFoundError,
|
|
78
|
+
BudgetTooLowError,
|
|
79
|
+
BackwardsTimeRangeError,
|
|
80
|
+
InvalidStateError,
|
|
81
|
+
type DecisioningPlatform,
|
|
82
|
+
type SalesPlatform,
|
|
64
83
|
} from '@adcp/sdk/server';
|
|
65
84
|
|
|
66
85
|
class MyPlatform implements DecisioningPlatform {
|
|
@@ -68,13 +87,13 @@ class MyPlatform implements DecisioningPlatform {
|
|
|
68
87
|
adcp_version: '3.0.0',
|
|
69
88
|
specialisms: ['sales-non-guaranteed'] as const,
|
|
70
89
|
pricingModels: ['cpm'] as const,
|
|
71
|
-
channels: ['display', 'video'] as const,
|
|
90
|
+
channels: ['display', 'video'] as const, // strict literal-union — TS catches typos
|
|
72
91
|
formats: [{ format_id: 'display_300x250' }],
|
|
73
92
|
idempotency: { replay_ttl_seconds: 86400 },
|
|
74
93
|
};
|
|
75
94
|
|
|
76
95
|
accounts = {
|
|
77
|
-
resolution: 'derived' as const,
|
|
96
|
+
resolution: 'derived' as const, // single tenant; framework returns the same Account every call
|
|
78
97
|
resolve: async () => ({ id: 'pub_main', operator: 'mypub', ctx_metadata: {} }),
|
|
79
98
|
upsert: async () => ({ ok: true, items: [] }),
|
|
80
99
|
list: async () => ({ items: [], nextCursor: null }),
|
|
@@ -90,8 +109,11 @@ class MyPlatform implements DecisioningPlatform {
|
|
|
90
109
|
name: p.name,
|
|
91
110
|
format_ids: p.formatIds.map(id => ({ id })),
|
|
92
111
|
delivery_type: 'non_guaranteed',
|
|
93
|
-
|
|
94
|
-
|
|
112
|
+
reporting_capabilities: DEFAULT_REPORTING_CAPABILITIES, // required — see ReportingCapabilities type for all fields
|
|
113
|
+
pricing_options: [
|
|
114
|
+
{ pricing_option_id: `${p.id}-cpm`, model: 'cpm', floor: { amount: p.floor, currency: 'USD' } },
|
|
115
|
+
],
|
|
116
|
+
ctx_metadata: { gam: { ad_unit_ids: p.adUnitIds } }, // stashed; framework round-trips
|
|
95
117
|
})),
|
|
96
118
|
};
|
|
97
119
|
},
|
|
@@ -124,8 +146,8 @@ class MyPlatform implements DecisioningPlatform {
|
|
|
124
146
|
// Stash your platform's IDs so subsequent updateMediaBuy can hydrate them too.
|
|
125
147
|
return {
|
|
126
148
|
media_buy_id: order.id,
|
|
127
|
-
status: 'pending_creatives',
|
|
128
|
-
ctx_metadata: { gam_order_id: order.gamOrderId },
|
|
149
|
+
status: 'pending_creatives', // creative state machine — see advanced/STATE-MACHINE.md
|
|
150
|
+
ctx_metadata: { gam_order_id: order.gamOrderId }, // SDK persists; subsequent updateMediaBuy gets req.ctx_metadata.gam_order_id
|
|
129
151
|
packages: order.lineItems.map(li => ({
|
|
130
152
|
package_id: li.id,
|
|
131
153
|
status: 'pending_creatives',
|
|
@@ -180,14 +202,14 @@ class MyPlatform implements DecisioningPlatform {
|
|
|
180
202
|
media_buy_id: buy.id,
|
|
181
203
|
status: this.statusMappers.mediaBuy(buy.nativeStatus),
|
|
182
204
|
buyer_ref: buy.buyerRef,
|
|
183
|
-
total_budget: { amount: buy.budgetAmount, currency: buy.currency },
|
|
205
|
+
total_budget: { amount: buy.budgetAmount, currency: buy.currency }, // REQUIRED on the wire shape
|
|
184
206
|
start_time: buy.startTime,
|
|
185
207
|
end_time: buy.endTime,
|
|
186
208
|
packages: buy.lineItems.map(li => ({
|
|
187
209
|
package_id: li.id,
|
|
188
210
|
status: this.statusMappers.mediaBuy(li.nativeStatus),
|
|
189
211
|
buyer_ref: li.buyerRef,
|
|
190
|
-
ctx_metadata: { gam_line_item_id: li.gamLineItemId },
|
|
212
|
+
ctx_metadata: { gam_line_item_id: li.gamLineItemId }, // round-trip publisher state
|
|
191
213
|
})),
|
|
192
214
|
ctx_metadata: { gam_order_id: buy.gamOrderId },
|
|
193
215
|
})),
|
|
@@ -208,25 +230,25 @@ That's the agent. Five functions. The framework wires the wire protocol around i
|
|
|
208
230
|
|
|
209
231
|
```ts
|
|
210
232
|
import {
|
|
211
|
-
PackageNotFoundError,
|
|
212
|
-
MediaBuyNotFoundError,
|
|
213
|
-
ProductNotFoundError,
|
|
214
|
-
ProductUnavailableError,
|
|
215
|
-
CreativeNotFoundError,
|
|
216
|
-
CreativeRejectedError,
|
|
217
|
-
BudgetTooLowError,
|
|
218
|
-
BudgetExhaustedError,
|
|
219
|
-
IdempotencyConflictError,
|
|
220
|
-
InvalidRequestError,
|
|
221
|
-
InvalidStateError,
|
|
222
|
-
BackwardsTimeRangeError,
|
|
223
|
-
AuthRequiredError,
|
|
224
|
-
PermissionDeniedError,
|
|
225
|
-
RateLimitedError,
|
|
226
|
-
UnsupportedFeatureError,
|
|
227
|
-
ComplianceUnsatisfiedError,
|
|
228
|
-
GovernanceDeniedError,
|
|
229
|
-
PolicyViolationError,
|
|
233
|
+
PackageNotFoundError, // wrong package_id on update
|
|
234
|
+
MediaBuyNotFoundError, // wrong media_buy_id
|
|
235
|
+
ProductNotFoundError, // wrong product_id on create
|
|
236
|
+
ProductUnavailableError, // product exists but sold out
|
|
237
|
+
CreativeNotFoundError, // wrong creative_id
|
|
238
|
+
CreativeRejectedError, // brand-safety failed, etc.
|
|
239
|
+
BudgetTooLowError, // under floor (correctable — buyer raises)
|
|
240
|
+
BudgetExhaustedError, // pacing burst hit cap
|
|
241
|
+
IdempotencyConflictError, // same key, different payload
|
|
242
|
+
InvalidRequestError, // generic field-level bad input
|
|
243
|
+
InvalidStateError, // illegal transition (paused → archived violations)
|
|
244
|
+
BackwardsTimeRangeError, // start_time >= end_time
|
|
245
|
+
AuthRequiredError, // need auth, then retry
|
|
246
|
+
PermissionDeniedError, // auth present, lacks scope
|
|
247
|
+
RateLimitedError, // throttled (clamps retry_after to [1, 3600])
|
|
248
|
+
UnsupportedFeatureError, // tool unimplemented
|
|
249
|
+
ComplianceUnsatisfiedError, // brand-safety attestation missing
|
|
250
|
+
GovernanceDeniedError, // spending authority revoked
|
|
251
|
+
PolicyViolationError, // categorical content rejection
|
|
230
252
|
} from '@adcp/sdk/server';
|
|
231
253
|
```
|
|
232
254
|
|
|
@@ -258,20 +280,16 @@ const meta = await ctx.ctxMetadata?.product(productId);
|
|
|
258
280
|
|
|
259
281
|
```ts
|
|
260
282
|
import { Pool } from 'pg';
|
|
261
|
-
import {
|
|
262
|
-
createAdcpServerFromPlatform,
|
|
263
|
-
getAllAdcpMigrations,
|
|
264
|
-
serve,
|
|
265
|
-
} from '@adcp/sdk/server';
|
|
283
|
+
import { createAdcpServerFromPlatform, getAllAdcpMigrations, serve } from '@adcp/sdk/server';
|
|
266
284
|
|
|
267
285
|
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
268
|
-
await pool.query(getAllAdcpMigrations());
|
|
286
|
+
await pool.query(getAllAdcpMigrations()); // one DDL call, all 3 tables
|
|
269
287
|
|
|
270
288
|
const platform = new MyPlatform(myAdServer);
|
|
271
289
|
const server = createAdcpServerFromPlatform(platform, {
|
|
272
290
|
name: 'My Sales Agent',
|
|
273
291
|
version: '1.0.0',
|
|
274
|
-
pool,
|
|
292
|
+
pool, // wires idempotency + ctxMetadata + taskRegistry
|
|
275
293
|
});
|
|
276
294
|
|
|
277
295
|
serve(() => server, { port: process.env.PORT });
|