@adcp/sdk 17.0.0-beta.21 → 17.0.0-beta.23

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 (223) hide show
  1. package/README.md +26 -2
  2. package/dist/lib/adapters/version/index.d.mts +1 -1
  3. package/dist/lib/adapters/version/index.d.ts +1 -1
  4. package/dist/lib/adapters/version/index.js +2 -0
  5. package/dist/lib/adapters/version/index.mjs +2 -0
  6. package/dist/lib/adapters/version/negotiate.d.mts +13 -0
  7. package/dist/lib/adapters/version/negotiate.d.ts +13 -0
  8. package/dist/lib/adapters/version/negotiate.js +6 -0
  9. package/dist/lib/adapters/version/negotiate.mjs +5 -0
  10. package/dist/lib/client/core.d.mts +4 -0
  11. package/dist/lib/client/core.d.ts +4 -0
  12. package/dist/lib/client/core.js +13 -0
  13. package/dist/lib/client/core.mjs +12 -0
  14. package/dist/lib/conformance/property-lists.d.mts +1 -1
  15. package/dist/lib/conformance/property-lists.d.ts +1 -1
  16. package/dist/lib/conformance/property-lists.js +1 -1
  17. package/dist/lib/conformance/property-lists.mjs +1 -1
  18. package/dist/lib/core/SingleAgentClient.d.mts +23 -1
  19. package/dist/lib/core/SingleAgentClient.d.ts +23 -1
  20. package/dist/lib/core/SingleAgentClient.js +102 -18
  21. package/dist/lib/core/SingleAgentClient.mjs +108 -18
  22. package/dist/lib/core/targeting-helpers.d.mts +123 -0
  23. package/dist/lib/core/targeting-helpers.d.ts +123 -0
  24. package/dist/lib/core/targeting-helpers.js +412 -0
  25. package/dist/lib/core/targeting-helpers.mjs +370 -0
  26. package/dist/lib/entrypoints/client-account-changes.d.mts +5 -0
  27. package/dist/lib/entrypoints/client-account-changes.d.ts +5 -0
  28. package/dist/lib/entrypoints/client-account-changes.js +28 -0
  29. package/dist/lib/entrypoints/client-account-changes.mjs +4 -0
  30. package/dist/lib/entrypoints/client-webhook-stores.d.mts +2 -0
  31. package/dist/lib/entrypoints/client-webhook-stores.d.ts +2 -0
  32. package/dist/lib/entrypoints/client-webhook-stores.js +37 -0
  33. package/dist/lib/entrypoints/client-webhook-stores.mjs +16 -0
  34. package/dist/lib/entrypoints/discovery.d.mts +9 -0
  35. package/dist/lib/entrypoints/discovery.d.ts +9 -0
  36. package/dist/lib/entrypoints/discovery.js +72 -0
  37. package/dist/lib/entrypoints/discovery.mjs +56 -0
  38. package/dist/lib/entrypoints/errors.d.mts +11 -0
  39. package/dist/lib/entrypoints/errors.d.ts +11 -0
  40. package/dist/lib/entrypoints/errors.js +159 -0
  41. package/dist/lib/entrypoints/errors.mjs +132 -0
  42. package/dist/lib/entrypoints/media-buy.d.mts +5 -0
  43. package/dist/lib/entrypoints/media-buy.d.ts +5 -0
  44. package/dist/lib/entrypoints/media-buy.js +119 -0
  45. package/dist/lib/entrypoints/media-buy.mjs +100 -0
  46. package/dist/lib/entrypoints/registry.d.mts +5 -0
  47. package/dist/lib/entrypoints/registry.d.ts +5 -0
  48. package/dist/lib/entrypoints/registry.js +61 -0
  49. package/dist/lib/entrypoints/registry.mjs +40 -0
  50. package/dist/lib/entrypoints/utils.d.mts +7 -0
  51. package/dist/lib/entrypoints/utils.d.ts +7 -0
  52. package/dist/lib/entrypoints/utils.js +100 -0
  53. package/dist/lib/entrypoints/utils.mjs +72 -0
  54. package/dist/lib/entrypoints/version.d.mts +3 -0
  55. package/dist/lib/entrypoints/version.d.ts +3 -0
  56. package/dist/lib/entrypoints/version.js +57 -0
  57. package/dist/lib/entrypoints/version.mjs +36 -0
  58. package/dist/lib/index.d.mts +1 -1
  59. package/dist/lib/index.d.ts +1 -1
  60. package/dist/lib/media-buy/action-contracts.js +3 -3
  61. package/dist/lib/media-buy/action-contracts.mjs +1 -1
  62. package/dist/lib/media-buy/creative-start-policy.d.mts +19 -0
  63. package/dist/lib/media-buy/creative-start-policy.d.ts +19 -0
  64. package/dist/lib/media-buy/creative-start-policy.js +59 -0
  65. package/dist/lib/media-buy/creative-start-policy.mjs +31 -0
  66. package/dist/lib/media-buy/valid-actions.d.mts +47 -0
  67. package/dist/lib/media-buy/valid-actions.d.ts +47 -0
  68. package/dist/lib/media-buy/valid-actions.js +42 -0
  69. package/dist/lib/media-buy/valid-actions.mjs +18 -0
  70. package/dist/lib/net/pin-and-bind-fetch.d.mts +121 -0
  71. package/dist/lib/net/pin-and-bind-fetch.d.ts +121 -0
  72. package/dist/lib/net/pin-and-bind-fetch.js +209 -0
  73. package/dist/lib/net/pin-and-bind-fetch.mjs +183 -0
  74. package/dist/lib/protocols/mcp-modern.js +20 -4
  75. package/dist/lib/protocols/mcp-modern.mjs +20 -4
  76. package/dist/lib/registry/types.generated.d.ts +224 -3
  77. package/dist/lib/reporting/ledger/index.d.mts +1 -0
  78. package/dist/lib/reporting/ledger/index.d.ts +1 -0
  79. package/dist/lib/reporting/ledger/index.js +3 -1
  80. package/dist/lib/reporting/ledger/index.mjs +1 -0
  81. package/dist/lib/reporting/ledger/instant.d.mts +5 -0
  82. package/dist/lib/reporting/ledger/instant.d.ts +5 -0
  83. package/dist/lib/reporting/ledger/instant.js +10 -0
  84. package/dist/lib/reporting/ledger/instant.mjs +9 -0
  85. package/dist/lib/reporting/ledger/issue-events.d.mts +333 -0
  86. package/dist/lib/reporting/ledger/issue-events.d.ts +333 -0
  87. package/dist/lib/reporting/ledger/issue-events.js +310 -0
  88. package/dist/lib/reporting/ledger/issue-events.mjs +282 -0
  89. package/dist/lib/reporting/service/index.d.mts +36 -1
  90. package/dist/lib/reporting/service/index.d.ts +36 -1
  91. package/dist/lib/reporting/service/index.js +51 -1
  92. package/dist/lib/reporting/service/index.mjs +52 -2
  93. package/dist/lib/reporting/service/scheduler-support.d.mts +1 -1
  94. package/dist/lib/reporting/service/scheduler-support.d.ts +1 -1
  95. package/dist/lib/reporting/service/scheduler-support.js +1 -1
  96. package/dist/lib/reporting/service/scheduler-support.mjs +1 -1
  97. package/dist/lib/server/capabilities-release-projection.d.mts +43 -0
  98. package/dist/lib/server/capabilities-release-projection.d.ts +43 -0
  99. package/dist/lib/server/capabilities-release-projection.js +128 -0
  100. package/dist/lib/server/capabilities-release-projection.mjs +112 -0
  101. package/dist/lib/server/create-adcp-server.d.mts +29 -5
  102. package/dist/lib/server/create-adcp-server.d.ts +29 -5
  103. package/dist/lib/server/create-adcp-server.js +97 -24
  104. package/dist/lib/server/create-adcp-server.mjs +108 -23
  105. package/dist/lib/server/decisioning/capabilities.d.mts +27 -0
  106. package/dist/lib/server/decisioning/capabilities.d.ts +27 -0
  107. package/dist/lib/server/decisioning/runtime/from-platform.js +99 -27
  108. package/dist/lib/server/decisioning/runtime/from-platform.mjs +103 -27
  109. package/dist/lib/server/declared-input-schema.d.mts +108 -0
  110. package/dist/lib/server/declared-input-schema.d.ts +108 -0
  111. package/dist/lib/server/declared-input-schema.js +167 -0
  112. package/dist/lib/server/declared-input-schema.mjs +137 -0
  113. package/dist/lib/server/envelope-allowlist.d.mts +1 -105
  114. package/dist/lib/server/envelope-allowlist.d.ts +1 -105
  115. package/dist/lib/server/envelope-allowlist.js +3 -79
  116. package/dist/lib/server/envelope-allowlist.mjs +1 -71
  117. package/dist/lib/server/errors.d.mts +1 -186
  118. package/dist/lib/server/errors.d.ts +1 -186
  119. package/dist/lib/server/errors.js +3 -98
  120. package/dist/lib/server/errors.mjs +1 -94
  121. package/dist/lib/server/index.d.mts +1 -1
  122. package/dist/lib/server/index.d.ts +1 -1
  123. package/dist/lib/server/mcp-modern-server.js +21 -4
  124. package/dist/lib/server/mcp-modern-server.mjs +21 -4
  125. package/dist/lib/server/media-buy-action-resolver.d.mts +7 -0
  126. package/dist/lib/server/media-buy-action-resolver.d.ts +7 -0
  127. package/dist/lib/server/media-buy-action-resolver.js +10 -1
  128. package/dist/lib/server/media-buy-action-resolver.mjs +10 -1
  129. package/dist/lib/server/media-buy-helpers.d.mts +1 -47
  130. package/dist/lib/server/media-buy-helpers.d.ts +1 -47
  131. package/dist/lib/server/media-buy-helpers.js +3 -23
  132. package/dist/lib/server/media-buy-helpers.mjs +1 -18
  133. package/dist/lib/server/pick-safe-details.d.mts +1 -89
  134. package/dist/lib/server/pick-safe-details.d.ts +1 -89
  135. package/dist/lib/server/pick-safe-details.js +3 -61
  136. package/dist/lib/server/pick-safe-details.mjs +1 -56
  137. package/dist/lib/server/pin-and-bind-fetch.d.mts +1 -121
  138. package/dist/lib/server/pin-and-bind-fetch.d.ts +1 -121
  139. package/dist/lib/server/pin-and-bind-fetch.js +3 -190
  140. package/dist/lib/server/pin-and-bind-fetch.mjs +1 -183
  141. package/dist/lib/server/targeting-helpers.d.mts +1 -123
  142. package/dist/lib/server/targeting-helpers.d.ts +1 -123
  143. package/dist/lib/server/targeting-helpers.js +3 -393
  144. package/dist/lib/server/targeting-helpers.mjs +1 -370
  145. package/dist/lib/server/test-controller.js +7 -3
  146. package/dist/lib/server/test-controller.mjs +7 -3
  147. package/dist/lib/storage/memory-ledger.js +219 -1
  148. package/dist/lib/storage/memory-ledger.mjs +223 -1
  149. package/dist/lib/testing/client.js +26 -5
  150. package/dist/lib/testing/client.mjs +24 -5
  151. package/dist/lib/testing/compliance/storyboard-tracks.js +0 -4
  152. package/dist/lib/testing/compliance/storyboard-tracks.mjs +0 -4
  153. package/dist/lib/testing/comply-controller.js +7 -2
  154. package/dist/lib/testing/comply-controller.mjs +7 -2
  155. package/dist/lib/testing/storyboard/request-signing/grader.d.mts +21 -0
  156. package/dist/lib/testing/storyboard/request-signing/grader.d.ts +21 -0
  157. package/dist/lib/testing/storyboard/request-signing/grader.js +31 -0
  158. package/dist/lib/testing/storyboard/request-signing/grader.mjs +30 -0
  159. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.js +1 -1
  160. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs +2 -1
  161. package/dist/lib/testing/storyboard/request-signing/types.d.mts +12 -0
  162. package/dist/lib/testing/storyboard/request-signing/types.d.ts +12 -0
  163. package/dist/lib/testing/storyboard/request-signing/vector-loader.js +7 -2
  164. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +7 -2
  165. package/dist/lib/testing/storyboard/runner.js +4 -4
  166. package/dist/lib/testing/storyboard/runner.mjs +4 -4
  167. package/dist/lib/testing/storyboard/task-map.js +4 -1
  168. package/dist/lib/testing/storyboard/task-map.mjs +4 -1
  169. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  170. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  171. package/dist/lib/utils/adcp-error-response.d.mts +196 -0
  172. package/dist/lib/utils/adcp-error-response.d.ts +196 -0
  173. package/dist/lib/utils/adcp-error-response.js +118 -0
  174. package/dist/lib/utils/adcp-error-response.mjs +95 -0
  175. package/dist/lib/utils/buyer-retry-policy.js +2 -2
  176. package/dist/lib/utils/buyer-retry-policy.mjs +1 -1
  177. package/dist/lib/utils/capabilities.d.mts +6 -0
  178. package/dist/lib/utils/capabilities.d.ts +6 -0
  179. package/dist/lib/utils/capabilities.js +6 -2
  180. package/dist/lib/utils/capabilities.mjs +6 -2
  181. package/dist/lib/utils/envelope-allowlist.d.mts +105 -0
  182. package/dist/lib/utils/envelope-allowlist.d.ts +105 -0
  183. package/dist/lib/utils/envelope-allowlist.js +98 -0
  184. package/dist/lib/utils/envelope-allowlist.mjs +71 -0
  185. package/dist/lib/utils/pick-safe-details.d.mts +89 -0
  186. package/dist/lib/utils/pick-safe-details.d.ts +89 -0
  187. package/dist/lib/utils/pick-safe-details.js +80 -0
  188. package/dist/lib/utils/pick-safe-details.mjs +56 -0
  189. package/dist/lib/v2/projection/augment-response.d.mts +4 -0
  190. package/dist/lib/v2/projection/augment-response.d.ts +4 -0
  191. package/dist/lib/v2/projection/creative-delivery.d.mts +20 -3
  192. package/dist/lib/v2/projection/creative-delivery.d.ts +20 -3
  193. package/dist/lib/v2/projection/creative-delivery.js +20 -4
  194. package/dist/lib/v2/projection/creative-delivery.mjs +19 -4
  195. package/dist/lib/v2/projection/index.d.mts +2 -2
  196. package/dist/lib/v2/projection/index.d.ts +2 -2
  197. package/dist/lib/v2/projection/index.js +4 -0
  198. package/dist/lib/v2/projection/index.mjs +5 -1
  199. package/dist/lib/v2/projection/legacy-metadata.d.mts +7 -0
  200. package/dist/lib/v2/projection/legacy-metadata.d.ts +7 -0
  201. package/dist/lib/v2/projection/legacy-metadata.js +14 -0
  202. package/dist/lib/v2/projection/legacy-metadata.mjs +12 -0
  203. package/dist/lib/v2/projection/legacy-routes.d.mts +11 -0
  204. package/dist/lib/v2/projection/legacy-routes.d.ts +11 -0
  205. package/dist/lib/v2/projection/legacy-routes.js +2 -1
  206. package/dist/lib/v2/projection/legacy-routes.mjs +7 -2
  207. package/dist/lib/v2/projection/v1-to-v2.d.mts +21 -1
  208. package/dist/lib/v2/projection/v1-to-v2.d.ts +21 -1
  209. package/dist/lib/v2/projection/v1-to-v2.js +18 -11
  210. package/dist/lib/v2/projection/v1-to-v2.mjs +19 -11
  211. package/dist/lib/version.d.mts +3 -3
  212. package/dist/lib/version.d.ts +3 -3
  213. package/dist/lib/version.js +3 -3
  214. package/dist/lib/version.mjs +3 -3
  215. package/docs/TYPE-SUMMARY.md +2 -2
  216. package/docs/guides/CREATIVE-DELIVERY.md +12 -0
  217. package/docs/guides/REPORTING-LEDGER.md +121 -0
  218. package/docs/guides/VALIDATE-YOUR-AGENT.md +1 -0
  219. package/docs/llms.txt +2 -2
  220. package/docs/migration-14.x-rc-worksheet.md +4 -4
  221. package/docs/migration-16-to-17.md +149 -0
  222. package/docs/migration-reporting-storage-package.md +10 -0
  223. package/package.json +106 -1
