pi-crew 0.2.6 → 0.2.7
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
|
@@ -8,7 +8,13 @@ export interface ProcessLiveness {
|
|
|
8
8
|
detail: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* How long (ms) a foreground team run with status "running" but no active agents
|
|
13
|
+
* survives before being flagged as orphaned. Reduced from 10min to 2min to
|
|
14
|
+
* improve UX: stuck foreground runs (e.g. planner with 0 tool calls) no longer
|
|
15
|
+
* linger for 10min before the dashboard shows them as stale.
|
|
16
|
+
*/
|
|
17
|
+
const ORPHANED_ACTIVE_RUN_MS = 2 * 60 * 1000;
|
|
12
18
|
/** How long a completed run stays visible in the widget after completion. */
|
|
13
19
|
const COMPLETED_VISIBILITY_GRACE_MS = 8000;
|
|
14
20
|
/** Maximum age (ms) for an active run before it's considered stale.
|
|
@@ -39,13 +45,35 @@ export function isFinishedRunStatus(status: string): boolean {
|
|
|
39
45
|
return status === "completed" || status === "failed" || status === "cancelled" || status === "blocked";
|
|
40
46
|
}
|
|
41
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Secondary threshold: runs that have been "running" for more than this without
|
|
50
|
+
* any active agents (all queued, no progress) are also considered orphaned.
|
|
51
|
+
* This catches foreground team runs where the planner got stuck with 0 tool calls.
|
|
52
|
+
*/
|
|
53
|
+
const ORPHANED_NO_PROGRESS_MS = 5 * 60 * 1000;
|
|
54
|
+
|
|
42
55
|
export function isLikelyOrphanedActiveRun(run: TeamRunManifest, agents: CrewAgentRecord[] = [], now = Date.now(), staleMs = ORPHANED_ACTIVE_RUN_MS): boolean {
|
|
43
56
|
if (!isActiveRunStatus(run.status)) return false;
|
|
44
57
|
if (run.async?.pid !== undefined) return false;
|
|
45
58
|
const updatedAt = new Date(run.updatedAt).getTime();
|
|
46
|
-
if (!Number.isFinite(updatedAt)
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
if (!Number.isFinite(updatedAt)) return false;
|
|
60
|
+
|
|
61
|
+
// Primary check: run hasn't been updated in a while
|
|
62
|
+
if (now - updatedAt >= staleMs) {
|
|
63
|
+
if (agents.length === 0) return run.summary === "Creating workflow prompts and placeholder results.";
|
|
64
|
+
return agents.every((agent) => agent.status === "queued" && !agent.completedAt && !agent.progress);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Secondary check: run has been running without any progress for too long
|
|
68
|
+
if (now - updatedAt >= ORPHANED_NO_PROGRESS_MS) {
|
|
69
|
+
// If no agent is "running" or has made progress, the run is likely stuck
|
|
70
|
+
const hasActiveAgent = agents.some((agent) => agent.status === "running" || agent.progress || agent.toolUses);
|
|
71
|
+
if (!hasActiveAgent && agents.length > 0) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return false;
|
|
49
77
|
}
|
|
50
78
|
|
|
51
79
|
function hasDurableActiveAgentEvidence(agent: CrewAgentRecord): boolean {
|