@adcp/sdk 15.3.0 → 15.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/lib/advanced.d.mts +2 -2
  2. package/dist/lib/advanced.d.ts +2 -2
  3. package/dist/lib/advanced.js +8 -2
  4. package/dist/lib/advanced.mjs +8 -2
  5. package/dist/lib/core/AgentClient.d.mts +4 -0
  6. package/dist/lib/core/AgentClient.d.ts +4 -0
  7. package/dist/lib/core/AgentClient.js +8 -0
  8. package/dist/lib/core/AgentClient.mjs +8 -0
  9. package/dist/lib/core/SingleAgentClient.d.mts +154 -0
  10. package/dist/lib/core/SingleAgentClient.d.ts +154 -0
  11. package/dist/lib/core/SingleAgentClient.js +661 -23
  12. package/dist/lib/core/SingleAgentClient.mjs +666 -23
  13. package/dist/lib/core/agent-discovery-cache.d.mts +103 -0
  14. package/dist/lib/core/agent-discovery-cache.d.ts +103 -0
  15. package/dist/lib/core/agent-discovery-cache.js +121 -0
  16. package/dist/lib/core/agent-discovery-cache.mjs +92 -0
  17. package/dist/lib/index.d.mts +5 -3
  18. package/dist/lib/index.d.ts +5 -3
  19. package/dist/lib/index.js +7 -0
  20. package/dist/lib/index.mjs +6 -0
  21. package/dist/lib/protocols/index.d.mts +2 -2
  22. package/dist/lib/protocols/index.d.ts +2 -2
  23. package/dist/lib/protocols/index.js +1 -1
  24. package/dist/lib/protocols/index.mjs +1 -1
  25. package/dist/lib/protocols/mcp-call-context.d.mts +109 -0
  26. package/dist/lib/protocols/mcp-call-context.d.ts +109 -0
  27. package/dist/lib/protocols/mcp-call-context.js +221 -0
  28. package/dist/lib/protocols/mcp-call-context.mjs +186 -0
  29. package/dist/lib/protocols/mcp-modern.d.mts +9 -1
  30. package/dist/lib/protocols/mcp-modern.d.ts +9 -1
  31. package/dist/lib/protocols/mcp-modern.js +180 -104
  32. package/dist/lib/protocols/mcp-modern.mjs +193 -104
  33. package/dist/lib/protocols/mcp-scope.d.mts +15 -0
  34. package/dist/lib/protocols/mcp-scope.d.ts +15 -0
  35. package/dist/lib/protocols/mcp.d.mts +4 -2
  36. package/dist/lib/protocols/mcp.d.ts +4 -2
  37. package/dist/lib/protocols/mcp.js +178 -154
  38. package/dist/lib/protocols/mcp.mjs +189 -153
  39. package/dist/lib/protocols/transportDiagnostics.d.mts +33 -1
  40. package/dist/lib/protocols/transportDiagnostics.d.ts +33 -1
  41. package/dist/lib/protocols/transportDiagnostics.js +128 -12
  42. package/dist/lib/protocols/transportDiagnostics.mjs +128 -12
  43. package/dist/lib/reporting/gcs/index.d.mts +2 -0
  44. package/dist/lib/reporting/gcs/index.d.ts +2 -0
  45. package/dist/lib/reporting/gcs/index.js +3 -0
  46. package/dist/lib/reporting/gcs/index.mjs +2 -0
  47. package/dist/lib/reporting/gcs/row-provider.d.mts +32 -0
  48. package/dist/lib/reporting/gcs/row-provider.d.ts +32 -0
  49. package/dist/lib/reporting/gcs/row-provider.js +205 -0
  50. package/dist/lib/reporting/gcs/row-provider.mjs +188 -0
  51. package/dist/lib/reporting/ledger/change-feed.d.mts +41 -0
  52. package/dist/lib/reporting/ledger/change-feed.d.ts +41 -0
  53. package/dist/lib/reporting/ledger/change-feed.js +101 -0
  54. package/dist/lib/reporting/ledger/change-feed.mjs +74 -0
  55. package/dist/lib/reporting/ledger/handler.d.mts +6 -0
  56. package/dist/lib/reporting/ledger/handler.d.ts +6 -0
  57. package/dist/lib/reporting/ledger/handler.js +51 -8
  58. package/dist/lib/reporting/ledger/handler.mjs +50 -8
  59. package/dist/lib/reporting/ledger/index.d.mts +5 -0
  60. package/dist/lib/reporting/ledger/index.d.ts +5 -0
  61. package/dist/lib/reporting/ledger/index.js +11 -1
  62. package/dist/lib/reporting/ledger/index.mjs +5 -0
  63. package/dist/lib/reporting/ledger/lifecycle.js +3 -2
  64. package/dist/lib/reporting/ledger/lifecycle.mjs +3 -2
  65. package/dist/lib/reporting/ledger/managed-postgres.d.mts +2 -0
  66. package/dist/lib/reporting/ledger/managed-postgres.d.ts +2 -0
  67. package/dist/lib/reporting/ledger/managed-postgres.js +26 -6
  68. package/dist/lib/reporting/ledger/managed-postgres.mjs +26 -6
  69. package/dist/lib/reporting/ledger/managed.d.mts +9 -0
  70. package/dist/lib/reporting/ledger/managed.d.ts +9 -0
  71. package/dist/lib/reporting/ledger/managed.js +18 -0
  72. package/dist/lib/reporting/ledger/managed.mjs +18 -0
  73. package/dist/lib/reporting/ledger/postgres.d.mts +179 -1
  74. package/dist/lib/reporting/ledger/postgres.d.ts +179 -1
  75. package/dist/lib/reporting/ledger/postgres.js +882 -19
  76. package/dist/lib/reporting/ledger/postgres.mjs +890 -19
  77. package/dist/lib/reporting/ledger/producer.js +13 -3
  78. package/dist/lib/reporting/ledger/producer.mjs +13 -3
  79. package/dist/lib/reporting/ledger/revision-metadata.d.mts +17 -0
  80. package/dist/lib/reporting/ledger/revision-metadata.d.ts +17 -0
  81. package/dist/lib/reporting/ledger/revision-metadata.js +71 -0
  82. package/dist/lib/reporting/ledger/revision-metadata.mjs +44 -0
  83. package/dist/lib/reporting/ledger/row-encoding.d.mts +128 -0
  84. package/dist/lib/reporting/ledger/row-encoding.d.ts +128 -0
  85. package/dist/lib/reporting/ledger/row-encoding.js +355 -0
  86. package/dist/lib/reporting/ledger/row-encoding.mjs +315 -0
  87. package/dist/lib/reporting/ledger/row-storage-errors.d.mts +7 -0
  88. package/dist/lib/reporting/ledger/row-storage-errors.d.ts +7 -0
  89. package/dist/lib/reporting/ledger/row-storage-errors.js +41 -0
  90. package/dist/lib/reporting/ledger/row-storage-errors.mjs +16 -0
  91. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +41 -0
  92. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +41 -0
  93. package/dist/lib/reporting/ledger/row-storage-migration.js +234 -0
  94. package/dist/lib/reporting/ledger/row-storage-migration.mjs +208 -0
  95. package/dist/lib/reporting/ledger/row-storage-object.d.mts +112 -0
  96. package/dist/lib/reporting/ledger/row-storage-object.d.ts +112 -0
  97. package/dist/lib/reporting/ledger/row-storage-object.js +281 -0
  98. package/dist/lib/reporting/ledger/row-storage-object.mjs +239 -0
  99. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +51 -0
  100. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +51 -0
  101. package/dist/lib/reporting/ledger/row-storage-provider-io.js +152 -0
  102. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +119 -0
  103. package/dist/lib/reporting/ledger/row-storage.d.mts +224 -0
  104. package/dist/lib/reporting/ledger/row-storage.d.ts +224 -0
  105. package/dist/lib/reporting/ledger/row-storage.js +692 -0
  106. package/dist/lib/reporting/ledger/row-storage.mjs +680 -0
  107. package/dist/lib/reporting/ledger/types.d.mts +45 -0
  108. package/dist/lib/reporting/ledger/types.d.ts +45 -0
  109. package/dist/lib/reporting/service/index.d.mts +41 -1
  110. package/dist/lib/reporting/service/index.d.ts +41 -1
  111. package/dist/lib/reporting/service/index.js +68 -1
  112. package/dist/lib/reporting/service/index.mjs +70 -1
  113. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  114. package/dist/lib/signing/agent-resolver/fetch-helpers.js +1 -1
  115. package/dist/lib/signing/agent-resolver/fetch-helpers.mjs +1 -1
  116. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  117. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  118. package/dist/lib/version.d.mts +3 -3
  119. package/dist/lib/version.d.ts +3 -3
  120. package/dist/lib/version.js +3 -3
  121. package/dist/lib/version.mjs +3 -3
  122. package/docs/README.md +1 -1
  123. package/docs/TYPE-SUMMARY.md +35 -2
  124. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +142 -0
  125. package/docs/guides/EXISTING-PLATFORM.md +43 -12
  126. package/docs/guides/REPORTING-LEDGER.md +209 -0
  127. package/docs/llms.txt +4 -2
  128. package/docs/migration-14.x-rc-worksheet.md +4 -4
  129. package/docs/recipes/verifying-inbound-webhooks.md +8 -0
  130. package/package.json +1 -1