@@ -24,9 +24,14 @@ module.exports = __toCommonJS(memory_ledger_exports);
24
24
  var import_node_crypto = require("node:crypto");
25
25
  var import_coverage = require('../reporting/ledger/coverage.js');
26
26
  var import_health = require('../reporting/ledger/health.js');
27
+ var import_instant = require('../reporting/ledger/instant.js');
28
+ var import_issue_events = require('../reporting/ledger/issue-events.js');
27
29
  var import_schedule = require('../reporting/ledger/schedule.js');
28
30
  var import_types = require('../reporting/ledger/types.js');
29
31
  var import_manifest = require('../reporting/source/manifest.js');
32
+ function issueOccurrenceKey(value) {
33
+ return `${value.issueId}\0${value.consumerId}`;
34
+ }
30
35
  function sha(value) {
31
36
  return (0, import_node_crypto.createHash)("sha256").update((0, import_manifest.canonicalJsonV1)(value)).digest("hex");
32
37
  }
@@ -38,6 +43,11 @@ class MemoryReportingLedgerStore {
38
43
  this.now = now;
39
44
  }
40
45
  now;
46
+ /** Records issue-lifecycle events for the issue observer (see `issue-events.ts`). */
47
+ issueEventsSupported = true;
48
+ /** The issue-event outbox, by event id. */
49
+ issueEvents = /* @__PURE__ */ new Map();
50
+ issueEventSeq = 0;
41
51
  configurations = /* @__PURE__ */ new Map();
