@devflow-tools/database 0.16.11 → 0.16.13
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/CHANGELOG.md +27 -0
- package/__tests__/database.memory-turn-receipts.test.ts +27 -0
- package/__tests__/database.skill-executions.test.ts +62 -1
- package/dist/database.d.ts +46 -0
- package/dist/database.js +438 -48
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -1
- package/dist/node-sqlite.js +1 -6
- package/dist/obligation-ledger.d.ts +19 -0
- package/dist/obligation-ledger.js +35 -0
- package/dist/work-queue.d.ts +1 -1
- package/package.json +3 -3
- package/src/database.ts +552 -45
- package/src/index.ts +11 -0
- package/src/node-sqlite.ts +1 -6
- package/src/obligation-ledger.ts +57 -0
- package/src/work-queue.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { DevFlowDatabase, getGlobalDevFlowDbPath, openGlobalDevFlowDatabase, } from './database';
|
|
2
|
-
export type { BenchmarkReportMetaRecord, BenchmarkReportRecord, FeedbackRecord, GovernanceAuditRecord, GovernanceRuleRecord, HookFallbackRecord, HookReceiptRecord, MemoryDistillCheckpointRecord, MemoryTurnRecord, MemoryTurnStatus, TelemetryFailureRecord, } from './database';
|
|
2
|
+
export type { BenchmarkReportMetaRecord, BenchmarkReportRecord, FeedbackRecord, GovernanceAuditRecord, GovernanceRuleRecord, HookFallbackRecord, HookReceiptRecord, ContextReceiptRecord, ContextSelectionEventRecord, MemoryDistillCheckpointRecord, MemoryTurnRecord, MemoryTurnStatus, TelemetryFailureRecord, } from './database';
|
|
3
3
|
export type { EnqueueWorkInput, LeaseWorkInput, RequestSessionClosureInput, SessionClosureRecord, SessionClosureState, WorkError, WorkItemRecord, WorkKind, WorkQueueHealth, WorkState, } from './work-queue';
|
|
4
|
+
export { mapSessionObligationRow, normalizeTurnId, } from './obligation-ledger';
|
|
5
|
+
export type { SessionObligationKind, SessionObligationRecord, SessionObligationState, } from './obligation-ledger';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.openGlobalDevFlowDatabase = exports.getGlobalDevFlowDbPath = exports.DevFlowDatabase = void 0;
|
|
3
|
+
exports.normalizeTurnId = exports.mapSessionObligationRow = exports.openGlobalDevFlowDatabase = exports.getGlobalDevFlowDbPath = exports.DevFlowDatabase = void 0;
|
|
4
4
|
var database_1 = require("./database");
|
|
5
5
|
Object.defineProperty(exports, "DevFlowDatabase", { enumerable: true, get: function () { return database_1.DevFlowDatabase; } });
|
|
6
6
|
Object.defineProperty(exports, "getGlobalDevFlowDbPath", { enumerable: true, get: function () { return database_1.getGlobalDevFlowDbPath; } });
|
|
7
7
|
Object.defineProperty(exports, "openGlobalDevFlowDatabase", { enumerable: true, get: function () { return database_1.openGlobalDevFlowDatabase; } });
|
|
8
|
+
var obligation_ledger_1 = require("./obligation-ledger");
|
|
9
|
+
Object.defineProperty(exports, "mapSessionObligationRow", { enumerable: true, get: function () { return obligation_ledger_1.mapSessionObligationRow; } });
|
|
10
|
+
Object.defineProperty(exports, "normalizeTurnId", { enumerable: true, get: function () { return obligation_ledger_1.normalizeTurnId; } });
|
package/dist/node-sqlite.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NodeSqliteDatabase = void 0;
|
|
4
|
-
// node:sqlite is a Node.js 22+ experimental built-in. TypeScript does not
|
|
5
|
-
// resolve `node:` prefixed modules unless @types/node includes them (which
|
|
6
|
-
// requires @types/node >= 22.5). We suppress the TS error here and rely on
|
|
7
|
-
// the ambient types defined below until the project upgrades @types/node.
|
|
8
|
-
// @ts-expect-error - node:sqlite types not available in @types/node@20
|
|
9
4
|
const node_sqlite_1 = require("node:sqlite");
|
|
10
5
|
class NodeSqliteDatabase {
|
|
11
6
|
constructor(path, busyTimeoutMs = 10000) {
|
|
@@ -23,7 +18,7 @@ class NodeSqliteDatabase {
|
|
|
23
18
|
run: (...params) => {
|
|
24
19
|
const result = stmt.run(...normalizeParams(params));
|
|
25
20
|
return {
|
|
26
|
-
changes: result.changes,
|
|
21
|
+
changes: Number(result.changes),
|
|
27
22
|
lastInsertRowid: result.lastInsertRowid,
|
|
28
23
|
};
|
|
29
24
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type SessionObligationKind = 'memory_decision' | 'evidence_contract' | 'session_finalize';
|
|
2
|
+
export type SessionObligationState = 'open' | 'satisfied' | 'degraded' | 'cancelled';
|
|
3
|
+
export interface SessionObligationRecord {
|
|
4
|
+
obligationId: string;
|
|
5
|
+
projectRoot: string;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
executionId?: string;
|
|
8
|
+
turnId?: string;
|
|
9
|
+
kind: SessionObligationKind;
|
|
10
|
+
state: SessionObligationState;
|
|
11
|
+
payload: Record<string, unknown>;
|
|
12
|
+
receiptId?: string;
|
|
13
|
+
reason?: string;
|
|
14
|
+
createdAt: number;
|
|
15
|
+
updatedAt: number;
|
|
16
|
+
resolvedAt?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function normalizeTurnId(value: string): string;
|
|
19
|
+
export declare function mapSessionObligationRow(row: Record<string, unknown>): SessionObligationRecord;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeTurnId = normalizeTurnId;
|
|
4
|
+
exports.mapSessionObligationRow = mapSessionObligationRow;
|
|
5
|
+
function normalizeTurnId(value) {
|
|
6
|
+
const trimmed = value.trim();
|
|
7
|
+
if (!trimmed)
|
|
8
|
+
throw new Error('Memory turn ID is required');
|
|
9
|
+
return trimmed.startsWith('turn:') ? trimmed : `turn:${trimmed}`;
|
|
10
|
+
}
|
|
11
|
+
function mapSessionObligationRow(row) {
|
|
12
|
+
let payload = {};
|
|
13
|
+
try {
|
|
14
|
+
const parsed = JSON.parse(String(row.payload ?? '{}'));
|
|
15
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
16
|
+
payload = parsed;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
return {
|
|
21
|
+
obligationId: String(row.obligation_id),
|
|
22
|
+
projectRoot: String(row.project_root),
|
|
23
|
+
sessionId: String(row.session_id),
|
|
24
|
+
executionId: typeof row.execution_id === 'string' ? row.execution_id : undefined,
|
|
25
|
+
turnId: typeof row.turn_id === 'string' ? row.turn_id : undefined,
|
|
26
|
+
kind: row.kind,
|
|
27
|
+
state: row.state,
|
|
28
|
+
payload,
|
|
29
|
+
receiptId: typeof row.receipt_id === 'string' ? row.receipt_id : undefined,
|
|
30
|
+
reason: typeof row.reason === 'string' ? row.reason : undefined,
|
|
31
|
+
createdAt: Number(row.created_at),
|
|
32
|
+
updatedAt: Number(row.updated_at),
|
|
33
|
+
resolvedAt: typeof row.resolved_at === 'number' ? row.resolved_at : undefined,
|
|
34
|
+
};
|
|
35
|
+
}
|
package/dist/work-queue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type WorkKind = 'memory.explicit_commit' | 'memory.turn_capture' | 'memory.turn_distill' | 'memory.vector_backfill' | 'session.bootstrap' | 'session.finalize' | 'telemetry.reconcile';
|
|
1
|
+
export type WorkKind = 'memory.explicit_commit' | 'memory.explicit_enrichment' | 'memory.turn_capture' | 'memory.turn_distill' | 'memory.vector_backfill' | 'session.bootstrap' | 'session.finalize' | 'telemetry.reconcile';
|
|
2
2
|
export type WorkState = 'pending' | 'leased' | 'completed' | 'failed' | 'dead_letter';
|
|
3
3
|
export interface WorkError {
|
|
4
4
|
category: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devflow-tools/database",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.13",
|
|
4
4
|
"description": "DevFlow SQLite database package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@types/node": "^
|
|
12
|
+
"@types/node": "^22.15.0",
|
|
13
13
|
"typescript": "^5.5.0",
|
|
14
14
|
"vitest": "^2.0.0"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "67c9dfc3709bd0ce36b7c2a9341896eedcc8a725"
|
|
17
17
|
}
|