@adcp/sdk 15.4.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 (115) 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.js +22 -8
  56. package/dist/lib/reporting/ledger/handler.mjs +22 -8
  57. package/dist/lib/reporting/ledger/index.d.mts +4 -0
  58. package/dist/lib/reporting/ledger/index.d.ts +4 -0
  59. package/dist/lib/reporting/ledger/index.js +9 -1
  60. package/dist/lib/reporting/ledger/index.mjs +4 -0
  61. package/dist/lib/reporting/ledger/managed-postgres.d.mts +2 -0
  62. package/dist/lib/reporting/ledger/managed-postgres.d.ts +2 -0
  63. package/dist/lib/reporting/ledger/managed-postgres.js +21 -1
  64. package/dist/lib/reporting/ledger/managed-postgres.mjs +21 -1
  65. package/dist/lib/reporting/ledger/managed.d.mts +9 -0
  66. package/dist/lib/reporting/ledger/managed.d.ts +9 -0
  67. package/dist/lib/reporting/ledger/managed.js +18 -0
  68. package/dist/lib/reporting/ledger/managed.mjs +18 -0
  69. package/dist/lib/reporting/ledger/postgres.d.mts +175 -0
  70. package/dist/lib/reporting/ledger/postgres.d.ts +175 -0
  71. package/dist/lib/reporting/ledger/postgres.js +851 -26
  72. package/dist/lib/reporting/ledger/postgres.mjs +859 -26
  73. package/dist/lib/reporting/ledger/producer.js +10 -1
  74. package/dist/lib/reporting/ledger/producer.mjs +10 -1
  75. package/dist/lib/reporting/ledger/row-storage-errors.d.mts +7 -0
  76. package/dist/lib/reporting/ledger/row-storage-errors.d.ts +7 -0
  77. package/dist/lib/reporting/ledger/row-storage-errors.js +41 -0
  78. package/dist/lib/reporting/ledger/row-storage-errors.mjs +16 -0
  79. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +41 -0
  80. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +41 -0
  81. package/dist/lib/reporting/ledger/row-storage-migration.js +234 -0
  82. package/dist/lib/reporting/ledger/row-storage-migration.mjs +208 -0
  83. package/dist/lib/reporting/ledger/row-storage-object.d.mts +112 -0
  84. package/dist/lib/reporting/ledger/row-storage-object.d.ts +112 -0
  85. package/dist/lib/reporting/ledger/row-storage-object.js +281 -0
  86. package/dist/lib/reporting/ledger/row-storage-object.mjs +239 -0
  87. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +51 -0
  88. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +51 -0
  89. package/dist/lib/reporting/ledger/row-storage-provider-io.js +152 -0
  90. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +119 -0
  91. package/dist/lib/reporting/ledger/row-storage.d.mts +224 -0
  92. package/dist/lib/reporting/ledger/row-storage.d.ts +224 -0
  93. package/dist/lib/reporting/ledger/row-storage.js +692 -0
  94. package/dist/lib/reporting/ledger/row-storage.mjs +680 -0
  95. package/dist/lib/reporting/ledger/types.d.mts +8 -0
  96. package/dist/lib/reporting/ledger/types.d.ts +8 -0
  97. package/dist/lib/reporting/service/index.d.mts +41 -1
  98. package/dist/lib/reporting/service/index.d.ts +41 -1
  99. package/dist/lib/reporting/service/index.js +68 -1
  100. package/dist/lib/reporting/service/index.mjs +70 -1
  101. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  102. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  103. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  104. package/dist/lib/version.d.mts +3 -3
  105. package/dist/lib/version.d.ts +3 -3
  106. package/dist/lib/version.js +3 -3
  107. package/dist/lib/version.mjs +3 -3
  108. package/docs/README.md +1 -1
  109. package/docs/TYPE-SUMMARY.md +35 -2
  110. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +142 -0
  111. package/docs/guides/EXISTING-PLATFORM.md +43 -12
  112. package/docs/guides/REPORTING-LEDGER.md +209 -0
  113. package/docs/llms.txt +4 -2
  114. package/docs/migration-14.x-rc-worksheet.md +4 -4
  115. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  import { REPORTING_LEDGER_AUTHORITY } from './types';