42
52
  obligations = /* @__PURE__ */ new Map();
43
53
  revisions = /* @__PURE__ */ new Map();
@@ -185,7 +195,10 @@ class MemoryReportingLedgerStore {
185
195
  (item) => item.reporting_obligation_id === value.reporting_obligation_id && item.revisionNumber === value.revisionNumber
186
196
  );
187
197
  if (existing && existing.binding.sha256 !== value.binding.sha256) throw new Error("immutable conflict");
188
- if (!existing) this.revisions.set(value.reporting_revision_id, clone(value));
198
+ if (!existing) {
199
+ this.revisions.set(value.reporting_revision_id, clone(value));
200
+ this.settleIssueObligation(value.reporting_obligation_id, this.instant());
201
+ }
189
202
  return { inserted: !existing, value: clone(existing ?? value) };
190
203
  }
191
204
  async getRevision(id, accountId) {
@@ -473,11 +486,216 @@ class MemoryReportingLedgerStore {
473
486
  continue;
474
487
  }
475
488
  this.consumerStatements.push(clone(candidate));
489
+ this.settleIssueChain(candidate);
476
490
  results.push({ inserted: true, value: clone(candidate) });
477
491
  }
478
492
  this.consumerStatusBatches.set(batchKey, { requestFingerprint: input.requestFingerprint, results });
479
493
  return clone(results);
480
494
  }
