@kb-labs/studio-data-client 0.2.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.
@@ -0,0 +1,2755 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import * as _kb_labs_rest_api_contracts from '@kb-labs/rest-api-contracts';
3
+ import { ErrorEnvelope, ReadyResponse, NotReadyResponse, SystemInfoPayload, SystemCapabilitiesPayload, SystemConfigPayload, PlatformConfigPayload } from '@kb-labs/rest-api-contracts';
4
+ import { ServiceObservabilityHealth } from '@kb-labs/core-contracts';
5
+ import * as _kb_labs_core_platform_adapters from '@kb-labs/core-platform/adapters';
6
+ import { EventsQuery, EventsResponse, EventsStats, BufferStatus, DlqStatus } from '@kb-labs/core-platform/adapters';
7
+ export { AnalyticsEvent, BufferStatus, DlqStatus, EventsQuery, EventsResponse, EventsStats } from '@kb-labs/core-platform/adapters';
8
+ import { z } from 'zod';
9
+ import { ManifestV3 } from '@kb-labs/plugin-contracts';
10
+ import * as _tanstack_react_query from '@tanstack/react-query';
11
+
12
+ declare class KBError extends Error {
13
+ code: string;
14
+ message: string;
15
+ status?: number | undefined;
16
+ cause?: unknown | undefined;
17
+ constructor(code: string, message: string, status?: number | undefined, cause?: unknown | undefined);
18
+ }
19
+ declare const errorCodes: {
20
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
21
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
22
+ readonly AUTH_ERROR: "AUTH_ERROR";
23
+ readonly NOT_FOUND: "NOT_FOUND";
24
+ readonly SERVER_ERROR: "SERVER_ERROR";
25
+ readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
26
+ readonly TIMEOUT: "TIMEOUT";
27
+ readonly CONFLICT: "CONFLICT";
28
+ readonly RATE_LIMIT: "RATE_LIMIT";
29
+ readonly TOOL_ERROR: "TOOL_ERROR";
30
+ };
31
+
32
+ interface FetchOptions extends RequestInit {
33
+ timeout?: number;
34
+ }
35
+ interface ResponseError {
36
+ status: number;
37
+ statusText: string;
38
+ data?: unknown;
39
+ }
40
+ interface RequestInterceptor {
41
+ (config: FetchOptions): FetchOptions | Promise<FetchOptions>;
42
+ }
43
+ interface ResponseInterceptor {
44
+ (response: Response): Response | Promise<Response>;
45
+ }
46
+ interface ErrorInterceptor {
47
+ (error: KBError): KBError | Promise<KBError>;
48
+ }
49
+
50
+ declare class HttpClient {
51
+ private client;
52
+ private requestInterceptors;
53
+ private responseInterceptors;
54
+ private errorInterceptors;
55
+ private baseUrl;
56
+ constructor(baseUrl?: string, token?: string);
57
+ addRequestInterceptor(interceptor: RequestInterceptor): void;
58
+ addResponseInterceptor(interceptor: ResponseInterceptor): void;
59
+ addErrorInterceptor(interceptor: ErrorInterceptor): void;
60
+ getBaseUrl(): string;
61
+ fetch<T>(path: string, options?: AxiosRequestConfig): Promise<T>;
62
+ private processError;
63
+ }
64
+
65
+ declare function mapFetchError(error: unknown, response?: Response): KBError;
66
+ /**
67
+ * Map error envelope to KBError
68
+ */
69
+ declare function mapErrorEnvelope(envelope: ErrorEnvelope): KBError;
70
+
71
+ /**
72
+ * @module @kb-labs/studio-data-client/client/envelope-interceptor
73
+ * Envelope interceptor for automatic unwrap of API responses
74
+ */
75
+
76
+ /**
77
+ * Create envelope unwrap interceptor
78
+ * Automatically unwraps { ok: true, data: T } to T
79
+ */
80
+ declare function createEnvelopeInterceptor(): ResponseInterceptor;
81
+ /**
82
+ * Extract envelope metadata from response
83
+ */
84
+ declare function extractEnvelopeMeta(response: Response): {
85
+ requestId?: string;
86
+ apiVersion?: string;
87
+ durationMs?: number;
88
+ } | null;
89
+
90
+ declare const SCHEMA_VERSION = "1.0";
91
+ type ID = string;
92
+ type ISODate = string;
93
+ interface PackageRef {
94
+ name: string;
95
+ version?: string;
96
+ private?: boolean;
97
+ path?: string;
98
+ }
99
+ interface RunRef {
100
+ id: ID;
101
+ startedAt: ISODate;
102
+ endedAt?: ISODate;
103
+ status: 'pending' | 'ok' | 'warn' | 'fail';
104
+ }
105
+ interface ActionResult {
106
+ ok: boolean;
107
+ message?: string;
108
+ runId?: ID;
109
+ }
110
+
111
+ interface HealthStatus {
112
+ ok: boolean;
113
+ timestamp: ISODate;
114
+ sources: Array<{
115
+ name: string;
116
+ ok: boolean;
117
+ latency?: number;
118
+ error?: string;
119
+ }>;
120
+ snapshot?: ServiceObservabilityHealth;
121
+ }
122
+
123
+ type WorkflowStatus = 'queued' | 'running' | 'success' | 'failed' | 'cancelled' | 'skipped' | 'waiting_approval';
124
+ interface StepRun {
125
+ id: string;
126
+ jobId: string;
127
+ name: string;
128
+ status: WorkflowStatus;
129
+ queuedAt: string;
130
+ startedAt?: string;
131
+ finishedAt?: string;
132
+ durationMs?: number;
133
+ command?: string;
134
+ inputs?: Record<string, unknown>;
135
+ outputs?: Record<string, unknown>;
136
+ error?: Record<string, unknown> | null;
137
+ spec?: {
138
+ name: string;
139
+ uses?: string;
140
+ with?: Record<string, unknown>;
141
+ };
142
+ }
143
+ interface JobRun {
144
+ id: string;
145
+ runId: string;
146
+ jobName: string;
147
+ status: WorkflowStatus;
148
+ runsOn: 'local' | 'sandbox';
149
+ queuedAt: string;
150
+ startedAt?: string;
151
+ finishedAt?: string;
152
+ durationMs?: number;
153
+ concurrency?: Record<string, unknown>;
154
+ retries?: Record<string, unknown>;
155
+ timeoutMs?: number;
156
+ artifacts: Record<string, unknown>;
157
+ steps: StepRun[];
158
+ error?: Record<string, unknown> | null;
159
+ }
160
+ interface WorkflowTrigger {
161
+ type: 'manual' | 'webhook' | 'push' | 'schedule';
162
+ actor?: string;
163
+ payload?: Record<string, unknown>;
164
+ }
165
+ interface WorkflowRun {
166
+ id: string;
167
+ name: string;
168
+ version: string;
169
+ status: WorkflowStatus;
170
+ createdAt: string;
171
+ queuedAt: string;
172
+ startedAt?: string;
173
+ finishedAt?: string;
174
+ durationMs?: number;
175
+ trigger: WorkflowTrigger;
176
+ jobs: JobRun[];
177
+ artifacts?: string[];
178
+ metadata?: Record<string, unknown>;
179
+ result?: WorkflowExecutionResult;
180
+ }
181
+ interface WorkflowSpec {
182
+ name: string;
183
+ version: string;
184
+ on?: Record<string, unknown>;
185
+ jobs: Record<string, unknown>;
186
+ }
187
+ interface WorkflowRunsListResponse {
188
+ runs: WorkflowRun[];
189
+ total: number;
190
+ }
191
+ interface WorkflowRunResponse {
192
+ run: WorkflowRun;
193
+ }
194
+ interface WorkflowLogEvent {
195
+ type: string;
196
+ runId: string;
197
+ jobId?: string;
198
+ stepId?: string;
199
+ payload?: Record<string, unknown>;
200
+ timestamp?: string;
201
+ }
202
+ interface WorkflowResultMetrics {
203
+ timeMs?: number;
204
+ cpuMs?: number;
205
+ memMb?: number;
206
+ jobsTotal?: number;
207
+ jobsSucceeded?: number;
208
+ jobsFailed?: number;
209
+ jobsCancelled?: number;
210
+ stepsTotal?: number;
211
+ stepsFailed?: number;
212
+ stepsCancelled?: number;
213
+ }
214
+ interface WorkflowResultError {
215
+ message: string;
216
+ code?: string;
217
+ details?: Record<string, unknown>;
218
+ }
219
+ interface WorkflowExecutionResult {
220
+ status: WorkflowStatus;
221
+ summary?: string;
222
+ startedAt?: string;
223
+ completedAt?: string;
224
+ metrics?: WorkflowResultMetrics;
225
+ details?: Record<string, unknown>;
226
+ outputs?: Record<string, unknown>;
227
+ error?: WorkflowResultError;
228
+ }
229
+ interface WorkflowPresenterEvent {
230
+ id: string;
231
+ type: string;
232
+ version: string;
233
+ timestamp: string;
234
+ payload?: unknown;
235
+ meta?: Record<string, unknown>;
236
+ }
237
+
238
+ /**
239
+ * @module @kb-labs/studio-data-client/contracts/observability
240
+ * Observability contracts for Studio
241
+ */
242
+ /**
243
+ * State Broker statistics
244
+ */
245
+ interface StateBrokerStats {
246
+ /** Daemon uptime in milliseconds */
247
+ uptime: number;
248
+ /** Total number of cache entries */
249
+ totalEntries: number;
250
+ /** Total cache size in bytes */
251
+ totalSize: number;
252
+ /** Cache hit rate (0-1) */
253
+ hitRate: number;
254
+ /** Cache miss rate (0-1) */
255
+ missRate: number;
256
+ /** Number of evicted entries */
257
+ evictions: number;
258
+ /** Stats per namespace */
259
+ namespaces: Record<string, NamespaceStats>;
260
+ }
261
+ /**
262
+ * Namespace-level statistics
263
+ */
264
+ interface NamespaceStats {
265
+ /** Number of entries */
266
+ entries: number;
267
+ /** Cache hits */
268
+ hits: number;
269
+ /** Cache misses */
270
+ misses: number;
271
+ /** Size in bytes */
272
+ size: number;
273
+ }
274
+ /**
275
+ * DevKit health snapshot
276
+ */
277
+ interface DevKitHealth {
278
+ /** Health score (0-100) */
279
+ healthScore: number;
280
+ /** Letter grade (A-F) */
281
+ grade: 'A' | 'B' | 'C' | 'D' | 'F';
282
+ /** Issues breakdown */
283
+ issues: {
284
+ duplicateDeps?: number;
285
+ missingReadmes?: number;
286
+ typeErrors?: number;
287
+ brokenImports?: number;
288
+ unusedExports?: number;
289
+ [key: string]: number | undefined;
290
+ };
291
+ /** Total packages */
292
+ packages: number;
293
+ /** Average type coverage percentage */
294
+ avgTypeCoverage?: number;
295
+ }
296
+ /**
297
+ * Prometheus metrics from REST API
298
+ */
299
+ interface PrometheusMetrics {
300
+ /** Request statistics */
301
+ requests: {
302
+ total: number;
303
+ success: number;
304
+ clientErrors: number;
305
+ serverErrors: number;
306
+ };
307
+ /** Latency statistics */
308
+ latency: {
309
+ average: number;
310
+ min: number;
311
+ max: number;
312
+ p50: number;
313
+ p95: number;
314
+ p99: number;
315
+ };
316
+ /** Per-plugin metrics */
317
+ perPlugin: Array<{
318
+ pluginId: string;
319
+ } & PluginMetrics>;
320
+ /** Per-tenant metrics */
321
+ perTenant: Array<{
322
+ tenantId: string;
323
+ } & TenantMetrics>;
324
+ /** Error breakdown */
325
+ errors: {
326
+ byStatusCode: Record<number, number>;
327
+ recent: Array<{
328
+ timestamp: number;
329
+ statusCode: number;
330
+ errorCode?: string;
331
+ message: string;
332
+ }>;
333
+ };
334
+ /** Timestamps */
335
+ timestamps: {
336
+ startTime: number;
337
+ lastRequest: number | null;
338
+ };
339
+ /** Redis statistics */
340
+ redis: {
341
+ updates: number;
342
+ healthyTransitions: number;
343
+ unhealthyTransitions: number;
344
+ lastStatus: {
345
+ healthy: boolean;
346
+ state: string;
347
+ role: string;
348
+ } | null;
349
+ };
350
+ /** Plugin mount snapshot */
351
+ pluginMounts: {
352
+ total: number;
353
+ succeeded: number;
354
+ failed: number;
355
+ elapsedMs: number;
356
+ } | null;
357
+ /** Uptime information */
358
+ uptime: {
359
+ seconds: number;
360
+ startTime: string;
361
+ lastRequest: string | null;
362
+ };
363
+ }
364
+ /**
365
+ * Plugin-level metrics
366
+ */
367
+ interface PluginMetrics {
368
+ requests: number;
369
+ errors: number;
370
+ latency: {
371
+ average: number;
372
+ min: number;
373
+ max: number;
374
+ };
375
+ }
376
+ /**
377
+ * Tenant-level metrics
378
+ */
379
+ interface TenantMetrics {
380
+ requests: number;
381
+ errors: number;
382
+ latency: {
383
+ average: number;
384
+ };
385
+ }
386
+ /**
387
+ * System event from /events/registry SSE stream
388
+ */
389
+ type SystemEvent = RegistryEvent | HealthEvent;
390
+ /**
391
+ * Registry snapshot event
392
+ */
393
+ interface RegistryEvent {
394
+ type: 'registry';
395
+ rev: string;
396
+ generatedAt: string;
397
+ partial: boolean;
398
+ stale: boolean;
399
+ expiresAt: string | null;
400
+ ttlMs: number | null;
401
+ checksum?: string;
402
+ checksumAlgorithm?: 'sha256';
403
+ previousChecksum: string | null;
404
+ }
405
+ /**
406
+ * Health status event
407
+ */
408
+ interface HealthEvent {
409
+ type: 'health';
410
+ status: 'healthy' | 'unhealthy';
411
+ ts: string;
412
+ ready: boolean;
413
+ reason: string | null;
414
+ registryPartial: boolean;
415
+ registryStale: boolean;
416
+ registryLoaded: boolean;
417
+ pluginMountInProgress: boolean;
418
+ pluginRoutesMounted: boolean;
419
+ pluginsMounted: number;
420
+ pluginsFailed: number;
421
+ lastPluginMountTs: string | null;
422
+ pluginRoutesLastDurationMs: number | null;
423
+ redisEnabled: boolean;
424
+ redisHealthy: boolean;
425
+ redisStates?: Array<{
426
+ role: string;
427
+ state: string;
428
+ }>;
429
+ }
430
+ /**
431
+ * Log record (matches backend LogRecord interface)
432
+ */
433
+ interface LogRecord {
434
+ id?: string;
435
+ time: string;
436
+ level: 'trace' | 'debug' | 'info' | 'warn' | 'error';
437
+ msg?: string;
438
+ plugin?: string;
439
+ command?: string;
440
+ executionId?: string;
441
+ tenantId?: string;
442
+ trace?: string;
443
+ span?: string;
444
+ err?: {
445
+ name: string;
446
+ message: string;
447
+ stack?: string;
448
+ code?: string;
449
+ };
450
+ meta?: Record<string, unknown>;
451
+ [key: string]: unknown;
452
+ }
453
+ /**
454
+ * Log query filters
455
+ */
456
+ interface LogQuery {
457
+ from?: string;
458
+ to?: string;
459
+ level?: string;
460
+ plugin?: string;
461
+ executionId?: string;
462
+ tenantId?: string;
463
+ search?: string;
464
+ limit?: number;
465
+ offset?: number;
466
+ }
467
+ /**
468
+ * Log query response
469
+ */
470
+ interface LogQueryResponse {
471
+ ok: boolean;
472
+ data: {
473
+ logs: LogRecord[];
474
+ total: number;
475
+ filters: LogQuery;
476
+ bufferStats: {
477
+ size: number;
478
+ maxSize: number;
479
+ oldest?: string;
480
+ newest?: string;
481
+ };
482
+ };
483
+ }
484
+ /**
485
+ * Log event from /logs/stream SSE
486
+ */
487
+ interface LogEvent {
488
+ type: 'log';
489
+ time: string;
490
+ level: LogRecord['level'];
491
+ msg?: string;
492
+ plugin?: string;
493
+ executionId?: string;
494
+ tenantId?: string;
495
+ [key: string]: unknown;
496
+ }
497
+ /**
498
+ * Context options for AI summarization
499
+ */
500
+ interface LogSummarizeContext {
501
+ errors?: boolean;
502
+ warnings?: boolean;
503
+ info?: boolean;
504
+ metadata?: boolean;
505
+ stackTraces?: boolean;
506
+ }
507
+ /**
508
+ * Log summarization request
509
+ */
510
+ interface LogSummarizeRequest {
511
+ /** User's question about the logs */
512
+ question: string;
513
+ /** Context inclusion options */
514
+ includeContext?: LogSummarizeContext;
515
+ /** Time range filter */
516
+ timeRange?: {
517
+ from?: string;
518
+ to?: string;
519
+ };
520
+ /** Log filters */
521
+ filters?: {
522
+ level?: string;
523
+ plugin?: string;
524
+ traceId?: string;
525
+ executionId?: string;
526
+ };
527
+ /** Group logs by field */
528
+ groupBy?: 'trace' | 'execution' | 'plugin';
529
+ }
530
+ /**
531
+ * Log statistics for AI context
532
+ */
533
+ interface LogStats {
534
+ total: number;
535
+ byLevel: Record<string, number>;
536
+ byPlugin: Record<string, number>;
537
+ topErrors: Array<{
538
+ message: string;
539
+ count: number;
540
+ }>;
541
+ timeRange: {
542
+ from: string | null;
543
+ to: string | null;
544
+ };
545
+ }
546
+ /**
547
+ * Log summarization response
548
+ */
549
+ interface LogSummarizeResponse {
550
+ ok: boolean;
551
+ data: {
552
+ summary: {
553
+ question: string;
554
+ timeRange: {
555
+ from: string | null;
556
+ to: string | null;
557
+ };
558
+ total: number;
559
+ stats: LogStats;
560
+ groups: Record<string, any[]> | null;
561
+ };
562
+ /** AI-generated summary (null if LLM unavailable) */
563
+ aiSummary: string | null;
564
+ /** Info message if AI not available */
565
+ message?: string | null;
566
+ };
567
+ }
568
+ /**
569
+ * Historical data point for time-series metrics
570
+ */
571
+ interface HistoricalDataPoint {
572
+ /** Unix timestamp in milliseconds */
573
+ timestamp: number;
574
+ /** Metric value */
575
+ value: number;
576
+ }
577
+ /**
578
+ * Heatmap cell data (7 days × 24 hours)
579
+ */
580
+ interface HeatmapCell {
581
+ /** Day of week: 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' */
582
+ day: string;
583
+ /** Hour of day: 0-23 */
584
+ hour: number;
585
+ /** Aggregated metric value */
586
+ value: number;
587
+ }
588
+ /**
589
+ * Metrics history query options
590
+ */
591
+ interface MetricsHistoryQuery {
592
+ /** Metric type */
593
+ metric: 'requests' | 'errors' | 'latency' | 'uptime';
594
+ /** Time range */
595
+ range: '1m' | '5m' | '10m' | '30m' | '1h';
596
+ /** Aggregation interval (optional) */
597
+ interval?: '5s' | '1m' | '5m';
598
+ }
599
+ /**
600
+ * Metrics heatmap query options
601
+ */
602
+ interface MetricsHeatmapQuery {
603
+ /** Metric type */
604
+ metric: 'latency' | 'errors' | 'requests';
605
+ /** Number of days (optional, default: 7) */
606
+ days?: 7 | 14 | 30;
607
+ }
608
+ /**
609
+ * Incident severity levels
610
+ */
611
+ type IncidentSeverity = 'critical' | 'warning' | 'info';
612
+ /**
613
+ * Incident type categories
614
+ */
615
+ type IncidentType = 'error_rate' | 'latency_spike' | 'plugin_failure' | 'adapter_failure' | 'system_health' | 'custom';
616
+ /**
617
+ * Root cause analysis item
618
+ */
619
+ interface RootCauseItem {
620
+ /** Factor contributing to the incident */
621
+ factor: string;
622
+ /** Confidence level (0.0 - 1.0) */
623
+ confidence: number;
624
+ /** Evidence supporting this root cause */
625
+ evidence: string;
626
+ }
627
+ /**
628
+ * Related logs data collected during incident
629
+ */
630
+ interface RelatedLogsData {
631
+ errorCount: number;
632
+ warnCount: number;
633
+ timeRange: [number, number];
634
+ sampleErrors: string[];
635
+ topEndpoints?: Array<{
636
+ endpoint: string;
637
+ count: number;
638
+ sample: string;
639
+ }>;
640
+ }
641
+ /**
642
+ * Slow request details
643
+ */
644
+ interface SlowRequest {
645
+ endpoint: string;
646
+ method: string;
647
+ durationMs: number;
648
+ statusCode?: number;
649
+ }
650
+ /**
651
+ * Related metrics data (before/during comparison)
652
+ */
653
+ interface RelatedMetricsData {
654
+ before?: Record<string, number>;
655
+ during?: Record<string, number>;
656
+ topSlowest?: SlowRequest[];
657
+ affectedEndpoints?: string[];
658
+ }
659
+ /**
660
+ * Timeline event during incident
661
+ */
662
+ interface TimelineEvent {
663
+ timestamp: number;
664
+ event: string;
665
+ source: 'detector' | 'logs' | 'metrics' | 'manual';
666
+ }
667
+ /**
668
+ * Related data gathered during incident detection
669
+ */
670
+ interface RelatedData {
671
+ logs?: RelatedLogsData;
672
+ metrics?: RelatedMetricsData;
673
+ timeline?: TimelineEvent[];
674
+ }
675
+ /**
676
+ * AI-generated incident analysis
677
+ */
678
+ interface IncidentAnalysis {
679
+ summary: string;
680
+ rootCauses: RootCauseItem[];
681
+ patterns: string[];
682
+ recommendations: string[];
683
+ analyzedAt: number;
684
+ }
685
+ /**
686
+ * Incident record
687
+ */
688
+ interface Incident {
689
+ /** Unique incident identifier */
690
+ id: string;
691
+ /** Incident type */
692
+ type: IncidentType;
693
+ /** Severity level */
694
+ severity: IncidentSeverity;
695
+ /** Incident title/summary */
696
+ title: string;
697
+ /** Detailed description */
698
+ details: string;
699
+ /** Root cause analysis (optional) - array of contributing factors */
700
+ rootCause?: RootCauseItem[];
701
+ /** Affected services/plugins */
702
+ affectedServices?: string[];
703
+ /** Timestamp when incident occurred (Unix ms) */
704
+ timestamp: number;
705
+ /** Timestamp when incident was resolved (Unix ms) */
706
+ resolvedAt?: number;
707
+ /** Resolution notes */
708
+ resolutionNotes?: string;
709
+ /** Related metrics/logs */
710
+ metadata?: Record<string, unknown>;
711
+ /** Related data gathered during detection (NEW) */
712
+ relatedData?: RelatedData;
713
+ /** AI analysis results (NEW) */
714
+ aiAnalysis?: IncidentAnalysis;
715
+ /** When AI analysis was performed (NEW) */
716
+ aiAnalyzedAt?: number;
717
+ }
718
+ /**
719
+ * Incident query options
720
+ */
721
+ interface IncidentQuery {
722
+ /** Maximum number of incidents to return (default: 50) */
723
+ limit?: number;
724
+ /** Filter by severity */
725
+ severity?: IncidentSeverity | IncidentSeverity[];
726
+ /** Filter by type */
727
+ type?: IncidentType | IncidentType[];
728
+ /** Filter by time range (from timestamp) */
729
+ from?: number;
730
+ /** Filter by time range (to timestamp) */
731
+ to?: number;
732
+ /** Include resolved incidents (default: false) */
733
+ includeResolved?: boolean;
734
+ }
735
+ /**
736
+ * Incident create payload
737
+ */
738
+ interface IncidentCreatePayload {
739
+ type: IncidentType;
740
+ severity: IncidentSeverity;
741
+ title: string;
742
+ details: string;
743
+ rootCause?: RootCauseItem[];
744
+ affectedServices?: string[];
745
+ timestamp?: number;
746
+ metadata?: Record<string, unknown>;
747
+ relatedData?: RelatedData;
748
+ }
749
+ /**
750
+ * Incidents list response with summary stats
751
+ */
752
+ interface IncidentsListResponse {
753
+ ok: boolean;
754
+ data: {
755
+ incidents: Incident[];
756
+ summary: {
757
+ total: number;
758
+ unresolved: number;
759
+ bySeverity: {
760
+ critical: number;
761
+ warning: number;
762
+ info: number;
763
+ };
764
+ showing: number;
765
+ };
766
+ };
767
+ }
768
+ /**
769
+ * Incident detail response
770
+ */
771
+ interface IncidentDetailResponse {
772
+ ok: boolean;
773
+ data: Incident;
774
+ }
775
+ /**
776
+ * Incident analysis response
777
+ */
778
+ interface IncidentAnalysisResponse {
779
+ ok: boolean;
780
+ data: IncidentAnalysis & {
781
+ cached: boolean;
782
+ };
783
+ }
784
+ /**
785
+ * Incident resolve request
786
+ */
787
+ interface IncidentResolveRequest {
788
+ resolutionNotes?: string;
789
+ }
790
+
791
+ /**
792
+ * @module @kb-labs/studio-data-client/contracts/adapters
793
+ * Platform adapter analytics contracts
794
+ */
795
+ /**
796
+ * LLM usage statistics by model
797
+ */
798
+ interface LLMModelStats {
799
+ requests: number;
800
+ promptTokens: number;
801
+ completionTokens: number;
802
+ totalTokens: number;
803
+ cost: number;
804
+ costPer1KTokens: number;
805
+ tokensPerRequest: number;
806
+ errorRate: number;
807
+ avgDurationMs: number;
808
+ cacheReadTokens: number;
809
+ billableTokens: number;
810
+ cacheSavingsUsd: number;
811
+ }
812
+ /**
813
+ * LLM usage statistics response
814
+ */
815
+ interface LLMUsageStats {
816
+ totalRequests: number;
817
+ totalTokens: number;
818
+ totalCost: number;
819
+ totalCacheReadTokens: number;
820
+ totalBillableTokens: number;
821
+ totalCacheSavingsUsd: number;
822
+ byModel: Record<string, LLMModelStats>;
823
+ errors: number;
824
+ timeRange: {
825
+ from: string;
826
+ to: string;
827
+ };
828
+ }
829
+
830
+ /**
831
+ * @module @kb-labs/studio-data-client/contracts/adapters-embeddings
832
+ * Embeddings adapter analytics contracts
833
+ */
834
+ /**
835
+ * Embeddings usage statistics
836
+ */
837
+ interface EmbeddingsUsageStats {
838
+ totalRequests: number;
839
+ totalTextLength: number;
840
+ totalCost: number;
841
+ errors: number;
842
+ avgDurationMs: number;
843
+ batchRequests: number;
844
+ singleRequests: number;
845
+ avgBatchSize: number;
846
+ }
847
+
848
+ /**
849
+ * @module @kb-labs/studio-data-client/contracts/adapters-vectorstore
850
+ * VectorStore adapter analytics contracts
851
+ */
852
+ /**
853
+ * VectorStore usage statistics
854
+ */
855
+ interface VectorStoreUsageStats {
856
+ searchQueries: number;
857
+ upsertOperations: number;
858
+ deleteOperations: number;
859
+ avgSearchDuration: number;
860
+ avgSearchScore: number;
861
+ avgResultsCount: number;
862
+ totalVectorsUpserted: number;
863
+ totalVectorsDeleted: number;
864
+ }
865
+
866
+ /**
867
+ * @module @kb-labs/studio-data-client/contracts/adapters-cache
868
+ * Cache adapter analytics contracts
869
+ */
870
+ /**
871
+ * Cache usage statistics
872
+ */
873
+ interface CacheUsageStats {
874
+ totalGets: number;
875
+ hits: number;
876
+ misses: number;
877
+ hitRate: number;
878
+ sets: number;
879
+ avgGetDuration: number;
880
+ avgSetDuration: number;
881
+ }
882
+
883
+ /**
884
+ * @module @kb-labs/studio-data-client/contracts/adapters-storage
885
+ * Storage adapter analytics contracts
886
+ */
887
+ /**
888
+ * Storage usage statistics
889
+ */
890
+ interface StorageUsageStats {
891
+ readOperations: number;
892
+ writeOperations: number;
893
+ deleteOperations: number;
894
+ totalBytesRead: number;
895
+ totalBytesWritten: number;
896
+ avgReadDuration: number;
897
+ avgWriteDuration: number;
898
+ }
899
+
900
+ declare const idSchema: z.ZodString;
901
+ declare const isoDateSchema: z.ZodString;
902
+ declare const packageRefSchema: z.ZodObject<{
903
+ name: z.ZodString;
904
+ version: z.ZodOptional<z.ZodString>;
905
+ private: z.ZodOptional<z.ZodBoolean>;
906
+ path: z.ZodOptional<z.ZodString>;
907
+ }, "strip", z.ZodTypeAny, {
908
+ name: string;
909
+ version?: string | undefined;
910
+ private?: boolean | undefined;
911
+ path?: string | undefined;
912
+ }, {
913
+ name: string;
914
+ version?: string | undefined;
915
+ private?: boolean | undefined;
916
+ path?: string | undefined;
917
+ }>;
918
+ declare const runRefSchema: z.ZodObject<{
919
+ id: z.ZodString;
920
+ startedAt: z.ZodString;
921
+ endedAt: z.ZodOptional<z.ZodString>;
922
+ status: z.ZodEnum<["pending", "ok", "warn", "fail"]>;
923
+ }, "strip", z.ZodTypeAny, {
924
+ status: "ok" | "pending" | "warn" | "fail";
925
+ id: string;
926
+ startedAt: string;
927
+ endedAt?: string | undefined;
928
+ }, {
929
+ status: "ok" | "pending" | "warn" | "fail";
930
+ id: string;
931
+ startedAt: string;
932
+ endedAt?: string | undefined;
933
+ }>;
934
+ declare const actionResultSchema: z.ZodObject<{
935
+ ok: z.ZodBoolean;
936
+ message: z.ZodOptional<z.ZodString>;
937
+ runId: z.ZodOptional<z.ZodString>;
938
+ }, "strip", z.ZodTypeAny, {
939
+ ok: boolean;
940
+ message?: string | undefined;
941
+ runId?: string | undefined;
942
+ }, {
943
+ ok: boolean;
944
+ message?: string | undefined;
945
+ runId?: string | undefined;
946
+ }>;
947
+
948
+ declare const auditSummarySchema: z.ZodObject<{
949
+ ts: z.ZodString;
950
+ totals: z.ZodObject<{
951
+ packages: z.ZodNumber;
952
+ ok: z.ZodNumber;
953
+ warn: z.ZodNumber;
954
+ fail: z.ZodNumber;
955
+ durationMs: z.ZodNumber;
956
+ }, "strip", z.ZodTypeAny, {
957
+ ok: number;
958
+ warn: number;
959
+ fail: number;
960
+ packages: number;
961
+ durationMs: number;
962
+ }, {
963
+ ok: number;
964
+ warn: number;
965
+ fail: number;
966
+ packages: number;
967
+ durationMs: number;
968
+ }>;
969
+ topFailures: z.ZodArray<z.ZodObject<{
970
+ pkg: z.ZodString;
971
+ checks: z.ZodArray<z.ZodEnum<["style", "types", "tests", "build", "devlink", "mind"]>, "many">;
972
+ }, "strip", z.ZodTypeAny, {
973
+ pkg: string;
974
+ checks: ("style" | "types" | "tests" | "build" | "devlink" | "mind")[];
975
+ }, {
976
+ pkg: string;
977
+ checks: ("style" | "types" | "tests" | "build" | "devlink" | "mind")[];
978
+ }>, "many">;
979
+ }, "strip", z.ZodTypeAny, {
980
+ ts: string;
981
+ totals: {
982
+ ok: number;
983
+ warn: number;
984
+ fail: number;
985
+ packages: number;
986
+ durationMs: number;
987
+ };
988
+ topFailures: {
989
+ pkg: string;
990
+ checks: ("style" | "types" | "tests" | "build" | "devlink" | "mind")[];
991
+ }[];
992
+ }, {
993
+ ts: string;
994
+ totals: {
995
+ ok: number;
996
+ warn: number;
997
+ fail: number;
998
+ packages: number;
999
+ durationMs: number;
1000
+ };
1001
+ topFailures: {
1002
+ pkg: string;
1003
+ checks: ("style" | "types" | "tests" | "build" | "devlink" | "mind")[];
1004
+ }[];
1005
+ }>;
1006
+ declare const auditCheckSchema: z.ZodObject<{
1007
+ id: z.ZodEnum<["style", "types", "tests", "build", "devlink", "mind"]>;
1008
+ ok: z.ZodBoolean;
1009
+ errors: z.ZodOptional<z.ZodNumber>;
1010
+ warnings: z.ZodOptional<z.ZodNumber>;
1011
+ meta: z.ZodOptional<z.ZodUnknown>;
1012
+ }, "strip", z.ZodTypeAny, {
1013
+ ok: boolean;
1014
+ id: "style" | "types" | "tests" | "build" | "devlink" | "mind";
1015
+ meta?: unknown;
1016
+ errors?: number | undefined;
1017
+ warnings?: number | undefined;
1018
+ }, {
1019
+ ok: boolean;
1020
+ id: "style" | "types" | "tests" | "build" | "devlink" | "mind";
1021
+ meta?: unknown;
1022
+ errors?: number | undefined;
1023
+ warnings?: number | undefined;
1024
+ }>;
1025
+ declare const auditPackageReportSchema: z.ZodObject<{
1026
+ pkg: z.ZodObject<{
1027
+ name: z.ZodString;
1028
+ version: z.ZodOptional<z.ZodString>;
1029
+ private: z.ZodOptional<z.ZodBoolean>;
1030
+ path: z.ZodOptional<z.ZodString>;
1031
+ }, "strip", z.ZodTypeAny, {
1032
+ name: string;
1033
+ version?: string | undefined;
1034
+ private?: boolean | undefined;
1035
+ path?: string | undefined;
1036
+ }, {
1037
+ name: string;
1038
+ version?: string | undefined;
1039
+ private?: boolean | undefined;
1040
+ path?: string | undefined;
1041
+ }>;
1042
+ lastRun: z.ZodObject<{
1043
+ id: z.ZodString;
1044
+ startedAt: z.ZodString;
1045
+ endedAt: z.ZodOptional<z.ZodString>;
1046
+ status: z.ZodEnum<["pending", "ok", "warn", "fail"]>;
1047
+ }, "strip", z.ZodTypeAny, {
1048
+ status: "ok" | "pending" | "warn" | "fail";
1049
+ id: string;
1050
+ startedAt: string;
1051
+ endedAt?: string | undefined;
1052
+ }, {
1053
+ status: "ok" | "pending" | "warn" | "fail";
1054
+ id: string;
1055
+ startedAt: string;
1056
+ endedAt?: string | undefined;
1057
+ }>;
1058
+ checks: z.ZodArray<z.ZodObject<{
1059
+ id: z.ZodEnum<["style", "types", "tests", "build", "devlink", "mind"]>;
1060
+ ok: z.ZodBoolean;
1061
+ errors: z.ZodOptional<z.ZodNumber>;
1062
+ warnings: z.ZodOptional<z.ZodNumber>;
1063
+ meta: z.ZodOptional<z.ZodUnknown>;
1064
+ }, "strip", z.ZodTypeAny, {
1065
+ ok: boolean;
1066
+ id: "style" | "types" | "tests" | "build" | "devlink" | "mind";
1067
+ meta?: unknown;
1068
+ errors?: number | undefined;
1069
+ warnings?: number | undefined;
1070
+ }, {
1071
+ ok: boolean;
1072
+ id: "style" | "types" | "tests" | "build" | "devlink" | "mind";
1073
+ meta?: unknown;
1074
+ errors?: number | undefined;
1075
+ warnings?: number | undefined;
1076
+ }>, "many">;
1077
+ artifacts: z.ZodObject<{
1078
+ json: z.ZodOptional<z.ZodString>;
1079
+ md: z.ZodOptional<z.ZodString>;
1080
+ txt: z.ZodOptional<z.ZodString>;
1081
+ html: z.ZodOptional<z.ZodString>;
1082
+ }, "strip", z.ZodTypeAny, {
1083
+ json?: string | undefined;
1084
+ md?: string | undefined;
1085
+ txt?: string | undefined;
1086
+ html?: string | undefined;
1087
+ }, {
1088
+ json?: string | undefined;
1089
+ md?: string | undefined;
1090
+ txt?: string | undefined;
1091
+ html?: string | undefined;
1092
+ }>;
1093
+ }, "strip", z.ZodTypeAny, {
1094
+ pkg: {
1095
+ name: string;
1096
+ version?: string | undefined;
1097
+ private?: boolean | undefined;
1098
+ path?: string | undefined;
1099
+ };
1100
+ checks: {
1101
+ ok: boolean;
1102
+ id: "style" | "types" | "tests" | "build" | "devlink" | "mind";
1103
+ meta?: unknown;
1104
+ errors?: number | undefined;
1105
+ warnings?: number | undefined;
1106
+ }[];
1107
+ lastRun: {
1108
+ status: "ok" | "pending" | "warn" | "fail";
1109
+ id: string;
1110
+ startedAt: string;
1111
+ endedAt?: string | undefined;
1112
+ };
1113
+ artifacts: {
1114
+ json?: string | undefined;
1115
+ md?: string | undefined;
1116
+ txt?: string | undefined;
1117
+ html?: string | undefined;
1118
+ };
1119
+ }, {
1120
+ pkg: {
1121
+ name: string;
1122
+ version?: string | undefined;
1123
+ private?: boolean | undefined;
1124
+ path?: string | undefined;
1125
+ };
1126
+ checks: {
1127
+ ok: boolean;
1128
+ id: "style" | "types" | "tests" | "build" | "devlink" | "mind";
1129
+ meta?: unknown;
1130
+ errors?: number | undefined;
1131
+ warnings?: number | undefined;
1132
+ }[];
1133
+ lastRun: {
1134
+ status: "ok" | "pending" | "warn" | "fail";
1135
+ id: string;
1136
+ startedAt: string;
1137
+ endedAt?: string | undefined;
1138
+ };
1139
+ artifacts: {
1140
+ json?: string | undefined;
1141
+ md?: string | undefined;
1142
+ txt?: string | undefined;
1143
+ html?: string | undefined;
1144
+ };
1145
+ }>;
1146
+
1147
+ declare const releasePreviewSchema: z.ZodObject<{
1148
+ range: z.ZodObject<{
1149
+ from: z.ZodString;
1150
+ to: z.ZodString;
1151
+ }, "strip", z.ZodTypeAny, {
1152
+ from: string;
1153
+ to: string;
1154
+ }, {
1155
+ from: string;
1156
+ to: string;
1157
+ }>;
1158
+ packages: z.ZodArray<z.ZodObject<{
1159
+ name: z.ZodString;
1160
+ prev: z.ZodString;
1161
+ next: z.ZodString;
1162
+ bump: z.ZodEnum<["major", "minor", "patch", "none"]>;
1163
+ breaking: z.ZodOptional<z.ZodNumber>;
1164
+ }, "strip", z.ZodTypeAny, {
1165
+ name: string;
1166
+ prev: string;
1167
+ next: string;
1168
+ bump: "patch" | "major" | "minor" | "none";
1169
+ breaking?: number | undefined;
1170
+ }, {
1171
+ name: string;
1172
+ prev: string;
1173
+ next: string;
1174
+ bump: "patch" | "major" | "minor" | "none";
1175
+ breaking?: number | undefined;
1176
+ }>, "many">;
1177
+ manifestJson: z.ZodOptional<z.ZodString>;
1178
+ markdown: z.ZodOptional<z.ZodString>;
1179
+ }, "strip", z.ZodTypeAny, {
1180
+ packages: {
1181
+ name: string;
1182
+ prev: string;
1183
+ next: string;
1184
+ bump: "patch" | "major" | "minor" | "none";
1185
+ breaking?: number | undefined;
1186
+ }[];
1187
+ range: {
1188
+ from: string;
1189
+ to: string;
1190
+ };
1191
+ manifestJson?: string | undefined;
1192
+ markdown?: string | undefined;
1193
+ }, {
1194
+ packages: {
1195
+ name: string;
1196
+ prev: string;
1197
+ next: string;
1198
+ bump: "patch" | "major" | "minor" | "none";
1199
+ breaking?: number | undefined;
1200
+ }[];
1201
+ range: {
1202
+ from: string;
1203
+ to: string;
1204
+ };
1205
+ manifestJson?: string | undefined;
1206
+ markdown?: string | undefined;
1207
+ }>;
1208
+
1209
+ declare const healthStatusSchema: z.ZodObject<{
1210
+ ok: z.ZodBoolean;
1211
+ timestamp: z.ZodString;
1212
+ sources: z.ZodArray<z.ZodObject<{
1213
+ name: z.ZodString;
1214
+ ok: z.ZodBoolean;
1215
+ latency: z.ZodOptional<z.ZodNumber>;
1216
+ error: z.ZodOptional<z.ZodString>;
1217
+ }, "strip", z.ZodTypeAny, {
1218
+ ok: boolean;
1219
+ name: string;
1220
+ error?: string | undefined;
1221
+ latency?: number | undefined;
1222
+ }, {
1223
+ ok: boolean;
1224
+ name: string;
1225
+ error?: string | undefined;
1226
+ latency?: number | undefined;
1227
+ }>, "many">;
1228
+ }, "strip", z.ZodTypeAny, {
1229
+ ok: boolean;
1230
+ timestamp: string;
1231
+ sources: {
1232
+ ok: boolean;
1233
+ name: string;
1234
+ error?: string | undefined;
1235
+ latency?: number | undefined;
1236
+ }[];
1237
+ }, {
1238
+ ok: boolean;
1239
+ timestamp: string;
1240
+ sources: {
1241
+ ok: boolean;
1242
+ name: string;
1243
+ error?: string | undefined;
1244
+ latency?: number | undefined;
1245
+ }[];
1246
+ }>;
1247
+
1248
+ interface RouteInfo {
1249
+ method: string;
1250
+ url: string;
1251
+ }
1252
+ interface RoutesResponse {
1253
+ schema: string;
1254
+ ts: string;
1255
+ count: number;
1256
+ routes: RouteInfo[];
1257
+ raw?: string;
1258
+ }
1259
+ interface SystemDataSource {
1260
+ getHealth(): Promise<HealthStatus>;
1261
+ getReady?(): Promise<ReadyResponse | NotReadyResponse>;
1262
+ getInfo?(): Promise<SystemInfoPayload>;
1263
+ getCapabilities?(): Promise<SystemCapabilitiesPayload>;
1264
+ getConfig?(): Promise<SystemConfigPayload>;
1265
+ /** Get all registered API routes */
1266
+ getRoutes(): Promise<RoutesResponse>;
1267
+ /** Get the base URL of the API (e.g., http://localhost:5050/api/v1) */
1268
+ getBaseUrl(): string;
1269
+ }
1270
+
1271
+ interface WorkflowRunsFilters {
1272
+ status?: string;
1273
+ limit?: number;
1274
+ }
1275
+ interface WorkflowRunParams {
1276
+ spec: WorkflowSpec;
1277
+ idempotencyKey?: string;
1278
+ concurrencyGroup?: string;
1279
+ metadata?: Record<string, unknown>;
1280
+ }
1281
+ interface DashboardStatsResponse {
1282
+ workflows: {
1283
+ total: number;
1284
+ active: number;
1285
+ inactive: number;
1286
+ };
1287
+ jobs: {
1288
+ running: number;
1289
+ pending: number;
1290
+ completed: number;
1291
+ failed: number;
1292
+ };
1293
+ crons: {
1294
+ total: number;
1295
+ enabled: number;
1296
+ disabled: number;
1297
+ };
1298
+ activeExecutions: Array<{
1299
+ id: string;
1300
+ type: string;
1301
+ workflowName?: string;
1302
+ status: 'running';
1303
+ progress?: number;
1304
+ progressMessage?: string;
1305
+ startedAt: string;
1306
+ durationMs?: number;
1307
+ }>;
1308
+ recentActivity: Array<{
1309
+ id: string;
1310
+ type: string;
1311
+ workflowName?: string;
1312
+ status: 'completed' | 'failed' | 'cancelled';
1313
+ finishedAt: string;
1314
+ durationMs?: number;
1315
+ error?: string;
1316
+ }>;
1317
+ }
1318
+ interface WorkflowInfo {
1319
+ id: string;
1320
+ name: string;
1321
+ description?: string;
1322
+ source: 'manifest' | 'standalone';
1323
+ pluginId?: string;
1324
+ status?: 'active' | 'inactive';
1325
+ tags?: string[];
1326
+ inputs?: Record<string, {
1327
+ type: 'string' | 'number' | 'boolean';
1328
+ description?: string;
1329
+ required?: boolean;
1330
+ default?: unknown;
1331
+ }>;
1332
+ }
1333
+ interface WorkflowListResponse {
1334
+ workflows: WorkflowInfo[];
1335
+ }
1336
+ interface JobStatusInfo {
1337
+ id: string;
1338
+ type: string;
1339
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
1340
+ tenantId?: string;
1341
+ priority?: number;
1342
+ createdAt?: Date | string;
1343
+ startedAt?: Date | string;
1344
+ finishedAt?: Date | string;
1345
+ attempt?: number;
1346
+ maxRetries?: number;
1347
+ result?: unknown;
1348
+ error?: string;
1349
+ progress?: number;
1350
+ progressMessage?: string;
1351
+ }
1352
+ interface JobListFilter {
1353
+ type?: string;
1354
+ status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
1355
+ limit?: number;
1356
+ offset?: number;
1357
+ }
1358
+ interface JobListResponse {
1359
+ jobs: JobStatusInfo[];
1360
+ }
1361
+ interface JobStepInfo {
1362
+ name: string;
1363
+ handler?: string;
1364
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
1365
+ progress?: number;
1366
+ startedAt?: string;
1367
+ finishedAt?: string;
1368
+ durationMs?: number;
1369
+ error?: string;
1370
+ output?: unknown;
1371
+ }
1372
+ interface JobStepsResponse {
1373
+ jobId: string;
1374
+ workflowName?: string;
1375
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
1376
+ steps: JobStepInfo[];
1377
+ currentStep?: number;
1378
+ }
1379
+ interface JobLogsResponse {
1380
+ jobId: string;
1381
+ logs: Array<{
1382
+ timestamp: string;
1383
+ level: 'info' | 'warn' | 'error' | 'debug';
1384
+ message: string;
1385
+ context?: Record<string, unknown>;
1386
+ }>;
1387
+ total: number;
1388
+ hasMore: boolean;
1389
+ }
1390
+ interface CronInfo {
1391
+ id: string;
1392
+ schedule: string;
1393
+ jobType: string;
1394
+ timezone?: string;
1395
+ enabled: boolean;
1396
+ lastRun?: Date | string;
1397
+ nextRun?: Date | string;
1398
+ pluginId?: string;
1399
+ }
1400
+ interface CronListResponse {
1401
+ crons: CronInfo[];
1402
+ }
1403
+ interface WorkflowRunInfo {
1404
+ id: string;
1405
+ workflowId: string;
1406
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
1407
+ trigger: {
1408
+ type: 'manual' | 'api' | 'cron';
1409
+ user?: string;
1410
+ };
1411
+ startedAt: string;
1412
+ finishedAt?: string;
1413
+ durationMs?: number;
1414
+ error?: string;
1415
+ }
1416
+ interface WorkflowRunHistoryResponse {
1417
+ workflowId: string;
1418
+ runs: WorkflowRunInfo[];
1419
+ total: number;
1420
+ }
1421
+ interface PendingApproval {
1422
+ jobId: string;
1423
+ stepId: string;
1424
+ stepName: string;
1425
+ specId?: string;
1426
+ context: Record<string, unknown>;
1427
+ waitingSince?: string;
1428
+ }
1429
+ interface PendingApprovalsResponse {
1430
+ runId: string;
1431
+ pending: PendingApproval[];
1432
+ }
1433
+ interface ResolveApprovalParams {
1434
+ runId: string;
1435
+ jobId: string;
1436
+ stepId: string;
1437
+ action: 'approve' | 'reject';
1438
+ comment?: string;
1439
+ data?: Record<string, unknown>;
1440
+ }
1441
+ interface WorkflowDataSource {
1442
+ listRuns(filters?: WorkflowRunsFilters): Promise<WorkflowRunsListResponse>;
1443
+ getRun(runId: string): Promise<WorkflowRun | null>;
1444
+ cancelRun(runId: string): Promise<WorkflowRun>;
1445
+ runWorkflow?(params: WorkflowRunParams): Promise<WorkflowRun>;
1446
+ getPendingApprovals?(runId: string): Promise<PendingApprovalsResponse>;
1447
+ resolveApproval?(params: ResolveApprovalParams): Promise<{
1448
+ resolved: boolean;
1449
+ }>;
1450
+ listEvents?(runId: string, options?: {
1451
+ cursor?: string | null;
1452
+ limit?: number;
1453
+ }): Promise<{
1454
+ events: WorkflowPresenterEvent[];
1455
+ cursor: string | null;
1456
+ }>;
1457
+ getStats(): Promise<DashboardStatsResponse>;
1458
+ listWorkflows(filters?: {
1459
+ limit?: number;
1460
+ }): Promise<WorkflowListResponse>;
1461
+ getWorkflow(workflowId: string): Promise<WorkflowInfo | null>;
1462
+ runWorkflowById(workflowId: string, input?: Record<string, unknown>): Promise<{
1463
+ runId: string;
1464
+ status: string;
1465
+ }>;
1466
+ listJobs(filters?: JobListFilter): Promise<JobListResponse>;
1467
+ getJob(jobId: string): Promise<JobStatusInfo | null>;
1468
+ getJobSteps(jobId: string): Promise<JobStepsResponse>;
1469
+ getJobLogs(jobId: string, filters?: {
1470
+ limit?: number;
1471
+ offset?: number;
1472
+ level?: string;
1473
+ }): Promise<JobLogsResponse>;
1474
+ listCronJobs(): Promise<CronListResponse>;
1475
+ getWorkflowRuns(workflowId: string, filters?: {
1476
+ limit?: number;
1477
+ offset?: number;
1478
+ status?: string;
1479
+ }): Promise<WorkflowRunHistoryResponse>;
1480
+ cancelWorkflowRun(runId: string): Promise<{
1481
+ cancelled: boolean;
1482
+ runId: string;
1483
+ }>;
1484
+ }
1485
+
1486
+ /**
1487
+ * @module @kb-labs/studio-data-client/sources/cache-source
1488
+ * Cache management data source
1489
+ */
1490
+ /**
1491
+ * Cache invalidation result
1492
+ */
1493
+ interface CacheInvalidationResult {
1494
+ invalidated: boolean;
1495
+ timestamp: string;
1496
+ previousRev: number | null;
1497
+ newRev: number;
1498
+ pluginsDiscovered: number;
1499
+ }
1500
+ /**
1501
+ * Cache data source interface
1502
+ */
1503
+ interface CacheDataSource {
1504
+ /**
1505
+ * Invalidate cache and force re-discovery
1506
+ */
1507
+ invalidateCache(): Promise<CacheInvalidationResult>;
1508
+ }
1509
+
1510
+ /**
1511
+ * Observability data source interface
1512
+ */
1513
+ interface ObservabilityDataSource {
1514
+ /**
1515
+ * Get State Broker statistics
1516
+ */
1517
+ getStateBrokerStats(): Promise<StateBrokerStats>;
1518
+ /**
1519
+ * Get DevKit health snapshot
1520
+ */
1521
+ getDevKitHealth(): Promise<DevKitHealth>;
1522
+ /**
1523
+ * Get Prometheus metrics from REST API
1524
+ */
1525
+ getPrometheusMetrics(): Promise<PrometheusMetrics>;
1526
+ /**
1527
+ * Subscribe to system events SSE stream
1528
+ * Returns cleanup function
1529
+ */
1530
+ subscribeToSystemEvents(onEvent: (event: SystemEvent) => void, onError: (error: Error) => void): () => void;
1531
+ /**
1532
+ * Query logs with filters
1533
+ */
1534
+ queryLogs(filters: LogQuery): Promise<LogQueryResponse>;
1535
+ /**
1536
+ * Subscribe to live log stream
1537
+ * Returns cleanup function
1538
+ */
1539
+ subscribeToLogs(onLog: (log: LogRecord) => void, onError: (error: Error) => void, filters?: LogQuery): () => void;
1540
+ /**
1541
+ * Get AI-powered log summarization
1542
+ */
1543
+ summarizeLogs(request: LogSummarizeRequest): Promise<LogSummarizeResponse>;
1544
+ /**
1545
+ * Get single log by ID with optional related logs
1546
+ */
1547
+ getLog(id: string, includeRelated?: boolean): Promise<{
1548
+ log: LogRecord;
1549
+ related?: LogRecord[];
1550
+ }>;
1551
+ /**
1552
+ * Get logs related to a specific log (same trace/execution/request)
1553
+ */
1554
+ getRelatedLogs(id: string): Promise<{
1555
+ total: number;
1556
+ logs: LogRecord[];
1557
+ correlationKeys: any;
1558
+ }>;
1559
+ /**
1560
+ * Get historical metrics time-series data
1561
+ */
1562
+ getMetricsHistory(query: MetricsHistoryQuery): Promise<HistoricalDataPoint[]>;
1563
+ /**
1564
+ * Get metrics heatmap data (7 days × 24 hours)
1565
+ */
1566
+ getMetricsHeatmap(query: MetricsHeatmapQuery): Promise<HeatmapCell[]>;
1567
+ /**
1568
+ * Query incident history (DEPRECATED - use listIncidents)
1569
+ */
1570
+ queryIncidents(query?: IncidentQuery): Promise<Incident[]>;
1571
+ /**
1572
+ * Create a new incident
1573
+ */
1574
+ createIncident(payload: IncidentCreatePayload): Promise<Incident>;
1575
+ /**
1576
+ * Resolve an incident
1577
+ */
1578
+ resolveIncident(id: string, resolutionNotes?: string): Promise<Incident>;
1579
+ /**
1580
+ * List incidents with filters and summary stats (NEW)
1581
+ */
1582
+ listIncidents(query?: IncidentQuery): Promise<IncidentsListResponse>;
1583
+ /**
1584
+ * Get incident details by ID (NEW)
1585
+ */
1586
+ getIncident(id: string): Promise<IncidentDetailResponse>;
1587
+ /**
1588
+ * Analyze incident with AI (NEW)
1589
+ */
1590
+ analyzeIncident(id: string): Promise<IncidentAnalysisResponse>;
1591
+ /**
1592
+ * Chat with AI insights
1593
+ */
1594
+ chatWithInsights(question: string, context?: {
1595
+ includeMetrics?: boolean;
1596
+ includeIncidents?: boolean;
1597
+ includeHistory?: boolean;
1598
+ timeRange?: '1h' | '6h' | '24h' | '7d';
1599
+ plugins?: string[];
1600
+ }): Promise<{
1601
+ answer: string;
1602
+ context: string[];
1603
+ usage: {
1604
+ promptTokens: number;
1605
+ completionTokens: number;
1606
+ totalTokens: number;
1607
+ };
1608
+ }>;
1609
+ }
1610
+
1611
+ /**
1612
+ * @module @kb-labs/studio-data-client/sources/analytics-source
1613
+ * Analytics data source interface
1614
+ */
1615
+
1616
+ /**
1617
+ * Analytics data source interface
1618
+ */
1619
+ interface AnalyticsDataSource {
1620
+ /**
1621
+ * Get analytics events
1622
+ */
1623
+ getEvents(query?: EventsQuery): Promise<EventsResponse>;
1624
+ /**
1625
+ * Get aggregated statistics
1626
+ */
1627
+ getStats(): Promise<EventsStats>;
1628
+ /**
1629
+ * Get buffer status (if applicable)
1630
+ */
1631
+ getBufferStatus(): Promise<BufferStatus | null>;
1632
+ /**
1633
+ * Get DLQ status (if applicable)
1634
+ */
1635
+ getDlqStatus(): Promise<DlqStatus | null>;
1636
+ }
1637
+
1638
+ /**
1639
+ * @module @kb-labs/studio-data-client/sources/adapters-source
1640
+ * Platform adapter analytics data source interface
1641
+ */
1642
+
1643
+ /**
1644
+ * Date range and aggregation options for analytics queries
1645
+ */
1646
+ interface DateRangeOptions {
1647
+ /** Start date (ISO 8601 timestamp) */
1648
+ from?: string;
1649
+ /** End date (ISO 8601 timestamp) */
1650
+ to?: string;
1651
+ /**
1652
+ * Optional model filter (LLM analytics only, legacy).
1653
+ * Prefer breakdownBy='payload.model' for universal breakdown support.
1654
+ */
1655
+ models?: string | string[];
1656
+ /**
1657
+ * Time bucket granularity. Default: 'day'.
1658
+ * Controls the format of DailyStats.date in the response.
1659
+ */
1660
+ groupBy?: 'hour' | 'day' | 'week' | 'month';
1661
+ /**
1662
+ * Dot-notation path to split results by (e.g. 'payload.model', 'payload.tier').
1663
+ * When specified, each time bucket returns multiple rows — one per unique value.
1664
+ * Rows include a `breakdown` field with the field value.
1665
+ * Adapters that don't support this silently return data without breakdown.
1666
+ */
1667
+ breakdownBy?: string;
1668
+ /**
1669
+ * Specific metric field names to aggregate (e.g. ['totalCost', 'totalTokens']).
1670
+ * When omitted, adapters return all known metrics for the event type.
1671
+ */
1672
+ metrics?: string[];
1673
+ }
1674
+ /**
1675
+ * Daily aggregated statistics for time-series charts
1676
+ */
1677
+ interface DailyStats {
1678
+ /**
1679
+ * Bucket key — format depends on groupBy:
1680
+ * 'YYYY-MM-DD' (day, default), 'YYYY-MM-DDTHH' (hour), 'YYYY-WXX' (week), 'YYYY-MM' (month)
1681
+ */
1682
+ date: string;
1683
+ /** Number of events in this bucket */
1684
+ count: number;
1685
+ /** Event-specific metrics (e.g., totalTokens, totalCost, avgDurationMs) */
1686
+ metrics?: Record<string, number>;
1687
+ /**
1688
+ * Present when DateRangeOptions.breakdownBy is specified.
1689
+ * The value of the breakdown field for this row.
1690
+ */
1691
+ breakdown?: string;
1692
+ }
1693
+ /**
1694
+ * Platform adapter analytics data source
1695
+ */
1696
+ interface AdaptersDataSource {
1697
+ /**
1698
+ * Get LLM usage statistics
1699
+ * @param options - Optional date range filter
1700
+ */
1701
+ getLLMUsage(options?: DateRangeOptions): Promise<LLMUsageStats>;
1702
+ /**
1703
+ * Get Embeddings usage statistics
1704
+ * @param options - Optional date range filter
1705
+ */
1706
+ getEmbeddingsUsage(options?: DateRangeOptions): Promise<EmbeddingsUsageStats>;
1707
+ /**
1708
+ * Get VectorStore usage statistics
1709
+ * @param options - Optional date range filter
1710
+ */
1711
+ getVectorStoreUsage(options?: DateRangeOptions): Promise<VectorStoreUsageStats>;
1712
+ /**
1713
+ * Get Cache usage statistics
1714
+ * @param options - Optional date range filter
1715
+ */
1716
+ getCacheUsage(options?: DateRangeOptions): Promise<CacheUsageStats>;
1717
+ /**
1718
+ * Get Storage usage statistics
1719
+ * @param options - Optional date range filter
1720
+ */
1721
+ getStorageUsage(options?: DateRangeOptions): Promise<StorageUsageStats>;
1722
+ /**
1723
+ * Get daily aggregated LLM statistics for time-series charts
1724
+ * @param options - Optional date range filter
1725
+ */
1726
+ getLLMDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
1727
+ /**
1728
+ * Get daily aggregated Embeddings statistics for time-series charts
1729
+ * @param options - Optional date range filter
1730
+ */
1731
+ getEmbeddingsDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
1732
+ /**
1733
+ * Get daily aggregated VectorStore statistics for time-series charts
1734
+ * @param options - Optional date range filter
1735
+ */
1736
+ getVectorStoreDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
1737
+ /**
1738
+ * Get daily aggregated Cache statistics for time-series charts
1739
+ * @param options - Optional date range filter
1740
+ */
1741
+ getCacheDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
1742
+ /**
1743
+ * Get daily aggregated Storage statistics for time-series charts
1744
+ * @param options - Optional date range filter
1745
+ */
1746
+ getStorageDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
1747
+ }
1748
+
1749
+ /**
1750
+ * @module @kb-labs/studio-data-client/sources/platform-source
1751
+ * Platform configuration data source contract
1752
+ */
1753
+
1754
+ /**
1755
+ * Platform configuration data source
1756
+ */
1757
+ interface PlatformDataSource {
1758
+ /**
1759
+ * Get platform configuration (adapters, options, execution mode)
1760
+ */
1761
+ getConfig(): Promise<PlatformConfigPayload>;
1762
+ }
1763
+
1764
+ /**
1765
+ * Plugin registry data source interface
1766
+ */
1767
+
1768
+ interface PluginSource {
1769
+ /** Source kind (workspace, npm, etc.) */
1770
+ kind: string;
1771
+ /** Source path or location */
1772
+ path: string;
1773
+ }
1774
+ interface PluginManifestEntry {
1775
+ /** Plugin ID (@scope/name) */
1776
+ pluginId: string;
1777
+ /** Full plugin manifest */
1778
+ manifest: ManifestV3;
1779
+ /** Absolute path to plugin root directory */
1780
+ pluginRoot: string;
1781
+ /** Source of the plugin */
1782
+ source: string | PluginSource;
1783
+ /** When the plugin was discovered (ISO timestamp) */
1784
+ discoveredAt?: string;
1785
+ /** When the plugin's dist/ was last built (ISO timestamp) */
1786
+ buildTimestamp?: string;
1787
+ /** Manifest validation result */
1788
+ validation?: {
1789
+ /** Whether the manifest is valid */
1790
+ valid: boolean;
1791
+ /** Validation errors (if any) */
1792
+ errors: string[];
1793
+ };
1794
+ }
1795
+ interface PluginsRegistryResponse {
1796
+ /** List of discovered plugin manifests */
1797
+ manifests: PluginManifestEntry[];
1798
+ /** Base path for all REST API routes (e.g., /api/v1) */
1799
+ apiBasePath?: string;
1800
+ }
1801
+ interface PluginAskRequest {
1802
+ /** The question to ask about the plugin */
1803
+ question: string;
1804
+ }
1805
+ interface PluginAskResponse {
1806
+ /** LLM's answer */
1807
+ answer: string;
1808
+ /** Token usage */
1809
+ usage: {
1810
+ promptTokens: number;
1811
+ completionTokens: number;
1812
+ };
1813
+ }
1814
+ /**
1815
+ * Data source for plugin registry operations
1816
+ */
1817
+ interface PluginsDataSource {
1818
+ /**
1819
+ * Get all discovered plugins with their manifests
1820
+ */
1821
+ getPlugins(): Promise<PluginsRegistryResponse>;
1822
+ /**
1823
+ * Ask AI a question about a specific plugin
1824
+ */
1825
+ askAboutPlugin(pluginId: string, request: PluginAskRequest): Promise<PluginAskResponse>;
1826
+ }
1827
+
1828
+ /**
1829
+ * @module @kb-labs/studio-data-client/sources/http-system-source
1830
+ * HTTP implementation of SystemDataSource
1831
+ */
1832
+
1833
+ /**
1834
+ * HTTP implementation of SystemDataSource
1835
+ */
1836
+ declare class HttpSystemSource implements SystemDataSource {
1837
+ private client;
1838
+ constructor(client: HttpClient);
1839
+ getHealth(): Promise<HealthStatus>;
1840
+ /**
1841
+ * Get ready status
1842
+ */
1843
+ getReady(): Promise<ReadyResponse | NotReadyResponse>;
1844
+ /**
1845
+ * Get info
1846
+ */
1847
+ getInfo(): Promise<SystemInfoPayload>;
1848
+ /**
1849
+ * Get capabilities
1850
+ */
1851
+ getCapabilities(): Promise<SystemCapabilitiesPayload>;
1852
+ /**
1853
+ * Get config (redacted)
1854
+ */
1855
+ getConfig(): Promise<SystemConfigPayload>;
1856
+ /**
1857
+ * Get all registered API routes
1858
+ */
1859
+ getRoutes(): Promise<RoutesResponse>;
1860
+ /**
1861
+ * Get the base URL of the API
1862
+ */
1863
+ getBaseUrl(): string;
1864
+ }
1865
+
1866
+ declare class HttpWorkflowSource implements WorkflowDataSource {
1867
+ private readonly client;
1868
+ constructor(client: HttpClient);
1869
+ listRuns(filters?: WorkflowRunsFilters): Promise<WorkflowRunsListResponse>;
1870
+ getRun(runId: string): Promise<WorkflowRun | null>;
1871
+ cancelRun(runId: string): Promise<WorkflowRun>;
1872
+ runWorkflow(params: WorkflowRunParams): Promise<WorkflowRun>;
1873
+ listEvents(runId: string, options?: {
1874
+ cursor?: string | null;
1875
+ limit?: number;
1876
+ }): Promise<{
1877
+ events: WorkflowPresenterEvent[];
1878
+ cursor: string | null;
1879
+ }>;
1880
+ getStats(): Promise<DashboardStatsResponse>;
1881
+ listWorkflows(filters?: {
1882
+ limit?: number;
1883
+ }): Promise<WorkflowListResponse>;
1884
+ getWorkflow(workflowId: string): Promise<WorkflowInfo | null>;
1885
+ runWorkflowById(workflowId: string, input?: Record<string, unknown>): Promise<{
1886
+ runId: string;
1887
+ status: string;
1888
+ }>;
1889
+ listJobs(filters?: JobListFilter): Promise<JobListResponse>;
1890
+ getJob(jobId: string): Promise<JobStatusInfo | null>;
1891
+ getJobSteps(jobId: string): Promise<JobStepsResponse>;
1892
+ getJobLogs(jobId: string, filters?: {
1893
+ limit?: number;
1894
+ offset?: number;
1895
+ level?: string;
1896
+ }): Promise<JobLogsResponse>;
1897
+ listCronJobs(): Promise<CronListResponse>;
1898
+ getPendingApprovals(runId: string): Promise<PendingApprovalsResponse>;
1899
+ resolveApproval(params: ResolveApprovalParams): Promise<{
1900
+ resolved: boolean;
1901
+ }>;
1902
+ cancelWorkflowRun(runId: string): Promise<{
1903
+ cancelled: boolean;
1904
+ runId: string;
1905
+ }>;
1906
+ getWorkflowRuns(workflowId: string, filters?: {
1907
+ limit?: number;
1908
+ offset?: number;
1909
+ status?: string;
1910
+ }): Promise<WorkflowRunHistoryResponse>;
1911
+ }
1912
+
1913
+ /**
1914
+ * @module @kb-labs/studio-data-client/sources/http-cache-source
1915
+ * HTTP implementation of CacheDataSource
1916
+ */
1917
+
1918
+ /**
1919
+ * HTTP implementation of CacheDataSource
1920
+ */
1921
+ declare class HttpCacheSource implements CacheDataSource {
1922
+ private client;
1923
+ constructor(client: HttpClient);
1924
+ invalidateCache(): Promise<CacheInvalidationResult>;
1925
+ }
1926
+
1927
+ /**
1928
+ * @module @kb-labs/studio-data-client/sources/http-observability-source
1929
+ * HTTP implementation of ObservabilityDataSource
1930
+ */
1931
+
1932
+ /**
1933
+ * HTTP implementation of ObservabilityDataSource
1934
+ */
1935
+ declare class HttpObservabilitySource implements ObservabilityDataSource {
1936
+ private client;
1937
+ constructor(client: HttpClient);
1938
+ getStateBrokerStats(): Promise<StateBrokerStats>;
1939
+ getDevKitHealth(): Promise<DevKitHealth>;
1940
+ getPrometheusMetrics(): Promise<PrometheusMetrics>;
1941
+ subscribeToSystemEvents(onEvent: (event: SystemEvent) => void, onError: (error: Error) => void): () => void;
1942
+ queryLogs(filters: LogQuery): Promise<LogQueryResponse>;
1943
+ subscribeToLogs(onLog: (log: LogRecord) => void, onError: (error: Error) => void, filters?: LogQuery): () => void;
1944
+ summarizeLogs(request: LogSummarizeRequest): Promise<LogSummarizeResponse>;
1945
+ getLog(id: string, includeRelated?: boolean): Promise<{
1946
+ log: LogRecord;
1947
+ related?: LogRecord[];
1948
+ }>;
1949
+ getRelatedLogs(id: string): Promise<{
1950
+ total: number;
1951
+ logs: LogRecord[];
1952
+ correlationKeys: any;
1953
+ }>;
1954
+ getMetricsHistory(query: MetricsHistoryQuery): Promise<HistoricalDataPoint[]>;
1955
+ getMetricsHeatmap(query: MetricsHeatmapQuery): Promise<HeatmapCell[]>;
1956
+ queryIncidents(query?: IncidentQuery): Promise<Incident[]>;
1957
+ createIncident(payload: IncidentCreatePayload): Promise<Incident>;
1958
+ resolveIncident(id: string, resolutionNotes?: string): Promise<Incident>;
1959
+ listIncidents(query?: IncidentQuery): Promise<IncidentsListResponse>;
1960
+ getIncident(id: string): Promise<IncidentDetailResponse>;
1961
+ analyzeIncident(id: string): Promise<IncidentAnalysisResponse>;
1962
+ chatWithInsights(question: string, context?: {
1963
+ includeMetrics?: boolean;
1964
+ includeIncidents?: boolean;
1965
+ includeHistory?: boolean;
1966
+ timeRange?: '1h' | '6h' | '24h' | '7d';
1967
+ plugins?: string[];
1968
+ }): Promise<{
1969
+ answer: string;
1970
+ context: string[];
1971
+ usage: {
1972
+ promptTokens: number;
1973
+ completionTokens: number;
1974
+ totalTokens: number;
1975
+ };
1976
+ }>;
1977
+ }
1978
+
1979
+ /**
1980
+ * @module @kb-labs/studio-data-client/sources/http-analytics-source
1981
+ * HTTP implementation of AnalyticsDataSource
1982
+ */
1983
+
1984
+ /**
1985
+ * HTTP implementation of AnalyticsDataSource
1986
+ * Calls REST API /v1/analytics/* endpoints
1987
+ */
1988
+ declare class HttpAnalyticsSource implements AnalyticsDataSource {
1989
+ private readonly client;
1990
+ constructor(client: HttpClient);
1991
+ getEvents(query?: EventsQuery): Promise<EventsResponse>;
1992
+ getStats(): Promise<EventsStats>;
1993
+ getBufferStatus(): Promise<BufferStatus | null>;
1994
+ getDlqStatus(): Promise<DlqStatus | null>;
1995
+ }
1996
+
1997
+ /**
1998
+ * @module @kb-labs/studio-data-client/sources/http-adapters-source
1999
+ * HTTP implementation of AdaptersDataSource
2000
+ */
2001
+
2002
+ /**
2003
+ * HTTP implementation of AdaptersDataSource
2004
+ * Calls REST API /v1/adapters/* endpoints
2005
+ */
2006
+ declare class HttpAdaptersSource implements AdaptersDataSource {
2007
+ private readonly client;
2008
+ constructor(client: HttpClient);
2009
+ /**
2010
+ * Build query string from date range options
2011
+ */
2012
+ private buildQueryString;
2013
+ getLLMUsage(options?: DateRangeOptions): Promise<LLMUsageStats>;
2014
+ getEmbeddingsUsage(options?: DateRangeOptions): Promise<EmbeddingsUsageStats>;
2015
+ getVectorStoreUsage(options?: DateRangeOptions): Promise<VectorStoreUsageStats>;
2016
+ getCacheUsage(options?: DateRangeOptions): Promise<CacheUsageStats>;
2017
+ getStorageUsage(options?: DateRangeOptions): Promise<StorageUsageStats>;
2018
+ getLLMDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
2019
+ getEmbeddingsDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
2020
+ getVectorStoreDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
2021
+ getCacheDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
2022
+ getStorageDailyStats(options?: DateRangeOptions): Promise<DailyStats[]>;
2023
+ }
2024
+
2025
+ /**
2026
+ * @module @kb-labs/studio-data-client/sources/http-platform-source
2027
+ * HTTP implementation of PlatformDataSource
2028
+ */
2029
+
2030
+ /**
2031
+ * HTTP implementation of PlatformDataSource
2032
+ */
2033
+ declare class HttpPlatformSource implements PlatformDataSource {
2034
+ private client;
2035
+ constructor(client: HttpClient);
2036
+ /**
2037
+ * Get platform configuration
2038
+ */
2039
+ getConfig(): Promise<PlatformConfigPayload>;
2040
+ }
2041
+
2042
+ /**
2043
+ * HTTP implementation of PluginsDataSource
2044
+ */
2045
+
2046
+ declare class HttpPluginsSource implements PluginsDataSource {
2047
+ private readonly client;
2048
+ constructor(client: HttpClient);
2049
+ getPlugins(): Promise<PluginsRegistryResponse>;
2050
+ askAboutPlugin(pluginId: string, request: PluginAskRequest): Promise<PluginAskResponse>;
2051
+ }
2052
+
2053
+ declare class MockSystemSource implements SystemDataSource {
2054
+ getHealth(): Promise<HealthStatus>;
2055
+ getRoutes(): Promise<RoutesResponse>;
2056
+ getBaseUrl(): string;
2057
+ }
2058
+
2059
+ declare class MockWorkflowSource implements WorkflowDataSource {
2060
+ private runs;
2061
+ listRuns(_filters?: WorkflowRunsFilters): Promise<{
2062
+ runs: WorkflowRun[];
2063
+ total: number;
2064
+ }>;
2065
+ getRun(runId: string): Promise<WorkflowRun | null>;
2066
+ cancelRun(runId: string): Promise<WorkflowRun>;
2067
+ runWorkflow(params: WorkflowRunParams): Promise<WorkflowRun>;
2068
+ listEvents(): Promise<{
2069
+ events: never[];
2070
+ cursor: null;
2071
+ }>;
2072
+ getStats(): Promise<DashboardStatsResponse>;
2073
+ listWorkflows(_filters?: {
2074
+ limit?: number;
2075
+ }): Promise<WorkflowListResponse>;
2076
+ getWorkflow(workflowId: string): Promise<WorkflowInfo | null>;
2077
+ runWorkflowById(workflowId: string, _input?: Record<string, unknown>): Promise<{
2078
+ runId: string;
2079
+ status: string;
2080
+ }>;
2081
+ listJobs(filters?: JobListFilter): Promise<JobListResponse>;
2082
+ getJob(jobId: string): Promise<JobStatusInfo | null>;
2083
+ getJobSteps(jobId: string): Promise<JobStepsResponse>;
2084
+ getJobLogs(jobId: string, _filters?: {
2085
+ limit?: number;
2086
+ offset?: number;
2087
+ level?: string;
2088
+ }): Promise<JobLogsResponse>;
2089
+ listCronJobs(): Promise<CronListResponse>;
2090
+ cancelWorkflowRun(runId: string): Promise<{
2091
+ cancelled: boolean;
2092
+ runId: string;
2093
+ }>;
2094
+ getWorkflowRuns(workflowId: string, _filters?: {
2095
+ limit?: number;
2096
+ offset?: number;
2097
+ status?: string;
2098
+ }): Promise<WorkflowRunHistoryResponse>;
2099
+ }
2100
+
2101
+ /**
2102
+ * @module @kb-labs/studio-data-client/mocks/mock-cache-source
2103
+ * Mock implementation of CacheDataSource
2104
+ */
2105
+
2106
+ /**
2107
+ * Mock implementation of CacheDataSource
2108
+ */
2109
+ declare class MockCacheSource implements CacheDataSource {
2110
+ invalidateCache(): Promise<CacheInvalidationResult>;
2111
+ }
2112
+
2113
+ /**
2114
+ * @module @kb-labs/studio-data-client/mocks/mock-observability-source
2115
+ * Mock implementation of ObservabilityDataSource
2116
+ */
2117
+
2118
+ /**
2119
+ * Mock implementation of ObservabilityDataSource
2120
+ *
2121
+ * Returns deterministic mock data for development and testing
2122
+ */
2123
+ declare class MockObservabilitySource implements ObservabilityDataSource {
2124
+ getStateBrokerStats(): Promise<StateBrokerStats>;
2125
+ getDevKitHealth(): Promise<DevKitHealth>;
2126
+ getPrometheusMetrics(): Promise<PrometheusMetrics>;
2127
+ queryLogs(filters: LogQuery): Promise<LogQueryResponse>;
2128
+ subscribeToSystemEvents(onEvent: (event: SystemEvent) => void, _onError: (error: Error) => void): () => void;
2129
+ subscribeToLogs(onLog: (log: LogRecord) => void, _onError: (error: Error) => void, filters?: LogQuery): () => void;
2130
+ getLog(_id: string, includeRelated?: boolean): Promise<{
2131
+ log: LogRecord;
2132
+ related?: LogRecord[];
2133
+ }>;
2134
+ getRelatedLogs(_id: string): Promise<{
2135
+ total: number;
2136
+ logs: LogRecord[];
2137
+ correlationKeys: any;
2138
+ }>;
2139
+ summarizeLogs(request: LogSummarizeRequest): Promise<LogSummarizeResponse>;
2140
+ getMetricsHistory(query: MetricsHistoryQuery): Promise<HistoricalDataPoint[]>;
2141
+ getMetricsHeatmap(query: MetricsHeatmapQuery): Promise<HeatmapCell[]>;
2142
+ queryIncidents(query?: IncidentQuery): Promise<Incident[]>;
2143
+ createIncident(payload: IncidentCreatePayload): Promise<Incident>;
2144
+ resolveIncident(_id: string, resolutionNotes?: string): Promise<Incident>;
2145
+ listIncidents(query?: IncidentQuery): Promise<IncidentsListResponse>;
2146
+ getIncident(_id: string): Promise<IncidentDetailResponse>;
2147
+ analyzeIncident(_id: string): Promise<IncidentAnalysisResponse>;
2148
+ chatWithInsights(question: string, context?: {
2149
+ includeMetrics?: boolean;
2150
+ includeIncidents?: boolean;
2151
+ includeHistory?: boolean;
2152
+ timeRange?: '1h' | '6h' | '24h' | '7d';
2153
+ plugins?: string[];
2154
+ }): Promise<{
2155
+ answer: string;
2156
+ context: string[];
2157
+ usage: {
2158
+ promptTokens: number;
2159
+ completionTokens: number;
2160
+ totalTokens: number;
2161
+ };
2162
+ }>;
2163
+ }
2164
+
2165
+ /**
2166
+ * @module @kb-labs/studio-data-client/mocks/mock-analytics-source
2167
+ * Mock implementation of AnalyticsDataSource
2168
+ */
2169
+
2170
+ /**
2171
+ * Mock implementation of AnalyticsDataSource
2172
+ * Returns deterministic mock data for development and testing
2173
+ */
2174
+ declare class MockAnalyticsSource implements AnalyticsDataSource {
2175
+ private mockEvents;
2176
+ constructor();
2177
+ private generateMockEvents;
2178
+ getEvents(query?: EventsQuery): Promise<EventsResponse>;
2179
+ getStats(): Promise<EventsStats>;
2180
+ getBufferStatus(): Promise<BufferStatus | null>;
2181
+ getDlqStatus(): Promise<DlqStatus | null>;
2182
+ }
2183
+
2184
+ /**
2185
+ * @module @kb-labs/studio-data-client/mocks/mock-adapters-source
2186
+ * Mock implementation of AdaptersDataSource
2187
+ */
2188
+
2189
+ /**
2190
+ * Mock adapters data source for testing
2191
+ */
2192
+ declare class MockAdaptersSource implements AdaptersDataSource {
2193
+ getLLMUsage(_options?: DateRangeOptions): Promise<LLMUsageStats>;
2194
+ getEmbeddingsUsage(_options?: DateRangeOptions): Promise<EmbeddingsUsageStats>;
2195
+ getVectorStoreUsage(_options?: DateRangeOptions): Promise<VectorStoreUsageStats>;
2196
+ getCacheUsage(_options?: DateRangeOptions): Promise<CacheUsageStats>;
2197
+ getStorageUsage(_options?: DateRangeOptions): Promise<StorageUsageStats>;
2198
+ getLLMDailyStats(_options?: DateRangeOptions): Promise<DailyStats[]>;
2199
+ getEmbeddingsDailyStats(_options?: DateRangeOptions): Promise<DailyStats[]>;
2200
+ getVectorStoreDailyStats(_options?: DateRangeOptions): Promise<DailyStats[]>;
2201
+ getCacheDailyStats(_options?: DateRangeOptions): Promise<DailyStats[]>;
2202
+ getStorageDailyStats(_options?: DateRangeOptions): Promise<DailyStats[]>;
2203
+ /**
2204
+ * Helper to generate mock daily stats
2205
+ */
2206
+ private generateMockDailyStats;
2207
+ }
2208
+
2209
+ /**
2210
+ * @module @kb-labs/studio-data-client/mocks/mock-platform-source
2211
+ * Mock implementation of PlatformDataSource for development
2212
+ */
2213
+
2214
+ /**
2215
+ * Mock platform data source
2216
+ */
2217
+ declare class MockPlatformSource implements PlatformDataSource {
2218
+ getConfig(): Promise<PlatformConfigPayload>;
2219
+ }
2220
+
2221
+ /**
2222
+ * Mock implementation of PluginsDataSource for testing
2223
+ */
2224
+
2225
+ declare class MockPluginsSource implements PluginsDataSource {
2226
+ getPlugins(): Promise<PluginsRegistryResponse>;
2227
+ askAboutPlugin(pluginId: string, request: {
2228
+ question: string;
2229
+ }): Promise<{
2230
+ answer: string;
2231
+ usage: {
2232
+ promptTokens: number;
2233
+ completionTokens: number;
2234
+ };
2235
+ }>;
2236
+ }
2237
+
2238
+ interface DataSourcesConfig {
2239
+ mode: 'mock' | 'http';
2240
+ baseUrl?: string;
2241
+ /** Bearer token forwarded to Gateway on every request */
2242
+ token?: string;
2243
+ }
2244
+ interface DataSources {
2245
+ system: SystemDataSource;
2246
+ workflow: WorkflowDataSource;
2247
+ cache: CacheDataSource;
2248
+ observability: ObservabilityDataSource;
2249
+ analytics: AnalyticsDataSource;
2250
+ adapters: AdaptersDataSource;
2251
+ platform: PlatformDataSource;
2252
+ plugins: PluginsDataSource;
2253
+ }
2254
+ declare function createDataSources(config: DataSourcesConfig): DataSources;
2255
+
2256
+ /**
2257
+ * @module @kb-labs/studio-data-client/query-keys
2258
+ * Query keys factory for TanStack Query
2259
+ */
2260
+
2261
+ /**
2262
+ * Standardized query keys factory
2263
+ */
2264
+ declare const qk: {
2265
+ readonly audit: {
2266
+ readonly all: readonly ["audit"];
2267
+ readonly summary: () => readonly ["audit", "summary"];
2268
+ readonly runs: {
2269
+ readonly all: () => readonly ["audit", "runs"];
2270
+ readonly list: (params?: {
2271
+ cursor?: string;
2272
+ limit?: number;
2273
+ status?: string;
2274
+ }) => readonly ["audit", "runs", "list", {
2275
+ cursor?: string;
2276
+ limit?: number;
2277
+ status?: string;
2278
+ } | undefined];
2279
+ readonly byId: (runId: string) => readonly ["audit", "runs", "detail", string];
2280
+ };
2281
+ readonly report: {
2282
+ readonly latest: () => readonly ["audit", "report", "latest"];
2283
+ readonly byRunId: (runId: string) => readonly ["audit", "report", string];
2284
+ };
2285
+ readonly pkg: (name: string) => readonly ["audit", "pkg", string];
2286
+ };
2287
+ readonly release: {
2288
+ readonly all: readonly ["release"];
2289
+ readonly preview: (params?: {
2290
+ from?: string;
2291
+ to?: string;
2292
+ }) => readonly ["release", "preview", {
2293
+ from?: string;
2294
+ to?: string;
2295
+ } | undefined];
2296
+ readonly runs: {
2297
+ readonly all: () => readonly ["release", "runs"];
2298
+ readonly byId: (runId: string) => readonly ["release", "runs", "detail", string];
2299
+ };
2300
+ readonly changelog: (params?: {
2301
+ format?: string;
2302
+ }) => readonly ["release", "changelog", {
2303
+ format?: string;
2304
+ } | undefined];
2305
+ };
2306
+ readonly jobs: {
2307
+ readonly all: readonly ["jobs"];
2308
+ readonly byId: (jobId: string) => readonly ["jobs", "detail", string];
2309
+ readonly logs: {
2310
+ readonly byJobId: (jobId: string, offset?: number) => readonly ["jobs", "logs", string, number | undefined];
2311
+ readonly stream: (jobId: string) => readonly ["jobs", "logs", "stream", string];
2312
+ };
2313
+ readonly events: (jobId: string) => readonly ["jobs", "events", string];
2314
+ readonly list: (params?: {
2315
+ cursor?: string;
2316
+ limit?: number;
2317
+ status?: string;
2318
+ kind?: string;
2319
+ }) => readonly ["jobs", "list", {
2320
+ cursor?: string;
2321
+ limit?: number;
2322
+ status?: string;
2323
+ kind?: string;
2324
+ } | undefined];
2325
+ };
2326
+ readonly system: {
2327
+ readonly all: readonly ["system"];
2328
+ readonly health: {
2329
+ readonly live: () => readonly ["system", "health", "live"];
2330
+ readonly ready: () => readonly ["system", "health", "ready"];
2331
+ };
2332
+ readonly info: () => readonly ["system", "info"];
2333
+ readonly capabilities: () => readonly ["system", "capabilities"];
2334
+ readonly config: () => readonly ["system", "config"];
2335
+ };
2336
+ readonly workflows: {
2337
+ readonly all: readonly ["workflows"];
2338
+ readonly list: (filters?: WorkflowRunsFilters) => readonly ["workflows", "list", WorkflowRunsFilters];
2339
+ readonly run: (runId: string) => readonly ["workflows", "run", string];
2340
+ };
2341
+ readonly devlink: {
2342
+ readonly all: readonly ["devlink"];
2343
+ readonly summary: () => readonly ["devlink", "summary"];
2344
+ readonly graph: () => readonly ["devlink", "graph"];
2345
+ };
2346
+ readonly mind: {
2347
+ readonly all: readonly ["mind"];
2348
+ readonly summary: () => readonly ["mind", "summary"];
2349
+ };
2350
+ readonly analytics: {
2351
+ readonly all: readonly ["analytics"];
2352
+ readonly summary: (params?: {
2353
+ start?: string;
2354
+ end?: string;
2355
+ }) => readonly ["analytics", "summary", {
2356
+ start?: string;
2357
+ end?: string;
2358
+ } | undefined];
2359
+ };
2360
+ readonly platform: {
2361
+ readonly all: readonly ["platform"];
2362
+ readonly config: () => readonly ["platform", "config"];
2363
+ };
2364
+ };
2365
+ declare const queryKeys: {
2366
+ readonly audit: {
2367
+ readonly all: readonly ["audit"];
2368
+ readonly summary: () => readonly ["audit", "summary"];
2369
+ readonly runs: {
2370
+ readonly all: () => readonly ["audit", "runs"];
2371
+ readonly list: (params?: {
2372
+ cursor?: string;
2373
+ limit?: number;
2374
+ status?: string;
2375
+ }) => readonly ["audit", "runs", "list", {
2376
+ cursor?: string;
2377
+ limit?: number;
2378
+ status?: string;
2379
+ } | undefined];
2380
+ readonly byId: (runId: string) => readonly ["audit", "runs", "detail", string];
2381
+ };
2382
+ readonly report: {
2383
+ readonly latest: () => readonly ["audit", "report", "latest"];
2384
+ readonly byRunId: (runId: string) => readonly ["audit", "report", string];
2385
+ };
2386
+ readonly pkg: (name: string) => readonly ["audit", "pkg", string];
2387
+ };
2388
+ readonly release: {
2389
+ readonly all: readonly ["release"];
2390
+ readonly preview: (params?: {
2391
+ from?: string;
2392
+ to?: string;
2393
+ }) => readonly ["release", "preview", {
2394
+ from?: string;
2395
+ to?: string;
2396
+ } | undefined];
2397
+ readonly runs: {
2398
+ readonly all: () => readonly ["release", "runs"];
2399
+ readonly byId: (runId: string) => readonly ["release", "runs", "detail", string];
2400
+ };
2401
+ readonly changelog: (params?: {
2402
+ format?: string;
2403
+ }) => readonly ["release", "changelog", {
2404
+ format?: string;
2405
+ } | undefined];
2406
+ };
2407
+ readonly jobs: {
2408
+ readonly all: readonly ["jobs"];
2409
+ readonly byId: (jobId: string) => readonly ["jobs", "detail", string];
2410
+ readonly logs: {
2411
+ readonly byJobId: (jobId: string, offset?: number) => readonly ["jobs", "logs", string, number | undefined];
2412
+ readonly stream: (jobId: string) => readonly ["jobs", "logs", "stream", string];
2413
+ };
2414
+ readonly events: (jobId: string) => readonly ["jobs", "events", string];
2415
+ readonly list: (params?: {
2416
+ cursor?: string;
2417
+ limit?: number;
2418
+ status?: string;
2419
+ kind?: string;
2420
+ }) => readonly ["jobs", "list", {
2421
+ cursor?: string;
2422
+ limit?: number;
2423
+ status?: string;
2424
+ kind?: string;
2425
+ } | undefined];
2426
+ };
2427
+ readonly system: {
2428
+ readonly all: readonly ["system"];
2429
+ readonly health: {
2430
+ readonly live: () => readonly ["system", "health", "live"];
2431
+ readonly ready: () => readonly ["system", "health", "ready"];
2432
+ };
2433
+ readonly info: () => readonly ["system", "info"];
2434
+ readonly capabilities: () => readonly ["system", "capabilities"];
2435
+ readonly config: () => readonly ["system", "config"];
2436
+ };
2437
+ readonly workflows: {
2438
+ readonly all: readonly ["workflows"];
2439
+ readonly list: (filters?: WorkflowRunsFilters) => readonly ["workflows", "list", WorkflowRunsFilters];
2440
+ readonly run: (runId: string) => readonly ["workflows", "run", string];
2441
+ };
2442
+ readonly devlink: {
2443
+ readonly all: readonly ["devlink"];
2444
+ readonly summary: () => readonly ["devlink", "summary"];
2445
+ readonly graph: () => readonly ["devlink", "graph"];
2446
+ };
2447
+ readonly mind: {
2448
+ readonly all: readonly ["mind"];
2449
+ readonly summary: () => readonly ["mind", "summary"];
2450
+ };
2451
+ readonly analytics: {
2452
+ readonly all: readonly ["analytics"];
2453
+ readonly summary: (params?: {
2454
+ start?: string;
2455
+ end?: string;
2456
+ }) => readonly ["analytics", "summary", {
2457
+ start?: string;
2458
+ end?: string;
2459
+ } | undefined];
2460
+ };
2461
+ readonly platform: {
2462
+ readonly all: readonly ["platform"];
2463
+ readonly config: () => readonly ["platform", "config"];
2464
+ };
2465
+ };
2466
+
2467
+ declare function useHealthStatus(source: SystemDataSource): _tanstack_react_query.UseQueryResult<HealthStatus, Error>;
2468
+ declare function useReadyStatus(source: SystemDataSource): _tanstack_react_query.UseQueryResult<any, Error>;
2469
+ declare function useSystemInfo(source: SystemDataSource): _tanstack_react_query.UseQueryResult<any, Error>;
2470
+ declare function useCapabilities(source: SystemDataSource): _tanstack_react_query.UseQueryResult<any, Error>;
2471
+
2472
+ declare function useWorkflowRuns(source: WorkflowDataSource, filters?: WorkflowRunsFilters): _tanstack_react_query.UseQueryResult<WorkflowRunsListResponse, Error>;
2473
+ declare function useWorkflowRun(runId: string | null, source: WorkflowDataSource): _tanstack_react_query.UseQueryResult<WorkflowRun | null, Error>;
2474
+ declare function useCancelWorkflowRun(source: WorkflowDataSource): _tanstack_react_query.UseMutationResult<WorkflowRun, Error, string, unknown>;
2475
+ declare function useRunWorkflow(source: WorkflowDataSource): _tanstack_react_query.UseMutationResult<WorkflowRun, Error, WorkflowRunParams, unknown>;
2476
+ declare function useResolveApproval(source: WorkflowDataSource): _tanstack_react_query.UseMutationResult<{
2477
+ resolved: boolean;
2478
+ }, Error, ResolveApprovalParams, unknown>;
2479
+ interface UseWorkflowLogsOptions {
2480
+ follow?: boolean;
2481
+ idleTimeoutMs?: number;
2482
+ enabled?: boolean;
2483
+ baseUrl?: string;
2484
+ }
2485
+ declare function useWorkflowLogs(runId: string | null, options?: UseWorkflowLogsOptions): {
2486
+ events: WorkflowLogEvent[];
2487
+ error: Error | null;
2488
+ isConnected: boolean;
2489
+ };
2490
+ interface UseWorkflowEventsOptions {
2491
+ follow?: boolean;
2492
+ pollIntervalMs?: number;
2493
+ cursor?: string | null;
2494
+ enabled?: boolean;
2495
+ baseUrl?: string;
2496
+ }
2497
+ declare function useWorkflowEvents(runId: string | null, options?: UseWorkflowEventsOptions): {
2498
+ events: WorkflowPresenterEvent[];
2499
+ error: Error | null;
2500
+ isConnected: boolean;
2501
+ };
2502
+
2503
+ /**
2504
+ * Hook to fetch State Broker statistics
2505
+ *
2506
+ * Auto-refreshes every 5 seconds to show real-time cache metrics
2507
+ */
2508
+ declare function useStateBrokerStats(source: ObservabilityDataSource): _tanstack_react_query.UseQueryResult<StateBrokerStats, Error>;
2509
+ /**
2510
+ * Hook to fetch DevKit health snapshot
2511
+ *
2512
+ * Caches for 1 minute as DevKit health doesn't change frequently
2513
+ */
2514
+ declare function useDevKitHealth(source: ObservabilityDataSource): _tanstack_react_query.UseQueryResult<DevKitHealth, Error>;
2515
+ /**
2516
+ * Hook to fetch Prometheus metrics from REST API
2517
+ *
2518
+ * Auto-refreshes every 10 seconds to show near real-time metrics
2519
+ */
2520
+ declare function usePrometheusMetrics(source: ObservabilityDataSource): _tanstack_react_query.UseQueryResult<PrometheusMetrics, Error>;
2521
+ /**
2522
+ * Hook to connect to system events SSE stream
2523
+ *
2524
+ * Uses ObservabilityDataSource to subscribe to real-time system events
2525
+ */
2526
+ declare function useSystemEvents(source: ObservabilityDataSource): {
2527
+ events: SystemEvent[];
2528
+ isConnected: boolean;
2529
+ error: Error | null;
2530
+ };
2531
+ /**
2532
+ * Hook to connect to live log stream
2533
+ *
2534
+ * Uses ObservabilityDataSource to subscribe to real-time logs
2535
+ *
2536
+ * @param source - Observability data source
2537
+ * @param filters - Optional log filters
2538
+ */
2539
+ declare function useLogStream(source: ObservabilityDataSource, filters?: LogQuery): {
2540
+ logs: LogRecord[];
2541
+ isConnected: boolean;
2542
+ error: Error | null;
2543
+ clearLogs: () => void;
2544
+ };
2545
+ /**
2546
+ * Hook to fetch historical metrics time-series data
2547
+ *
2548
+ * Auto-refreshes every 5 seconds for near real-time charts
2549
+ */
2550
+ declare function useMetricsHistory(source: ObservabilityDataSource, query: MetricsHistoryQuery): _tanstack_react_query.UseQueryResult<HistoricalDataPoint[], Error>;
2551
+ /**
2552
+ * Hook to fetch metrics heatmap data
2553
+ *
2554
+ * Caches for 1 minute as heatmap data changes slowly
2555
+ */
2556
+ declare function useMetricsHeatmap(source: ObservabilityDataSource, query: MetricsHeatmapQuery): _tanstack_react_query.UseQueryResult<HeatmapCell[], Error>;
2557
+ /**
2558
+ * Hook to query incident history
2559
+ *
2560
+ * Auto-refreshes every 30 seconds to show new incidents
2561
+ */
2562
+ declare function useIncidents(source: ObservabilityDataSource, query?: IncidentQuery): _tanstack_react_query.UseQueryResult<Incident[], Error>;
2563
+
2564
+ /**
2565
+ * Hook to fetch analytics events
2566
+ *
2567
+ * @param source - Analytics data source
2568
+ * @param query - Optional query filters
2569
+ */
2570
+ declare function useAnalyticsEvents(source: AnalyticsDataSource, query?: EventsQuery): _tanstack_react_query.UseQueryResult<_kb_labs_core_platform_adapters.EventsResponse, Error>;
2571
+ /**
2572
+ * Hook to fetch analytics stats
2573
+ *
2574
+ * @param source - Analytics data source
2575
+ */
2576
+ declare function useAnalyticsStats(source: AnalyticsDataSource): _tanstack_react_query.UseQueryResult<_kb_labs_core_platform_adapters.EventsStats, Error>;
2577
+ /**
2578
+ * Hook to fetch buffer status
2579
+ *
2580
+ * @param source - Analytics data source
2581
+ */
2582
+ declare function useAnalyticsBufferStatus(source: AnalyticsDataSource): _tanstack_react_query.UseQueryResult<_kb_labs_core_platform_adapters.BufferStatus | null, Error>;
2583
+ /**
2584
+ * Hook to fetch DLQ status
2585
+ *
2586
+ * @param source - Analytics data source
2587
+ */
2588
+ declare function useAnalyticsDlqStatus(source: AnalyticsDataSource): _tanstack_react_query.UseQueryResult<_kb_labs_core_platform_adapters.DlqStatus | null, Error>;
2589
+
2590
+ /**
2591
+ * Hook to fetch LLM usage statistics
2592
+ *
2593
+ * @param source - Adapters data source
2594
+ * @param options - Optional date range filter
2595
+ */
2596
+ declare function useAdaptersLLMUsage(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<LLMUsageStats, Error>;
2597
+ /**
2598
+ * Hook to fetch Embeddings usage statistics
2599
+ *
2600
+ * @param source - Adapters data source
2601
+ * @param options - Optional date range filter
2602
+ */
2603
+ declare function useAdaptersEmbeddingsUsage(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<EmbeddingsUsageStats, Error>;
2604
+ /**
2605
+ * Hook to fetch VectorStore usage statistics
2606
+ *
2607
+ * @param source - Adapters data source
2608
+ * @param options - Optional date range filter
2609
+ */
2610
+ declare function useAdaptersVectorStoreUsage(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<VectorStoreUsageStats, Error>;
2611
+ /**
2612
+ * Hook to fetch Cache usage statistics
2613
+ *
2614
+ * @param source - Adapters data source
2615
+ * @param options - Optional date range filter
2616
+ */
2617
+ declare function useAdaptersCacheUsage(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<CacheUsageStats, Error>;
2618
+ /**
2619
+ * Hook to fetch Storage usage statistics
2620
+ *
2621
+ * @param source - Adapters data source
2622
+ * @param options - Optional date range filter
2623
+ */
2624
+ declare function useAdaptersStorageUsage(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<StorageUsageStats, Error>;
2625
+ /**
2626
+ * Hook to fetch LLM daily statistics for time-series charts
2627
+ *
2628
+ * @param source - Adapters data source
2629
+ * @param options - Optional date range filter
2630
+ */
2631
+ declare function useAdaptersLLMDailyStats(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<DailyStats[], Error>;
2632
+ /**
2633
+ * Hook to fetch Embeddings daily statistics for time-series charts
2634
+ *
2635
+ * @param source - Adapters data source
2636
+ * @param options - Optional date range filter
2637
+ */
2638
+ declare function useAdaptersEmbeddingsDailyStats(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<DailyStats[], Error>;
2639
+ /**
2640
+ * Hook to fetch VectorStore daily statistics for time-series charts
2641
+ *
2642
+ * @param source - Adapters data source
2643
+ * @param options - Optional date range filter
2644
+ */
2645
+ declare function useAdaptersVectorStoreDailyStats(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<DailyStats[], Error>;
2646
+ /**
2647
+ * Hook to fetch Cache daily statistics for time-series charts
2648
+ *
2649
+ * @param source - Adapters data source
2650
+ * @param options - Optional date range filter
2651
+ */
2652
+ declare function useAdaptersCacheDailyStats(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<DailyStats[], Error>;
2653
+ /**
2654
+ * Hook to fetch Storage daily statistics for time-series charts
2655
+ *
2656
+ * @param source - Adapters data source
2657
+ * @param options - Optional date range filter
2658
+ */
2659
+ declare function useAdaptersStorageDailyStats(source: AdaptersDataSource, options?: DateRangeOptions): _tanstack_react_query.UseQueryResult<DailyStats[], Error>;
2660
+
2661
+ /**
2662
+ * Get platform configuration (adapters, options, execution mode)
2663
+ */
2664
+ declare function usePlatformConfig(source: PlatformDataSource): _tanstack_react_query.UseQueryResult<_kb_labs_rest_api_contracts.PlatformConfigPayload, Error>;
2665
+
2666
+ /**
2667
+ * @module @kb-labs/studio-data-client/hooks/types
2668
+ * Types for hooks
2669
+ */
2670
+ /**
2671
+ * Job event types
2672
+ */
2673
+ type JobEventType = 'job.queued' | 'job.started' | 'job.progress' | 'job.finished' | 'job.failed';
2674
+
2675
+ /**
2676
+ * @module @kb-labs/studio-data-client/hooks/use-job-events
2677
+ * React hook for subscribing to job events via SSE with fallback to polling
2678
+ */
2679
+
2680
+ /**
2681
+ * Job event structure
2682
+ */
2683
+ interface JobEvent {
2684
+ type: JobEventType;
2685
+ jobId: string;
2686
+ timestamp: string;
2687
+ data?: {
2688
+ status?: string;
2689
+ progress?: number;
2690
+ error?: string;
2691
+ };
2692
+ }
2693
+ /**
2694
+ * Hook options
2695
+ */
2696
+ interface UseJobEventsOptions {
2697
+ enabled?: boolean;
2698
+ pollInterval?: number;
2699
+ baseUrl?: string;
2700
+ onEvent?: (event: JobEvent) => void;
2701
+ onError?: (error: Error) => void;
2702
+ onComplete?: () => void;
2703
+ }
2704
+ /**
2705
+ * Hook result
2706
+ */
2707
+ interface UseJobEventsResult {
2708
+ events: JobEvent[];
2709
+ isConnected: boolean;
2710
+ error: Error | null;
2711
+ reconnect: () => void;
2712
+ }
2713
+ /**
2714
+ * Use job events hook with SSE support and polling fallback
2715
+ */
2716
+ declare function useJobEvents(jobId: string | null, options?: UseJobEventsOptions): UseJobEventsResult;
2717
+
2718
+ /**
2719
+ * @module @kb-labs/studio-data-client/hooks/use-notifications
2720
+ * React hook for tracking critical log notifications
2721
+ */
2722
+
2723
+ interface LogNotification {
2724
+ id: string;
2725
+ timestamp: string;
2726
+ level: 'warn' | 'error';
2727
+ message: string;
2728
+ plugin?: string;
2729
+ executionId?: string;
2730
+ error?: {
2731
+ name: string;
2732
+ message: string;
2733
+ };
2734
+ read: boolean;
2735
+ }
2736
+ interface UseNotificationsResult {
2737
+ notifications: LogNotification[];
2738
+ unreadCount: number;
2739
+ markAsRead: (id: string) => void;
2740
+ markAllAsRead: () => void;
2741
+ clearAll: () => void;
2742
+ clearNotification: (id: string) => void;
2743
+ }
2744
+ /**
2745
+ * Hook to track critical log notifications (warn/error) from SSE stream
2746
+ *
2747
+ * Automatically subscribes to log stream and filters warn/error logs.
2748
+ * Maintains a list of recent critical logs with read/unread status.
2749
+ *
2750
+ * @param source - Observability data source
2751
+ * @param maxNotifications - Maximum number of notifications to keep (default: 50)
2752
+ */
2753
+ declare function useNotifications(source: ObservabilityDataSource, maxNotifications?: number): UseNotificationsResult;
2754
+
2755
+ export { type ActionResult, type AdaptersDataSource, type AnalyticsDataSource, type CacheDataSource, type CacheInvalidationResult, type CacheUsageStats, type CronInfo, type CronListResponse, type DailyStats, type DashboardStatsResponse, type DataSources, type DataSourcesConfig, type DateRangeOptions, type DevKitHealth, type EmbeddingsUsageStats, type ErrorInterceptor, type FetchOptions, type HealthEvent, type HealthStatus, type HeatmapCell, type HistoricalDataPoint, HttpAdaptersSource, HttpAnalyticsSource, HttpCacheSource, HttpClient, HttpObservabilitySource, HttpPlatformSource, HttpPluginsSource, HttpSystemSource, HttpWorkflowSource, type ID, type ISODate, type Incident, type IncidentAnalysis, type IncidentAnalysisResponse, type IncidentCreatePayload, type IncidentDetailResponse, type IncidentQuery, type IncidentResolveRequest, type IncidentSeverity, type IncidentType, type IncidentsListResponse, type JobEvent, type JobEventType, type JobListFilter, type JobListResponse, type JobLogsResponse, type JobRun, type JobStatusInfo, type JobStepInfo, type JobStepsResponse, KBError, type LLMModelStats, type LLMUsageStats, type LogEvent, type LogNotification, type LogQuery, type LogQueryResponse, type LogRecord, type LogStats, type LogSummarizeContext, type LogSummarizeRequest, type LogSummarizeResponse, type MetricsHeatmapQuery, type MetricsHistoryQuery, MockAdaptersSource, MockAnalyticsSource, MockCacheSource, MockObservabilitySource, MockPlatformSource, MockPluginsSource, MockSystemSource, MockWorkflowSource, type NamespaceStats, type ObservabilityDataSource, type PackageRef, type PendingApproval, type PendingApprovalsResponse, type PlatformDataSource, type PluginAskRequest, type PluginAskResponse, type PluginManifestEntry, type PluginMetrics, type PluginSource, type PluginsDataSource, type PluginsRegistryResponse, type PrometheusMetrics, type RegistryEvent, type RelatedData, type RelatedLogsData, type RelatedMetricsData, type RequestInterceptor, type ResolveApprovalParams, type ResponseError, type ResponseInterceptor, type RootCauseItem, type RouteInfo, type RoutesResponse, type RunRef, SCHEMA_VERSION, type SlowRequest, type StateBrokerStats, type StepRun, type StorageUsageStats, type SystemDataSource, type SystemEvent, type TenantMetrics, type TimelineEvent, type UseJobEventsOptions, type UseJobEventsResult, type UseNotificationsResult, type UseWorkflowEventsOptions, type UseWorkflowLogsOptions, type VectorStoreUsageStats, type WorkflowDataSource, type WorkflowExecutionResult, type WorkflowInfo, type WorkflowListResponse, type WorkflowLogEvent, type WorkflowPresenterEvent, type WorkflowResultError, type WorkflowResultMetrics, type WorkflowRun, type WorkflowRunHistoryResponse, type WorkflowRunInfo, type WorkflowRunParams, type WorkflowRunResponse, type WorkflowRunsFilters, type WorkflowRunsListResponse, type WorkflowSpec, type WorkflowStatus, type WorkflowTrigger, actionResultSchema, auditCheckSchema, auditPackageReportSchema, auditSummarySchema, createDataSources, createEnvelopeInterceptor, errorCodes, extractEnvelopeMeta, healthStatusSchema, idSchema, isoDateSchema, mapErrorEnvelope, mapFetchError, packageRefSchema, qk, queryKeys, releasePreviewSchema, runRefSchema, useAdaptersCacheDailyStats, useAdaptersCacheUsage, useAdaptersEmbeddingsDailyStats, useAdaptersEmbeddingsUsage, useAdaptersLLMDailyStats, useAdaptersLLMUsage, useAdaptersStorageDailyStats, useAdaptersStorageUsage, useAdaptersVectorStoreDailyStats, useAdaptersVectorStoreUsage, useAnalyticsBufferStatus, useAnalyticsDlqStatus, useAnalyticsEvents, useAnalyticsStats, useCancelWorkflowRun, useCapabilities, useDevKitHealth, useHealthStatus, useIncidents, useJobEvents, useLogStream, useMetricsHeatmap, useMetricsHistory, useNotifications, usePlatformConfig, usePrometheusMetrics, useReadyStatus, useResolveApproval, useRunWorkflow, useStateBrokerStats, useSystemEvents, useSystemInfo, useWorkflowEvents, useWorkflowLogs, useWorkflowRun, useWorkflowRuns };