@kb-labs/core-platform 1.0.0 → 1.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.
Files changed (29) hide show
  1. package/dist/adapters/index.d.cts +5 -5
  2. package/dist/adapters/index.d.ts +5 -5
  3. package/dist/artifacts-CrJhdBm-.d.cts +74 -0
  4. package/dist/artifacts-CrJhdBm-.d.ts +74 -0
  5. package/dist/{artifacts-BUghvkUU.d.cts → database-CJ5eZJB8.d.ts} +61 -14
  6. package/dist/{artifacts-Bd-1UVTw.d.ts → database-DUeYQUg-.d.cts} +61 -14
  7. package/dist/index.d.cts +10 -8
  8. package/dist/index.d.ts +10 -8
  9. package/dist/{artifacts-DrVnkLzu.d.cts → invoke-BzOIin5Z.d.cts} +427 -74
  10. package/dist/{artifacts-DrVnkLzu.d.ts → invoke-BzOIin5Z.d.ts} +427 -74
  11. package/dist/{log-reader-uOHBLBax.d.ts → log-reader-B8HGaAKp.d.ts} +1 -1
  12. package/dist/{log-reader-BVohbSMB.d.cts → log-reader-DwHla8Sz.d.cts} +1 -1
  13. package/dist/noop/adapters/index.d.cts +16 -63
  14. package/dist/noop/adapters/index.d.ts +16 -63
  15. package/dist/noop/index.cjs +34 -33
  16. package/dist/noop/index.cjs.map +1 -1
  17. package/dist/noop/index.d.cts +4 -4
  18. package/dist/noop/index.d.ts +4 -4
  19. package/dist/noop/index.js +33 -33
  20. package/dist/noop/index.js.map +1 -1
  21. package/dist/serializable/index.cjs.map +1 -1
  22. package/dist/serializable/index.d.cts +2 -0
  23. package/dist/serializable/index.d.ts +2 -0
  24. package/dist/serializable/index.js.map +1 -1
  25. package/dist/{snapshot-provider--COac4P-.d.ts → snapshot-provider-BeZmFkse.d.cts} +49 -99
  26. package/dist/{snapshot-provider-nE9wuc1C.d.cts → snapshot-provider-CNO_x3lV.d.ts} +49 -99
  27. package/package.json +14 -14
  28. package/dist/database-DGV6a1nj.d.cts +0 -427
  29. package/dist/database-DGV6a1nj.d.ts +0 -427
@@ -1,5 +1,4 @@
1
- import { L as LogRecord, a as LogQuery } from './artifacts-DrVnkLzu.js';
2
- import { I as ISQLDatabase } from './database-DGV6a1nj.js';
1
+ import { L as LogRecord, a as LogQuery, W as ISQLDatabase } from './invoke-BzOIin5Z.cjs';
3
2
 
4
3
  /**
5
4
  * @module @kb-labs/core-platform/adapters/adapter-manifest
@@ -526,6 +525,15 @@ interface ILogPersistence {
526
525
  /** Storage size in bytes */
527
526
  sizeBytes: number;
528
527
  }>;
528
+ /**
529
+ * Delete logs matching specific levels older than specified timestamp.
530
+ * Allows per-level retention policies (e.g., keep errors longer than debug).
531
+ *
532
+ * @param levels - Log levels to delete (e.g., ['debug', 'trace'])
533
+ * @param beforeTimestamp - Delete logs before this timestamp (milliseconds)
534
+ * @returns Promise with number of deleted logs
535
+ */
536
+ deleteByLevelOlderThan?(levels: string[], beforeTimestamp: number): Promise<number>;
529
537
  /**
530
538
  * Close persistence adapter and flush pending writes.
531
539
  * Should be called during application shutdown.
@@ -534,6 +542,41 @@ interface ILogPersistence {
534
542
  */
535
543
  close?(): Promise<void>;
536
544
  }
545
+ /**
546
+ * Log retention policy configuration.
547
+ * Controls automatic cleanup of old logs and database size limits.
548
+ *
549
+ * Defaults are applied when retention is omitted — logs are never unbounded.
550
+ */
551
+ interface LogRetentionPolicy {
552
+ /**
553
+ * Max age for warn/error/fatal logs in milliseconds.
554
+ * @default 604800000 (7 days)
555
+ */
556
+ maxAge?: number;
557
+ /**
558
+ * Max age for debug/trace logs in milliseconds.
559
+ * Set to 0 to disable debug/trace persistence entirely.
560
+ * @default 3600000 (1 hour)
561
+ */
562
+ maxAgeDebug?: number;
563
+ /**
564
+ * Max age for info logs in milliseconds.
565
+ * @default 86400000 (24 hours)
566
+ */
567
+ maxAgeInfo?: number;
568
+ /**
569
+ * Maximum database size in bytes.
570
+ * When exceeded, oldest logs are deleted until size is under limit.
571
+ * @default 524288000 (500 MB)
572
+ */
573
+ maxSizeBytes?: number;
574
+ /**
575
+ * How often to run retention cleanup in milliseconds.
576
+ * @default 300000 (5 minutes)
577
+ */
578
+ cleanupIntervalMs?: number;
579
+ }
537
580
  /**
538
581
  * Configuration for log persistence adapter.
539
582
  */