2
2
  import type { ReportingLedgerConfigurationV1, ReportingLedgerAdjustmentMetadataV1, ReportingLedgerAdjustmentV1, ReportingLedgerConsumerStatusV1, ReportingLedgerIssueV1, ReportingLedgerLeaseV1, ReportingLedgerObligationV1, ReportingLedgerPageV1, ReportingLedgerRevisionV1, ReportingLedgerSnapshotQueryV1, ReportingLedgerSnapshotV1, ReportingLedgerStatusTransitionV1, ReportingLedgerNotificationActivityPortV1, ReportingLedgerTransactionV1, ReportingObservedFinalityV1, ReportingLedgerStore, ReportingConsumerStatusBatchInputV1, ReportingConsumerStatusBatchResultV1, ReportingConsumerStatusReplayInputV1, ReportingLedgerRevisionMetadataV1, ReportingRevisionRowsPageV1, ReportingRevisionRowsReadV1, ReportingManagedLifecycleProjectionV1, ReportingLedgerAuthorityV1 } from './types';
3
3
  import type { ReportingConsumerMismatchEscalationV1 } from './types';
4
+ import { type ReportingChangeKindV1, type ReportingChangesPageV1 } from './change-feed';
5
+ import { type ReportingRowStorageOptionsV1 } from './row-storage';
4
6
  type QueryResultRow = Record<string, unknown>;
