@adcp/sdk 5.25.1 → 6.0.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.
Files changed (288) hide show
  1. package/README.md +45 -7
  2. package/dist/lib/compliance-fixtures/index.d.ts +1 -1
  3. package/dist/lib/compliance-fixtures/index.js +1 -1
  4. package/dist/lib/core/AgentClient.d.ts.map +1 -1
  5. package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
  6. package/dist/lib/core/SingleAgentClient.js +15 -0
  7. package/dist/lib/core/SingleAgentClient.js.map +1 -1
  8. package/dist/lib/core/TaskExecutor.d.ts +7 -0
  9. package/dist/lib/core/TaskExecutor.d.ts.map +1 -1
  10. package/dist/lib/core/TaskExecutor.js +9 -2
  11. package/dist/lib/core/TaskExecutor.js.map +1 -1
  12. package/dist/lib/index.d.ts +1 -1
  13. package/dist/lib/index.d.ts.map +1 -1
  14. package/dist/lib/index.js +7 -8
  15. package/dist/lib/index.js.map +1 -1
  16. package/dist/lib/schemas/index.d.ts +1 -1
  17. package/dist/lib/schemas/index.js +1 -1
  18. package/dist/lib/server/create-adcp-server.d.ts +129 -11
  19. package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
  20. package/dist/lib/server/create-adcp-server.js +112 -2
  21. package/dist/lib/server/create-adcp-server.js.map +1 -1
  22. package/dist/lib/server/ctx-metadata/backends/memory.d.ts +27 -0
  23. package/dist/lib/server/ctx-metadata/backends/memory.d.ts.map +1 -0
  24. package/dist/lib/server/ctx-metadata/backends/memory.js +72 -0
  25. package/dist/lib/server/ctx-metadata/backends/memory.js.map +1 -0
  26. package/dist/lib/server/ctx-metadata/backends/pg.d.ts +62 -0
  27. package/dist/lib/server/ctx-metadata/backends/pg.d.ts.map +1 -0
  28. package/dist/lib/server/ctx-metadata/backends/pg.js +145 -0
  29. package/dist/lib/server/ctx-metadata/backends/pg.js.map +1 -0
  30. package/dist/lib/server/ctx-metadata/index.d.ts +15 -0
  31. package/dist/lib/server/ctx-metadata/index.d.ts.map +1 -0
  32. package/dist/lib/server/ctx-metadata/index.js +28 -0
  33. package/dist/lib/server/ctx-metadata/index.js.map +1 -0
  34. package/dist/lib/server/ctx-metadata/store.d.ts +177 -0
  35. package/dist/lib/server/ctx-metadata/store.d.ts.map +1 -0
  36. package/dist/lib/server/ctx-metadata/store.js +327 -0
  37. package/dist/lib/server/ctx-metadata/store.js.map +1 -0
  38. package/dist/lib/server/ctx-metadata/wire-shape.d.ts +55 -0
  39. package/dist/lib/server/ctx-metadata/wire-shape.d.ts.map +1 -0
  40. package/dist/lib/server/ctx-metadata/wire-shape.js +121 -0
  41. package/dist/lib/server/ctx-metadata/wire-shape.js.map +1 -0
  42. package/dist/lib/server/decisioning/account.d.ts +309 -0
  43. package/dist/lib/server/decisioning/account.d.ts.map +1 -0
  44. package/dist/lib/server/decisioning/account.js +102 -0
  45. package/dist/lib/server/decisioning/account.js.map +1 -0
  46. package/dist/lib/server/decisioning/admin-router.d.ts +75 -0
  47. package/dist/lib/server/decisioning/admin-router.d.ts.map +1 -0
  48. package/dist/lib/server/decisioning/admin-router.js +120 -0
  49. package/dist/lib/server/decisioning/admin-router.js.map +1 -0
  50. package/dist/lib/server/decisioning/assembly-helpers.d.ts +204 -0
  51. package/dist/lib/server/decisioning/assembly-helpers.d.ts.map +1 -0
  52. package/dist/lib/server/decisioning/assembly-helpers.js +173 -0
  53. package/dist/lib/server/decisioning/assembly-helpers.js.map +1 -0
  54. package/dist/lib/server/decisioning/async-outcome.d.ts +154 -0
  55. package/dist/lib/server/decisioning/async-outcome.d.ts.map +1 -0
  56. package/dist/lib/server/decisioning/async-outcome.js +239 -0
  57. package/dist/lib/server/decisioning/async-outcome.js.map +1 -0
  58. package/dist/lib/server/decisioning/capabilities.d.ts +251 -0
  59. package/dist/lib/server/decisioning/capabilities.d.ts.map +1 -0
  60. package/dist/lib/server/decisioning/capabilities.js +16 -0
  61. package/dist/lib/server/decisioning/capabilities.js.map +1 -0
  62. package/dist/lib/server/decisioning/context.d.ts +212 -0
  63. package/dist/lib/server/decisioning/context.d.ts.map +1 -0
  64. package/dist/lib/server/decisioning/context.js +26 -0
  65. package/dist/lib/server/decisioning/context.js.map +1 -0
  66. package/dist/lib/server/decisioning/errors-typed.d.ts +104 -0
  67. package/dist/lib/server/decisioning/errors-typed.d.ts.map +1 -0
  68. package/dist/lib/server/decisioning/errors-typed.js +304 -0
  69. package/dist/lib/server/decisioning/errors-typed.js.map +1 -0
  70. package/dist/lib/server/decisioning/helpers.d.ts +131 -0
  71. package/dist/lib/server/decisioning/helpers.d.ts.map +1 -0
  72. package/dist/lib/server/decisioning/helpers.js +134 -0
  73. package/dist/lib/server/decisioning/helpers.js.map +1 -0
  74. package/dist/lib/server/decisioning/index.d.ts +46 -0
  75. package/dist/lib/server/decisioning/index.d.ts.map +1 -0
  76. package/dist/lib/server/decisioning/index.js +120 -0
  77. package/dist/lib/server/decisioning/index.js.map +1 -0
  78. package/dist/lib/server/decisioning/list-helpers.d.ts +53 -0
  79. package/dist/lib/server/decisioning/list-helpers.d.ts.map +1 -0
  80. package/dist/lib/server/decisioning/list-helpers.js +96 -0
  81. package/dist/lib/server/decisioning/list-helpers.js.map +1 -0
  82. package/dist/lib/server/decisioning/manifest-helpers.d.ts +56 -0
  83. package/dist/lib/server/decisioning/manifest-helpers.d.ts.map +1 -0
  84. package/dist/lib/server/decisioning/manifest-helpers.js +78 -0
  85. package/dist/lib/server/decisioning/manifest-helpers.js.map +1 -0
  86. package/dist/lib/server/decisioning/pagination.d.ts +21 -0
  87. package/dist/lib/server/decisioning/pagination.d.ts.map +1 -0
  88. package/dist/lib/server/decisioning/pagination.js +12 -0
  89. package/dist/lib/server/decisioning/pagination.js.map +1 -0
  90. package/dist/lib/server/decisioning/platform.d.ts +188 -0
  91. package/dist/lib/server/decisioning/platform.d.ts.map +1 -0
  92. package/dist/lib/server/decisioning/platform.js +19 -0
  93. package/dist/lib/server/decisioning/platform.js.map +1 -0
  94. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +510 -0
  95. package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -0
  96. package/dist/lib/server/decisioning/runtime/from-platform.js +2196 -0
  97. package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -0
  98. package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts +114 -0
  99. package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts.map +1 -0
  100. package/dist/lib/server/decisioning/runtime/postgres-task-registry.js +247 -0
  101. package/dist/lib/server/decisioning/runtime/postgres-task-registry.js.map +1 -0
  102. package/dist/lib/server/decisioning/runtime/protocol-for-tool.d.ts +32 -0
  103. package/dist/lib/server/decisioning/runtime/protocol-for-tool.d.ts.map +1 -0
  104. package/dist/lib/server/decisioning/runtime/protocol-for-tool.js +127 -0
  105. package/dist/lib/server/decisioning/runtime/protocol-for-tool.js.map +1 -0
  106. package/dist/lib/server/decisioning/runtime/task-registry.d.ts +105 -0
  107. package/dist/lib/server/decisioning/runtime/task-registry.d.ts.map +1 -0
  108. package/dist/lib/server/decisioning/runtime/task-registry.js +96 -0
  109. package/dist/lib/server/decisioning/runtime/task-registry.js.map +1 -0
  110. package/dist/lib/server/decisioning/runtime/to-context.d.ts +54 -0
  111. package/dist/lib/server/decisioning/runtime/to-context.d.ts.map +1 -0
  112. package/dist/lib/server/decisioning/runtime/to-context.js +166 -0
  113. package/dist/lib/server/decisioning/runtime/to-context.js.map +1 -0
  114. package/dist/lib/server/decisioning/runtime/validate-platform.d.ts +20 -0
  115. package/dist/lib/server/decisioning/runtime/validate-platform.d.ts.map +1 -0
  116. package/dist/lib/server/decisioning/runtime/validate-platform.js +93 -0
  117. package/dist/lib/server/decisioning/runtime/validate-platform.js.map +1 -0
  118. package/dist/lib/server/decisioning/specialisms/audiences.d.ts +72 -0
  119. package/dist/lib/server/decisioning/specialisms/audiences.d.ts.map +1 -0
  120. package/dist/lib/server/decisioning/specialisms/audiences.js +15 -0
  121. package/dist/lib/server/decisioning/specialisms/audiences.js.map +1 -0
  122. package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts +92 -0
  123. package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts.map +1 -0
  124. package/dist/lib/server/decisioning/specialisms/brand-rights.js +28 -0
  125. package/dist/lib/server/decisioning/specialisms/brand-rights.js.map +1 -0
  126. package/dist/lib/server/decisioning/specialisms/campaign-governance.d.ts +67 -0
  127. package/dist/lib/server/decisioning/specialisms/campaign-governance.d.ts.map +1 -0
  128. package/dist/lib/server/decisioning/specialisms/campaign-governance.js +31 -0
  129. package/dist/lib/server/decisioning/specialisms/campaign-governance.js.map +1 -0
  130. package/dist/lib/server/decisioning/specialisms/content-standards.d.ts +78 -0
  131. package/dist/lib/server/decisioning/specialisms/content-standards.d.ts.map +1 -0
  132. package/dist/lib/server/decisioning/specialisms/content-standards.js +35 -0
  133. package/dist/lib/server/decisioning/specialisms/content-standards.js.map +1 -0
  134. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts +81 -0
  135. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts.map +1 -0
  136. package/dist/lib/server/decisioning/specialisms/creative-ad-server.js +28 -0
  137. package/dist/lib/server/decisioning/specialisms/creative-ad-server.js.map +1 -0
  138. package/dist/lib/server/decisioning/specialisms/creative.d.ts +144 -0
  139. package/dist/lib/server/decisioning/specialisms/creative.d.ts.map +1 -0
  140. package/dist/lib/server/decisioning/specialisms/creative.js +19 -0
  141. package/dist/lib/server/decisioning/specialisms/creative.js.map +1 -0
  142. package/dist/lib/server/decisioning/specialisms/lists.d.ts +61 -0
  143. package/dist/lib/server/decisioning/specialisms/lists.d.ts.map +1 -0
  144. package/dist/lib/server/decisioning/specialisms/lists.js +30 -0
  145. package/dist/lib/server/decisioning/specialisms/lists.js.map +1 -0
  146. package/dist/lib/server/decisioning/specialisms/sales.d.ts +163 -0
  147. package/dist/lib/server/decisioning/specialisms/sales.d.ts.map +1 -0
  148. package/dist/lib/server/decisioning/specialisms/sales.js +64 -0
  149. package/dist/lib/server/decisioning/specialisms/sales.js.map +1 -0
  150. package/dist/lib/server/decisioning/specialisms/signals.d.ts +64 -0
  151. package/dist/lib/server/decisioning/specialisms/signals.d.ts.map +1 -0
  152. package/dist/lib/server/decisioning/specialisms/signals.js +28 -0
  153. package/dist/lib/server/decisioning/specialisms/signals.js.map +1 -0
  154. package/dist/lib/server/decisioning/start-time.d.ts +76 -0
  155. package/dist/lib/server/decisioning/start-time.d.ts.map +1 -0
  156. package/dist/lib/server/decisioning/start-time.js +81 -0
  157. package/dist/lib/server/decisioning/start-time.js.map +1 -0
  158. package/dist/lib/server/decisioning/status-changes.d.ts +165 -0
  159. package/dist/lib/server/decisioning/status-changes.d.ts.map +1 -0
  160. package/dist/lib/server/decisioning/status-changes.js +131 -0
  161. package/dist/lib/server/decisioning/status-changes.js.map +1 -0
  162. package/dist/lib/server/decisioning/status-mappers.d.ts +46 -0
  163. package/dist/lib/server/decisioning/status-mappers.d.ts.map +1 -0
  164. package/dist/lib/server/decisioning/status-mappers.js +46 -0
  165. package/dist/lib/server/decisioning/status-mappers.js.map +1 -0
  166. package/dist/lib/server/decisioning/tenant-registry.d.ts +289 -0
  167. package/dist/lib/server/decisioning/tenant-registry.d.ts.map +1 -0
  168. package/dist/lib/server/decisioning/tenant-registry.js +503 -0
  169. package/dist/lib/server/decisioning/tenant-registry.js.map +1 -0
  170. package/dist/lib/server/express-adapter.d.ts +1 -1
  171. package/dist/lib/server/express-adapter.js +1 -1
  172. package/dist/lib/server/governance.d.ts +1 -1
  173. package/dist/lib/server/governance.js +1 -1
  174. package/dist/lib/server/idempotency/store.d.ts +1 -1
  175. package/dist/lib/server/idempotency/store.js +1 -1
  176. package/dist/lib/server/index.d.ts +9 -2
  177. package/dist/lib/server/index.d.ts.map +1 -1
  178. package/dist/lib/server/index.js +79 -4
  179. package/dist/lib/server/index.js.map +1 -1
  180. package/dist/lib/server/legacy/v5/index.d.ts +38 -0
  181. package/dist/lib/server/legacy/v5/index.d.ts.map +1 -0
  182. package/dist/lib/server/legacy/v5/index.js +60 -0
  183. package/dist/lib/server/legacy/v5/index.js.map +1 -0
  184. package/dist/lib/server/normalize-errors.d.ts +88 -0
  185. package/dist/lib/server/normalize-errors.d.ts.map +1 -0
  186. package/dist/lib/server/normalize-errors.js +146 -0
  187. package/dist/lib/server/normalize-errors.js.map +1 -0
  188. package/dist/lib/server/pick-safe-details.d.ts +90 -0
  189. package/dist/lib/server/pick-safe-details.d.ts.map +1 -0
  190. package/dist/lib/server/pick-safe-details.js +148 -0
  191. package/dist/lib/server/pick-safe-details.js.map +1 -0
  192. package/dist/lib/server/postgres-state-store.d.ts +1 -1
  193. package/dist/lib/server/postgres-state-store.js +1 -1
  194. package/dist/lib/server/responses.d.ts +38 -0
  195. package/dist/lib/server/responses.d.ts.map +1 -1
  196. package/dist/lib/server/responses.js +38 -0
  197. package/dist/lib/server/responses.js.map +1 -1
  198. package/dist/lib/server/state-store.d.ts +1 -1
  199. package/dist/lib/server/state-store.js +1 -1
  200. package/dist/lib/server/test-controller.d.ts +10 -3
  201. package/dist/lib/server/test-controller.d.ts.map +1 -1
  202. package/dist/lib/server/test-controller.js +10 -3
  203. package/dist/lib/server/test-controller.js.map +1 -1
  204. package/dist/lib/testing/comply-controller.d.ts +47 -1
  205. package/dist/lib/testing/comply-controller.d.ts.map +1 -1
  206. package/dist/lib/testing/comply-controller.js +11 -4
  207. package/dist/lib/testing/comply-controller.js.map +1 -1
  208. package/dist/lib/testing/index.d.ts +1 -1
  209. package/dist/lib/testing/index.d.ts.map +1 -1
  210. package/dist/lib/testing/index.js.map +1 -1
  211. package/dist/lib/testing/personas/index.d.ts +143 -0
  212. package/dist/lib/testing/personas/index.d.ts.map +1 -0
  213. package/dist/lib/testing/personas/index.js +190 -0
  214. package/dist/lib/testing/personas/index.js.map +1 -0
  215. package/dist/lib/testing/storyboard/index.d.ts +1 -1
  216. package/dist/lib/testing/storyboard/index.d.ts.map +1 -1
  217. package/dist/lib/testing/storyboard/index.js +3 -2
  218. package/dist/lib/testing/storyboard/index.js.map +1 -1
  219. package/dist/lib/testing/storyboard/runner.d.ts +13 -0
  220. package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
  221. package/dist/lib/testing/storyboard/runner.js +179 -7
  222. package/dist/lib/testing/storyboard/runner.js.map +1 -1
  223. package/dist/lib/types/asset-instances.d.ts +1 -0
  224. package/dist/lib/types/asset-instances.d.ts.map +1 -1
  225. package/dist/lib/types/core.generated.d.ts +203 -98
  226. package/dist/lib/types/core.generated.d.ts.map +1 -1
  227. package/dist/lib/types/core.generated.js +1 -1
  228. package/dist/lib/types/index.d.ts +1 -0
  229. package/dist/lib/types/index.d.ts.map +1 -1
  230. package/dist/lib/types/index.js.map +1 -1
  231. package/dist/lib/types/schemas.generated.d.ts +599 -159
  232. package/dist/lib/types/schemas.generated.d.ts.map +1 -1
  233. package/dist/lib/types/schemas.generated.js +175 -94
  234. package/dist/lib/types/schemas.generated.js.map +1 -1
  235. package/dist/lib/types/tools.generated.d.ts +315 -46
  236. package/dist/lib/types/tools.generated.d.ts.map +1 -1
  237. package/dist/lib/utils/capabilities.d.ts +1 -1
  238. package/dist/lib/utils/capabilities.d.ts.map +1 -1
  239. package/dist/lib/utils/capabilities.js +6 -0
  240. package/dist/lib/utils/capabilities.js.map +1 -1
  241. package/dist/lib/validation/schema-validator.d.ts +13 -0
  242. package/dist/lib/validation/schema-validator.d.ts.map +1 -1
  243. package/dist/lib/validation/schema-validator.js +240 -3
  244. package/dist/lib/validation/schema-validator.js.map +1 -1
  245. package/dist/lib/version.d.ts +3 -3
  246. package/dist/lib/version.d.ts.map +1 -1
  247. package/dist/lib/version.js +3 -3
  248. package/dist/lib/version.js.map +1 -1
  249. package/docs/guides/BUILD-AN-AGENT.md +30 -5
  250. package/docs/llms.txt +28 -17
  251. package/examples/README.md +3 -1
  252. package/examples/decisioning-platform-broadcast-tv.ts +300 -0
  253. package/examples/decisioning-platform-identity-graph.ts +214 -0
  254. package/examples/decisioning-platform-mock-seller.ts +332 -0
  255. package/examples/decisioning-platform-multi-tenant.ts +128 -0
  256. package/examples/decisioning-platform-programmatic.ts +254 -0
  257. package/examples/signals-agent.ts +1 -1
  258. package/package.json +13 -2
  259. package/skills/build-brand-rights-agent/SKILL.md +10 -3
  260. package/skills/build-creative-agent/SKILL.md +94 -64
  261. package/skills/build-decisioning-creative-template/SKILL.md +554 -0
  262. package/skills/build-decisioning-platform/SKILL.md +304 -0
  263. package/skills/build-decisioning-platform/advanced/BRAND-RIGHTS.md +25 -0
  264. package/skills/build-decisioning-platform/advanced/COMPLIANCE.md +23 -0
  265. package/skills/build-decisioning-platform/advanced/GOVERNANCE.md +24 -0
  266. package/skills/build-decisioning-platform/advanced/HITL.md +34 -0
  267. package/skills/build-decisioning-platform/advanced/IDEMPOTENCY.md +52 -0
  268. package/skills/build-decisioning-platform/advanced/MULTI-TENANT.md +47 -0
  269. package/skills/build-decisioning-platform/advanced/OAUTH.md +22 -0
  270. package/skills/build-decisioning-platform/advanced/REFERENCE.md +991 -0
  271. package/skills/build-decisioning-platform/advanced/SANDBOX.md +24 -0
  272. package/skills/build-decisioning-platform/advanced/STATE-MACHINE.md +52 -0
  273. package/skills/build-decisioning-signal-marketplace/SKILL.md +269 -0
  274. package/skills/build-generative-seller-agent/SKILL.md +89 -53
  275. package/skills/build-governance-agent/SKILL.md +76 -45
  276. package/skills/build-retail-media-agent/SKILL.md +87 -62
  277. package/skills/build-seller-agent/SKILL.md +384 -255
  278. package/skills/build-seller-agent/deployment.md +5 -3
  279. package/skills/build-seller-agent/specialisms/audience-sync.md +0 -2
  280. package/skills/build-seller-agent/specialisms/sales-broadcast-tv.md +0 -2
  281. package/skills/build-seller-agent/specialisms/sales-guaranteed.md +0 -2
  282. package/skills/build-seller-agent/specialisms/sales-non-guaranteed.md +0 -2
  283. package/skills/build-seller-agent/specialisms/sales-proposal-mode.md +0 -2
  284. package/skills/build-seller-agent/specialisms/sales-social.md +0 -2
  285. package/skills/build-seller-agent/specialisms/signed-requests.md +0 -2
  286. package/skills/build-si-agent/SKILL.md +40 -32
  287. package/skills/build-signals-agent/SKILL.md +139 -92
  288. package/skills/call-adcp-agent.previous/SKILL.md +5 -0
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * SignalsPlatform — signal-marketplace + signal-owned specialism interface
4
+ * (v6.0).
5
+ *
6
+ * Two specialisms share the same platform interface:
7
+ *
8
+ * - **`signal-marketplace`** — third-party data brokers serving curated
9
+ * audience signals (LiveRamp, Oracle Data Cloud, third-party DMPs)
10
+ * - **`signal-owned`** — first-party data providers serving their own
11
+ * signals (publisher first-party data, retailer customer-graph)
12
+ *
13
+ * Both expose the same surface: `getSignals` for catalog discovery and
14
+ * `activateSignal` for provisioning a signal onto a destination platform.
15
+ *
16
+ * Async story: `activate_signal` is sync at the wire level — its response
17
+ * union has no `Submitted` arm. Long-running activation pipelines (identity-
18
+ * graph match: 5-30 min, destination provisioning: hours) return the wire
19
+ * `ActivateSignalSuccess` immediately with deployments in `pending` state,
20
+ * then emit `publishStatusChange({ resource_type: 'signal', ... })` events
21
+ * as each deployment reaches `activating` / `deployed` / `failed`.
22
+ *
23
+ * Status: Preview / 6.0.
24
+ *
25
+ * @public
26
+ */
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ //# sourceMappingURL=signals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signals.js","sourceRoot":"","sources":["../../../../../src/lib/server/decisioning/specialisms/signals.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Resolve a wire `start_time` into a concrete `Date`, with platform-aware
3
+ * ASAP semantics.
4
+ *
5
+ * The wire shape is `string | undefined` where the string is either an
6
+ * ISO 8601 timestamp OR the literal `'asap'`. Every platform method that
7
+ * touches `start_time` has to:
8
+ * 1. Handle the union (and the undefined case)
9
+ * 2. Validate that an ISO timestamp parses + isn't in the past
10
+ * 3. Interpret `'asap'` as a sensible date for THIS platform
11
+ *
12
+ * Step 3 is platform-specific. For programmatic sellers, ASAP means
13
+ * `now()`. For guaranteed/broadcast sellers with a 1-3 day trafficker
14
+ * approval pipeline, ASAP means `now() + approval lead time` because the
15
+ * buy can't physically start before the operator signs off. This helper
16
+ * takes a config object so each adopter injects their own semantics
17
+ * consistently across `createMediaBuy(Task)` and `updateMediaBuy`.
18
+ *
19
+ * @example Programmatic seller (no approval)
20
+ * ```ts
21
+ * const startAt = resolveStartTime(req.start_time, {});
22
+ * // 'asap' → now()
23
+ * // '2026-05-01T00:00:00Z' → that date
24
+ * // undefined → now()
25
+ * ```
26
+ *
27
+ * @example Broadcast seller with 2-day IO sign-off + 1-day default lead
28
+ * ```ts
29
+ * const startAt = resolveStartTime(req.start_time, {
30
+ * asapLeadTimeMs: 2 * 86_400_000,
31
+ * defaultLeadTimeMs: 86_400_000,
32
+ * notBefore: new Date(),
33
+ * });
34
+ * // 'asap' → now() + 2 days
35
+ * // past date → throws AdcpError(INVALID_REQUEST)
36
+ * // undefined → now() + 1 day
37
+ * ```
38
+ *
39
+ * @public
40
+ */
41
+ export interface ResolveStartTimeOptions {
42
+ /**
43
+ * When `start_time` is the literal `'asap'`, return `now() + this`.
44
+ * Models the platform's approval / trafficking pipeline that runs
45
+ * before a buy can actually start. Default `0` (interpret asap as
46
+ * truly now, suitable for programmatic platforms).
47
+ */
48
+ asapLeadTimeMs?: number;
49
+ /**
50
+ * When `start_time` is `undefined`, return `now() + this`. Lets adopters
51
+ * pick whether "no start_time specified" means "asap" (use the same
52
+ * lead time) or some other default. Defaults to the value of
53
+ * `asapLeadTimeMs`.
54
+ */
55
+ defaultLeadTimeMs?: number;
56
+ /**
57
+ * Reject parsed timestamps strictly before this. Most adopters pass
58
+ * `new Date()` to forbid past start times. Omit to skip the check.
59
+ */
60
+ notBefore?: Date;
61
+ /**
62
+ * Override the field name on the error message when validation throws.
63
+ * Defaults to `'start_time'`. Set to `'patch.start_time'` (or similar)
64
+ * when calling from `updateMediaBuy`.
65
+ */
66
+ fieldName?: string;
67
+ }
68
+ /**
69
+ * Normalize the wire `start_time` value into a guaranteed-non-null Date.
70
+ *
71
+ * Throws `AdcpError('INVALID_REQUEST')` when the string isn't a parseable
72
+ * ISO 8601 timestamp OR when the parsed date is before `opts.notBefore`.
73
+ * Returns `now() + lead time` for `'asap'` and `undefined` inputs.
74
+ */
75
+ export declare function resolveStartTime(raw: string | undefined, opts?: ResolveStartTimeOptions): Date;
76
+ //# sourceMappingURL=start-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-time.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/start-time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAIH,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,GAAE,uBAA4B,GAAG,IAAI,CAgClG"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /**
3
+ * Resolve a wire `start_time` into a concrete `Date`, with platform-aware
4
+ * ASAP semantics.
5
+ *
6
+ * The wire shape is `string | undefined` where the string is either an
7
+ * ISO 8601 timestamp OR the literal `'asap'`. Every platform method that
8
+ * touches `start_time` has to:
9
+ * 1. Handle the union (and the undefined case)
10
+ * 2. Validate that an ISO timestamp parses + isn't in the past
11
+ * 3. Interpret `'asap'` as a sensible date for THIS platform
12
+ *
13
+ * Step 3 is platform-specific. For programmatic sellers, ASAP means
14
+ * `now()`. For guaranteed/broadcast sellers with a 1-3 day trafficker
15
+ * approval pipeline, ASAP means `now() + approval lead time` because the
16
+ * buy can't physically start before the operator signs off. This helper
17
+ * takes a config object so each adopter injects their own semantics
18
+ * consistently across `createMediaBuy(Task)` and `updateMediaBuy`.
19
+ *
20
+ * @example Programmatic seller (no approval)
21
+ * ```ts
22
+ * const startAt = resolveStartTime(req.start_time, {});
23
+ * // 'asap' → now()
24
+ * // '2026-05-01T00:00:00Z' → that date
25
+ * // undefined → now()
26
+ * ```
27
+ *
28
+ * @example Broadcast seller with 2-day IO sign-off + 1-day default lead
29
+ * ```ts
30
+ * const startAt = resolveStartTime(req.start_time, {
31
+ * asapLeadTimeMs: 2 * 86_400_000,
32
+ * defaultLeadTimeMs: 86_400_000,
33
+ * notBefore: new Date(),
34
+ * });
35
+ * // 'asap' → now() + 2 days
36
+ * // past date → throws AdcpError(INVALID_REQUEST)
37
+ * // undefined → now() + 1 day
38
+ * ```
39
+ *
40
+ * @public
41
+ */
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.resolveStartTime = resolveStartTime;
44
+ const async_outcome_1 = require("./async-outcome");
45
+ /**
46
+ * Normalize the wire `start_time` value into a guaranteed-non-null Date.
47
+ *
48
+ * Throws `AdcpError('INVALID_REQUEST')` when the string isn't a parseable
49
+ * ISO 8601 timestamp OR when the parsed date is before `opts.notBefore`.
50
+ * Returns `now() + lead time` for `'asap'` and `undefined` inputs.
51
+ */
52
+ function resolveStartTime(raw, opts = {}) {
53
+ const asapLead = opts.asapLeadTimeMs ?? 0;
54
+ const defaultLead = opts.defaultLeadTimeMs ?? asapLead;
55
+ const fieldName = opts.fieldName ?? 'start_time';
56
+ if (raw === undefined) {
57
+ return new Date(Date.now() + defaultLead);
58
+ }
59
+ if (raw === 'asap') {
60
+ return new Date(Date.now() + asapLead);
61
+ }
62
+ const parsed = new Date(raw);
63
+ if (isNaN(parsed.getTime())) {
64
+ throw new async_outcome_1.AdcpError('INVALID_REQUEST', {
65
+ recovery: 'correctable',
66
+ message: `${fieldName} is not a valid ISO 8601 timestamp: '${raw}'`,
67
+ field: fieldName,
68
+ suggestion: "Use 'asap' or an ISO 8601 timestamp (e.g., '2026-05-01T00:00:00Z')",
69
+ });
70
+ }
71
+ if (opts.notBefore && parsed.getTime() < opts.notBefore.getTime()) {
72
+ throw new async_outcome_1.AdcpError('INVALID_REQUEST', {
73
+ recovery: 'correctable',
74
+ message: `${fieldName} is in the past: ${parsed.toISOString()} (cutoff ${opts.notBefore.toISOString()})`,
75
+ field: fieldName,
76
+ suggestion: 'Use a future timestamp or `asap`',
77
+ });
78
+ }
79
+ return parsed;
80
+ }
81
+ //# sourceMappingURL=start-time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-time.js","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/start-time.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;;AAuCH,4CAgCC;AArED,mDAA4C;AA8B5C;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,GAAuB,EAAE,OAAgC,EAAE;IAC1F,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,IAAI,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,IAAI,QAAQ,CAAC;IACvD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,YAAY,CAAC;IAEjD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,yBAAS,CAAC,iBAAiB,EAAE;YACrC,QAAQ,EAAE,aAAa;YACvB,OAAO,EAAE,GAAG,SAAS,wCAAwC,GAAG,GAAG;YACnE,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,oEAAoE;SACjF,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;QAClE,MAAM,IAAI,yBAAS,CAAC,iBAAiB,EAAE;YACrC,QAAQ,EAAE,aAAa;YACvB,OAAO,EAAE,GAAG,SAAS,oBAAoB,MAAM,CAAC,WAAW,EAAE,YAAY,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG;YACxG,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,kCAAkC;SAC/C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Status-change event bus for the v6.0 decisioning runtime.
3
+ *
4
+ * Adopters call `publishStatusChange(...)` from anywhere — webhook handler,
5
+ * cron, in-process worker, the body of a `*Task` method — to push lifecycle
6
+ * updates on a resource the framework knows about. The framework records
7
+ * the change against the resource and projects it to subscribed buyers via
8
+ * the MCP Resources subscription extension (`notifications/resources/updated`)
9
+ * and the equivalent A2A DataPart-typed message contract.
10
+ *
11
+ * Ten resource types are wired in v6.0 (matches AdCP 3.0 lifecycle
12
+ * channels):
13
+ *
14
+ * - `media_buy` — pending → active → completed; paused, canceled
15
+ * - `creative` — pending_review → approved/rejected
16
+ * - `audience` — matching → matched → activating → active
17
+ * - `signal` — pending → activated → expired
18
+ * - `proposal` — issued → accepted/expired/withdrawn
19
+ * - `plan` — draft → submitted → approved/rejected
20
+ * - `rights_grant` — pending → granted/denied/expired
21
+ * - `delivery_report`— staging → published (manual report-runs)
22
+ * - `property_list` — list-changed events (cache invalidation, fetch_token revoke)
23
+ * - `collection_list`— list-changed events (cache invalidation, fetch_token revoke)
24
+ *
25
+ * The bus is module-level so adopters can call `publishStatusChange(...)`
26
+ * without holding a reference to the server. The framework wires the bus
27
+ * into the server's resource registry at construction; in tests, the
28
+ * registry can be swapped via `setStatusChangeBus(...)`.
29
+ *
30
+ * Status: Preview / 6.0. Wire-level MCP Resources subscription handlers
31
+ * and the A2A backport land in a subsequent commit; this file ships the
32
+ * adopter-facing primitive and an in-memory subscriber model the runtime
33
+ * can consume.
34
+ *
35
+ * @public
36
+ */
37
+ /**
38
+ * Resource categories whose lifecycle changes can be published on the
39
+ * status-change bus and projected to subscribed buyers.
40
+ *
41
+ * **Spec status (v6.0):** The AdCP spec doesn't yet ship a closed enum
42
+ * for `resource_type`. The values below are the v6 SDK's working set —
43
+ * the resource categories adopters publish lifecycle events against
44
+ * today. They become wire-visible via the URI scheme
45
+ * `adcp://{account_id}/{resource_type}/{resource_id}` projected to MCP
46
+ * Resources subscriptions.
47
+ *
48
+ * Filed upstream as adcontextprotocol/adcp#3412 proposing a normative
49
+ * `enums/status-change-resource-type.json`. When the spec lands the
50
+ * enum, this type becomes a `$ref` to the generated schema. Until then
51
+ * adopters subscribing across multiple AdCP agents may see drift; the
52
+ * SDK's set is the working canonical until the spec consolidates.
53
+ *
54
+ * Adopters publishing custom resource types not in this list should
55
+ * prefix with `x-` (e.g., `'x-pcim_session'`) to reduce collision risk
56
+ * with the eventual normative enum. The framework accepts any string
57
+ * (the type is widened with `(string & {})` for forward-compat) but
58
+ * only the values listed here have stable cross-SDK semantics.
59
+ */
60
+ export type StatusChangeResourceType = 'media_buy' | 'creative' | 'audience' | 'signal' | 'proposal' | 'plan' | 'rights_grant' | 'delivery_report' | 'property_list' | 'collection_list' | (string & {});
61
+ /**
62
+ * A single status-change event.
63
+ *
64
+ * `account_id` scopes the event to a tenant; subscribers receive only
65
+ * events for their resolved account. `resource_uri` follows the MCP
66
+ * Resources URI scheme: `adcp://{account_id}/{resource_type}/{resource_id}`.
67
+ */
68
+ export interface StatusChange<TPayload = unknown> {
69
+ account_id: string;
70
+ resource_type: StatusChangeResourceType;
71
+ resource_id: string;
72
+ /** Canonical MCP Resources URI for this resource. */
73
+ resource_uri: string;
74
+ /** ISO 8601 timestamp the change was observed. */
75
+ at: string;
76
+ /**
77
+ * Resource-type-specific change payload. Shape is the wire fragment the
78
+ * subscribed buyer will see — e.g., for `media_buy` it's the AdCP
79
+ * `media_buy_status_changes` message body.
80
+ */
81
+ payload: TPayload;
82
+ /**
83
+ * Correlation id linking this change back to the buyer request that
84
+ * caused it. Useful for "show me everything that happened from this
85
+ * `create_media_buy` call" observability across HITL flows. Adopters
86
+ * pass through `ctx.task.id` (for `*Task`-driven changes) or any
87
+ * stable request identifier they generate at dispatch time.
88
+ *
89
+ * Optional — many status changes originate from cron / webhook /
90
+ * upstream-platform events that have no buyer-request correlation.
91
+ */
92
+ caused_by_request_id?: string;
93
+ /**
94
+ * Status the resource was transitioning FROM. Lets subscribers assert
95
+ * legal transitions (`from: 'matching' → to: 'active'` is fine;
96
+ * `from: 'failed' → to: 'matching'` is a state-machine bug). The
97
+ * framework doesn't validate transitions in v6.0 (no per-resource
98
+ * state machine yet); the field is captured and projected to the
99
+ * wire so downstream consumers can.
100
+ */
101
+ previous_status?: string;
102
+ }
103
+ export interface PublishStatusChangeOpts<TPayload = unknown> {
104
+ account_id: string;
105
+ resource_type: StatusChangeResourceType;
106
+ resource_id: string;
107
+ payload: TPayload;
108
+ /** Override the timestamp (defaults to now). Useful for replay/backfill. */
109
+ at?: string;
110
+ /**
111
+ * Correlation id linking this change to the buyer request that caused
112
+ * it. Inside `*Task` method bodies, pass `ctx.task.id` to thread the
113
+ * task lifecycle. Outside HITL flows, pass any stable request id you
114
+ * derive at dispatch time. Optional.
115
+ */
116
+ caused_by_request_id?: string;
117
+ /** Status the resource was transitioning FROM. Optional. */
118
+ previous_status?: string;
119
+ }
120
+ export type StatusChangeListener = (event: StatusChange) => void | Promise<void>;
121
+ export interface StatusChangeBus {
122
+ publish<TPayload>(opts: PublishStatusChangeOpts<TPayload>): void;
123
+ /**
124
+ * Subscribe a listener. Returns an unsubscribe function. Listeners are
125
+ * fire-and-forget; rejected promises are caught and logged so one bad
126
+ * subscriber doesn't break delivery to others.
127
+ */
128
+ subscribe(listener: StatusChangeListener): () => void;
129
+ /** Snapshot the most-recent N events (in-memory cache for `tasks/get` + replay). */
130
+ recent(limit?: number): readonly StatusChange[];
131
+ }
132
+ export declare function createInMemoryStatusChangeBus(opts?: {
133
+ recentLimit?: number;
134
+ }): StatusChangeBus;
135
+ /**
136
+ * Push a status change for a resource. Adopters call this from anywhere —
137
+ * webhook handler, cron, in-process worker — to surface lifecycle changes
138
+ * the framework projects to subscribed buyers.
139
+ *
140
+ * ```ts
141
+ * // After GAM webhook reports order activation:
142
+ * publishStatusChange({
143
+ * account_id: account.id,
144
+ * resource_type: 'media_buy',
145
+ * resource_id: gamOrderToBuyId(order),
146
+ * payload: { status: 'active', activated_at: order.startTime },
147
+ * });
148
+ * ```
149
+ *
150
+ * Buyers subscribed via MCP `resources/subscribe` (or the A2A equivalent)
151
+ * receive the change as a `notifications/resources/updated` notification
152
+ * carrying the `payload` as the resource's wire fragment.
153
+ */
154
+ export declare function publishStatusChange<TPayload>(opts: PublishStatusChangeOpts<TPayload>): void;
155
+ /**
156
+ * Replace the active bus. The framework calls this at server construction
157
+ * to wire its own bus implementation; tests can call it to swap in a fake.
158
+ *
159
+ * Returns the previous bus so the caller can restore it (e.g., in a test
160
+ * teardown).
161
+ */
162
+ export declare function setStatusChangeBus(bus: StatusChangeBus): StatusChangeBus;
163
+ /** Read the active bus (for the framework to wire subscribers). */
164
+ export declare function getStatusChangeBus(): StatusChangeBus;
165
+ //# sourceMappingURL=status-changes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-changes.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/status-chang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B,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IACjE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,IAAI,CAAC;IACtD,oFAAoF;IACpF,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,YAAY,EAAE,CAAC;CACjD;AAID,wBAAgB,6BAA6B,CAAC,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,CA8C9F;AAQD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,IAAI,EAAE,uBAAuB,CAAC,QAAQ,CAAC,GAAG,IAAI,CAE3F;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,eAAe,CAIxE;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ /**
3
+ * Status-change event bus for the v6.0 decisioning runtime.
4
+ *
5
+ * Adopters call `publishStatusChange(...)` from anywhere — webhook handler,
6
+ * cron, in-process worker, the body of a `*Task` method — to push lifecycle
7
+ * updates on a resource the framework knows about. The framework records
8
+ * the change against the resource and projects it to subscribed buyers via
9
+ * the MCP Resources subscription extension (`notifications/resources/updated`)
10
+ * and the equivalent A2A DataPart-typed message contract.
11
+ *
12
+ * Ten resource types are wired in v6.0 (matches AdCP 3.0 lifecycle
13
+ * channels):
14
+ *
15
+ * - `media_buy` — pending → active → completed; paused, canceled
16
+ * - `creative` — pending_review → approved/rejected
17
+ * - `audience` — matching → matched → activating → active
18
+ * - `signal` — pending → activated → expired
19
+ * - `proposal` — issued → accepted/expired/withdrawn
20
+ * - `plan` — draft → submitted → approved/rejected
21
+ * - `rights_grant` — pending → granted/denied/expired
22
+ * - `delivery_report`— staging → published (manual report-runs)
23
+ * - `property_list` — list-changed events (cache invalidation, fetch_token revoke)
24
+ * - `collection_list`— list-changed events (cache invalidation, fetch_token revoke)
25
+ *
26
+ * The bus is module-level so adopters can call `publishStatusChange(...)`
27
+ * without holding a reference to the server. The framework wires the bus
28
+ * into the server's resource registry at construction; in tests, the
29
+ * registry can be swapped via `setStatusChangeBus(...)`.
30
+ *
31
+ * Status: Preview / 6.0. Wire-level MCP Resources subscription handlers
32
+ * and the A2A backport land in a subsequent commit; this file ships the
33
+ * adopter-facing primitive and an in-memory subscriber model the runtime
34
+ * can consume.
35
+ *
36
+ * @public
37
+ */
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.createInMemoryStatusChangeBus = createInMemoryStatusChangeBus;
40
+ exports.publishStatusChange = publishStatusChange;
41
+ exports.setStatusChangeBus = setStatusChangeBus;
42
+ exports.getStatusChangeBus = getStatusChangeBus;
43
+ const DEFAULT_RECENT_LIMIT = 1000;
44
+ function createInMemoryStatusChangeBus(opts) {
45
+ const listeners = new Set();
46
+ const recent = [];
47
+ const recentLimit = opts?.recentLimit ?? DEFAULT_RECENT_LIMIT;
48
+ return {
49
+ publish(eventOpts) {
50
+ const event = {
51
+ account_id: eventOpts.account_id,
52
+ resource_type: eventOpts.resource_type,
53
+ resource_id: eventOpts.resource_id,
54
+ resource_uri: `adcp://${eventOpts.account_id}/${eventOpts.resource_type}/${eventOpts.resource_id}`,
55
+ at: eventOpts.at ?? new Date().toISOString(),
56
+ payload: eventOpts.payload,
57
+ ...(eventOpts.caused_by_request_id !== undefined && { caused_by_request_id: eventOpts.caused_by_request_id }),
58
+ ...(eventOpts.previous_status !== undefined && { previous_status: eventOpts.previous_status }),
59
+ };
60
+ recent.push(event);
61
+ if (recent.length > recentLimit)
62
+ recent.shift();
63
+ for (const listener of listeners) {
64
+ try {
65
+ const result = listener(event);
66
+ if (result && typeof result.catch === 'function') {
67
+ result.catch((err) => {
68
+ // eslint-disable-next-line no-console
69
+ console.warn('[adcp] status-change listener rejected:', err);
70
+ });
71
+ }
72
+ }
73
+ catch (err) {
74
+ // eslint-disable-next-line no-console
75
+ console.warn('[adcp] status-change listener threw:', err);
76
+ }
77
+ }
78
+ },
79
+ subscribe(listener) {
80
+ listeners.add(listener);
81
+ return () => listeners.delete(listener);
82
+ },
83
+ recent(limit) {
84
+ const n = limit ?? recent.length;
85
+ return recent.slice(-n);
86
+ },
87
+ };
88
+ }
89
+ // ---------------------------------------------------------------------------
90
+ // Module-level adopter-facing primitive
91
+ // ---------------------------------------------------------------------------
92
+ let activeBus = createInMemoryStatusChangeBus();
93
+ /**
94
+ * Push a status change for a resource. Adopters call this from anywhere —
95
+ * webhook handler, cron, in-process worker — to surface lifecycle changes
96
+ * the framework projects to subscribed buyers.
97
+ *
98
+ * ```ts
99
+ * // After GAM webhook reports order activation:
100
+ * publishStatusChange({
101
+ * account_id: account.id,
102
+ * resource_type: 'media_buy',
103
+ * resource_id: gamOrderToBuyId(order),
104
+ * payload: { status: 'active', activated_at: order.startTime },
105
+ * });
106
+ * ```
107
+ *
108
+ * Buyers subscribed via MCP `resources/subscribe` (or the A2A equivalent)
109
+ * receive the change as a `notifications/resources/updated` notification
110
+ * carrying the `payload` as the resource's wire fragment.
111
+ */
112
+ function publishStatusChange(opts) {
113
+ activeBus.publish(opts);
114
+ }
115
+ /**
116
+ * Replace the active bus. The framework calls this at server construction
117
+ * to wire its own bus implementation; tests can call it to swap in a fake.
118
+ *
119
+ * Returns the previous bus so the caller can restore it (e.g., in a test
120
+ * teardown).
121
+ */
122
+ function setStatusChangeBus(bus) {
123
+ const prev = activeBus;
124
+ activeBus = bus;
125
+ return prev;
126
+ }
127
+ /** Read the active bus (for the framework to wire subscribers). */
128
+ function getStatusChangeBus() {
129
+ return activeBus;
130
+ }
131
+ //# sourceMappingURL=status-changes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-changes.js","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/status-changes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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E; LiveRamp
4
+ * uses INGESTING/MATCHED/ACTIVATED). The platform implements one mapper
5
+ * per AdCP-typed status; framework calls them where wire responses need
6
+ * the AdCP-typed value.
7
+ *
8
+ * **Scope**: each mapper is a wire-status decoder for a single native
9
+ * status string. Rollup logic — taking N native statuses across multiple
10
+ * objects (GAM Order + LineItems, Criteo campaign + line items + creatives)
11
+ * and computing one AdCP-typed status — is platform-specific and lives in
12
+ * adapter code, NOT here. The mapper answers "what does GAM's `READY` mean
13
+ * in AdCP terms?"; the adapter answers "if any LineItem is `DISAPPROVED`,
14
+ * the buy is `rejected`; if all are `DELIVERING`, the buy is `active`".
15
+ *
16
+ * Status: Preview / 6.0.
17
+ *
18
+ * @public
19
+ */
20
+ import type { AdcpAccountStatus } from './account';
21
+ /**
22
+ * One method per AdCP-typed status. All optional — platforms only map the
23
+ * statuses their AdCP-claimed specialisms expose.
24
+ */
25
+ export interface StatusMappers {
26
+ account?(native: string): AdcpAccountStatus;
27
+ mediaBuy?(native: string): AdcpMediaBuyStatus;
28
+ creative?(native: string): AdcpCreativeStatus;
29
+ plan?(native: string): AdcpPlanStatus;
30
+ }
31
+ export type AdcpMediaBuyStatus = 'pending_creatives' | 'pending_start' | 'active' | 'paused' | 'completed' | 'rejected' | 'canceled';
32
+ export type AdcpCreativeStatus = 'pending_review' | 'approved' | 'rejected' | 'archived';
33
+ export type AdcpPlanStatus = 'active' | 'exhausted' | 'expired' | 'paused';
34
+ /**
35
+ * Identity mappers — when the platform's native status strings already match
36
+ * AdCP's typed enums (most modern platforms do for `active` / `paused`),
37
+ * adopters use this instead of writing the obvious passthrough functions.
38
+ *
39
+ * Falls back to the AdCP default for unknown native values:
40
+ * - mediaBuy: `'pending_creatives'`
41
+ * - creative: `'pending_review'`
42
+ * - account: `'active'`
43
+ * - plan: `'active'`
44
+ */
45
+ export declare const identityStatusMappers: StatusMappers;
46
+ //# sourceMappingURL=status-mappers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-mappers.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/status-mappers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC;IAC5C,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAC9C,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAC9C,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC;CACvC;AAED,MAAM,MAAM,kBAAkB,GAC1B,mBAAmB,GACnB,eAAe,GACf,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,UAAU,GACV,UAAU,CAAC;AAEf,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAEzF,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAcnC,CAAC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Native status mapping. Real ad systems have their own status models
4
+ * (GAM uses DRAFT/APPROVED/etc.; Spotify uses PENDING/ACTIVE; LiveRamp
5
+ * uses INGESTING/MATCHED/ACTIVATED). The platform implements one mapper
6
+ * per AdCP-typed status; framework calls them where wire responses need
7
+ * the AdCP-typed value.
8
+ *
9
+ * **Scope**: each mapper is a wire-status decoder for a single native
10
+ * status string. Rollup logic — taking N native statuses across multiple
11
+ * objects (GAM Order + LineItems, Criteo campaign + line items + creatives)
12
+ * and computing one AdCP-typed status — is platform-specific and lives in
13
+ * adapter code, NOT here. The mapper answers "what does GAM's `READY` mean
14
+ * in AdCP terms?"; the adapter answers "if any LineItem is `DISAPPROVED`,
15
+ * the buy is `rejected`; if all are `DELIVERING`, the buy is `active`".
16
+ *
17
+ * Status: Preview / 6.0.
18
+ *
19
+ * @public
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.identityStatusMappers = void 0;
23
+ /**
24
+ * Identity mappers — when the platform's native status strings already match
25
+ * AdCP's typed enums (most modern platforms do for `active` / `paused`),
26
+ * adopters use this instead of writing the obvious passthrough functions.
27
+ *
28
+ * Falls back to the AdCP default for unknown native values:
29
+ * - mediaBuy: `'pending_creatives'`
30
+ * - creative: `'pending_review'`
31
+ * - account: `'active'`
32
+ * - plan: `'active'`
33
+ */
34
+ exports.identityStatusMappers = {
35
+ mediaBuy: native => (['pending_creatives', 'pending_start', 'active', 'paused', 'completed', 'rejected', 'canceled'].includes(native)
36
+ ? native
37
+ : 'pending_creatives'),
38
+ creative: native => (['pending_review', 'approved', 'rejected', 'archived'].includes(native)
39
+ ? native
40
+ : 'pending_review'),
41
+ account: native => (['active', 'pending_approval', 'rejected', 'payment_required', 'suspended', 'closed'].includes(native)
42
+ ? native
43
+ : 'active'),
44
+ plan: native => (['active', 'exhausted', 'expired', 'paused'].includes(native) ? native : 'active'),
45
+ };
46
+ //# sourceMappingURL=status-mappers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-mappers.js","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/status-mappers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AA4BH;;;;;;;;;;GAUG;AACU,QAAA,qBAAqB,GAAkB;IAClD,QAAQ,EAAE,MAAM,CAAC,EAAE,CACjB,CAAC,CAAC,mBAAmB,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC/G,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,mBAAmB,CAAuB;IAChD,QAAQ,EAAE,MAAM,CAAC,EAAE,CACjB,CAAC,CAAC,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QACtE,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,gBAAgB,CAAuB;IAC7C,OAAO,EAAE,MAAM,CAAC,EAAE,CAChB,CAAC,CAAC,QAAQ,EAAE,kBAAkB,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QACrG,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,QAAQ,CAAsB;IACpC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAmB;CACtH,CAAC"}