495
+ // --- issue-lifecycle events (the issue observer) ----------------------------
496
+ obligationMatchesStatement(obligation, status) {
497
+ return obligation.account.account_id === status.account_id && status.delivery_config_id === obligation.delivery_config_id && status.delivery_config_version === obligation.delivery_config_version && status.report_definition_id === obligation.report_definition_id && (0, import_instant.compareReportingInstants)(status.period.start, obligation.period.start) === 0 && (0, import_instant.compareReportingInstants)(status.period.end, obligation.period.end) === 0 && status.period.source_timezone === obligation.period.sourceTimezone;
498
+ }
499
+ revisionMetadata(obligationId) {
500
+ return [...this.revisions.values()].filter((value) => value.reporting_obligation_id === obligationId).sort((a, b) => a.revisionNumber - b.revisionNumber).map(({ rows: _rows, ...metadata }) => metadata);
501
+ }
502
+ /** Occurrences whose `opened` is recorded and that have not resolved. */
503
+ openIssueOccurrences() {
504
+ const resolved = new Set(
505
+ [...this.issueEvents.values()].filter((value) => value.kind === "resolved").map(issueOccurrenceKey)
506
+ );
507
+ return [...this.issueEvents.values()].filter(
508
+ (value) => value.kind === "opened" && !resolved.has(issueOccurrenceKey(value))
509
+ );
510
+ }
511
+ conflictsOn(obligation) {
512
+ const revisions = this.revisionMetadata(obligation.reporting_obligation_id);
513
+ const chains = /* @__PURE__ */ new Map();
514
+ for (const status of this.consumerStatements) {
515
+ if (!this.obligationMatchesStatement(obligation, status)) continue;
516
+ chains.set(status.consumerId, [...chains.get(status.consumerId) ?? [], status]);
517
+ }
518
+ return [...chains.values()].flatMap((statements) => {
519
+ const superseded = new Set(statements.map((value) => value.supersedes_reporting_status_id).filter(Boolean));
520
+ const leaf = statements.find((value) => !superseded.has(value.reporting_status_id));
521
+ const occurrence = (0, import_issue_events.reportingConsumerMismatchOccurrenceV1)(obligation, leaf, revisions);
522
+ return occurrence ? [occurrence] : [];
523
+ });
524
+ }
525
+ recordIssueEvents(records) {
526
+ let recorded = 0;
527
+ for (const record of records) {
528
+ if (this.issueEvents.has(record.eventId)) continue;
529
+ const now = this.instant();
530
+ this.issueEventSeq += 1;
531
+ this.issueEvents.set(record.eventId, {
532
+ ...clone(record),
533
+ seq: this.issueEventSeq,
534
+ recordedAt: now,
535
+ dueAt: now,
536
+ attempts: 0
537
+ });
538
+ recorded += 1;
539
+ }
540
+ return recorded;
541
+ }
542
+ /** Re-derive one obligation's occurrences after a write: open what conflicts, resolve what cleared. */
543
+ settleIssueObligation(obligationId, at) {
544
+ const obligation = this.obligations.get(obligationId);
545
+ this.recordIssueEvents(
546
+ (0, import_issue_events.planReportingIssueEventsV1)({
547
+ open: this.openIssueOccurrences().filter((value) => value.reportingObligationId === obligationId),
548
+ conflicts: obligation ? this.conflictsOn(obligation) : [],
549
+ at
550
+ })
551
+ );
552
+ }
553
+ /**
554
+ * After a statement lands: resolve the occurrence of the leaf it superseded, open one for it if it
555
+ * conflicts. Scoped to the statement's own chain, so it works before the obligation exists.
556
+ */
557
+ settleIssueChain(statement) {
558
+ const chain = new Set(
559
+ this.consumerStatements.filter(
560
+ (value) => value.account_id === statement.account_id && value.consumerId === statement.consumerId && this.consumerChainKey(value) === this.consumerChainKey(statement)
561
+ ).map((value) => value.reporting_status_id)
562
+ );
563
+ const obligation = [...this.obligations.values()].find((value) => this.obligationMatchesStatement(value, statement));
564
+ const occurrence = obligation ? (0, import_issue_events.reportingConsumerMismatchOccurrenceV1)(
565
+ obligation,
566
+ statement,
567
+ this.revisionMetadata(obligation.reporting_obligation_id)
568
+ ) : void 0;
569
+ this.recordIssueEvents(
570
+ (0, import_issue_events.planReportingIssueEventsV1)({
571
+ open: this.openIssueOccurrences().filter(
572
+ (value) => value.accountId === statement.account_id && value.consumerId === statement.consumerId && chain.has(value.reportingStatusId)
573
+ ),
574
+ conflicts: occurrence ? [occurrence] : [],
575
+ at: statement.recorded_at
576
+ })
577
+ );
578
+ }
579
+ async issueEventsReady() {
580
+ return true;
581
+ }
582
+ async sweepIssueEscalations({
583
+ escalationSeconds,
584
+ accountId,
585
+ limit = 100
586
+ }) {
587
+ if (!Number.isSafeInteger(escalationSeconds) || escalationSeconds < 0) {
588
+ throw new RangeError("escalationSeconds must be a non-negative integer");
589
+ }
590
+ if (!Number.isSafeInteger(limit) || limit < 1) throw new RangeError("limit must be a positive integer");
591
+ const now = this.instant();
592
+ const escalated = new Set(
593
+ [...this.issueEvents.values()].filter((value) => value.kind === "escalated").map(issueOccurrenceKey)
594
+ );
595
+ const due = (value) => (accountId === void 0 || value.accountId === accountId) && !escalated.has(issueOccurrenceKey(value)) && (0, import_instant.compareReportingInstantToOffset)(now, value.occurredAt, escalationSeconds * 1e3) >= 0;
596
+ const obligationIds = [
597
+ ...new Set(
598
+ this.openIssueOccurrences().filter(due).sort((a, b) => (0, import_instant.compareReportingInstants)(a.occurredAt, b.occurredAt) || a.seq - b.seq).map((value) => value.reportingObligationId)
599
+ )
600
+ ].slice(0, limit);
601
+ let recorded = 0;
602
+ for (const obligationId of obligationIds) {
603
+ this.settleIssueObligation(obligationId, now);
604
+ for (const opened of this.openIssueOccurrences().filter(
605
+ (value) => value.reportingObligationId === obligationId && due(value)
606
+ )) {
607
+ const escalation = (0, import_issue_events.reportingIssueEscalationV1)(opened, escalationSeconds, now);
608
+ if (escalation) recorded += this.recordIssueEvents([escalation]);
609
+ }
610
+ }
611
+ return recorded;
612
+ }
613
+ async claimIssueEvents({
614
+ leaseMilliseconds,
615
+ limit,
616
+ accountId
617
+ }) {
618
+ if (!Number.isSafeInteger(leaseMilliseconds) || leaseMilliseconds < 1) {
619
+ throw new RangeError("leaseMilliseconds must be a positive integer");
620
+ }
621
+ if (!Number.isSafeInteger(limit) || limit < 1) throw new RangeError("limit must be a positive integer");
622
+ const now = this.instant();
623
+ const pending = [...this.issueEvents.values()].filter((value) => value.deliveredAt === void 0).sort((a, b) => a.seq - b.seq);
624
+ const head = /* @__PURE__ */ new Map();
625
+ for (const value of pending) {
626
+ if (!head.has(issueOccurrenceKey(value))) head.set(issueOccurrenceKey(value), value.seq);
627
+ }
628
+ const due = pending.filter(
629
+ (value) => head.get(issueOccurrenceKey(value)) === value.seq && (accountId === void 0 || value.accountId === accountId) && Date.parse(value.dueAt) <= Date.parse(now) && (value.leaseExpiresAt === void 0 || Date.parse(value.leaseExpiresAt) <= Date.parse(now))
630
+ ).sort((a, b) => Date.parse(a.dueAt) - Date.parse(b.dueAt) || a.seq - b.seq).slice(0, limit);
631
+ const leaseToken = (0, import_node_crypto.createHash)("sha256").update(`${now}:${this.issueEventSeq}:${Math.random()}`).digest("hex");
632
+ const leaseExpiresAt = new Date(Date.parse(now) + leaseMilliseconds).toISOString();
633
+ return due.map((value) => {
634
+ value.attempts += 1;
635
+ value.leaseToken = leaseToken;
636
+ value.leaseExpiresAt = leaseExpiresAt;
637
+ const statement = this.consumerStatements.find(
638
+ (item) => item.account_id === value.accountId && item.consumerId === value.consumerId && item.reporting_status_id === value.reportingStatusId
639
+ );
640
+ const { seq: _seq, dueAt: _dueAt, deliveredAt: _deliveredAt, ...lease } = value;
641
+ return clone({
642
+ ...lease,
643
+ leaseToken,
644
+ leaseExpiresAt,
645
+ ...statement ? { statement } : {}
646
+ });
647
+ });
648
+ }
649
+ leasedIssueEvent(lease) {
650
+ const value = this.issueEvents.get(lease.eventId);
651
+ return value && value.deliveredAt === void 0 && value.leaseToken === lease.leaseToken ? value : void 0;
652
+ }
653
+ async completeIssueEvent(lease) {
654
+ const value = this.leasedIssueEvent(lease);
655
+ if (!value) return false;
656
+ value.deliveredAt = this.instant();
657
+ delete value.leaseToken;
658
+ delete value.leaseExpiresAt;
659
+ return true;
660
+ }
661
+ async releaseIssueEvent(lease, { retryAfterMilliseconds }) {
662
+ const value = this.leasedIssueEvent(lease);
663
+ if (!value) return false;
664
+ value.dueAt = new Date(Date.parse(this.instant()) + Math.max(0, retryAfterMilliseconds)).toISOString();
665
+ delete value.leaseToken;
666
+ delete value.leaseExpiresAt;
667
+ return true;
668
+ }
669
+ /** Whether an occurrence can never be derived again: its statement is no longer current, or its obligation is gone. */
670
+ issueOccurrenceClosed(event) {
671
+ if (!this.obligations.has(event.reportingObligationId)) return true;
672
+ const statement = this.consumerStatements.find(
673
+ (value) => value.account_id === event.accountId && value.consumerId === event.consumerId && value.reporting_status_id === event.reportingStatusId
674
+ );
675
+ if (!statement) return true;
676
+ return this.currentConsumerLeaf(statement, event.accountId, event.consumerId)?.reporting_status_id !== statement.reporting_status_id;
677
+ }
678
+ async pruneIssueEvents({
679
+ olderThanMilliseconds,
680
+ limit = 1e3
681
+ }) {
682
+ if (!Number.isSafeInteger(limit) || limit < 1) throw new RangeError("limit must be a positive integer");
683
+ const horizon = Date.parse(this.instant()) - olderThanMilliseconds;
684
+ const occurrences = /* @__PURE__ */ new Map();
685
+ for (const value of this.issueEvents.values()) {
686
+ const key = issueOccurrenceKey(value);
687
+ occurrences.set(key, [...occurrences.get(key) ?? [], value]);
688
+ }
689
+ const expired = [...occurrences.values()].filter(
690
+ (events) => events.some((value) => value.kind === "resolved") && events.every((value) => value.deliveredAt !== void 0 && Date.parse(value.deliveredAt) < horizon) && this.issueOccurrenceClosed(events[0])
691
+ ).map((events) => ({ events, lastDelivered: Math.max(...events.map((value) => Date.parse(value.deliveredAt))) })).sort((a, b) => a.lastDelivered - b.lastDelivered).slice(0, limit);
692
+ let deleted = 0;
693
+ for (const { events } of expired) {
694
+ for (const value of events) this.issueEvents.delete(value.eventId);
695
+ deleted += events.length;
696
+ }
697
+ return deleted;
698
+ }
481
699
  }
