@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.
- package/dist/adapters/index.d.cts +5 -5
- package/dist/adapters/index.d.ts +5 -5
- package/dist/artifacts-CrJhdBm-.d.cts +74 -0
- package/dist/artifacts-CrJhdBm-.d.ts +74 -0
- package/dist/{artifacts-BUghvkUU.d.cts → database-CJ5eZJB8.d.ts} +61 -14
- package/dist/{artifacts-Bd-1UVTw.d.ts → database-DUeYQUg-.d.cts} +61 -14
- package/dist/index.d.cts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/{artifacts-DrVnkLzu.d.cts → invoke-BzOIin5Z.d.cts} +427 -74
- package/dist/{artifacts-DrVnkLzu.d.ts → invoke-BzOIin5Z.d.ts} +427 -74
- package/dist/{log-reader-uOHBLBax.d.ts → log-reader-B8HGaAKp.d.ts} +1 -1
- package/dist/{log-reader-BVohbSMB.d.cts → log-reader-DwHla8Sz.d.cts} +1 -1
- package/dist/noop/adapters/index.d.cts +16 -63
- package/dist/noop/adapters/index.d.ts +16 -63
- package/dist/noop/index.cjs +34 -33
- package/dist/noop/index.cjs.map +1 -1
- package/dist/noop/index.d.cts +4 -4
- package/dist/noop/index.d.ts +4 -4
- package/dist/noop/index.js +33 -33
- package/dist/noop/index.js.map +1 -1
- package/dist/serializable/index.cjs.map +1 -1
- package/dist/serializable/index.d.cts +2 -0
- package/dist/serializable/index.d.ts +2 -0
- package/dist/serializable/index.js.map +1 -1
- package/dist/{snapshot-provider--COac4P-.d.ts → snapshot-provider-BeZmFkse.d.cts} +49 -99
- package/dist/{snapshot-provider-nE9wuc1C.d.cts → snapshot-provider-CNO_x3lV.d.ts} +49 -99
- package/package.json +14 -14
- package/dist/database-DGV6a1nj.d.cts +0 -427
- package/dist/database-DGV6a1nj.d.ts +0 -427
|
@@ -1196,6 +1196,432 @@ interface ILogger {
|
|
|
1196
1196
|
onLog?(callback: (record: LogRecord) => void): () => void;
|
|
1197
1197
|
}
|
|
1198
1198
|
|
|
1199
|
+
/**
|
|
1200
|
+
* @module @kb-labs/core-platform/adapters/database
|
|
1201
|
+
* Database abstraction for SQL, Document, KV, and TimeSeries databases.
|
|
1202
|
+
*
|
|
1203
|
+
* Design principles:
|
|
1204
|
+
* - Unified interface across SQL, NoSQL, KV, TimeSeries
|
|
1205
|
+
* - Permission-aware (checked at runtime)
|
|
1206
|
+
* - Backend-agnostic (SQLite, Postgres, Mongo, Redis, etc.)
|
|
1207
|
+
*/
|
|
1208
|
+
/**
|
|
1209
|
+
* Result of a SQL query execution.
|
|
1210
|
+
*/
|
|
1211
|
+
interface SQLQueryResult<T = unknown> {
|
|
1212
|
+
/** Rows returned by SELECT queries */
|
|
1213
|
+
rows: T[];
|
|
1214
|
+
/** Number of rows affected by INSERT/UPDATE/DELETE */
|
|
1215
|
+
rowCount: number;
|
|
1216
|
+
/** Column metadata (names, types) */
|
|
1217
|
+
fields?: Array<{
|
|
1218
|
+
name: string;
|
|
1219
|
+
type: string;
|
|
1220
|
+
}>;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* SQL transaction interface.
|
|
1224
|
+
* Supports ACID transactions with explicit commit/rollback.
|
|
1225
|
+
*/
|
|
1226
|
+
interface SQLTransaction {
|
|
1227
|
+
/**
|
|
1228
|
+
* Execute a SQL query within the transaction.
|
|
1229
|
+
* @param sql - SQL query string
|
|
1230
|
+
* @param params - Query parameters (prevents SQL injection)
|
|
1231
|
+
* @returns Query result
|
|
1232
|
+
*/
|
|
1233
|
+
query<T = unknown>(sql: string, params?: unknown[]): Promise<SQLQueryResult<T>>;
|
|
1234
|
+
/**
|
|
1235
|
+
* Commit the transaction.
|
|
1236
|
+
* All changes are persisted to the database.
|
|
1237
|
+
*/
|
|
1238
|
+
commit(): Promise<void>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Rollback the transaction.
|
|
1241
|
+
* All changes are discarded.
|
|
1242
|
+
*/
|
|
1243
|
+
rollback(): Promise<void>;
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* SQL database adapter interface.
|
|
1247
|
+
*
|
|
1248
|
+
* **Security model:**
|
|
1249
|
+
* - Permission enforcement happens at runtime (SecureSQLDatabase wrapper)
|
|
1250
|
+
* - SQL parsing extracts table names for permission checks
|
|
1251
|
+
* - Validation-only approach (no query rewriting)
|
|
1252
|
+
*
|
|
1253
|
+
* **Implementations:**
|
|
1254
|
+
* - `@kb-labs/adapters-db-sqlite` - SQLite (file-based, embedded)
|
|
1255
|
+
* - `@kb-labs/adapters-db-postgres` - PostgreSQL (network)
|
|
1256
|
+
* - `NoOpSQLDatabase` - No-op adapter for testing
|
|
1257
|
+
*/
|
|
1258
|
+
interface ISQLDatabase {
|
|
1259
|
+
/**
|
|
1260
|
+
* Execute a SQL query.
|
|
1261
|
+
*
|
|
1262
|
+
* @param sql - SQL query string (SELECT, INSERT, UPDATE, DELETE, etc.)
|
|
1263
|
+
* @param params - Query parameters (prevents SQL injection)
|
|
1264
|
+
* @returns Query result
|
|
1265
|
+
*
|
|
1266
|
+
* **Security:**
|
|
1267
|
+
* - Runtime permission check: extracts table names from SQL
|
|
1268
|
+
* - Validates against `permissions.platform.database.sql.tables`
|
|
1269
|
+
* - Throws PermissionError if access denied
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* ```typescript
|
|
1273
|
+
* const result = await db.query<{ id: number; name: string }>(
|
|
1274
|
+
* 'SELECT id, name FROM users WHERE age > ?',
|
|
1275
|
+
* [18]
|
|
1276
|
+
* );
|
|
1277
|
+
* console.log(result.rows); // [{ id: 1, name: 'Alice' }, ...]
|
|
1278
|
+
* ```
|
|
1279
|
+
*/
|
|
1280
|
+
query<T = unknown>(sql: string, params?: unknown[]): Promise<SQLQueryResult<T>>;
|
|
1281
|
+
/**
|
|
1282
|
+
* Begin a SQL transaction.
|
|
1283
|
+
*
|
|
1284
|
+
* @returns Transaction object
|
|
1285
|
+
*
|
|
1286
|
+
* **Usage:**
|
|
1287
|
+
* ```typescript
|
|
1288
|
+
* const tx = await db.transaction();
|
|
1289
|
+
* try {
|
|
1290
|
+
* await tx.query('INSERT INTO users (name) VALUES (?)', ['Alice']);
|
|
1291
|
+
* await tx.query('INSERT INTO audit_log (action) VALUES (?)', ['user_created']);
|
|
1292
|
+
* await tx.commit();
|
|
1293
|
+
* } catch (err) {
|
|
1294
|
+
* await tx.rollback();
|
|
1295
|
+
* throw err;
|
|
1296
|
+
* }
|
|
1297
|
+
* ```
|
|
1298
|
+
*/
|
|
1299
|
+
transaction(): Promise<SQLTransaction>;
|
|
1300
|
+
/**
|
|
1301
|
+
* Close database connection.
|
|
1302
|
+
* Should be called on shutdown.
|
|
1303
|
+
*/
|
|
1304
|
+
close(): Promise<void>;
|
|
1305
|
+
/**
|
|
1306
|
+
* Execute raw SQL (for schema migrations).
|
|
1307
|
+
* Optional utility method - not all database adapters may support this.
|
|
1308
|
+
* Better-sqlite3's exec() handles multiple statements separated by semicolons.
|
|
1309
|
+
*
|
|
1310
|
+
* @param sql - Raw SQL string (may contain multiple statements)
|
|
1311
|
+
*/
|
|
1312
|
+
exec?(sql: string): Promise<void>;
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Base document type - all documents must have id, createdAt, updatedAt.
|
|
1316
|
+
*/
|
|
1317
|
+
interface BaseDocument {
|
|
1318
|
+
id: string;
|
|
1319
|
+
createdAt: number;
|
|
1320
|
+
updatedAt: number;
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* MongoDB-style query operators.
|
|
1324
|
+
*/
|
|
1325
|
+
interface FilterOperators<T> {
|
|
1326
|
+
$eq?: T;
|
|
1327
|
+
$ne?: T;
|
|
1328
|
+
$gt?: T;
|
|
1329
|
+
$gte?: T;
|
|
1330
|
+
$lt?: T;
|
|
1331
|
+
$lte?: T;
|
|
1332
|
+
$in?: T[];
|
|
1333
|
+
$nin?: T[];
|
|
1334
|
+
$exists?: boolean;
|
|
1335
|
+
$regex?: string;
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Document filter - MongoDB-style query syntax.
|
|
1339
|
+
*/
|
|
1340
|
+
type DocumentFilter<T> = {
|
|
1341
|
+
[K in keyof T]?: T[K] | FilterOperators<T[K]>;
|
|
1342
|
+
} & {
|
|
1343
|
+
$and?: DocumentFilter<T>[];
|
|
1344
|
+
$or?: DocumentFilter<T>[];
|
|
1345
|
+
};
|
|
1346
|
+
/**
|
|
1347
|
+
* MongoDB-style update operators.
|
|
1348
|
+
*/
|
|
1349
|
+
interface DocumentUpdate<T> {
|
|
1350
|
+
$set?: Partial<T>;
|
|
1351
|
+
$unset?: {
|
|
1352
|
+
[K in keyof T]?: 1;
|
|
1353
|
+
};
|
|
1354
|
+
$inc?: {
|
|
1355
|
+
[K in keyof T]?: number;
|
|
1356
|
+
};
|
|
1357
|
+
$push?: {
|
|
1358
|
+
[K in keyof T]?: unknown;
|
|
1359
|
+
};
|
|
1360
|
+
$pull?: {
|
|
1361
|
+
[K in keyof T]?: unknown;
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* Find options (sort, limit, skip).
|
|
1366
|
+
*/
|
|
1367
|
+
interface FindOptions {
|
|
1368
|
+
sort?: Record<string, 1 | -1>;
|
|
1369
|
+
limit?: number;
|
|
1370
|
+
skip?: number;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Document database adapter interface.
|
|
1374
|
+
*
|
|
1375
|
+
* **Security model:**
|
|
1376
|
+
* - Permission enforcement happens at runtime (SecureDocumentDatabase wrapper)
|
|
1377
|
+
* - Validates collection access against `permissions.platform.database.document.collections`
|
|
1378
|
+
*
|
|
1379
|
+
* **Implementations:**
|
|
1380
|
+
* - `@kb-labs/adapters-db-mongo` - MongoDB
|
|
1381
|
+
* - `NoOpDocumentDatabase` - No-op adapter for testing
|
|
1382
|
+
*/
|
|
1383
|
+
interface IDocumentDatabase {
|
|
1384
|
+
/**
|
|
1385
|
+
* Find documents matching a filter.
|
|
1386
|
+
*
|
|
1387
|
+
* @param collection - Collection name
|
|
1388
|
+
* @param filter - MongoDB-style filter
|
|
1389
|
+
* @param options - Sort, limit, skip
|
|
1390
|
+
* @returns Array of matching documents
|
|
1391
|
+
*/
|
|
1392
|
+
find<T extends BaseDocument>(collection: string, filter: DocumentFilter<T>, options?: FindOptions): Promise<T[]>;
|
|
1393
|
+
/**
|
|
1394
|
+
* Find a single document by ID.
|
|
1395
|
+
*
|
|
1396
|
+
* @param collection - Collection name
|
|
1397
|
+
* @param id - Document ID
|
|
1398
|
+
* @returns Document or null if not found
|
|
1399
|
+
*/
|
|
1400
|
+
findById<T extends BaseDocument>(collection: string, id: string): Promise<T | null>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Insert a single document.
|
|
1403
|
+
*
|
|
1404
|
+
* @param collection - Collection name
|
|
1405
|
+
* @param document - Document to insert (id, createdAt, updatedAt will be added if missing)
|
|
1406
|
+
* @returns Inserted document with generated fields
|
|
1407
|
+
*/
|
|
1408
|
+
insertOne<T extends BaseDocument>(collection: string, document: Omit<T, "id" | "createdAt" | "updatedAt">): Promise<T>;
|
|
1409
|
+
/**
|
|
1410
|
+
* Update documents matching a filter.
|
|
1411
|
+
*
|
|
1412
|
+
* @param collection - Collection name
|
|
1413
|
+
* @param filter - MongoDB-style filter
|
|
1414
|
+
* @param update - MongoDB-style update operators ($set, $inc, etc.)
|
|
1415
|
+
* @returns Number of documents updated
|
|
1416
|
+
*/
|
|
1417
|
+
updateMany<T extends BaseDocument>(collection: string, filter: DocumentFilter<T>, update: DocumentUpdate<T>): Promise<number>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Update a single document by ID.
|
|
1420
|
+
*
|
|
1421
|
+
* @param collection - Collection name
|
|
1422
|
+
* @param id - Document ID
|
|
1423
|
+
* @param update - MongoDB-style update operators
|
|
1424
|
+
* @returns Updated document or null if not found
|
|
1425
|
+
*/
|
|
1426
|
+
updateById<T extends BaseDocument>(collection: string, id: string, update: DocumentUpdate<T>): Promise<T | null>;
|
|
1427
|
+
/**
|
|
1428
|
+
* Delete documents matching a filter.
|
|
1429
|
+
*
|
|
1430
|
+
* @param collection - Collection name
|
|
1431
|
+
* @param filter - MongoDB-style filter
|
|
1432
|
+
* @returns Number of documents deleted
|
|
1433
|
+
*/
|
|
1434
|
+
deleteMany<T extends BaseDocument>(collection: string, filter: DocumentFilter<T>): Promise<number>;
|
|
1435
|
+
/**
|
|
1436
|
+
* Delete a single document by ID.
|
|
1437
|
+
*
|
|
1438
|
+
* @param collection - Collection name
|
|
1439
|
+
* @param id - Document ID
|
|
1440
|
+
* @returns True if deleted, false if not found
|
|
1441
|
+
*/
|
|
1442
|
+
deleteById(collection: string, id: string): Promise<boolean>;
|
|
1443
|
+
/**
|
|
1444
|
+
* Count documents matching a filter.
|
|
1445
|
+
*
|
|
1446
|
+
* @param collection - Collection name
|
|
1447
|
+
* @param filter - MongoDB-style filter
|
|
1448
|
+
* @returns Number of matching documents
|
|
1449
|
+
*/
|
|
1450
|
+
count<T extends BaseDocument>(collection: string, filter: DocumentFilter<T>): Promise<number>;
|
|
1451
|
+
/**
|
|
1452
|
+
* Close database connection.
|
|
1453
|
+
*/
|
|
1454
|
+
close(): Promise<void>;
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Key-value database adapter interface.
|
|
1458
|
+
*
|
|
1459
|
+
* **Security model:**
|
|
1460
|
+
* - Permission enforcement happens at runtime
|
|
1461
|
+
* - Validates key prefix access against `permissions.platform.database.kv.prefixes`
|
|
1462
|
+
*
|
|
1463
|
+
* **Implementations:**
|
|
1464
|
+
* - `@kb-labs/adapters-db-redis` - Redis
|
|
1465
|
+
* - `NoOpKVDatabase` - No-op adapter for testing
|
|
1466
|
+
*/
|
|
1467
|
+
interface IKeyValueDatabase {
|
|
1468
|
+
/**
|
|
1469
|
+
* Get value by key.
|
|
1470
|
+
*
|
|
1471
|
+
* @param key - Key to retrieve
|
|
1472
|
+
* @returns Value or null if not found
|
|
1473
|
+
*/
|
|
1474
|
+
get(key: string): Promise<string | null>;
|
|
1475
|
+
/**
|
|
1476
|
+
* Set value for key.
|
|
1477
|
+
*
|
|
1478
|
+
* @param key - Key to set
|
|
1479
|
+
* @param value - Value to store
|
|
1480
|
+
* @param ttlMs - Optional TTL in milliseconds
|
|
1481
|
+
*/
|
|
1482
|
+
set(key: string, value: string, ttlMs?: number): Promise<void>;
|
|
1483
|
+
/**
|
|
1484
|
+
* Delete key.
|
|
1485
|
+
*
|
|
1486
|
+
* @param key - Key to delete
|
|
1487
|
+
* @returns True if deleted, false if not found
|
|
1488
|
+
*/
|
|
1489
|
+
delete(key: string): Promise<boolean>;
|
|
1490
|
+
/**
|
|
1491
|
+
* Check if key exists.
|
|
1492
|
+
*
|
|
1493
|
+
* @param key - Key to check
|
|
1494
|
+
* @returns True if exists, false otherwise
|
|
1495
|
+
*/
|
|
1496
|
+
exists(key: string): Promise<boolean>;
|
|
1497
|
+
/**
|
|
1498
|
+
* List keys matching a pattern.
|
|
1499
|
+
*
|
|
1500
|
+
* @param pattern - Glob pattern (e.g., 'user:*')
|
|
1501
|
+
* @returns Array of matching keys
|
|
1502
|
+
*/
|
|
1503
|
+
keys(pattern: string): Promise<string[]>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Close database connection.
|
|
1506
|
+
*/
|
|
1507
|
+
close(): Promise<void>;
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Time-series data point.
|
|
1511
|
+
*/
|
|
1512
|
+
interface TimeSeriesPoint {
|
|
1513
|
+
/** Timestamp (Unix milliseconds) */
|
|
1514
|
+
timestamp: number;
|
|
1515
|
+
/** Metric value */
|
|
1516
|
+
value: number;
|
|
1517
|
+
/** Optional tags/labels */
|
|
1518
|
+
tags?: Record<string, string>;
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Time-series database adapter interface.
|
|
1522
|
+
*
|
|
1523
|
+
* **Security model:**
|
|
1524
|
+
* - Permission enforcement happens at runtime
|
|
1525
|
+
* - Validates metric access against `permissions.platform.database.timeseries.metrics`
|
|
1526
|
+
*
|
|
1527
|
+
* **Implementations:**
|
|
1528
|
+
* - `@kb-labs/adapters-db-timescale` - TimescaleDB (PostgreSQL extension)
|
|
1529
|
+
* - `NoOpTimeSeriesDatabase` - No-op adapter for testing
|
|
1530
|
+
*/
|
|
1531
|
+
interface ITimeSeriesDatabase {
|
|
1532
|
+
/**
|
|
1533
|
+
* Write a single data point.
|
|
1534
|
+
*
|
|
1535
|
+
* @param metric - Metric name (e.g., 'cpu_usage')
|
|
1536
|
+
* @param point - Data point
|
|
1537
|
+
*/
|
|
1538
|
+
write(metric: string, point: TimeSeriesPoint): Promise<void>;
|
|
1539
|
+
/**
|
|
1540
|
+
* Write multiple data points (batch).
|
|
1541
|
+
*
|
|
1542
|
+
* @param metric - Metric name
|
|
1543
|
+
* @param points - Array of data points
|
|
1544
|
+
*/
|
|
1545
|
+
writeBatch(metric: string, points: TimeSeriesPoint[]): Promise<void>;
|
|
1546
|
+
/**
|
|
1547
|
+
* Query time-series data.
|
|
1548
|
+
*
|
|
1549
|
+
* @param metric - Metric name
|
|
1550
|
+
* @param startTime - Start timestamp (Unix milliseconds)
|
|
1551
|
+
* @param endTime - End timestamp (Unix milliseconds)
|
|
1552
|
+
* @param tags - Optional tag filters
|
|
1553
|
+
* @returns Array of data points
|
|
1554
|
+
*/
|
|
1555
|
+
query(metric: string, startTime: number, endTime: number, tags?: Record<string, string>): Promise<TimeSeriesPoint[]>;
|
|
1556
|
+
/**
|
|
1557
|
+
* Close database connection.
|
|
1558
|
+
*/
|
|
1559
|
+
close(): Promise<void>;
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Database provider interface.
|
|
1563
|
+
* Provides access to different database types (SQL, Document, KV, TimeSeries).
|
|
1564
|
+
*
|
|
1565
|
+
* **Usage:**
|
|
1566
|
+
* ```typescript
|
|
1567
|
+
* const provider = runtime.platform.database;
|
|
1568
|
+
*
|
|
1569
|
+
* // SQL
|
|
1570
|
+
* const sql = await provider.getSQLDatabase('main');
|
|
1571
|
+
* const users = await sql.query('SELECT * FROM users WHERE active = ?', [true]);
|
|
1572
|
+
*
|
|
1573
|
+
* // Document
|
|
1574
|
+
* const doc = await provider.getDocumentDatabase('main');
|
|
1575
|
+
* const posts = await doc.find('posts', { status: 'published' });
|
|
1576
|
+
*
|
|
1577
|
+
* // KV
|
|
1578
|
+
* const kv = await provider.getKeyValueDatabase('cache');
|
|
1579
|
+
* await kv.set('session:123', JSON.stringify(session), 3600000);
|
|
1580
|
+
*
|
|
1581
|
+
* // TimeSeries
|
|
1582
|
+
* const ts = await provider.getTimeSeriesDatabase('metrics');
|
|
1583
|
+
* await ts.write('api_latency', { timestamp: Date.now(), value: 42 });
|
|
1584
|
+
* ```
|
|
1585
|
+
*/
|
|
1586
|
+
interface IDatabaseProvider {
|
|
1587
|
+
/**
|
|
1588
|
+
* Get SQL database instance.
|
|
1589
|
+
*
|
|
1590
|
+
* @param name - Database name (from config)
|
|
1591
|
+
* @returns SQL database adapter
|
|
1592
|
+
* @throws Error if database not configured
|
|
1593
|
+
*/
|
|
1594
|
+
getSQLDatabase(name: string): Promise<ISQLDatabase>;
|
|
1595
|
+
/**
|
|
1596
|
+
* Get document database instance.
|
|
1597
|
+
*
|
|
1598
|
+
* @param name - Database name (from config)
|
|
1599
|
+
* @returns Document database adapter
|
|
1600
|
+
* @throws Error if database not configured
|
|
1601
|
+
*/
|
|
1602
|
+
getDocumentDatabase(name: string): Promise<IDocumentDatabase>;
|
|
1603
|
+
/**
|
|
1604
|
+
* Get key-value database instance.
|
|
1605
|
+
*
|
|
1606
|
+
* @param name - Database name (from config)
|
|
1607
|
+
* @returns KV database adapter
|
|
1608
|
+
* @throws Error if database not configured
|
|
1609
|
+
*/
|
|
1610
|
+
getKeyValueDatabase(name: string): Promise<IKeyValueDatabase>;
|
|
1611
|
+
/**
|
|
1612
|
+
* Get time-series database instance.
|
|
1613
|
+
*
|
|
1614
|
+
* @param name - Database name (from config)
|
|
1615
|
+
* @returns TimeSeries database adapter
|
|
1616
|
+
* @throws Error if database not configured
|
|
1617
|
+
*/
|
|
1618
|
+
getTimeSeriesDatabase(name: string): Promise<ITimeSeriesDatabase>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Close all database connections.
|
|
1621
|
+
*/
|
|
1622
|
+
close(): Promise<void>;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1199
1625
|
/**
|
|
1200
1626
|
* @module @kb-labs/core-platform/adapters/event-bus
|
|
1201
1627
|
* Event bus abstraction for pub/sub messaging.
|
|
@@ -1298,77 +1724,4 @@ interface IInvoke {
|
|
|
1298
1724
|
isAvailable(pluginId: string, command?: string): Promise<boolean>;
|
|
1299
1725
|
}
|
|
1300
1726
|
|
|
1301
|
-
|
|
1302
|
-
* @module @kb-labs/core-platform/adapters/artifacts
|
|
1303
|
-
* Artifact storage interface.
|
|
1304
|
-
*/
|
|
1305
|
-
/**
|
|
1306
|
-
* Artifact metadata.
|
|
1307
|
-
*/
|
|
1308
|
-
interface ArtifactMeta {
|
|
1309
|
-
/** Artifact key/path */
|
|
1310
|
-
key: string;
|
|
1311
|
-
/** Content type (e.g., 'application/json') */
|
|
1312
|
-
contentType?: string;
|
|
1313
|
-
/** Size in bytes */
|
|
1314
|
-
size?: number;
|
|
1315
|
-
/** Creation timestamp */
|
|
1316
|
-
createdAt?: Date;
|
|
1317
|
-
/** Last modified timestamp */
|
|
1318
|
-
updatedAt?: Date;
|
|
1319
|
-
/** Custom metadata */
|
|
1320
|
-
metadata?: Record<string, unknown>;
|
|
1321
|
-
}
|
|
1322
|
-
/**
|
|
1323
|
-
* Artifact write options.
|
|
1324
|
-
*/
|
|
1325
|
-
interface ArtifactWriteOptions {
|
|
1326
|
-
/** Content type */
|
|
1327
|
-
contentType?: string;
|
|
1328
|
-
/** Custom metadata */
|
|
1329
|
-
metadata?: Record<string, unknown>;
|
|
1330
|
-
/** TTL in seconds (optional expiration) */
|
|
1331
|
-
ttl?: number;
|
|
1332
|
-
}
|
|
1333
|
-
/**
|
|
1334
|
-
* Artifact storage interface.
|
|
1335
|
-
* Provides structured storage for plugin outputs.
|
|
1336
|
-
*/
|
|
1337
|
-
interface IArtifacts {
|
|
1338
|
-
/**
|
|
1339
|
-
* Write an artifact.
|
|
1340
|
-
* @param key - Artifact key/path
|
|
1341
|
-
* @param data - Data to write (will be serialized)
|
|
1342
|
-
* @param options - Write options
|
|
1343
|
-
*/
|
|
1344
|
-
write(key: string, data: unknown, options?: ArtifactWriteOptions): Promise<void>;
|
|
1345
|
-
/**
|
|
1346
|
-
* Read an artifact.
|
|
1347
|
-
* @param key - Artifact key/path
|
|
1348
|
-
* @returns Artifact data or null if not found
|
|
1349
|
-
*/
|
|
1350
|
-
read<T = unknown>(key: string): Promise<T | null>;
|
|
1351
|
-
/**
|
|
1352
|
-
* Check if artifact exists.
|
|
1353
|
-
* @param key - Artifact key/path
|
|
1354
|
-
*/
|
|
1355
|
-
exists(key: string): Promise<boolean>;
|
|
1356
|
-
/**
|
|
1357
|
-
* Delete an artifact.
|
|
1358
|
-
* @param key - Artifact key/path
|
|
1359
|
-
*/
|
|
1360
|
-
delete(key: string): Promise<void>;
|
|
1361
|
-
/**
|
|
1362
|
-
* List artifacts by prefix.
|
|
1363
|
-
* @param prefix - Key prefix
|
|
1364
|
-
* @returns List of artifact metadata
|
|
1365
|
-
*/
|
|
1366
|
-
list(prefix: string): Promise<ArtifactMeta[]>;
|
|
1367
|
-
/**
|
|
1368
|
-
* Get artifact metadata.
|
|
1369
|
-
* @param key - Artifact key/path
|
|
1370
|
-
*/
|
|
1371
|
-
getMeta(key: string): Promise<ArtifactMeta | null>;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
export { type EventHandler as $, type AnalyticsContext as A, type BufferStatus as B, type LLMTier as C, type DlqStatus as D, type EventsQuery as E, type LLMCapability as F, type LLMResolution as G, type LLMAdapterBinding as H, type IAnalytics as I, type ILLMRouter as J, isTierHigher as K, type LogRecord as L, isTierLower as M, type IEmbeddings as N, type ICache as O, type IConfig as P, type IStorage as Q, type StorageMetadata as R, type StatsQuery as S, TIER_ORDER as T, type UseLLMOptions as U, type VectorRecord as V, type ILogger as W, type ILogBuffer as X, type LogLevel as Y, generateLogId as Z, type IEventBus as _, type LogQuery as a, type Unsubscribe as a0, type IInvoke as a1, type InvokeRequest as a2, type InvokeResponse as a3, type IArtifacts as a4, type ArtifactMeta as a5, type ArtifactWriteOptions as a6, type LLMRequestMetadata as a7, type AnalyticsEvent as b, type EventsResponse as c, type EventsStats as d, type DailyStats as e, type IVectorStore as f, type VectorSearchResult as g, type VectorFilter as h, type ILLM as i, type LLMOptions as j, type LLMResponse as k, type LLMExecutionPolicy as l, type LLMCachePolicy as m, type LLMStreamPolicy as n, type LLMCacheMode as o, type LLMCacheScope as p, type LLMStreamMode as q, type LLMProtocolCapabilities as r, type LLMCacheCapability as s, type LLMStreamCapability as t, type LLMCacheDecisionTrace as u, type LLMTool as v, type LLMToolCall as w, type LLMMessage as x, type LLMToolCallOptions as y, type LLMToolCallResponse as z };
|
|
1727
|
+
export { type DocumentFilter as $, type AnalyticsContext as A, type BufferStatus as B, type LLMTier as C, type DlqStatus as D, type EventsQuery as E, type LLMCapability as F, type LLMResolution as G, type LLMAdapterBinding as H, type IAnalytics as I, type ILLMRouter as J, isTierHigher as K, type LogRecord as L, isTierLower as M, type IEmbeddings as N, type ICache as O, type IConfig as P, type IStorage as Q, type StorageMetadata as R, type StatsQuery as S, TIER_ORDER as T, type UseLLMOptions as U, type VectorRecord as V, type ISQLDatabase as W, type SQLQueryResult as X, type SQLTransaction as Y, type IDocumentDatabase as Z, type BaseDocument as _, type LogQuery as a, type DocumentUpdate as a0, type FilterOperators as a1, type FindOptions as a2, type IKeyValueDatabase as a3, type ITimeSeriesDatabase as a4, type TimeSeriesPoint as a5, type IDatabaseProvider as a6, type ILogger as a7, type ILogBuffer as a8, type LogLevel as a9, generateLogId as aa, type IEventBus as ab, type EventHandler as ac, type Unsubscribe as ad, type IInvoke as ae, type InvokeRequest as af, type InvokeResponse as ag, type LLMRequestMetadata as ah, type AnalyticsEvent as b, type EventsResponse as c, type EventsStats as d, type DailyStats as e, type IVectorStore as f, type VectorSearchResult as g, type VectorFilter as h, type ILLM as i, type LLMOptions as j, type LLMResponse as k, type LLMExecutionPolicy as l, type LLMCachePolicy as m, type LLMStreamPolicy as n, type LLMCacheMode as o, type LLMCacheScope as p, type LLMStreamMode as q, type LLMProtocolCapabilities as r, type LLMCacheCapability as s, type LLMStreamCapability as t, type LLMCacheDecisionTrace as u, type LLMTool as v, type LLMToolCall as w, type LLMMessage as x, type LLMToolCallOptions as y, type LLMToolCallResponse as z };
|