@@ -560,104 +603,11 @@ interface LogPersistenceConfig {
560
603
  * @default 5000 (5 seconds)
561
604
  */
562
605
  flushInterval?: number;
563
- }
564
-
565
- /**
566
- * @module @kb-labs/core-platform/adapters/execution
567
- * Execution backend interface (plugin execution layer).
568
- */
569
- /**
570
- * Execution backend interface.
571
- * Handles plugin execution (in-process, worker-pool, or remote).
572
- *
573
- * Implementations:
574
- * - InProcessBackend: Same process, no isolation (dev mode)
575
- * - WorkerPoolBackend: Worker pool with fault isolation (production)
576
- * - RemoteExecutionBackend: Remote executor service (Phase 3)
577
- */
578
- interface IExecutionBackend {
579
606
  /**
580
- * Execute a plugin handler.
581
- *
582
- * @param request - Execution request with descriptor, pluginRoot, handlerRef
583
- * @param options - Optional execution options (signal, etc.)
584
- * @returns Execution result with data/error
607
+ * Retention policy for automatic log cleanup.
608
+ * Defaults are applied to prevent unbounded database growth.
585
609
  */
586
- execute(request: ExecutionRequest, options?: ExecuteOptions): Promise<ExecutionResult>;
587
- /**
588
- * Shutdown execution backend gracefully.
589
- * Closes worker pool, cleanup resources.
590
- */
591
- shutdown(): Promise<void>;
592
- }
593
- /**
594
- * Execution options (optional).
595
- */
596
- interface ExecuteOptions {
597
- /** Abort signal for cancellation */
598
- signal?: AbortSignal;
599
- /** Additional options */
600
- [key: string]: unknown;
601
- }
602
- /**
603
- * Execution request - minimal interface for core-platform.
604
- * Full implementation in @kb-labs/plugin-execution.
605
- */
606
- interface ExecutionRequest {
607
- /** Unique execution ID */
608
- executionId: string;
609
- /**
610
- * Runtime descriptor containing execution context.
611
- *
612
- * Type is `any` to allow implementations to use their concrete descriptor types
613
- * (e.g., PluginContextDescriptor from @kb-labs/plugin-contracts).
614
- *
615
- * This is intentional for interface contracts - concrete type determined by implementation.
616
- */
617
- descriptor: any;
618
- /** Plugin root directory (absolute path) */
619
- pluginRoot: string;
620
- /** Handler reference (relative path) */
621
- handlerRef: string;
622
- /** Input data passed to handler */
623
- input: unknown;
624
- /** Execution timeout in milliseconds */
625
- timeoutMs?: number;
626
- /** Optional execution target affinity */
627
- target?: {
628
- environmentId?: string;
629
- workspaceId?: string;
630
- namespace?: string;
631
- workdir?: string;
632
- };
633
- /** Additional configuration */
634
- [key: string]: unknown;
635
- }
636
- /**
637
- * Execution result - minimal interface for core-platform.
638
- * Full implementation in @kb-labs/plugin-execution.
639
- */
640
- interface ExecutionResult {
641
- /** Success flag */
642
- ok: boolean;
643
- /** Result data (if ok) */
644
- data?: unknown;
645
- /**
646
- * Error details (if !ok).
647
- * Type is `any` to allow implementations to use their own error types.
648
- * Expected to have at least { message: string } structure.
649
- */
650
- error?: any;
651
- /** Execution time in milliseconds */
652
- executionTimeMs: number;
653
- /**
654
- * Execution metadata (optional).
655
- * Contains backend-specific info, timing, plugin info.
656
- * Type is `any` to allow implementations to extend with their own metadata types.
657
- */
658
- metadata?: any;
659
- /** Additional fields allowed for extensibility */
660
- [key: string]: unknown;
610
+ retention?: LogRetentionPolicy;
661
611
  }
662
612
 
