paseo-follow-up 1.4.0-beta.16 → 1.4.0-beta.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/README.md +1 -1
- package/client/panel.tsx +40 -1
- package/index.server.ts +15 -3
- package/package.json +1 -1
- package/server/agent-actions.ts +6 -1
- package/server/daemon.ts +24 -5
- package/server/discovery.ts +34 -6
- package/server/engine.ts +2 -2
- package/shared/contracts.ts +1 -1
- package/shared/model.ts +5 -1
package/README.md
CHANGED
|
@@ -197,7 +197,7 @@ The choices live in `agents.json` in Follow-up's data folder. Anything missing o
|
|
|
197
197
|
Install the beta:
|
|
198
198
|
|
|
199
199
|
```sh
|
|
200
|
-
paseo plugin update follow-through --version 1.4.0-beta.
|
|
200
|
+
paseo plugin update follow-through --version 1.4.0-beta.17
|
|
201
201
|
# or, for a fresh install:
|
|
202
202
|
paseo plugin install npm:paseo-follow-up@beta
|
|
203
203
|
```
|
package/client/panel.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, type ReactNode } from "react";
|
|
2
2
|
import { ScrollView, Text, View } from "react-native";
|
|
3
3
|
import { Icon, useToast } from "@getpaseo/plugin/client/ui";
|
|
4
|
-
import { useRpc, useTabState, openExternalUrl, type PluginHostProps, type PluginWorkspacePanelProps } from "@getpaseo/plugin/client";
|
|
4
|
+
import { useAgent, useRpc, useTabState, openExternalUrl, type PluginHostProps, type PluginWorkspacePanelProps } from "@getpaseo/plugin/client";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import type { InboxStore } from "./inbox-store";
|
|
7
7
|
import { useInbox } from "./inbox";
|
|
@@ -186,10 +186,12 @@ function WorkspaceCard({ workspace: w, theme, compact, open, toggle, openAgent,
|
|
|
186
186
|
<View style={{ flexDirection: "row", alignItems: "center", gap: 10, flexWrap: "wrap" }}>
|
|
187
187
|
<View style={{ flex: 1, minWidth: 160, gap: 2 }}>
|
|
188
188
|
<Text style={t.label}>Main agent</Text>
|
|
189
|
+
<MainAgentName agentId={w.mainAgentId} theme={theme} />
|
|
189
190
|
<Text style={t.meta}>Owns the PRs, tasks and the Done call. Repairs go here.</Text>
|
|
190
191
|
</View>
|
|
191
192
|
{openAgent && <Button theme={theme} compact={compact} icon="MessageSquare" title="Open" accessibilityLabel="Open main agent" onPress={() => openAgent(w.mainAgentId)} />}
|
|
192
193
|
</View>
|
|
194
|
+
{(w.contributorAgentIds ?? []).map(id => <OtherRootAgent key={id} agentId={id} workspace={w} theme={theme} compact={compact} openAgent={openAgent} mainAgentId={w.mainAgentId} />)}
|
|
193
195
|
</CardRow>
|
|
194
196
|
<CardRow theme={theme}>
|
|
195
197
|
<View style={{ gap: 8 }}>
|
|
@@ -221,6 +223,43 @@ function WorkspaceCard({ workspace: w, theme, compact, open, toggle, openAgent,
|
|
|
221
223
|
</View>;
|
|
222
224
|
}
|
|
223
225
|
|
|
226
|
+
/** An agent's title from Paseo's client state (no fetch), or a short id while it loads or once it's gone. */
|
|
227
|
+
function useAgentTitle(agentId: string): string {
|
|
228
|
+
return useAgent(agentId, a => a.title) || `Agent ${agentId.slice(0, 8)}`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function MainAgentName({ agentId, theme }: { agentId: string; theme: Theme }) {
|
|
232
|
+
const t = text(theme.colors);
|
|
233
|
+
return <Text numberOfLines={1} style={[t.meta, { color: theme.colors.foreground }]}>{useAgentTitle(agentId)}</Text>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Another root agent in this workspace: it can contribute PRs but not ask Tom or call Done. "Make main agent" is
|
|
238
|
+
* the developer's choice (a plugin RPC, never an agent tool). It swaps roles, so the former main appears here with
|
|
239
|
+
* its own Make main agent: that is the undo, and the toast says so instead of a confirmation step.
|
|
240
|
+
*/
|
|
241
|
+
function OtherRootAgent({ agentId, mainAgentId, workspace: w, theme, compact, openAgent }: { agentId: string; mainAgentId: string; workspace: Workspace; theme: Theme; compact: boolean; openAgent?: (id: string) => void }) {
|
|
242
|
+
const c = theme.colors; const t = text(c);
|
|
243
|
+
const title = useAgentTitle(agentId); const formerTitle = useAgentTitle(mainAgentId);
|
|
244
|
+
const control = useRpc(controlRpc); const cache = useQueryClient(); const toast = useToast();
|
|
245
|
+
const promote = useMutation({
|
|
246
|
+
mutationFn: () => control({ workspaceId: w.id, mainAgentId: agentId }),
|
|
247
|
+
onSuccess: () => { void cache.invalidateQueries({ queryKey: workspaceKey(w.id) }); void cache.invalidateQueries({ queryKey: overviewKey }); toast.show(`${title} is now the main agent. To undo, make ${formerTitle} main again.`, { variant: "success" }); },
|
|
248
|
+
onError: (e: Error) => toast.error(errorText(e)),
|
|
249
|
+
});
|
|
250
|
+
const canPromote = w.enable_tracking && !w.archived;
|
|
251
|
+
return <View style={{ gap: 8, marginTop: 10, paddingTop: 10, borderTopWidth: 1, borderTopColor: c.border }}>
|
|
252
|
+
<View style={{ gap: 2 }}>
|
|
253
|
+
<Text numberOfLines={1} style={[t.meta, { color: c.foreground }]}>{title}</Text>
|
|
254
|
+
<Text style={t.meta}>Can add PRs here. Can't ask you questions or call Done.</Text>
|
|
255
|
+
</View>
|
|
256
|
+
{(openAgent || canPromote) && <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
|
|
257
|
+
{canPromote && <Button theme={theme} compact={compact} title="Make main agent" accessibilityLabel={`Make ${title} the main agent`} accessibilityHint={`Repairs, questions and Done move from ${formerTitle} to ${title}.`} loading={promote.isPending} disabled={promote.isPending} onPress={() => promote.mutate()} />}
|
|
258
|
+
{openAgent && <Button theme={theme} compact={compact} kind="ghost" icon="MessageSquare" title="Open" accessibilityLabel={`Open ${title}`} onPress={() => openAgent(agentId)} />}
|
|
259
|
+
</View>}
|
|
260
|
+
</View>;
|
|
261
|
+
}
|
|
262
|
+
|
|
224
263
|
function historyLabel(w: Workspace): string {
|
|
225
264
|
const stacks = new Set(w.prs.map(p => p.stack)).size;
|
|
226
265
|
const tasks = followUpObligations(w).filter(o => ["done", "waived"].includes(o.status)).length;
|
package/index.server.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { AgentActions, AGENT_TOOLS, controlWorkspace, type AgentTool } from "./s
|
|
|
25
25
|
import { PaseoGateway, paseoHome, clientEntry, closeConnections, sessionGuardOwnsInterruption } from "./server/daemon";
|
|
26
26
|
import { mcpSource } from "./server/mcp-source";
|
|
27
27
|
import { excludeStack } from "./server/exclusions";
|
|
28
|
-
import { applyHistory, applyDiscovery, extractHistory } from "./server/discovery";
|
|
28
|
+
import { applyHistory, applyDiscovery, extractHistory, markMainWork } from "./server/discovery";
|
|
29
29
|
import { lifecycleOnly, recoveryBatch } from "./shared/follow-up";
|
|
30
30
|
import { Deployments } from "./server/deployments";
|
|
31
31
|
import { AgentHooks } from "./server/agent-hooks";
|
|
@@ -63,6 +63,9 @@ import { OnboardingStore, ReadinessChecks, nativeAgentCount } from "./server/onb
|
|
|
63
63
|
import { execFile } from "node:child_process";
|
|
64
64
|
import { BRIEF_KIND, BRIEF_VERSION, prState, validateNeedsYou, type Brief, type NeedsYouRecord } from "./shared/brief";
|
|
65
65
|
|
|
66
|
+
/** Agent calls that only the main agent makes: one of these from a successor means the handover is in use. */
|
|
67
|
+
const MAIN_WORK = new Set(["follow.sync", "follow.register-pr", "follow.obligation", "follow.done", "follow.acknowledge", "follow.exclude-stack", "follow.ask-question", "follow.record-answer", "follow.withdraw-question", "follow.set-spec", "follow.needs-you"]);
|
|
68
|
+
|
|
66
69
|
export default function contribute(server: PluginServerContext) {
|
|
67
70
|
const displaySettings = server.registerSettings(displayPreferences);
|
|
68
71
|
const questionSettings = server.registerSettings(questionPreferences);
|
|
@@ -84,7 +87,16 @@ export default function contribute(server: PluginServerContext) {
|
|
|
84
87
|
} catch { /* Without it the hook assumes the tools are attached, as before. */ }
|
|
85
88
|
// Every RPC handler, also callable in-process: native agent tools run the same handlers the stdio bridge reaches.
|
|
86
89
|
const handlers = new Map<string, { input: { parseAsync(value: unknown): Promise<unknown> }; run: (input: any, context: PluginHandlerContext) => unknown }>();
|
|
87
|
-
const handle: PluginServerContext["handle"] = (contract, handler) => {
|
|
90
|
+
const handle: PluginServerContext["handle"] = (contract, handler) => {
|
|
91
|
+
// Main-agent work by a successor makes its handover stick (see handBackMainAgent): noted after the call succeeds.
|
|
92
|
+
const run = MAIN_WORK.has(contract.name) ? (async (input: { agentId?: string }, context: PluginHandlerContext) => { const out = await (handler as (i: unknown, c: PluginHandlerContext) => unknown)(input, context); if (input?.agentId) await noteMainWork(input.agentId).catch(() => undefined); return out; }) as typeof handler : handler;
|
|
93
|
+
handlers.set(contract.name, { input: contract.input, run: run as never }); server.handle(contract, run);
|
|
94
|
+
};
|
|
95
|
+
const noteMainWork = async (agentId: string) => {
|
|
96
|
+
// A cheap check on the snapshot first: almost every call has no open handover, so nothing is written.
|
|
97
|
+
if (!(await store.snapshot()).workspaces.some(w => w.mainAgentId === agentId && w.handover && !w.handover.worked)) return;
|
|
98
|
+
await store.mutate(state => { markMainWork(state, agentId); });
|
|
99
|
+
};
|
|
88
100
|
const store = new Store(directory, 1_000);
|
|
89
101
|
const onboarding = new OnboardingStore(directory);
|
|
90
102
|
store.onChanged = scopeWriter(directory);
|
|
@@ -909,7 +921,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
909
921
|
if (!w || w.mainAgentId !== event.agent.id || !interruption) return;
|
|
910
922
|
// The provider lost the conversation: every later send fails the same way, so stop sending instead of holding.
|
|
911
923
|
if (event.outcome.kind === "failed" && conversationGone(event.outcome.error.message)) { w.goneAgent = { agentId: event.agent.id, at: interruption.at, reason: event.outcome.error.message }; w.completion = null; return; }
|
|
912
|
-
w.hold = interruptionHold(interruption.kind); w.interruption = interruption; w.completion = null;
|
|
924
|
+
w.hold = interruptionHold(interruption.kind); w.interruption = { ...interruption, agentId: event.agent.id }; w.completion = null;
|
|
913
925
|
});
|
|
914
926
|
void engine.tick();
|
|
915
927
|
}),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.4.0-beta.
|
|
4
|
+
"version": "1.4.0-beta.17",
|
|
5
5
|
"description": "Follow every workspace PR stack in Paseo, answer agent questions, batch repairs for the main agent, and see what needs you.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
package/server/agent-actions.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { InboxRow } from "../shared/inbox";
|
|
|
8
8
|
import type { Pr, State, Workspace } from "../shared/model";
|
|
9
9
|
import { configuredReviewers, reviewerLoginSchema, noReviewers, resolveReviewers, reviewerConfig, reviewerLabel, withoutAuthor, type ReviewerEntry } from "../shared/reviewers";
|
|
10
10
|
import { findWorkspace } from "./engine";
|
|
11
|
+
import { setMainAgent } from "./discovery";
|
|
11
12
|
import type { InboxAction } from "./inbox";
|
|
12
13
|
import { priorityInputSchema, type Priority } from "../shared/priorities";
|
|
13
14
|
import type { AboutView } from "../shared/about";
|
|
@@ -31,9 +32,13 @@ export const DESTRUCTIVE_TOOLS: readonly AgentTool[] = ["merge"];
|
|
|
31
32
|
export const PLANNED_TOOLS: readonly AgentTool[] = ["add_reviewers", "merge", "enable_merge_when_ready", "disable_merge_when_ready", "sign_off", "snooze", "set_finish_flags", "set_priorities"];
|
|
32
33
|
|
|
33
34
|
/** The developer's control panel switches (Auto-send, Resume, Retry). The button and the agent tool share it. */
|
|
34
|
-
export function controlWorkspace(state: State, input: { workspaceId: string; enable_auto_sends?: boolean; clearHold?: boolean; retryBatchId?: string }, now = Date.now()): Workspace {
|
|
35
|
+
export function controlWorkspace(state: State, input: { workspaceId: string; enable_auto_sends?: boolean; clearHold?: boolean; retryBatchId?: string; mainAgentId?: string }, now = Date.now()): Workspace {
|
|
35
36
|
const w = findWorkspace(state, input.workspaceId);
|
|
36
37
|
if (!w.enable_tracking || w.archived) throw new Error("Activate this workspace before changing follow-up controls.");
|
|
38
|
+
if (input.mainAgentId && input.mainAgentId !== w.mainAgentId) {
|
|
39
|
+
if (!w.contributorAgentIds?.includes(input.mainAgentId)) throw new Error("That agent isn't one of this workspace's root agents. Refresh and pick another.");
|
|
40
|
+
setMainAgent(w, input.mainAgentId, "developer", now);
|
|
41
|
+
}
|
|
37
42
|
if (input.enable_auto_sends !== undefined) w.enable_auto_sends = input.enable_auto_sends;
|
|
38
43
|
if (input.clearHold) w.hold = null;
|
|
39
44
|
if (input.retryBatchId) {
|
package/server/daemon.ts
CHANGED
|
@@ -206,11 +206,13 @@ export class PaseoGateway implements Gateway {
|
|
|
206
206
|
const candidates = agents.map(row => row.agent).filter(a => a.workspaceId === workspace.id && !a.archivedAt && !a.labels["follow-through.recovery"]);
|
|
207
207
|
const roots: Agent[] = [];
|
|
208
208
|
for (const agent of candidates) if (await isWorkspaceRoot(agent, findParent)) roots.push(agent);
|
|
209
|
-
const
|
|
209
|
+
const recorded = existing ? roots.find(a => a.id === existing.mainAgentId) : undefined;
|
|
210
|
+
const handBack = existing ? handBackMainAgent(roots, existing) : undefined;
|
|
211
|
+
const successor = handBack ?? successorMainAgent(roots, existing?.mainAgentId, existing?.mainClosedSince, now);
|
|
210
212
|
const main = successor ?? chooseMainAgent(roots, existing?.mainAgentId);
|
|
211
213
|
if (!main && !existing) continue;
|
|
212
214
|
const owner = successor?.id ?? existing?.mainAgentId ?? main!.id;
|
|
213
|
-
const row: DiscoveredWorkspace = { id: workspace.id, title: workspace.name || main?.title || existing!.title, mainAgentId: owner, ...(successor ? { replacesMainAgentId: existing!.mainAgentId } : {}), projectId: workspace.projectId, messageAt: main?.lastUserMessageAt ?? null, enable_default_tracking: defaults.has(workspace.projectId ?? "") && !optedOut(state, workspace.id), contributorAgentIds: roots.filter(a => a.id !== owner
|
|
215
|
+
const row: DiscoveredWorkspace = { id: workspace.id, title: workspace.name || main?.title || existing!.title, mainAgentId: owner, ...(successor ? { replacesMainAgentId: existing!.mainAgentId, ...(handBack ? { handBack: true } : {}) } : {}), mainClosed: !!recorded && recorded.status === "closed", projectId: workspace.projectId, messageAt: main?.lastUserMessageAt ?? null, enable_default_tracking: defaults.has(workspace.projectId ?? "") && !optedOut(state, workspace.id), contributorAgentIds: roots.filter(a => a.id !== owner).map(a => a.id) };
|
|
214
216
|
// Preserve the designated owner even when it is no longer indexed. Other root
|
|
215
217
|
// sessions can still contribute their PRs without acquiring completion authority.
|
|
216
218
|
const project = projects.find(p => p.projectId === workspace.projectId);
|
|
@@ -460,14 +462,31 @@ export function chooseMainAgent(roots: Agent[], existingId?: string): Agent | un
|
|
|
460
462
|
return [...roots].sort((a, b) => a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id))[0];
|
|
461
463
|
}
|
|
462
464
|
|
|
465
|
+
/** How long the recorded main agent must read closed, without a break, before another root agent takes over. */
|
|
466
|
+
export const MAIN_CLOSED_HANDOVER_MS = 30 * 60_000;
|
|
467
|
+
|
|
463
468
|
/**
|
|
464
|
-
* The recorded main agent is
|
|
465
|
-
* one takes over (the one Tom wrote to last, then the newest).
|
|
469
|
+
* The recorded main agent is archived or gone, or has read "closed" continuously for MAIN_CLOSED_HANDOVER_MS, while
|
|
470
|
+
* the workspace still has a live root agent: the live one takes over (the one Tom wrote to last, then the newest).
|
|
471
|
+
* "closed" alone is not enough: a Claude session closes and reopens on its own (a plugin update reopens sessions, the
|
|
472
|
+
* process restarts between turns), so a short close never hands the workspace away. A live recorded main is never
|
|
473
|
+
* replaced. `closedSince` is when discovery first saw it closed (Workspace.mainClosedSince); unknown means just now.
|
|
466
474
|
*/
|
|
467
|
-
export function successorMainAgent(roots: Agent[], existingId: string | undefined): Agent | undefined {
|
|
475
|
+
export function successorMainAgent(roots: Agent[], existingId: string | undefined, closedSince?: string, now = Date.now()): Agent | undefined {
|
|
468
476
|
if (!existingId) return undefined;
|
|
469
477
|
const current = roots.find(a => a.id === existingId);
|
|
470
478
|
if (current && current.status !== "closed") return undefined;
|
|
479
|
+
if (current && (!closedSince || now - Date.parse(closedSince) < MAIN_CLOSED_HANDOVER_MS)) return undefined;
|
|
471
480
|
const live = roots.filter(a => a.id !== existingId && a.status !== "closed");
|
|
472
481
|
return live.sort((a, b) => (b.lastUserMessageAt ?? "").localeCompare(a.lastUserMessageAt ?? "") || b.createdAt.localeCompare(a.createdAt) || a.id.localeCompare(b.id))[0];
|
|
473
482
|
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* After a handover, the original main agent takes the workspace back once it reads live again, as long as the
|
|
486
|
+
* successor hasn't done main-agent work (a sync, task, question, needs_you or Done call) in the meantime.
|
|
487
|
+
*/
|
|
488
|
+
export function handBackMainAgent(roots: Agent[], w: { mainAgentId: string; handover?: { from: string; worked: boolean } }): Agent | undefined {
|
|
489
|
+
if (!w.handover || w.handover.worked || w.handover.from === w.mainAgentId) return undefined;
|
|
490
|
+
const original = roots.find(a => a.id === w.handover!.from);
|
|
491
|
+
return original && original.status !== "closed" ? original : undefined;
|
|
492
|
+
}
|
package/server/discovery.ts
CHANGED
|
@@ -5,7 +5,33 @@ import type { State, Workspace } from "../shared/model";
|
|
|
5
5
|
import { autoSendsByDefault, followsByDefault } from "../shared/settings";
|
|
6
6
|
|
|
7
7
|
export type History = { candidates: string[]; goal: string | null; complete: boolean; error: string | null };
|
|
8
|
-
export type DiscoveredWorkspace = { id: string; title: string; mainAgentId: string; /** Set when mainAgentId is a live successor to this closed or gone main agent. */ replacesMainAgentId?: string; messageAt: string | null; projectId?: string | null; enable_default_tracking?: boolean; history?: History; contributorAgentIds?: string[]; submissions?: Submission[]; artifacts?: Artifact[]; /** In the active scope (see workspaceActive). Undefined means unknown, treated as active. */ active?: boolean };
|
|
8
|
+
export type DiscoveredWorkspace = { id: string; title: string; mainAgentId: string; /** Set when mainAgentId is a live successor to this closed or gone main agent. */ replacesMainAgentId?: string; /** The replacement is the original main agent taking the workspace back (Workspace.handover). */ handBack?: boolean; /** The recorded main agent reads "closed" right now. */ mainClosed?: boolean; messageAt: string | null; projectId?: string | null; enable_default_tracking?: boolean; history?: History; contributorAgentIds?: string[]; submissions?: Submission[]; artifacts?: Artifact[]; /** In the active scope (see workspaceActive). Undefined means unknown, treated as active. */ active?: boolean };
|
|
9
|
+
|
|
10
|
+
export const interruptionHold = (kind: "canceled" | "failed") => kind === "canceled" ? "You stopped the main agent. Resume follow-up when ready." : "The main agent's turn failed. Check it before resuming follow-up.";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Moves the workspace to another main agent: automatic handover, hand-back, or the developer's "Make main agent".
|
|
14
|
+
* A stop hold raised by another agent's turn doesn't carry over to the new main (a hold from before 1.4.0-beta.16
|
|
15
|
+
* names no agent, so only the developer's explicit choice clears it).
|
|
16
|
+
*/
|
|
17
|
+
export function setMainAgent(w: Workspace, to: string, kind: "handover" | "handBack" | "developer", now: number): void {
|
|
18
|
+
const from = w.mainAgentId;
|
|
19
|
+
if (from === to) return;
|
|
20
|
+
w.mainAgentId = to; w.runtimeReason = null; delete w.mainClosedSince;
|
|
21
|
+
w.contributorAgentIds = [...new Set([...(w.contributorAgentIds ?? []).filter(id => id !== to), from])];
|
|
22
|
+
for (const b of w.batches) if (b.state === "pending" && b.recipientAgentId === from) b.recipientAgentId = null;
|
|
23
|
+
if (kind === "handover") w.handover = { from, at: new Date(now).toISOString(), worked: false }; else delete w.handover;
|
|
24
|
+
const stop = w.interruption;
|
|
25
|
+
if (stop && w.hold === interruptionHold(stop.kind) && (stop.agentId ? stop.agentId !== to : kind === "developer")) { w.hold = null; delete w.interruption; w.completion = null; }
|
|
26
|
+
w.updatedAt = new Date(now).toISOString();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A successor's main-agent call: its handover is in use and no longer goes back. True when something changed. */
|
|
30
|
+
export function markMainWork(state: State, agentId: string): boolean {
|
|
31
|
+
let changed = false;
|
|
32
|
+
for (const w of state.workspaces) if (w.mainAgentId === agentId && w.handover && !w.handover.worked) { w.handover.worked = true; changed = true; }
|
|
33
|
+
return changed;
|
|
34
|
+
}
|
|
9
35
|
|
|
10
36
|
export function extractHistory(items: readonly unknown[], complete = true, error: string | null = null): History {
|
|
11
37
|
const candidates = new Set<string>();
|
|
@@ -57,11 +83,13 @@ export function applyDiscovery(state: State, discovered: DiscoveredWorkspace[],
|
|
|
57
83
|
if (!state.autoSendsParked.length) delete state.autoSendsParked;
|
|
58
84
|
}
|
|
59
85
|
}
|
|
60
|
-
// A closed or gone main agent hands the workspace to its live successor
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
86
|
+
// A long-closed, archived or gone main agent hands the workspace to its live successor, and an unused handover
|
|
87
|
+
// goes back to the original main once it's live (discovery decides; see successorMainAgent, handBackMainAgent).
|
|
88
|
+
// Any other mismatch keeps the recorded owner.
|
|
89
|
+
if (row.replacesMainAgentId && row.replacesMainAgentId === w.mainAgentId && !w.archived) setMainAgent(w, row.mainAgentId, row.handBack ? "handBack" : "handover", now);
|
|
90
|
+
// How long the recorded main has read closed without a break: a reopen resets it.
|
|
91
|
+
if (row.mainAgentId === w.mainAgentId && !row.replacesMainAgentId && row.mainClosed !== undefined) {
|
|
92
|
+
if (!row.mainClosed) delete w.mainClosedSince; else w.mainClosedSince ??= new Date(now).toISOString();
|
|
65
93
|
}
|
|
66
94
|
if (w.mainAgentId !== row.mainAgentId || w.archived) continue;
|
|
67
95
|
// A new main agent, or a new message to the gone one, means its conversation can be tried again.
|
package/server/engine.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { batchPrompt, tasksFor, isRecovery, needsPrObservations } from "./tasks"
|
|
|
6
6
|
import { answerRecipients, developerAnswer, syncTaskQuestions } from "./questions";
|
|
7
7
|
import { answerMessage, isOpen as isOpenQuestion, type Question } from "../shared/questions";
|
|
8
8
|
import { reconcileSubmittedStacks } from "./submissions";
|
|
9
|
-
import { applyDiscovery, startsWithAutoSend, type DiscoveredWorkspace } from "./discovery";
|
|
9
|
+
import { applyDiscovery, interruptionHold, startsWithAutoSend, type DiscoveredWorkspace } from "./discovery";
|
|
10
10
|
import { followsByDefault, migrateActiveScope } from "../shared/settings";
|
|
11
11
|
import { replyRecorded } from "../shared/communication";
|
|
12
12
|
import { DeliveryDeferred, ConversationGone } from "./delivery";
|
|
@@ -26,7 +26,7 @@ export interface Runtime {
|
|
|
26
26
|
const GONE_REASON = "The main agent's conversation no longer exists, so Follow-up stopped sending to it. Start a new agent in this workspace to continue.";
|
|
27
27
|
/** A batch that asks the agent to verify it's finished and declare Done. These never go out on their own. */
|
|
28
28
|
export const completionBatch = (b: Batch): boolean => b.tasks.some(t => t.kind === "completion");
|
|
29
|
-
export
|
|
29
|
+
export { interruptionHold };
|
|
30
30
|
export interface Gateway {
|
|
31
31
|
discover?(state: State, workspaceId?: string): Promise<DiscoveredWorkspace[]>;
|
|
32
32
|
observe(w: Workspace, fresh?: boolean): Promise<Runtime>;
|
package/shared/contracts.ts
CHANGED
|
@@ -35,7 +35,7 @@ export const registerPrRpc = defineRpc({ name: "follow.register-pr", input: z.st
|
|
|
35
35
|
export const obligationRpc = defineRpc({ name: "follow.obligation", input: z.strictObject({ agentId: idSchema, id: idSchema.optional(), title: textSchema, status: z.enum(["pending", "waiting", "working", "blocked", "done", "waived"]), afterPrs: z.array(idSchema).optional(), dependencyStage: z.enum(["merged", "deployed"]).optional(), evidence: z.string().max(4000).optional(), enable_follow_up: z.boolean().optional(), communication: agentCommunicationSchema.optional(), trigger: taskTriggerSchema.strict().nullable().optional() }), output: workspaceSchema.extend({ updatedObligationId: idSchema }) });
|
|
36
36
|
export const declareDoneRpc = defineRpc({ name: "follow.done", input: z.strictObject({ agentId: idSchema, summary: textSchema }), output: z.object({ workspace: workspaceSchema, blockers: z.array(z.string()) }) });
|
|
37
37
|
export const acknowledgeRpc = defineRpc({ name: "follow.acknowledge", input: z.strictObject({ agentId: idSchema, batchId: idSchema, outcome: z.enum(["completed", "blocked"]), result: textSchema }), output: workspaceSchema });
|
|
38
|
-
export const controlRpc = defineRpc({ name: "follow.control", input: z.object({ workspaceId: idSchema, enable_auto_sends: z.boolean().optional(), clearHold: z.boolean().optional(), retryBatchId: idSchema.optional() }), output: workspaceSchema });
|
|
38
|
+
export const controlRpc = defineRpc({ name: "follow.control", input: z.object({ workspaceId: idSchema, enable_auto_sends: z.boolean().optional(), clearHold: z.boolean().optional(), retryBatchId: idSchema.optional(), /** The developer's "Make main agent": one of the workspace's other root agents. */ mainAgentId: idSchema.optional() }), output: workspaceSchema });
|
|
39
39
|
export const refreshRpc = defineRpc({ name: "follow.refresh", input: z.object({ workspaceId: idSchema.optional() }), output: z.object({ ok: z.boolean() }) });
|
|
40
40
|
|
|
41
41
|
export const activateRpc = defineRpc({ name: "follow.activate", input: z.object({ workspaceId: idSchema }), output: workspaceSchema });
|
package/shared/model.ts
CHANGED
|
@@ -60,6 +60,10 @@ export const batchSchema = z.object({
|
|
|
60
60
|
export const workspaceSchema = z.object({
|
|
61
61
|
id: idSchema, title: textSchema, goal: textSchema, mainAgentId: idSchema,
|
|
62
62
|
contributorAgentIds: z.array(idSchema).optional(),
|
|
63
|
+
/** When discovery first saw the recorded main agent closed, cleared once it reads live again (see successorMainAgent). */
|
|
64
|
+
mainClosedSince: z.string().optional(),
|
|
65
|
+
/** A main agent closed for MAIN_CLOSED_HANDOVER_MS handed the workspace to `mainAgentId`; until that agent does main-agent work, a live `from` takes it back. */
|
|
66
|
+
handover: z.object({ from: idSchema, at: z.string(), worked: z.boolean() }).optional(),
|
|
63
67
|
enable_tracking: z.boolean().default(false), enable_auto_sends: z.boolean().default(false), hold: z.string().nullable(), archived: z.boolean(),
|
|
64
68
|
prs: z.array(prSchema), obligations: z.array(obligationSchema), batches: z.array(batchSchema),
|
|
65
69
|
excludedStacks: z.array(z.object({ name: textSchema, reason: textSchema, excludedAt: z.string(), prs: z.array(prSchema), obligations: z.array(obligationSchema) })).default([]),
|
|
@@ -67,7 +71,7 @@ export const workspaceSchema = z.object({
|
|
|
67
71
|
completion: z.object({ summary: textSchema, declaredAt: z.string() }).nullable(),
|
|
68
72
|
updatedAt: z.string(), managedDoneLabel: z.boolean(),
|
|
69
73
|
runtimeReason: z.string().nullable(), runtimeBusy: z.boolean(), backgroundBusy: z.boolean().default(false),
|
|
70
|
-
interruption: z.object({ turnId: z.string().nullable(), at: z.string(), kind: z.enum(["canceled", "failed"]), guardPauseId: z.string().optional() }).optional(),
|
|
74
|
+
interruption: z.object({ turnId: z.string().nullable(), at: z.string(), kind: z.enum(["canceled", "failed"]), guardPauseId: z.string().optional(), /** The agent whose turn stopped (since 1.4.0-beta.16). */ agentId: idSchema.optional() }).optional(),
|
|
71
75
|
// Added with questions; older saved states parse with none.
|
|
72
76
|
questions: z.array(questionSchema).default([]),
|
|
73
77
|
// Added with spec links; older saved states parse with none.
|