@mu-crew/mu 4.2.1 → 4.2.2

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.
@@ -6,7 +6,7 @@ import {
6
6
  logItem,
7
7
  openHumanNeeds,
8
8
  parseOpKey
9
- } from "./chunk-FVRIKUBR.js";
9
+ } from "./chunk-FOWIQ4TP.js";
10
10
  import {
11
11
  UNKNOWN_REASON,
12
12
  WorkstreamNotFoundError,
@@ -375,4 +375,4 @@ export {
375
375
  matches,
376
376
  loadDashboard
377
377
  };
378
- //# sourceMappingURL=chunk-U2QLTREB.js.map
378
+ //# sourceMappingURL=chunk-EIE5OKZZ.js.map
@@ -23,7 +23,7 @@ import {
23
23
  recordHumanNeeded,
24
24
  reserveAttempt,
25
25
  reserveRetry
26
- } from "./chunk-FVRIKUBR.js";
26
+ } from "./chunk-FOWIQ4TP.js";
27
27
  import {
28
28
  AgentLockBusyError,
29
29
  AgentNotFoundError,
@@ -4483,4 +4483,4 @@ export {
4483
4483
  saveResume,
4484
4484
  loadResume
4485
4485
  };
4486
- //# sourceMappingURL=chunk-RJQNDFBU.js.map
4486
+ //# sourceMappingURL=chunk-FHGYHXFB.js.map
@@ -2632,6 +2632,11 @@ function recordHumanNeeded(db, opts) {
2632
2632
  db,
2633
2633
  { intent: "task.note", actor: caller, group: "new" },
2634
2634
  () => db.transaction(() => {
2635
+ if (opts.stop === false) {
2636
+ const same = openItemWith(db, opts.workstream, reason);
2637
+ if (same !== void 0) return { id: same, changed: false };
2638
+ return { id: addHumanTask(db, opts.workstream, caller, reason), changed: true };
2639
+ }
2635
2640
  const open = openNeedFor(db, caller, opts.workstream);
2636
2641
  if (open !== void 0) {
2637
2642
  if (open.briefs.includes(reason)) return { id: open.id, changed: false };
@@ -2642,20 +2647,37 @@ function recordHumanNeeded(db, opts) {
2642
2647
  });
2643
2648
  return { id: open.id, changed: true };
2644
2649
  }
2645
- const title = `human needed: ${reason.replace(/\s+/g, " ").slice(0, TITLE_CHARS)}`;
2646
- const { ids } = addTasks(db, [{ title, note: reason }], {
2647
- workstream: opts.workstream,
2648
- kind: "human",
2649
- noteAuthor: caller
2650
- });
2651
- const id = ids[0];
2652
- if (id === void 0) throw new Error("recordHumanNeeded: no task created");
2650
+ const id = addHumanTask(db, opts.workstream, caller, reason);
2653
2651
  const taskId = db.prepare("SELECT id FROM tasks WHERE workstream_id = ? AND local_id = ?").get(resolveWorkstreamId(db, opts.workstream), id).id;
2654
2652
  db.prepare("INSERT INTO human_needs (task_id, caller) VALUES (?, ?)").run(taskId, caller);
2655
2653
  return { id, changed: true };
2656
2654
  }).immediate()
2657
2655
  );
2658
2656
  }
2657
+ function addHumanTask(db, workstream, caller, reason) {
2658
+ const title = `human needed: ${reason.replace(/\s+/g, " ").slice(0, TITLE_CHARS)}`;
2659
+ const { ids } = addTasks(db, [{ title, note: reason }], {
2660
+ workstream,
2661
+ kind: "human",
2662
+ noteAuthor: caller
2663
+ });
2664
+ const id = ids[0];
2665
+ if (id === void 0) throw new Error("recordHumanNeeded: no task created");
2666
+ return id;
2667
+ }
2668
+ function openItemWith(db, workstream, reason) {
2669
+ const row = db.prepare(
2670
+ `SELECT t.local_id AS id
2671
+ FROM tasks t
2672
+ JOIN workstreams w ON w.id = t.workstream_id
2673
+ WHERE w.name = ? AND t.kind = 'human' AND t.status = 'OPEN'
2674
+ AND NOT EXISTS (SELECT 1 FROM human_needs h WHERE h.task_id = t.id)
2675
+ AND (SELECT n.content FROM task_notes n
2676
+ WHERE n.task_id = t.id AND n.kind = 'brief' ORDER BY n.id LIMIT 1) = ?
2677
+ LIMIT 1`
2678
+ ).get(workstream, reason);
2679
+ return row?.id;
2680
+ }
2659
2681
  function openNeedRows(db, caller, workstream) {
2660
2682
  return db.prepare(
2661
2683
  `SELECT t.id AS taskId, t.local_id AS id, w.name AS workstream
@@ -3657,4 +3679,4 @@ export {
3657
3679
  ingestFromDb,
3658
3680
  currentCallers
3659
3681
  };
3660
- //# sourceMappingURL=chunk-FVRIKUBR.js.map
3682
+ //# sourceMappingURL=chunk-FOWIQ4TP.js.map