663
613
  /**
@@ -920,4 +870,4 @@ interface ISnapshotProvider {
920
870
  getCapabilities?(): SnapshotProviderCapabilities;
921
871
  }
922
872
 
923
- export type { AdapterManifest as A, RestoreSnapshotResult as B, CreateEnvironmentRequest as C, SnapshotStatusResult as D, ExecutionRequest as E, SnapshotGarbageCollectRequest as F, SnapshotGarbageCollectResult as G, SnapshotProviderCapabilities as H, ILogPersistence as I, LogPersistenceConfig as L, MaterializeWorkspaceRequest as M, RestoreSnapshotRequest as R, SnapshotStatus as S, WorkspaceStatus as W, AdapterType as a, AdapterDependency as b, AdapterExtension as c, AdapterCapabilities as d, AdapterFactory as e, IExecutionBackend as f, ExecutionResult as g, ExecuteOptions as h, IEnvironmentProvider as i, EnvironmentStatus as j, EnvironmentResources as k, EnvironmentLease as l, EnvironmentEndpoint as m, EnvironmentDescriptor as n, EnvironmentStatusResult as o, EnvironmentProviderCapabilities as p, IWorkspaceProvider as q, WorkspaceMount as r, WorkspaceDescriptor as s, AttachWorkspaceRequest as t, WorkspaceAttachment as u, WorkspaceStatusResult as v, WorkspaceProviderCapabilities as w, ISnapshotProvider as x, CaptureSnapshotRequest as y, SnapshotDescriptor as z };
873
+ export type { AdapterManifest as A, SnapshotGarbageCollectResult as B, CreateEnvironmentRequest as C, SnapshotProviderCapabilities as D, EnvironmentStatus as E, ILogPersistence as I, LogPersistenceConfig as L, MaterializeWorkspaceRequest as M, RestoreSnapshotRequest as R, SnapshotStatus as S, WorkspaceStatus as W, AdapterType as a, AdapterDependency as b, AdapterExtension as c, AdapterCapabilities as d, AdapterFactory as e, LogRetentionPolicy as f, IEnvironmentProvider as g, EnvironmentResources as h, EnvironmentLease as i, EnvironmentEndpoint as j, EnvironmentDescriptor as k, EnvironmentStatusResult as l, EnvironmentProviderCapabilities as m, IWorkspaceProvider as n, WorkspaceMount as o, WorkspaceDescriptor as p, AttachWorkspaceRequest as q, WorkspaceAttachment as r, WorkspaceStatusResult as s, WorkspaceProviderCapabilities as t, ISnapshotProvider as u, CaptureSnapshotRequest as v, SnapshotDescriptor as w, RestoreSnapshotResult as x, SnapshotStatusResult as y, SnapshotGarbageCollectRequest as z };
@@ -1,5 +1,4 @@
1
- import { L as LogRecord, a as LogQuery } from './artifacts-DrVnkLzu.cjs';
2
- import { I as ISQLDatabase } from './database-DGV6a1nj.cjs';
1
+ import { L as LogRecord, a as LogQuery, W as ISQLDatabase } from './invoke-BzOIin5Z.js';
3
2
 
4
3
  /**
5
4
  * @module @kb-labs/core-platform/adapters/adapter-manifest
@@ -526,6 +525,15 @@ interface ILogPersistence {
526
525
  /** Storage size in bytes */
527
526
  sizeBytes: number;
528
527
  }>;
528
+ /**
529
+ * Delete logs matching specific levels older than specified timestamp.
530
+ * Allows per-level retention policies (e.g., keep errors longer than debug).
531
+ *
532
+ * @param levels - Log levels to delete (e.g., ['debug', 'trace'])
533
+ * @param beforeTimestamp - Delete logs before this timestamp (milliseconds)
534
+ * @returns Promise with number of deleted logs
535
+ */
536
+ deleteByLevelOlderThan?(levels: string[], beforeTimestamp: number): Promise<number>;
529
537
  /**
530
538
  * Close persistence adapter and flush pending writes.
531
539
  * Should be called during application shutdown.
@@ -534,6 +542,41 @@ interface ILogPersistence {
534
542
  */
535
543
  close?(): Promise<void>;
536
544
  }
