pi-crew 0.9.39 → 0.9.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-crew",
3
- "version": "0.9.39",
3
+ "version": "0.9.40",
4
4
  "description": "Pi extension for coordinated AI teams, workflows, worktrees, and async task orchestration",
5
5
  "author": "baphuongna",
6
6
  "license": "MIT",
@@ -14,7 +14,7 @@ import path from "node:path";
14
14
  import type { AgentConfig } from "../agents/agent-config.ts";
15
15
  import { writeArtifact } from "../state/artifact-store.ts";
16
16
  import { appendEventAsync } from "../state/event-log.ts";
17
- import { saveRunTasks, updateRunStatus } from "../state/state-store.ts";
17
+ import { saveRunTasksAsync, updateRunStatus } from "../state/state-store.ts";
18
18
  import type { TeamRunManifest, TeamTaskState } from "../state/types.ts";
19
19
  import type { WorkflowStep } from "../workflows/workflow-config.ts";
20
20
  import { runChildPi } from "./child-pi.ts";
@@ -62,7 +62,7 @@ export async function runCoalescedTaskGroup(input: CoalescedTaskGroupInput): Pro
62
62
  }
63
63
  return t;
64
64
  });
65
- saveRunTasks(manifest, updatedTasks);
65
+ await saveRunTasksAsync(manifest, updatedTasks);
66
66
  await appendEventAsync(manifest.eventsPath, {
67
67
  type: "task.coalesced_dispatch_start",
68
68
  runId: manifest.runId,
@@ -87,7 +87,7 @@ export async function runCoalescedTaskGroup(input: CoalescedTaskGroupInput): Pro
87
87
  heartbeat: t.heartbeat ?? createWorkerHeartbeat(t.id),
88
88
  };
89
89
  });
90
- saveRunTasks(manifest, updatedTasks);
90
+ await saveRunTasksAsync(manifest, updatedTasks);
91
91
 
92
92
  let rawOutput = "";
93
93
  let success = false;
@@ -98,7 +98,7 @@ export async function runCoalescedTaskGroup(input: CoalescedTaskGroupInput): Pro
98
98
  // Heartbeat refresher: touch every task's heartbeat every 15s while the
99
99
  // worker is alive. Set `alive: true` explicitly so post-completion
100
100
  // staleness checks immediately recognize liveness.
101
- const heartbeatTimer = setInterval(() => {
101
+ const heartbeatTimer = setInterval(async () => {
102
102
  const now = new Date().toISOString();
103
103
  updatedTasks = updatedTasks.map((t) => {
104
104
  if (!taskIds.includes(t.id)) return t;
@@ -108,7 +108,7 @@ export async function runCoalescedTaskGroup(input: CoalescedTaskGroupInput): Pro
108
108
  };
109
109
  });
110
110
  try {
111
- saveRunTasks(manifest, updatedTasks);
111
+ await saveRunTasksAsync(manifest, updatedTasks);
112
112
  } catch {
113
113
  // Run may have been pruned mid-dispatch — best-effort only.
114
114
  }
@@ -168,7 +168,7 @@ export async function runCoalescedTaskGroup(input: CoalescedTaskGroupInput): Pro
168
168
  resultArtifact,
169
169
  };
170
170
  });
171
- saveRunTasks(manifest, updatedTasks);
171
+ await saveRunTasksAsync(manifest, updatedTasks);
172
172
  let updatedManifest: TeamRunManifest = {
173
173
  ...manifest,
174
174
  artifacts: mergeArtifacts([...manifest.artifacts, ...newArtifacts]),
@@ -70,7 +70,7 @@ function checkResultFile(manifest: TeamRunManifest, tasks: TeamTaskState[]): { f
70
70
  // All tasks are terminal but manifest status was not updated — repair it.
71
71
  // Derive the run status from task outcomes instead of blindly marking
72
72
  // "completed": a run where every task failed/cancelled is NOT a success.
73
- const hasFailed = tasks.some((t) => t.status === "failed");
73
+ const hasFailed = tasks.some((t) => t.status === "failed" || t.status === "needs_attention");
74
74
  const onlyCancelledOrSkipped = tasks.every((t) => t.status === "cancelled" || t.status === "skipped");
75
75
  manifest.status = hasFailed ? "failed" : onlyCancelledOrSkipped ? "cancelled" : "completed";
76
76
  // Persist manifest status change immediately to make checkResultFile self-contained.