@@ -0,0 +1,224 @@
1
+ import { type ReportingEncodedRowsV1, type ReportingRowChunkManifestV1 } from './row-encoding.mjs';
2
+ import { type ReportingRowObjectProviderV1 } from './row-storage-object.mjs';
3
+ /**
4
+ * Revision row storage (shared SDK persistence spec,
5
+ * adcontextprotocol/adcp#7996 §3). Revision headers stay in the ledger
6
+ * document; rows live as canonical JSONL chunks in a storage binding, and
7
+ * every read is verified against digests committed in PostgreSQL before rows
8
+ * are released.
9
+ */
10
+ export { ReportingRowStoreError, isReportingRowStoreError } from './row-storage-errors.mjs';
11
+ export type { ReportingRowStoreErrorCode } from './row-storage-errors.mjs';
12
+ /** Rows stored as chunk bodies in the ledger's own PostgreSQL schema. */
13
+ export interface ReportingPostgresRowBindingV1 {
14
+ kind: 'postgres';
15
+ }
16
+ /**
17
+ * Rows stored as one object per chunk through a registered provider. The
18
+ * definition lives in host code, which makes it the allowlist: a row set
19
+ * whose recorded binding identity differs from the configured definition is
20
+ * never read from or written to.
21
+ */
22
+ export interface ReportingObjectRowBindingV1 {
23
+ kind: 'object';
24
+ /** Name of a provider registered in `ReportingRowStorageOptionsV1.providers`. */
25
+ provider: string;
26
+ /** Non-secret provider coordinates, validated by the provider's closed schema. */
27
+ location: Readonly<Record<string, string>>;
28
+ /** Owned key prefix. Sweeps and deletes never touch keys outside it. */
29
+ prefix: string;
30
+ /** Object key template; see `REPORTING_ROW_DEFAULT_KEY_TEMPLATE`. */
31
+ keyTemplate?: string;
32
+ /** Stored encoding; digests always cover uncompressed bytes. Default `gzip`. */
33
+ compression?: 'none' | 'gzip';
34
+ /** Host-mapped client reference passed to the provider; never a secret. */
35
+ credentialRef?: string;
36
+ }
37
+ export type ReportingRowBindingDefinitionV1 = ReportingPostgresRowBindingV1 | ReportingObjectRowBindingV1;
38
+ export interface ReportingRowBindingSelectionInputV1 {
39
+ account_id: string;
40
+ reporting_obligation_id: string;
41
+ row_set_kind: 'revision' | 'adjustment';
42
+ finality?: 'snapshot' | 'official';
43
+ row_count: number;
44
+ canonical_byte_count: number;
45
+ }
46
+ export interface ReportingRowStorageOptionsV1 {
47
+ /**
48
+ * Logical binding ID → immutable definition. Defaults to a single
49
+ * `postgres` binding. Changing a definition requires a new ID; keep retired
50
+ * definitions configured while revisions still reference them.
51
+ */
52
+ bindings?: Readonly<Record<string, ReportingRowBindingDefinitionV1>>;
53
+ /** Object-storage providers by name. */
54
+ providers?: Readonly<Record<string, ReportingRowObjectProviderV1>>;
55
+ /** Picks the binding for each new row set. Defaults to the only binding, or `postgres`. */
56
+ selectRowBinding?(input: ReportingRowBindingSelectionInputV1): string | Promise<string>;
57
+ /**
58
+ * Stable deployment namespace, combined with the schema's installation
59
+ * identity into each binding's `namespace_key`. Defaults to `default`.
60
+ */
61
+ deploymentNamespace?: string;
62
+ /** Deadline for one row set's uploads. Default 60 seconds. */
63
+ writeDeadlineMilliseconds?: number;
64
+ /** Deadline for one object read. Default 30 seconds. */
65
+ readDeadlineMilliseconds?: number;
66
+ }
67
+ export interface ReportingRowSetPrepareInputV1 {
68
+ rowSetId: string;
69
+ rowSetKind: 'revision' | 'adjustment';
70
+ accountId: string;
71
+ obligationId: string;
72
+ rows: readonly Record<string, unknown>[];
73
+ finality?: 'snapshot' | 'official';
74
+ /** Reporting period start, used for `{period_date}` in object keys. */
75
+ periodStart?: string;
76
+ /** Committed protocol binding the chunks must reproduce. */
77
+ binding: {
78
+ sha256: string;
79
+ byteCount: number;
80
+ rowCount: number;
81
+ };
82
+ /** Required for revisions (`revision_envelope_v1`); omitted for adjustments (`rows_v1`). */
83
+ controlTotals?: readonly unknown[];
84
+ /** Overrides `selectRowBinding` (for example, to migrate inline rows into a PostgreSQL binding). */
85
+ bindingId?: string;
86
+ }
87
+ interface PreparedObjectV1 {
88
+ readonly key: string;
89
+ readonly physicalBytes: Buffer;
90
+ readonly physicalSha256: string;
91
+ readonly compression: 'none' | 'gzip';
92
+ }
93
+ export interface ReportingPreparedRowSetV1 {
94
+ readonly input: ReportingRowSetPrepareInputV1;
95
+ readonly encoded: ReportingEncodedRowsV1;
96
+ readonly bindingId: string;
97
+ readonly binding: ReportingRowBindingDefinitionV1;
98
+ readonly digestProfile: 'revision_envelope_v1' | 'rows_v1';
99
+ /** Object kind only: one planned object per chunk. */
100
+ readonly objects?: readonly PreparedObjectV1[];
101
+ }
102
+ /** Where one chunk was stored; recorded in the chunk manifest. */
103
+ export interface ReportingRowChunkLocatorV1 {
104
+ objectKey: string;
105
+ nativeVersion: string;
106
+ compression: 'none' | 'gzip';
107
+ physicalSha256: string;
108
+ physicalByteCount: number;
109
+ /** Whether this upload created the object (as opposed to adopting identical bytes). */
110
+ created: boolean;
111
+ }
112
+ interface QueryableV1 {
113
+ query<Row extends Record<string, unknown> = Record<string, unknown>>(text: string, values?: unknown[]): Promise<{
114
+ rows: Row[];
115
+ rowCount?: number | null;
116
+ }>;
117
+ }
118
+ /** A row set whose chunk manifest has been verified against its committed digest. */
119
+ export interface ReportingRowSetHandleV1 {
120
+ readonly rowSetId: string;
121
+ readonly rowSetKind: 'revision' | 'adjustment';
122
+ readonly accountId: string;
123
+ readonly obligationId: string;
124
+ readonly digestProfile: 'revision_envelope_v1' | 'rows_v1';
125
+ readonly contentSha256: string;
126
+ readonly canonicalByteCount: number;
127
+ readonly rowCount: number;
128
+ readonly rowManifestSha256: string;
129
+ readonly bindingId: string;
130
+ readonly bindingIdentitySha256: string;
131
+ readonly kind: 'postgres' | 'object';
132
+ readonly manifests: readonly ReportingRowChunkManifestV1[];
133
+ /** Object kind only, by chunk index. */
134
+ readonly locators: readonly (Omit<ReportingRowChunkLocatorV1, 'created'> | undefined)[];
135
+ }
136
+ /**
137
+ * Reads and writes revision row sets. PostgreSQL-kind reads are always
138
+ * available once the row-storage migration is applied; object-kind reads need
139
+ * the binding and its provider configured. Writes require an explicit opt-in
140
+ * on the owning store.
141
+ */
142
+ export declare class ReportingRowStorageV1 {
143
+ private readonly pool;
144
+ private readonly options;
145
+ private readonly bindings;
146
+ private readonly providers;
147
+ private readonly deploymentNamespace;
148
+ private readonly writeDeadline;
149
+ private readonly readDeadline;
150
+ private readied?;
151
+ private installation?;
152
+ constructor(pool: QueryableV1, options?: ReportingRowStorageOptionsV1);
153
+ /** Deadline budget a writer must still hold on its lease before uploading. */
154
+ get writeDeadlineMilliseconds(): number;
155
+ /** Probe the schema and every provider, and register (or verify) every configured binding. Idempotent. */
156
+ ready(): Promise<void>;
157
+ /** Encode rows, prove the chunks reproduce the committed binding, select a binding and plan objects. */
158
+ prepare(input: ReportingRowSetPrepareInputV1): Promise<ReportingPreparedRowSetV1>;
159
+ /**
160
+ * Upload a prepared object-kind row set, create-only. An object already at a
161
+ * planned key is adopted only when its bytes decode to the exact chunk;
162
+ * otherwise `CONTENT_CONFLICT`. `onCreated` is awaited for every object this
163
+ * call created, before the next upload, so the caller can record it in its
164
+ * write intent.
165
+ */
166
+ upload(prepared: ReportingPreparedRowSetV1, intentId: string, onCreated: (object: {
167
+ objectKey: string;
168
+ nativeVersion: string;
169
+ }) => Promise<void>, signal?: AbortSignal): Promise<ReportingRowChunkLocatorV1[]>;
170
+ /**
171
+ * Persist a prepared row set inside the caller's ledger transaction:
172
+ * bodies for the `postgres` kind, or the uploaded locators for the object
173
+ * kind. Replays of an identical row set are no-ops; a conflicting row set
174
+ * under the same ID is refused.
175
+ */
176
+ writeInTransaction(transaction: QueryableV1, prepared: ReportingPreparedRowSetV1, locators?: readonly ReportingRowChunkLocatorV1[], sharedFromRowSetId?: string): Promise<void>;
177
+ /**
178
+ * Load a row set and verify its chunk manifest against the committed digest.
179
+ * Returns `null` when no row set exists (legacy inline rows) or it belongs
180
+ * to another account. Throws `ROWS_EXPIRED` / `ROWS_UNAVAILABLE` when the
181
+ * rows were pruned or lost.
182
+ */
183
+ find(rowSetId: string, accountId: string, queryable?: QueryableV1): Promise<ReportingRowSetHandleV1 | null>;
184
+ /** Verified rows `[offset, offset + limit)` in ordinal order. */
185
+ readPage(handle: ReportingRowSetHandleV1, offset: number, limit: number, signal?: AbortSignal): Promise<Record<string, unknown>[]>;
186
+ /**
187
+ * Every row, verified chunk by chunk and against the committed binding.
188
+ * `controlTotals` are required for revision row sets.
189
+ */
190
+ readAll(handle: ReportingRowSetHandleV1, controlTotals?: readonly unknown[], options?: {
191
+ maxBytes?: number;
192
+ signal?: AbortSignal;
193
+ }): Promise<Record<string, unknown>[]>;
194
+ /**
195
+ * Delete exact object versions through the configured binding's provider.
196
+ * `absent` counts as success. Only object-kind bindings are accepted.
197
+ */
198
+ deleteObjects(bindingId: string, objects: readonly {
199
+ objectKey: string;
200
+ nativeVersion: string;
201
+ }[], signal?: AbortSignal): Promise<void>;
202
+ /**
203
+ * A live row set in the same obligation and binding whose rows are
204
+ * byte-identical (same manifest digest), with its chunk locations. Sharing
205
+ * never crosses obligations, so it never crosses consumers.
206
+ */
207
+ findShareable(queryable: QueryableV1, prepared: ReportingPreparedRowSetV1): Promise<{
208
+ rowSetId: string;
209
+ locators: ReportingRowChunkLocatorV1[];
210
+ } | undefined>;
211
+ /** Installation identity and namespace key; available after `ready()`. */
212
+ get installationIdentity(): {
213
+ installationId: string;
214
+ namespaceKey: string;
215
+ };
216
+ private readChunkRange;
217
+ private inflate;
218
+ private decode;
219
+ /** Collapse provider failures to stable, secret-free codes. */
220
+ private provider;
221
+ private register;
222
+ }
223
+ /** Fresh opaque intent identifier for one upload attempt. */
224
+ export declare function reportingRowWriteIntentIdV1(): string;
@@ -0,0 +1,224 @@
1
+ import { type ReportingEncodedRowsV1, type ReportingRowChunkManifestV1 } from './row-encoding';
2
+ import { type ReportingRowObjectProviderV1 } from './row-storage-object';
3
+ /**
4
+ * Revision row storage (shared SDK persistence spec,
5
+ * adcontextprotocol/adcp#7996 §3). Revision headers stay in the ledger
6
+ * document; rows live as canonical JSONL chunks in a storage binding, and
7
+ * every read is verified against digests committed in PostgreSQL before rows
8
+ * are released.
9
+ */
10
+ export { ReportingRowStoreError, isReportingRowStoreError } from './row-storage-errors';
11
+ export type { ReportingRowStoreErrorCode } from './row-storage-errors';
12
+ /** Rows stored as chunk bodies in the ledger's own PostgreSQL schema. */
13
+ export interface ReportingPostgresRowBindingV1 {
14
+ kind: 'postgres';
15
+ }
16
+ /**
17
+ * Rows stored as one object per chunk through a registered provider. The
18
+ * definition lives in host code, which makes it the allowlist: a row set
19
+ * whose recorded binding identity differs from the configured definition is
20
+ * never read from or written to.
21
+ */
22
+ export interface ReportingObjectRowBindingV1 {
23
+ kind: 'object';
24
+ /** Name of a provider registered in `ReportingRowStorageOptionsV1.providers`. */
25
+ provider: string;
26
+ /** Non-secret provider coordinates, validated by the provider's closed schema. */
27
+ location: Readonly<Record<string, string>>;
28
+ /** Owned key prefix. Sweeps and deletes never touch keys outside it. */
29
+ prefix: string;
30
+ /** Object key template; see `REPORTING_ROW_DEFAULT_KEY_TEMPLATE`. */
31
+ keyTemplate?: string;
32
+ /** Stored encoding; digests always cover uncompressed bytes. Default `gzip`. */
33
+ compression?: 'none' | 'gzip';
34
+ /** Host-mapped client reference passed to the provider; never a secret. */
35
+ credentialRef?: string;
36
+ }
37
+ export type ReportingRowBindingDefinitionV1 = ReportingPostgresRowBindingV1 | ReportingObjectRowBindingV1;
38
+ export interface ReportingRowBindingSelectionInputV1 {
39
+ account_id: string;
40
+ reporting_obligation_id: string;
41
+ row_set_kind: 'revision' | 'adjustment';
42
+ finality?: 'snapshot' | 'official';
43
+ row_count: number;
44
+ canonical_byte_count: number;
45
+ }
46
+ export interface ReportingRowStorageOptionsV1 {
47
+ /**
48
+ * Logical binding ID → immutable definition. Defaults to a single
49
+ * `postgres` binding. Changing a definition requires a new ID; keep retired
50
+ * definitions configured while revisions still reference them.
51
+ */
52
+ bindings?: Readonly<Record<string, ReportingRowBindingDefinitionV1>>;
53
+ /** Object-storage providers by name. */
54
+ providers?: Readonly<Record<string, ReportingRowObjectProviderV1>>;
55
+ /** Picks the binding for each new row set. Defaults to the only binding, or `postgres`. */
56
+ selectRowBinding?(input: ReportingRowBindingSelectionInputV1): string | Promise<string>;
57
+ /**
58
+ * Stable deployment namespace, combined with the schema's installation
59
+ * identity into each binding's `namespace_key`. Defaults to `default`.
60
+ */
61
+ deploymentNamespace?: string;
62
+ /** Deadline for one row set's uploads. Default 60 seconds. */
63
+ writeDeadlineMilliseconds?: number;
64
+ /** Deadline for one object read. Default 30 seconds. */
65
+ readDeadlineMilliseconds?: number;
66
+ }
67
+ export interface ReportingRowSetPrepareInputV1 {
68
+ rowSetId: string;
69
+ rowSetKind: 'revision' | 'adjustment';
70
+ accountId: string;
71
+ obligationId: string;
72
+ rows: readonly Record<string, unknown>[];
73
+ finality?: 'snapshot' | 'official';
74
+ /** Reporting period start, used for `{period_date}` in object keys. */
75
+ periodStart?: string;
76
+ /** Committed protocol binding the chunks must reproduce. */
77
+ binding: {
78
+ sha256: string;
79
+ byteCount: number;
80
+ rowCount: number;
81
+ };
82
+ /** Required for revisions (`revision_envelope_v1`); omitted for adjustments (`rows_v1`). */
83
+ controlTotals?: readonly unknown[];
84
+ /** Overrides `selectRowBinding` (for example, to migrate inline rows into a PostgreSQL binding). */
85
+ bindingId?: string;
86
+ }
87
+ interface PreparedObjectV1 {
88
+ readonly key: string;
89
+ readonly physicalBytes: Buffer;
90
+ readonly physicalSha256: string;
91
+ readonly compression: 'none' | 'gzip';
92
+ }
93
+ export interface ReportingPreparedRowSetV1 {
94
+ readonly input: ReportingRowSetPrepareInputV1;
95
+ readonly encoded: ReportingEncodedRowsV1;
96
+ readonly bindingId: string;
97
+ readonly binding: ReportingRowBindingDefinitionV1;
98
+ readonly digestProfile: 'revision_envelope_v1' | 'rows_v1';
99
+ /** Object kind only: one planned object per chunk. */
100
+ readonly objects?: readonly PreparedObjectV1[];
101
+ }
102
+ /** Where one chunk was stored; recorded in the chunk manifest. */
103
+ export interface ReportingRowChunkLocatorV1 {
104
+ objectKey: string;
105
+ nativeVersion: string;
106
+ compression: 'none' | 'gzip';
107
+ physicalSha256: string;
108
+ physicalByteCount: number;
109
+ /** Whether this upload created the object (as opposed to adopting identical bytes). */
110
+ created: boolean;
111
+ }
112
+ interface QueryableV1 {
113
+ query<Row extends Record<string, unknown> = Record<string, unknown>>(text: string, values?: unknown[]): Promise<{
114
+ rows: Row[];
115
+ rowCount?: number | null;
116
+ }>;
117
+ }
118
+ /** A row set whose chunk manifest has been verified against its committed digest. */
119
+ export interface ReportingRowSetHandleV1 {
120
+ readonly rowSetId: string;
121
+ readonly rowSetKind: 'revision' | 'adjustment';
122
+ readonly accountId: string;
123
+ readonly obligationId: string;
124
+ readonly digestProfile: 'revision_envelope_v1' | 'rows_v1';
125
+ readonly contentSha256: string;
126
+ readonly canonicalByteCount: number;
127
+ readonly rowCount: number;
128
+ readonly rowManifestSha256: string;
129
+ readonly bindingId: string;
130
+ readonly bindingIdentitySha256: string;
131
+ readonly kind: 'postgres' | 'object';
132
+ readonly manifests: readonly ReportingRowChunkManifestV1[];
133
+ /** Object kind only, by chunk index. */
134
+ readonly locators: readonly (Omit<ReportingRowChunkLocatorV1, 'created'> | undefined)[];
135
+ }
136
+ /**
137
+ * Reads and writes revision row sets. PostgreSQL-kind reads are always
138
+ * available once the row-storage migration is applied; object-kind reads need
139
+ * the binding and its provider configured. Writes require an explicit opt-in
140
+ * on the owning store.
141
+ */
142
+ export declare class ReportingRowStorageV1 {
143
+ private readonly pool;
144
+ private readonly options;
145
+ private readonly bindings;
146
+ private readonly providers;
147
+ private readonly deploymentNamespace;
148
+ private readonly writeDeadline;
149
+ private readonly readDeadline;
150
+ private readied?;
151
+ private installation?;
152
+ constructor(pool: QueryableV1, options?: ReportingRowStorageOptionsV1);
153
+ /** Deadline budget a writer must still hold on its lease before uploading. */
154
+ get writeDeadlineMilliseconds(): number;
155
+ /** Probe the schema and every provider, and register (or verify) every configured binding. Idempotent. */
156
+ ready(): Promise<void>;
157
+ /** Encode rows, prove the chunks reproduce the committed binding, select a binding and plan objects. */
158
+ prepare(input: ReportingRowSetPrepareInputV1): Promise<ReportingPreparedRowSetV1>;
159
+ /**
160
+ * Upload a prepared object-kind row set, create-only. An object already at a
161
+ * planned key is adopted only when its bytes decode to the exact chunk;
162
+ * otherwise `CONTENT_CONFLICT`. `onCreated` is awaited for every object this
163
+ * call created, before the next upload, so the caller can record it in its
164
+ * write intent.
165
+ */
166
+ upload(prepared: ReportingPreparedRowSetV1, intentId: string, onCreated: (object: {
167
+ objectKey: string;
168
+ nativeVersion: string;
169
+ }) => Promise<void>, signal?: AbortSignal): Promise<ReportingRowChunkLocatorV1[]>;
170
+ /**
171
+ * Persist a prepared row set inside the caller's ledger transaction:
172
+ * bodies for the `postgres` kind, or the uploaded locators for the object
173
+ * kind. Replays of an identical row set are no-ops; a conflicting row set
174
+ * under the same ID is refused.
175
+ */
176
+ writeInTransaction(transaction: QueryableV1, prepared: ReportingPreparedRowSetV1, locators?: readonly ReportingRowChunkLocatorV1[], sharedFromRowSetId?: string): Promise<void>;
177
+ /**
178
+ * Load a row set and verify its chunk manifest against the committed digest.
179
+ * Returns `null` when no row set exists (legacy inline rows) or it belongs
180
+ * to another account. Throws `ROWS_EXPIRED` / `ROWS_UNAVAILABLE` when the
181
+ * rows were pruned or lost.
182
+ */
183
+ find(rowSetId: string, accountId: string, queryable?: QueryableV1): Promise<ReportingRowSetHandleV1 | null>;
184
+ /** Verified rows `[offset, offset + limit)` in ordinal order. */
185
+ readPage(handle: ReportingRowSetHandleV1, offset: number, limit: number, signal?: AbortSignal): Promise<Record<string, unknown>[]>;
186
+ /**
187
+ * Every row, verified chunk by chunk and against the committed binding.
188
+ * `controlTotals` are required for revision row sets.
189
+ */
190
+ readAll(handle: ReportingRowSetHandleV1, controlTotals?: readonly unknown[], options?: {
191
+ maxBytes?: number;
192
+ signal?: AbortSignal;
193
+ }): Promise<Record<string, unknown>[]>;
194
+ /**
195
+ * Delete exact object versions through the configured binding's provider.
196
+ * `absent` counts as success. Only object-kind bindings are accepted.
197
+ */
198
+ deleteObjects(bindingId: string, objects: readonly {
199
+ objectKey: string;
200
+ nativeVersion: string;
201
+ }[], signal?: AbortSignal): Promise<void>;
202
+ /**
203
+ * A live row set in the same obligation and binding whose rows are
204
+ * byte-identical (same manifest digest), with its chunk locations. Sharing
205
+ * never crosses obligations, so it never crosses consumers.
206
+ */
207
+ findShareable(queryable: QueryableV1, prepared: ReportingPreparedRowSetV1): Promise<{
208
+ rowSetId: string;
209
+ locators: ReportingRowChunkLocatorV1[];
210
+ } | undefined>;
211
+ /** Installation identity and namespace key; available after `ready()`. */
212
+ get installationIdentity(): {
213
+ installationId: string;
214
+ namespaceKey: string;
215
+ };
216
+ private readChunkRange;
217
+ private inflate;
218
+ private decode;
219
+ /** Collapse provider failures to stable, secret-free codes. */
220
+ private provider;
221
+ private register;
222
+ }
223
+ /** Fresh opaque intent identifier for one upload attempt. */
224
+ export declare function reportingRowWriteIntentIdV1(): string;