@adcp/sdk 16.0.0-beta.2 → 16.0.0-beta.4

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 (248) hide show
  1. package/README.md +54 -0
  2. package/dist/lib/auth/oauth/diagnose.js +3 -11
  3. package/dist/lib/auth/oauth/diagnose.mjs +4 -12
  4. package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
  5. package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
  6. package/dist/lib/auth/oauth/diagnostics.js +8 -10
  7. package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
  8. package/dist/lib/core/ConversationTypes.d.mts +8 -3
  9. package/dist/lib/core/ConversationTypes.d.ts +8 -3
  10. package/dist/lib/core/SingleAgentClient.d.mts +5 -3
  11. package/dist/lib/core/SingleAgentClient.d.ts +5 -3
  12. package/dist/lib/core/TaskExecutor.js +5 -1
  13. package/dist/lib/core/TaskExecutor.mjs +5 -1
  14. package/dist/lib/errors/index.d.mts +9 -4
  15. package/dist/lib/errors/index.d.ts +9 -4
  16. package/dist/lib/index.d.mts +3 -3
  17. package/dist/lib/index.d.ts +3 -3
  18. package/dist/lib/index.js +8 -0
  19. package/dist/lib/index.mjs +14 -2
  20. package/dist/lib/negotiation/types.d.mts +20 -39
  21. package/dist/lib/negotiation/types.d.ts +20 -39
  22. package/dist/lib/protocols/index.d.mts +60 -24
  23. package/dist/lib/protocols/index.d.ts +60 -24
  24. package/dist/lib/protocols/index.js +9 -4
  25. package/dist/lib/protocols/index.mjs +3 -0
  26. package/dist/lib/protocols/mcp-modern.js +1 -0
  27. package/dist/lib/protocols/mcp-modern.mjs +2 -1
  28. package/dist/lib/protocols/mcp.js +1 -0
  29. package/dist/lib/protocols/mcp.mjs +2 -1
  30. package/dist/lib/protocols/responseSizeLimit.d.mts +91 -5
  31. package/dist/lib/protocols/responseSizeLimit.d.ts +91 -5
  32. package/dist/lib/protocols/responseSizeLimit.js +195 -31
  33. package/dist/lib/protocols/responseSizeLimit.mjs +192 -31
  34. package/dist/lib/reporting/consumer-runtime.js +2 -1
  35. package/dist/lib/reporting/consumer-runtime.mjs +2 -1
  36. package/dist/lib/reporting/ledger/handler.js +50 -11
  37. package/dist/lib/reporting/ledger/handler.mjs +50 -12
  38. package/dist/lib/reporting/ledger/index.d.mts +17 -14
  39. package/dist/lib/reporting/ledger/index.d.ts +17 -14
  40. package/dist/lib/reporting/ledger/index.js +32 -20
  41. package/dist/lib/reporting/ledger/index.mjs +21 -10
  42. package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
  43. package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
  44. package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
  45. package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
  46. package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
  47. package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
  48. package/dist/lib/reporting/ledger/receipts.js +186 -0
  49. package/dist/lib/reporting/ledger/receipts.mjs +161 -0
  50. package/dist/lib/reporting/ledger/status-ingest.js +3 -3
  51. package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
  52. package/dist/lib/reporting/ledger/types.d.mts +43 -0
  53. package/dist/lib/reporting/ledger/types.d.ts +43 -0
  54. package/dist/lib/reporting/ledger/types.js +31 -2
  55. package/dist/lib/reporting/ledger/types.mjs +26 -1
  56. package/dist/lib/reporting/pagination.d.mts +6 -0
  57. package/dist/lib/reporting/pagination.d.ts +6 -0
  58. package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
  59. package/dist/lib/reporting/pagination.mjs +12 -0
  60. package/dist/lib/reporting/reconciliation.d.mts +1 -0
  61. package/dist/lib/reporting/reconciliation.d.ts +1 -0
  62. package/dist/lib/reporting/reconciliation.js +3 -2
  63. package/dist/lib/reporting/reconciliation.mjs +3 -2
  64. package/dist/lib/reporting/service/index.d.mts +79 -153
  65. package/dist/lib/reporting/service/index.d.ts +79 -153
  66. package/dist/lib/reporting/service/index.js +34 -491
  67. package/dist/lib/reporting/service/index.mjs +36 -510
  68. package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
  69. package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
  70. package/dist/lib/reporting/service/scheduler-support.js +125 -0
  71. package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
  72. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  73. package/dist/lib/signing/canonicalize.d.mts +4 -0
  74. package/dist/lib/signing/canonicalize.d.ts +4 -0
  75. package/dist/lib/signing/canonicalize.js +14 -8
  76. package/dist/lib/signing/canonicalize.mjs +14 -8
  77. package/dist/lib/signing/content-digest.d.mts +8 -0
  78. package/dist/lib/signing/content-digest.d.ts +8 -0
  79. package/dist/lib/signing/content-digest.js +11 -5
  80. package/dist/lib/signing/content-digest.mjs +10 -5
  81. package/dist/lib/signing/crypto.d.mts +15 -0
  82. package/dist/lib/signing/crypto.d.ts +15 -0
  83. package/dist/lib/signing/crypto.js +75 -3
  84. package/dist/lib/signing/crypto.mjs +78 -3
  85. package/dist/lib/signing/server.d.mts +1 -1
  86. package/dist/lib/signing/server.d.ts +1 -1
  87. package/dist/lib/signing/server.js +2 -0
  88. package/dist/lib/signing/server.mjs +2 -1
  89. package/dist/lib/signing/signer.js +11 -14
  90. package/dist/lib/signing/signer.mjs +13 -16
  91. package/dist/lib/signing/testing.js +2 -6
  92. package/dist/lib/signing/testing.mjs +3 -7
  93. package/dist/lib/signing/verifier.js +2 -2
  94. package/dist/lib/signing/verifier.mjs +3 -3
  95. package/dist/lib/signing/web-bot-auth.js +122 -43
  96. package/dist/lib/signing/web-bot-auth.mjs +128 -44
  97. package/dist/lib/signing/webhook-verifier.js +2 -2
  98. package/dist/lib/signing/webhook-verifier.mjs +3 -3
  99. package/dist/lib/substitution/compile.js +2 -1
  100. package/dist/lib/substitution/compile.mjs +2 -1
  101. package/dist/lib/substitution/consent-macros.d.mts +4 -0
  102. package/dist/lib/substitution/consent-macros.d.ts +4 -0
  103. package/dist/lib/substitution/consent-macros.js +45 -0
  104. package/dist/lib/substitution/consent-macros.mjs +20 -0
  105. package/dist/lib/substitution/index.d.mts +1 -1
  106. package/dist/lib/substitution/index.d.ts +1 -1
  107. package/dist/lib/substitution/index.js +2 -0
  108. package/dist/lib/substitution/index.mjs +2 -1
  109. package/dist/lib/substitution/translate.d.mts +15 -2
  110. package/dist/lib/substitution/translate.d.ts +15 -2
  111. package/dist/lib/substitution/translate.js +148 -26
  112. package/dist/lib/substitution/translate.mjs +147 -26
  113. package/dist/lib/testing/client.js +2 -1
  114. package/dist/lib/testing/client.mjs +2 -1
  115. package/dist/lib/testing/scenarios/capabilities.js +1 -1
  116. package/dist/lib/testing/scenarios/capabilities.mjs +1 -1
  117. package/dist/lib/testing/storyboard/junit.js +16 -3
  118. package/dist/lib/testing/storyboard/junit.mjs +16 -3
  119. package/dist/lib/testing/storyboard/request-signing/builder.js +12 -14
  120. package/dist/lib/testing/storyboard/request-signing/builder.mjs +13 -15
  121. package/dist/lib/testing/storyboard/runner.js +94 -25
  122. package/dist/lib/testing/storyboard/runner.mjs +94 -25
  123. package/dist/lib/testing/storyboard/signer-grader/grader.js +2 -7
  124. package/dist/lib/testing/storyboard/signer-grader/grader.mjs +2 -7
  125. package/dist/lib/testing/storyboard/types.d.mts +6 -0
  126. package/dist/lib/testing/storyboard/types.d.ts +6 -0
  127. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  128. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  129. package/dist/lib/types/enums.generated.d.mts +3 -0
  130. package/dist/lib/types/enums.generated.d.ts +3 -0
  131. package/dist/lib/types/enums.generated.js +9 -0
  132. package/dist/lib/types/enums.generated.mjs +6 -0
  133. package/dist/lib/validation/schema-loader.js +25 -0
  134. package/dist/lib/validation/schema-loader.mjs +24 -0
  135. package/dist/lib/version.d.mts +3 -3
  136. package/dist/lib/version.d.ts +3 -3
  137. package/dist/lib/version.js +3 -3
  138. package/dist/lib/version.mjs +3 -3
  139. package/docs/TYPE-SUMMARY.md +28 -5
  140. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +3 -2
  141. package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
  142. package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
  143. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
  144. package/docs/guides/REPORTING-LEDGER.md +107 -51
  145. package/docs/guides/REPORTING-OPERATIONS.md +66 -5
  146. package/docs/guides/REPORTING-STABILITY.md +36 -32
  147. package/docs/guides/UNIVERSAL-MACRO-COMPILATION.md +38 -0
  148. package/docs/guides/VALIDATE-YOUR-AGENT.md +12 -0
  149. package/docs/llms.txt +4 -3
  150. package/docs/migration-14.x-rc-worksheet.md +4 -7
  151. package/docs/migration-reporting-storage-package.md +186 -0
  152. package/examples/README.md +1 -1
  153. package/package.json +14 -78
  154. package/dist/lib/reporting/azure/index.d.mts +0 -31
  155. package/dist/lib/reporting/azure/index.d.ts +0 -31
  156. package/dist/lib/reporting/azure/index.js +0 -266
  157. package/dist/lib/reporting/azure/index.mjs +0 -249
  158. package/dist/lib/reporting/bigquery/index.d.mts +0 -246
  159. package/dist/lib/reporting/bigquery/index.d.ts +0 -246
  160. package/dist/lib/reporting/bigquery/index.js +0 -633
  161. package/dist/lib/reporting/bigquery/index.mjs +0 -594
  162. package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
  163. package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
  164. package/dist/lib/reporting/gcs/adapter.js +0 -342
  165. package/dist/lib/reporting/gcs/adapter.mjs +0 -325
  166. package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
  167. package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
  168. package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
  169. package/dist/lib/reporting/gcs/errors.d.mts +0 -11
  170. package/dist/lib/reporting/gcs/errors.d.ts +0 -11
  171. package/dist/lib/reporting/gcs/errors.mjs +0 -16
  172. package/dist/lib/reporting/gcs/fence.d.mts +0 -41
  173. package/dist/lib/reporting/gcs/fence.d.ts +0 -41
  174. package/dist/lib/reporting/gcs/fence.js +0 -250
  175. package/dist/lib/reporting/gcs/fence.mjs +0 -230
  176. package/dist/lib/reporting/gcs/index.d.mts +0 -18
  177. package/dist/lib/reporting/gcs/index.d.ts +0 -18
  178. package/dist/lib/reporting/gcs/index.js +0 -44
  179. package/dist/lib/reporting/gcs/index.mjs +0 -14
  180. package/dist/lib/reporting/gcs/io.d.mts +0 -7
  181. package/dist/lib/reporting/gcs/io.d.ts +0 -7
  182. package/dist/lib/reporting/gcs/io.js +0 -95
  183. package/dist/lib/reporting/gcs/io.mjs +0 -69
  184. package/dist/lib/reporting/gcs/reader.d.mts +0 -67
  185. package/dist/lib/reporting/gcs/reader.d.ts +0 -67
  186. package/dist/lib/reporting/gcs/reader.js +0 -193
  187. package/dist/lib/reporting/gcs/reader.mjs +0 -169
  188. package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
  189. package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
  190. package/dist/lib/reporting/gcs/row-provider.js +0 -225
  191. package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
  192. package/dist/lib/reporting/gcs/validation.d.mts +0 -5
  193. package/dist/lib/reporting/gcs/validation.d.ts +0 -5
  194. package/dist/lib/reporting/gcs/validation.js +0 -49
  195. package/dist/lib/reporting/gcs/validation.mjs +0 -25
  196. package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
  197. package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
  198. package/dist/lib/reporting/ledger/change-feed.js +0 -107
  199. package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
  200. package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
  201. package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
  202. package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
  203. package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
  204. package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
  205. package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
  206. package/dist/lib/reporting/ledger/managed-router.js +0 -280
  207. package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
  208. package/dist/lib/reporting/ledger/managed.d.mts +0 -535
  209. package/dist/lib/reporting/ledger/managed.d.ts +0 -535
  210. package/dist/lib/reporting/ledger/managed.js +0 -761
  211. package/dist/lib/reporting/ledger/managed.mjs +0 -729
  212. package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
  213. package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
  214. package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
  215. package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
  216. package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
  217. package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
  218. package/dist/lib/reporting/ledger/object-writes.js +0 -147
  219. package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
  220. package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
  221. package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
  222. package/dist/lib/reporting/ledger/postgres.js +0 -4462
  223. package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
  224. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
  225. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
  226. package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
  227. package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
  228. package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
  229. package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
  230. package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
  231. package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
  232. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
  233. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
  234. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
  235. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
  236. package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
  237. package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
  238. package/dist/lib/reporting/ledger/row-storage.js +0 -812
  239. package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
  240. package/dist/lib/reporting/s3/index.d.mts +0 -34
  241. package/dist/lib/reporting/s3/index.d.ts +0 -34
  242. package/dist/lib/reporting/s3/index.js +0 -347
  243. package/dist/lib/reporting/s3/index.mjs +0 -340
  244. package/dist/lib/reporting/service/maintenance.d.mts +0 -148
  245. package/dist/lib/reporting/service/maintenance.d.ts +0 -148
  246. package/dist/lib/reporting/service/maintenance.js +0 -185
  247. package/dist/lib/reporting/service/maintenance.mjs +0 -159
  248. package/examples/reliable-reporting-service/README.md +0 -169
