@secondlayer/shared 13.4.0 → 13.6.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 (42) hide show
  1. package/dist/src/archive/range-digest.d.ts +45 -0
  2. package/dist/src/archive/semantic-digest-builder.d.ts +45 -0
  3. package/dist/src/coverage/index.d.ts +45 -0
  4. package/dist/src/db/index.d.ts +50 -1
  5. package/dist/src/db/index.js +4 -1
  6. package/dist/src/db/index.js.map +3 -3
  7. package/dist/src/db/queries/chain-reorgs.d.ts +45 -0
  8. package/dist/src/db/queries/chain-reorgs.js +4 -1
  9. package/dist/src/db/queries/chain-reorgs.js.map +3 -3
  10. package/dist/src/db/queries/contracts.d.ts +45 -0
  11. package/dist/src/db/queries/instance.d.ts +45 -0
  12. package/dist/src/db/queries/integrity.d.ts +45 -0
  13. package/dist/src/db/queries/subgraph-gaps.d.ts +45 -0
  14. package/dist/src/db/queries/subgraph-operations.d.ts +45 -0
  15. package/dist/src/db/queries/subgraphs.d.ts +45 -0
  16. package/dist/src/db/queries/sync-scope.d.ts +45 -0
  17. package/dist/src/db/queries/webhooks.d.ts +45 -0
  18. package/dist/src/db/schema.d.ts +47 -1
  19. package/dist/src/index.d.ts +144 -7
  20. package/dist/src/index.js +183 -87
  21. package/dist/src/index.js.map +5 -4
  22. package/dist/src/insights/index.d.ts +1554 -0
  23. package/dist/src/insights/index.js +2284 -0
  24. package/dist/src/insights/index.js.map +29 -0
  25. package/dist/src/insights/thresholds.d.ts +56 -0
  26. package/dist/src/insights/thresholds.js +86 -0
  27. package/dist/src/insights/thresholds.js.map +10 -0
  28. package/dist/src/leader.d.ts +3 -1
  29. package/dist/src/leader.js +3 -1
  30. package/dist/src/leader.js.map +3 -3
  31. package/dist/src/node/local-client.d.ts +45 -0
  32. package/dist/src/queue/listener.js +4 -1
  33. package/dist/src/queue/listener.js.map +3 -3
  34. package/dist/src/schemas/index.d.ts +95 -7
  35. package/dist/src/schemas/index.js +180 -87
  36. package/dist/src/schemas/index.js.map +4 -3
  37. package/dist/src/schemas/insights.d.ts +89 -0
  38. package/dist/src/schemas/insights.js +98 -0
  39. package/dist/src/schemas/insights.js.map +10 -0
  40. package/migrations/0170_insights.ts +63 -0
  41. package/migrations/0171_webhook_incident_alerts.ts +45 -0
  42. package/package.json +13 -1
@@ -389,6 +389,35 @@ interface SubgraphErrorGroupsTable {
389
389
  first_seen: Generated<Date>;
390
390
  last_seen: Generated<Date>;
391
391
  }