545
+ /**
546
+ * Log retention policy configuration.
547
+ * Controls automatic cleanup of old logs and database size limits.
548
+ *
549
+ * Defaults are applied when retention is omitted — logs are never unbounded.
550
+ */
551
+ interface LogRetentionPolicy {
552
+ /**
553
+ * Max age for warn/error/fatal logs in milliseconds.
554
+ * @default 604800000 (7 days)
555
+ */
556
+ maxAge?: number;
557
+ /**
558
+ * Max age for debug/trace logs in milliseconds.
559
+ * Set to 0 to disable debug/trace persistence entirely.
560
+ * @default 3600000 (1 hour)
561
+ */
562
+ maxAgeDebug?: number;
563
+ /**
564
+ * Max age for info logs in milliseconds.
565
+ * @default 86400000 (24 hours)
566
+ */
567
+ maxAgeInfo?: number;
568
+ /**
569
+ * Maximum database size in bytes.
570
+ * When exceeded, oldest logs are deleted until size is under limit.
571
+ * @default 524288000 (500 MB)
572
+ */
573
+ maxSizeBytes?: number;
574
+ /**
575
+ * How often to run retention cleanup in milliseconds.
576
+ * @default 300000 (5 minutes)
577
+ */
578
+ cleanupIntervalMs?: number;
579
+ }
537
580
  /**
538
581
  * Configuration for log persistence adapter.
539
582
  */
@@ -560,104 +603,11 @@ interface LogPersistenceConfig {
560
603
  * @default 5000 (5 seconds)
561
604
  */
562
605
  flushInterval?: number;
563
- }
564
-
565
- /**
566
- * @module @kb-labs/core-platform/adapters/execution
567
- * Execution backend interface (plugin execution layer).
568
- */
569
- /**
570
- * Execution backend interface.
571
- * Handles plugin execution (in-process, worker-pool, or remote).
572
- *
573
- * Implementations:
574
- * - InProcessBackend: Same process, no isolation (dev mode)
575
- * - WorkerPoolBackend: Worker pool with fault isolation (production)
576
- * - RemoteExecutionBackend: Remote executor service (Phase 3)
577
- */
578
- interface IExecutionBackend {
579
606
  /**
580
- * Execute a plugin handler.
581
- *
582
- * @param request - Execution request with descriptor, pluginRoot, handlerRef
583
- * @param options - Optional execution options (signal, etc.)
584
- * @returns Execution result with data/error
607
+ * Retention policy for automatic log cleanup.
608
+ * Defaults are applied to prevent unbounded database growth.
585
609
  */
586
- execute(request: ExecutionRequest, options?: ExecuteOptions): Promise<ExecutionResult>;
587
- /**
588
- * Shutdown execution backend gracefully.
589
- * Closes worker pool, cleanup resources.
590
- */
591
- shutdown(): Promise<void>;
592
- }
593
- /**
594
- * Execution options (optional).
595
- */
596
- interface ExecuteOptions {
597
- /** Abort signal for cancellation */
598
- signal?: AbortSignal;
599
- /** Additional options */
600
- [key: string]: unknown;
601
- }
602
- /**
603
- * Execution request - minimal interface for core-platform.
604
- * Full implementation in @kb-labs/plugin-execution.
605
- */
606
- interface ExecutionRequest {
607
- /** Unique execution ID */
608
- executionId: string;
609
- /**
610
- * Runtime descriptor containing execution context.
611
- *
612
- * Type is `any` to allow implementations to use their concrete descriptor types
613
- * (e.g., PluginContextDescriptor from @kb-labs/plugin-contracts).
614
- *
615
- * This is intentional for interface contracts - concrete type determined by implementation.
616
- */
617
- descriptor: any;
618
- /** Plugin root directory (absolute path) */
619
- pluginRoot: string;
620
- /** Handler reference (relative path) */
621
- handlerRef: string;
622
- /** Input data passed to handler */
623
- input: unknown;
624
- /** Execution timeout in milliseconds */
625
- timeoutMs?: number;
626
- /** Optional execution target affinity */
627
- target?: {
628
- environmentId?: string;
629
- workspaceId?: string;
630
- namespace?: string;
631
- workdir?: string;
632
- };
633
- /** Additional configuration */
634
- [key: string]: unknown;
635
- }
636
- /**
637
- * Execution result - minimal interface for core-platform.
638
- * Full implementation in @kb-labs/plugin-execution.
639
- */
640
- interface ExecutionResult {
641
- /** Success flag */
642
- ok: boolean;
643
- /** Result data (if ok) */
644
- data?: unknown;
645
- /**
646
- * Error details (if !ok).
647
- * Type is `any` to allow implementations to use their own error types.
648
- * Expected to have at least { message: string } structure.
649
- */
650
- error?: any;
651
- /** Execution time in milliseconds */
652
- executionTimeMs: number;
653
- /**
654
- * Execution metadata (optional).
655
- * Contains backend-specific info, timing, plugin info.
656
- * Type is `any` to allow implementations to extend with their own metadata types.
657
- */
658
- metadata?: any;
659
- /** Additional fields allowed for extensibility */
660
- [key: string]: unknown;
610
+ retention?: LogRetentionPolicy;
661
611
  }
