@adcp/sdk 16.0.0-beta.3 → 16.0.0-beta.5

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 (185) hide show
  1. package/dist/lib/auth/oauth/diagnose.js +3 -11
  2. package/dist/lib/auth/oauth/diagnose.mjs +4 -12
  3. package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
  4. package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
  5. package/dist/lib/auth/oauth/diagnostics.js +8 -10
  6. package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
  7. package/dist/lib/index.d.mts +1 -1
  8. package/dist/lib/index.d.ts +1 -1
  9. package/dist/lib/index.js +2 -0
  10. package/dist/lib/index.mjs +7 -1
  11. package/dist/lib/reporting/consumer-runtime.js +2 -1
  12. package/dist/lib/reporting/consumer-runtime.mjs +2 -1
  13. package/dist/lib/reporting/ledger/handler.js +50 -11
  14. package/dist/lib/reporting/ledger/handler.mjs +50 -12
  15. package/dist/lib/reporting/ledger/index.d.mts +17 -14
  16. package/dist/lib/reporting/ledger/index.d.ts +17 -14
  17. package/dist/lib/reporting/ledger/index.js +32 -20
  18. package/dist/lib/reporting/ledger/index.mjs +21 -10
  19. package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
  20. package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
  21. package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
  22. package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
  23. package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
  24. package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
  25. package/dist/lib/reporting/ledger/receipts.js +186 -0
  26. package/dist/lib/reporting/ledger/receipts.mjs +161 -0
  27. package/dist/lib/reporting/ledger/status-ingest.js +3 -3
  28. package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
  29. package/dist/lib/reporting/ledger/types.d.mts +43 -0
  30. package/dist/lib/reporting/ledger/types.d.ts +43 -0
  31. package/dist/lib/reporting/ledger/types.js +31 -2
  32. package/dist/lib/reporting/ledger/types.mjs +26 -1
  33. package/dist/lib/reporting/pagination.d.mts +6 -0
  34. package/dist/lib/reporting/pagination.d.ts +6 -0
  35. package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
  36. package/dist/lib/reporting/pagination.mjs +12 -0
  37. package/dist/lib/reporting/reconciliation.d.mts +1 -0
  38. package/dist/lib/reporting/reconciliation.d.ts +1 -0
  39. package/dist/lib/reporting/reconciliation.js +3 -2
  40. package/dist/lib/reporting/reconciliation.mjs +3 -2
  41. package/dist/lib/reporting/service/index.d.mts +79 -153
  42. package/dist/lib/reporting/service/index.d.ts +79 -153
  43. package/dist/lib/reporting/service/index.js +34 -491
  44. package/dist/lib/reporting/service/index.mjs +36 -510
  45. package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
  46. package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
  47. package/dist/lib/reporting/service/scheduler-support.js +125 -0
  48. package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
  49. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  50. package/dist/lib/signing/canonicalize.d.mts +4 -0
  51. package/dist/lib/signing/canonicalize.d.ts +4 -0
  52. package/dist/lib/signing/canonicalize.js +14 -8
  53. package/dist/lib/signing/canonicalize.mjs +14 -8
  54. package/dist/lib/signing/content-digest.d.mts +8 -0
  55. package/dist/lib/signing/content-digest.d.ts +8 -0
  56. package/dist/lib/signing/content-digest.js +11 -5
  57. package/dist/lib/signing/content-digest.mjs +10 -5
  58. package/dist/lib/signing/signer.js +9 -6
  59. package/dist/lib/signing/signer.mjs +10 -7
  60. package/dist/lib/signing/web-bot-auth.js +103 -37
  61. package/dist/lib/signing/web-bot-auth.mjs +108 -37
  62. package/dist/lib/testing/storyboard/junit.js +16 -3
  63. package/dist/lib/testing/storyboard/junit.mjs +16 -3
  64. package/dist/lib/testing/storyboard/request-signing/builder.js +10 -9
  65. package/dist/lib/testing/storyboard/request-signing/builder.mjs +10 -9
  66. package/dist/lib/testing/storyboard/runner.js +94 -25
  67. package/dist/lib/testing/storyboard/runner.mjs +94 -25
  68. package/dist/lib/testing/storyboard/types.d.mts +6 -0
  69. package/dist/lib/testing/storyboard/types.d.ts +6 -0
  70. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  71. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  72. package/dist/lib/types/schemas.generated.d.ts +907 -60
  73. package/dist/lib/types/schemas.generated.js +7 -7
  74. package/dist/lib/types/schemas.generated.mjs +7 -7
  75. package/dist/lib/version.d.mts +3 -3
  76. package/dist/lib/version.d.ts +3 -3
  77. package/dist/lib/version.js +3 -3
  78. package/dist/lib/version.mjs +3 -3
  79. package/docs/TYPE-SUMMARY.md +23 -5
  80. package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
  81. package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
  82. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
  83. package/docs/guides/REPORTING-LEDGER.md +107 -51
  84. package/docs/guides/REPORTING-OPERATIONS.md +66 -5
  85. package/docs/guides/REPORTING-STABILITY.md +36 -32
  86. package/docs/llms.txt +4 -3
  87. package/docs/migration-14.x-rc-worksheet.md +4 -7
  88. package/docs/migration-reporting-storage-package.md +186 -0
  89. package/examples/README.md +1 -1
  90. package/package.json +13 -78
  91. package/dist/lib/reporting/azure/index.d.mts +0 -31
  92. package/dist/lib/reporting/azure/index.d.ts +0 -31
  93. package/dist/lib/reporting/azure/index.js +0 -266
  94. package/dist/lib/reporting/azure/index.mjs +0 -249
  95. package/dist/lib/reporting/bigquery/index.d.mts +0 -246
  96. package/dist/lib/reporting/bigquery/index.d.ts +0 -246
  97. package/dist/lib/reporting/bigquery/index.js +0 -633
  98. package/dist/lib/reporting/bigquery/index.mjs +0 -594
  99. package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
  100. package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
  101. package/dist/lib/reporting/gcs/adapter.js +0 -342
  102. package/dist/lib/reporting/gcs/adapter.mjs +0 -325
  103. package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
  104. package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
  105. package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
  106. package/dist/lib/reporting/gcs/errors.d.mts +0 -11
  107. package/dist/lib/reporting/gcs/errors.d.ts +0 -11
  108. package/dist/lib/reporting/gcs/errors.mjs +0 -16
  109. package/dist/lib/reporting/gcs/fence.d.mts +0 -41
  110. package/dist/lib/reporting/gcs/fence.d.ts +0 -41
  111. package/dist/lib/reporting/gcs/fence.js +0 -250
  112. package/dist/lib/reporting/gcs/fence.mjs +0 -230
  113. package/dist/lib/reporting/gcs/index.d.mts +0 -18
  114. package/dist/lib/reporting/gcs/index.d.ts +0 -18
  115. package/dist/lib/reporting/gcs/index.js +0 -44
  116. package/dist/lib/reporting/gcs/index.mjs +0 -14
  117. package/dist/lib/reporting/gcs/io.d.mts +0 -7
  118. package/dist/lib/reporting/gcs/io.d.ts +0 -7
  119. package/dist/lib/reporting/gcs/io.js +0 -95
  120. package/dist/lib/reporting/gcs/io.mjs +0 -69
  121. package/dist/lib/reporting/gcs/reader.d.mts +0 -67
  122. package/dist/lib/reporting/gcs/reader.d.ts +0 -67
  123. package/dist/lib/reporting/gcs/reader.js +0 -193
  124. package/dist/lib/reporting/gcs/reader.mjs +0 -169
  125. package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
  126. package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
  127. package/dist/lib/reporting/gcs/row-provider.js +0 -225
  128. package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
  129. package/dist/lib/reporting/gcs/validation.d.mts +0 -5
  130. package/dist/lib/reporting/gcs/validation.d.ts +0 -5
  131. package/dist/lib/reporting/gcs/validation.js +0 -49
  132. package/dist/lib/reporting/gcs/validation.mjs +0 -25
  133. package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
  134. package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
  135. package/dist/lib/reporting/ledger/change-feed.js +0 -107
  136. package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
  137. package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
  138. package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
  139. package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
  140. package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
  141. package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
  142. package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
  143. package/dist/lib/reporting/ledger/managed-router.js +0 -280
  144. package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
  145. package/dist/lib/reporting/ledger/managed.d.mts +0 -535
  146. package/dist/lib/reporting/ledger/managed.d.ts +0 -535
  147. package/dist/lib/reporting/ledger/managed.js +0 -761
  148. package/dist/lib/reporting/ledger/managed.mjs +0 -729
  149. package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
  150. package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
  151. package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
  152. package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
  153. package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
  154. package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
  155. package/dist/lib/reporting/ledger/object-writes.js +0 -147
  156. package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
  157. package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
  158. package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
  159. package/dist/lib/reporting/ledger/postgres.js +0 -4462
  160. package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
  161. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
  162. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
  163. package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
  164. package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
  165. package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
  166. package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
  167. package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
  168. package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
  169. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
  170. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
  171. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
  172. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
  173. package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
  174. package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
  175. package/dist/lib/reporting/ledger/row-storage.js +0 -812
  176. package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
  177. package/dist/lib/reporting/s3/index.d.mts +0 -34
  178. package/dist/lib/reporting/s3/index.d.ts +0 -34
  179. package/dist/lib/reporting/s3/index.js +0 -347
  180. package/dist/lib/reporting/s3/index.mjs +0 -340
  181. package/dist/lib/reporting/service/maintenance.d.mts +0 -148
  182. package/dist/lib/reporting/service/maintenance.d.ts +0 -148
  183. package/dist/lib/reporting/service/maintenance.js +0 -185
  184. package/dist/lib/reporting/service/maintenance.mjs +0 -159
  185. 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
- });