5
7
  interface ReportingPgResult<Row extends QueryResultRow> {
6
8
  rows: Row[];
@@ -86,10 +88,28 @@ export interface PostgresReportingLedgerStoreOptions {
86
88
  * lifecycle transaction. Its tables must be migrated before transitions run.
87
89
  */
88
90
  notificationActivityPort?: ReportingLedgerNotificationActivityPortV1<ReportingLedgerTransactionV1>;
91
+ /**
92
+ * Store new revision and adjustment rows as verified canonical JSONL chunks
93
+ * (see `REPORTING_ROW_STORAGE_MIGRATION`) instead of inline in the ledger
94
+ * document. `true` uses a single `postgres` binding. Revisions written
95
+ * before enabling this keep their inline rows; reads handle both forms
96
+ * whether or not this option is set.
97
+ */
98
+ rowStorage?: boolean | ReportingRowStorageOptionsV1;
99
+ /**
100
+ * Append obligation, revision, adjustment and retirement changes to the
101
+ * host change feed (`REPORTING_LEDGER_CHANGES_MIGRATION`, PostgreSQL 13+) in
102
+ * the same transaction as each record. Required for `changesAfter`.
103
+ */
104
+ changeFeed?: boolean;
89
105
  }
90
106
  export declare class ReportingLedgerLeaseLostError extends Error {
91
107
  constructor(message?: string);
92
108
  }
109
+ /** A planner or writer named a period whose ledger records were retired by retention. */
110
+ export declare class ReportingLedgerPeriodRetiredError extends Error {
111
+ constructor(message?: string);
112
+ }
93
113
  export declare class ReportingLedgerContinuityError extends Error {
94
114
  constructor(message?: string);
95
115
  }
@@ -113,7 +133,36 @@ export declare class PostgresReportingLedgerStore implements ReportingLedgerStor
113
133
  private readonly obligatedConsumers;
114
134
  readonly transactionalNotificationActivity: boolean;
115
135
  private readonly notificationActivityPort?;
136
+ private readonly rowStorage;
137
+ private readonly rowStorageWrites;
138
+ private readonly changeFeed;
116
139
  constructor(pool: ReportingPgPool, options?: PostgresReportingLedgerStoreOptions);
140
+ /** Append one host change-feed row inside the caller's account-locked transaction. */
141
+ private appendChange;
142
+ /** Probe and register row storage when enabled. Safe to call repeatedly. */
143
+ readyRowStorage(): Promise<void>;
144
+ /**
145
+ * Move legacy inline revision and adjustment rows into row storage, a
146
+ * bounded batch at a time. Each row set is re-encoded, proven to reproduce
147
+ * its committed binding, written, and only then removed from the ledger
148
+ * document, in one transaction under the account lock. A document whose
149
+ * rows do not reproduce its binding is never rewritten: it is reported in
150
+ * `quarantined` and left inline. Pass the returned `cursor` back to resume
151
+ * after the last examined document; it is absent once every candidate has
152
+ * been examined. Reclaiming the freed space needs `VACUUM FULL` or an online
153
+ * repack.
154
+ */
155
+ migrateInlineRows(input?: {
156
+ limit?: number;
157
+ account_id?: string;
158
+ cursor?: string;
159
+ bindingId?: string;
160
+ signal?: AbortSignal;
161
+ }): Promise<{
162
+ migrated: number;
163
+ quarantined: string[];
164
+ cursor?: string;
165
+ }>;
117
166
  putConfiguration(configuration: ReportingLedgerConfigurationV1): Promise<{
118
167
  inserted: boolean;
119
168
  value: ReportingLedgerConfigurationV1;
@@ -124,6 +173,11 @@ export declare class PostgresReportingLedgerStore implements ReportingLedgerStor
124
173
  value: ReportingLedgerObligationV1;
125
174
  }>;
126
175
  getObligation(id: string, account_id?: string): Promise<ReportingLedgerObligationV1 | null>;
176
+ /** Periods retired by retention; planners treat them as already covered. */
177
+ listRetiredObligationOrdinals(account_id?: string): Promise<{
178
+ configurationId: string;
179
+ periodOrdinal: number;
180
+ }[]>;
127
181
  listObligations(account_id?: string): Promise<ReportingLedgerObligationV1[]>;
128
182
  listLifecycleDueObligations(input: {
129
183
  ledgerAsOf: string;
@@ -152,6 +206,127 @@ export declare class PostgresReportingLedgerStore implements ReportingLedgerStor
152
206
  value: ReportingLedgerAdjustmentV1;
153
207
  }>;
154
208
  listAdjustments(obligationId: string): Promise<ReportingLedgerAdjustmentV1[]>;
209
+ /**
210
+ * The obligation's current revision header: its official revision if one
211
+ * exists, otherwise its highest-numbered snapshot. An official revision is
212
+ * terminal, so this is always the highest revision number — one index
213
+ * lookup. Rows are read separately through `readRevisionRows`.
214
+ */
215
+ getCurrentRevision(input: {
216
+ account_id: string;
217
+ reporting_obligation_id: string;
218
+ }): Promise<ReportingLedgerRevisionMetadataV1 | null>;
219
+ /**
220
+ * Current revision headers for an account's obligations whose period starts
221
+ * in `[period_start_from, period_start_to)`, ordered by period start.
222
+ * Obligations without a revision yet are omitted. Page with `cursor`.
223
+ */
224
+ listCurrentRevisions(input: {
225
+ account_id: string;
226
+ period_start_from: string;
227
+ period_start_to: string;
228
+ delivery_config_id?: string;
229
+ limit?: number;
230
+ cursor?: string;
231
+ }): Promise<{
232
+ revisions: ReportingLedgerRevisionMetadataV1[];
233
+ cursor?: string;
234
+ }>;
235
+ /**
236
+ * Host change feed. Omit `cursor` to start from the oldest retained change.
237
+ * Account-scoped feeds order by sequence; the deployment-wide feed orders by
238
+ * `(xid, seq)` and returns only changes whose transaction precedes every
239
+ * transaction still in flight, so no commit is ever skipped. A cursor older
240
+ * than the retained history throws `ReportingChangeCursorExpiredError`;
241
+ * resynchronize from `listCurrentRevisions`.
242
+ */
243
+ changesAfter(input?: {
244
+ cursor?: string;
245
+ account_id?: string;
246
+ kinds?: readonly ReportingChangeKindV1[];
247
+ limit?: number;
248
+ }): Promise<ReportingChangesPageV1>;
249
+ /**
250
+ * Record a named durable consumer's position. Registered consumers hold
251
+ * back change-table pruning until `maxFeedHoldDays` after their last update.
252
+ */
253
+ saveFeedConsumerCursor(name: string, cursor: string): Promise<void>;
254
+ /**
255
+ * Delete change rows older than `changeRetentionDays` that every consumer
256
+ * updated within `maxFeedHoldDays` has passed, and advance the expiry
257
+ * horizon so older cursors fail closed.
258
+ */
259
+ pruneChanges(input?: {
260
+ changeRetentionDays?: number;
261
+ maxFeedHoldDays?: number;
262
+ limit?: number;
263
+ }): Promise<{
264
+ deleted: number;
265
+ }>;
266
+ /**
267
+ * Retire whole reporting periods whose retention has elapsed (shared SDK
268
+ * persistence spec §4). A period is eligible once both its end and its
269
+ * latest publication are older than `max(statusRetentionDays,
270
+ * recordRetentionDays)`, no worker holds its lease, and no Managed Delivery
271
+ * materialization still references it. Retirement is period-aligned and
272
+ * resumable:
273
+ *
274
+ * 1. under the account lock, record a `retiring` tombstone and mark the
275
+ * period's row sets `pruning`, so exact reads answer as expired;
276
+ * 2. delete the period's external row objects at their recorded versions;
277
+ * 3. under the account lock, delete the period's ledger records (rows,
278
+ * revisions, adjustments, consumer statuses, issues, transitions,
279
+ * lifecycle state, obligation) and mark the tombstone `retired`.
280
+ *
281
+ * Planners skip retired periods, and `ledger_retained_from` advances past
282
+ * them because their obligations no longer exist.
283
+ */
284
+ retireExpiredPeriods(input: {
285
+ statusRetentionDays: number;
286
+ recordRetentionDays?: number;
287
+ limit?: number;
288
+ account_id?: string;
289
+ signal?: AbortSignal;
290
+ }): Promise<{
291
+ retired: number;
292
+ failed: string[];
293
+ /** Secret-free cause per failed period: a row-store code or the error class name. */
294
+ failures: {
295
+ reporting_obligation_id: string;
296
+ cause: string;
297
+ }[];
298
+ }>;
299
+ private retirePeriod;
300
+ /**
301
+ * Resolve abandoned object uploads (spec §4.3). An expired `open` write
302
+ * intent whose ledger commit never happened is moved to `sweeping` under
303
+ * the account lock, so no writer can commit against it, then only the
304
+ * objects that upload created — never adopted ones, never any object a
305
+ * committed chunk references — are deleted at their recorded versions.
306
+ * Interrupted sweeps resume.
307
+ */
308
+ sweepRowWriteIntents(input?: {
309
+ limit?: number;
310
+ account_id?: string;
311
+ signal?: AbortSignal;
312
+ }): Promise<{
313
+ swept: number;
314
+ objectsDeleted: number;
315
+ failed: number;
316
+ }>;
317
+ private optionalTables;
318
+ /**
319
+ * Upload an object-kind row set before its ledger commit (spec §3.5):
320
+ * skip when the document already exists (replay), refuse unless the lease
321
+ * still covers the upload deadline, open or take over an expired write
322
+ * intent under the account lock, then write every chunk create-only,
323
+ * recording each object this upload created in the intent first.
324
+ */
325
+ private uploadRowSetUnlessCommitted;
326
+ /** Persist a prepared row set and close its upload intent in the ledger commit transaction. */
327
+ private writePreparedRowSet;
328
+ /** Attach verified rows to a revision document whose rows live in row storage. */
329
+ private hydrateRevision;
155
330
  listAdjustmentMetadata(obligationId: string): Promise<ReportingLedgerAdjustmentMetadataV1[]>;
156
331
  putConsumerStatus(status: ReportingLedgerConsumerStatusV1): Promise<{
157
332
  inserted: boolean;