paseo-follow-up 2.0.2-beta.2 → 2.1.0-beta.0
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/OVERVIEW.md +1 -1
- package/README.md +28 -0
- package/client/home-list.tsx +25 -10
- package/client/home.tsx +3 -0
- package/client/panel-menu.tsx +1 -1
- package/client/rename.tsx +2 -2
- package/client/row-actions.ts +1 -1
- package/client/sidebar-view.tsx +20 -6
- package/index.client.tsx +3 -2
- package/index.server.ts +14 -7
- package/package.json +1 -1
- package/server/agent-actions.ts +1 -1
- package/server/agent-hook.mjs +24 -4
- package/server/agent-settings.ts +12 -16
- package/server/hook-source.ts +24 -4
- package/server/inbox.ts +20 -41
- package/server/mcp-source.ts +1 -1
- package/server/mcp.mjs +1 -1
- package/server/overseer.ts +38 -9
- package/server/pr-workflow.ts +10 -14
- package/server/rename.ts +20 -6
- package/server/reviewer-config.ts +10 -15
- package/server/store.ts +29 -1
- package/server/teardown.ts +3 -0
- package/server/write-behind.ts +144 -0
- package/shared/contracts.ts +1 -1
- package/shared/overseer.ts +35 -1
- package/shared/rename.ts +1 -1
- package/shared/row-menu.ts +1 -1
package/OVERVIEW.md
CHANGED
|
@@ -44,7 +44,7 @@ The Needs-you inbox (beta) keeps one flag per root agent in `plugin-data/follow-
|
|
|
44
44
|
|
|
45
45
|
The brief (beta) is stored on the agent's inbox entry and appended to its timeline as a Follow-up row; re-appending replaces that row, and the restart check ignores the `updatedAt` change the append causes because it never reads `updatedAt`. To build a brief Follow-up reads only what it already has: the agent's `needs_you` call, the permission request's title, the failed turn's error message, Session Guard's note and reset time for a paused agent, and its own PR state. It does not read or quote the agent's reply. While the inbox is on, every root Paseo agent on Claude Code or Codex gets Follow-up's MCP bridge with the `needs_you` tool only (tracked main agents keep their full set), and `plugin-data/follow-up/brief.json` records whether the inbox and the nudge are on and which agents have a permission prompt showing. Clicking an option or Retry sends one message as you; it is logged in the delivery ledger as yours, so it clears the flag. The Stop hook, part of the same reversible provider hooks Follow-up already installs, now also runs for those root Claude Code sessions: if the turn ended without `needs_you`, it blocks the stop once with a one-line request to call it, records that it did in `hook-state`, and never blocks the same turn again. It reads `brief.json`, its own per-turn marker and the time of the agent's last `needs_you` call, and nothing else. Turn it off with *Ask agents to state what they need*; turning the inbox off stops it too.
|
|
46
46
|
|
|
47
|
-
The Overseer (beta) is one Claude agent in a Follow-up workspace under `plugin-data/follow-up/overseer-home`, labelled `follow-up.overseer=1` and created only when you click Start. Its id is kept in `plugin-data/follow-up/overseer.json`. Discovery, tracking, auto-send and Needs you skip its workspace. At the start of each of its turns, the provider hook adds a digest from `plugin-data/follow-up/overseer-digest.json` and records what it showed in `hook-state/overseer-seen-<agent>.json`. The worker builds that file from Paseo's workspace list (metadata only, at most once a minute) and Follow-up's own state
|
|
47
|
+
The Overseer (beta) is one Claude agent in a Follow-up workspace under `plugin-data/follow-up/overseer-home`, labelled `follow-up.overseer=1` and created only when you click Start. Its id is kept in `plugin-data/follow-up/overseer.json`. Discovery, tracking, auto-send and Needs you skip its workspace. At the start of each of its turns, the provider hook adds a digest from `plugin-data/follow-up/overseer-digest.json` and records what it showed in `hook-state/overseer-seen-<agent>.json`. The worker builds that file when the Overseer's turn starts (and every 10 minutes as a backstop), from Paseo's workspace list (metadata only, at most once a minute) and Follow-up's own state; the hook waits up to 1.5 s for that turn's build. It skips the build while the resource governor pauses background work. Its tools are `workstreams`, `agent_digest`, `route_candidates`, `send_to_agent` and `start_workspace`. For an agent that isn't loaded, `agent_digest` reads the provider's transcript on disk, read-only (Claude Code's `projects/<cwd>/<session>.jsonl`, Codex's `sessions/**/rollout-*-<thread>.jsonl`; only the last 512 KB, and never the credentials in Paseo's agent record). Without a transcript it uses Follow-up's goal and PR titles. It never reads that agent's timeline. `send_to_agent` writes your words to the delivery ledger first: as yours only when they answer that agent's open ask, otherwise as Follow-up's. It wakes a resting agent only because you asked for it. `start_workspace` runs only after your approval, through a dry run and confirm. The Overseer can't merge, archive or post anywhere.
|
|
48
48
|
The Summary keeps its overviews in `plugin-data/follow-up/about.json` (gist, overview, linked rows, when and from what; never raw history) and logs each model call's duration and cost to `ai-jobs.jsonl`. To write one it reads the root agent's latest steps from its live timeline only when Paseo already has the agent loaded; otherwise it reads the first and last part of the agent's provider transcript on disk (Claude Code's `~/.claude/projects`, Codex's `~/.codex/sessions`), read-only, and never wakes the agent. It reads subagent titles from Paseo's agent list, PR titles and bodies with `gh pr view`, and only the Linear issues and Slack threads the workspace itself links, through `mcpproxy call tool-read` (`linear:get_issue`, `slack-user:slack_read_thread`); there are no searches. The model is set under Settings → Agents (default Haiku). With Claude it runs as a headless `claude -p` with no tools, no MCP servers, no settings and no saved session. With Codex it runs as `codex exec --ephemeral` with no user config or rules, no shell tool and a read-only sandbox in an empty temporary folder. Either way it gets one turn, a 90-second timeout, and runs one call at a time; on timeout the whole process group is killed. Overviews are written ahead of time only for non-dormant workspaces in Needs you, at most 60 a day by default (Settings → Agents), and not while a Claude account is above 85% of a limit or the resource governor has paused background work; above its higher threshold, opening the section shows the cached overview and writes none.
|
|
49
49
|
|
|
50
50
|
Settings → Agents (`plugin-data/follow-up/agents.json`, its own file) chooses the provider, model, effort and mode for Summaries, the Overseer, recovery agents and the priority ranker. Missing or invalid entries use the defaults. The provider and model list comes from Paseo's provider snapshot. It is read only when that settings screen opens, and cached for ten minutes. A changed Overseer setting is never applied mid-conversation: Home offers a restart, and the new Overseer is handed the old one's last steps (read from its transcript on disk when it isn't loaded). The old agent is left as it is. A recovery agent on a different provider than the main agent keeps the main agent's system prompt, MCP servers and tool policy, and drops its provider-specific model, mode and options. `FOLLOW_UP_OVERSEER_PROVIDER` ("provider/model") overrides the Overseer's setting; it exists only for isolated test daemons.
|
package/README.md
CHANGED
|
@@ -157,6 +157,34 @@ and GitHub PR status with your existing credentials, and keeps its state in `$PA
|
|
|
157
157
|
gives agents scoped tools and installs reversible hooks for Claude Code and Codex. [OVERVIEW.md](OVERVIEW.md) has the
|
|
158
158
|
full data-access statement.
|
|
159
159
|
|
|
160
|
+
## Memory on Linux
|
|
161
|
+
|
|
162
|
+
On Linux (glibc), a Follow-up that stays up for hours can slowly grow in memory: the allocator keeps memory Follow-up
|
|
163
|
+
already freed. macOS isn't affected. Three allocator settings in the Paseo daemon's environment stop the growth. Every
|
|
164
|
+
process Paseo starts inherits them.
|
|
165
|
+
|
|
166
|
+
If a systemd unit runs Paseo, add them to it (the unit name is your own; `paseo` here):
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
systemctl --user edit paseo
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```ini
|
|
173
|
+
[Service]
|
|
174
|
+
Environment=MALLOC_ARENA_MAX=2 MALLOC_MMAP_THRESHOLD_=131072 MALLOC_TRIM_THRESHOLD_=131072
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Then `systemctl --user restart paseo`. If the unit already reads an `EnvironmentFile=` (say `~/.config/paseo/env`),
|
|
178
|
+
put the three `NAME=value` lines there instead. If you start the daemon from a shell, stop it and start it with them:
|
|
179
|
+
|
|
180
|
+
```sh
|
|
181
|
+
paseo daemon stop
|
|
182
|
+
MALLOC_ARENA_MAX=2 MALLOC_MMAP_THRESHOLD_=131072 MALLOC_TRIM_THRESHOLD_=131072 paseo daemon start
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
In our test harness (140 workspaces, 45 idle minutes) Follow-up grew about 20 MB without them and 3 to 6 MB with them,
|
|
186
|
+
at no measurable CPU cost. To undo it, remove the settings and restart Paseo.
|
|
187
|
+
|
|
160
188
|
## Docs
|
|
161
189
|
|
|
162
190
|
- [CHANGELOG.md](CHANGELOG.md): release notes.
|
package/client/home-list.tsx
CHANGED
|
@@ -25,7 +25,9 @@ const QUIET_PAGE = 20;
|
|
|
25
25
|
export const BRIEF_KEY = "brief";
|
|
26
26
|
export const OVERSEER_KEY = "overseer";
|
|
27
27
|
/** The pinned Overseer row: not started yet (a one-time Start), working, asking, idle, or failed to come back. */
|
|
28
|
-
export type OverseerRowState = { state: "start" | "idle" | "running" | "asks" | "error"; line: string
|
|
28
|
+
export type OverseerRowState = { state: "start" | "idle" | "running" | "asks" | "error"; line: string;
|
|
29
|
+
/** A list filter's match in `line`, highlighted like a row's (the sidebar view's "Filter workspaces"). */
|
|
30
|
+
ranges?: Range[] };
|
|
29
31
|
|
|
30
32
|
type Entry =
|
|
31
33
|
| { type: "brief"; key: string }
|
|
@@ -74,6 +76,8 @@ export type HomeListProps = {
|
|
|
74
76
|
filter?: HomeGroupId | null;
|
|
75
77
|
/** The pinned Overseer row under the brief. Absent: the Overseer is off (or this surface has none). */
|
|
76
78
|
overseer?: OverseerRowState | null;
|
|
79
|
+
/** A narrow list (Paseo's sidebar view): the Overseer row stacks like every row there, title then its line. */
|
|
80
|
+
stackOverseer?: boolean;
|
|
77
81
|
/** An omnibox ask is on its way to the Overseer. */
|
|
78
82
|
asking?: boolean;
|
|
79
83
|
/** Sending rows' Send now (only where the server would take it: Workstream.sendNow). Absent: the list offers none. */
|
|
@@ -88,7 +92,7 @@ export type HomeListProps = {
|
|
|
88
92
|
|
|
89
93
|
const noMenu: OpenRowMenu = () => undefined;
|
|
90
94
|
|
|
91
|
-
export function HomeList({ model, theme, dense = false, touch, selectedKey, onSelect, briefLine, renderExpanded, header, footer, top, afterNeeds, emptyAction, results, hits = null, activeResult = 0, onResult, filter = null, overseer = null, asking = false, menu, onSendNow }: HomeListProps) {
|
|
95
|
+
export function HomeList({ model, theme, dense = false, touch, selectedKey, onSelect, briefLine, renderExpanded, header, footer, top, afterNeeds, emptyAction, results, hits = null, activeResult = 0, onResult, filter = null, overseer = null, stackOverseer = false, asking = false, menu, onSendNow }: HomeListProps) {
|
|
92
96
|
const c = theme.colors;
|
|
93
97
|
const [openMenu, setOpenMenu] = useState<RowMenuOpen | null>(null);
|
|
94
98
|
const build = menu.build;
|
|
@@ -178,7 +182,7 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
|
|
|
178
182
|
onSelect={pickResult} onMenu={item.archived ? noMenu : onMenu} />;
|
|
179
183
|
case "ask": return <AskRow ask={item.ask} theme={theme} active={item.index === activeResult} dense={dense} touch={touch} sending={!!asking} onPress={() => onResult?.({ provider: "overseer", key: ASK_KEY, ask: item.ask })} />;
|
|
180
184
|
case "brief": return <BriefRow theme={theme} line={briefLine ?? ""} selected={!touch && (selectedKey === null || selectedKey === BRIEF_KEY)} touch={touch} onSelect={onSelect} />;
|
|
181
|
-
case "overseer": return overseer ? <OverseerRow theme={theme} o={overseer} selected={selectedKey === OVERSEER_KEY} touch={touch} onSelect={onSelect} /> : null;
|
|
185
|
+
case "overseer": return overseer ? <OverseerRow theme={theme} o={overseer} selected={selectedKey === OVERSEER_KEY} touch={touch} stacked={stackOverseer} onSelect={onSelect} /> : null;
|
|
182
186
|
case "header": return <GroupHeader theme={theme} title={item.title} count={item.count} open={item.open} tone={item.group === "needs" && item.count ? c.statusWarning : undefined} dense={dense} touch={touch} onPress={() => toggle(item.group)} />;
|
|
183
187
|
case "fold": return <Pressable accessibilityRole="button" aria-expanded={item.open} accessibilityState={{ expanded: item.open }} accessibilityLabel={`${item.project}, ${item.count}. ${item.open ? "Collapse" : "Expand"}`} onPress={() => toggleProject(item.project)}
|
|
184
188
|
style={state => ({ flexDirection: "row", alignItems: "center", gap: 8, minHeight: touch ? 44 : dense ? 28 : 34, paddingHorizontal: dense ? 8 : 16, backgroundColor: (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
|
|
@@ -199,7 +203,7 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
|
|
|
199
203
|
</View>;
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
|
-
}, [theme, c, dense, touch, selectedKey, onSelect, briefLine, renderExpanded, toggle, toggleProject, activeResult, onResult, pickResult, model, overseer?.state, overseer?.line, asking, afterNeeds, emptyAction, onMenu, menuKey, onSendNow]);
|
|
206
|
+
}, [theme, c, dense, touch, selectedKey, onSelect, briefLine, renderExpanded, toggle, toggleProject, activeResult, onResult, pickResult, model, overseer?.state, overseer?.line, overseer?.ranges, stackOverseer, asking, afterNeeds, emptyAction, onMenu, menuKey, onSendNow]);
|
|
203
207
|
|
|
204
208
|
const listRef = useRef<FlatList<Entry>>(null);
|
|
205
209
|
// Keep the keyboard-active result in view.
|
|
@@ -240,18 +244,29 @@ function BriefRow({ theme, line, selected, touch, onSelect }: { theme: Theme; li
|
|
|
240
244
|
</Pressable>;
|
|
241
245
|
}
|
|
242
246
|
|
|
243
|
-
function OverseerRow({ theme, o, selected, touch, onSelect }: { theme: Theme; o: OverseerRowState; selected: boolean; touch: boolean; onSelect: (key: string) => void }) {
|
|
247
|
+
function OverseerRow({ theme, o, selected, touch, stacked = false, onSelect }: { theme: Theme; o: OverseerRowState; selected: boolean; touch: boolean; stacked?: boolean; onSelect: (key: string) => void }) {
|
|
244
248
|
const c = theme.colors;
|
|
245
249
|
const tone = o.state === "asks" ? c.statusWarning : o.state === "error" ? c.statusDanger : o.state === "running" ? runningColor(c) : c.foregroundMuted;
|
|
250
|
+
const icon = o.state === "running" ? <Spinner color={tone} size={13} label="Overseer working" /> : <Icon name="MessagesSquare" size={touch ? 16 : 15} color={o.state === "idle" || o.state === "start" ? c.foregroundMuted : tone} />;
|
|
251
|
+
const lineColor = o.state === "asks" || o.state === "error" ? tone : c.foregroundMuted;
|
|
252
|
+
// Wide Home: one line, the phone's shorter start line. Stacked (the sidebar view): the whole line, wrapping to two.
|
|
253
|
+
const line = marks(!stacked && touch && o.state === "start" ? "Ask about any workspace" : o.line, stacked || !(touch && o.state === "start") ? o.ranges : null, c);
|
|
246
254
|
return <Pressable accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={`Overseer. ${o.line}`} onPress={() => onSelect(OVERSEER_KEY)}
|
|
247
|
-
style={state => ({ flexDirection: "row", alignItems: "center", gap: 10, minHeight: touch ? 52 : 40, paddingLeft: 14, paddingRight: 16, borderBottomWidth: 1, borderBottomColor: c.border,
|
|
255
|
+
style={state => ({ flexDirection: "row", alignItems: stacked ? "flex-start" : "center", gap: 10, minHeight: touch ? 52 : 40, paddingLeft: 14, paddingRight: 16, paddingVertical: stacked ? (touch ? 12 : 8) : 0, borderBottomWidth: 1, borderBottomColor: c.border,
|
|
248
256
|
// Its ask isn't a Needs-you row (it's yours to route), so the edge marks it the way blocking rows are marked.
|
|
249
257
|
borderLeftWidth: 2, borderLeftColor: o.state === "asks" || o.state === "error" ? withAlpha(tone, 0.9) : "transparent",
|
|
250
258
|
backgroundColor: selected ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
|
|
251
|
-
{
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
259
|
+
{stacked ? <View style={{ paddingTop: 2 }}>{icon}</View> : icon}
|
|
260
|
+
{stacked
|
|
261
|
+
? <View style={{ flex: 1, gap: 2 }}>
|
|
262
|
+
<Text style={{ color: c.foreground, fontSize: touch ? 14 : 13, fontWeight: "600" }}>Overseer</Text>
|
|
263
|
+
<Text numberOfLines={2} style={{ color: lineColor, fontSize: touch ? 13 : 12, lineHeight: touch ? 18 : 16 }}>{line}</Text>
|
|
264
|
+
</View>
|
|
265
|
+
: <>
|
|
266
|
+
<Text style={{ color: c.foreground, fontSize: touch ? 14 : 13, fontWeight: "600" }}>Overseer</Text>
|
|
267
|
+
<Text numberOfLines={1} style={{ flex: 1, color: lineColor, fontSize: touch ? 13 : 12 }}>{line}</Text>
|
|
268
|
+
{touch && <Icon name="ChevronRight" size={16} color={c.foregroundMuted} />}
|
|
269
|
+
</>}
|
|
255
270
|
</Pressable>;
|
|
256
271
|
}
|
|
257
272
|
|
package/client/home.tsx
CHANGED
|
@@ -93,6 +93,9 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
93
93
|
} : undefined, [navigation, compact, deps]);
|
|
94
94
|
useNextRelay(inbox, params, openAgentRow, openWorkspaceRelay);
|
|
95
95
|
useEffect(() => { if (params.select) setSelected(`agent:${params.select}`); }, [params.select]);
|
|
96
|
+
// An already-open Home asked to show an item (the sidebar view's Overseer row: Start and Restart live here). `at` makes
|
|
97
|
+
// the same item twice a second request.
|
|
98
|
+
useEffect(() => { if (params.item && params.at) setSelected(params.item); }, [params.item, params.at]);
|
|
96
99
|
// Phones show one thing at a time. A row opens its own screen (pushed by the host) instead of swapping in place, so the
|
|
97
100
|
// host's ← is the only back control and it lands on the list. Desktop selects in place beside the list.
|
|
98
101
|
const route = compact && deps.openItem ? deps.openItem : null;
|
package/client/panel-menu.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { useRowMenu } from "./row-actions";
|
|
|
8
8
|
import type { HomeSources } from "./home-data";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* The panel header's More button: the same row menu Home and the sidebar show for this workspace (Rename with AI
|
|
11
|
+
* The panel header's More button: the same row menu Home and the sidebar show for this workspace (Rename title with AI
|
|
12
12
|
* among it), so there is one menu everywhere. A popover under the button on desktop, the sheet on phones.
|
|
13
13
|
*/
|
|
14
14
|
export function PanelMore({ w, sources, theme, compact, openAgent, openQuestion, showMenu }: {
|
package/client/rename.tsx
CHANGED
|
@@ -14,7 +14,7 @@ import { Spinner } from "./motion";
|
|
|
14
14
|
import { hasToastHost, pushToast, runAction } from "./toast-store";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Rename with AI (docs/ai-roles.md#rename-with-ai): one dialog for every entry point (row menus, the panel's More
|
|
17
|
+
* Rename title with AI (docs/ai-roles.md#rename-title-with-ai): one dialog for every entry point (row menus, the panel's More
|
|
18
18
|
* menu, ⌘K). It asks for a suggestion as it opens, shows it in an editable field, and renames only on Rename. The
|
|
19
19
|
* toast after it carries Undo; for 24 hours the dialog also offers Undo last rename.
|
|
20
20
|
*/
|
|
@@ -106,7 +106,7 @@ export function RenameDialog({ request, theme, compact, onClose }: { request: Re
|
|
|
106
106
|
// Only near the limit: the reason text covers the rest (words, keys, branch names).
|
|
107
107
|
const showCounter = counter > NAME_MAX_CHARS - 15;
|
|
108
108
|
const waiting = phase === "suggesting" && !name;
|
|
109
|
-
return <Modal title="Rename with AI" icon={<Icon name="Sparkles" size={18} color={c.foregroundMuted} />} open onOpenChange={next => { if (!next) onClose(); }}>
|
|
109
|
+
return <Modal title="Rename title with AI" icon={<Icon name="Sparkles" size={18} color={c.foregroundMuted} />} open onOpenChange={next => { if (!next) onClose(); }}>
|
|
110
110
|
<Modal.Content contentContainerStyle={{ padding: compact ? 16 : 20 }}>
|
|
111
111
|
<SubmitScope enabled={canRename} onSubmit={apply} style={{ gap: compact ? 16 : 14, maxWidth: 520 }}>
|
|
112
112
|
<View style={{ gap: 2 }}>
|
package/client/row-actions.ts
CHANGED
|
@@ -85,7 +85,7 @@ export function useRowMenu(host: RowMenuHost) {
|
|
|
85
85
|
case "copy_branch": return runAction({ label: "Copy branch", run: () => copyText(arg), success: "Branch name copied", failure: "Couldn't copy here" });
|
|
86
86
|
case "copy_pr": return runAction({ label: "Copy PR link", run: () => copyText(arg), success: arg.includes("\n") ? "PR links copied" : "PR link copied", failure: "Couldn't copy here" });
|
|
87
87
|
case "rewrite_summary": return runAction({ label: "Rewrite summary", run: async () => cache.setQueryData(aboutKey(workspaceId), await about({ workspaceId, open: true, refresh: true })), success: "Summary rewritten" }, `about:${workspaceId}`);
|
|
88
|
-
case "rename_ai": return runAction({ label: "Rename with AI", run: async () => openRename({ workspaceId, title: s.title }), success: null });
|
|
88
|
+
case "rename_ai": return runAction({ label: "Rename title with AI", run: async () => openRename({ workspaceId, title: s.title }), success: null });
|
|
89
89
|
case "make_main": return runAction({ label: "Make main agent", run: async () => { await control({ workspaceId, mainAgentId: arg }); after(); }, success: `${s.agent ?? "That agent"} is now the main agent` }, `main:${workspaceId}`);
|
|
90
90
|
case "stop_following": return runAction({ label: "Stop following", run: async () => { await setFollow({ workspace: { workspaceId, follow: false } }); after(); }, success: `Stopped following ${s.title}` }, `follow:${workspaceId}`);
|
|
91
91
|
}
|
package/client/sidebar-view.tsx
CHANGED
|
@@ -3,13 +3,14 @@ import type { PluginClientContext, PluginHostProps } from "@getpaseo/plugin/clie
|
|
|
3
3
|
import { useCallback, useMemo, useSyncExternalStore, type ComponentType } from "react";
|
|
4
4
|
import { View } from "react-native";
|
|
5
5
|
import { Text } from "./text";
|
|
6
|
-
import { UndoBar, useSidebarViewMounted } from "./inbox";
|
|
7
|
-
import { HomeList } from "./home-list";
|
|
6
|
+
import { UndoBar, useInbox, useSidebarViewMounted } from "./inbox";
|
|
7
|
+
import { HomeList, OVERSEER_KEY, type OverseerRowState } from "./home-list";
|
|
8
8
|
import { FilterField, SortMenu, useListFilter } from "./home-chrome";
|
|
9
9
|
import { useHomeModel, type HomeSources } from "./home-data";
|
|
10
10
|
import { useRowMenu } from "./row-actions";
|
|
11
11
|
import { RenameHost } from "./rename";
|
|
12
12
|
import type { Workstream } from "../shared/home";
|
|
13
|
+
import { listOverseerRow, overseerRowTarget } from "../shared/overseer";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Phase 2: Home's list as Paseo's sidebar (the same HomeList component Home uses). `addSidebarView` and the ref queries exist on Paseo main
|
|
@@ -38,7 +39,8 @@ export function sidebarViewHost(client: PluginClientContext): SidebarViewHost |
|
|
|
38
39
|
return typeof candidate.addSidebarView === "function" && typeof hooks.useAgents === "function" && typeof hooks.useWorkspaces === "function" ? candidate as SidebarViewHost : null;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
/** `openOverseerHome`: Follow-up Home with the Overseer selected, where Start and Restart live. */
|
|
43
|
+
export function inboxSidebarView(sources: HomeSources, openOverseerHome: () => void) {
|
|
42
44
|
return function NeedsYouSidebar(view: SidebarViewProps) {
|
|
43
45
|
const refs = sdk as unknown as RefSdk;
|
|
44
46
|
useSidebarViewMounted();
|
|
@@ -51,26 +53,38 @@ export function inboxSidebarView(sources: HomeSources) {
|
|
|
51
53
|
const workspaces = refs.useWorkspaces({});
|
|
52
54
|
const agentRef = useMemo(() => new Map(agents.map(r => [r.id, r])), [agents]);
|
|
53
55
|
const workspaceRef = useMemo(() => new Map(workspaces.map(r => [r.id, r])), [workspaces]);
|
|
56
|
+
// Home's pinned Overseer row, the same state (one-row-everywhere); a filter keeps it only when it's about it.
|
|
57
|
+
const overseerStatus = useSyncExternalStore(sources.extras.subscribe, sources.extras.overseer, sources.extras.overseer);
|
|
58
|
+
const overseerInbox = useInbox(sources.inbox, () => sources.inbox.overseer());
|
|
59
|
+
const overseer: OverseerRowState | null = listOverseerRow(overseerStatus, overseerInbox, filter.query);
|
|
60
|
+
const overseerAgent = overseerStatus?.agentId ?? null;
|
|
54
61
|
const touch = view.layout.compact;
|
|
55
62
|
const c = view.theme.colors;
|
|
56
63
|
const activeAgent = view.active.agent?.id ?? null;
|
|
57
64
|
const activeWorkspace = view.active.workspace?.id ?? null;
|
|
58
65
|
const selectedKey = useMemo(() => {
|
|
66
|
+
if (overseer && activeAgent && activeAgent === overseerAgent) return OVERSEER_KEY;
|
|
59
67
|
const all = [...full.byKey.values()];
|
|
60
68
|
return all.find(s => activeAgent && s.agentId === activeAgent)?.key ?? all.find(s => activeWorkspace && s.workspaceId === activeWorkspace)?.key ?? null;
|
|
61
|
-
}, [full, activeAgent, activeWorkspace]);
|
|
69
|
+
}, [full, activeAgent, activeWorkspace, overseer, overseerAgent]);
|
|
62
70
|
const onSelect = useCallback((key: string) => {
|
|
71
|
+
if (key === OVERSEER_KEY) {
|
|
72
|
+
// A live Overseer opens its chat like any row; Start and a failed restart need Home's Overseer pane.
|
|
73
|
+
const ref = overseerAgent ? agentRef.get(overseerAgent) : undefined;
|
|
74
|
+
if (overseer && overseerRowTarget(overseer.state) === "chat" && ref) view.navigation.openAgent(ref); else openOverseerHome();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
63
77
|
const s = full.byKey.get(key);
|
|
64
78
|
const agent = s?.agentId ? agentRef.get(s.agentId) : undefined;
|
|
65
79
|
const workspace = s?.workspaceId ? workspaceRef.get(s.workspaceId) : undefined;
|
|
66
80
|
if (agent) view.navigation.openAgent(agent); else if (workspace) view.navigation.openWorkspace(workspace);
|
|
67
|
-
}, [full, agentRef, workspaceRef, view.navigation]);
|
|
81
|
+
}, [full, agentRef, workspaceRef, view.navigation, overseer, overseerAgent]);
|
|
68
82
|
// The row menu, as on Home (rename among it). No omnibox here, so no Ask; Open and Answer go to the chat.
|
|
69
83
|
const openKey = (s: Workstream) => onSelect(s.key);
|
|
70
84
|
const menu = useRowMenu({ sources, openFull: openKey, openQuestion: openKey, overseerOn: false });
|
|
71
85
|
if (!sources.inbox.enabled()) return <View style={{ padding: 12 }}><Text style={{ color: c.foregroundMuted, fontSize: 12 }}>The Needs-you inbox is off. Turn it on in Follow-up's display settings.</Text></View>;
|
|
72
86
|
return <View style={{ flex: 1 }}>
|
|
73
|
-
<HomeList model={model} hits={filter.hits} theme={view.theme} dense touch={touch} selectedKey={selectedKey} onSelect={onSelect} menu={menu}
|
|
87
|
+
<HomeList model={model} hits={filter.hits} theme={view.theme} dense touch={touch} selectedKey={selectedKey} onSelect={onSelect} menu={menu} overseer={overseer} stackOverseer
|
|
74
88
|
// One row, nothing else (invariant 8): the filter takes the width, the sort is an icon. zIndex keeps the
|
|
75
89
|
// sort menu above the list on web, where every View is its own stacking context.
|
|
76
90
|
top={<View style={{ zIndex: 10, flexDirection: "row", alignItems: "center", gap: touch ? 8 : 4, paddingHorizontal: touch ? 12 : 8, paddingVertical: touch ? 8 : 6, borderBottomWidth: 1, borderBottomColor: c.border }}>
|
package/index.client.tsx
CHANGED
|
@@ -18,6 +18,7 @@ import { createInboxStore } from "./client/inbox-store";
|
|
|
18
18
|
import { contributeInboxCommands } from "./client/inbox";
|
|
19
19
|
import type { BriefDeps } from "./client/brief";
|
|
20
20
|
import { inboxSidebarView, sidebarViewHost } from "./client/sidebar-view";
|
|
21
|
+
import { OVERSEER_KEY } from "./client/home-list";
|
|
21
22
|
import { contributeBrief } from "./client/brief";
|
|
22
23
|
import { clientTimeZoneRpc, setOnboardingRpc } from "./shared/contracts";
|
|
23
24
|
import { isCategory, writeCategory } from "./shared/settings-nav";
|
|
@@ -104,7 +105,7 @@ export default function contribute(host: PluginClientContext) {
|
|
|
104
105
|
// Without a link yet, open the panel, where the spec link can be added.
|
|
105
106
|
if (url) void openExternalUrl(url).catch(() => undefined); else openPanel(PANEL, { location: location() });
|
|
106
107
|
} }),
|
|
107
|
-
client.addCommandCenterItem({ id: "follow-up-rename", title: "Follow-up: Rename
|
|
108
|
+
client.addCommandCenterItem({ id: "follow-up-rename", title: "Follow-up: Rename title with AI", icon: "Sparkles", keywords: ["rename", "name", "title", "AI", "suggest"], context: "workspace", onSelect({ workspace, openPanel }) {
|
|
108
109
|
// The dialog lives in Follow-up's surfaces: open the panel, which mounts a host, then ask.
|
|
109
110
|
openPanel(PANEL, { location: location() }); setTimeout(() => openRename({ workspaceId: workspace.id }), 0); } }),
|
|
110
111
|
client.addCommandCenterItem({ id: "follow-up-overview", title: "Follow-up: Home", icon: "House", keywords: ["home", "workspaces", "needs you", "inbox", "attention", "brief", "overview"], context: "global", onSelect({ openScreen }) { openScreen({ screenId: OVERVIEW }); } }),
|
|
@@ -139,7 +140,7 @@ export default function contribute(host: PluginClientContext) {
|
|
|
139
140
|
removers.push(extras.subscribe(syncAsk), () => removeAsk?.());
|
|
140
141
|
// Phase 2: only on hosts with the sidebar-view API (Paseo main after 2026-11-07).
|
|
141
142
|
const views = sidebarViewHost(host);
|
|
142
|
-
if (views) removers.push(views.addSidebarView({ id: "needs-you", title: "Follow-up: Needs you", description: "Agents that need you until you sign them off, then your workspaces.", Component: inboxSidebarView(sources) }));
|
|
143
|
+
if (views) removers.push(views.addSidebarView({ id: "needs-you", title: "Follow-up: Needs you", description: "Agents that need you until you sign them off, then your workspaces.", Component: inboxSidebarView(sources, () => client.openScreen({ screenId: OVERVIEW, params: { item: OVERSEER_KEY, at: String(Date.now()) } })) }));
|
|
143
144
|
|
|
144
145
|
return async () => {
|
|
145
146
|
setReportFallback(null); setReportError(null);
|
package/index.server.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { stopWorker } from "./server/teardown";
|
|
2
|
+
import { WriteHealth } from "./server/write-behind";
|
|
2
3
|
import { actorBy, actorOf, type Actor } from "./shared/actor";
|
|
3
4
|
import { TICK_MS } from "./shared/poll";
|
|
4
5
|
import { PluginMove } from "./server/plugin-move";
|
|
@@ -201,6 +202,9 @@ export default function contribute(server: PluginServerContext) {
|
|
|
201
202
|
prWorkflow.onChanged = () => { void store.snapshot().then(state => store.onChanged(state)).catch(() => undefined); };
|
|
202
203
|
const browser = new BrowserBridge();
|
|
203
204
|
const reviewerStore = new ReviewerConfigStore(directory);
|
|
205
|
+
// an-ack-never-waits-on-the-disk (server/write-behind.ts): these files save behind the reply; one still failing after
|
|
206
|
+
// SURFACE_AFTER attempts shows as the worker's error line until it lands.
|
|
207
|
+
const writeHealth = new WriteHealth();
|
|
204
208
|
const reviewerSuggestions = new ReviewerSuggestions();
|
|
205
209
|
const actions = new PrActions(store, github, graphite, browser);
|
|
206
210
|
actions.savedMethod = repo => prWorkflow.current().repos[repoKey(repo)]?.mergeMethod ?? null;
|
|
@@ -311,8 +315,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
311
315
|
if (!governor.allowsExtras()) { if (!stopped) inboxTimer = setTimeout(() => void inboxLoop(), 15_000); return; }
|
|
312
316
|
try { await writeBriefState().catch(() => undefined); await inbox.tick(); await inbox.reconcilePermissions(); await inbox.observeGuard(); await inbox.observeFollowUp(await store.snapshot()); inboxError = null; }
|
|
313
317
|
catch (error) { inboxError = error instanceof Error ? error.message : "The Needs-you inbox couldn't update."; }
|
|
314
|
-
// The Overseer's digest
|
|
315
|
-
if (overseer) { await overseer.
|
|
318
|
+
// The Overseer's digest backstop (it is built when its turn starts: agent.turn_started below) and its recreation if it was archived. Never blocks the inbox.
|
|
319
|
+
if (overseer) { await overseer.backstopDigest().catch(() => undefined); if (api) await overseer.ensure(api as unknown as OverseerPaseo, { periodic: true }).catch(() => undefined); }
|
|
316
320
|
// The ranker's scheduled run (window, cadence, cap and the governor are its own checks). Never awaited: it can take minutes.
|
|
317
321
|
if (ranker) void ranker.tick().catch(() => undefined);
|
|
318
322
|
// Wake-ups, the Overseer's status and the directory's titles move with this tick; the feeds diff, so a quiet tick
|
|
@@ -414,6 +418,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
414
418
|
// Brief answers recorded before a reload that Paseo never confirmed go out again, under the same messageId.
|
|
415
419
|
await inbox.resumeAnswers(sendTo).catch(() => undefined);
|
|
416
420
|
})().catch(() => { loadError = "Follow-up could not start. Check its saved state and worker lock."; });
|
|
421
|
+
for (const file of [store, reviewerStore.persist, agentSettings.persist, prWorkflow.persist, inbox.store.persist]) file.health = writeHealth;
|
|
417
422
|
const requireReady = async () => { await ready; if (loadError || stopped) throw new Error(loadError ?? "Follow-up is stopping"); };
|
|
418
423
|
// 1.4.0-beta.2: Follow-up's tools per agent: natively through Paseo's MCP when the host serves plugin tools,
|
|
419
424
|
// otherwise the stdio bridge for this launch only. FOLLOW_UP_TOOLS tells the hooks which names the agent has.
|
|
@@ -545,8 +550,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
545
550
|
const view = browserWorkspaces(entries);
|
|
546
551
|
return { tracked: true, ...view, workspaces: view.workspaces.map(w => ({ ...w, title: w.title.slice(0, 200), agentStatus: w.agentStatus.slice(0, 40), state: w.state.slice(0, 200) })) };
|
|
547
552
|
});
|
|
548
|
-
handle(rpc.listRpc, async ({ since }) => { await ready; return { ...listCache.answer(await store.snapshot(), since), error: loadError ?? hookError ?? engine.error }; });
|
|
549
|
-
handle(rpc.getRpc, async ({ workspaceId }) => { await ready; return { workspace: (await store.snapshot()).workspaces.find(w => w.id === workspaceId && w.enable_tracking) ?? null, error: loadError ?? hookError ?? engine.error }; });
|
|
553
|
+
handle(rpc.listRpc, async ({ since }) => { await ready; return { ...listCache.answer(await store.snapshot(), since), error: loadError ?? hookError ?? writeHealth.message() ?? engine.error }; });
|
|
554
|
+
handle(rpc.getRpc, async ({ workspaceId }) => { await ready; return { workspace: (await store.snapshot()).workspaces.find(w => w.id === workspaceId && w.enable_tracking) ?? null, error: loadError ?? hookError ?? writeHealth.message() ?? engine.error }; });
|
|
550
555
|
handle(rpc.syncWorkspaceRpc, async ({ agentId, summary }, { paseo }) => {
|
|
551
556
|
await requireReady();
|
|
552
557
|
const workspaceId = await callerWorkspaceId(agentId, paseo, false);
|
|
@@ -1056,7 +1061,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1056
1061
|
firstMessage: async agentId => { await historyCache.load(); return historyCache.get(agentId)?.history.goal ?? null; }, roomForBackground: async () => governor.allowsBackground(), roomOnDemand: async () => governor.allowsExtras(),
|
|
1057
1062
|
});
|
|
1058
1063
|
handle(rpc.workspaceAboutRpc, async ({ workspaceId, open, refresh }, { paseo }) => { await requireReady(); seen(paseo); return about.view(workspaceId, { open, refresh }); });
|
|
1059
|
-
// Rename with AI (server/rename.ts): stored data only, Summaries' model, Paseo's own workspace title.
|
|
1064
|
+
// Rename title with AI (server/rename.ts): stored data only, Summaries' model, Paseo's own workspace title.
|
|
1060
1065
|
const renamer = new RenameService({
|
|
1061
1066
|
store: new RenameStore(directory), jobs: aiJobs, role: () => agentSettings.role("about"),
|
|
1062
1067
|
titles: renameDaemon(withDaemon as never, () => gateway.directory.markDirty()),
|
|
@@ -1207,7 +1212,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1207
1212
|
// Subscriptions (Paseo 0.16): every open client used to poll these reads (about 17 a minute for an idle Home); now
|
|
1208
1213
|
// the worker pushes from state it already holds, one shared serve per topic (server/feeds.ts, invariant
|
|
1209
1214
|
// idle-client-makes-at-most-one-rpc-a-minute). A 0.15 host serves no subscriptions, and its clients keep polling.
|
|
1210
|
-
const workspacesFeed = new WorkspacesFeed(listCache, () => store.snapshot(), () => loadError ?? hookError ?? engine.error);
|
|
1215
|
+
const workspacesFeed = new WorkspacesFeed(listCache, () => store.snapshot(), () => loadError ?? hookError ?? writeHealth.message() ?? engine.error);
|
|
1211
1216
|
const inboxFeed = new ValueFeed({ read: async () => { await requireReady(); return inboxAnswer({ ...await inbox.list(), error: inboxError }, undefined); }, key: v => v.etag ?? JSON.stringify(v) });
|
|
1212
1217
|
let usageWatch: { close(): void } | null = null;
|
|
1213
1218
|
const homeFeed = new ValueFeed({
|
|
@@ -1373,6 +1378,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1373
1378
|
server.on("agent.turn_started", async () => updater.activity()),
|
|
1374
1379
|
server.on("agent.turn_ended", async () => { updater.activity(); void evaluateMove(); }),
|
|
1375
1380
|
server.on("agent.turn_started", async (event, { paseo }) => { seen(paseo); inboxHook(() => inbox.turnStarted(event.agent, event.turnId)); }),
|
|
1381
|
+
// a-derived-view-is-built-when-read: the Overseer's digest, built for the turn its prompt hook is about to read.
|
|
1382
|
+
server.on("agent.turn_started", async event => { await ready; if (stopped || loadError || !overseer) return; await overseer.turnStarted(event.agent.id).catch(() => undefined); }),
|
|
1376
1383
|
// A newer main-agent turn supersedes the failed turn's automatic hold (shared/status.ts holdSuperseded).
|
|
1377
1384
|
// A turn writes only the workspace it is about (server/turn-events.ts, a-send-never-clones-the-whole-state): a
|
|
1378
1385
|
// superseded hold lifts, the owned workspace's Done ends, and a dormant workspace becomes active again.
|
|
@@ -1473,6 +1480,6 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1473
1480
|
// One deadline for every wait (worker-stop-never-waits-on-a-stuck-pass, server/teardown.ts): start-up and the work
|
|
1474
1481
|
// in flight may be stuck on a daemon or CLI that never answers. Work that ends inside the deadline is saved; what
|
|
1475
1482
|
// outlives it can't write, because the store closes before the lock is released.
|
|
1476
|
-
await stopWorker({ ready, hooks: hooksStarted ? () => agentHooks.stop() : undefined, actions, closeConnections, engine, store, inbox: inbox.store, unlock });
|
|
1483
|
+
await stopWorker({ files: [reviewerStore, agentSettings, prWorkflow], ready, hooks: hooksStarted ? () => agentHooks.stop() : undefined, actions, closeConnections, engine, store, inbox: inbox.store, unlock });
|
|
1477
1484
|
};
|
|
1478
1485
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0-beta.0",
|
|
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/agent-actions.ts
CHANGED
|
@@ -436,7 +436,7 @@ export class AgentActions {
|
|
|
436
436
|
|
|
437
437
|
/** Later and Bring back now on a workspace-only Needs-you row, planned like snooze. Same mutator as the row menu. */
|
|
438
438
|
/**
|
|
439
|
-
* Rename with AI (server/rename.ts): the dry run asks for a suggestion (or takes `title`, or plans Undo) and shows the
|
|
439
|
+
* Rename title with AI (server/rename.ts): the dry run asks for a suggestion (or takes `title`, or plans Undo) and shows the
|
|
440
440
|
* name now and the name after; confirm runs the dialog's Rename with that exact name.
|
|
441
441
|
*/
|
|
442
442
|
private async planRename(caller: string, args: { workspaceId?: string; title?: string; undo?: boolean }) {
|
package/server/agent-hook.mjs
CHANGED
|
@@ -82,6 +82,25 @@ export function overseerDigest(file, seen, now = Date.now(), { needsMax = 20, ch
|
|
|
82
82
|
for (const l of lines) { if (text.length + l.length + 1 > chars) { text += "- …truncated: use workstreams()\n"; break; } text += l + "\n"; }
|
|
83
83
|
return { text: text.trimEnd(), seen: { at: now, rows: Object.fromEntries(all.map(r => [r.id, r.hash])) } };
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* a-derived-view-is-built-when-read: the worker builds overseer-digest.json when the Overseer's turn starts, usually before
|
|
87
|
+
* this hook runs. The file is fresh for this turn when its builtAt is newer than the one the Overseer last saw and
|
|
88
|
+
* within windowMs of now; otherwise poll every stepMs for up to waitMs, then use what is there (the last build, at most
|
|
89
|
+
* the worker's 10-min backstop old). A worker that writes no builtAt is taken as is. Pure apart from read and sleep.
|
|
90
|
+
*/
|
|
91
|
+
export async function freshDigest(read, seen, { now = Date.now, sleep = ms => new Promise(r => setTimeout(r, ms)), waitMs = 1500, stepMs = 100, windowMs = 5000 } = {}) {
|
|
92
|
+
const fresh = file => {
|
|
93
|
+
if (!file?.builtAt) return true;
|
|
94
|
+
const built = Date.parse(file.builtAt);
|
|
95
|
+
const last = Date.parse(seen?.builtAt ?? "");
|
|
96
|
+
return (!Number.isFinite(last) || built > last) && now() - built <= windowMs;
|
|
97
|
+
};
|
|
98
|
+
let file = await read();
|
|
99
|
+
const until = now() + waitMs;
|
|
100
|
+
let waited = 0;
|
|
101
|
+
while (!fresh(file) && now() < until) { await sleep(stepMs); waited += stepMs; file = (await read()) ?? file; }
|
|
102
|
+
return { file, fresh: fresh(file), waited };
|
|
103
|
+
}
|
|
85
104
|
/**
|
|
86
105
|
* How batches are worked, for this workspace's PR workflow (from scopes.json). Graphite with /fix-pr, and agents of an
|
|
87
106
|
* older worker that wrote no workflow, keep the original text; plain GitHub never mentions Graphite, gt or /fix-pr.
|
|
@@ -196,11 +215,12 @@ async function main() {
|
|
|
196
215
|
return;
|
|
197
216
|
}
|
|
198
217
|
if (event.hook_event_name !== "UserPromptSubmit") return;
|
|
199
|
-
const file = await json(join(directory, "overseer-digest.json")).catch(() => null);
|
|
200
|
-
if (!file || file.agentId !== agentId) return;
|
|
201
218
|
const seenPath = join(directory, "hook-state", `overseer-seen-${agentId}.json`);
|
|
202
|
-
const
|
|
203
|
-
await
|
|
219
|
+
const seen = await json(seenPath).catch(() => null);
|
|
220
|
+
const { file } = await freshDigest(() => json(join(directory, "overseer-digest.json")).catch(() => null), seen);
|
|
221
|
+
if (!file || file.agentId !== agentId) return;
|
|
222
|
+
const digest = overseerDigest(file, seen);
|
|
223
|
+
await save(seenPath, { ...digest.seen, ...(file.builtAt ? { builtAt: file.builtAt } : {}) });
|
|
204
224
|
process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: digest.text } }) + "\n");
|
|
205
225
|
return;
|
|
206
226
|
}
|
package/server/agent-settings.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { WriteBehind } from "./write-behind";
|
|
4
4
|
import {
|
|
5
5
|
AGENT_ROLES, EMPTY_AGENT_SETTINGS, isJobRole, parseAgentSettings, resolveAll, resolveRole,
|
|
6
6
|
type AgentRole, type AgentSettingsFile, type Catalog, type CatalogProvider, type RoleConfig, type SavedRole,
|
|
7
7
|
} from "../shared/agent-settings";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* The role settings file (`agents.json`), its own small file next to state.json. Read once and cached;
|
|
11
|
-
* serialized
|
|
10
|
+
* The role settings file (`agents.json`), its own small file next to state.json. Read once and cached; changes are
|
|
11
|
+
* serialized and validated, then saved behind the reply (an-ack-never-waits-on-the-disk, server/write-behind.ts),
|
|
12
|
+
* atomic and owner-only, and only when the developer changes something.
|
|
12
13
|
*/
|
|
13
14
|
export class AgentSettingsStore {
|
|
14
15
|
private tail: Promise<unknown> = Promise.resolve();
|
|
15
16
|
private cached: { file: AgentSettingsFile; invalid: AgentRole[] } | null = null;
|
|
16
|
-
|
|
17
|
+
/** agents.json, written behind the reply. */
|
|
18
|
+
readonly persist: WriteBehind<AgentSettingsFile>;
|
|
19
|
+
constructor(readonly directory: string) { this.persist = new WriteBehind({ path: this.path, encode: file => JSON.stringify(file, null, 2) }); }
|
|
17
20
|
private get path() { return join(this.directory, "agents.json"); }
|
|
21
|
+
/** Waits for the changes in flight, then writes what is pending; the worker's stop calls it. */
|
|
22
|
+
async flush(): Promise<void> { await this.tail; await this.persist.flush(); }
|
|
18
23
|
|
|
19
24
|
async load(): Promise<{ file: AgentSettingsFile; invalid: AgentRole[] }> {
|
|
20
25
|
if (this.cached) return this.cached;
|
|
@@ -38,8 +43,8 @@ export class AgentSettingsStore {
|
|
|
38
43
|
copy.roles[role] = clean(role, parsed.file.roles[role] ?? {});
|
|
39
44
|
if (!Object.keys(copy.roles[role]!).length) delete copy.roles[role];
|
|
40
45
|
}
|
|
41
|
-
await this.write(copy);
|
|
42
46
|
this.cached = { file: copy, invalid: (this.cached?.invalid ?? []).filter(r => r !== role) };
|
|
47
|
+
this.persist.set(copy);
|
|
43
48
|
return copy;
|
|
44
49
|
});
|
|
45
50
|
this.tail = next.catch(() => undefined);
|
|
@@ -53,23 +58,14 @@ export class AgentSettingsStore {
|
|
|
53
58
|
const { file, invalid } = await this.load();
|
|
54
59
|
const copy: AgentSettingsFile = { ...structuredClone(file), enable_wait: enabled };
|
|
55
60
|
if (enabled) delete copy.enable_wait;
|
|
56
|
-
await this.write(copy);
|
|
57
61
|
this.cached = { file: copy, invalid };
|
|
62
|
+
this.persist.set(copy);
|
|
58
63
|
return copy;
|
|
59
64
|
});
|
|
60
65
|
this.tail = next.catch(() => undefined);
|
|
61
66
|
return next;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
private async write(file: AgentSettingsFile): Promise<void> {
|
|
65
|
-
await mkdir(this.directory, { recursive: true, mode: 0o700 });
|
|
66
|
-
const temporary = join(this.directory, `agents.${randomUUID()}.tmp`);
|
|
67
|
-
try {
|
|
68
|
-
const handle = await open(temporary, "wx", 0o600);
|
|
69
|
-
try { await handle.writeFile(JSON.stringify(file, null, 2)); await handle.sync(); } finally { await handle.close(); }
|
|
70
|
-
await rename(temporary, this.path);
|
|
71
|
-
} finally { await unlink(temporary).catch(() => undefined); }
|
|
72
|
-
}
|
|
73
69
|
}
|
|
74
70
|
|
|
75
71
|
/** Fields a role doesn't use aren't stored. */
|
package/server/hook-source.ts
CHANGED
|
@@ -85,6 +85,25 @@ export const hookSource: string = [
|
|
|
85
85
|
" return { text: text.trimEnd(), seen: { at: now, rows: Object.fromEntries(all.map(r => [r.id, r.hash])) } };",
|
|
86
86
|
"}",
|
|
87
87
|
"/**",
|
|
88
|
+
" * a-derived-view-is-built-when-read: the worker builds overseer-digest.json when the Overseer's turn starts, usually before",
|
|
89
|
+
" * this hook runs. The file is fresh for this turn when its builtAt is newer than the one the Overseer last saw and",
|
|
90
|
+
" * within windowMs of now; otherwise poll every stepMs for up to waitMs, then use what is there (the last build, at most",
|
|
91
|
+
" * the worker's 10-min backstop old). A worker that writes no builtAt is taken as is. Pure apart from read and sleep.",
|
|
92
|
+
" */",
|
|
93
|
+
"export async function freshDigest(read, seen, { now = Date.now, sleep = ms => new Promise(r => setTimeout(r, ms)), waitMs = 1500, stepMs = 100, windowMs = 5000 } = {}) {",
|
|
94
|
+
" const fresh = file => {",
|
|
95
|
+
" if (!file?.builtAt) return true;",
|
|
96
|
+
" const built = Date.parse(file.builtAt);",
|
|
97
|
+
" const last = Date.parse(seen?.builtAt ?? \"\");",
|
|
98
|
+
" return (!Number.isFinite(last) || built > last) && now() - built <= windowMs;",
|
|
99
|
+
" };",
|
|
100
|
+
" let file = await read();",
|
|
101
|
+
" const until = now() + waitMs;",
|
|
102
|
+
" let waited = 0;",
|
|
103
|
+
" while (!fresh(file) && now() < until) { await sleep(stepMs); waited += stepMs; file = (await read()) ?? file; }",
|
|
104
|
+
" return { file, fresh: fresh(file), waited };",
|
|
105
|
+
"}",
|
|
106
|
+
"/**",
|
|
88
107
|
" * How batches are worked, for this workspace's PR workflow (from scopes.json). Graphite with /fix-pr, and agents of an",
|
|
89
108
|
" * older worker that wrote no workflow, keep the original text; plain GitHub never mentions Graphite, gt or /fix-pr.",
|
|
90
109
|
" */",
|
|
@@ -198,11 +217,12 @@ export const hookSource: string = [
|
|
|
198
217
|
" return;",
|
|
199
218
|
" }",
|
|
200
219
|
" if (event.hook_event_name !== \"UserPromptSubmit\") return;",
|
|
201
|
-
" const file = await json(join(directory, \"overseer-digest.json\")).catch(() => null);",
|
|
202
|
-
" if (!file || file.agentId !== agentId) return;",
|
|
203
220
|
" const seenPath = join(directory, \"hook-state\", `overseer-seen-${agentId}.json`);",
|
|
204
|
-
" const
|
|
205
|
-
" await
|
|
221
|
+
" const seen = await json(seenPath).catch(() => null);",
|
|
222
|
+
" const { file } = await freshDigest(() => json(join(directory, \"overseer-digest.json\")).catch(() => null), seen);",
|
|
223
|
+
" if (!file || file.agentId !== agentId) return;",
|
|
224
|
+
" const digest = overseerDigest(file, seen);",
|
|
225
|
+
" await save(seenPath, { ...digest.seen, ...(file.builtAt ? { builtAt: file.builtAt } : {}) });",
|
|
206
226
|
" process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: \"UserPromptSubmit\", additionalContext: digest.text } }) + \"\\n\");",
|
|
207
227
|
" return;",
|
|
208
228
|
" }",
|