@hasna/loops 0.3.26 → 0.3.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.
@@ -418,6 +418,42 @@ function validateTarget(value, label) {
418
418
  throw new Error(`${label}.allowlist.enforcement must be metadata_only`);
419
419
  }
420
420
  }
421
+ if (value.worktree !== undefined) {
422
+ assertObject(value.worktree, `${label}.worktree`);
423
+ assertString(value.worktree.mode, `${label}.worktree.mode`);
424
+ const modes = ["auto", "required", "off", "main"];
425
+ if (!modes.includes(value.worktree.mode))
426
+ throw new Error(`${label}.worktree.mode must be one of ${modes.join(", ")}`);
427
+ if (typeof value.worktree.enabled !== "boolean")
428
+ throw new Error(`${label}.worktree.enabled must be a boolean`);
429
+ assertString(value.worktree.originalCwd, `${label}.worktree.originalCwd`);
430
+ assertString(value.worktree.cwd, `${label}.worktree.cwd`);
431
+ if (value.worktree.repoRoot !== undefined)
432
+ assertString(value.worktree.repoRoot, `${label}.worktree.repoRoot`);
433
+ if (value.worktree.root !== undefined)
434
+ assertString(value.worktree.root, `${label}.worktree.root`);
435
+ if (value.worktree.path !== undefined)
436
+ assertString(value.worktree.path, `${label}.worktree.path`);
437
+ if (value.worktree.branch !== undefined)
438
+ assertString(value.worktree.branch, `${label}.worktree.branch`);
439
+ if (value.worktree.reason !== undefined)
440
+ assertString(value.worktree.reason, `${label}.worktree.reason`);
441
+ }
442
+ if (value.routing !== undefined) {
443
+ assertObject(value.routing, `${label}.routing`);
444
+ if (value.routing.projectPath !== undefined)
445
+ assertString(value.routing.projectPath, `${label}.routing.projectPath`);
446
+ if (value.routing.projectGroup !== undefined)
447
+ assertString(value.routing.projectGroup, `${label}.routing.projectGroup`);
448
+ if (value.routing.taskId !== undefined)
449
+ assertString(value.routing.taskId, `${label}.routing.taskId`);
450
+ if (value.routing.eventId !== undefined)
451
+ assertString(value.routing.eventId, `${label}.routing.eventId`);
452
+ if (value.routing.eventType !== undefined)
453
+ assertString(value.routing.eventType, `${label}.routing.eventType`);
454
+ if (value.routing.eventSource !== undefined)
455
+ assertString(value.routing.eventSource, `${label}.routing.eventSource`);
456
+ }
421
457
  return value;
422
458
  }
423
459
  throw new Error(`${label}.type must be command or agent`);
@@ -2189,6 +2225,19 @@ class Store {
2189
2225
  const row = this.db.query("SELECT * FROM daemon_lease LIMIT 1").get();
2190
2226
  return row ? rowToLease(row) : undefined;
2191
2227
  }
2228
+ writeTransaction(fn) {
2229
+ this.db.exec("BEGIN IMMEDIATE;");
2230
+ try {
2231
+ const result = fn();
2232
+ this.db.exec("COMMIT;");
2233
+ return result;
2234
+ } catch (error) {
2235
+ try {
2236
+ this.db.exec("ROLLBACK;");
2237
+ } catch {}
2238
+ throw error;
2239
+ }
2240
+ }
2192
2241
  close() {
2193
2242
  this.db.close();
2194
2243
  }
@@ -4525,7 +4574,7 @@ function enableStartup(result) {
4525
4574
  // package.json
4526
4575
  var package_default = {
4527
4576
  name: "@hasna/loops",
4528
- version: "0.3.26",
4577
+ version: "0.3.28",
4529
4578
  description: "Persistent local loop and workflow runner for deterministic commands and headless AI coding agents",
4530
4579
  type: "module",
4531
4580
  main: "dist/index.js",