@@ -1,148 +0,0 @@
1
- import type { ReportingVerification } from '../../types/index.mjs';
2
- import { type ReportingDestinationAuthorizationV1, type ReportingDestinationPatternV1, type ReportingManagedDeliveryAdapterV1 } from './managed.mjs';
3
- import type { ReportingManagedDeliveryBindingV1 } from './types.mjs';
4
- type VerificationProfile = ReportingVerification['verification_profile'];
5
- /**
6
- * Why a delivery, read, revocation or admission could not be routed.
7
- *
8
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
9
- */
10
- export type ReportingManagedDeliveryRoutingErrorCodeV1 =
11
- /** No route is installed for the pattern and transport. */
12
- 'REPORTING_ROUTE_NOT_FOUND'
13
- /** The binding names no transport and the router has no usable `legacyDefault`. */
14
- | 'REPORTING_ROUTE_TRANSPORT_REQUIRED'
15
- /** The authorization recorded no pattern/transport and the router has no usable `legacyDefault`. */
16
- | 'REPORTING_ROUTE_CONTRACT_UNRECORDED'
17
- /** The binding's verification profile is not one its route can verify. */
18
- | 'REPORTING_ROUTE_VERIFICATION_UNSUPPORTED';
19
- /**
20
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
21
- */
22
- export type ReportingManagedDeliveryRoutingOperationV1 = 'deliver' | 'read' | 'revoke' | 'admit_binding' | 'admit_offering';
23
- /**
24
- * Raised by the router before it touches any adapter. The fields are the
25
- * non-secret routing facts only: no destination, location or credential.
26
- *
27
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
28
- */
29
- export declare class ReportingManagedDeliveryRoutingErrorV1 extends Error {
30
- readonly code: ReportingManagedDeliveryRoutingErrorCodeV1;
31
- readonly operation: ReportingManagedDeliveryRoutingOperationV1;
32
- readonly pattern: string | undefined;
33
- readonly transport: string | undefined;
34
- readonly verificationProfile: string | undefined;
35
- constructor(code: ReportingManagedDeliveryRoutingErrorCodeV1, operation: ReportingManagedDeliveryRoutingOperationV1, detail: {
36
- pattern?: string | undefined;
37
- transport?: string | undefined;
38
- verificationProfile?: string | undefined;
39
- }, message: string);
40
- }
41
- /**
42
- * Raised by `router.probe()` when at least one route's probe failed. Carries
43
- * the ids of the failing routes and nothing else from the provider; the
44
- * individual errors are on `cause` (an `AggregateError`) for seller logs only.
45
- *
46
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
47
- */
48
- export declare class ReportingManagedDeliveryProbeErrorV1 extends Error {
49
- readonly failedRouteIds: readonly string[];
50
- constructor(failedRouteIds: readonly string[], errors: readonly unknown[]);
51
- }
52
- /**
53
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
54
- */
55
- export interface ReportingManagedDeliveryRouteV1 {
56
- /** Stable id used in per-route counts and probe failures. Lowercase token, at most 64 characters. */
57
- id: string;
58
- /** The pattern and transport this route serves. Exactly one route may match a pair. */
59
- match: {
60
- pattern: ReportingDestinationPatternV1;
61
- transport: string;
62
- };
63
- /**
64
- * The adapter that serves it. It must declare
65
- * `revocationFencesDeliveryGenerations: true` and a non-empty
66
- * `verificationProfiles`; its profiles are what a binding routed here may use.
67
- */
68
- adapter: ReportingManagedDeliveryAdapterV1;
69
- }
70
- /**
71
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
72
- */
73
- export interface CreateReportingManagedDeliveryAdapterRouterOptionsV1 {
74
- routes: readonly ReportingManagedDeliveryRouteV1[];
75
- /**
76
- * Id of the route that takes work recorded before pattern and transport
77
- * existed: a binding with no `transport`, and a destination authorization
78
- * with no recorded pattern/transport. Without it that work fails with a
79
- * typed error rather than being guessed or sent to every route. A binding
80
- * or authorization that does state a pattern is only sent here if it is this
81
- * route's pattern.
82
- */
83
- legacyDefault?: string;
84
- /**
85
- * Per-route budget for `probe()`. Defaults to 10 seconds and must be below the
86
- * runtime's 30 second probe deadline, so a hung route is still named in the startup error.
87
- */
88
- probeTimeoutMilliseconds?: number;
89
- }
90
- /**
91
- * What a router exposes about a route. The adapter itself stays private to the router.
92
- *
93
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
94
- */
95
- export interface ReportingManagedDeliveryRouteDescriptionV1 {
96
- readonly id: string;
97
- readonly match: Readonly<{
98
- pattern: ReportingDestinationPatternV1;
99
- transport: string;
100
- }>;
101
- readonly verificationProfiles: readonly VerificationProfile[];
102
- }
103
- /**
104
- * A `ReportingManagedDeliveryAdapterV1` that dispatches to one adapter per
105
- * (pattern, transport). The optional hooks are always present on a router.
106
- *
107
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
108
- */
109
- export interface ReportingManagedDeliveryAdapterRouterV1 extends ReportingManagedDeliveryAdapterV1 {
110
- readonly routes: readonly ReportingManagedDeliveryRouteDescriptionV1[];
111
- readonly legacyDefault: string | undefined;
112
- probe(context: {
113
- signal: AbortSignal;
114
- }): Promise<void>;
115
- admitBinding(binding: ReportingManagedDeliveryBindingV1): void;
116
- admitOffering(offering: {
117
- method: {
118
- pattern: string;
119
- transport: string;
120
- };
121
- reconciliation_mode?: string;
122
- }): void;
123
- routeIdFor(target: Readonly<{
124
- binding: ReportingManagedDeliveryBindingV1;
125
- } | {
126
- authorization: ReportingDestinationAuthorizationV1;
127
- }>): string | undefined;
128
- }
129
- /**
130
- * One managed-delivery runtime across several transports.
131
- *
132
- * The router is pure dispatch with no state of its own, so every fence the
133
- * store and worker provide (leases, the authorization-generation check,
134
- * settlement, the retry and attempt caps, revocation SLA accounting) is
135
- * untouched and keeps working per materialization whatever route served it.
136
- *
137
- * - `deliver()` and `read()` choose the route from the immutable binding
138
- * alone (`binding.method` and `binding.transport`), never from request
139
- * input, materialization state or the resource.
140
- * - `revoke()` chooses it from the pattern and transport recorded on the
141
- * authorization generation. It never fans out.
142
- * - Nothing that cannot be routed reaches an adapter: the router throws a
143
- * `ReportingManagedDeliveryRoutingErrorV1` first.
144
- *
145
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
146
- */
147
- export declare function createReportingManagedDeliveryAdapterRouterV1(options: CreateReportingManagedDeliveryAdapterRouterOptionsV1): ReportingManagedDeliveryAdapterRouterV1;
148
- export {};
@@ -1,148 +0,0 @@
1
- import type { ReportingVerification } from '../../types';
2
- import { type ReportingDestinationAuthorizationV1, type ReportingDestinationPatternV1, type ReportingManagedDeliveryAdapterV1 } from './managed';
3
- import type { ReportingManagedDeliveryBindingV1 } from './types';
4
- type VerificationProfile = ReportingVerification['verification_profile'];
5
- /**
6
- * Why a delivery, read, revocation or admission could not be routed.
7
- *
8
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
9
- */
10
- export type ReportingManagedDeliveryRoutingErrorCodeV1 =
11
- /** No route is installed for the pattern and transport. */
12
- 'REPORTING_ROUTE_NOT_FOUND'
13
- /** The binding names no transport and the router has no usable `legacyDefault`. */
14
- | 'REPORTING_ROUTE_TRANSPORT_REQUIRED'
15
- /** The authorization recorded no pattern/transport and the router has no usable `legacyDefault`. */
16
- | 'REPORTING_ROUTE_CONTRACT_UNRECORDED'
17
- /** The binding's verification profile is not one its route can verify. */
18
- | 'REPORTING_ROUTE_VERIFICATION_UNSUPPORTED';
19
- /**
20
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
21
- */
22
- export type ReportingManagedDeliveryRoutingOperationV1 = 'deliver' | 'read' | 'revoke' | 'admit_binding' | 'admit_offering';
23
- /**
24
- * Raised by the router before it touches any adapter. The fields are the
25
- * non-secret routing facts only: no destination, location or credential.
26
- *
27
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
28
- */
29
- export declare class ReportingManagedDeliveryRoutingErrorV1 extends Error {
30
- readonly code: ReportingManagedDeliveryRoutingErrorCodeV1;
31
- readonly operation: ReportingManagedDeliveryRoutingOperationV1;
32
- readonly pattern: string | undefined;
33
- readonly transport: string | undefined;
34
- readonly verificationProfile: string | undefined;
35
- constructor(code: ReportingManagedDeliveryRoutingErrorCodeV1, operation: ReportingManagedDeliveryRoutingOperationV1, detail: {
36
- pattern?: string | undefined;
37
- transport?: string | undefined;
38
- verificationProfile?: string | undefined;
39
- }, message: string);
40
- }
41
- /**
42
- * Raised by `router.probe()` when at least one route's probe failed. Carries
43
- * the ids of the failing routes and nothing else from the provider; the
44
- * individual errors are on `cause` (an `AggregateError`) for seller logs only.
45
- *
46
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
47
- */
48
- export declare class ReportingManagedDeliveryProbeErrorV1 extends Error {
49
- readonly failedRouteIds: readonly string[];
50
- constructor(failedRouteIds: readonly string[], errors: readonly unknown[]);
51
- }
52
- /**
53
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
54
- */
55
- export interface ReportingManagedDeliveryRouteV1 {
56
- /** Stable id used in per-route counts and probe failures. Lowercase token, at most 64 characters. */
57
- id: string;
58
- /** The pattern and transport this route serves. Exactly one route may match a pair. */
59
- match: {
60
- pattern: ReportingDestinationPatternV1;
61
- transport: string;
62
- };
63
- /**
64
- * The adapter that serves it. It must declare
65
- * `revocationFencesDeliveryGenerations: true` and a non-empty
66
- * `verificationProfiles`; its profiles are what a binding routed here may use.
67
- */
68
- adapter: ReportingManagedDeliveryAdapterV1;
69
- }
70
- /**
71
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
72
- */
73
- export interface CreateReportingManagedDeliveryAdapterRouterOptionsV1 {
74
- routes: readonly ReportingManagedDeliveryRouteV1[];
75
- /**
76
- * Id of the route that takes work recorded before pattern and transport
77
- * existed: a binding with no `transport`, and a destination authorization
78
- * with no recorded pattern/transport. Without it that work fails with a
79
- * typed error rather than being guessed or sent to every route. A binding
80
- * or authorization that does state a pattern is only sent here if it is this
81
- * route's pattern.
82
- */
83
- legacyDefault?: string;
84
- /**
85
- * Per-route budget for `probe()`. Defaults to 10 seconds and must be below the
86
- * runtime's 30 second probe deadline, so a hung route is still named in the startup error.
87
- */
88
- probeTimeoutMilliseconds?: number;
89
- }
90
- /**
91
- * What a router exposes about a route. The adapter itself stays private to the router.
92
- *
93
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
94
- */
95
- export interface ReportingManagedDeliveryRouteDescriptionV1 {
96
- readonly id: string;
97
- readonly match: Readonly<{
98
- pattern: ReportingDestinationPatternV1;
99
- transport: string;
100
- }>;
101
- readonly verificationProfiles: readonly VerificationProfile[];
102
- }
103
- /**
104
- * A `ReportingManagedDeliveryAdapterV1` that dispatches to one adapter per
105
- * (pattern, transport). The optional hooks are always present on a router.
106
- *
107
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
108
- */
109
- export interface ReportingManagedDeliveryAdapterRouterV1 extends ReportingManagedDeliveryAdapterV1 {
110
- readonly routes: readonly ReportingManagedDeliveryRouteDescriptionV1[];
111
- readonly legacyDefault: string | undefined;
112
- probe(context: {
113
- signal: AbortSignal;
114
- }): Promise<void>;
115
- admitBinding(binding: ReportingManagedDeliveryBindingV1): void;
116
- admitOffering(offering: {
117
- method: {
118
- pattern: string;
119
- transport: string;
120
- };
121
- reconciliation_mode?: string;
122
- }): void;
123
- routeIdFor(target: Readonly<{
124
- binding: ReportingManagedDeliveryBindingV1;
125
- } | {
126
- authorization: ReportingDestinationAuthorizationV1;
127
- }>): string | undefined;
128
- }
129
- /**
130
- * One managed-delivery runtime across several transports.
131
- *
132
- * The router is pure dispatch with no state of its own, so every fence the
133
- * store and worker provide (leases, the authorization-generation check,
134
- * settlement, the retry and attempt caps, revocation SLA accounting) is
135
- * untouched and keeps working per materialization whatever route served it.
136
- *
137
- * - `deliver()` and `read()` choose the route from the immutable binding
138
- * alone (`binding.method` and `binding.transport`), never from request
139
- * input, materialization state or the resource.
140
- * - `revoke()` chooses it from the pattern and transport recorded on the
141
- * authorization generation. It never fans out.
142
- * - Nothing that cannot be routed reaches an adapter: the router throws a
143
- * `ReportingManagedDeliveryRoutingErrorV1` first.
144
- *
145
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
146
- */
147
- export declare function createReportingManagedDeliveryAdapterRouterV1(options: CreateReportingManagedDeliveryAdapterRouterOptionsV1): ReportingManagedDeliveryAdapterRouterV1;
148
- export {};
@@ -1,280 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var managed_router_exports = {};
20
- __export(managed_router_exports, {
21
- ReportingManagedDeliveryProbeErrorV1: () => ReportingManagedDeliveryProbeErrorV1,
22
- ReportingManagedDeliveryRoutingErrorV1: () => ReportingManagedDeliveryRoutingErrorV1,
23
- createReportingManagedDeliveryAdapterRouterV1: () => createReportingManagedDeliveryAdapterRouterV1
24
- });
25
- module.exports = __toCommonJS(managed_router_exports);
26
- var import_managed = require('./managed.js');
27
- const ROUTE_ID_PATTERN = /^[a-z][a-z0-9_.-]{0,63}$/;
28
- const DEFAULT_ROUTE_PROBE_TIMEOUT_MILLISECONDS = 1e4;
29
- class ReportingManagedDeliveryRoutingErrorV1 extends Error {
30
- code;
31
- operation;
32
- pattern;
33
- transport;
34
- verificationProfile;
35
- constructor(code, operation, detail, message) {
36
- super(message);
37
- this.name = "ReportingManagedDeliveryRoutingErrorV1";
38
- this.code = code;
39
- this.operation = operation;
40
- this.pattern = detail.pattern;
41
- this.transport = detail.transport;
42
- this.verificationProfile = detail.verificationProfile;
43
- }
44
- }
45
- class ReportingManagedDeliveryProbeErrorV1 extends Error {
46
- failedRouteIds;
47
- constructor(failedRouteIds, errors) {
48
- super(`Managed Delivery route probe failed for ${failedRouteIds.map((id) => JSON.stringify(id)).join(", ")}`, {
49
- cause: new AggregateError(errors, "Managed Delivery route probes failed")
50
- });
51
- this.name = "ReportingManagedDeliveryProbeErrorV1";
52
- this.failedRouteIds = Object.freeze([...failedRouteIds]);
53
- }
54
- }
55
- const routeKey = (pattern, transport) => `${pattern}:${transport}`;
56
- const hasText = (value) => typeof value === "string" && value !== "";
57
- function createReportingManagedDeliveryAdapterRouterV1(options) {
58
- if (!options || !Array.isArray(options.routes) || options.routes.length === 0) {
59
- throw new TypeError("A Managed Delivery router requires at least one route");
60
- }
61
- const probeTimeout = options.probeTimeoutMilliseconds ?? DEFAULT_ROUTE_PROBE_TIMEOUT_MILLISECONDS;
62
- if (!Number.isSafeInteger(probeTimeout) || probeTimeout <= 0) {
63
- throw new RangeError("probeTimeoutMilliseconds must be a positive safe integer");
64
- }
65
- if (probeTimeout >= import_managed.REPORTING_ADAPTER_PROBE_DEADLINE_MILLISECONDS_V1) {
66
- throw new RangeError(
67
- `probeTimeoutMilliseconds must be below the runtime's ${import_managed.REPORTING_ADAPTER_PROBE_DEADLINE_MILLISECONDS_V1} ms probe deadline`
68
- );
69
- }
70
- const routes = [];
71
- const byId = /* @__PURE__ */ new Map();
72
- const byMatch = /* @__PURE__ */ new Map();
73
- for (const candidate of options.routes) {
74
- const id = candidate?.id;
75
- if (typeof id !== "string" || !ROUTE_ID_PATTERN.test(id)) {
76
- throw new TypeError("A Managed Delivery route id must match ^[a-z][a-z0-9_.-]{0,63}$");
77
- }
78
- if (byId.has(id)) throw new TypeError(`Managed Delivery route id ${JSON.stringify(id)} is duplicated`);
79
- const pattern = candidate.match?.pattern;
80
- const transport = candidate.match?.transport;
81
- if (!import_managed.REPORTING_DESTINATION_PATTERNS_V1.includes(pattern)) {
82
- throw new TypeError(
83
- `Managed Delivery route ${JSON.stringify(id)} must match file_transfer, dataset_share, or warehouse_materialization`
84
- );
85
- }
86
- if (typeof transport !== "string" || !import_managed.REPORTING_DESTINATION_TRANSPORT_PATTERN_V1.test(transport)) {
87
- throw new TypeError(`Managed Delivery route ${JSON.stringify(id)} has an invalid transport`);
88
- }
89
- const adapter = candidate.adapter;
90
- if (!adapter || typeof adapter.deliver !== "function" || typeof adapter.read !== "function" || typeof adapter.revoke !== "function") {
91
- throw new TypeError(`Managed Delivery route ${JSON.stringify(id)} requires deliver, read, and revoke`);
92
- }
93
- if (adapter.revocationFencesDeliveryGenerations !== true) {
94
- throw new TypeError(
95
- `Managed Delivery route ${JSON.stringify(id)} does not fence delivery generations on revocation`
96
- );
97
- }
98
- if (!Array.isArray(adapter.verificationProfiles) || adapter.verificationProfiles.length === 0) {
99
- throw new TypeError(`Managed Delivery route ${JSON.stringify(id)} declares no verification profile`);
100
- }
101
- const key = routeKey(pattern, transport);
102
- const clash = byMatch.get(key);
103
- if (clash) {
104
- throw new TypeError(
105
- `Managed Delivery routes ${JSON.stringify(clash.id)} and ${JSON.stringify(id)} both match ${pattern}/${transport}`
106
- );
107
- }
108
- const route = Object.freeze({
109
- id,
110
- pattern,
111
- transport,
112
- adapter,
113
- verificationProfiles: Object.freeze([...new Set(adapter.verificationProfiles)])
114
- });
115
- routes.push(route);
116
- byId.set(id, route);
117
- byMatch.set(key, route);
118
- }
119
- let legacy;
120
- if (options.legacyDefault !== void 0) {
121
- legacy = byId.get(options.legacyDefault);
122
- if (!legacy) {
123
- throw new TypeError(`Managed Delivery legacyDefault ${JSON.stringify(options.legacyDefault)} is not a route id`);
124
- }
125
- }
126
- const exact = (pattern, transport) => typeof pattern === "string" && typeof transport === "string" ? byMatch.get(routeKey(pattern, transport)) : void 0;
127
- const forBinding = (binding, operation) => {
128
- const pattern = binding?.method;
129
- const transport = binding?.transport;
130
- if (!hasText(transport)) {
131
- if (legacy && legacy.pattern === pattern) return legacy;
132
- throw new ReportingManagedDeliveryRoutingErrorV1(
133
- "REPORTING_ROUTE_TRANSPORT_REQUIRED",
134
- operation,
135
- { pattern },
136
- "Managed Delivery binding names no transport and no legacy route serves its pattern"
137
- );
138
- }
139
- const route = exact(pattern, transport);
140
- if (route) return route;
141
- throw new ReportingManagedDeliveryRoutingErrorV1(
142
- "REPORTING_ROUTE_NOT_FOUND",
143
- operation,
144
- { pattern, transport },
145
- `No Managed Delivery route serves ${String(pattern)}/${transport}`
146
- );
147
- };
148
- const forAuthorization = (authorization) => {
149
- const { pattern, transport } = authorization ?? {};
150
- if (hasText(pattern) && hasText(transport)) {
151
- const route = exact(pattern, transport);
152
- if (route) return route;
153
- throw new ReportingManagedDeliveryRoutingErrorV1(
154
- "REPORTING_ROUTE_NOT_FOUND",
155
- "revoke",
156
- { pattern, transport },
157
- `No Managed Delivery route serves ${pattern}/${transport}`
158
- );
159
- }
160
- if (legacy && (!hasText(pattern) || legacy.pattern === pattern)) return legacy;
161
- throw new ReportingManagedDeliveryRoutingErrorV1(
162
- "REPORTING_ROUTE_CONTRACT_UNRECORDED",
163
- "revoke",
164
- { pattern, transport },
165
- "Managed Delivery destination authorization recorded no pattern and transport, and no legacy route serves it"
166
- );
167
- };
168
- const assertProfile = (route, binding, operation) => {
169
- if (!route.verificationProfiles.includes(binding.verification_profile)) {
170
- throw new ReportingManagedDeliveryRoutingErrorV1(
171
- "REPORTING_ROUTE_VERIFICATION_UNSUPPORTED",
172
- operation,
173
- { pattern: route.pattern, transport: route.transport, verificationProfile: binding.verification_profile },
174
- `Managed Delivery route ${JSON.stringify(route.id)} cannot verify ${String(binding.verification_profile)}`
175
- );
176
- }
177
- };
178
- const union = Object.freeze([...new Set(routes.flatMap((route) => route.verificationProfiles))]);
179
- const descriptions = Object.freeze(
180
- routes.map(
181
- (route) => Object.freeze({
182
- id: route.id,
183
- match: Object.freeze({ pattern: route.pattern, transport: route.transport }),
184
- verificationProfiles: route.verificationProfiles
185
- })
186
- )
187
- );
188
- const router = {
189
- routes: descriptions,
190
- legacyDefault: legacy?.id,
191
- // Compatibility only: nothing here ever admits a binding. A route's own
192
- // profiles do, in `admitBinding` and again before delivery.
193
- verificationProfiles: union,
194
- revocationFencesDeliveryGenerations: true,
195
- async deliver(input, context) {
196
- const route = forBinding(input.binding, "deliver");
197
- assertProfile(route, input.binding, "deliver");
198
- return route.adapter.deliver(input, context);
199
- },
200
- async read(input, context) {
201
- return forBinding(input.binding, "read").adapter.read(input, context);
202
- },
203
- async revoke(input, context) {
204
- return forAuthorization(input.authorization).adapter.revoke(input, context);
205
- },
206
- admitBinding(binding) {
207
- assertProfile(forBinding(binding, "admit_binding"), binding, "admit_binding");
208
- },
209
- admitOffering(offering) {
210
- const { pattern, transport } = offering.method;
211
- const route = exact(pattern, transport);
212
- if (!route) {
213
- throw new ReportingManagedDeliveryRoutingErrorV1(
214
- "REPORTING_ROUTE_NOT_FOUND",
215
- "admit_offering",
216
- { pattern, transport },
217
- `No Managed Delivery route serves the advertised offering ${pattern}/${transport}`
218
- );
219
- }
220
- if (offering.reconciliation_mode === "consumer_receipt" && !route.verificationProfiles.includes("canonical_digest")) {
221
- throw new ReportingManagedDeliveryRoutingErrorV1(
222
- "REPORTING_ROUTE_VERIFICATION_UNSUPPORTED",
223
- "admit_offering",
224
- { pattern, transport, verificationProfile: "canonical_digest" },
225
- `Managed Delivery route ${JSON.stringify(route.id)} cannot verify canonical_digest for a consumer-receipt offering`
226
- );
227
- }
228
- },
229
- routeIdFor(target) {
230
- try {
231
- if ("binding" in target) return forBinding(target.binding, "deliver").id;
232
- return forAuthorization(target.authorization).id;
233
- } catch {
234
- return void 0;
235
- }
236
- },
237
- async probe(context) {
238
- const probing = routes.filter((route) => typeof route.adapter.probe === "function");
239
- const settled = await Promise.allSettled(probing.map((route) => probeRoute(route, context.signal, probeTimeout)));
240
- const failedIds = [];
241
- const errors = [];
242
- settled.forEach((result, index) => {
243
- if (result.status === "rejected") {
244
- failedIds.push(probing[index].id);
245
- errors.push(result.reason);
246
- }
247
- });
248
- if (failedIds.length) throw new ReportingManagedDeliveryProbeErrorV1(failedIds, errors);
249
- }
250
- };
251
- return Object.freeze(router);
252
- }
253
- async function probeRoute(route, outer, timeoutMilliseconds) {
254
- const controller = new AbortController();
255
- const signal = AbortSignal.any([outer, controller.signal]);
256
- let timer;
257
- try {
258
- await Promise.race([
259
- Promise.resolve().then(() => route.adapter.probe({ signal })),
260
- new Promise((_resolve, reject) => {
261
- const abandon = (reason) => reject(reason ?? new Error("Route probe aborted"));
262
- if (signal.aborted) return abandon(signal.reason);
263
- signal.addEventListener("abort", () => abandon(signal.reason), { once: true });
264
- timer = setTimeout(() => {
265
- const error = new Error("Route probe deadline elapsed");
266
- controller.abort(error);
267
- abandon(error);
268
- }, timeoutMilliseconds);
269
- })
270
- ]);
271
- } finally {
272
- if (timer) clearTimeout(timer);
273
- }
274
- }
275
- // Annotate the CommonJS export names for ESM import in node:
276
- 0 && (module.exports = {
277
- ReportingManagedDeliveryProbeErrorV1,
278
- ReportingManagedDeliveryRoutingErrorV1,
279
- createReportingManagedDeliveryAdapterRouterV1
280
- });