482
700
  // Annotate the CommonJS export names for ESM import in node:
483
701
  0 && (module.exports = {
@@ -9,12 +9,21 @@ import {
9
9
  reportingLedgerSubscriptionVisibleV1
10
10
  } from "../reporting/ledger/coverage.mjs";
11
11
  import { projectReportingObligationHealthV1 } from "../reporting/ledger/health.mjs";
12
+ import { compareReportingInstants, compareReportingInstantToOffset } from "../reporting/ledger/instant.mjs";
13
+ import {
14
+ planReportingIssueEventsV1,
15
+ reportingConsumerMismatchOccurrenceV1,
16
+ reportingIssueEscalationV1
17
+ } from "../reporting/ledger/issue-events.mjs";
12
18
  import { reportingPeriodSchedule } from "../reporting/ledger/schedule.mjs";
13
19
  import {
14
20
  ReportingConsumerStatusConflictError,
15
21
  ReportingLedgerSnapshotUnavailableError
16
22
  } from "../reporting/ledger/types.mjs";
17
23
  import { canonicalJsonV1 } from "../reporting/source/manifest.mjs";
24
+ function issueOccurrenceKey(value) {
25
+ return `${value.issueId}\0${value.consumerId}`;
26
+ }
18
27
  function sha(value) {
19
28
  return createHash("sha256").update(canonicalJsonV1(value)).digest("hex");
20
29
  }
@@ -26,6 +35,11 @@ class MemoryReportingLedgerStore {
26
35
  this.now = now;
27
36
  }
28
37
  now;
38
+ /** Records issue-lifecycle events for the issue observer (see `issue-events.ts`). */
39
+ issueEventsSupported = true;
40
+ /** The issue-event outbox, by event id. */
41
+ issueEvents = /* @__PURE__ */ new Map();
42
+ issueEventSeq = 0;
29
43
  configurations = /* @__PURE__ */ new Map();
30
44
  obligations = /* @__PURE__ */ new Map();
31
45
  revisions = /* @__PURE__ */ new Map();
@@ -173,7 +187,10 @@ class MemoryReportingLedgerStore {
173
187
  (item) => item.reporting_obligation_id === value.reporting_obligation_id && item.revisionNumber === value.revisionNumber
174
188
  );
175
189
  if (existing && existing.binding.sha256 !== value.binding.sha256) throw new Error("immutable conflict");
176
- if (!existing) this.revisions.set(value.reporting_revision_id, clone(value));
190
+ if (!existing) {
191
+ this.revisions.set(value.reporting_revision_id, clone(value));
192
+ this.settleIssueObligation(value.reporting_obligation_id, this.instant());
193
+ }
177
194
  return { inserted: !existing, value: clone(existing ?? value) };
178
195
  }
179
196
  async getRevision(id, accountId) {
@@ -461,11 +478,216 @@ class MemoryReportingLedgerStore {
461
478
  continue;
462
479
  }
463
480
  this.consumerStatements.push(clone(candidate));
481
+ this.settleIssueChain(candidate);
464
482
  results.push({ inserted: true, value: clone(candidate) });
465
483
  }
466
484
  this.consumerStatusBatches.set(batchKey, { requestFingerprint: input.requestFingerprint, results });
467
485
  return clone(results);
468
486
  }