662
612
 
663
613
  /**
@@ -920,4 +870,4 @@ interface ISnapshotProvider {
920
870
  getCapabilities?(): SnapshotProviderCapabilities;
921
871
  }
922
872
 
923
- export type { AdapterManifest as A, RestoreSnapshotResult as B, CreateEnvironmentRequest as C, SnapshotStatusResult as D, ExecutionRequest as E, SnapshotGarbageCollectRequest as F, SnapshotGarbageCollectResult as G, SnapshotProviderCapabilities as H, ILogPersistence as I, LogPersistenceConfig as L, MaterializeWorkspaceRequest as M, RestoreSnapshotRequest as R, SnapshotStatus as S, WorkspaceStatus as W, AdapterType as a, AdapterDependency as b, AdapterExtension as c, AdapterCapabilities as d, AdapterFactory as e, IExecutionBackend as f, ExecutionResult as g, ExecuteOptions as h, IEnvironmentProvider as i, EnvironmentStatus as j, EnvironmentResources as k, EnvironmentLease as l, EnvironmentEndpoint as m, EnvironmentDescriptor as n, EnvironmentStatusResult as o, EnvironmentProviderCapabilities as p, IWorkspaceProvider as q, WorkspaceMount as r, WorkspaceDescriptor as s, AttachWorkspaceRequest as t, WorkspaceAttachment as u, WorkspaceStatusResult as v, WorkspaceProviderCapabilities as w, ISnapshotProvider as x, CaptureSnapshotRequest as y, SnapshotDescriptor as z };
873
+ export type { AdapterManifest as A, SnapshotGarbageCollectResult as B, CreateEnvironmentRequest as C, SnapshotProviderCapabilities as D, EnvironmentStatus as E, ILogPersistence as I, LogPersistenceConfig as L, MaterializeWorkspaceRequest as M, RestoreSnapshotRequest as R, SnapshotStatus as S, WorkspaceStatus as W, AdapterType as a, AdapterDependency as b, AdapterExtension as c, AdapterCapabilities as d, AdapterFactory as e, LogRetentionPolicy as f, IEnvironmentProvider as g, EnvironmentResources as h, EnvironmentLease as i, EnvironmentEndpoint as j, EnvironmentDescriptor as k, EnvironmentStatusResult as l, EnvironmentProviderCapabilities as m, IWorkspaceProvider as n, WorkspaceMount as o, WorkspaceDescriptor as p, AttachWorkspaceRequest as q, WorkspaceAttachment as r, WorkspaceStatusResult as s, WorkspaceProviderCapabilities as t, ISnapshotProvider as u, CaptureSnapshotRequest as v, SnapshotDescriptor as w, RestoreSnapshotResult as x, SnapshotStatusResult as y, SnapshotGarbageCollectRequest as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kb-labs/core-platform",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Pure abstractions for KB Labs platform with minimal dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -46,6 +46,17 @@
46
46
  "files": [
47
47
  "dist"
48
48
  ],
49
+ "scripts": {
50
+ "build": "tsup",
51
+ "clean": "rimraf dist",
52
+ "typecheck": "tsc --noEmit",
53
+ "test": "vitest run --passWithNoTests",
54
+ "test:watch": "vitest",
55
+ "dev": "tsup --config tsup.config.ts --watch",
56
+ "lint": "eslint src --ext .ts",
57
+ "lint:fix": "eslint . --fix",
58
+ "type-check": "tsc --noEmit"
59
+ },
49
60
  "dependencies": {
50
61
  "ulid": "^2.3.0"
51
62
  },
@@ -54,7 +65,7 @@
54
65
  "typescript": "^5.6.3",
55
66
  "rimraf": "^6.0.1",
56
67
  "vitest": "^3.2.4",
57
- "@kb-labs/devkit": "link:../../../kb-labs-devkit",
68
+ "@kb-labs/devkit": "^1.0.0",
58
69
  "@types/node": "^24.3.3"
59
70
  },
60
71
  "keywords": [
@@ -77,16 +88,5 @@
77
88
  },
78
89
  "publishConfig": {
79
90
  "access": "public"
80
- },
81
- "scripts": {
82
- "build": "tsup",
83
- "clean": "rimraf dist",
84
- "typecheck": "tsc --noEmit",
85
- "test": "vitest run --passWithNoTests",
86
- "test:watch": "vitest",
87
- "dev": "tsup --config tsup.config.ts --watch",
88
- "lint": "eslint src --ext .ts",
89
- "lint:fix": "eslint . --fix",
90
- "type-check": "tsc --noEmit"
91
91
  }
92
- }
92
+ }