pi-crew 0.2.15 → 0.2.17
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
|
@@ -94,32 +94,37 @@ export function registerCompactionGuard(pi: ExtensionAPI, options: RegisterCompa
|
|
|
94
94
|
});
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
// Phase 1.2:
|
|
97
|
+
// Phase 1.2: Always allow compaction to proceed.
|
|
98
|
+
// Previously this deferred compaction during foreground runs, but that prevented
|
|
99
|
+
// context-mode's PreCompact hook from running (which needs compaction to build resume snapshots).
|
|
100
|
+
// pi-crew state is preserved via customInstructions and artifactIndex appended above.
|
|
98
101
|
pi.on("session_before_compact", async (_event, ctx) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (ratio !== undefined && ratio >= HARD_RATIO) {
|
|
102
|
-
ctx.ui.notify("Compaction allowed despite foreground run: context is critically full", "warning");
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
pendingCompactReason = "deferred-during-foreground-run";
|
|
106
|
-
ctx.ui.notify("Compaction deferred: foreground team run in progress", "info");
|
|
107
|
-
return { cancel: true };
|
|
102
|
+
// Always allow compaction - context-mode needs it for resume snapshots
|
|
103
|
+
return;
|
|
108
104
|
});
|
|
109
105
|
|
|
110
|
-
// Phase 2.1: Proactive compaction with dynamic threshold
|
|
106
|
+
// Phase 2.1: Proactive compaction with dynamic threshold.
|
|
107
|
+
// Only trigger compaction when context usage >=75%, or when deferred from a previous high-usage turn.
|
|
111
108
|
pi.on("turn_end", (_event, ctx) => {
|
|
112
109
|
if (compactionInProgress) return;
|
|
113
110
|
const hasActiveForeground = options.foregroundControllers.size > 0 || options.foregroundTeamRunControllers.size > 0;
|
|
111
|
+
const ratio = usageRatio(ctx);
|
|
112
|
+
// If deferred compaction is pending and foreground just ended, check if still needed
|
|
114
113
|
if (!hasActiveForeground && pendingCompactReason) {
|
|
115
114
|
pendingCompactReason = null;
|
|
115
|
+
// Only compact if ratio still >= TRIGGER_RATIO, otherwise skip
|
|
116
|
+
if (ratio === undefined || ratio < TRIGGER_RATIO) return;
|
|
116
117
|
startCompact(ctx, "deferred");
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
|
-
const ratio = usageRatio(ctx);
|
|
120
120
|
if (ratio === undefined || ratio < TRIGGER_RATIO) return;
|
|
121
|
+
// During foreground run: defer unless context is critically full
|
|
121
122
|
if (hasActiveForeground) {
|
|
122
|
-
|
|
123
|
+
if (ratio >= HARD_RATIO) {
|
|
124
|
+
startCompact(ctx, "critical");
|
|
125
|
+
} else {
|
|
126
|
+
pendingCompactReason = "threshold-during-foreground-run";
|
|
127
|
+
}
|
|
123
128
|
return;
|
|
124
129
|
}
|
|
125
130
|
startCompact(ctx, "threshold");
|
package/src/ui/crew-widget.ts
CHANGED
|
@@ -121,7 +121,10 @@ function agentActivity(agent: CrewAgentRecord, liveHandle?: LiveAgentHandle): st
|
|
|
121
121
|
}
|
|
122
122
|
if (agent.progress?.currentTool) return `${TOOL_LABELS[agent.progress.currentTool] ?? agent.progress.currentTool}…`;
|
|
123
123
|
const recent = agent.progress?.recentOutput?.at(-1);
|
|
124
|
-
if (recent)
|
|
124
|
+
if (recent) {
|
|
125
|
+
const cleaned = recent.replace(/\s+/g, " ").trim();
|
|
126
|
+
return cleaned.length > 60 ? cleaned.slice(0, 60) + "…" : cleaned;
|
|
127
|
+
}
|
|
125
128
|
if (agent.progress?.activityState === "needs_attention") return "needs attention";
|
|
126
129
|
if (agent.status === "queued") return "queued";
|
|
127
130
|
if (agent.status === "running") {
|
|
@@ -165,9 +168,20 @@ function agentStats(agent: CrewAgentRecord, liveHandle?: LiveAgentHandle): strin
|
|
|
165
168
|
// If distance to seconds is much smaller AND value is in valid seconds range
|
|
166
169
|
return distToSec < distToMs && distToSec < 31536000 * 2 && v > 1000000000;
|
|
167
170
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
// Simple fix: detect if value is Unix seconds and convert properly
|
|
172
|
+
// Unix seconds are ~10 digits (e.g., 1779082445), Unix ms are ~13 digits (e.g., 1779082445000)
|
|
173
|
+
const toMs = (v: number): number => {
|
|
174
|
+
if (v <= 0) return 0;
|
|
175
|
+
// If 10 digits (or 9 with recent), treat as seconds
|
|
176
|
+
if (v > 1000000000 && v < 10000000000) return v * 1000;
|
|
177
|
+
// If 13 digits, treat as ms
|
|
178
|
+
if (v > 100000000000 && v < 10000000000000) return v;
|
|
179
|
+
// Fallback: use as-is
|
|
180
|
+
return v;
|
|
181
|
+
};
|
|
182
|
+
const startedMs = toMs(rawStarted);
|
|
183
|
+
const completedMs = rawCompleted > 0 ? toMs(rawCompleted) : 0;
|
|
184
|
+
// Validate bounds
|
|
171
185
|
const isValidStarted = startedMs > 0 && startedMs < nowMs + 60000 && startedMs > nowMs - 3155692600000;
|
|
172
186
|
const isValidCompleted = completedMs === 0 || (completedMs > 0 && completedMs < nowMs + 60000);
|
|
173
187
|
const ms = (isValidCompleted ? completedMs : nowMs) - (isValidStarted ? startedMs : nowMs);
|
|
@@ -68,15 +68,19 @@ export class LiveConversationOverlay {
|
|
|
68
68
|
const rawCompleted = act.completedAtMs || 0;
|
|
69
69
|
const nowMs = Date.now();
|
|
70
70
|
const nowSec = Math.floor(nowMs / 1000);
|
|
71
|
-
//
|
|
72
|
-
const
|
|
73
|
-
if (v <= 0) return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
// Simple fix: detect if value is Unix seconds and convert properly
|
|
72
|
+
const toMs = (v: number): number => {
|
|
73
|
+
if (v <= 0) return 0;
|
|
74
|
+
// If 10 digits (or 9 with recent), treat as seconds
|
|
75
|
+
if (v > 1000000000 && v < 10000000000) return v * 1000;
|
|
76
|
+
// If 13 digits, treat as ms
|
|
77
|
+
if (v > 100000000000 && v < 10000000000000) return v;
|
|
78
|
+
// Fallback: use as-is
|
|
79
|
+
return v;
|
|
77
80
|
};
|
|
78
|
-
const startedMs =
|
|
79
|
-
const completedMs =
|
|
81
|
+
const startedMs = toMs(rawStarted);
|
|
82
|
+
const completedMs = rawCompleted > 0 ? toMs(rawCompleted) : 0;
|
|
83
|
+
// Validate bounds
|
|
80
84
|
const isValidStarted = startedMs > 0 && startedMs < nowMs + 60000 && startedMs > nowMs - 3155692600000;
|
|
81
85
|
const isValidCompleted = completedMs === 0 || (completedMs > 0 && completedMs < nowMs + 60000);
|
|
82
86
|
return (isValidCompleted ? completedMs : nowMs) - (isValidStarted ? startedMs : nowMs);
|