@devflow-tools/database 0.18.26 → 0.18.28

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.
@@ -527,6 +527,14 @@ export declare class DevFlowDatabase {
527
527
  snapshot: RuntimeActivationSnapshotV1;
528
528
  replayed: boolean;
529
529
  };
530
+ getOrCreateRuntimeActivation(input: {
531
+ identity: CanonicalTaskIdentity;
532
+ revision: number;
533
+ snapshot: RuntimeActivationSnapshotV1;
534
+ }): {
535
+ snapshot: RuntimeActivationSnapshotV1;
536
+ replayed: boolean;
537
+ };
530
538
  private bindRuntimeActivationInTransaction;
531
539
  getRuntimeActivation(projectRoot: string, sessionId: string, turnId: string, revision: number): RuntimeActivationSnapshotV1 | null;
532
540
  putSemanticExecutionContext(input: {
package/dist/database.js CHANGED
@@ -4050,6 +4050,19 @@ class DevFlowDatabase {
4050
4050
  bindRuntimeActivation(input) {
4051
4051
  return this.db.transaction(() => this.bindRuntimeActivationInTransaction(input));
4052
4052
  }
4053
+ getOrCreateRuntimeActivation(input) {
4054
+ const identity = input.identity;
4055
+ const inserted = this.db.prepare(`
4056
+ INSERT OR IGNORE INTO devflow_runtime_activations_v1 (
4057
+ snapshot_hash, project_root, project_id, host_id, session_id, turn_id,
4058
+ request_id, execution_id, revision, snapshot_json, created_at
4059
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
4060
+ `).run(input.snapshot.snapshotHash, identity.projectRoot, identity.projectId, identity.hostId, identity.sessionId, identity.turnId, identity.requestId, identity.executionId ?? null, input.revision, (0, task_runtime_1.stableTaskRuntimeJson)(input.snapshot), input.snapshot.createdAt);
4061
+ const snapshot = this.getRuntimeActivation(identity.projectRoot, identity.sessionId, identity.turnId, input.revision);
4062
+ if (!snapshot)
4063
+ throw new Error('RUNTIME_ACTIVATION_GET_OR_CREATE_FAILED');
4064
+ return { snapshot, replayed: inserted.changes === 0 };
4065
+ }
4053
4066
  bindRuntimeActivationInTransaction(input) {
4054
4067
  const existing = this.getRuntimeActivation(input.identity.projectRoot, input.identity.sessionId, input.identity.turnId, input.revision);
4055
4068
  if (existing) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devflow-tools/database",
3
- "version": "0.18.26",
3
+ "version": "0.18.28",
4
4
  "description": "SQLite persistence primitives shared by DevFlow runtime packages.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "test": "vitest run"
13
13
  },
14
14
  "dependencies": {
15
- "@devflow-tools/sdk": "0.18.26"
15
+ "@devflow-tools/sdk": "0.18.28"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^22.15.0",