@wrongstack/core 0.6.5 → 0.6.6

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.
@@ -32,11 +32,11 @@ import '../index-DcnXDPdY.js';
32
32
  import '../system-prompt-gL06H9P4.js';
33
33
  import '../observability-BhnVLBLS.js';
34
34
  import '../selector-DDb_mq9X.js';
35
- import '../goal-store-_Er467ya.js';
35
+ import '../goal-store-HHgaq5ue.js';
36
36
  import '../skill-CxuWrsKK.js';
37
37
  import 'node:events';
38
38
  import '../mode-CV077NjV.js';
39
- import '../task-graph-BITvWt4t.js';
39
+ import '../task-graph-D1YQbpxF.js';
40
40
 
41
41
  /**
42
42
  * Default ProviderRunner — thin adapter over `runProviderWithRetry`.
@@ -5449,23 +5449,33 @@ var EternalAutonomyEngine = class {
5449
5449
  * `agent.run()` avoids race conditions on the shared Context.
5450
5450
  */
5451
5451
  async runOneIteration() {
5452
+ const emit = (stage) => {
5453
+ this.opts.onStage?.(stage);
5454
+ };
5452
5455
  const goal = await loadGoal(this.goalPath);
5453
5456
  if (!goal) {
5457
+ emit({ phase: "stopped" });
5454
5458
  this.stopRequested = true;
5455
5459
  return false;
5456
5460
  }
5457
5461
  const missionState = goal.goalState ?? "active";
5458
5462
  if (missionState !== "active") {
5463
+ emit({ phase: missionState === "paused" ? "paused" : "stopped" });
5459
5464
  this.stopRequested = true;
5460
5465
  return false;
5461
5466
  }
5467
+ emit({ phase: "decide", reason: "picking next task" });
5462
5468
  const action = await this.decide(goal);
5463
5469
  if (!action) {
5464
5470
  if (!this.stopRequested) {
5471
+ emit({ phase: "sleep", ms: 5e3 });
5465
5472
  await sleep(5e3);
5473
+ } else {
5474
+ emit({ phase: "stopped" });
5466
5475
  }
5467
5476
  return false;
5468
5477
  }
5478
+ emit({ phase: "execute", task: action.task });
5469
5479
  const ctrl = new AbortController();
5470
5480
  this.currentCtrl = ctrl;
5471
5481
  const timer = setTimeout(
@@ -5543,6 +5553,7 @@ var EternalAutonomyEngine = class {
5543
5553
  tokens,
5544
5554
  costUsd
5545
5555
  });
5556
+ emit({ phase: "reflect", status, note });
5546
5557
  let iterationIndex = 0;
5547
5558
  try {
5548
5559
  const reloaded = await loadGoal(this.goalPath);
@@ -5564,6 +5575,7 @@ var EternalAutonomyEngine = class {
5564
5575
  this.consecutiveTransientRetries++;
5565
5576
  const delay = this.computeTransientBackoffMs();
5566
5577
  if (delay > 0) {
5578
+ emit({ phase: "sleep", ms: delay });
5567
5579
  await this.sleepInterruptible(delay);
5568
5580
  }
5569
5581
  return false;
@@ -5577,6 +5589,9 @@ var EternalAutonomyEngine = class {
5577
5589
  return false;
5578
5590
  }
5579
5591
  this.consecutiveTransientRetries = 0;
5592
+ const cycleGapMs = this.opts.cycleGapMs ?? 1e3;
5593
+ emit({ phase: "sleep", ms: cycleGapMs });
5594
+ await sleep(cycleGapMs);
5580
5595
  if (GOAL_COMPLETE_MARKER.test(finalText)) {
5581
5596
  await this.markGoalCompleted(action, finalText);
5582
5597
  this.stopRequested = true;
@@ -10247,6 +10262,10 @@ var TaskTracker = class {
10247
10262
  node.updatedAt = now;
10248
10263
  if (status === "completed") {
10249
10264
  node.completedAt = now;
10265
+ node.startedAt = node.startedAt ?? now;
10266
+ }
10267
+ if (status === "in_progress") {
10268
+ node.startedAt = now;
10250
10269
  }
10251
10270
  this.transitions.push({ from, to: status, timestamp: now, reason });
10252
10271
  if (status === "completed") {
@@ -10258,6 +10277,23 @@ var TaskTracker = class {
10258
10277
  this.graph.updatedAt = now;
10259
10278
  this.persist();
10260
10279
  }
10280
+ /**
10281
+ * Update node fields (title, description, priority, estimateHours, tags).
10282
+ * Does NOT change status. Use updateNodeStatus for status changes.
10283
+ */
10284
+ updateNode(id, patch) {
10285
+ if (!this.graph) throw new Error("No graph loaded");
10286
+ const node = this.graph.nodes.get(id);
10287
+ if (!node) throw new Error(`Node ${id} not found`);
10288
+ if (patch.title !== void 0) node.title = patch.title;
10289
+ if (patch.description !== void 0) node.description = patch.description;
10290
+ if (patch.priority !== void 0) node.priority = patch.priority;
10291
+ if (patch.estimateHours !== void 0) node.estimateHours = patch.estimateHours;
10292
+ if (patch.tags !== void 0) node.tags = patch.tags;
10293
+ node.updatedAt = Date.now();
10294
+ this.graph.updatedAt = node.updatedAt;
10295
+ this.persist();
10296
+ }
10261
10297
  getNode(id) {
10262
10298
  return this.graph?.nodes.get(id);
10263
10299
  }