paseo-follow-up 2.2.1-beta.0 → 2.2.1-beta.1
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/client/home.tsx +26 -1
- package/client/tasks.tsx +6 -4
- package/index.server.ts +2 -0
- package/package.json +1 -1
- package/server/daemon.ts +28 -13
- package/server/engine.ts +19 -6
- package/server/mcp-source.ts +1 -1
- package/server/mcp.mjs +1 -1
- package/shared/attention.ts +8 -3
- package/shared/model.ts +10 -1
- package/shared/send-decision.ts +38 -4
- package/shared/status-invariants.ts +17 -3
package/client/home.tsx
CHANGED
|
@@ -137,7 +137,7 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
137
137
|
try {
|
|
138
138
|
const after = await send({ workspaceId: s.workspaceId, batchId: s.sendNow.batchId });
|
|
139
139
|
const b = after.batches.find(x => x.id === s.sendNow!.batchId);
|
|
140
|
-
toast.show(!b || ["sent", "sending", "completed"].includes(b.state) ? `Sent to ${s.title}` : b.result || "Queued. It goes out when the agent is free.", { variant: !b || ["sent", "sending", "completed"].includes(b.state) ? "success" : "info" });
|
|
140
|
+
toast.show(!b || ["sent", "sending", "completed"].includes(b.state) ? `Sent to ${s.title}` : b.result || "Queued. It goes out when the main agent is free.", { variant: !b || ["sent", "sending", "completed"].includes(b.state) ? "success" : "info" });
|
|
141
141
|
} catch (e) { toast.error(errorText(e)); } finally { deps.sources.live.refresh(); }
|
|
142
142
|
}, [send, toast, deps.sources.live]);
|
|
143
143
|
// The omnibox's "Ask the Overseer" row: send, then show the conversation it lands in.
|
|
@@ -368,6 +368,30 @@ function useTail(handle: ReturnType<typeof useAgentLive>["handle"], key: string,
|
|
|
368
368
|
return { steps, error, seenAt, asleep, loading, woken: wake > 0, load: () => setWake(n => n + 1) };
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Send now under a queued message's line in the detail pane: phones list Sending rows without it (dense rows), so this
|
|
373
|
+
* is where a phone sends a waiting repair (a-repair-goes-to-a-free-main-agent). The same Send as the row's and the
|
|
374
|
+
* Tasks strip's: taken while the main agent is busy, it goes the moment the main agent is free.
|
|
375
|
+
*/
|
|
376
|
+
function DetailSendNow({ s, theme, compact, deps }: { s: Workstream; theme: Theme; compact: boolean; deps: HomeDeps }) {
|
|
377
|
+
const send = useRpc(sendRpc); const toast = useToast();
|
|
378
|
+
const [busy, setBusy] = useState(false);
|
|
379
|
+
const n = s.sendNow!.count;
|
|
380
|
+
const press = async () => {
|
|
381
|
+
if (!s.workspaceId || !s.sendNow) return;
|
|
382
|
+
setBusy(true);
|
|
383
|
+
try {
|
|
384
|
+
const after = await send({ workspaceId: s.workspaceId, batchId: s.sendNow.batchId });
|
|
385
|
+
const b = after.batches.find(x => x.id === s.sendNow!.batchId);
|
|
386
|
+
const out = !b || ["sent", "sending", "completed"].includes(b.state);
|
|
387
|
+
toast.show(out ? `Sent to ${s.title}` : b.result || "Queued. It goes out when the main agent is free.", { variant: out ? "success" : "info" });
|
|
388
|
+
} catch (e) { toast.error(errorText(e)); } finally { setBusy(false); deps.sources.live.refresh(); }
|
|
389
|
+
};
|
|
390
|
+
return <View style={{ flexDirection: "row" }}>
|
|
391
|
+
<Button theme={theme} compact={compact} kind="secondary" title="Send now" accessibilityLabel={`Send ${n} task${n === 1 ? "" : "s"} to ${s.title} now`} loading={busy} disabled={busy} onPress={() => void press()} />
|
|
392
|
+
</View>;
|
|
393
|
+
}
|
|
394
|
+
|
|
371
395
|
function DetailPane({ s, model, theme, compact, deps, openFull, signOffNext, ask, onBack }: {
|
|
372
396
|
s: Workstream; model: HomeModel; theme: Theme; compact: boolean; deps: HomeDeps;
|
|
373
397
|
openFull: (s: Workstream) => void; signOffNext: (s: Workstream) => void; onBack?: () => void;
|
|
@@ -556,6 +580,7 @@ function DetailPane({ s, model, theme, compact, deps, openFull, signOffNext, ask
|
|
|
556
580
|
: echoed || (b && compact && b.source === "none" && asks.length) ? null
|
|
557
581
|
: row?.needs && !agent.permissions.length && !b ? <Text style={compact ? t.ask : [t.body, { fontSize: 15, lineHeight: 21, fontWeight: "600" }]}>{s.line || s.word || "Needs you"}</Text>
|
|
558
582
|
: !row?.needs && s.line ? <Text style={t.body}>{s.line}</Text> : null}
|
|
583
|
+
{!row?.needs && s.sendNow && <DetailSendNow s={s} theme={theme} compact={compact} deps={deps} />}
|
|
559
584
|
{w && <NeedsYouBlock workspace={w} theme={theme} compact={compact} now={Date.now()} style={{ marginHorizontal: 0, marginTop: 0 }}
|
|
560
585
|
brief={inBlock ? b : null} briefCard={inBlock && <BriefCard {...({ embedded: true, bare: true, item: { data: b }, theme, layout: { compact }, agentId: s.agentId, deps: deps.briefDeps } as unknown as Parameters<typeof BriefCard>[0])} />}
|
|
561
586
|
actions={{ openPr: (key, intent) => setSheet({ key, intent }), openQuestion: setQuestion, openAgent: () => openFull(s) }} />}
|
package/client/tasks.tsx
CHANGED
|
@@ -169,14 +169,16 @@ function StripRow({ strip, w, theme, compact, onPreview, openAgent }: { strip: M
|
|
|
169
169
|
try {
|
|
170
170
|
const result = await send({ workspaceId: w.id, batchId: strip.batchId });
|
|
171
171
|
const b = result.batches.find(x => x.id === strip.batchId);
|
|
172
|
-
toast.show(!b || ["sent", "sending", "completed"].includes(b.state) ? `Sent to ${strip.to}` : b.state === "pending" ? "Queued. It goes out when the agent is free." : b.result || "The message couldn't be sent.", { variant: !b || ["sent", "sending", "completed"].includes(b.state) ? "success" : "info" });
|
|
172
|
+
toast.show(!b || ["sent", "sending", "completed"].includes(b.state) ? `Sent to ${strip.to}` : b.state === "pending" ? "Queued. It goes out when the main agent is free." : b.result || "The message couldn't be sent.", { variant: !b || ["sent", "sending", "completed"].includes(b.state) ? "success" : "info" });
|
|
173
173
|
} catch (error) { toast.error(error instanceof Error ? error.message : "The message couldn't be sent."); }
|
|
174
174
|
finally { setBusy(false); void cache.invalidateQueries(); }
|
|
175
175
|
};
|
|
176
|
-
|
|
176
|
+
// The why is the point of the row (a-repair-goes-to-a-free-main-agent): it keeps a readable width, and the buttons
|
|
177
|
+
// wrap under it in a narrow panel instead of squeezing it into a column.
|
|
178
|
+
return <View accessibilityRole="summary" style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8, rowGap: 8, paddingHorizontal: compact ? 14 : 12, paddingVertical: compact ? 12 : 8, borderTopWidth: 1, borderTopColor: c.border, backgroundColor: c.surface1 }}>
|
|
177
179
|
<Icon name="Send" size={13} color={c.foregroundMuted} />
|
|
178
|
-
<Text style={[t.meta, {
|
|
179
|
-
<View style={{ flexDirection: "row", gap: 8, marginLeft:
|
|
180
|
+
<Text style={[t.meta, { flexGrow: 1, flexShrink: 1, flexBasis: compact ? "80%" : 240, minWidth: 0 }]}><Text style={{ color: c.foreground, fontWeight: "500" }}>{line.lead}</Text>{line.rest}</Text>
|
|
181
|
+
<View style={{ flexDirection: "row", gap: 8, marginLeft: "auto" }}>
|
|
180
182
|
{strip.phase === "queued" && <Button theme={theme} compact={compact} title="Preview" accessibilityLabel={`Preview the next message to ${strip.to}`} onPress={onPreview} />}
|
|
181
183
|
{strip.phase === "queued" && strip.sendNow && <Button theme={theme} compact={compact} title="Send now" accessibilityLabel={`Send ${tasks(strip.count)} to ${strip.to} now`} loading={busy} disabled={busy} onPress={() => void sendNow()} />}
|
|
182
184
|
{strip.phase === "sent" && openAgent && <Button theme={theme} compact={compact} title="Open agent" accessibilityLabel={`Open ${strip.to}`} onPress={() => openAgent(strip.recipientId)} />}
|
package/index.server.ts
CHANGED
|
@@ -196,6 +196,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
196
196
|
// Settings → Agents: which agent each special role uses, in agents.json (defaults when absent).
|
|
197
197
|
const agentSettings = new AgentSettingsStore(directory);
|
|
198
198
|
gateway.recoveryRole = () => agentSettings.role("recovery");
|
|
199
|
+
// The main agent's own background job holds its repairs only while Wait for background jobs is on (Q96 = A).
|
|
200
|
+
gateway.waitForJobs = () => agentSettings.waitEnabled();
|
|
199
201
|
const graphite = new Graphite();
|
|
200
202
|
const github = new Github(undefined, graphite, new Deployments(undefined, undefined, undefined, undefined, repo => prWorkflow.current().repos[repoKey(repo)]?.deploy));
|
|
201
203
|
github.workflow = repo => prWorkflow.workflow(repo);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.2.1-beta.
|
|
4
|
+
"version": "2.2.1-beta.1",
|
|
5
5
|
"description": "A Paseo plugin that follows every workspace until the work is done: one Home for what needs you, questions you answer anywhere, and repairs that send themselves.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
package/server/daemon.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { readSharedJson } from "./shared-file";
|
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
import type { Workspace, Batch } from "../shared/model";
|
|
11
11
|
import type { Gateway, Runtime } from "./engine";
|
|
12
|
+
import { MAIN_WAIT, QUIET_WAIT, repairWait } from "../shared/send-decision";
|
|
12
13
|
import type { State } from "../shared/model";
|
|
13
14
|
import { defaultTracking, followsEvery, optedOut, projectSetting, type Project } from "../shared/settings";
|
|
14
15
|
import { recoveryHandoff } from "./recovery-handoff";
|
|
@@ -480,6 +481,9 @@ export class PaseoGateway implements Gateway {
|
|
|
480
481
|
*/
|
|
481
482
|
/** A new engine tick: sends re-list agents at most once in it (a-send-lists-agents-at-most-once-per-tick). */
|
|
482
483
|
tickStarted(): void { this.directory.tickStarted(); }
|
|
484
|
+
/** Settings → Agents → Wait for background jobs (index.server.ts sets it). Unset or unreadable: on (Unknown is not off). */
|
|
485
|
+
waitForJobs?: () => Promise<boolean>;
|
|
486
|
+
private async waitsForJobs(): Promise<boolean> { try { return (await this.waitForJobs?.()) ?? true; } catch { return true; } }
|
|
483
487
|
async observe(w: Workspace, fresh = false): Promise<Runtime> {
|
|
484
488
|
const [rows, compacting, pauses] = await Promise.all([this.directory.read(fresh ? { fresh: "agents" } : {}), this.compacting(w.mainAgentId), this.guard.read()]);
|
|
485
489
|
const { agents, workspaces } = rows;
|
|
@@ -500,29 +504,37 @@ export class PaseoGateway implements Gateway {
|
|
|
500
504
|
const guarded = this.guard.waiting(pauses, { agentIds: [w.mainAgentId, ...scoped.map(agent => agent.id)], workspaceId: w.id, excludedAgentIds: [...recoveryIds].filter((id): id is string => !!id) });
|
|
501
505
|
const guardedInterruptionId = this.guard.ownsInterruption(pauses, w.mainAgentId, w.interruption)?.id;
|
|
502
506
|
const context = { guardedInterruptionId, mainTurnId: turnIdOf(a.activeTurn), mainTitle: a.title?.trim() || null };
|
|
503
|
-
if (guarded || !pauses && workspace.labels?.some(label => /^(Paused|Paused by Session Guard)$/i.test(label))) return { taskAgents, ...context, guarded: true, busy: false, reason: "Waiting for Session Guard to resume this workspace", archived: false };
|
|
504
|
-
if (compacting) return { taskAgents, busy: true, reason: "Smart Session is compacting the main agent", archived: false };
|
|
507
|
+
if (guarded || !pauses && workspace.labels?.some(label => /^(Paused|Paused by Session Guard)$/i.test(label))) return { taskAgents, ...context, guarded: true, busy: false, mainBusy: "guard", reason: "Waiting for Session Guard to resume this workspace", archived: false };
|
|
508
|
+
if (compacting) return { taskAgents, busy: true, mainBusy: "compacting", reason: "Smart Session is compacting the main agent", archived: false };
|
|
505
509
|
const mainLoaded = isLoaded(a), mainRecent = recentlyUsed(a, this.windowMs, this.now());
|
|
506
510
|
if (conversationGone(a.lastError)) return { taskAgents, busy: false, reason: a.lastError ?? "Conversation not found", archived: false, gone: a.lastError ?? "Conversation not found", mainLoaded, mainRecent };
|
|
507
|
-
if (a.pendingPermissions.length || a.status === "error") return { taskAgents, busy: false, reason: a.status === "error" ? "Main agent needs recovery" : "Main agent is waiting for a permission or answer", archived: false };
|
|
508
|
-
|
|
511
|
+
if (a.pendingPermissions.length || a.status === "error") return { taskAgents, busy: false, ...(a.status === "error" ? {} : { mainBusy: "permission" as const }), reason: a.status === "error" ? "Main agent needs recovery" : "Main agent is waiting for a permission or answer", archived: false };
|
|
512
|
+
// One busy computation, two scopes (Q96 = A, a-repair-goes-to-a-free-main-agent). `busy` and `backgroundBusy` are the
|
|
513
|
+
// whole workspace: Done, a sent message's turn, "all work finished". `mainBusy` is the main agent's own work, and only
|
|
514
|
+
// it holds a repair: its turn, and its own background job while Wait for background jobs is on. Another agent in the
|
|
515
|
+
// workspace (a subagent the main agent started) and provider subagents never hold a repair. 2026-11-18: a repair sat
|
|
516
|
+
// pending over two hours while the main agent was idle and a subagent it started ran one task after another.
|
|
517
|
+
let busy = false; let backgroundBusy = false; let mainBusy: "turn" | "jobs" | null = null;
|
|
509
518
|
const members = here.filter(agent => !recoveryIds.has(agent.id) && !isRecovery(agent.labels));
|
|
510
519
|
for (const agent of members) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
520
|
+
const main = agent.id === w.mainAgentId;
|
|
521
|
+
if (["running", "initializing"].includes(agent.status)) { busy = true; if (main) mainBusy = "turn"; else backgroundBusy = true; }
|
|
522
|
+
// 0.16: work an agent started and ended its turn on (a shell, a task) is still work: no Done yet, and the main
|
|
523
|
+
// agent's own job holds its repairs while Wait for background jobs is on.
|
|
524
|
+
else if (backgroundCount(agent) > 0) { backgroundBusy = true; if (main && await this.waitsForJobs()) mainBusy = "jobs"; }
|
|
514
525
|
}
|
|
515
|
-
// Subagents only decide
|
|
516
|
-
//
|
|
517
|
-
const
|
|
518
|
-
|
|
526
|
+
// Subagents only decide the whole workspace's quiet: Done, a sent message's turn, and the Done check's send (a fresh
|
|
527
|
+
// read). Repairs never wait for them (Q96 = A), so a queued repair, or its send, never lists subagents (2026-11-12).
|
|
528
|
+
const doneCheckGoing = (b: Workspace["batches"][number]) => fresh && ["pending", "sending"].includes(b.state) && b.tasks.some(t => t.kind === "completion");
|
|
529
|
+
// A Done declaration is waiting to be accepted: Done needs the whole workspace quiet, subagents included.
|
|
530
|
+
const subagentsMatter = !!w.completion || !!w.declaration || w.batches.some(b => !b.tasks.every(t => t.kind === "inventory") && (b.state === "sent" || doneCheckGoing(b)));
|
|
519
531
|
const idleLoaded = members.filter(agent => isLoaded(agent) && !["running", "initializing"].includes(agent.status));
|
|
520
532
|
if (subagentsMatter && !backgroundBusy && idleLoaded.length) await this.connect(async client => {
|
|
521
533
|
for (const listed of idleLoaded) {
|
|
522
534
|
if (await subagentsRunning(client, listed, "Subagent observation unavailable", this.directory)) { busy = true; backgroundBusy = true; break; }
|
|
523
535
|
}
|
|
524
536
|
});
|
|
525
|
-
return { taskAgents, ...context, busy, reason: null, archived: false, backgroundBusy, mainLoaded, mainRecent };
|
|
537
|
+
return { taskAgents, ...context, busy, reason: null, archived: false, backgroundBusy, mainBusy, mainLoaded, mainRecent };
|
|
526
538
|
}
|
|
527
539
|
async recoveryRuntime(w: Workspace, batch: Batch): Promise<{ busy: boolean; reason: string | null }> {
|
|
528
540
|
return this.connect(async client => {
|
|
@@ -551,7 +563,10 @@ export class PaseoGateway implements Gateway {
|
|
|
551
563
|
// The dispatch observed fresh this tick; this re-check reads the same tick's list (a-send-lists-agents-at-most-once-per-tick).
|
|
552
564
|
try { runtime = await this.observe(w, true); }
|
|
553
565
|
catch { throw new DeliveryDeferred("Agent or Session Guard state is unavailable; follow-up will wait and retry."); }
|
|
554
|
-
|
|
566
|
+
// A repair waits only for the main agent itself (Q96 = A); the Done check for the whole workspace to be quiet.
|
|
567
|
+
const main = repairWait(runtime);
|
|
568
|
+
const holds = batch.tasks.some(t => t.kind === "completion") ? (runtime.busy || runtime.backgroundBusy ? QUIET_WAIT : null) : main && MAIN_WAIT[main];
|
|
569
|
+
if (holds || runtime.reason || runtime.archived) throw new DeliveryDeferred(holds || runtime.reason || "The workspace was archived.");
|
|
555
570
|
}
|
|
556
571
|
await this.connect(async client => {
|
|
557
572
|
const recipient = batch.recipientAgentId ?? w.mainAgentId;
|
package/server/engine.ts
CHANGED
|
@@ -19,12 +19,18 @@ import { PASEO_UNREACHABLE, deliveryOf, type NewQueueItem, type QueueItem, type
|
|
|
19
19
|
import { recordSnapshot } from "./deployment-anchor";
|
|
20
20
|
import { pruneUnsent } from "./batch-archive";
|
|
21
21
|
import { holdSuperseded, liftHold } from "../shared/status";
|
|
22
|
-
import { conditionId, isCapped, mootReason, personHeld, readSince, sendDecision, settleUnacknowledged, stillApplies, stuckRepair, UNACKNOWLEDGED_MS } from "../shared/send-decision";
|
|
22
|
+
import { conditionId, isCapped, MAIN_WAIT, mootReason, personHeld, QUIET_WAIT, readSince, repairWait, sendDecision, settleUnacknowledged, stillApplies, stuckRepair, UNACKNOWLEDGED_MS, type MainWait } from "../shared/send-decision";
|
|
23
23
|
import { isRepair } from "../shared/task-rows";
|
|
24
|
-
export { settleUnacknowledged, UNACKNOWLEDGED_MS, NO_PROGRESS_CAP } from "../shared/send-decision";
|
|
24
|
+
export { settleUnacknowledged, UNACKNOWLEDGED_MS, NO_PROGRESS_CAP, repairWait, QUIET_WAIT } from "../shared/send-decision";
|
|
25
25
|
|
|
26
26
|
export interface Runtime {
|
|
27
27
|
busy: boolean; reason: string | null; archived: boolean; backgroundBusy?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* What the main agent itself is doing that holds a repair (Workspace.mainBusy, Q96 = A). `busy` and `backgroundBusy`
|
|
30
|
+
* are the whole workspace (Done, "all work finished"); only this decides a repair. Undefined: unknown, so a repair
|
|
31
|
+
* treats the workspace's busy as the main agent's (repairWait).
|
|
32
|
+
*/
|
|
33
|
+
mainBusy?: MainWait | null;
|
|
28
34
|
/** Live state of the agents working tasks name (Workspace.taskAgents). Undefined: unknown, so every line naming an agent says "Agent unavailable". */
|
|
29
35
|
taskAgents?: Workspace["taskAgents"];
|
|
30
36
|
guarded?: boolean; guardedInterruptionId?: string;
|
|
@@ -259,6 +265,7 @@ export class Engine {
|
|
|
259
265
|
if (!untouched) await this.store.mutateWorkspace(original.id, w => {
|
|
260
266
|
w.runtimeBusy = runtime.busy; w.runtimeReason = runtime.reason; w.taskAgents = runtime.taskAgents;
|
|
261
267
|
w.backgroundBusy = runtime.backgroundBusy ?? false;
|
|
268
|
+
w.mainBusy = repairWait(runtime);
|
|
262
269
|
if (runtime.mainTitle !== undefined && (w.mainAgentTitle ?? null) !== runtime.mainTitle) w.mainAgentTitle = runtime.mainTitle;
|
|
263
270
|
if (runtime.gone && w.goneAgent?.agentId !== w.mainAgentId) w.goneAgent = { agentId: w.mainAgentId, at: new Date(this.now()).toISOString(), reason: runtime.gone };
|
|
264
271
|
if (w.goneAgent?.agentId === w.mainAgentId) w.runtimeReason = GONE_REASON;
|
|
@@ -343,8 +350,8 @@ export class Engine {
|
|
|
343
350
|
const heldItem = held && this.queue?.get(repairItemId(current.id, held.id));
|
|
344
351
|
// An Auto send keeps its own pace (a refusal retries once per settle window: the-send-line-matches-the-send-decision);
|
|
345
352
|
// only the developer's Send, or any repair waiting out a turn, goes on this tick.
|
|
346
|
-
const due = heldItem?.state === "queued" && !!heldItem.reason && (heldItem.reason
|
|
347
|
-
if (due && !runtime
|
|
353
|
+
const due = heldItem?.state === "queued" && !!heldItem.reason && (MAIN_WAITS.has(heldItem.reason) || !heldItem.ref.automatic && heldAgentSide(heldItem.reason));
|
|
354
|
+
if (due && !repairWait(runtime) && !runtime.reason) await this.queue!.retry(heldItem!.id).catch(() => undefined);
|
|
348
355
|
current = findWorkspace(await this.store.snapshot(), original.id);
|
|
349
356
|
const done = !current.archived && !!current.completion && completionBlockers(current, this.now()).length === 0;
|
|
350
357
|
if (done || current.managedDoneLabel) {
|
|
@@ -527,7 +534,10 @@ export class Engine {
|
|
|
527
534
|
try { runtime = await this.gateway.observe(w, true); }
|
|
528
535
|
catch { return { defer: "Paseo unreachable" }; }
|
|
529
536
|
if (runtime.archived) return { cancel: "The workspace was archived." };
|
|
530
|
-
|
|
537
|
+
// A repair waits only for the main agent itself (Q96 = A); the Done check waits for the whole workspace to be quiet.
|
|
538
|
+
if (completionCheck(b) && (runtime.busy || runtime.backgroundBusy)) return { defer: QUIET_WAIT };
|
|
539
|
+
const holds = repairWait(runtime);
|
|
540
|
+
if (holds) return { defer: MAIN_WAIT[holds] };
|
|
531
541
|
if (runtime.reason) return { defer: runtime.reason };
|
|
532
542
|
// The runtime read awaited Paseo: what the developer changed meanwhile (Auto off, a hold) still wins.
|
|
533
543
|
const fresh = (await this.store.snapshot()).workspaces.find(x => x.id === w.id);
|
|
@@ -594,7 +604,7 @@ export class Engine {
|
|
|
594
604
|
if (!b || this.queue?.get(repairItemId(w.id, b.id))) return [];
|
|
595
605
|
if (!sendDecision({ ...w, sendWait: null }, this.now(), { settleMs: 0, batch: b }).send || this.autoSendsHeld()) return [];
|
|
596
606
|
const runtime = await this.gateway.observe(w, true).catch(() => null);
|
|
597
|
-
if (!runtime || runtime
|
|
607
|
+
if (!runtime || repairWait(runtime) || runtime.reason || runtime.archived) return [];
|
|
598
608
|
return [this.repairItem(w, b, true)];
|
|
599
609
|
}
|
|
600
610
|
/**
|
|
@@ -697,6 +707,7 @@ export class Engine {
|
|
|
697
707
|
const w = ownedWorkspace(state, agentId, workspaceId);
|
|
698
708
|
w.runtimeBusy = runtime.busy; w.runtimeReason = runtime.reason; w.taskAgents = runtime.taskAgents;
|
|
699
709
|
w.backgroundBusy = runtime.backgroundBusy ?? false;
|
|
710
|
+
w.mainBusy = repairWait(runtime);
|
|
700
711
|
if (runtime.archived) w.archived = true;
|
|
701
712
|
for (const pr of w.prs) {
|
|
702
713
|
const observation = observations.get(pr.key);
|
|
@@ -840,5 +851,7 @@ export function agentWorkspace(state: State, agentId: string, access: "read" | "
|
|
|
840
851
|
export const answerItemId = (workspaceId: string, q: Pick<Question, "id" | "answer">) => `answer:${workspaceId}:${q.id}:${q.answer?.delivery.messageId ?? ""}`;
|
|
841
852
|
/** A batch's queue item: one per batch (a Retry makes a new batch, so a new item). */
|
|
842
853
|
/** A repair's hold that only the agent's runtime can clear, so a tick that sees the agent free retries it. */
|
|
854
|
+
/** The main agent's own waits: a repair held by one goes on the tick that sees the main agent free. */
|
|
855
|
+
const MAIN_WAITS = new Set<string>(Object.values(MAIN_WAIT));
|
|
843
856
|
export const heldAgentSide = (reason: string) => reason !== PASEO_UNREACHABLE && !reason.startsWith("waits for the last message") && !reason.startsWith("waits until GitHub answers");
|
|
844
857
|
export const repairItemId = (workspaceId: string, batchId: string) => `repair:${workspaceId}:${batchId}`;
|
package/server/mcp-source.ts
CHANGED
|
@@ -258,7 +258,7 @@ export const mcpSource: string = [
|
|
|
258
258
|
" if (type === \"string\" && (schema.minLength !== undefined && value.length < schema.minLength || schema.maxLength !== undefined && value.length > schema.maxLength)) throw new Error(`${path}: outside the allowed length.`);",
|
|
259
259
|
"}",
|
|
260
260
|
"function currentWork(w) {",
|
|
261
|
-
" return { id: w.id, title: w.title, goal: w.goal, mainAgentId: w.mainAgentId, enable_tracking: w.enable_tracking, enable_auto_sends: w.enable_auto_sends, hold: w.hold, archived: w.archived, runtimeBusy: w.runtimeBusy, runtimeReason: w.runtimeReason, backgroundBusy: w.backgroundBusy, completion: w.completion,",
|
|
261
|
+
" return { id: w.id, title: w.title, goal: w.goal, mainAgentId: w.mainAgentId, enable_tracking: w.enable_tracking, enable_auto_sends: w.enable_auto_sends, hold: w.hold, archived: w.archived, runtimeBusy: w.runtimeBusy, runtimeReason: w.runtimeReason, backgroundBusy: w.backgroundBusy, mainBusy: w.mainBusy ?? null, completion: w.completion,",
|
|
262
262
|
" prs: w.prs.map(p => ({ key: p.key, stack: p.stack, parent: p.parent, disposition: p.disposition, error: p.error, ...(p.snapshot ? { title: p.snapshot.title, state: p.snapshot.state, head: p.snapshot.head, draft: p.snapshot.draft, reviewDecision: p.snapshot.reviewDecision, conflict: p.snapshot.conflict, openThreads: p.snapshot.threads.length, failedChecks: p.snapshot.failedChecks, otherFailedChecks: p.snapshot.otherFailedChecks ?? [], deployment: p.snapshot.deployment } : {}) })),",
|
|
263
263
|
" obligations: w.obligations.filter(o => ![\"done\", \"waived\"].includes(o.status)), completedObligations: w.obligations.filter(o => [\"done\", \"waived\"].includes(o.status)).length,",
|
|
264
264
|
" openQuestions: (w.questions ?? []).filter(q => !q.answer && !q.closed).map(q => ({ id: q.id, title: q.title, question: q.question, options: q.options, recommend: q.recommend, big: q.big, mode: q.mode, askedBy: q.askedBy, taskId: q.taskId })),",
|
package/server/mcp.mjs
CHANGED
|
@@ -256,7 +256,7 @@ function validate(value, schema, path = "arguments") {
|
|
|
256
256
|
if (type === "string" && (schema.minLength !== undefined && value.length < schema.minLength || schema.maxLength !== undefined && value.length > schema.maxLength)) throw new Error(`${path}: outside the allowed length.`);
|
|
257
257
|
}
|
|
258
258
|
function currentWork(w) {
|
|
259
|
-
return { id: w.id, title: w.title, goal: w.goal, mainAgentId: w.mainAgentId, enable_tracking: w.enable_tracking, enable_auto_sends: w.enable_auto_sends, hold: w.hold, archived: w.archived, runtimeBusy: w.runtimeBusy, runtimeReason: w.runtimeReason, backgroundBusy: w.backgroundBusy, completion: w.completion,
|
|
259
|
+
return { id: w.id, title: w.title, goal: w.goal, mainAgentId: w.mainAgentId, enable_tracking: w.enable_tracking, enable_auto_sends: w.enable_auto_sends, hold: w.hold, archived: w.archived, runtimeBusy: w.runtimeBusy, runtimeReason: w.runtimeReason, backgroundBusy: w.backgroundBusy, mainBusy: w.mainBusy ?? null, completion: w.completion,
|
|
260
260
|
prs: w.prs.map(p => ({ key: p.key, stack: p.stack, parent: p.parent, disposition: p.disposition, error: p.error, ...(p.snapshot ? { title: p.snapshot.title, state: p.snapshot.state, head: p.snapshot.head, draft: p.snapshot.draft, reviewDecision: p.snapshot.reviewDecision, conflict: p.snapshot.conflict, openThreads: p.snapshot.threads.length, failedChecks: p.snapshot.failedChecks, otherFailedChecks: p.snapshot.otherFailedChecks ?? [], deployment: p.snapshot.deployment } : {}) })),
|
|
261
261
|
obligations: w.obligations.filter(o => !["done", "waived"].includes(o.status)), completedObligations: w.obligations.filter(o => ["done", "waived"].includes(o.status)).length,
|
|
262
262
|
openQuestions: (w.questions ?? []).filter(q => !q.answer && !q.closed).map(q => ({ id: q.id, title: q.title, question: q.question, options: q.options, recommend: q.recommend, big: q.big, mode: q.mode, askedBy: q.askedBy, taskId: q.taskId })),
|
package/shared/attention.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { deliveryStatus } from "./queue";
|
|
|
3
3
|
import { sentence } from "./errors";
|
|
4
4
|
import { blockedOnDeveloper, completionCheck, liveWorkingTask, statusKnown, summary, type Task, type Status } from "./model";
|
|
5
5
|
import type { ListBatch as Batch, ListPr as Pr, ListWorkspace as Workspace } from "./list";
|
|
6
|
-
import { IDLE_REASON, NO_PROGRESS_CAP } from "./send-decision";
|
|
6
|
+
import { IDLE_REASON, MAIN_WAIT, NO_PROGRESS_CAP, QUIET_WAIT, mainWait } from "./send-decision";
|
|
7
7
|
import { workingLine } from "./task-status";
|
|
8
8
|
import { followUpObligations, recoveryBatch } from "./follow-up";
|
|
9
9
|
import { orderedStacks, prLink, settledForDisplay, type PrLink } from "./presentation";
|
|
@@ -96,7 +96,11 @@ export const workflowReady = (pr: Pr) => isGithubFlow(pr.snapshot) ? mergeBlocke
|
|
|
96
96
|
/** Why a pending batch cannot be sent right now, or null when Send is available. Mirrors the server's guards. */
|
|
97
97
|
export function sendBlocker(w: Workspace, batch: Batch): string | null {
|
|
98
98
|
if (w.hold) return "Resume follow-up first";
|
|
99
|
-
|
|
99
|
+
// The Done check waits for the whole workspace; a repair only for the main agent's own wait (Q96 = A), said in the
|
|
100
|
+
// send decision's words.
|
|
101
|
+
if (completionCheck(batch) && (w.runtimeBusy || w.backgroundBusy)) return capitalize(QUIET_WAIT);
|
|
102
|
+
const main = mainWait(w);
|
|
103
|
+
if (main) return capitalize(MAIN_WAIT[main]);
|
|
100
104
|
if (w.runtimeReason) return w.runtimeReason;
|
|
101
105
|
if (w.batches.some(other => other.id !== batch.id && ["sending", "sent", "blocked", "uncertain"].includes(other.state))) return "Another batch is still open";
|
|
102
106
|
return null;
|
|
@@ -347,7 +351,8 @@ export function liveLine(w: Workspace, now = Date.now()): { icon: LiveIcon; text
|
|
|
347
351
|
if (w.runtimeReason) return { icon: "waiting", text: w.runtimeReason, since: null };
|
|
348
352
|
// Queued work, in the same words as the agent card and Home (shared/status.ts). Repairs you send by hand live in Needs you.
|
|
349
353
|
if (view?.phase === "queued" && (view.kind === "finish" || w.enable_auto_sends)) return { icon: "waiting", text: view.line, since: view.batch.createdAt };
|
|
350
|
-
|
|
354
|
+
// Say who: the main agent only when it is its own turn (Q96 = A), never for a subagent at work beside an idle main.
|
|
355
|
+
if (w.runtimeBusy) return { icon: "spinner", text: mainWait(w) === "turn" ? "Main agent is working" : "Agents in this workspace are working", since: null };
|
|
351
356
|
// A working task spins only while its recorded agent is running (invariant `a-task-only-says-working-when-its-agent-is`).
|
|
352
357
|
// Otherwise it says what the task row says: "<agent> idle", "<agent> closed", "Agent unavailable" or "In progress", with no spinner.
|
|
353
358
|
const live = liveWorkingTask(w);
|
package/shared/model.ts
CHANGED
|
@@ -138,6 +138,15 @@ export const workspaceSchema = z.object({
|
|
|
138
138
|
sendWait: z.enum(["unloaded", "setup"]).nullable().optional(),
|
|
139
139
|
updatedAt: z.string(), managedDoneLabel: z.boolean(),
|
|
140
140
|
runtimeReason: z.string().nullable(), runtimeBusy: z.boolean(), backgroundBusy: z.boolean().default(false),
|
|
141
|
+
/**
|
|
142
|
+
* What the main agent itself is doing that holds a repair (Q96 = A, invariant a-repair-goes-to-a-free-main-agent): its
|
|
143
|
+
* own turn, its own background job while Wait for background jobs is on, a permission prompt or question, a Session
|
|
144
|
+
* Guard pause or a compaction. Set with runtimeBusy, by the same read
|
|
145
|
+
* (server/daemon.ts observe). runtimeBusy and backgroundBusy stay the whole workspace (Done, "all work finished");
|
|
146
|
+
* other agents and subagents never land here. Absent (a record no refresh has read yet): unknown, so the send
|
|
147
|
+
* decision treats the workspace's busy as the main agent's (Unknown is not off).
|
|
148
|
+
*/
|
|
149
|
+
mainBusy: z.enum(["turn", "jobs", "permission", "guard", "compacting"]).nullable().optional(),
|
|
141
150
|
/** Live state of the agents this workspace's working tasks name, refreshed with runtimeBusy from Paseo's agent list
|
|
142
151
|
* (metadata only). Every surface that says a task's agent is working reads this, never the stored status alone. */
|
|
143
152
|
taskAgents: z.record(z.string(), z.object({ title: z.string().nullable(), state: z.enum(["working", "idle", "closed", "archived"]) })).optional(),
|
|
@@ -272,7 +281,7 @@ export function summary(w: ListWorkspace, now = Date.now()): { status: Status; l
|
|
|
272
281
|
const batch = w.batches.find(b => !recoveryBatch(b) && ["pending", "sending", "sent"].includes(b.state) && !(b.state === "pending" && completionCheck(b)));
|
|
273
282
|
if (batch) return { status: batch.state === "pending" ? "active" : "handling", label: batch.state === "pending" ? w.enable_auto_sends ? "Auto queued" : "Ready to send" : "Agent handling", reason: `${batch.tasks.length} follow-up task${batch.tasks.length === 1 ? "" : "s"} ${batch.state === "pending" ? "queued" : batch.recipientAgentId && batch.recipientAgentId !== w.mainAgentId ? "sent to the recovery agent" : "sent to the main agent"}` };
|
|
274
283
|
const live = liveWorkingTask(w);
|
|
275
|
-
if (w.runtimeBusy || live) return { status: "handling", label: "Agent handling", reason: live?.title ?? "The main agent is working" };
|
|
284
|
+
if (w.runtimeBusy || live) return { status: "handling", label: "Agent handling", reason: live?.title ?? (w.mainBusy === null ? "Agents in this workspace are working" : "The main agent is working") };
|
|
276
285
|
if (w.prs.some(pr => !statusKnown(pr))) return { status: "waiting", label: "Waiting", reason: "PR status unavailable; refresh will retry" };
|
|
277
286
|
const pending = obligations.find(o => !["done", "waived"].includes(o.status));
|
|
278
287
|
if (pending) return { status: pending.status === "waiting" ? "waiting" : "active", label: pending.status === "waiting" ? "Waiting" : "Active", reason: pending.title };
|
package/shared/send-decision.ts
CHANGED
|
@@ -39,6 +39,38 @@ const iso = (ms: number) => new Date(ms).toISOString();
|
|
|
39
39
|
/** The reason the settle gives: why "in a minute" and not now (Tom, 2026-11-12: "sending in a moment? why not now?"). */
|
|
40
40
|
export const SETTLE_REASON = "waits a minute so new changes join the same message";
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Why a repair waits on the main agent itself, said the same on every surface and in the queue (Q96 = A). Only the
|
|
44
|
+
* main agent's own work holds a repair: never another agent in the workspace, never a subagent.
|
|
45
|
+
*/
|
|
46
|
+
export const MAIN_WAIT = {
|
|
47
|
+
turn: "sends when the main agent's turn ends, so it isn't interrupted",
|
|
48
|
+
jobs: "sends when the main agent's background job ends (Wait for background jobs is on)",
|
|
49
|
+
permission: "sends once the main agent's permission prompt is answered",
|
|
50
|
+
guard: "sends when Session Guard resumes the main agent",
|
|
51
|
+
compacting: "sends when Smart Session finishes compacting the main agent",
|
|
52
|
+
} as const;
|
|
53
|
+
export type MainWait = keyof typeof MAIN_WAIT;
|
|
54
|
+
/** Auto-send is off for the workspace: the repair waits for the developer's Send. */
|
|
55
|
+
export const AUTO_OFF_REASON = "Auto-send is off here, so it waits for your Send";
|
|
56
|
+
/**
|
|
57
|
+
* The main agent's own wait. A record no refresh has read yet (`mainBusy` absent) counts the workspace's busy as the
|
|
58
|
+
* main agent's: unknown is not off.
|
|
59
|
+
*/
|
|
60
|
+
export const mainWait = (w: Pick<Workspace, "mainBusy" | "runtimeBusy" | "backgroundBusy">): MainWait | null =>
|
|
61
|
+
repairWait({ busy: w.runtimeBusy, backgroundBusy: w.backgroundBusy, mainBusy: w.mainBusy });
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* What holds a repair: the main agent's own wait (Runtime.mainBusy, Q96 = A). A gateway that doesn't say (undefined)
|
|
65
|
+
* counts the workspace's busy as the main agent's: unknown is not off.
|
|
66
|
+
*/
|
|
67
|
+
export function repairWait(runtime: { busy: boolean; backgroundBusy?: boolean; mainBusy?: MainWait | null }): MainWait | null {
|
|
68
|
+
if (runtime.mainBusy !== undefined) return runtime.mainBusy;
|
|
69
|
+
return runtime.busy ? "turn" : runtime.backgroundBusy ? "jobs" : null;
|
|
70
|
+
}
|
|
71
|
+
/** The Done check reads whether all work is finished, so it alone still waits for every agent in the workspace. */
|
|
72
|
+
export const QUIET_WAIT = "waits until every agent in the workspace is done, so the check sees finished work";
|
|
73
|
+
|
|
42
74
|
/**
|
|
43
75
|
* The one auto-send rule (status invariant the-send-line-matches-the-send-decision). The worker's refresh sends the
|
|
44
76
|
* queued batch when, and only when, `send` is true; the batch line on every surface (shared/status.ts) and the Tasks
|
|
@@ -52,19 +84,21 @@ export function sendDecision(w: Workspace, now: number, o: { settleMs?: number;
|
|
|
52
84
|
// What the developer's own Send (Engine.sendPending/dispatch) refuses, checked in the same order.
|
|
53
85
|
const prUnread = b && needsPrObservations(w, b) ? w.prs.find(p => p.error || !p.snapshot?.complete) : undefined;
|
|
54
86
|
const openBatch = !!b && w.batches.some(x => x.id !== b.id && !recoveryBatch(x) && OPEN_BATCH_STATES.includes(x.state));
|
|
87
|
+
// The developer's Send is taken while the main agent is busy: it goes the moment the main agent is free (Q96).
|
|
55
88
|
const canSendNow = !!b && b.state === "pending" && !recoveryBatch(b) && !w.archived && w.enable_tracking && !w.hold && !w.goneAgent &&
|
|
56
|
-
!w.
|
|
89
|
+
(!w.runtimeReason || !!mainWait(w)) && !openBatch && !prUnread;
|
|
57
90
|
const wait = (waitingOn: SendDecision["waitingOn"], reason: string, eta: string | null = null): SendDecision => ({ send: false, waitingOn, reason, eta, canSendNow });
|
|
58
91
|
if (!b || b.state !== "pending" || recoveryBatch(b)) return wait(null, "nothing queued");
|
|
59
92
|
if (w.archived) return wait("you", "the workspace is archived");
|
|
60
93
|
if (!w.enable_tracking) return wait("you", "Follow-up isn't following this workspace");
|
|
61
94
|
// The Done check never goes out on its own (it would wake an idle agent for bookkeeping).
|
|
62
95
|
if (b.tasks.some(t => t.kind === "completion")) return wait("you", "ready to send");
|
|
63
|
-
if (!w.enable_auto_sends) return wait("you",
|
|
96
|
+
if (!w.enable_auto_sends) return wait("you", AUTO_OFF_REASON);
|
|
64
97
|
if (w.hold) return wait("you", "paused until you resume");
|
|
65
98
|
if (w.goneAgent) return wait("you", "the main agent's conversation is gone");
|
|
66
|
-
|
|
67
|
-
|
|
99
|
+
// Only the main agent's own work holds a repair (Q96 = A): a subagent or another agent at work never does.
|
|
100
|
+
const main = mainWait(w);
|
|
101
|
+
if (main) return wait("agent", MAIN_WAIT[main]);
|
|
68
102
|
if (w.runtimeReason) return wait("follow-up", w.runtimeReason);
|
|
69
103
|
if (openBatch) return wait("follow-up", "waits for the last message to finish");
|
|
70
104
|
if (w.dormant) return wait("you", "waits until the workspace is active again");
|
|
@@ -13,7 +13,7 @@ import { asksForReviewers, liveLine, needsYou, type NeedItem } from "./attention
|
|
|
13
13
|
import { HOME_GROUPS, homeCounts, prChip, trackedGroup, type HomeModel } from "./home";
|
|
14
14
|
import { freshPriorities, type Priority } from "./priorities";
|
|
15
15
|
import { agentCard, automaticHold, batchView, holdSuperseded } from "./status";
|
|
16
|
-
import { conditionId, isCapped, NO_PROGRESS_CAP, personHeld, sendDecision, stuckRepair } from "./send-decision";
|
|
16
|
+
import { conditionId, isCapped, mainWait, NO_PROGRESS_CAP, personHeld, sendDecision, stuckRepair } from "./send-decision";
|
|
17
17
|
import { messageStrip, obligationDelivery, repairRows } from "./task-rows";
|
|
18
18
|
import { followUpObligations } from "./follow-up";
|
|
19
19
|
import { PRESENCE, claimsWorking, taskStatus } from "./task-status";
|
|
@@ -32,7 +32,6 @@ import { GONE_REASON } from "./queue";
|
|
|
32
32
|
*/
|
|
33
33
|
export type Invariant = { id: string; why: string; check(w: Workspace, now: number): string | null };
|
|
34
34
|
|
|
35
|
-
const idle = (w: Workspace) => !w.runtimeBusy && !w.backgroundBusy;
|
|
36
35
|
const inFlight = (w: Workspace) => w.batches.some(b => ["sending", "sent"].includes(b.state));
|
|
37
36
|
const lines = (w: Workspace, now: number) => [liveLine(w, now).text, agentCard(w, now)?.line ?? "", batchView(w, now)?.line ?? "", ...needsYou(w, now).flatMap(i => [i.title, "blocker" in i ? i.blocker ?? "" : ""])];
|
|
38
37
|
|
|
@@ -170,7 +169,22 @@ export const INVARIANTS: Invariant[] = [
|
|
|
170
169
|
},
|
|
171
170
|
{
|
|
172
171
|
id: "waiting-on-agent-means-busy", why: "a queued batch may only blame the agent's turn while the agent is in one",
|
|
173
|
-
check: (w, now) => { const v = batchView(w, now); return v?.phase === "queued" && v.waitingOn === "agent" &&
|
|
172
|
+
check: (w, now) => { const v = batchView(w, now); return v?.phase === "queued" && v.waitingOn === "agent" && !mainWait(w) ? v.line : null; },
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: "a-repair-goes-to-a-free-main-agent",
|
|
176
|
+
why: "2026-11-18 (Q96 = A): a repair sat pending over two hours with Auto-send on and the main agent idle, because a subagent it started ran one task after another and every non-main agent's work held repairs; the card said nothing true. A repair waits only for the main agent itself (its turn, its own background job with Wait for background jobs on, a permission prompt, Session Guard, compaction), says what it waits for, and offers Send now while it does.",
|
|
177
|
+
check(w, now) {
|
|
178
|
+
const v = batchView(w, now);
|
|
179
|
+
if (v?.phase !== "queued" || v.kind !== "repairs") return null;
|
|
180
|
+
const d = sendDecision(w, now, { batch: v.batch });
|
|
181
|
+
if (d.waitingOn === "agent" && !mainWait(w)) return `"${d.reason}" while the main agent is free`;
|
|
182
|
+
// Send now is taken while the main agent is busy; only something else (an open message, unread PRs) refuses it.
|
|
183
|
+
if (d.waitingOn === "agent" && !d.canSendNow && sendDecision({ ...w, mainBusy: null, runtimeBusy: false, backgroundBusy: false, runtimeReason: null }, now, { batch: v.batch }).canSendNow)
|
|
184
|
+
return `waits on the main agent with no Send now: "${d.reason}"`;
|
|
185
|
+
if (!d.send && !d.reason.trim()) return "waits without saying why";
|
|
186
|
+
return null;
|
|
187
|
+
},
|
|
174
188
|
},
|
|
175
189
|
{
|
|
176
190
|
id: "on-it-means-sent", why: "2026-11-10 wks_4b27f268: \"Main agent is on it\" while the agent was idle and nothing had been sent",
|