487
+ // --- issue-lifecycle events (the issue observer) ----------------------------
488
+ obligationMatchesStatement(obligation, status) {
489
+ return obligation.account.account_id === status.account_id && status.delivery_config_id === obligation.delivery_config_id && status.delivery_config_version === obligation.delivery_config_version && status.report_definition_id === obligation.report_definition_id && compareReportingInstants(status.period.start, obligation.period.start) === 0 && compareReportingInstants(status.period.end, obligation.period.end) === 0 && status.period.source_timezone === obligation.period.sourceTimezone;
490
+ }
491
+ revisionMetadata(obligationId) {
492
+ return [...this.revisions.values()].filter((value) => value.reporting_obligation_id === obligationId).sort((a, b) => a.revisionNumber - b.revisionNumber).map(({ rows: _rows, ...metadata }) => metadata);
493
+ }
494
+ /** Occurrences whose `opened` is recorded and that have not resolved. */
495
+ openIssueOccurrences() {
496
+ const resolved = new Set(
497
+ [...this.issueEvents.values()].filter((value) => value.kind === "resolved").map(issueOccurrenceKey)
498
+ );
499
+ return [...this.issueEvents.values()].filter(
500
+ (value) => value.kind === "opened" && !resolved.has(issueOccurrenceKey(value))
501
+ );
502
+ }
503
+ conflictsOn(obligation) {
504
+ const revisions = this.revisionMetadata(obligation.reporting_obligation_id);
505
+ const chains = /* @__PURE__ */ new Map();
506
+ for (const status of this.consumerStatements) {
507
+ if (!this.obligationMatchesStatement(obligation, status)) continue;
508
+ chains.set(status.consumerId, [...chains.get(status.consumerId) ?? [], status]);
509
+ }
510
+ return [...chains.values()].flatMap((statements) => {
511
+ const superseded = new Set(statements.map((value) => value.supersedes_reporting_status_id).filter(Boolean));
512
+ const leaf = statements.find((value) => !superseded.has(value.reporting_status_id));
513
+ const occurrence = reportingConsumerMismatchOccurrenceV1(obligation, leaf, revisions);
514
+ return occurrence ? [occurrence] : [];
515
+ });
516
+ }
517
+ recordIssueEvents(records) {
518
+ let recorded = 0;
519
+ for (const record of records) {
520
+ if (this.issueEvents.has(record.eventId)) continue;
521
+ const now = this.instant();
522
+ this.issueEventSeq += 1;
523
+ this.issueEvents.set(record.eventId, {
524
+ ...clone(record),
525
+ seq: this.issueEventSeq,
526
+ recordedAt: now,
527
+ dueAt: now,
528
+ attempts: 0
529
+ });
530
+ recorded += 1;
531
+ }
532
+ return recorded;
533
+ }
534
+ /** Re-derive one obligation's occurrences after a write: open what conflicts, resolve what cleared. */
535
+ settleIssueObligation(obligationId, at) {
536
+ const obligation = this.obligations.get(obligationId);
537
+ this.recordIssueEvents(
538
+ planReportingIssueEventsV1({
539
+ open: this.openIssueOccurrences().filter((value) => value.reportingObligationId === obligationId),
540
+ conflicts: obligation ? this.conflictsOn(obligation) : [],
541
+ at
542
+ })
543
+ );
544
+ }
545
+ /**
546
+ * After a statement lands: resolve the occurrence of the leaf it superseded, open one for it if it
547
+ * conflicts. Scoped to the statement's own chain, so it works before the obligation exists.
548
+ */
549
+ settleIssueChain(statement) {
550
+ const chain = new Set(
551
+ this.consumerStatements.filter(
552
+ (value) => value.account_id === statement.account_id && value.consumerId === statement.consumerId && this.consumerChainKey(value) === this.consumerChainKey(statement)
553
+ ).map((value) => value.reporting_status_id)
554
+ );
555
+ const obligation = [...this.obligations.values()].find((value) => this.obligationMatchesStatement(value, statement));
556
+ const occurrence = obligation ? reportingConsumerMismatchOccurrenceV1(
557
+ obligation,
558
+ statement,
559
+ this.revisionMetadata(obligation.reporting_obligation_id)
560
+ ) : void 0;
561
+ this.recordIssueEvents(
562
+ planReportingIssueEventsV1({
563
+ open: this.openIssueOccurrences().filter(
564
+ (value) => value.accountId === statement.account_id && value.consumerId === statement.consumerId && chain.has(value.reportingStatusId)
565
+ ),
566
+ conflicts: occurrence ? [occurrence] : [],
567
+ at: statement.recorded_at
568
+ })
569
+ );
570
+ }
571
+ async issueEventsReady() {
572
+ return true;
573
+ }
574
+ async sweepIssueEscalations({
575
+ escalationSeconds,
576
+ accountId,
577
+ limit = 100
578
+ }) {
579
+ if (!Number.isSafeInteger(escalationSeconds) || escalationSeconds < 0) {
580
+ throw new RangeError("escalationSeconds must be a non-negative integer");
581
+ }
582
+ if (!Number.isSafeInteger(limit) || limit < 1) throw new RangeError("limit must be a positive integer");
583
+ const now = this.instant();
584
+ const escalated = new Set(
585
+ [...this.issueEvents.values()].filter((value) => value.kind === "escalated").map(issueOccurrenceKey)
586
+ );
587
+ const due = (value) => (accountId === void 0 || value.accountId === accountId) && !escalated.has(issueOccurrenceKey(value)) && compareReportingInstantToOffset(now, value.occurredAt, escalationSeconds * 1e3) >= 0;
588
+ const obligationIds = [
589
+ ...new Set(
590
+ this.openIssueOccurrences().filter(due).sort((a, b) => compareReportingInstants(a.occurredAt, b.occurredAt) || a.seq - b.seq).map((value) => value.reportingObligationId)
591
+ )
592
+ ].slice(0, limit);
593
+ let recorded = 0;
594
+ for (const obligationId of obligationIds) {
595
+ this.settleIssueObligation(obligationId, now);
596
+ for (const opened of this.openIssueOccurrences().filter(
597
+ (value) => value.reportingObligationId === obligationId && due(value)
598
+ )) {
599
+ const escalation = reportingIssueEscalationV1(opened, escalationSeconds, now);
600
+ if (escalation) recorded += this.recordIssueEvents([escalation]);
601
+ }
602
+ }
603
+ return recorded;
604
+ }
605
+ async claimIssueEvents({
606
+ leaseMilliseconds,
607
+ limit,
608
+ accountId
609
+ }) {
610
+ if (!Number.isSafeInteger(leaseMilliseconds) || leaseMilliseconds < 1) {
611
+ throw new RangeError("leaseMilliseconds must be a positive integer");
612
+ }
613
+ if (!Number.isSafeInteger(limit) || limit < 1) throw new RangeError("limit must be a positive integer");
614
+ const now = this.instant();
615
+ const pending = [...this.issueEvents.values()].filter((value) => value.deliveredAt === void 0).sort((a, b) => a.seq - b.seq);
616
+ const head = /* @__PURE__ */ new Map();
617
+ for (const value of pending) {
618
+ if (!head.has(issueOccurrenceKey(value))) head.set(issueOccurrenceKey(value), value.seq);
619
+ }
620
+ const due = pending.filter(
621
+ (value) => head.get(issueOccurrenceKey(value)) === value.seq && (accountId === void 0 || value.accountId === accountId) && Date.parse(value.dueAt) <= Date.parse(now) && (value.leaseExpiresAt === void 0 || Date.parse(value.leaseExpiresAt) <= Date.parse(now))
622
+ ).sort((a, b) => Date.parse(a.dueAt) - Date.parse(b.dueAt) || a.seq - b.seq).slice(0, limit);
623
+ const leaseToken = createHash("sha256").update(`${now}:${this.issueEventSeq}:${Math.random()}`).digest("hex");
624
+ const leaseExpiresAt = new Date(Date.parse(now) + leaseMilliseconds).toISOString();
625
+ return due.map((value) => {
626
+ value.attempts += 1;
627
+ value.leaseToken = leaseToken;
628
+ value.leaseExpiresAt = leaseExpiresAt;
629
+ const statement = this.consumerStatements.find(
630
+ (item) => item.account_id === value.accountId && item.consumerId === value.consumerId && item.reporting_status_id === value.reportingStatusId
631
+ );
632
+ const { seq: _seq, dueAt: _dueAt, deliveredAt: _deliveredAt, ...lease } = value;
633
+ return clone({
634
+ ...lease,
635
+ leaseToken,
636
+ leaseExpiresAt,
637
+ ...statement ? { statement } : {}
638
+ });
639
+ });
640
+ }
641
+ leasedIssueEvent(lease) {
642
+ const value = this.issueEvents.get(lease.eventId);
643
+ return value && value.deliveredAt === void 0 && value.leaseToken === lease.leaseToken ? value : void 0;
644
+ }
645
+ async completeIssueEvent(lease) {
646
+ const value = this.leasedIssueEvent(lease);
647
+ if (!value) return false;
648
+ value.deliveredAt = this.instant();
649
+ delete value.leaseToken;
650
+ delete value.leaseExpiresAt;
651
+ return true;
652
+ }
653
+ async releaseIssueEvent(lease, { retryAfterMilliseconds }) {
654
+ const value = this.leasedIssueEvent(lease);
655
+ if (!value) return false;
656
+ value.dueAt = new Date(Date.parse(this.instant()) + Math.max(0, retryAfterMilliseconds)).toISOString();
657
+ delete value.leaseToken;
658
+ delete value.leaseExpiresAt;
659
+ return true;
660
+ }
661
+ /** Whether an occurrence can never be derived again: its statement is no longer current, or its obligation is gone. */
662
+ issueOccurrenceClosed(event) {
663
+ if (!this.obligations.has(event.reportingObligationId)) return true;
664
+ const statement = this.consumerStatements.find(
665
+ (value) => value.account_id === event.accountId && value.consumerId === event.consumerId && value.reporting_status_id === event.reportingStatusId
666
+ );
667
+ if (!statement) return true;
668
+ return this.currentConsumerLeaf(statement, event.accountId, event.consumerId)?.reporting_status_id !== statement.reporting_status_id;
669
+ }
670
+ async pruneIssueEvents({
671
+ olderThanMilliseconds,
672
+ limit = 1e3
673
+ }) {
674
+ if (!Number.isSafeInteger(limit) || limit < 1) throw new RangeError("limit must be a positive integer");
675
+ const horizon = Date.parse(this.instant()) - olderThanMilliseconds;
676
+ const occurrences = /* @__PURE__ */ new Map();
677
+ for (const value of this.issueEvents.values()) {
678
+ const key = issueOccurrenceKey(value);
679
+ occurrences.set(key, [...occurrences.get(key) ?? [], value]);
680
+ }
681
+ const expired = [...occurrences.values()].filter(
682
+ (events) => events.some((value) => value.kind === "resolved") && events.every((value) => value.deliveredAt !== void 0 && Date.parse(value.deliveredAt) < horizon) && this.issueOccurrenceClosed(events[0])
683
+ ).map((events) => ({ events, lastDelivered: Math.max(...events.map((value) => Date.parse(value.deliveredAt))) })).sort((a, b) => a.lastDelivered - b.lastDelivered).slice(0, limit);
684
+ let deleted = 0;
685
+ for (const { events } of expired) {
686
+ for (const value of events) this.issueEvents.delete(value.eventId);
687
+ deleted += events.length;
688
+ }
689
+ return deleted;
690
+ }
469
691
  }
