paseo-follow-up 2.2.0-beta.2 → 2.2.0-beta.4
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/catch-up.tsx +609 -0
- package/client/home-view.ts +21 -3
- package/client/home.tsx +32 -13
- package/client/questions.tsx +15 -2
- package/index.client.tsx +4 -1
- package/index.server.ts +29 -27
- package/package.json +1 -1
- package/server/agent-actions.ts +3 -3
- package/server/agent-parity.ts +6 -3
- package/server/context-requests.ts +51 -24
- package/shared/catch-up.ts +169 -36
- package/shared/contracts.ts +4 -2
- package/shared/display.ts +7 -0
package/client/home-view.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
2
|
-
import { displayFeed, homeFeed, overseerAskRpc, overseerRestartRpc, overseerStartRpc, overseerStatusRpc, prioritiesRpc, rankNowRpc, rankStatusRpc, usageRpc } from "../shared/contracts";
|
|
2
|
+
import { contextAskRpc, contextListRpc, displayFeed, homeFeed, overseerAskRpc, overseerRestartRpc, overseerStartRpc, overseerStatusRpc, prioritiesRpc, rankNowRpc, rankStatusRpc, usageRpc } from "../shared/contracts";
|
|
3
3
|
import { openFeed } from "./feeds";
|
|
4
|
-
import type { RpcOutput } from "@getpaseo/plugin";
|
|
4
|
+
import type { RpcInput, RpcOutput } from "@getpaseo/plugin";
|
|
5
5
|
import type { Priority } from "../shared/priorities";
|
|
6
6
|
import { DEFAULT_SORT, isSortMode, type SortMode } from "../shared/sort";
|
|
7
7
|
import { homeSortSync } from "../shared/display";
|
|
8
8
|
import type { AgentLite } from "../shared/search";
|
|
9
9
|
import { NO_USAGE, USAGE_POLL_MS, type Usage } from "../shared/usage";
|
|
10
10
|
import { onVisible, whileVisible } from "./visibility";
|
|
11
|
+
import type { ContextRequest } from "../shared/catch-up";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* What Home adds on top of the inbox, live and Paseo stores (1.3.0-beta.2): the sort choice, external
|
|
@@ -41,6 +42,10 @@ export function createHomeExtras(client: PluginClientContext) {
|
|
|
41
42
|
let usage: Usage = NO_USAGE;
|
|
42
43
|
let overseer: RpcOutput<typeof overseerStatusRpc> | null = null;
|
|
43
44
|
let rank: RpcOutput<typeof rankStatusRpc> | null = null;
|
|
45
|
+
/** Catch up's More context asks: pushed on the home feed; read when Catch up opens or moves, never on a timer of their own. */
|
|
46
|
+
let context: ContextRequest[] = [];
|
|
47
|
+
const setContext = (next: ContextRequest[]) => { if (JSON.stringify(next) === JSON.stringify(context)) return false; context = next; return true; };
|
|
48
|
+
const readContext = async () => setContext((await client.rpc(contextListRpc, {})).requests);
|
|
44
49
|
const agents = new Map<string, AgentLite>();
|
|
45
50
|
let version = 0;
|
|
46
51
|
let focusToken = 0; let focusPending = false;
|
|
@@ -91,7 +96,9 @@ export function createHomeExtras(client: PluginClientContext) {
|
|
|
91
96
|
poll(PRIORITY_POLL_MS, readRank),
|
|
92
97
|
poll(15_000, async () => {
|
|
93
98
|
const next = await client.rpc(overseerStatusRpc, {});
|
|
94
|
-
|
|
99
|
+
// Without the feed, an ask still open is read on the Overseer's existing poll: no poll of its own.
|
|
100
|
+
const asked = context.some(r => r.state === "asking") ? await readContext().catch(() => false) : false;
|
|
101
|
+
if (JSON.stringify(next) === JSON.stringify(overseer)) return asked;
|
|
95
102
|
overseer = next; return true;
|
|
96
103
|
}),
|
|
97
104
|
pollUsage(),
|
|
@@ -110,6 +117,7 @@ export function createHomeExtras(client: PluginClientContext) {
|
|
|
110
117
|
event: event => {
|
|
111
118
|
if (stopped) return;
|
|
112
119
|
priorities = event.priorities; rank = event.rank; overseer = event.overseer;
|
|
120
|
+
if (event.context) setContext(event.context);
|
|
113
121
|
if (event.usage) usage = { ...event.usage, resources: usage.resources };
|
|
114
122
|
if (!event.rank.running) { for (const done of rankWaiters) done(); rankWaiters.clear(); }
|
|
115
123
|
// Smart Session's files can't be watched: read the meters once a minute instead.
|
|
@@ -221,6 +229,16 @@ export function createHomeExtras(client: PluginClientContext) {
|
|
|
221
229
|
async askOverseer(text: string) { overseer = await client.rpc(overseerAskRpc, { text }); emit(); return overseer; },
|
|
222
230
|
/** Settings → Agents changed: a new Overseer on the configured agent, handed the old one's last steps. */
|
|
223
231
|
async restartOverseer() { overseer = await client.rpc(overseerRestartRpc, {}); emit(); return overseer; },
|
|
232
|
+
/** Catch up's More context asks and their answers. */
|
|
233
|
+
context: () => context,
|
|
234
|
+
/** Reads the asks once (Catch up opening or moving on, so a 0.15 host or a dropped feed is never stale for long). */
|
|
235
|
+
async refreshContext() { if (await readContext().catch(() => false)) emit(); },
|
|
236
|
+
/** Asks the Overseer or the card's agent; the ask shows at once, its answer arrives on the feed. */
|
|
237
|
+
async askContext(input: RpcInput<typeof contextAskRpc>) {
|
|
238
|
+
const out = await client.rpc(contextAskRpc, input);
|
|
239
|
+
setContext([...context.filter(r => r.id !== out.request.id), out.request]); emit();
|
|
240
|
+
return out;
|
|
241
|
+
},
|
|
224
242
|
agents: () => [...agents.values()],
|
|
225
243
|
/** Bumped by ⌘K "Follow-up: Search" and the search key; the visible search field focuses when it changes. */
|
|
226
244
|
focusToken: () => focusToken,
|
package/client/home.tsx
CHANGED
|
@@ -36,6 +36,8 @@ import { withAlpha, isLight, mergedColor, type Colors } from "./theme";
|
|
|
36
36
|
import { UpdateNotice, VersionMark } from "./updates";
|
|
37
37
|
import { WhatsNewGate } from "./release-notes";
|
|
38
38
|
import { ViewSync } from "./view-store";
|
|
39
|
+
import { CatchUp, CatchUpButton } from "./catch-up";
|
|
40
|
+
import { deckCards } from "../shared/catch-up";
|
|
39
41
|
import { ResizableSplit } from "./split";
|
|
40
42
|
import type { SearchKey } from "./search-key";
|
|
41
43
|
|
|
@@ -63,6 +65,8 @@ export type HomeDeps = {
|
|
|
63
65
|
/** Docks the workspace's own panel in its explorer column. */
|
|
64
66
|
openPanel(workspaceId: string): void;
|
|
65
67
|
openLog(): void;
|
|
68
|
+
/** Catch up: Needs you one card at a time (`?view=catchup`). */
|
|
69
|
+
openCatchUp?(): void;
|
|
66
70
|
openHome(): void;
|
|
67
71
|
/** Phones: open one Home item as its own screen, so the host's ← (and Android back) returns to the list. */
|
|
68
72
|
openItem?(key: string, extra?: { question?: string }): void;
|
|
@@ -97,7 +101,7 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
97
101
|
const omnibox = useOmnibox(model, deps.sources);
|
|
98
102
|
const searchKey = deps.searchKey;
|
|
99
103
|
const anywhereKey = useSyncExternalStore(searchKey?.subscribe ?? noSubscribe, searchKey?.label ?? noLabel, searchKey?.label ?? noLabel);
|
|
100
|
-
useSlashToFocus(omnibox, params.view !== "log");
|
|
104
|
+
useSlashToFocus(omnibox, params.view !== "log" && params.view !== "catchup");
|
|
101
105
|
const [filter, setFilter] = useState<HomeGroupId | null>(null);
|
|
102
106
|
const [selected, setSelected] = useState<string | null>(() => params.item ?? (params.select ? `agent:${params.select}` : null));
|
|
103
107
|
const openAgentRow = useMemo(() => navigation ? (row: InboxRow) => navigation.openAgent({ agentId: row.agentId }) : undefined, [navigation]);
|
|
@@ -118,6 +122,8 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
118
122
|
const current = selected ? model.byKey.get(selected) ?? (selected.startsWith("agent:") ? [...model.byKey.values()].find(x => x.agentId === selected.slice(6)) ?? null : null) : null;
|
|
119
123
|
const tracked = useSyncExternalStore(deps.sources.live.subscribe, deps.sources.live.version, deps.sources.live.version);
|
|
120
124
|
const rows = useInbox(inbox, () => inbox.rows());
|
|
125
|
+
// Go through's count is its cards (one per ask), the same deck the mode opens on.
|
|
126
|
+
const deckSize = useMemo(() => deckCards({ model, rows, items: id => { const w = deps.sources.live.get(id); return w ? needsYou(w as never) : []; } }).length, [model, rows, tracked, deps.sources.live]);
|
|
121
127
|
const pane = useMemo(() => briefPane({ model, rows, tracked: deps.sources.live.all(), now: Date.now() }), [model, rows, tracked, deps.sources.live]);
|
|
122
128
|
const rank = useSyncExternalStore(deps.sources.extras.subscribe, deps.sources.extras.rank, deps.sources.extras.rank);
|
|
123
129
|
const overseerStatus = useSyncExternalStore(deps.sources.extras.subscribe, deps.sources.extras.overseer, deps.sources.extras.overseer);
|
|
@@ -185,13 +191,17 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
185
191
|
<WhatsNewGate surface="home" theme={theme} compact={compact} />
|
|
186
192
|
<ToastHost theme={theme} compact={compact} />
|
|
187
193
|
</>;
|
|
194
|
+
if (params.view === "catchup") return <View style={{ flex: 1 }}>
|
|
195
|
+
<CatchUp theme={theme} compact={compact} deps={{ sources: deps.sources, briefDeps: deps.briefDeps, openHome: deps.openHome, openPanel: deps.openPanel }} navigation={navigation as never} onExit={deps.openHome} />
|
|
196
|
+
{updateSheets}
|
|
197
|
+
</View>;
|
|
188
198
|
if (params.view === "log") return <LogView theme={theme} compact={compact} sources={deps.sources} onHome={deps.openHome} onOpen={key => { setSelected(key); deps.openHome(); }} />;
|
|
189
199
|
|
|
190
200
|
const detail = selected === OVERSEER_KEY && overseer
|
|
191
201
|
? <OverseerPane theme={theme} compact={compact} o={overseer} focus={replyFocus} pending={pendingAsk} agentId={overseerStatus?.agentId ?? null} model={overseerStatus?.model ?? null} restartWith={overseerStatus?.restartWith ?? null} configured={overseerStatus?.configured ?? null} deps={deps} navigation={navigation} onBack={compact && !route ? () => setSelected(null) : undefined} />
|
|
192
202
|
: current
|
|
193
203
|
? <DetailPane key={current.key} s={current} model={model} theme={theme} compact={compact} deps={deps} openFull={openFull} signOffNext={signOffNext} ask={ask?.key === current.key ? ask : null} onBack={compact && !route ? () => setSelected(null) : undefined} />
|
|
194
|
-
: <BriefPane theme={theme} compact={compact} pane={pane} onSelect={key => route ? route(key) : setSelected(key)} openLog={deps.openLog} sources={deps.sources} />;
|
|
204
|
+
: <BriefPane theme={theme} compact={compact} pane={pane} catchUp={deps.openCatchUp} deckSize={deckSize} onSelect={key => route ? route(key) : setSelected(key)} openLog={deps.openLog} sources={deps.sources} />;
|
|
195
205
|
// Nothing followed at all: no sort, no meters, just the empty state and its action.
|
|
196
206
|
const nothing = model.groups.every(g => !g.items.length);
|
|
197
207
|
// Enter on a row: its chat, as Open full does. The brief has nothing to open; the Overseer opens once it runs.
|
|
@@ -230,6 +240,7 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
230
240
|
{/* No title row on phones. The strip has the row to itself, so every chip is reachable (Q51: "Sending" pushed
|
|
231
241
|
Waiting, Quiet and Later behind the version); the version is at the end of the list. */}
|
|
232
242
|
<StatusStrip theme={theme} model={model} filter={filter} onFilter={setFilter} touch dense />
|
|
243
|
+
{model.needs > 0 && deps.openCatchUp && <View style={{ paddingHorizontal: 16 }}><CatchUpButton theme={theme} compact count={deckSize} onPress={deps.openCatchUp} /></View>}
|
|
233
244
|
{updateNotice}
|
|
234
245
|
{model.needs === 0 && <SetupOffer theme={theme} compact view={props.onboarding} />}
|
|
235
246
|
</View> : updateNotice} />;
|
|
@@ -253,24 +264,32 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
253
264
|
* (side-panes-are-resizable). The pane's share is the Display setting `home_detail_fraction`, so set_display reaches it.
|
|
254
265
|
*/
|
|
255
266
|
function HomeSplit({ theme, main, detail }: { theme: Theme; main: ReactNode; detail: ReactNode }) {
|
|
267
|
+
return <DisplaySplit theme={theme} main={main} side={detail} field="home_detail_fraction" testID="follow-up-home-split" label="Resize the detail pane"
|
|
268
|
+
defaultFraction={HOME_DETAIL_DEFAULT} range={[HOME_DETAIL_MIN, HOME_DETAIL_MAX]} minSide={HOME_DETAIL_MIN_PX} minMain={HOME_LIST_MIN_PX} />;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** A resizable side pane whose share is a Display field (Home's detail pane, Catch up's queue rail). */
|
|
272
|
+
export function DisplaySplit({ theme, main, side, field, defaultFraction, range, minSide, minMain, label, testID }: {
|
|
273
|
+
theme: Theme; main: ReactNode; side: ReactNode; field: "home_detail_fraction" | "catch_up_rail_fraction";
|
|
274
|
+
defaultFraction: number; range: [number, number]; minSide: number; minMain: number; label: string; testID: string;
|
|
275
|
+
}) {
|
|
256
276
|
const settings = useSettings(displayPreferences);
|
|
257
277
|
const readDisplay = useRpc(displayRpc.read); const saveDisplay = useRpc(displayRpc.write);
|
|
258
278
|
const toast = useToast();
|
|
259
279
|
// The host's settings read paints first; the Display feed (an agent's set_display, another device) and this
|
|
260
280
|
// device's own saves replace it. undefined = never set (the default); null = nothing pushed yet.
|
|
261
281
|
const [pushed, setPushed] = useState<number | undefined | null>(null);
|
|
262
|
-
useEffect(() => subscribeDisplay(values => setPushed(values
|
|
263
|
-
const fraction = pushed !== null ? pushed : settings.status === "ready" ? settings.values
|
|
282
|
+
useEffect(() => subscribeDisplay(values => setPushed(values[field])), [field]);
|
|
283
|
+
const fraction = pushed !== null ? pushed : settings.status === "ready" ? settings.values[field] : undefined;
|
|
264
284
|
const commit = (next: number) => {
|
|
265
285
|
setPushed(next);
|
|
266
286
|
const client: DisplayClient = { rpc: (contract, input) => (contract as unknown) === displayRpc.read ? readDisplay(input as never) : saveDisplay(input as never) };
|
|
267
|
-
void writeDisplay(client, {
|
|
268
|
-
.then(ok => { if (!ok) toast.error("Couldn't save the pane's width. It resets when
|
|
287
|
+
void writeDisplay(client, { [field]: next })
|
|
288
|
+
.then(ok => { if (!ok) toast.error("Couldn't save the pane's width. It resets when this screen reopens."); })
|
|
269
289
|
.catch(e => toast.error(errorText(e)));
|
|
270
290
|
};
|
|
271
|
-
return <ResizableSplit theme={theme} main={main} side={
|
|
272
|
-
fraction={fraction} defaultFraction={
|
|
273
|
-
minSide={HOME_DETAIL_MIN_PX} minMain={HOME_LIST_MIN_PX} onCommit={commit} />;
|
|
291
|
+
return <ResizableSplit theme={theme} main={main} side={side} testID={testID} label={label}
|
|
292
|
+
fraction={fraction} defaultFraction={defaultFraction} range={range} minSide={minSide} minMain={minMain} onCommit={commit} />;
|
|
274
293
|
}
|
|
275
294
|
|
|
276
295
|
/** The right pane is never narrower than this, and the list keeps at least HOME_LIST_MIN_PX (its rows keep their reason line). */
|
|
@@ -294,7 +313,7 @@ function ListHeader({ theme, compact, onSettings }: { theme: Theme; compact: boo
|
|
|
294
313
|
type Permission = { id: string; name: string; title?: string; description?: string; detail?: Record<string, unknown>; input?: Record<string, unknown>; actions?: { id: string; label: string; behavior: "allow" | "deny"; variant?: string }[] };
|
|
295
314
|
|
|
296
315
|
/** The selected agent's live state: pending permissions and status, from its own handle (never the whole list). */
|
|
297
|
-
function useAgentLive(agentId: string | null) {
|
|
316
|
+
export function useAgentLive(agentId: string | null) {
|
|
298
317
|
const paseo = usePaseo();
|
|
299
318
|
const handle = useMemo(() => agentId ? paseo.agents.ref(agentId) : null, [paseo, agentId]);
|
|
300
319
|
const [, bump] = useState(0);
|
|
@@ -658,7 +677,7 @@ function permissionText(p: Permission): string {
|
|
|
658
677
|
return typeof v === "string" ? v : p.description ?? "";
|
|
659
678
|
}
|
|
660
679
|
|
|
661
|
-
function PermissionBlock({ p, theme, compact, busy, primary, onRespond }: { p: Permission; theme: Theme; compact: boolean; busy: boolean; primary: boolean; onRespond: (r: { behavior: "allow" | "deny"; selectedActionId?: string; message?: string }) => void }) {
|
|
680
|
+
export function PermissionBlock({ p, theme, compact, busy, primary, onRespond }: { p: Permission; theme: Theme; compact: boolean; busy: boolean; primary: boolean; onRespond: (r: { behavior: "allow" | "deny"; selectedActionId?: string; message?: string }) => void }) {
|
|
662
681
|
const c = theme.colors; const t = text(c, compact);
|
|
663
682
|
const command = permissionText(p);
|
|
664
683
|
// Provider-defined choices ("Always for this session") show as extra secondaries; Allow and Deny always exist.
|
|
@@ -728,7 +747,7 @@ function ReplyBox({ theme, compact, agentName, onSend, placeholder = "Answer in
|
|
|
728
747
|
|
|
729
748
|
// ---------- brief pane ----------
|
|
730
749
|
|
|
731
|
-
function BriefPane({ theme, compact, pane, onSelect, openLog, sources }: { theme: Theme; compact: boolean; pane: ReturnType<typeof briefPane>; onSelect: (key: string) => void; openLog: () => void; sources: HomeSources }) {
|
|
750
|
+
function BriefPane({ theme, compact, pane, onSelect, openLog, sources, catchUp, deckSize = 0 }: { theme: Theme; compact: boolean; pane: ReturnType<typeof briefPane>; onSelect: (key: string) => void; openLog: () => void; sources: HomeSources; catchUp?: () => void; deckSize?: number }) {
|
|
732
751
|
const c = theme.colors; const t = text(c, compact);
|
|
733
752
|
useTick(30_000);
|
|
734
753
|
const now = Date.now();
|
|
@@ -745,7 +764,7 @@ function BriefPane({ theme, compact, pane, onSelect, openLog, sources }: { theme
|
|
|
745
764
|
{!compact && <Text style={t.meta}>{date} · {time}</Text>}
|
|
746
765
|
<Text accessibilityRole="header" style={t.headline}>{pane.headline}</Text>
|
|
747
766
|
{compact && <Text style={t.meta}>Morning brief · {date} · {time}</Text>}
|
|
748
|
-
{pane.first && <Button theme={theme} compact={compact} grow={compact} kind="primary" icon="ArrowRight" title={`Open ${pane.first.title.length > 40 ? `${pane.first.title.slice(0, 40)}…` : pane.first.title}`} onPress={() => onSelect(pane.first!.key)} />}
|
|
767
|
+
{catchUp && deckSize > 0 ? <CatchUpButton theme={theme} compact={compact} count={deckSize} onPress={catchUp} /> : pane.first && <Button theme={theme} compact={compact} grow={compact} kind="primary" icon="ArrowRight" title={`Open ${pane.first.title.length > 40 ? `${pane.first.title.slice(0, 40)}…` : pane.first.title}`} onPress={() => onSelect(pane.first!.key)} />}
|
|
749
768
|
{!!pane.waiting && <Text style={t.body}><Text style={{ color: c.foregroundMuted }}>Waiting on others: </Text>{pane.waiting}</Text>}
|
|
750
769
|
<Text style={t.body}><Text style={{ color: c.foregroundMuted }}>Cleared since {sinceLabel(now)}: </Text>{pane.cleared ?? "nothing yet"}.</Text>
|
|
751
770
|
|
package/client/questions.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The question dialog and its answer form. The layout of options with a recommendation, the
|
|
2
2
|
// "what the agent does meanwhile" line and Copy are adapted from Progress
|
|
3
3
|
// (@stevecastaneda/paseo-progress, MIT, © 2026 Steve Castaneda); see THIRD_PARTY_NOTICES.md.
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
5
|
import { View } from "react-native";
|
|
6
6
|
import { Pressable, Text, copyable } from "./text";
|
|
7
7
|
import { openExternalUrl, useRpc } from "@getpaseo/plugin/client";
|
|
@@ -92,18 +92,26 @@ export function OptionCard({ theme, letter, label, consequence, recommended, sel
|
|
|
92
92
|
|
|
93
93
|
const inputStyle = (c: Colors, compact: boolean, lines: number) => ({ minHeight: compact ? 44 : 18 * lines + 16, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, backgroundColor: c.surface1, fontSize: 13, lineHeight: 18, textAlignVertical: "top" as const });
|
|
94
94
|
|
|
95
|
+
/** A sendable answer, handed to a surface that also offers Send outside the form (Catch up's move bar). */
|
|
96
|
+
export type SendReady = { send: () => void; busy: boolean };
|
|
97
|
+
|
|
95
98
|
/**
|
|
96
99
|
* One question with its answer form. Send records the answer and messages the asking agent straight
|
|
97
100
|
* away; Copy records it and puts a reply on the clipboard instead. The one answer flow every question surface draws
|
|
98
101
|
* (the dialog, Needs you on Home and in the panel, the pill, phones): what its field means comes from answerDraft
|
|
99
102
|
* (`one-answer-flow-for-every-question`), never from the surface.
|
|
100
103
|
*/
|
|
101
|
-
export function QuestionBody({ workspace: w, question: q, theme, compact, now = Date.now(), dense = false, bodyMaxHeight, openAgent, onAnswered, onDetails, onClose, inline = false }: {
|
|
104
|
+
export function QuestionBody({ workspace: w, question: q, theme, compact, now = Date.now(), dense = false, bodyMaxHeight, openAgent, onAnswered, onDetails, onClose, inline = false, onSendReady }: {
|
|
102
105
|
workspace: ListWorkspace; question: ListQuestion; theme: Theme; compact: boolean; now?: number; dense?: boolean; bodyMaxHeight?: number; openAgent?: (agentId: string) => void; onAnswered?: () => void; onDetails?: () => void;
|
|
103
106
|
/** Inside the Needs you block: its header says the title and when it was asked, its footer what the agent does meanwhile. */
|
|
104
107
|
inline?: boolean;
|
|
105
108
|
/** The dialog's close: Send and Copy close it at once and report the outcome as a toast. */
|
|
106
109
|
onClose?: () => void;
|
|
110
|
+
/**
|
|
111
|
+
* Catch up's move bar: told whenever this answer becomes sendable (or stops being), with this form's own Send, so a
|
|
112
|
+
* Send outside the card runs exactly this flow (`one-answer-flow-for-every-question`), never a copy of it.
|
|
113
|
+
*/
|
|
114
|
+
onSendReady?: (send: SendReady | null) => void;
|
|
107
115
|
}) {
|
|
108
116
|
const c = theme.colors; const t = text(c);
|
|
109
117
|
const toast = useToast(); const cache = useQueryClient();
|
|
@@ -189,6 +197,11 @@ export function QuestionBody({ workspace: w, question: q, theme, compact, now =
|
|
|
189
197
|
});
|
|
190
198
|
onClose?.(); onAnswered?.();
|
|
191
199
|
};
|
|
200
|
+
// The footer's Send calls the latest quick through a ref, so it never sends a stale choice or words.
|
|
201
|
+
const quickRef = useRef(quick); quickRef.current = quick;
|
|
202
|
+
const sendable = open && !!answer;
|
|
203
|
+
useEffect(() => { onSendReady?.(sendable ? { send: () => quickRef.current("send"), busy: run.isPending } : null); }, [sendable, run.isPending]);
|
|
204
|
+
useEffect(() => () => onSendReady?.(null), []);
|
|
192
205
|
// The body says Not sent · Retry itself, with the button; the state line stays on what the agent is doing.
|
|
193
206
|
const state = meanwhile(w, q, null);
|
|
194
207
|
const delivery = deliveryLine(w, q, now);
|
package/index.client.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { openExternalUrl, type PluginClientContext, type PluginButtonRegistratio
|
|
|
6
6
|
import { Dimensions } from "react-native";
|
|
7
7
|
import { FollowSettings } from "./client/settings";
|
|
8
8
|
import { FollowHome, HOME_SCREEN } from "./client/home";
|
|
9
|
+
import { MODE } from "./shared/catch-up";
|
|
9
10
|
import { FollowPanel } from "./client/panel";
|
|
10
11
|
import { createPaseoWorkspaces } from "./client/home-data";
|
|
11
12
|
import { createHomeExtras } from "./client/home-view";
|
|
@@ -54,6 +55,7 @@ export default function contribute(host: PluginClientContext) {
|
|
|
54
55
|
const openSettings = (category?: string) => { if (isCategory(category)) writeCategory(category); client.openSettings("projects"); };
|
|
55
56
|
const openOverview = () => client.openScreen({ screenId: OVERVIEW });
|
|
56
57
|
const openLog = () => client.openScreen({ screenId: OVERVIEW, params: { view: "log" } });
|
|
58
|
+
const openCatchUp = () => client.openScreen({ screenId: OVERVIEW, params: { view: "catchup", at: "0", n: String(Date.now()) } });
|
|
57
59
|
const openLarge = (workspaceId: string) => client.openScreen({ screenId: LARGE_SCREEN, params: { workspaceId } });
|
|
58
60
|
// "Set up Follow-up again" (Settings and ⌘K): restart the flow on the server, then open Home, which shows it.
|
|
59
61
|
// `resume`: setup is already in progress, so open it where it was left instead of from the top.
|
|
@@ -91,7 +93,7 @@ export default function contribute(host: PluginClientContext) {
|
|
|
91
93
|
noteDone: (agentId, cancel) => inbox.noteDone(agentId, cancel), endDone: agentId => inbox.endDone(agentId),
|
|
92
94
|
};
|
|
93
95
|
const openItem = (key: string, extra: { question?: string } = {}) => client.openScreen({ screenId: OVERVIEW, params: { item: key, ...(extra.question ? { question: extra.question } : {}) } });
|
|
94
|
-
const homeDeps = { sources, openSettings, openPanel, openLog, openHome: openOverview, openItem, briefDeps, searchKey };
|
|
96
|
+
const homeDeps = { sources, openSettings, openPanel, openLog, openCatchUp, openHome: openOverview, openItem, briefDeps, searchKey };
|
|
95
97
|
const Overview = (props: PluginScreenProps) => <><FollowHome {...props} deps={homeDeps} />{reportHost(props)}</>;
|
|
96
98
|
const Panel = (props: PluginWorkspacePanelProps) => <><FollowPanel {...props} openSettings={openSettings} openOverview={openOverview} openLarge={openLarge} inbox={inbox} live={store} briefDeps={briefDeps} sources={sources} />{reportHost(props)}</>;
|
|
97
99
|
const Large = (props: PluginScreenProps) => <FollowLarge {...props} openSettings={openSettings} openOverview={openOverview} live={store} />;
|
|
@@ -112,6 +114,7 @@ export default function contribute(host: PluginClientContext) {
|
|
|
112
114
|
// The dialog lives in Follow-up's surfaces: open the panel, which mounts a host, then ask.
|
|
113
115
|
openPanel(PANEL, { location: location() }); setTimeout(() => openRename({ workspaceId: workspace.id }), 0); } }),
|
|
114
116
|
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 }); } }),
|
|
117
|
+
client.addCommandCenterItem({ id: "follow-up-catch-up", title: MODE.command, icon: "Layers", keywords: ["catch up", "inbox", "needs you", "triage", "answer", "questions", "one by one"], context: "global", onSelect() { openCatchUp(); } }),
|
|
115
118
|
client.addCommandCenterItem({ id: "follow-up-log", title: "Follow-up: Done while you were away", icon: "History", keywords: ["log", "overnight", "away", "repairs", "activity"], context: "global", onSelect({ openScreen }) { openScreen({ screenId: OVERVIEW, params: { view: "log" } }); } }),
|
|
116
119
|
client.addCommandCenterItem({ id: "follow-up-settings", title: "Follow-up: settings", icon: "Settings", keywords: ["default", "following", "project", "display", "sidebar", "pill", "header", "inbox", "questions"], context: "global", onSelect() { openSettings(); } }),
|
|
117
120
|
// "Set up Follow-up again": the setup flow from the top, on Home.
|
package/index.server.ts
CHANGED
|
@@ -14,8 +14,8 @@ import { agentSetSpec, developerSetSpec } from "./server/spec";
|
|
|
14
14
|
import type { PluginServerContext, PluginHandlerContext, PluginHookContext, PluginSessionOpenRequest } from "@getpaseo/plugin/server";
|
|
15
15
|
import type { PluginRpcContract, PluginSubscriptionContract } from "@getpaseo/plugin";
|
|
16
16
|
import { ValueFeed, WorkspacesFeed } from "./server/feeds";
|
|
17
|
-
import { ContextRequests } from "./server/context-requests";
|
|
18
|
-
import { agentContextPrompt, deckCards
|
|
17
|
+
import { ContextRequests, contextRecipient } from "./server/context-requests";
|
|
18
|
+
import { agentContextPrompt, deckCards } from "./shared/catch-up";
|
|
19
19
|
import { buildHome } from "./shared/home";
|
|
20
20
|
import { needsYou } from "./shared/attention";
|
|
21
21
|
import type { SortMode } from "./shared/sort";
|
|
@@ -331,6 +331,12 @@ export default function contribute(server: PluginServerContext) {
|
|
|
331
331
|
// No card of its own: one that didn't go out (Failed, or Queued past MESSAGE_STUCK_MS) shows in its workspace's
|
|
332
332
|
// Needs you with Retry and Cancel, and leaves it once sent or cancelled.
|
|
333
333
|
async project(item) {
|
|
334
|
+
// A More context ask rides the queue under its request id: the send's settle is its delivery, a send that can't
|
|
335
|
+
// happen fails it (context-never-blocks-the-deck: the card comes back either way).
|
|
336
|
+
if (item.messageId?.startsWith("ctx-")) {
|
|
337
|
+
if (item.state === "sent") await contextRequests.delivered(item.messageId, item.settledAt ?? new Date().toISOString());
|
|
338
|
+
else if (item.state === "cancelled" || item.state === "failed" && item.gone) await contextRequests.fail(item.messageId, item.reason ?? "The ask couldn't reach the agent.");
|
|
339
|
+
}
|
|
334
340
|
const w = (await store.snapshot()).workspaces.find(w => w.id === item.key && w.enable_tracking && !w.archived);
|
|
335
341
|
if (!w) return;
|
|
336
342
|
const has = w.undelivered?.find(m => m.id === item.id);
|
|
@@ -478,6 +484,17 @@ export default function contribute(server: PluginServerContext) {
|
|
|
478
484
|
await engine.adoptBatches().catch(error => console.warn(`[follow-up] couldn't move batches onto the queue: ${error instanceof Error ? error.message : String(error)}`));
|
|
479
485
|
await inbox.adoptOutbox().catch(error => console.warn(`[follow-up] couldn't move the answer outbox onto the queue: ${error instanceof Error ? error.message : String(error)}`));
|
|
480
486
|
queue.start();
|
|
487
|
+
// An ask still open from before a restart is re-derived from the queue's record and the cached agent list: nothing
|
|
488
|
+
// is woken, and nothing waits on it (context-never-blocks-the-deck).
|
|
489
|
+
void (async () => {
|
|
490
|
+
const rows = await gateway.directory.read().catch(() => null);
|
|
491
|
+
const status = new Map((rows?.agents ?? []).map(({ agent }) => [agent.id, agent.status]));
|
|
492
|
+
await contextRequests.reconcile(r => {
|
|
493
|
+
const item = queue.get(`message:${r.askedOf}:${r.id}`);
|
|
494
|
+
return { sent: item?.state === "sent" ? item.settledAt ?? null : null, failed: item?.state === "cancelled" || item?.state === "failed" && item.gone ? item.reason ?? "The ask couldn't reach the agent." : null,
|
|
495
|
+
idle: rows ? status.get(r.askedOf!) !== "running" : false };
|
|
496
|
+
});
|
|
497
|
+
})().catch(error => console.warn(`[follow-up] couldn't re-check open context asks: ${error instanceof Error ? error.message : String(error)}`));
|
|
481
498
|
})().catch(() => { loadError = "Follow-up could not start. Check its saved state and worker lock."; });
|
|
482
499
|
for (const file of [store, contextRequests.persist, reviewerStore.persist, agentSettings.persist, prWorkflow.persist, inbox.store.persist]) file.health = writeHealth;
|
|
483
500
|
const requireReady = async () => { if (waiting) throw new Error(waiting); await ready; if (loadError || stopped) throw new Error(loadError ?? "Follow-up is stopping"); };
|
|
@@ -936,30 +953,19 @@ export default function contribute(server: PluginServerContext) {
|
|
|
936
953
|
handle(rpc.overseerStatusRpc, async () => { await requireReady(); return overseerStatus(); });
|
|
937
954
|
handle(rpc.overseerStartRpc, async (_input, { paseo }) => { await requireReady(); seen(paseo); await overseer!.start(paseo as unknown as OverseerPaseo); return overseerStatus(); });
|
|
938
955
|
handle(rpc.overseerAskRpc, async ({ text }, { paseo }) => { await requireReady(); seen(paseo); await overseer!.ask(paseo as unknown as OverseerPaseo, text); return overseerStatus(); });
|
|
939
|
-
// Catch up's More context: the ask is recorded and answered at once
|
|
940
|
-
//
|
|
941
|
-
// it: the developer asked, the one exception to never-wake (invariant 1).
|
|
956
|
+
// Catch up's More context: the ask is recorded and answered at once, and goes through the message queue (invariant
|
|
957
|
+
// 36) to the card's workspace's main agent, the only role with context_reply (an-ask-goes-only-to-an-agent-that-can-
|
|
958
|
+
// answer-it). Asking may wake it: the developer asked, the one exception to never-wake (invariant 1).
|
|
942
959
|
handle(rpc.contextAskRpc, async (input, context) => {
|
|
943
960
|
await requireReady();
|
|
944
961
|
const actor = actorOf(context);
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
const
|
|
948
|
-
if (
|
|
949
|
-
const
|
|
950
|
-
if (
|
|
951
|
-
|
|
952
|
-
const paseo = (context as { paseo?: unknown }).paseo;
|
|
953
|
-
const workspace = input.workspaceId ? (await gateway.directory.read().catch(() => null))?.workspaces.find(w => w.id === input.workspaceId)?.name ?? "a workspace" : "a workspace";
|
|
954
|
-
void (async () => {
|
|
955
|
-
try {
|
|
956
|
-
if (!await overseerOn()) throw new Error("The Overseer is off. Turn it on in Settings → Agents, or ask the agent.");
|
|
957
|
-
const s = await overseer!.ask(paseo as unknown as OverseerPaseo, overseerContextPrompt(r, workspace));
|
|
958
|
-
if (s.agentId) await contextRequests.setAskedOf(r.id, s.agentId);
|
|
959
|
-
} catch (error) { await contextRequests.fail(r.id, error instanceof Error ? error.message : String(error)); }
|
|
960
|
-
})();
|
|
961
|
-
}
|
|
962
|
-
return out;
|
|
962
|
+
// The worker's own snapshot, never a daemon read (an-ack-never-waits).
|
|
963
|
+
const w = input.workspaceId ? (await store.snapshot()).workspaces.find(x => x.id === input.workspaceId) : undefined;
|
|
964
|
+
const to = contextRecipient(w, actor.kind === "agent" ? actor.agentId : null);
|
|
965
|
+
if ("error" in to) throw new Error(to.error);
|
|
966
|
+
const out = await contextRequests.ask({ ...input, target: "agent" }, actorBy(actor), to.agentId);
|
|
967
|
+
if (out.fresh) enqueueMessage(to.agentId, agentContextPrompt(out.request), out.request.id, actorBy(actor));
|
|
968
|
+
return input.target === "overseer" ? { ...out, note: "More context always asks the card's own main agent, which can answer on the card; the Overseer can't, so target is ignored." } : out;
|
|
963
969
|
});
|
|
964
970
|
// Built when read (a-derived-view-is-built-when-read), from state the worker holds: no daemon request but the
|
|
965
971
|
// directory's cached workspace list.
|
|
@@ -979,9 +985,6 @@ export default function contribute(server: PluginServerContext) {
|
|
|
979
985
|
handle(rpc.contextListRpc, async ({ workspaceId }) => ({ requests: await contextRequests.list(workspaceId ? { workspaceId } : {}) }));
|
|
980
986
|
handle(rpc.contextReplyRpc, async ({ agentId, requestId, text }) => {
|
|
981
987
|
await requireReady();
|
|
982
|
-
const r = (await contextRequests.list()).find(x => x.id === requestId);
|
|
983
|
-
// The Overseer may have been (re)started by the ask itself, so its id is checked now, not when it was asked.
|
|
984
|
-
if (r?.target === "overseer" && r.askedOf !== agentId && (await overseerStatus().catch(() => null))?.agentId === agentId) await contextRequests.setAskedOf(r.id, agentId);
|
|
985
988
|
await contextRequests.reply(requestId, agentId, text);
|
|
986
989
|
return { ok: true };
|
|
987
990
|
});
|
|
@@ -1505,7 +1508,6 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1505
1508
|
// handlers below read the patched rows.
|
|
1506
1509
|
server.on("agent.turn_started", async event => gateway.directory.turnStarted(event.agent, event.turnId)),
|
|
1507
1510
|
server.on("agent.turn_ended", async event => gateway.directory.turnEnded(event.agent, event.outcome)),
|
|
1508
|
-
server.on("agent.turn_started", async event => contextRequests.turnStarted(event.agent.id)),
|
|
1509
1511
|
server.on("agent.turn_ended", async event => contextRequests.turnEnded(event.agent.id)),
|
|
1510
1512
|
server.on("agent.permission_requested", async event => gateway.directory.permissionRequested(event.agent.id, event.request as { id?: string })),
|
|
1511
1513
|
server.on("agent.permission_resolved", async event => gateway.directory.permissionResolved(event.agent.id, event.requestId)),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.2.0-beta.
|
|
4
|
+
"version": "2.2.0-beta.4",
|
|
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
|
@@ -22,7 +22,7 @@ import { DISPLAY_TOOLS, RPC_TOOLS, type RpcTool } from "./agent-parity";
|
|
|
22
22
|
import { waitNote, type WaitStatus } from "../shared/wait";
|
|
23
23
|
import { reportInputSchema } from "./report-issue";
|
|
24
24
|
import type { RenameStatus } from "../shared/rename";
|
|
25
|
-
import { DISPLAY_KEYS, displayPreferences, HOME_DETAIL_DEFAULT } from "../shared/display";
|
|
25
|
+
import { DISPLAY_KEYS, displayPreferences, HOME_DETAIL_DEFAULT, CATCH_UP_RAIL_DEFAULT } from "../shared/display";
|
|
26
26
|
import { DEFAULT_SEARCH_SHORTCUT, SEARCH_SHORTCUTS } from "../shared/search-key";
|
|
27
27
|
import { DEFAULT_SORT, SORT_MODES } from "../shared/sort";
|
|
28
28
|
|
|
@@ -326,14 +326,14 @@ export class AgentActions {
|
|
|
326
326
|
private async displayTool(caller: string, tool: "display_settings" | "set_display", args: Record<string, any>) {
|
|
327
327
|
if (!this.d.display) throw new Error(`${tool} isn't available in this Follow-up.`);
|
|
328
328
|
const current = await this.d.display.read();
|
|
329
|
-
if (tool === "display_settings") return { values: { home_sort: DEFAULT_SORT, home_detail_fraction: HOME_DETAIL_DEFAULT, search_shortcut: DEFAULT_SEARCH_SHORTCUT, ...current.values }, sorts: SORT_MODES, search_shortcuts: SEARCH_SHORTCUTS, change: "set_display changes these, only when the developer asked. home_sort orders Home and the sidebar view. home_detail_fraction is the share of Home's width its right pane takes (0.2 to 0.8, default 0.42). search_shortcut is the key that opens Home's search from anywhere: mod-slash (⌘/ or Ctrl+/, the default), mod-shift-k, mod-shift-h or none." };
|
|
329
|
+
if (tool === "display_settings") return { values: { home_sort: DEFAULT_SORT, home_detail_fraction: HOME_DETAIL_DEFAULT, catch_up_rail_fraction: CATCH_UP_RAIL_DEFAULT, search_shortcut: DEFAULT_SEARCH_SHORTCUT, ...current.values }, sorts: SORT_MODES, search_shortcuts: SEARCH_SHORTCUTS, change: "set_display changes these, only when the developer asked. home_sort orders Home and the sidebar view. home_detail_fraction is the share of Home's width its right pane takes (0.2 to 0.8, default 0.42). catch_up_rail_fraction is the share of the Catch up screen its queue rail takes on a desktop (0.16 to 0.5, default 0.28). search_shortcut is the key that opens Home's search from anywhere: mod-slash (⌘/ or Ctrl+/, the default), mod-shift-k, mod-shift-h or none." };
|
|
330
330
|
const values = args.values as Record<string, boolean | string | number> | undefined;
|
|
331
331
|
if (!values || !Object.keys(values).length) throw new Error("set_display: give values, e.g. { enable_trust_bypass: false } or { home_sort: \"recent\" }. display_settings lists them.");
|
|
332
332
|
const unknown = Object.keys(values).filter(k => !DISPLAY_KEYS.includes(k));
|
|
333
333
|
if (unknown.length) throw new Error(`set_display: unknown setting ${unknown.join(", ")}. display_settings lists them.`);
|
|
334
334
|
const parsed = displayPreferences.schema.safeParse({ ...current.values, ...values });
|
|
335
335
|
if (!parsed.success) throw new Error(`set_display: ${parsed.error.issues.map(i => `${i.path.join(".")}: ${i.message}`).join("; ")}`);
|
|
336
|
-
const was = (k: string) => current.values[k] ?? (k === "home_sort" ? DEFAULT_SORT : k === "home_detail_fraction" ? HOME_DETAIL_DEFAULT : k === "search_shortcut" ? DEFAULT_SEARCH_SHORTCUT : undefined);
|
|
336
|
+
const was = (k: string) => current.values[k] ?? (k === "home_sort" ? DEFAULT_SORT : k === "home_detail_fraction" ? HOME_DETAIL_DEFAULT : k === "catch_up_rail_fraction" ? CATCH_UP_RAIL_DEFAULT : k === "search_shortcut" ? DEFAULT_SEARCH_SHORTCUT : undefined);
|
|
337
337
|
const changes = Object.entries(values).filter(([k, v]) => was(k) !== v).map(([key, to]) => ({ key, from: was(key), to }));
|
|
338
338
|
const planId = changes.length ? this.plan(caller, "set_display", async () => {
|
|
339
339
|
const now = await this.d.display!.read();
|
package/server/agent-parity.ts
CHANGED
|
@@ -75,8 +75,9 @@ export const RPC_TOOLS: readonly RpcTool[] = [
|
|
|
75
75
|
{ name: "ask_context", rpc: "follow.context-ask", kind: "planned", before: { rpc: "follow.context-list", input: a => ({ workspaceId: a.workspaceId ?? undefined }) },
|
|
76
76
|
input: z.strictObject({ workspaceId: id.nullable().optional(), agentId: id.nullable().optional(), cardKey: z.string().min(1).max(400).optional(), card: z.string().trim().min(1).max(300).optional(),
|
|
77
77
|
target: z.enum(["overseer", "agent"]).optional(), ask: z.string().trim().min(1).max(2000).optional(), ...confirm }),
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
// target is accepted and ignored: the server sends every ask to the card's workspace main agent, and refuses an
|
|
79
|
+
// agent asking itself (an-ask-goes-only-to-an-agent-that-can-answer-it).
|
|
80
|
+
toRpc: a => ({ workspaceId: a.workspaceId ?? null, agentId: a.agentId ?? null, cardKey: a.cardKey, card: a.card, target: a.target, ask: a.ask }) },
|
|
80
81
|
// Needs-you: the brief card and the inbox's other actions
|
|
81
82
|
// The message queue: what waits to go to agents, and Retry or Cancel on one item (a card's Retry, Needs you's message row).
|
|
82
83
|
{ name: "queue_list", rpc: "follow.queue-list", kind: "read", input: z.strictObject({ workspaceId: id.optional(), agentId: id.optional() }) },
|
|
@@ -179,6 +180,8 @@ export const PARITY: Record<string, { tools: readonly string[]; note?: string }
|
|
|
179
180
|
"follow.overseer-restart": { tools: ["overseer_restart"] },
|
|
180
181
|
"follow.overseer-ask": { tools: ["overseer_ask"] },
|
|
181
182
|
"follow.inbox-list": { tools: ["inbox_list"] },
|
|
183
|
+
"follow.context-ask": { tools: ["ask_context"] },
|
|
184
|
+
"follow.context-list": { tools: ["context_requests"] },
|
|
182
185
|
"follow.inbox-brief": { tools: ["inbox_brief"] },
|
|
183
186
|
"follow.queue-action": { tools: ["queue_action"] },
|
|
184
187
|
"follow.inbox-act": { tools: ["sign_off", "snooze", "set_finish_flags", "inbox_act"] },
|
|
@@ -214,6 +217,6 @@ export const PARITY: Record<string, { tools: readonly string[]; note?: string }
|
|
|
214
217
|
* note says where an agent finds what the developer found.
|
|
215
218
|
*/
|
|
216
219
|
export const VIEW_PARITY: Record<string, { tools: readonly string[]; note: string }> = {
|
|
217
|
-
"catch-up": { tools: ["catch_up_deck", "answer_question", "brief_action", "inbox_act", "snooze", "ask_context"], note: "Catch up deals Needs you one card at a time; moving between cards (Skip, Back) changes only the developer's view. catch_up_deck reads the same deck, and every act on a card is a tool: answer_question, brief_action, inbox_act and snooze (Later), ask_context (More context). A permission is Paseo's own respond_to_permission." },
|
|
220
|
+
"catch-up": { tools: ["catch_up_deck", "answer_question", "brief_action", "inbox_act", "snooze", "ask_context"], note: "Catch up deals Needs you one card at a time; moving between cards (Skip, Skip workspace, Back, the phone's drag) changes only the developer's view, so it has no server state and no tool. catch_up_deck reads the same deck, and every act on a card is a tool: answer_question, brief_action, inbox_act and snooze (Later), ask_context (More context). A permission is Paseo's own respond_to_permission." },
|
|
218
221
|
"section-search": { tools: ["workspace_status", "list_prs"], note: "The panel's Pull requests, Tasks and Activity search filters lists an agent already reads whole: workspace_status returns the workspace's PRs (title, branch, failed checks), tasks with their evidence, questions with their answers, and the sends, merges and PR actions the timeline is drawn from; list_prs returns every tracked PR with its checks." },
|
|
219
222
|
};
|
|
@@ -2,15 +2,28 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { WriteBehind } from "./write-behind";
|
|
5
|
-
import { CONTEXT_ANSWER_MAX, contextFileSchema, pruneContext, type ContextFile, type ContextRequest, type ContextTarget } from "../shared/catch-up";
|
|
5
|
+
import { CONTEXT_ANSWER_MAX, contextFileSchema, plainAnswer, pruneContext, type ContextFile, type ContextRequest, type ContextTarget } from "../shared/catch-up";
|
|
6
6
|
|
|
7
7
|
export const CONTEXT_FILE = "context.json";
|
|
8
8
|
|
|
9
9
|
export type AskInput = { workspaceId: string | null; agentId: string | null; cardKey: string; card: string; target: ContextTarget; ask: string };
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* an-ask-goes-only-to-an-agent-that-can-answer-it: who a More context ask goes to. Always the card's workspace's main
|
|
13
|
+
* agent (CONTEXT_REPLY_ROLE), the only role that has context_reply, whoever is named on the card: a contributor's
|
|
14
|
+
* question, or a recovery agent's, is still the workstream's, and its main agent answers. A workspace Follow-up doesn't
|
|
15
|
+
* track has no main agent, so nothing there could answer on the card, and the ask is refused with a way on. A main
|
|
16
|
+
* agent that was closed is still asked: the queue resumes it, or fails the ask if it is gone, and the card comes back.
|
|
17
|
+
*/
|
|
18
|
+
export function contextRecipient(workspace: { enable_tracking: boolean; mainAgentId: string } | undefined, caller: string | null): { agentId: string } | { error: string } {
|
|
19
|
+
if (!workspace?.enable_tracking || !workspace.mainAgentId) return { error: "Follow-up doesn't track this card's workspace, so no agent can answer on the card. Open its chat to ask there." };
|
|
20
|
+
if (caller && workspace.mainAgentId === caller) return { error: "ask_context asks another agent about its card for the developer; explain your own ask in your reply." };
|
|
21
|
+
return { agentId: workspace.mainAgentId };
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
/**
|
|
12
25
|
* Catch up's More context requests (docs/needs-you.md#catch-up): what the developer asked about a card, who answers
|
|
13
|
-
* (the
|
|
26
|
+
* (the card's workspace's main agent), and the answer once `context_reply` brings it. The value lives in memory and
|
|
14
27
|
* saves behind the reply (an-ack-never-waits-on-the-disk); a change calls `onChange`, which pushes Home's feed, so the
|
|
15
28
|
* client learns an answer arrived without polling. Small by construction: at most CONTEXT_MAX requests, none older
|
|
16
29
|
* than CONTEXT_KEEP_MS.
|
|
@@ -29,7 +42,13 @@ export class ContextRequests {
|
|
|
29
42
|
let value: ContextFile;
|
|
30
43
|
try { value = contextFileSchema.parse(JSON.parse(await readFile(join(this.directory, CONTEXT_FILE), "utf8"))); }
|
|
31
44
|
catch { value = { requests: [] }; } // Lost context requests cost a re-ask, never a broken Home.
|
|
32
|
-
this.value
|
|
45
|
+
if (this.value) return this.value;
|
|
46
|
+
// 2.2.0-beta.3 could ask the Overseer, which has no context_reply: an ask of it still open never ends on its own.
|
|
47
|
+
// Its answer, if any, is in the Overseer's chat (an-ask-goes-only-to-an-agent-that-can-answer-it).
|
|
48
|
+
const at = new Date(this.now()).toISOString();
|
|
49
|
+
const stuck = value.requests.some(r => r.target === "overseer" && r.state === "asking");
|
|
50
|
+
this.value = stuck ? { requests: value.requests.map(r => r.target === "overseer" && r.state === "asking" ? { ...r, state: "chat" as const, settledAt: at } : r) } : value;
|
|
51
|
+
if (stuck) this.persist.set(this.value);
|
|
33
52
|
return this.value;
|
|
34
53
|
}
|
|
35
54
|
private save(requests: ContextRequest[]): void {
|
|
@@ -51,7 +70,7 @@ export class ContextRequests {
|
|
|
51
70
|
if (open) return { request: open, fresh: false };
|
|
52
71
|
const request: ContextRequest = {
|
|
53
72
|
id: `ctx-${randomUUID()}`, ...input, askedOf, state: "asking", answer: null, error: null,
|
|
54
|
-
askedAt: new Date(this.now()).toISOString(), settledAt: null, by,
|
|
73
|
+
askedAt: new Date(this.now()).toISOString(), settledAt: null, deliveredAt: null, by,
|
|
55
74
|
};
|
|
56
75
|
this.save([...requests, request]);
|
|
57
76
|
return { request, fresh: true };
|
|
@@ -67,11 +86,6 @@ export class ContextRequests {
|
|
|
67
86
|
return next;
|
|
68
87
|
}
|
|
69
88
|
|
|
70
|
-
/** Who replies is learnt after the send (the Overseer's id). */
|
|
71
|
-
setAskedOf(id: string, askedOf: string): Promise<ContextRequest | null> {
|
|
72
|
-
return this.update(id, r => r.askedOf === askedOf ? r : { ...r, askedOf });
|
|
73
|
-
}
|
|
74
|
-
|
|
75
89
|
/**
|
|
76
90
|
* The asked agent's answer (context_reply). Only the agent it was asked of may answer it (ownership comes from the
|
|
77
91
|
* daemon, invariant 5); an answer to a settled request replaces it, so a corrected reply wins.
|
|
@@ -80,32 +94,45 @@ export class ContextRequests {
|
|
|
80
94
|
const r = (await this.list()).find(x => x.id === id);
|
|
81
95
|
if (!r) throw new Error(`No open context request ${id}. It may have expired; the developer can ask again.`);
|
|
82
96
|
if (r.askedOf !== caller) throw new Error("This context request was asked of another agent.");
|
|
83
|
-
const answer = text
|
|
97
|
+
const answer = plainAnswer(text).slice(0, CONTEXT_ANSWER_MAX);
|
|
84
98
|
if (!answer) throw new Error("context_reply: give text, the explanation for the developer.");
|
|
85
99
|
return (await this.update(id, x => ({ ...x, state: "answered", answer, error: null, settledAt: new Date(this.now()).toISOString() })))!;
|
|
86
100
|
}
|
|
87
101
|
|
|
88
|
-
/** The send failed for good (
|
|
102
|
+
/** The send failed for good (the agent is gone): the card comes back saying so. */
|
|
89
103
|
fail(id: string, error: string): Promise<ContextRequest | null> {
|
|
90
104
|
return this.update(id, r => r.state !== "asking" ? r : { ...r, state: "failed", error: error.slice(0, 500), settledAt: new Date(this.now()).toISOString() });
|
|
91
105
|
}
|
|
92
106
|
|
|
107
|
+
/** The ask reached its agent (the queue sent it). Earlier deliveries win: it is the first. */
|
|
108
|
+
delivered(id: string, at: string): Promise<ContextRequest | null> {
|
|
109
|
+
return this.update(id, r => r.state !== "asking" || r.deliveredAt ? r : { ...r, deliveredAt: at });
|
|
110
|
+
}
|
|
111
|
+
|
|
93
112
|
/**
|
|
94
|
-
* An
|
|
95
|
-
* its chat
|
|
113
|
+
* An agent's turn ended. Every ask it owes that was delivered before now and still has no context_reply settles as
|
|
114
|
+
* `chat`: the answer is in its chat, and the card comes back with Open chat. Delivery, not the turn's start, is the
|
|
115
|
+
* test, so a prompt steered into a turn already running counts, and nothing in memory is lost on a restart. Costs a
|
|
116
|
+
* lookup in a list of at most CONTEXT_MAX; no reads.
|
|
96
117
|
*/
|
|
97
|
-
private started = new Map<string, number>();
|
|
98
|
-
/** An agent's turn started: remembered only while that agent owes a reply. */
|
|
99
|
-
turnStarted(agentId: string): void {
|
|
100
|
-
if (this.value?.requests.some(r => r.state === "asking" && r.askedOf === agentId)) this.started.set(agentId, this.now());
|
|
101
|
-
}
|
|
102
118
|
async turnEnded(agentId: string): Promise<void> {
|
|
103
|
-
const
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
const owed = (await this.list()).filter(r => r.state === "asking" && r.askedOf === agentId && r.deliveredAt && Date.parse(r.deliveredAt) <= this.now());
|
|
120
|
+
for (const r of owed) await this.update(r.id, x => x.state !== "asking" ? x : { ...x, state: "chat", settledAt: new Date(this.now()).toISOString() });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* After a restart: anything still asking is re-derived from what the worker can read without waking anyone. `sent`
|
|
125
|
+
* says when the queue delivered it (null: not yet, or not a queued ask); `idle` says the agent isn't in a turn now.
|
|
126
|
+
* Delivered to an agent that is idle means its turn ended while the worker was down, so it settles as `chat`; a send
|
|
127
|
+
* that failed for good fails the ask.
|
|
128
|
+
*/
|
|
129
|
+
async reconcile(look: (r: ContextRequest) => { sent: string | null; failed: string | null; idle: boolean }): Promise<void> {
|
|
130
|
+
for (const r of (await this.list()).filter(x => x.state === "asking" && x.askedOf)) {
|
|
131
|
+
const seen = look(r);
|
|
132
|
+
if (seen.failed) { await this.fail(r.id, seen.failed); continue; }
|
|
133
|
+
const at = r.deliveredAt ?? seen.sent;
|
|
134
|
+
if (at && !r.deliveredAt) await this.delivered(r.id, at);
|
|
135
|
+
if (at && seen.idle) await this.turnEnded(r.askedOf!);
|
|
109
136
|
}
|
|
110
137
|
}
|
|
111
138
|
}
|