paseo-follow-up 2.1.0 → 2.2.0-beta.2
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/CHANGELOG.md +1 -1
- package/README.md +6 -2
- package/client/brief.tsx +8 -6
- package/client/dock.ts +70 -0
- package/client/docked-pane.tsx +108 -0
- package/client/home.tsx +27 -29
- package/client/onboarding.tsx +17 -40
- package/client/questions.tsx +35 -18
- package/client/release-notes.tsx +3 -2
- package/client/updates.tsx +7 -5
- package/index.server.ts +65 -7
- package/package.json +1 -1
- package/server/agent-actions.ts +1 -1
- package/server/agent-hook.mjs +1 -1
- package/server/agent-parity.ts +10 -1
- package/server/context-requests.ts +111 -0
- package/server/daemon.ts +20 -13
- package/server/delivery.ts +8 -0
- package/server/hook-source.ts +1 -1
- package/server/mcp-source.ts +9 -5
- package/server/mcp.mjs +9 -5
- package/server/message-queue.ts +34 -12
- package/server/transcript.ts +56 -0
- package/server/updater.ts +7 -6
- package/server/updates.ts +4 -2
- package/shared/attention.ts +3 -2
- package/shared/catch-up.ts +249 -0
- package/shared/changelog.ts +28 -22
- package/shared/chat.ts +1 -1
- package/shared/contracts.ts +15 -0
- package/shared/questions.ts +54 -0
- package/shared/queue.ts +28 -3
- package/shared/status-invariants.ts +14 -0
- package/shared/updates.ts +11 -3
package/client/questions.tsx
CHANGED
|
@@ -10,13 +10,15 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
10
10
|
import { answerQuestionRpc } from "../shared/contracts";
|
|
11
11
|
import type { Workspace } from "../shared/model";
|
|
12
12
|
import type { ListQuestion, ListWorkspace } from "../shared/list";
|
|
13
|
-
import { OTHER, OTHER_LABEL, answerHeading, answerLabel, answerStatus, answerMessage, answerHasActions, resendTitle, isOpen, isOther, questionState, type Question } from "../shared/questions";
|
|
13
|
+
import { OTHER, OTHER_LABEL, answerDraft, answerHeading, answerLabel, answerStatus, answerMessage, answerHasActions, resendTitle, isOpen, isOther, questionState, type Question } from "../shared/questions";
|
|
14
14
|
import { ago } from "../shared/attention";
|
|
15
15
|
import { RETRYING_DETAIL, deliveryStatus } from "../shared/queue";
|
|
16
16
|
import { mootNote, sentence } from "../shared/errors";
|
|
17
17
|
import { activity, type ActivityTone } from "../shared/activity";
|
|
18
18
|
import { Button, Card, CardRow, Chip, FoldRow, IconButton, SubmitScope, errorText, text, type Theme } from "./kit";
|
|
19
19
|
import { Spinner } from "./motion";
|
|
20
|
+
import { NoteLink } from "./brief";
|
|
21
|
+
import { PRIMARY_FORM } from "./dock";
|
|
20
22
|
import { mergedColor, tint, withAlpha, type Colors } from "./theme";
|
|
21
23
|
import { overviewKey, workspaceKey } from "./keys";
|
|
22
24
|
import { PrLinksProvider, RichText } from "./rich-text";
|
|
@@ -92,7 +94,9 @@ const inputStyle = (c: Colors, compact: boolean, lines: number) => ({ minHeight:
|
|
|
92
94
|
|
|
93
95
|
/**
|
|
94
96
|
* One question with its answer form. Send records the answer and messages the asking agent straight
|
|
95
|
-
* away; Copy records it and puts a reply on the clipboard instead.
|
|
97
|
+
* away; Copy records it and puts a reply on the clipboard instead. The one answer flow every question surface draws
|
|
98
|
+
* (the dialog, Needs you on Home and in the panel, the pill, phones): what its field means comes from answerDraft
|
|
99
|
+
* (`one-answer-flow-for-every-question`), never from the surface.
|
|
96
100
|
*/
|
|
97
101
|
export function QuestionBody({ workspace: w, question: q, theme, compact, now = Date.now(), dense = false, bodyMaxHeight, openAgent, onAnswered, onDetails, onClose, inline = false }: {
|
|
98
102
|
workspace: ListWorkspace; question: ListQuestion; theme: Theme; compact: boolean; now?: number; dense?: boolean; bodyMaxHeight?: number; openAgent?: (agentId: string) => void; onAnswered?: () => void; onDetails?: () => void;
|
|
@@ -122,10 +126,12 @@ export function QuestionBody({ workspace: w, question: q, theme, compact, now =
|
|
|
122
126
|
useEffect(() => { setChoice(unsent?.choice ?? q.answer?.choice ?? null); setWords(unsent?.words ?? q.answer?.words ?? ""); }, [q.id, !!unsent]);
|
|
123
127
|
const refresh = () => { void cache.invalidateQueries({ queryKey: workspaceKey(w.id) }); void cache.invalidateQueries({ queryKey: overviewKey }); };
|
|
124
128
|
const free = !q.options.length;
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
+
// The field is shown only once its role is known: Something else (the answer, so Send waits for words) or Add note
|
|
130
|
+
// on a lettered pick. One rule for every surface (shared/questions.ts answerDraft).
|
|
131
|
+
const draft = answerDraft(q, { choice, words, noteOpen });
|
|
132
|
+
const other = draft.own;
|
|
133
|
+
const answer = draft.answer;
|
|
134
|
+
const note = draft.note;
|
|
129
135
|
const run = useMutation({
|
|
130
136
|
mutationFn: async (action: "send" | "copy" | "resend") => {
|
|
131
137
|
if (action === "copy") await copyText(answerMessage(q, q.answer?.choice ?? answer!, q.answer?.words ?? note));
|
|
@@ -162,7 +168,7 @@ export function QuestionBody({ workspace: w, question: q, theme, compact, now =
|
|
|
162
168
|
if (!answer) return;
|
|
163
169
|
const input = { workspaceId: w.id, questionId: q.id, choice: answer, words: note, action };
|
|
164
170
|
if (action === "copy") void copyText(answerMessage(q, answer, note)).catch(() => undefined);
|
|
165
|
-
setPendingAnswer(w.id, q.id, { choice: answer, words:
|
|
171
|
+
setPendingAnswer(w.id, q.id, { choice: answer, words: other ? words.trim() : note });
|
|
166
172
|
const agent = who(w, q.askedBy);
|
|
167
173
|
void runAction({
|
|
168
174
|
label: `Answer to ${q.id}`, toast, run: () => answerRpc(input),
|
|
@@ -213,10 +219,12 @@ export function QuestionBody({ workspace: w, question: q, theme, compact, now =
|
|
|
213
219
|
const submittable = !run.isPending && (open ? !!answer : q.answer?.delivery.state === "copied" || q.answer?.delivery.state === "in-chat");
|
|
214
220
|
// In the pill popover the answer field and actions stay pinned below a scrolling body.
|
|
215
221
|
const pinned = dense && !!bodyMaxHeight;
|
|
216
|
-
|
|
222
|
+
// Re-keyed by role, so the field that opens on Something else or Add note takes the caret; typing never re-keys it.
|
|
223
|
+
const input = draft.field && <View style={{ gap: 6 }}>
|
|
217
224
|
{free && !dense && <Text style={t.meta}>No options were given. Write the decision for the agent.</Text>}
|
|
218
|
-
|
|
219
|
-
|
|
225
|
+
{!!draft.heading && <Text style={[t.small, { fontWeight: "600" }]}>{draft.heading}</Text>}
|
|
226
|
+
<TextInput key={draft.field} accessibilityLabel={draft.label} placeholder={draft.placeholder} placeholderTextColor={c.foregroundMuted}
|
|
227
|
+
multiline value={words} editable={!run.isPending} onChangeText={setWords} maxLength={2000} autoFocus={!free && (other || noteOpen)} style={[inputStyle(c, compact, draft.field === "answer" && !dense ? 3 : 2)]} />
|
|
220
228
|
</View>;
|
|
221
229
|
// Context comes before the options so the developer reads why before choosing.
|
|
222
230
|
const body = <View style={{ gap: dense ? 10 : 14 }}>
|
|
@@ -240,7 +248,7 @@ export function QuestionBody({ workspace: w, question: q, theme, compact, now =
|
|
|
240
248
|
selected={(open ? choice : q.answer?.choice) === o.letter} disabled={!open || run.isPending} onPress={() => setChoice(o.letter)} />)}
|
|
241
249
|
{/* Built in on every question with options, after the agent's own: the developer's own answer. */}
|
|
242
250
|
{(open || isOther(q.answer?.choice)) && <OptionCard theme={theme} compact={compact} dense={dense} own label={OTHER_LABEL} consequence={open && !dense ? "Write your own answer" : undefined} recommended={false}
|
|
243
|
-
selected={
|
|
251
|
+
selected={open ? other : isOther(q.answer?.choice)} disabled={!open || run.isPending} onPress={() => setChoice(OTHER)} />}
|
|
244
252
|
</View>}
|
|
245
253
|
{/* Not sent yet (copied, or in the agent's message box) never reads as answered: no check, no green. Only a
|
|
246
254
|
delivered answer is green; queued, retrying or failed keeps the check but stays neutral (answerHeading). */}
|
|
@@ -262,7 +270,10 @@ export function QuestionBody({ workspace: w, question: q, theme, compact, now =
|
|
|
262
270
|
<Text style={[t.meta, { color: c.foreground, fontWeight: "600", textDecorationLine: "underline" }]}>Retry</Text>
|
|
263
271
|
</Pressable>
|
|
264
272
|
</View>}
|
|
265
|
-
{
|
|
273
|
+
{/* A note on a lettered pick: the brief card's quiet links, under the options, in every mode. */}
|
|
274
|
+
{open && (draft.canAddNote || draft.canRemoveNote) && <NoteLink icon={draft.canAddNote ? "MessageSquarePlus" : "X"} label={draft.canAddNote ? "Add note" : "Remove note"}
|
|
275
|
+
a11y={draft.canAddNote ? `Add a note for the agent about ${q.id}` : `Remove the note on ${q.id}`} disabled={run.isPending} c={c} compact={compact}
|
|
276
|
+
onPress={() => { if (draft.canAddNote) setNoteOpen(true); else { setWords(""); setNoteOpen(false); } }} />}
|
|
266
277
|
</View>;
|
|
267
278
|
const actions = (open || q.answer && answerHasActions(q.answer.delivery)) && <View style={{ gap: 6 }}>
|
|
268
279
|
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8 }}>
|
|
@@ -276,18 +287,17 @@ export function QuestionBody({ workspace: w, question: q, theme, compact, now =
|
|
|
276
287
|
{q.answer && (q.answer.delivery.state === "failed" || q.answer.delivery.state === "cancelled") && <Button theme={theme} compact={compact} kind="ghost" icon="Copy" title="Copy" accessibilityLabel={`Copy the ${q.id} answer`} onPress={() => { void copyText(answerMessage(q, q.answer!.choice, q.answer!.words)).then(() => toast.show("Copied", { variant: "success" }), () => toast.error("Couldn't copy here")); }} />}
|
|
277
288
|
{q.answer?.delivery.state === "in-chat" && composer && <Button theme={theme} compact={compact} kind="ghost" icon="MessageSquareText" title="Open chat" accessibilityLabel={`Open the chat your ${q.id} answer is in`} onPress={() => { onClose?.(); void composer.focus().catch(() => undefined); }} />}
|
|
278
289
|
{(q.answer?.delivery.state === "failed" || q.answer?.delivery.state === "unconfirmed") && openAgent && <Button theme={theme} compact={compact} kind="ghost" icon="MessageSquare" title="Open agent" onPress={() => openAgent(q.askedBy ?? w.mainAgentId)} />}
|
|
279
|
-
{pinned && open && !free && !other && !noteOpen && <Button theme={theme} compact={compact} kind="ghost" icon="Pencil" title="Note" accessibilityLabel={`Add a note for the agent about ${q.id}`} onPress={() => setNoteOpen(true)} />}
|
|
280
290
|
{dense && onDetails && <IconButton theme={theme} compact={compact} icon="Maximize2" label={`Open ${q.id} with its links and full context`} onPress={onDetails} />}
|
|
281
291
|
</View>
|
|
282
292
|
{/* Same words as the brief card's, so a disabled Send always says why. */}
|
|
283
|
-
{open &&
|
|
293
|
+
{open && draft.hint ? <Text style={t.small}>{draft.hint}</Text>
|
|
284
294
|
// Two ways to deliver (Paseo 0.16) need telling apart everywhere, the phone and the Needs you block included.
|
|
285
295
|
: open && !dense && composer ? <Text style={t.small}>Send delivers it now, even mid-turn. Put in chat adds it to your message box to edit first.</Text>
|
|
286
296
|
: open && !dense && !compact && !inline && <Text style={t.small}>Send puts your answer straight into the asking agent's chat, even mid-turn. Follow-up keeps it under {q.id}.</Text>}
|
|
287
297
|
</View>;
|
|
288
298
|
// In the pill popover the question scrolls and the answer field and actions stay put, so Send is never cut off.
|
|
289
299
|
if (pinned) {
|
|
290
|
-
const showInput = open &&
|
|
300
|
+
const showInput = open && !!draft.field;
|
|
291
301
|
return <SubmitScope enabled={submittable} onSubmit={() => open ? quick("send") : run.mutate("send")} style={{ gap: 10 }}>
|
|
292
302
|
<View>
|
|
293
303
|
<ScrollView style={{ maxHeight: bodyMaxHeight! - (showInput ? 62 : 0), flexGrow: 0 }} contentContainerStyle={{ paddingRight: 2 }} scrollEventThrottle={32}
|
|
@@ -299,13 +309,20 @@ export function QuestionBody({ workspace: w, question: q, theme, compact, now =
|
|
|
299
309
|
<Text style={t.small}>More below</Text>
|
|
300
310
|
</View>}
|
|
301
311
|
</View>
|
|
302
|
-
{
|
|
303
|
-
{
|
|
312
|
+
{/* The field with its Send: kept on screen together while typing (a-focused-field-and-its-send-stay-in-view). */}
|
|
313
|
+
<View {...PRIMARY_FORM} style={{ gap: 10 }}>
|
|
314
|
+
{showInput && input}
|
|
315
|
+
{actions}
|
|
316
|
+
</View>
|
|
304
317
|
</SubmitScope>;
|
|
305
318
|
}
|
|
306
319
|
return <SubmitScope enabled={submittable} onSubmit={() => open ? quick("send") : run.mutate("send")} style={{ gap: dense ? 10 : 14 }}>
|
|
307
320
|
{body}
|
|
308
|
-
{
|
|
321
|
+
{/* The field with its Send: kept on screen together while typing (a-focused-field-and-its-send-stay-in-view). */}
|
|
322
|
+
<View {...PRIMARY_FORM} style={{ gap: dense ? 10 : 14 }}>
|
|
323
|
+
{open && input}
|
|
324
|
+
{actions}
|
|
325
|
+
</View>
|
|
309
326
|
{!dense && !compact && !inline && <Text style={t.small}>Asked {ago(q.askedAt, now)} by {who(w, q.askedBy)}{q.taskId && !q.options.length ? " (blocked task)" : ""}</Text>}
|
|
310
327
|
</SubmitScope>;
|
|
311
328
|
}
|
package/client/release-notes.tsx
CHANGED
|
@@ -290,7 +290,8 @@ const subscribeClaim = (l: () => void) => { listeners.add(l); return () => { lis
|
|
|
290
290
|
|
|
291
291
|
/**
|
|
292
292
|
* Shows "What's new" once per device per version, on whichever Follow-up surface mounts first (Home, the workspace
|
|
293
|
-
* panel or the sidebar item)
|
|
293
|
+
* panel or the sidebar item), after an update with notes (shared/changelog.ts `whatsNew`). Never on a first install,
|
|
294
|
+
* after a beta, with Settings → General's switch off, or while setup is showing or still loading.
|
|
294
295
|
*/
|
|
295
296
|
export function WhatsNewGate({ surface, theme, compact }: { surface: string; theme: Theme; compact: boolean }) {
|
|
296
297
|
const query = useReleaseNotes();
|
|
@@ -304,7 +305,7 @@ export function WhatsNewGate({ surface, theme, compact }: { surface: string; the
|
|
|
304
305
|
const viewVersion = useViewVersion();
|
|
305
306
|
const decision = useMemo(() => {
|
|
306
307
|
const deviceSeen = view ? seenOnDevice(view) : undefined;
|
|
307
|
-
return view && deviceSeen !== undefined ? whatsNew({ installed: view.version, deviceSeen, previous: view.previous, onboarding, notes: view.notes }) : null;
|
|
308
|
+
return view && deviceSeen !== undefined ? whatsNew({ installed: view.version, deviceSeen, previous: view.previous, onboarding, enabled: view.enable_whats_new, notes: view.notes }) : null;
|
|
308
309
|
}, [view, onboarding, viewVersion]);
|
|
309
310
|
useEffect(() => {
|
|
310
311
|
if (!decision || !view) return;
|
package/client/updates.tsx
CHANGED
|
@@ -2,11 +2,11 @@ import { useState } from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { Pressable, Text } from "./text";
|
|
4
4
|
import { openExternalUrl, useRpc } from "@getpaseo/plugin/client";
|
|
5
|
-
import { Icon, SettingsAction, SettingsCard, SettingsSection, SettingsSelect, copyText, useToast } from "@getpaseo/plugin/client/ui";
|
|
5
|
+
import { Icon, SettingsAction, SettingsCard, SettingsSection, SettingsSelect, SettingsSwitch, copyText, useToast } from "@getpaseo/plugin/client/ui";
|
|
6
6
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
7
7
|
import { dismissUpdateNoticeRpc, installUpdateRpc, retryMoveRpc, setUpdatesRpc, updatesRpc } from "../shared/contracts";
|
|
8
8
|
import { moveLine } from "../shared/plugin-move";
|
|
9
|
-
import { MODE_HINT, MODE_LABEL, UPDATE_MODES, channelHint, checkedText, copyCommand, statusCopy, versionMark, type StatusAction, type UpdateMode, type UpdatesView } from "../shared/updates";
|
|
9
|
+
import { MODE_HINT, MODE_LABEL, UPDATE_MODES, WHATS_NEW_LABEL, channelHint, checkedText, copyCommand, statusCopy, versionMark, whatsNewHint, type StatusAction, type UpdateMode, type UpdatesChange, type UpdatesView } from "../shared/updates";
|
|
10
10
|
import { writeCategory } from "../shared/settings-nav";
|
|
11
11
|
import type { Channel } from "../shared/version";
|
|
12
12
|
import { Button, errorText, space, text, useNow, type Theme } from "./kit";
|
|
@@ -14,7 +14,7 @@ import { Spinner } from "./motion";
|
|
|
14
14
|
import { Disclosure } from "./settings-shell";
|
|
15
15
|
import { withAlpha } from "./theme";
|
|
16
16
|
import { OptionCard } from "./questions";
|
|
17
|
-
import { ReleaseNotesSheet, VersionNotes } from "./release-notes";
|
|
17
|
+
import { ReleaseNotesSheet, VersionNotes, releaseNotesKey } from "./release-notes";
|
|
18
18
|
|
|
19
19
|
export const updatesKey = ["follow-up", "updates"];
|
|
20
20
|
|
|
@@ -142,7 +142,8 @@ export function UpdatesSections({ theme, compact }: { theme: Theme; compact: boo
|
|
|
142
142
|
const write = useRpc(setUpdatesRpc); const cache = useQueryClient(); const toast = useToast();
|
|
143
143
|
// null: closed; false: What's new (since the last update); true: every version.
|
|
144
144
|
const [sheet, setSheet] = useState<boolean | null>(null);
|
|
145
|
-
|
|
145
|
+
// The What's new gate reads the switch from the release notes view, so a change refreshes that too.
|
|
146
|
+
const save = useMutation({ mutationFn: (input: UpdatesChange) => write(input), onSuccess: (v, input) => { cache.setQueryData(updatesKey, v); if (input.enable_whats_new != null) void cache.invalidateQueries({ queryKey: releaseNotesKey }); }, onError: e => toast.error(errorText(e)) });
|
|
146
147
|
const view = query.data;
|
|
147
148
|
if (query.isLoading) return <Spinner color={c.foregroundMuted} size={16} label="Loading updates" />;
|
|
148
149
|
if (!view) return <SettingsSection title="Updates"><Text accessibilityRole="alert" style={{ color: c.statusDanger }}>{query.error ? errorText(query.error) : "Couldn't load updates."}</Text></SettingsSection>;
|
|
@@ -160,6 +161,7 @@ export function UpdatesSections({ theme, compact }: { theme: Theme; compact: boo
|
|
|
160
161
|
options={[{ value: "stable", label: "Stable" }, { value: "beta", label: "Beta" }]}
|
|
161
162
|
onValueChange={channel => save.mutate({ channel }, { onSuccess: () => toast.show(channel === "stable" ? "Switched to Stable. Nothing changes until a newer stable is out." : "Switched to Beta. The next check looks for betas.") })} />
|
|
162
163
|
</>}
|
|
164
|
+
<SettingsSwitch label={WHATS_NEW_LABEL} hint={whatsNewHint(view.enable_whats_new)} value={view.enable_whats_new} disabled={save.isPending} onValueChange={enable_whats_new => save.mutate({ enable_whats_new })} />
|
|
163
165
|
<SettingsAction label="Release notes" hint={`Every version up to ${view.version}, newest first.`} actionLabel="See all" onPress={() => setSheet(true)} />
|
|
164
166
|
</SettingsCard>
|
|
165
167
|
</SettingsSection>
|
|
@@ -175,7 +177,7 @@ export function UpdatesSections({ theme, compact }: { theme: Theme; compact: boo
|
|
|
175
177
|
|
|
176
178
|
const SETUP_CARDS: { mode: UpdateMode; hint: string }[] = [
|
|
177
179
|
{ mode: "auto", hint: "Waits until your agents are idle. Rolls back if the new version fails." },
|
|
178
|
-
{ mode: "notify", hint: "Shows new versions on Home. You choose when to install." },
|
|
180
|
+
{ mode: "notify", hint: "Shows new stable versions on Home. You choose when to install." },
|
|
179
181
|
{ mode: "off", hint: "No checks. You can check from Settings → General." },
|
|
180
182
|
];
|
|
181
183
|
/**
|
package/index.server.ts
CHANGED
|
@@ -14,6 +14,11 @@ 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, overseerContextPrompt } from "./shared/catch-up";
|
|
19
|
+
import { buildHome } from "./shared/home";
|
|
20
|
+
import { needsYou } from "./shared/attention";
|
|
21
|
+
import type { SortMode } from "./shared/sort";
|
|
17
22
|
import type { ZodType, output as zOutput } from "zod";
|
|
18
23
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
19
24
|
import { isTimeZone } from "./shared/inbox";
|
|
@@ -207,6 +212,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
207
212
|
prWorkflow.onChanged = () => { void store.snapshot().then(state => store.onChanged(state)).catch(() => undefined); };
|
|
208
213
|
const browser = new BrowserBridge();
|
|
209
214
|
const reviewerStore = new ReviewerConfigStore(directory);
|
|
215
|
+
const contextRequests = new ContextRequests(directory);
|
|
216
|
+
contextRequests.onChange = () => feeds.home();
|
|
210
217
|
// an-ack-never-waits-on-the-disk (server/write-behind.ts): these files save behind the reply; one still failing after
|
|
211
218
|
// SURFACE_AFTER attempts shows as the worker's error line until it lands.
|
|
212
219
|
const writeHealth = new WriteHealth();
|
|
@@ -472,7 +479,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
472
479
|
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)}`));
|
|
473
480
|
queue.start();
|
|
474
481
|
})().catch(() => { loadError = "Follow-up could not start. Check its saved state and worker lock."; });
|
|
475
|
-
for (const file of [store, reviewerStore.persist, agentSettings.persist, prWorkflow.persist, inbox.store.persist]) file.health = writeHealth;
|
|
482
|
+
for (const file of [store, contextRequests.persist, reviewerStore.persist, agentSettings.persist, prWorkflow.persist, inbox.store.persist]) file.health = writeHealth;
|
|
476
483
|
const requireReady = async () => { if (waiting) throw new Error(waiting); await ready; if (loadError || stopped) throw new Error(loadError ?? "Follow-up is stopping"); };
|
|
477
484
|
// 1.4.0-beta.2: Follow-up's tools per agent: natively through Paseo's MCP when the host serves plugin tools,
|
|
478
485
|
// otherwise the stdio bridge for this launch only. FOLLOW_UP_TOOLS tells the hooks which names the agent has.
|
|
@@ -929,6 +936,55 @@ export default function contribute(server: PluginServerContext) {
|
|
|
929
936
|
handle(rpc.overseerStatusRpc, async () => { await requireReady(); return overseerStatus(); });
|
|
930
937
|
handle(rpc.overseerStartRpc, async (_input, { paseo }) => { await requireReady(); seen(paseo); await overseer!.start(paseo as unknown as OverseerPaseo); return overseerStatus(); });
|
|
931
938
|
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; the Overseer's send runs after the reply (it may
|
|
940
|
+
// start the Overseer), the agent's goes through the message queue (invariant 36). Asking the card's agent may wake
|
|
941
|
+
// it: the developer asked, the one exception to never-wake (invariant 1). The Overseer reads without waking anyone.
|
|
942
|
+
handle(rpc.contextAskRpc, async (input, context) => {
|
|
943
|
+
await requireReady();
|
|
944
|
+
const actor = actorOf(context);
|
|
945
|
+
if (actor.kind === "agent" && input.target === "agent" && input.agentId === actor.agentId) throw new Error("ask_context asks another agent about its card for the developer; explain your own ask in your reply.");
|
|
946
|
+
if (input.target === "agent" && !input.agentId) throw new Error("This card has no agent to ask. Ask the Overseer instead.");
|
|
947
|
+
const out = await contextRequests.ask(input, actorBy(actor), input.target === "agent" ? input.agentId : (await overseerStatus().catch(() => null))?.agentId ?? null);
|
|
948
|
+
if (!out.fresh) return out;
|
|
949
|
+
const r = out.request;
|
|
950
|
+
if (input.target === "agent") enqueueMessage(input.agentId!, agentContextPrompt(r), r.id, "developer");
|
|
951
|
+
else {
|
|
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;
|
|
963
|
+
});
|
|
964
|
+
// Built when read (a-derived-view-is-built-when-read), from state the worker holds: no daemon request but the
|
|
965
|
+
// directory's cached workspace list.
|
|
966
|
+
handle(rpc.catchUpDeckRpc, async () => {
|
|
967
|
+
await requireReady();
|
|
968
|
+
const [state, list, paseoList, priorities, settings, context] = await Promise.all([store.snapshot(), inbox.list(), paseoWorkspaces(), priorityStore.read(), inboxSettings(), contextRequests.list()]);
|
|
969
|
+
const tracked = state.workspaces.filter(w => w.enable_tracking);
|
|
970
|
+
const byId = new Map(tracked.map(w => [w.id, w]));
|
|
971
|
+
const model = buildHome({ rows: list.rows, tracked, paseo: paseoList, now: Date.now(), sort: (settings as { home_sort?: SortMode }).home_sort, priorities });
|
|
972
|
+
const cards = deckCards({ model, rows: list.rows, items: id => { const w = byId.get(id); return w ? needsYou(w) : []; } });
|
|
973
|
+
return { cards: cards.map(c => {
|
|
974
|
+
const r = [...context].reverse().find(x => x.cardKey === c.key);
|
|
975
|
+
return { key: c.key, kind: c.kind, workspaceId: c.s.workspaceId, agentId: c.s.agentId, title: c.s.title, line: c.s.line, questionId: c.questionId ?? null,
|
|
976
|
+
item: c.item && "title" in c.item ? String((c.item as { title?: unknown }).title ?? "") || null : null, context: r ? { id: r.id, state: r.state, target: r.target } : null };
|
|
977
|
+
}) };
|
|
978
|
+
});
|
|
979
|
+
handle(rpc.contextListRpc, async ({ workspaceId }) => ({ requests: await contextRequests.list(workspaceId ? { workspaceId } : {}) }));
|
|
980
|
+
handle(rpc.contextReplyRpc, async ({ agentId, requestId, text }) => {
|
|
981
|
+
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
|
+
await contextRequests.reply(requestId, agentId, text);
|
|
986
|
+
return { ok: true };
|
|
987
|
+
});
|
|
932
988
|
handle(rpc.overseerRestartRpc, async (_input, { paseo }) => { await requireReady(); seen(paseo); await overseer!.restart(paseo as unknown as OverseerPaseo); return overseerStatus(); });
|
|
933
989
|
// The provider catalog for Settings → Agents: read only when that screen asks, cached ten minutes.
|
|
934
990
|
const providerCatalog = new ProviderCatalog(async () => {
|
|
@@ -960,8 +1016,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
960
1016
|
// Record the version at start (in the background), so "Updated to X 2h ago" counts from the reload, not first view.
|
|
961
1017
|
void ready.then(() => selfInstall()).catch(() => undefined);
|
|
962
1018
|
const releaseNotesView = async (): Promise<ReleaseNotesView> => {
|
|
963
|
-
const me = await selfInstall()
|
|
964
|
-
return demoOverride(directory, "release-notes", releaseNotesViewSchema, { version: me.version, name: me.name ?? PLUGIN_NAME, installKind: me.installKind, previous: file.previous ?? null, updatedAt: file.startedAt ?? null, hostSeen: file.hostSeen ?? null, notes: me.notes });
|
|
1019
|
+
const [me, file, updates] = await Promise.all([selfInstall(), versions.read(), updatesStore.read()]);
|
|
1020
|
+
return demoOverride(directory, "release-notes", releaseNotesViewSchema, { version: me.version, name: me.name ?? PLUGIN_NAME, installKind: me.installKind, previous: file.previous ?? null, updatedAt: file.startedAt ?? null, hostSeen: file.hostSeen ?? null, enable_whats_new: updates.enable_whats_new !== false, notes: me.notes });
|
|
965
1021
|
};
|
|
966
1022
|
handle(rpc.releaseNotesRpc, async () => releaseNotesView());
|
|
967
1023
|
handle(rpc.whatsNewSeenRpc, async ({ version }) => { await versions.seen(version); return releaseNotesView(); });
|
|
@@ -1046,7 +1102,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1046
1102
|
if (check) await updater.check(check).catch(() => undefined);
|
|
1047
1103
|
return updatesView();
|
|
1048
1104
|
});
|
|
1049
|
-
handle(rpc.setUpdatesRpc, async ({ mode, channel }) => { await updater.setSettings({ mode, channel }); return updatesView(); });
|
|
1105
|
+
handle(rpc.setUpdatesRpc, async ({ mode, channel, enable_whats_new }) => { await updater.setSettings({ mode, channel, enable_whats_new }); return updatesView(); });
|
|
1050
1106
|
handle(rpc.installUpdateRpc, async ({ version, anyway }) => { await updater.install(version, !!anyway); return updatesView(); });
|
|
1051
1107
|
handle(rpc.retryMoveRpc, async () => { await pluginMove.retry(); return updatesView(); });
|
|
1052
1108
|
handle(rpc.dismissUpdateNoticeRpc, async ({ id }) => { await updater.dismiss(id); return updatesView(); });
|
|
@@ -1303,9 +1359,9 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1303
1359
|
const [items, rank, overseerView] = await Promise.all([priorityStore.read(), ranker!.status(), overseerStatus()]);
|
|
1304
1360
|
// The worker's live resources change every tick: the client reads those once when Home opens (follow.usage).
|
|
1305
1361
|
const meters = governor.allowsExtras() ? await usage.read() : NO_USAGE;
|
|
1306
|
-
return { priorities: items, rank, overseer: overseerView, usage: { available: meters.available, source: meters.source, accounts: meters.accounts }, usageLive: !!usageWatch };
|
|
1362
|
+
return { priorities: items, rank, overseer: overseerView, usage: { available: meters.available, source: meters.source, accounts: meters.accounts }, usageLive: !!usageWatch, context: await contextRequests.list() };
|
|
1307
1363
|
},
|
|
1308
|
-
key: v => JSON.stringify([v.priorities, v.rank, v.overseer, usageKey(v.usage), v.usageLive]),
|
|
1364
|
+
key: v => JSON.stringify([v.priorities, v.rank, v.overseer, usageKey(v.usage), v.usageLive, v.context]),
|
|
1309
1365
|
// Smart Session's files are watched only while someone looks at Home (server/usage.ts watch()).
|
|
1310
1366
|
onFirst: () => { usageWatch = usage.watch(() => void homeFeed.changed()); },
|
|
1311
1367
|
onLast: () => { usageWatch?.close(); usageWatch = null; },
|
|
@@ -1449,6 +1505,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1449
1505
|
// handlers below read the patched rows.
|
|
1450
1506
|
server.on("agent.turn_started", async event => gateway.directory.turnStarted(event.agent, event.turnId)),
|
|
1451
1507
|
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
|
+
server.on("agent.turn_ended", async event => contextRequests.turnEnded(event.agent.id)),
|
|
1452
1510
|
server.on("agent.permission_requested", async event => gateway.directory.permissionRequested(event.agent.id, event.request as { id?: string })),
|
|
1453
1511
|
server.on("agent.permission_resolved", async event => gateway.directory.permissionResolved(event.agent.id, event.requestId)),
|
|
1454
1512
|
server.on("agent.archived", async event => gateway.directory.agentArchived(event.agent.id, event.archivedAt)),
|
|
@@ -1570,7 +1628,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1570
1628
|
// One deadline for every wait (worker-stop-never-waits-on-a-stuck-pass, server/teardown.ts): start-up and the work
|
|
1571
1629
|
// in flight may be stuck on a daemon or CLI that never answers. Work that ends inside the deadline is saved; what
|
|
1572
1630
|
// outlives it can't write, because the store closes before the lock is released.
|
|
1573
|
-
await stopWorker({ files: [reviewerStore, agentSettings, prWorkflow, queue], ready, hooks: hooksStarted ? () => agentHooks.stop() : undefined, actions, closeConnections, engine, store, inbox: inbox.store, unlock });
|
|
1631
|
+
await stopWorker({ files: [contextRequests, reviewerStore, agentSettings, prWorkflow, queue], ready, hooks: hooksStarted ? () => agentHooks.stop() : undefined, actions, closeConnections, engine, store, inbox: inbox.store, unlock });
|
|
1574
1632
|
})();
|
|
1575
1633
|
return stop;
|
|
1576
1634
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0-beta.2",
|
|
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
|
@@ -47,7 +47,7 @@ export function rowPrs(state: State, r: InboxRow, now: number): PrLink[] {
|
|
|
47
47
|
return [...out.values()];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export const AGENT_TOOLS = ["make_main_agent", "list_prs", "add_reviewers", "merge", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "track", "inbox_list", "sign_off", "snooze", "snooze_workspace", "set_finish_flags", "set_priorities", "workspace_about", "agent_settings", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "priorities", "rank_status", "rerank_priorities", "usage", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "run_recovery", "refresh", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "link_items", "set_linked_items", "updates_status", "check_updates", "set_updates", "install_update", "display_settings", "set_display", "retry_move", "report_issue", "report_send", "ai_rename"] as const;
|
|
50
|
+
export const AGENT_TOOLS = ["make_main_agent", "list_prs", "add_reviewers", "merge", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "track", "inbox_list", "sign_off", "snooze", "snooze_workspace", "set_finish_flags", "set_priorities", "workspace_about", "agent_settings", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "priorities", "rank_status", "rerank_priorities", "usage", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "run_recovery", "refresh", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "link_items", "set_linked_items", "updates_status", "check_updates", "set_updates", "install_update", "display_settings", "set_display", "retry_move", "report_issue", "report_send", "ai_rename", "catch_up_deck", "context_requests", "ask_context"] as const;
|
|
51
51
|
export type AgentTool = typeof AGENT_TOOLS[number];
|
|
52
52
|
/** Tools that only read. */
|
|
53
53
|
export const READ_ONLY_TOOLS: readonly AgentTool[] = ["list_prs", "inbox_list", "workspace_about", "agent_settings", "display_settings", ...RPC_TOOLS.filter(t => t.kind === "read").map(t => t.name as AgentTool)];
|
package/server/agent-hook.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const directory = dirname(fileURLToPath(import.meta.url));
|
|
|
13
13
|
/** 1.4.0-beta.2: launched with Follow-up's tools served by Paseo's MCP (follow_<name>), or the follow-up bridge (<name>). Agents opened before the upgrade carry no flag and keep the bridge names. */
|
|
14
14
|
let native = env("TOOLS") === "native";
|
|
15
15
|
// Tool names that read unambiguously in prose; kept identical to server/mcp.mjs's underscore names (a test checks it).
|
|
16
|
-
export const TOOL_NAMES = ["workspace_status", "sync_workspace", "enroll_workspace", "register_pr", "exclude_stack", "update_obligation", "acknowledge_batch", "ask_question", "record_answer", "withdraw_question", "set_spec", "link_item", "unlink_item", "link_items", "set_linked_items", "workspace_about", "agent_settings", "needs_you", "declare_done", "list_prs", "add_reviewers", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "inbox_list", "sign_off", "snooze_workspace", "set_finish_flags", "set_priorities", "agent_digest", "route_candidates", "send_to_agent", "start_workspace", "display_settings", "set_display", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "rank_status", "rerank_priorities", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "run_recovery", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "updates_status", "check_updates", "set_updates", "install_update", "make_main_agent", "retry_move", "report_issue", "report_send", "ai_rename"];
|
|
16
|
+
export const TOOL_NAMES = ["workspace_status", "sync_workspace", "enroll_workspace", "register_pr", "exclude_stack", "update_obligation", "acknowledge_batch", "ask_question", "record_answer", "withdraw_question", "set_spec", "link_item", "unlink_item", "link_items", "set_linked_items", "workspace_about", "agent_settings", "needs_you", "declare_done", "list_prs", "add_reviewers", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "inbox_list", "sign_off", "snooze_workspace", "set_finish_flags", "set_priorities", "agent_digest", "route_candidates", "send_to_agent", "start_workspace", "display_settings", "set_display", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "rank_status", "rerank_priorities", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "run_recovery", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "updates_status", "check_updates", "set_updates", "install_update", "make_main_agent", "retry_move", "report_issue", "report_send", "ai_rename", "catch_up_deck", "context_requests", "ask_context", "context_reply"];
|
|
17
17
|
const toolPattern = new RegExp(`(?<![\\w])(${TOOL_NAMES.join("|")})(?![\\w])`, "g");
|
|
18
18
|
/** Names Follow-up's tools the way this agent has them. */
|
|
19
19
|
export function named(text, isNative = native) { return isNative ? text.replace(toolPattern, "follow_$1") : text; }
|
package/server/agent-parity.ts
CHANGED
|
@@ -69,6 +69,14 @@ export const RPC_TOOLS: readonly RpcTool[] = [
|
|
|
69
69
|
{ name: "overseer_start", rpc: "follow.overseer-start", kind: "planned", before: { rpc: "follow.overseer-status" }, input: z.strictObject({ ...confirm }) },
|
|
70
70
|
{ name: "overseer_restart", rpc: "follow.overseer-restart", kind: "planned", before: { rpc: "follow.overseer-status" }, input: z.strictObject({ ...confirm }) },
|
|
71
71
|
{ name: "overseer_ask", rpc: "follow.overseer-ask", kind: "planned", input: z.strictObject({ text: z.string().trim().min(1).max(2000).optional(), ...confirm }) },
|
|
72
|
+
// Catch up: the deck, and More context (ask, read the asks); the asked agent answers with context_reply
|
|
73
|
+
{ name: "catch_up_deck", rpc: "follow.catch-up-deck", kind: "read", input: none },
|
|
74
|
+
{ name: "context_requests", rpc: "follow.context-list", kind: "read", input: z.strictObject({ workspaceId: id.optional() }) },
|
|
75
|
+
{ name: "ask_context", rpc: "follow.context-ask", kind: "planned", before: { rpc: "follow.context-list", input: a => ({ workspaceId: a.workspaceId ?? undefined }) },
|
|
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
|
+
target: z.enum(["overseer", "agent"]).optional(), ask: z.string().trim().min(1).max(2000).optional(), ...confirm }),
|
|
78
|
+
toRpc: a => ({ workspaceId: a.workspaceId ?? null, agentId: a.agentId ?? null, cardKey: a.cardKey, card: a.card, target: a.target, ask: a.ask }),
|
|
79
|
+
guard: (a, caller) => a.target === "agent" && a.agentId === caller ? "ask_context asks another agent about its card; explain your own ask in your reply." : null },
|
|
72
80
|
// Needs-you: the brief card and the inbox's other actions
|
|
73
81
|
// 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).
|
|
74
82
|
{ name: "queue_list", rpc: "follow.queue-list", kind: "read", input: z.strictObject({ workspaceId: id.optional(), agentId: id.optional() }) },
|
|
@@ -107,7 +115,7 @@ export const RPC_TOOLS: readonly RpcTool[] = [
|
|
|
107
115
|
{ name: "updates_status", rpc: "follow.updates", kind: "read", input: none },
|
|
108
116
|
{ name: "check_updates", rpc: "follow.updates", kind: "write", input: none, toRpc: () => ({ check: "manual" }) },
|
|
109
117
|
{ name: "set_updates", rpc: "follow.set-updates", kind: "planned", before: { rpc: "follow.updates", input: () => ({}) },
|
|
110
|
-
input: z.strictObject({ mode: z.enum(UPDATE_MODES).optional(), channel: z.enum(["stable", "beta"]).optional(), ...confirm }) },
|
|
118
|
+
input: z.strictObject({ mode: z.enum(UPDATE_MODES).optional(), channel: z.enum(["stable", "beta"]).optional(), enable_whats_new: z.boolean().optional(), ...confirm }) },
|
|
111
119
|
{ name: "install_update", rpc: "follow.install-update", kind: "planned", before: { rpc: "follow.updates", input: () => ({}) },
|
|
112
120
|
input: z.strictObject({ version: z.string().trim().min(1).max(64), anyway: z.boolean().optional(), ...confirm }) },
|
|
113
121
|
// Settings → General: 2.0's move to the new plugin id (status is in updates_status), Try again
|
|
@@ -206,5 +214,6 @@ export const PARITY: Record<string, { tools: readonly string[]; note?: string }
|
|
|
206
214
|
* note says where an agent finds what the developer found.
|
|
207
215
|
*/
|
|
208
216
|
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." },
|
|
209
218
|
"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." },
|
|
210
219
|
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { WriteBehind } from "./write-behind";
|
|
5
|
+
import { CONTEXT_ANSWER_MAX, contextFileSchema, pruneContext, type ContextFile, type ContextRequest, type ContextTarget } from "../shared/catch-up";
|
|
6
|
+
|
|
7
|
+
export const CONTEXT_FILE = "context.json";
|
|
8
|
+
|
|
9
|
+
export type AskInput = { workspaceId: string | null; agentId: string | null; cardKey: string; card: string; target: ContextTarget; ask: string };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Catch up's More context requests (docs/needs-you.md#catch-up): what the developer asked about a card, who answers
|
|
13
|
+
* (the Overseer or the card's agent), and the answer once `context_reply` brings it. The value lives in memory and
|
|
14
|
+
* saves behind the reply (an-ack-never-waits-on-the-disk); a change calls `onChange`, which pushes Home's feed, so the
|
|
15
|
+
* client learns an answer arrived without polling. Small by construction: at most CONTEXT_MAX requests, none older
|
|
16
|
+
* than CONTEXT_KEEP_MS.
|
|
17
|
+
*/
|
|
18
|
+
export class ContextRequests {
|
|
19
|
+
private value: ContextFile | null = null;
|
|
20
|
+
readonly persist: WriteBehind<ContextFile>;
|
|
21
|
+
onChange: () => void = () => undefined;
|
|
22
|
+
constructor(readonly directory: string, private now: () => number = Date.now) {
|
|
23
|
+
this.persist = new WriteBehind({ path: join(directory, CONTEXT_FILE), encode: v => JSON.stringify(v) });
|
|
24
|
+
}
|
|
25
|
+
async flush(): Promise<void> { await this.persist.flush(); }
|
|
26
|
+
|
|
27
|
+
private async load(): Promise<ContextFile> {
|
|
28
|
+
if (this.value) return this.value;
|
|
29
|
+
let value: ContextFile;
|
|
30
|
+
try { value = contextFileSchema.parse(JSON.parse(await readFile(join(this.directory, CONTEXT_FILE), "utf8"))); }
|
|
31
|
+
catch { value = { requests: [] }; } // Lost context requests cost a re-ask, never a broken Home.
|
|
32
|
+
this.value ??= value;
|
|
33
|
+
return this.value;
|
|
34
|
+
}
|
|
35
|
+
private save(requests: ContextRequest[]): void {
|
|
36
|
+
this.value = contextFileSchema.parse({ requests: pruneContext(requests, this.now()) });
|
|
37
|
+
this.persist.set(this.value);
|
|
38
|
+
this.onChange();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async list(filter: { workspaceId?: string } = {}): Promise<ContextRequest[]> {
|
|
42
|
+
const { requests } = await this.load();
|
|
43
|
+
const live = pruneContext(requests, this.now());
|
|
44
|
+
return filter.workspaceId ? live.filter(r => r.workspaceId === filter.workspaceId) : live;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Records an ask. One open ask per card: asking again while it's open returns that one (`fresh: false`). */
|
|
48
|
+
async ask(input: AskInput, by: string, askedOf: string | null): Promise<{ request: ContextRequest; fresh: boolean }> {
|
|
49
|
+
const { requests } = await this.load();
|
|
50
|
+
const open = requests.find(r => r.cardKey === input.cardKey && r.state === "asking");
|
|
51
|
+
if (open) return { request: open, fresh: false };
|
|
52
|
+
const request: ContextRequest = {
|
|
53
|
+
id: `ctx-${randomUUID()}`, ...input, askedOf, state: "asking", answer: null, error: null,
|
|
54
|
+
askedAt: new Date(this.now()).toISOString(), settledAt: null, by,
|
|
55
|
+
};
|
|
56
|
+
this.save([...requests, request]);
|
|
57
|
+
return { request, fresh: true };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private async update(id: string, change: (r: ContextRequest) => ContextRequest | null): Promise<ContextRequest | null> {
|
|
61
|
+
const { requests } = await this.load();
|
|
62
|
+
const i = requests.findIndex(r => r.id === id);
|
|
63
|
+
if (i < 0) return null;
|
|
64
|
+
const next = change(requests[i]);
|
|
65
|
+
if (!next || next === requests[i]) return requests[i];
|
|
66
|
+
this.save(requests.map((r, j) => j === i ? next : r));
|
|
67
|
+
return next;
|
|
68
|
+
}
|
|
69
|
+
|
|
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
|
+
/**
|
|
76
|
+
* The asked agent's answer (context_reply). Only the agent it was asked of may answer it (ownership comes from the
|
|
77
|
+
* daemon, invariant 5); an answer to a settled request replaces it, so a corrected reply wins.
|
|
78
|
+
*/
|
|
79
|
+
async reply(id: string, caller: string, text: string): Promise<ContextRequest> {
|
|
80
|
+
const r = (await this.list()).find(x => x.id === id);
|
|
81
|
+
if (!r) throw new Error(`No open context request ${id}. It may have expired; the developer can ask again.`);
|
|
82
|
+
if (r.askedOf !== caller) throw new Error("This context request was asked of another agent.");
|
|
83
|
+
const answer = text.trim().slice(0, CONTEXT_ANSWER_MAX);
|
|
84
|
+
if (!answer) throw new Error("context_reply: give text, the explanation for the developer.");
|
|
85
|
+
return (await this.update(id, x => ({ ...x, state: "answered", answer, error: null, settledAt: new Date(this.now()).toISOString() })))!;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The send failed for good (no Overseer, the agent archived): the card comes back saying so. */
|
|
89
|
+
fail(id: string, error: string): Promise<ContextRequest | null> {
|
|
90
|
+
return this.update(id, r => r.state !== "asking" ? r : { ...r, state: "failed", error: error.slice(0, 500), settledAt: new Date(this.now()).toISOString() });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* An asked agent's turn ended. If it started after the ask and the agent didn't reply with the tool, the answer is in
|
|
95
|
+
* its chat: the card comes back with Open chat. Costs a lookup in a list of at most CONTEXT_MAX; no reads.
|
|
96
|
+
*/
|
|
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
|
+
async turnEnded(agentId: string): Promise<void> {
|
|
103
|
+
const turnStartedAt = this.started.get(agentId) ?? null;
|
|
104
|
+
this.started.delete(agentId);
|
|
105
|
+
if (!this.value?.requests.some(r => r.state === "asking" && r.askedOf === agentId)) return;
|
|
106
|
+
for (const r of this.value.requests.filter(r => r.state === "asking" && r.askedOf === agentId)) {
|
|
107
|
+
if (turnStartedAt === null || turnStartedAt < Date.parse(r.askedAt)) continue;
|
|
108
|
+
await this.update(r.id, x => x.state !== "asking" ? x : { ...x, state: "chat", settledAt: new Date(this.now()).toISOString() });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
package/server/daemon.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { ConversationGone } from "./delivery";
|
|
|
28
28
|
import { compactionDelivered, turnIdOf } from "../shared/status";
|
|
29
29
|
import { activeWindowMs, backgroundCount, isLive, isLoaded, recentlyUsed, workspaceActive, conversationGone, DEFAULT_ACTIVE_WINDOW_DAYS, DAY_MS } from "./agent-load";
|
|
30
30
|
import { HistoryCache } from "./history-cache";
|
|
31
|
-
import { agentRecord,
|
|
31
|
+
import { agentRecord, markerInFile, transcriptFile } from "./transcript";
|
|
32
32
|
import { DaemonDirectory, type DirectoryRows } from "./directory";
|
|
33
33
|
import { traceDaemon } from "./request-trace";
|
|
34
34
|
import type { TurnTimeline } from "./turn-timeline";
|
|
@@ -620,19 +620,24 @@ export class PaseoGateway implements Gateway {
|
|
|
620
620
|
/**
|
|
621
621
|
* Whether `messageId` reached the agent since `since`. A loaded agent: its timeline, where Paseo records the message
|
|
622
622
|
* with its clientMessageId when it accepts it (before the provider runs). An unloaded one is never read (that would
|
|
623
|
-
* wake it, Invariant 1): its provider transcript on disk is searched for `marker` instead,
|
|
624
|
-
*
|
|
623
|
+
* wake it, Invariant 1): its provider transcript on disk is searched for `marker` instead, as it is for a loaded agent
|
|
624
|
+
* whose timeline read can't tell (a busy one); it says "not there" only when the part read reaches back to the send
|
|
625
|
+
* (markerInFile). Null: unknown.
|
|
625
626
|
*/
|
|
626
627
|
async arrivedMessage(agentId: string, messageId: string, since: string, marker: string): Promise<boolean | null> {
|
|
627
|
-
const
|
|
628
|
+
const sinceMs = Date.parse(since) - 60_000;
|
|
629
|
+
const timeline = await this.connect(async client => {
|
|
628
630
|
const a = (await client.fetchAgent(agentId))?.agent;
|
|
629
631
|
if (!a) return null;
|
|
630
|
-
if (!isLoaded(a)) return
|
|
631
|
-
return timelineHas(client, agentId, messageId,
|
|
632
|
+
if (!isLoaded(a)) return null;
|
|
633
|
+
return timelineHas(client, agentId, messageId, sinceMs);
|
|
632
634
|
}).catch(() => null);
|
|
633
|
-
|
|
634
|
-
|
|
635
|
+
// The timeline can't tell (the agent isn't loaded, or a busy one wrote more than the read's pages since the send):
|
|
636
|
+
// the provider transcript on disk decides, read back to the send. Only an unconfirmed item gets here.
|
|
637
|
+
return timeline ?? this.transcriptArrived(agentId, marker, sinceMs);
|
|
635
638
|
}
|
|
639
|
+
/** The transcript half of arrivedMessage (tests replace it): markerInFile over the agent's provider transcript. */
|
|
640
|
+
transcriptArrived: (agentId: string, marker: string, sinceMs: number) => Promise<boolean | null> = (agentId, marker, sinceMs) => transcriptHas(paseoHome, agentId, marker, sinceMs);
|
|
636
641
|
async handoff(w: Workspace, callerId: string): Promise<{ batchId: string; fromAgentId: string } | null> {
|
|
637
642
|
return this.connect(async client => {
|
|
638
643
|
const caller = (await client.fetchAgent(callerId))?.agent;
|
|
@@ -755,15 +760,17 @@ async function timelineHas(client: Daemon, agentId: string, messageId: string, s
|
|
|
755
760
|
}
|
|
756
761
|
return null;
|
|
757
762
|
}
|
|
758
|
-
/**
|
|
759
|
-
|
|
763
|
+
/**
|
|
764
|
+
* The agent's provider transcript on disk holds `marker`, read back from its end to the send (markerInFile, at most
|
|
765
|
+
* MARKER_READ_MAX_BYTES). Never wakes the agent. False only when the part read reaches back to `sinceMs` and holds no marker: the agent isn't loaded, so nothing of Paseo's is still
|
|
766
|
+
* holding the message, and a provider writes a prompt to its transcript when it takes it. Anything else is unknown.
|
|
767
|
+
*/
|
|
768
|
+
async function transcriptHas(home: string, agentId: string, marker: string, sinceMs: number): Promise<boolean | null> {
|
|
760
769
|
if (!marker) return null;
|
|
761
770
|
try {
|
|
762
771
|
const record = await agentRecord(home, agentId);
|
|
763
772
|
const file = record && await transcriptFile(record);
|
|
764
773
|
if (!file) return null;
|
|
765
|
-
|
|
766
|
-
const needle = JSON.stringify(marker).slice(1, -1);
|
|
767
|
-
return tail.some(line => line.includes(needle)) ? true : null;
|
|
774
|
+
return await markerInFile(file, sinceMs, marker);
|
|
768
775
|
} catch { return null; }
|
|
769
776
|
}
|