470
692
  export {
471
693
  MemoryReportingLedgerStore
@@ -38,6 +38,8 @@ __export(client_exports, {
38
38
  seedAuthRejectedTestClientProfile: () => seedAuthRejectedTestClientProfile,
39
39
  seedTestClientSigningCapability: () => seedTestClientSigningCapability,
40
40
  setAgentTesterLogger: () => setAgentTesterLogger,
41
+ storyboardCapabilityStepEnvelope: () => storyboardCapabilityStepEnvelope,
42
+ testClientDiscoveryWireAdcpVersion: () => testClientDiscoveryWireAdcpVersion,
41
43
  testClientWireAdcpVersion: () => testClientWireAdcpVersion,
42
44
  validateResponseSchema: () => validateResponseSchema,
43
45
  withTestClientScope: () => withTestClientScope
@@ -54,6 +56,7 @@ var import_capabilities = require('../utils/capabilities.js');
54
56
  var import_probe_policy = require('../utils/probe-policy.js');
55
57
  var import_ssrf_fetch = require('../net/ssrf-fetch.js');
56
58
  var import_version = require('../version.js');
59
+ var import_negotiate = require('../adapters/version/negotiate.js');
57
60
  var import_protocols = require('../protocols/index.js');
58
61
  var import_node_crypto = require("node:crypto");
59
62
  var import_node_async_hooks = require("node:async_hooks");
@@ -205,7 +208,7 @@ function createTestClient(agentUrl, protocol = "mcp", options = {}) {
205
208
  protocol,
206
209
  adcpVersion: multiClient.getAdcpVersion(),
207
210
  ...options.wireAdcpVersion !== void 0 && { wireAdcpVersion: options.wireAdcpVersion },
208
- versionEnvelope: options.versionEnvelope ?? "auto",
211
+ ...options.versionEnvelope !== void 0 && { versionEnvelope: options.versionEnvelope },
209
212
  strictResponseSchemaValidation: options.strictResponseSchemaValidation !== false,
210
213
  ...authMode !== void 0 && { authMode },
211
214
  ...requestScopeMode !== void 0 && { requestScopeMode },
@@ -261,8 +264,10 @@ function testClientMatchesVersionOptions(client, agentUrl, options) {
261
264
  }
262
265
  const expectedAdcpVersion = effectiveOptions.adcpVersion ?? import_version.ADCP_VERSION;
263
266
  const expectedWireAdcpVersion = effectiveOptions.wireAdcpVersion;
264
- const expectedVersionEnvelope = effectiveOptions.versionEnvelope ?? "auto";
265
- return meta.agentUrl === agentUrl && meta.protocol === (effectiveOptions.protocol ?? "mcp") && meta.adcpVersion === expectedAdcpVersion && meta.wireAdcpVersion === expectedWireAdcpVersion && meta.versionEnvelope === expectedVersionEnvelope && meta.strictResponseSchemaValidation === (effectiveOptions.strictResponseSchemaValidation !== false) && meta.authMode === expectedAuthMode && meta.requestScopeMode === expectedRequestScopeMode && meta.requestSigningMode === expectedRequestSigningMode && meta.oauthStorage === expectedOAuthStorage && meta.connectionPartition === expectedTransport?.connectionPartition && meta.connectionReuse === expectedTransport?.connectionReuse && meta.fetchFn === expectedTransport?.trustedFetchFn && meta.allowPrivateIp === expectedTransport?.allowPrivateIp && meta.maxResponseBytes === expectedTransport?.maxResponseBytes && meta.requestTimeoutMs === expectedTransport?.requestTimeoutMs && meta.legacyCompatEnabled === expectedTransport?.legacyCompat?.enabled;
267
+ return meta.agentUrl === agentUrl && meta.protocol === (effectiveOptions.protocol ?? "mcp") && meta.adcpVersion === expectedAdcpVersion && meta.wireAdcpVersion === expectedWireAdcpVersion && // Unset and `auto` put the same envelope on ordinary calls and authored
268
+ // storyboard steps; they differ only in the reused client's own preview
269
+ // discovery probe, which follows that client's config.
270
+ (meta.versionEnvelope ?? "auto") === (effectiveOptions.versionEnvelope ?? "auto") && meta.strictResponseSchemaValidation === (effectiveOptions.strictResponseSchemaValidation !== false) && meta.authMode === expectedAuthMode && meta.requestScopeMode === expectedRequestScopeMode && meta.requestSigningMode === expectedRequestSigningMode && meta.oauthStorage === expectedOAuthStorage && meta.connectionPartition === expectedTransport?.connectionPartition && meta.connectionReuse === expectedTransport?.connectionReuse && meta.fetchFn === expectedTransport?.trustedFetchFn && meta.allowPrivateIp === expectedTransport?.allowPrivateIp && meta.maxResponseBytes === expectedTransport?.maxResponseBytes && meta.requestTimeoutMs === expectedTransport?.requestTimeoutMs && meta.legacyCompatEnabled === expectedTransport?.legacyCompat?.enabled;
266
271
  }
267
272
  function withTestKitAuthDefaults(options) {
268
273
  if (options.auth) return options;
@@ -485,11 +490,22 @@ async function runStep(stepName, taskName, fn) {
485
490
  }
486
491
  function testClientWireAdcpVersion(client, fallbackVersion) {
487
492
  const meta = client?.[TEST_CLIENT_VERSION_OPTIONS];
488
- if (meta && meta.versionEnvelope !== "auto") return void 0;
493
+ if (meta && (meta.versionEnvelope ?? "auto") !== "auto") return void 0;
489
494
  const getAdcpVersion = client?.getAdcpVersion;
490
495
  const pinned = meta?.wireAdcpVersion ?? meta?.adcpVersion ?? (typeof getAdcpVersion === "function" ? getAdcpVersion.call(client) : void 0) ?? fallbackVersion;
491
496
  return pinned === void 0 ? void 0 : (0, import_version.toReleasePrecisionVersion)(pinned);
492
497
  }
498
+ function storyboardCapabilityStepEnvelope(client) {
499
+ const meta = client?.[TEST_CLIENT_VERSION_OPTIONS];
500
+ return meta && meta.versionEnvelope === void 0 ? "auto" : void 0;
501
+ }
502
+ function testClientDiscoveryWireAdcpVersion(client, fallbackVersion) {
503
+ const meta = client?.[TEST_CLIENT_VERSION_OPTIONS];
504
+ if (meta && (0, import_negotiate.capabilityDiscoveryEnvelope)(meta.versionEnvelope, meta.wireAdcpVersion ?? meta.adcpVersion) === "none") {
505
+ return void 0;
506
+ }
507
+ return testClientWireAdcpVersion(client, fallbackVersion);
508
+ }
493
509
  function describeVersionUnsupported(result, requestedVersion) {
494
510
  if (!result || typeof result !== "object") return void 0;
495
511
  const record = result;
@@ -586,7 +602,10 @@ async function discoverAgentProfile(client, signal, schemaAdcpVersion) {
586
602
  };
587
603
  const adcpError = caps.adcpError ?? caps.adcp_error;
588
604
  if (adcpError) step.adcp_error = (0, import_discovery_evidence.redactDiscoveryEvidence)(adcpError);
589
- const versionUnsupported = describeVersionUnsupported(caps, testClientWireAdcpVersion(client, schemaAdcpVersion));
605
+ const versionUnsupported = describeVersionUnsupported(
606
+ caps,
607
+ testClientDiscoveryWireAdcpVersion(client, schemaAdcpVersion)
608
+ );
590
609
  if (versionUnsupported) {
591
610
  profile.capabilities_probe_error = versionUnsupported;
592
611
  step.passed = false;
@@ -978,6 +997,8 @@ function zodCodeToKeyword(code) {
978
997
  seedAuthRejectedTestClientProfile,
979
998
  seedTestClientSigningCapability,
980
999
  setAgentTesterLogger,
1000
+ storyboardCapabilityStepEnvelope,
1001
+ testClientDiscoveryWireAdcpVersion,
981
1002
  testClientWireAdcpVersion,
982
1003
  validateResponseSchema,
983
1004
  withTestClientScope