392
+ /**
393
+ * One ranked dashboard insight. `account_id` is NULL on tenant and self-host
394
+ * databases. `severity` is never "recovered": that is derived on read from
395
+ * `resolved_at`.
396
+ */
397
+ interface InsightsTable {
398
+ id: Generated<string>;
399
+ account_id: string | null;
400
+ resource_kind: string;
401
+ resource_id: string;
402
+ rule: string;
403
+ severity: string;
404
+ impact: Generated<number>;
405
+ /** resource, line, meta, lead, body, evidence, handoff, how. */
406
+ payload: unknown;
407
+ first_seen_at: Generated<Date>;
408
+ last_seen_at: Generated<Date>;
409
+ clear_streak: Generated<number>;
410
+ resolved_at: Date | null;
411
+ dismissed_at: Date | null;
412
+ }
413
+ /** "Expected": mutes one rule for one resource until removed. */
414
+ interface InsightMutesTable {
415
+ account_id: string | null;
416
+ resource_kind: string;
417
+ resource_id: string;
418
+ rule: string;
419
+ created_at: Generated<Date>;
420
+ }
392
421
  interface ProcessedStripeEventsTable {
393
422
  event_id: string;
394
423
  event_type: string;
@@ -904,12 +933,15 @@ interface Database {
904
933
  archive_fetches: ArchiveFetchesTable;
905
934
  usage_ledger: UsageLedgerTable;
906
935
  account_balance_alerts: AccountBalanceAlertsTable;
936
+ webhook_incident_alerts: WebhookIncidentAlertsTable;
907
937
  sentinel_accounts: SentinelAccountsTable;
908
938
  waitlists: WaitlistsTable;
909
939
  waitlist_signups: WaitlistSignupsTable;
910
940
  contact_requests: ContactRequestsTable;
911
941
  api_failed_requests: ApiFailedRequestsTable;
912
942
  api_request_log: ApiRequestLogTable;
943
+ insights: InsightsTable;
944
+ insight_mutes: InsightMutesTable;
913
945
  feedback_tickets: FeedbackTicketsTable;
914
946
  }
915
947
  interface ServiceHeartbeatsTable {
@@ -990,6 +1022,19 @@ interface AccountBalanceAlertsTable {
990
1022
  sent_2d_at: Date | null;
991
1023
  sent_stopped_at: Date | null;
992
1024
  }
1025
+ /** Debounce state for the webhook-down email: one row per incident, open
1026
+ * while `resolved_at` is null. No preference columns by design. */
1027
+ interface WebhookIncidentAlertsTable {
1028
+ id: Generated<string>;
1029
+ account_id: string;
1030
+ webhook_id: string;
1031
+ webhook_name: string;
1032
+ failing_since: Date;
1033
+ opened_at: Generated<Date>;
1034
+ emailed_at: Date | null;
1035
+ email_attempts: Generated<number>;
1036
+ resolved_at: Date | null;
1037
+ }
993
1038
  /** Accounts Sentinel's service key may touch: created by Sentinel, or the
994
1039
  * owner opted in. */
995
1040
  interface SentinelAccountsTable {
@@ -379,6 +379,35 @@ interface SubgraphErrorGroupsTable {
379
379
  first_seen: Generated<Date>;
380
380
  last_seen: Generated<Date>;
381
381
  }
382
+ /**
383
+ * One ranked dashboard insight. `account_id` is NULL on tenant and self-host
384
+ * databases. `severity` is never "recovered": that is derived on read from
385
+ * `resolved_at`.
386
+ */
387
+ interface InsightsTable {
388
+ id: Generated<string>;
389
+ account_id: string | null;
390
+ resource_kind: string;
391
+ resource_id: string;
392
+ rule: string;
393
+ severity: string;
394
+ impact: Generated<number>;
395
+ /** resource, line, meta, lead, body, evidence, handoff, how. */
396
+ payload: unknown;
397
+ first_seen_at: Generated<Date>;
398
+ last_seen_at: Generated<Date>;
399
+ clear_streak: Generated<number>;
400
+ resolved_at: Date | null;
401
+ dismissed_at: Date | null;
402
+ }
403
+ /** "Expected": mutes one rule for one resource until removed. */
404
+ interface InsightMutesTable {
405
+ account_id: string | null;
406
+ resource_kind: string;
407
+ resource_id: string;
408
+ rule: string;
409
+ created_at: Generated<Date>;
410
+ }
382
411
  interface ProcessedStripeEventsTable {
383
412
  event_id: string;
384
413
  event_type: string;
@@ -894,12 +923,15 @@ interface Database {
894
923
  archive_fetches: ArchiveFetchesTable;
895
924
  usage_ledger: UsageLedgerTable;
896
925
  account_balance_alerts: AccountBalanceAlertsTable;
926
+ webhook_incident_alerts: WebhookIncidentAlertsTable;
897
927
  sentinel_accounts: SentinelAccountsTable;
898
928
  waitlists: WaitlistsTable;
899
929
  waitlist_signups: WaitlistSignupsTable;
900
930
  contact_requests: ContactRequestsTable;
901
931
  api_failed_requests: ApiFailedRequestsTable;
902
932
  api_request_log: ApiRequestLogTable;
933
+ insights: InsightsTable;
934
+ insight_mutes: InsightMutesTable;
903
935
  feedback_tickets: FeedbackTicketsTable;
904
936
  }
905
937
  interface ServiceHeartbeatsTable {
@@ -980,6 +1012,19 @@ interface AccountBalanceAlertsTable {
980
1012
  sent_2d_at: Date | null;
981
1013
  sent_stopped_at: Date | null;
982
1014
  }
1015
+ /** Debounce state for the webhook-down email: one row per incident, open
1016
+ * while `resolved_at` is null. No preference columns by design. */
1017
+ interface WebhookIncidentAlertsTable {
1018
+ id: Generated<string>;
1019
+ account_id: string;
1020
+ webhook_id: string;
1021
+ webhook_name: string;
1022
+ failing_since: Date;
1023
+ opened_at: Generated<Date>;
1024
+ emailed_at: Date | null;
1025
+ email_attempts: Generated<number>;
1026
+ resolved_at: Date | null;
1027
+ }
983
1028
  /** Accounts Sentinel's service key may touch: created by Sentinel, or the
984
1029
  * owner opted in. */
985
1030
  interface SentinelAccountsTable {
@@ -378,6 +378,35 @@ interface SubgraphErrorGroupsTable {
378
378
  first_seen: Generated<Date>;
379
379
  last_seen: Generated<Date>;
380
380
  }
381
+ /**
382
+ * One ranked dashboard insight. `account_id` is NULL on tenant and self-host
383
+ * databases. `severity` is never "recovered": that is derived on read from
384
+ * `resolved_at`.
385
+ */
386
+ interface InsightsTable {
387
+ id: Generated<string>;
388
+ account_id: string | null;
389
+ resource_kind: string;
390
+ resource_id: string;
391
+ rule: string;
392
+ severity: string;
393
+ impact: Generated<number>;
394
+ /** resource, line, meta, lead, body, evidence, handoff, how. */
395
+ payload: unknown;
396
+ first_seen_at: Generated<Date>;
397
+ last_seen_at: Generated<Date>;
398
+ clear_streak: Generated<number>;
399
+ resolved_at: Date | null;
400
+ dismissed_at: Date | null;
401
+ }
402
+ /** "Expected": mutes one rule for one resource until removed. */
403
+ interface InsightMutesTable {
404
+ account_id: string | null;
405
+ resource_kind: string;
406
+ resource_id: string;
407
+ rule: string;
408
+ created_at: Generated<Date>;
409
+ }
381
410
  interface ProcessedStripeEventsTable {
382
411
  event_id: string;
383
412
  event_type: string;
@@ -893,12 +922,15 @@ interface Database {
893
922
  archive_fetches: ArchiveFetchesTable;
894
923
  usage_ledger: UsageLedgerTable;
895
924
  account_balance_alerts: AccountBalanceAlertsTable;
925
+ webhook_incident_alerts: WebhookIncidentAlertsTable;
896
926
  sentinel_accounts: SentinelAccountsTable;
897
927
  waitlists: WaitlistsTable;
898
928
  waitlist_signups: WaitlistSignupsTable;
899
929
  contact_requests: ContactRequestsTable;
900
930
  api_failed_requests: ApiFailedRequestsTable;
901
931
  api_request_log: ApiRequestLogTable;
932
+ insights: InsightsTable;
933
+ insight_mutes: InsightMutesTable;
902
934
  feedback_tickets: FeedbackTicketsTable;
903
935
  }
904
936
  interface ServiceHeartbeatsTable {
@@ -991,6 +1023,20 @@ interface AccountBalanceAlertsTable {
991
1023
  sent_2d_at: Date | null;
992
1024
  sent_stopped_at: Date | null;
993
1025
  }
1026
+ /** Debounce state for the webhook-down email: one row per incident, open
1027
+ * while `resolved_at` is null. No preference columns by design. */
1028
+ interface WebhookIncidentAlertsTable {
1029
+ id: Generated<string>;
1030
+ account_id: string;
1031
+ webhook_id: string;
1032
+ webhook_name: string;
1033
+ failing_since: Date;
1034
+ opened_at: Generated<Date>;
1035
+ emailed_at: Date | null;
1036
+ email_attempts: Generated<number>;
1037
+ resolved_at: Date | null;
1038
+ }
1039
+ type WebhookIncidentAlert = Selectable<WebhookIncidentAlertsTable>;
994
1040
  /** Accounts Sentinel's service key may touch: created by Sentinel, or the
995
1041
  * owner opted in. */
996
1042
  interface SentinelAccountsTable {
@@ -1253,4 +1299,4 @@ type WaitlistSignup = Selectable<WaitlistSignupsTable>;
1253
1299
  type InsertWaitlistSignup = Insertable<WaitlistSignupsTable>;
1254
1300
  type ContactRequest = Selectable<ContactRequestsTable>;
1255
1301
  type InsertContactRequest = Insertable<ContactRequestsTable>;
1256
- export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ApiRequestLogRow, ApiRequestLogTable, ArchiveFetch, ArchiveFetchesTable, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, ChainReadCacheTable, ChainReorgsTable, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, Database, DeadLetterEventsTable, DecodedEventsTable, DecoderCheckpointsTable, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertApiRequestLogRow, InsertArchiveFetch, InsertBlock, InsertContactRequest, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, NativeClock, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RepairMode, RetryState, RunStatus, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, Subgraph, SubgraphErrorGroupsTable, SubgraphGap, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UsageLedgerRow, UsageLedgerTable, VmEvent, VmEventsArchiveTable, VmEventsTable, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookFormat, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookStatus, WebhooksTable };
1302
+ export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ApiRequestLogRow, ApiRequestLogTable, ArchiveFetch, ArchiveFetchesTable, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, ChainReadCacheTable, ChainReorgsTable, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, Database, DeadLetterEventsTable, DecodedEventsTable, DecoderCheckpointsTable, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertApiRequestLogRow, InsertArchiveFetch, InsertBlock, InsertContactRequest, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InsightMutesTable, InsightsTable, InstancesTable, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, NativeClock, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RepairMode, RetryState, RunStatus, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, Subgraph, SubgraphErrorGroupsTable, SubgraphGap, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UsageLedgerRow, UsageLedgerTable, VmEvent, VmEventsArchiveTable, VmEventsTable, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookFormat, WebhookIncidentAlert, WebhookIncidentAlertsTable, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookStatus, WebhooksTable };
@@ -597,6 +597,35 @@ interface SubgraphErrorGroupsTable {
597
597
  first_seen: Generated<Date>;
598
598
  last_seen: Generated<Date>;
599
599
  }
600
+ /**
601
+ * One ranked dashboard insight. `account_id` is NULL on tenant and self-host
602
+ * databases. `severity` is never "recovered": that is derived on read from
603
+ * `resolved_at`.
604
+ */
605
+ interface InsightsTable {
606
+ id: Generated<string>;
607
+ account_id: string | null;
608
+ resource_kind: string;
609
+ resource_id: string;
610
+ rule: string;
611
+ severity: string;
612
+ impact: Generated<number>;
613
+ /** resource, line, meta, lead, body, evidence, handoff, how. */
614
+ payload: unknown;
615
+ first_seen_at: Generated<Date>;
616
+ last_seen_at: Generated<Date>;
617
+ clear_streak: Generated<number>;
618
+ resolved_at: Date | null;
619
+ dismissed_at: Date | null;
620
+ }
621
+ /** "Expected": mutes one rule for one resource until removed. */
622
+ interface InsightMutesTable {
623
+ account_id: string | null;
624
+ resource_kind: string;
625
+ resource_id: string;
626
+ rule: string;
627
+ created_at: Generated<Date>;
628
+ }
600
629
  interface ProcessedStripeEventsTable {
601
630
  event_id: string;
602
631
  event_type: string;
@@ -1112,12 +1141,15 @@ interface Database {
1112
1141
  archive_fetches: ArchiveFetchesTable;
1113
1142
  usage_ledger: UsageLedgerTable;
1114
1143
  account_balance_alerts: AccountBalanceAlertsTable;
1144
+ webhook_incident_alerts: WebhookIncidentAlertsTable;
1115
1145
  sentinel_accounts: SentinelAccountsTable;
1116
1146
  waitlists: WaitlistsTable;
1117
1147
  waitlist_signups: WaitlistSignupsTable;
1118
1148
  contact_requests: ContactRequestsTable;
1119
1149
  api_failed_requests: ApiFailedRequestsTable;
1120
1150
  api_request_log: ApiRequestLogTable;
1151
+ insights: InsightsTable;
1152
+ insight_mutes: InsightMutesTable;
1121
1153
  feedback_tickets: FeedbackTicketsTable;
1122
1154
  }
1123
1155
  interface ServiceHeartbeatsTable {
@@ -1210,6 +1242,20 @@ interface AccountBalanceAlertsTable {
1210
1242
  sent_2d_at: Date | null;
1211
1243
  sent_stopped_at: Date | null;
1212
1244
  }
1245
+ /** Debounce state for the webhook-down email: one row per incident, open
1246
+ * while `resolved_at` is null. No preference columns by design. */
1247
+ interface WebhookIncidentAlertsTable {
1248
+ id: Generated<string>;
1249
+ account_id: string;
1250
+ webhook_id: string;
1251
+ webhook_name: string;
1252
+ failing_since: Date;
1253
+ opened_at: Generated<Date>;
1254
+ emailed_at: Date | null;
1255
+ email_attempts: Generated<number>;
1256
+ resolved_at: Date | null;
1257
+ }
1258
+ type WebhookIncidentAlert = Selectable<WebhookIncidentAlertsTable>;
1213
1259
  /** Accounts Sentinel's service key may touch: created by Sentinel, or the
1214
1260
  * owner opted in. */
1215
1261
  interface SentinelAccountsTable {
@@ -2500,12 +2546,15 @@ declare const TABLE_TO_DB: {
2500
2546
  archive_fetches: string
2501
2547
  usage_ledger: string
2502
2548
  account_balance_alerts: string
2549
+ webhook_incident_alerts: string
2503
2550
  sentinel_accounts: string
2504
2551
  waitlists: string
2505
2552
  waitlist_signups: string
2506
2553
  contact_requests: string
2507
2554
  api_failed_requests: string
2508
2555
  api_request_log: string
2556
+ insights: string
2557
+ insight_mutes: string
2509
2558
  feedback_tickets: string
2510
2559
  service_heartbeats: string
2511
2560
  };
@@ -2753,10 +2802,98 @@ declare class Logger {
2753
2802
  }
2754
2803
  declare const logger: Logger;
2755
2804
  import { z as z3 } from "zod";
2805
+ /**
2806
+ * The insight contract. The tenant (`/api/insights`) and platform
2807
+ * (`/api/accounts/insights`) routes serve `Insight` verbatim. The web app keeps
2808
+ * a field-for-field copy in `apps/web/src/lib/insights.ts`; change both
2809
+ * together.
2810
+ *
2811
+ * The types are written out and the schemas annotated with them, rather than
2812
+ * inferred: the bundled `.d.ts` loses inferred zod types (they come out as
2813
+ * `unknown`), the same reason `schemas/webhooks.ts` annotates its schemas.
2814
+ */
2815
+ declare const INSIGHT_SEVERITIES: readonly ["losing", "will_fail", "costs", "recovered"];
2816
+ type InsightSeverity = (typeof INSIGHT_SEVERITIES)[number];
2817
+ type InsightResourceKind = "webhook" | "subgraph" | "account";
2818
+ type InsightEvidence = {
2819
+ kind: "series"
2820
+ title: string
2821
+ series: {
2822
+ name: string
2823
+ role: "a" | "context" | "mark"
2824
+ points: number[]
2825
+ }[]
2826
+ labels: [number, string][]
2827
+ unit?: string
2828
+ } | {
2829
+ kind: "table"
2830
+ title: string
2831
+ columns: string[]
2832
+ rows: (string | number)[][]
2833
+ markRow?: number
2834
+ } | {
2835
+ kind: "shapes"
2836
+ title: string
2837
+ shapes: {
2838
+ code: string
2839
+ body: string
2840
+ count: number
2841
+ isNew: boolean
2842
+ }[]
2843
+ } | {
2844
+ kind: "timeline"
2845
+ title: string
2846
+ steps: {
2847
+ what: string
2848
+ at: string
2849
+ note?: string
2850
+ failed: boolean
2851
+ }[]
2852
+ };
2853
+ interface Insight {
2854
+ id: string;
2855
+ rule: string;
2856
+ severity: InsightSeverity;
2857
+ impact: number;
2858
+ resource: {
2859
+ kind: InsightResourceKind
2860
+ id: string
2861
+ name: string
2862
+ };
2863
+ line: string;
2864
+ meta?: string;
2865
+ lead: string;
2866
+ body: string;
2867
+ evidence: InsightEvidence[];
2868
+ handoff: {
2869
+ prompt: string
2870
+ commands: string[]
2871
+ };
2872
+ how: {
2873
+ detector: string
2874
+ facts: [string, string][]
2875
+ label?: {
2876
+ cause: string
2877
+ confidence: number
2878
+ }
2879
+ };
2880
+ createdAt: string;
2881
+ resolvedAt?: string | null;
2882
+ }
2883
+ interface InsightListResponse {
2884
+ data: Insight[];
2885
+ }
2886
+ declare const InsightSeveritySchema: z3.ZodType<InsightSeverity>;
2887
+ declare const InsightResourceKindSchema: z3.ZodType<InsightResourceKind>;
2888
+ declare const InsightEvidenceSchema: z3.ZodType<InsightEvidence>;
2889
+ declare const InsightSchema: z3.ZodType<Insight>;
2890
+ declare const InsightListResponseSchema: z3.ZodType<InsightListResponse>;
2891
+ declare const SEVERITY_ORDER: Record<InsightSeverity, number>;
2892
+ import { z as z4 } from "zod";
2756
2893
  declare const WEBHOOK_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
2757
2894
  declare const WEBHOOK_STATUSES: readonly ["active", "paused", "error"];
2758
- declare const WebhookStatusSchema: z3.ZodType<WebhookStatus2>;
2759
- declare const WebhookFormatSchema: z3.ZodType<WebhookFormat2>;
2895
+ declare const WebhookStatusSchema: z4.ZodType<WebhookStatus2>;
2896
+ declare const WebhookFormatSchema: z4.ZodType<WebhookFormat2>;
2760
2897
  declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "contract_call", "contract_deploy", "print_event", "nested_contract_call", "var_set", "map_set", "map_insert", "map_delete", "sbtc_deposit", "sbtc_withdrawal_create", "sbtc_withdrawal_accept", "sbtc_withdrawal_reject", "sbtc_withdrawal_swept_confirmed", "rune_etch", "rune_mint", "rune_transfer", "rune_burn"];
2761
2898
  /**
2762
2899
  * Per-type accepted filter fields for chain triggers, DERIVED from
@@ -2764,9 +2901,9 @@ declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_bu
2764
2901
  * the validator. `{ stx_transfer: ["sender","recipient","minAmount","maxAmount"], ... }`.
2765
2902
  */
2766
2903
  declare const CHAIN_TRIGGER_FIELDS: Record<string, string[]>;
2767
- declare const CreateWebhookRequestSchema: z3.ZodType<ParsedCreateWebhookRequest>;
2768
- declare const UpdateWebhookRequestSchema: z3.ZodType<UpdateWebhookRequest>;
2769
- declare const ReplayWebhookRequestSchema: z3.ZodType<ReplayWebhookRequest>;
2904
+ declare const CreateWebhookRequestSchema: z4.ZodType<ParsedCreateWebhookRequest>;
2905
+ declare const UpdateWebhookRequestSchema: z4.ZodType<UpdateWebhookRequest>;
2906
+ declare const ReplayWebhookRequestSchema: z4.ZodType<ReplayWebhookRequest>;
2770
2907
  type WebhookStatus2 = (typeof WEBHOOK_STATUSES)[number];
2771
2908
  /** Webhook kind (mirrors db/types `WebhookKind`). Chain events only. */
2772
2909
  type WebhookKind2 = "chain";
@@ -3040,7 +3177,7 @@ interface DeadRow {
3040
3177
  failedAt: string | null;
3041
3178
  createdAt: string;
3042
3179
  }
3043
- declare function formatWebhookSchemaErrors(error: z3.ZodError): string[];
3180
+ declare function formatWebhookSchemaErrors(error: z4.ZodError): string[];
3044
3181
  type SubgraphSpecFormat = "openapi" | "agent" | "markdown";
3045
3182
  /** Options for generating a subgraph's agent schema. */
3046
3183
  interface SubgraphSpecOptions {
@@ -3497,4 +3634,4 @@ declare function publicKeyPemFromPrivate(privateKeyPem: string): string;
3497
3634
  declare function ed25519KeyId(publicKeyPem: string): string;
3498
3635
  declare function signEd25519(payload: string, privateKey: KeyObject): string;
3499
3636
  declare function verifyEd25519(payload: string, signatureBase64: string, publicKey: KeyObject): boolean;
3500
- export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ApiRequestLogRow, ApiRequestLogTable, ArchiveFetch, ArchiveFetchesTable, AuthenticationError, AuthorizationError, BILLING_PAUSED_PREFIX, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, CHAIN_TRIGGER_FIELDS, CHAIN_TRIGGER_TYPES, CODE_TO_STATUS, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReadCacheTable, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainReorgsTable, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery, ChainWebhookEnvelope, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, CreateWebhookRequest, CreateWebhookRequestSchema, CreateWebhookResponse, DB_TO_STREAMS_EVENT_TYPE, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DEFAULT_BTC_CONFIRMATIONS, Database, DatabaseError, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DeadRow, DecodedEventType2 as DecodedEventType, DecodedEventsTable, DecoderCheckpointsTable, DeliveryRow, DeploySubgraphRequest, DeploySubgraphRequestSchema, DeploySubgraphResponse, EMPTY_RANGE_EVENT_INDEX_SENTINEL, Env, ErrorCode, ErrorCodes, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, ForbiddenError, HealthHour, HealthSnapshotPoint, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertApiRequestLogRow, InsertArchiveFetch, InsertBlock, InsertContactRequest, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, KeyRotatedError, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NotFoundError, NumericAsText, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, ParsedCreateWebhookRequest, ParsedReplayWebhookRequest, ParsedUpdateWebhookRequest, PaymentRequiredError, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RUNE_EVENT_TYPES, RateLimitError, ReindexResponse, RepairMode, ReplayResult, ReplayWebhookRequest, ReplayWebhookRequestSchema, RetryState, RotateSecretResponse, RunStatus, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneEventType, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, STREAMS_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_TO_DB_EVENT_TYPES, SbtcDepositEvent, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent, SecondLayerError, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, StreamsCursor, StreamsDbEventType, StreamsEventType, Subgraph, SubgraphAgentSchema, SubgraphAggregateParams, SubgraphAggregateResponse, SubgraphDetail, SubgraphErrorGroupsTable, SubgraphGap, SubgraphGapEntry, SubgraphGapRange, SubgraphGapsResponse, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphQueryParams, SubgraphSpecFormat, SubgraphSpecOptions, SubgraphSummary, SubgraphSyncInfo, SubgraphVerification, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, TenantSuspendedError, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UpdateWebhookRequest, UpdateWebhookRequestSchema, UsageLedgerRow, UsageLedgerTable, VM_EVENT_TYPES, VM_NODE_TO_STORED_TYPE2 as VM_NODE_TO_STORED_TYPE, VM_STORED_TO_NODE_TYPE, ValidationError, VersionConflictError, VmEvent, VmEventType, VmEventsArchiveTable, VmEventsTable, VmNodeEventType, WEBHOOK_FORMATS, WEBHOOK_STATUSES, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookDetail, WebhookFormat, WebhookFormatSchema, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookStatus, WebhookStatusSchema, WebhookSummary, WebhooksTable, applicationDatabaseUrl, assertDbSplit, billingPausedCode, blockEndCursor, bucketHourly, closeDb, closeDbOrTimeout, committedHeight, compareStreamsCursor, exports_hmac as crypto, decodeStreamsCursor, describeDbUrl, exports_ed25519 as ed25519, encodeStreamsCursor, finalizedBurnHeight, formatWebhookSchemaErrors, generateSubgraphAgentSchema, generateSubgraphMarkdown, generateSubgraphOpenApi, generateSubgraphSpec, getDb, getDbSplitStatus, getEnv, getErrorMessage, getMigrationRole, getRawClient, getSourceDb, getTargetDb, isBnsDecoderEnabled, isEmptyRangeCursor, isPox4DecoderEnabled, isPox5DecoderEnabled, isSbtcDecoderEnabled, jsonb, logger, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql };
3637
+ export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ApiRequestLogRow, ApiRequestLogTable, ArchiveFetch, ArchiveFetchesTable, AuthenticationError, AuthorizationError, BILLING_PAUSED_PREFIX, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, CHAIN_TRIGGER_FIELDS, CHAIN_TRIGGER_TYPES, CODE_TO_STATUS, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReadCacheTable, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainReorgsTable, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery, ChainWebhookEnvelope, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, CreateWebhookRequest, CreateWebhookRequestSchema, CreateWebhookResponse, DB_TO_STREAMS_EVENT_TYPE, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DEFAULT_BTC_CONFIRMATIONS, Database, DatabaseError, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DeadRow, DecodedEventType2 as DecodedEventType, DecodedEventsTable, DecoderCheckpointsTable, DeliveryRow, DeploySubgraphRequest, DeploySubgraphRequestSchema, DeploySubgraphResponse, EMPTY_RANGE_EVENT_INDEX_SENTINEL, Env, ErrorCode, ErrorCodes, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, ForbiddenError, HealthHour, HealthSnapshotPoint, INSIGHT_SEVERITIES, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertApiRequestLogRow, InsertArchiveFetch, InsertBlock, InsertContactRequest, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, Insight, InsightEvidence, InsightEvidenceSchema, InsightListResponse, InsightListResponseSchema, InsightMutesTable, InsightResourceKind, InsightResourceKindSchema, InsightSchema, InsightSeverity, InsightSeveritySchema, InsightsTable, InstancesTable, KeyRotatedError, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NotFoundError, NumericAsText, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, ParsedCreateWebhookRequest, ParsedReplayWebhookRequest, ParsedUpdateWebhookRequest, PaymentRequiredError, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RUNE_EVENT_TYPES, RateLimitError, ReindexResponse, RepairMode, ReplayResult, ReplayWebhookRequest, ReplayWebhookRequestSchema, RetryState, RotateSecretResponse, RunStatus, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneEventType, SEVERITY_ORDER, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, STREAMS_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_TO_DB_EVENT_TYPES, SbtcDepositEvent, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent, SecondLayerError, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, StreamsCursor, StreamsDbEventType, StreamsEventType, Subgraph, SubgraphAgentSchema, SubgraphAggregateParams, SubgraphAggregateResponse, SubgraphDetail, SubgraphErrorGroupsTable, SubgraphGap, SubgraphGapEntry, SubgraphGapRange, SubgraphGapsResponse, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphQueryParams, SubgraphSpecFormat, SubgraphSpecOptions, SubgraphSummary, SubgraphSyncInfo, SubgraphVerification, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, TenantSuspendedError, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UpdateWebhookRequest, UpdateWebhookRequestSchema, UsageLedgerRow, UsageLedgerTable, VM_EVENT_TYPES, VM_NODE_TO_STORED_TYPE2 as VM_NODE_TO_STORED_TYPE, VM_STORED_TO_NODE_TYPE, ValidationError, VersionConflictError, VmEvent, VmEventType, VmEventsArchiveTable, VmEventsTable, VmNodeEventType, WEBHOOK_FORMATS, WEBHOOK_STATUSES, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookDetail, WebhookFormat, WebhookFormatSchema, WebhookIncidentAlert, WebhookIncidentAlertsTable, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookStatus, WebhookStatusSchema, WebhookSummary, WebhooksTable, applicationDatabaseUrl, assertDbSplit, billingPausedCode, blockEndCursor, bucketHourly, closeDb, closeDbOrTimeout, committedHeight, compareStreamsCursor, exports_hmac as crypto, decodeStreamsCursor, describeDbUrl, exports_ed25519 as ed25519, encodeStreamsCursor, finalizedBurnHeight, formatWebhookSchemaErrors, generateSubgraphAgentSchema, generateSubgraphMarkdown, generateSubgraphOpenApi, generateSubgraphSpec, getDb, getDbSplitStatus, getEnv, getErrorMessage, getMigrationRole, getRawClient, getSourceDb, getTargetDb, isBnsDecoderEnabled, isEmptyRangeCursor, isPox4DecoderEnabled, isPox5DecoderEnabled, isSbtcDecoderEnabled, jsonb, logger, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql };