paseo-follow-up 2.4.2 → 2.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/OVERVIEW.md +1 -1
  3. package/README.md +0 -1
  4. package/client/home.tsx +16 -8
  5. package/client/live.tsx +4 -3
  6. package/client/new-settings.tsx +1 -1
  7. package/client/onboarding.tsx +50 -118
  8. package/client/panel.tsx +2 -1
  9. package/client/release-notes.tsx +98 -123
  10. package/client/setup-dialog.tsx +168 -0
  11. package/client/setup-gate.tsx +69 -0
  12. package/client/setup-ui.ts +27 -0
  13. package/client/tasks.tsx +38 -8
  14. package/client/updates.tsx +6 -6
  15. package/index.client.tsx +1 -1
  16. package/index.server.ts +46 -4
  17. package/package.json +1 -1
  18. package/server/agent-hook.mjs +6 -4
  19. package/server/agent-parity.ts +2 -2
  20. package/server/ai-jobs.ts +26 -5
  21. package/server/engine.ts +6 -2
  22. package/server/hook-source.ts +6 -4
  23. package/server/job-agent.ts +13 -2
  24. package/server/mcp-source.ts +4 -4
  25. package/server/mcp.mjs +4 -4
  26. package/server/obligations.ts +7 -5
  27. package/server/release-notes.ts +5 -5
  28. package/server/scheduled-tasks.ts +92 -0
  29. package/server/session-prompt.ts +30 -3
  30. package/server/turn-end.ts +130 -0
  31. package/server/wait-jobs.ts +18 -2
  32. package/server/wait.ts +17 -12
  33. package/shared/agent-settings.ts +9 -8
  34. package/shared/attention.ts +4 -0
  35. package/shared/changelog.ts +33 -0
  36. package/shared/compass.ts +5 -4
  37. package/shared/contracts.ts +4 -4
  38. package/shared/job-rows.ts +2 -2
  39. package/shared/message-sender.ts +2 -0
  40. package/shared/new-name.ts +4 -1
  41. package/shared/onboarding.ts +17 -13
  42. package/shared/provider-support.ts +83 -34
  43. package/shared/queue.ts +1 -1
  44. package/shared/recommend.ts +1 -1
  45. package/shared/settings-nav.ts +3 -1
  46. package/shared/setup-popup.ts +28 -0
  47. package/shared/task-due.ts +3 -1
  48. package/shared/task-trigger.ts +125 -1
  49. package/shared/wait.ts +2 -2
  50. package/skills/follow-up/SKILL.md +1 -1
@@ -0,0 +1,27 @@
1
+ import { useSyncExternalStore } from "react";
2
+ import { deviceStorage } from "../shared/settings-nav";
3
+ import { SETUP_CLOSED_KEY } from "../shared/setup-popup";
4
+
5
+ /**
6
+ * Setup's popup in this app session (setup-is-one-popup, client/setup-gate.tsx): which Follow-up surface draws it
7
+ * (`owner`, the first to want it) and whether the done page is up (`done`: after Finish the server already says setup
8
+ * is over). Close is the device's, not the session's: SETUP_CLOSED_KEY in the device's view state, so a put-away popup
9
+ * stays away after a reload until Home's Finish setup line opens it.
10
+ */
11
+ type Session = { owner: string | null; done: boolean };
12
+ let state: Session = { owner: null, done: false };
13
+ const listeners = new Set<() => void>();
14
+ export const setupSession = {
15
+ get: () => state,
16
+ set(next: Partial<Session>) { state = { ...state, ...next }; listeners.forEach(l => l()); },
17
+ subscribe(l: () => void) { listeners.add(l); return () => { listeners.delete(l); }; },
18
+ };
19
+ export const useSetupSession = () => useSyncExternalStore(setupSession.subscribe, setupSession.get, setupSession.get);
20
+ /** Tests and a fresh app session: nobody draws the popup, no done page. */
21
+ export const resetSetupSession = () => setupSession.set({ owner: null, done: false });
22
+
23
+ export const setupClosed = () => deviceStorage.get(SETUP_CLOSED_KEY) === "1";
24
+ /** Close (X): put the popup away on this device. The server hears nothing; setup stays on its step. */
25
+ export const closeSetup = () => deviceStorage.set(SETUP_CLOSED_KEY, "1");
26
+ /** Finish setup, Set up again, or setup ending: the next time setup is under way, the popup opens by itself. */
27
+ export const reopenSetup = () => { if (deviceStorage.get(SETUP_CLOSED_KEY) === "1") deviceStorage.set(SETUP_CLOSED_KEY, ""); };
package/client/tasks.tsx CHANGED
@@ -5,7 +5,7 @@ import { Icon, Modal, TextInput, useToast } from "@getpaseo/plugin/client/ui";
5
5
  import { useRpc } from "@getpaseo/plugin/client";
6
6
  import { useQueryClient } from "@tanstack/react-query";
7
7
  import type { Obligation, Workspace } from "../shared/model";
8
- import type { TaskTrigger } from "../shared/task-trigger";
8
+ import { atChoices, atProblem, clockLabel, DIDNT_GO_OUT, localTimeText, parseLocalTime, TRIGGER_HELP, type TaskTrigger } from "../shared/task-trigger";
9
9
  import { taskTriggerRpc } from "../shared/contracts";
10
10
  import { linkedQuestion, type TaskStatus } from "../shared/task-status";
11
11
  import { finishedParts, summaryParts, taskSummary, taskViewRows, type TaskViewRow } from "../shared/task-view";
@@ -24,28 +24,53 @@ function TriggerEditor({ obligation: o, workspace, theme, compact }: { obligatio
24
24
  const [event, setEvent] = useState<TaskTrigger["event"] | "manual">(o.enable_follow_up && o.trigger ? o.trigger.event : "manual");
25
25
  const [days, setDays] = useState(String(o.trigger?.delayDays ?? 0));
26
26
  const [prs, setPrs] = useState(o.afterPrs);
27
+ // At a time: a quick pick or a typed time, on the device's clock (the developer's zone). Opened with a time already
28
+ // set, the field starts there; else in 30 minutes.
29
+ const now = Date.now();
30
+ const choices = atChoices(now);
31
+ const [when, setWhen] = useState(() => localTimeText(o.trigger?.event === "at" && o.trigger.at && Date.parse(o.trigger.at) > now ? Date.parse(o.trigger.at) : choices[0].at));
32
+ const at = parseLocalTime(when, now);
33
+ const timeProblem = event === "at" ? atProblem(at, now) : null;
34
+ // A time that already went out (or couldn't): said once, so a new time reads as sending it again.
35
+ const before = o.trigger?.event === "at" ? o.trigger.notSent ? `${DIDNT_GO_OUT} at ${clockLabel(o.trigger.at ?? "", now)}: ${o.trigger.notSent}.` : o.trigger.sentAt ? `Went out ${clockLabel(o.trigger.sentAt, now)}.` : null : null;
27
36
  const rpc = useRpc(taskTriggerRpc); const cache = useQueryClient(); const toast = useToast();
28
37
  const gated = event === "merge" || event === "deploy";
29
- const valid = !gated || prs.length > 0 && /^\d+$/.test(days) && Number(days) <= 3650;
38
+ const valid = event === "at" ? !timeProblem : !gated || prs.length > 0 && /^\d+$/.test(days) && Number(days) <= 3650;
30
39
  // Quick action: Save doesn't wait on the server; a toast confirms it, or says what failed with Retry.
31
40
  const save = { isPending: false, mutate: () => void runAction({
32
- label: "Schedule", toast, run: () => rpc({ workspaceId: workspace.id, obligationId: o.id, expectedRevision: o.revision, afterPrs: event === "now" ? [] : prs, trigger: event === "manual" ? null : { event, delayDays: gated ? Number(days) : 0 } }),
41
+ label: "Schedule", toast, run: () => rpc({ workspaceId: workspace.id, obligationId: o.id, expectedRevision: o.revision, afterPrs: event === "now" ? [] : prs, trigger: event === "manual" ? null : event === "at" ? { event, delayDays: 0, at: new Date(at!).toISOString() } : { event, delayDays: gated ? Number(days) : 0 } }),
33
42
  success: () => ({ message: "Schedule saved" }), onSuccess: () => { void cache.invalidateQueries(); }, onError: () => { void cache.invalidateQueries(); },
34
43
  failure: `Schedule for ${o.title} not saved`,
35
44
  }) };
36
45
  const busy = save.isPending;
37
- const options = [["manual", "Not sent"], ["now", "Now"], ["merge", "After merge"], ["deploy", "After deploy"]] as const;
46
+ const options = [["manual", "Not sent"], ["now", "Now"], ["at", "At a time"], ["merge", "After merge"], ["deploy", "After deploy"]] as const;
47
+ const chip = (selected: boolean) => ({ minHeight: compact ? 44 : 30, justifyContent: "center" as const, paddingHorizontal: 11, borderRadius: 999, borderWidth: 1, borderColor: selected ? c.accent : c.border, backgroundColor: selected ? c.accent : "transparent" });
38
48
  return <SubmitScope enabled={!busy && valid} onSubmit={() => save.mutate()} style={{ gap: 10 }}>
39
49
  <View style={{ gap: 4 }}>
40
50
  <Text style={t.label}>Send to the agent</Text>
41
- <Text style={t.meta}>Not sent: the task comes due when its PRs merge or deploy, or on its re-check date, and the agent is reminded at the end of its turn. Scheduled tasks join the next message to the agent instead, and still follow your Auto-send choice.</Text>
51
+ <Text style={t.meta}>{TRIGGER_HELP[event]}</Text>
42
52
  </View>
43
53
  <View accessibilityRole="radiogroup" accessibilityLabel={`Send trigger for ${o.title}`} style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>
44
54
  {options.map(([value, label]) => <Pressable key={value} accessibilityRole="radio" accessibilityLabel={label} aria-checked={event === value} accessibilityState={{ checked: event === value, disabled: busy }} disabled={busy} onPress={() => { setEvent(value); }}
45
- style={{ minHeight: compact ? 44 : 30, justifyContent: "center", paddingHorizontal: 11, borderRadius: 999, borderWidth: 1, borderColor: event === value ? c.accent : c.border, backgroundColor: event === value ? c.accent : "transparent" }}>
55
+ style={chip(event === value)}>
46
56
  <Text style={{ fontSize: 12, fontWeight: "600", color: event === value ? c.accentForeground : c.foreground }}>{label}</Text>
47
57
  </Pressable>)}
48
58
  </View>
59
+ {event === "at" && <View style={{ gap: 8 }}>
60
+ {before && <Text style={t.meta}>{before} Pick a new time to send it again.</Text>}
61
+ {/* Quick picks fill the field: small outlined buttons, never a second selected state beside the trigger choice. */}
62
+ <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>
63
+ {choices.map(ch => <Pressable key={ch.label} accessibilityRole="button" accessibilityLabel={`${ch.label}: fill in ${localTimeText(ch.at)}`} disabled={busy} hitSlop={compact ? 0 : 6} onPress={() => setWhen(localTimeText(ch.at))}
64
+ style={state => ({ minHeight: compact ? 44 : 26, justifyContent: "center", paddingHorizontal: 9, borderRadius: 6, borderWidth: 1, borderColor: c.border, opacity: state.pressed ? 0.6 : 1 })}>
65
+ <Text style={{ fontSize: 12, color: c.foreground, fontVariant: ["tabular-nums"] }}>{ch.label}</Text>
66
+ </Pressable>)}
67
+ </View>
68
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8, flexWrap: "wrap" }}>
69
+ <TextInput accessibilityLabel="Send at, date and time" value={when} editable={!busy} onChangeText={setWhen} autoCapitalize="none" autoCorrect={false}
70
+ style={{ width: 150, minHeight: compact ? 44 : 32, paddingHorizontal: 10, borderRadius: 6, borderWidth: 1, borderColor: timeProblem ? c.statusDanger : c.border, color: c.foreground, backgroundColor: c.surface1, fontSize: 13, fontVariant: ["tabular-nums"] }} />
71
+ <Text style={[t.meta, timeProblem ? { color: c.statusDanger } : null]}>{timeProblem ?? `Sends ${clockLabel(new Date(at!).toISOString(), Date.now())}, your time`}</Text>
72
+ </View>
73
+ </View>}
49
74
  {gated && <>
50
75
  <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
51
76
  <Text style={t.meta}>Wait</Text>
@@ -91,7 +116,12 @@ function TaskGlyph({ row, w, colors }: { row: TaskViewRow; w: Workspace; colors:
91
116
  case "blocked": return <Icon name="CirclePause" size={14} color={muted} />;
92
117
  case "after-pr": return <Icon name="GitPullRequest" size={14} color={muted} />;
93
118
  case "recheck": return <Icon name="CalendarClock" size={14} color={muted} />;
94
- case "scheduled": return row.status.tone === "queued" || row.status.tone === "sent" ? <DeliveryGlyph state={row.status.tone} w={w} colors={colors} /> : <Icon name="Clock" size={14} color={muted} />;
119
+ case "scheduled":
120
+ if (row.status.tone === "queued" || row.status.tone === "sent") return <DeliveryGlyph state={row.status.tone} w={w} colors={colors} />;
121
+ // A time trigger that couldn't go out is the developer's to notice (amber, its own shape); one that went out is a send.
122
+ if (row.o.trigger?.event === "at" && row.o.trigger.notSent) return <Icon name="CircleAlert" size={14} color={staleColor(colors)} />;
123
+ if (row.o.trigger?.event === "at" && row.o.trigger.sentAt) return <Icon name="Send" size={14} color={muted} />;
124
+ return <Icon name="Clock" size={14} color={muted} />;
95
125
  case "needs-you": return <Icon name={linkedQuestion(row.o, w)?.need === "action" ? "Hand" : "MessageCircleQuestion"} size={14} color={muted} />;
96
126
  default: return <Dot color={muted} />;
97
127
  }
@@ -100,7 +130,7 @@ function TaskGlyph({ row, w, colors }: { row: TaskViewRow; w: Workspace; colors:
100
130
  /** The meta line: "Stale" in amber, the rest muted; everything else muted. */
101
131
  function MetaLine({ row, theme }: { row: TaskViewRow; theme: Theme }) {
102
132
  const c = theme.colors; const t = text(c);
103
- if (row.kind !== "stale") return <Text style={[t.meta, { fontVariant: ["tabular-nums"] }]}>{row.meta}</Text>;
133
+ if (row.kind !== "stale" && !row.meta.startsWith(DIDNT_GO_OUT)) return <Text style={[t.meta, { fontVariant: ["tabular-nums"] }]}>{row.meta}</Text>;
104
134
  const [word, ...rest] = row.meta.split(" · ");
105
135
  return <Text style={[t.meta, { fontVariant: ["tabular-nums"] }]}><Text style={{ color: staleColor(c), fontWeight: "600" }}>{word}</Text>{rest.length ? ` · ${rest.join(" · ")}` : ""}</Text>;
106
136
  }
@@ -14,9 +14,9 @@ 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, releaseNotesKey } from "./release-notes";
17
+ import { ReleaseNotesSheet, VersionNotes, releaseNotesKey, updatesKey } from "./release-notes";
18
18
 
19
- export const updatesKey = ["follow-up", "updates"];
19
+ export { updatesKey };
20
20
 
21
21
  /** The server's updates view. Reading it never asks the registry; `check` does (rate-limited on the server). */
22
22
  export function useUpdates(check?: "settings") {
@@ -140,8 +140,8 @@ export function UpdatesSections({ theme, compact }: { theme: Theme; compact: boo
140
140
  const c = theme.colors; const t = text(c);
141
141
  const query = useUpdates("settings");
142
142
  const write = useRpc(setUpdatesRpc); const cache = useQueryClient(); const toast = useToast();
143
- // null: closed; false: What's new (since the last update); true: every version.
144
- const [sheet, setSheet] = useState<boolean | null>(null);
143
+ // What's new: every version in one scroll, opened at the newest, from the status card or Release notes.
144
+ const [sheet, setSheet] = useState(false);
145
145
  // The What's new gate reads the switch from the release notes view, so a change refreshes that too.
146
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)) });
147
147
  const view = query.data;
@@ -149,7 +149,7 @@ export function UpdatesSections({ theme, compact }: { theme: Theme; compact: boo
149
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>;
150
150
  return <View style={{ gap: 18 }}>
151
151
  <SettingsSection title="Updates">
152
- <StatusCard view={view} theme={theme} compact={compact} onWhatsNew={() => setSheet(false)} />
152
+ <StatusCard view={view} theme={theme} compact={compact} onWhatsNew={() => setSheet(true)} />
153
153
  <MoveLine view={view} theme={theme} compact={compact} />
154
154
  </SettingsSection>
155
155
  <SettingsSection title={view.installKind === "npm" ? "How Follow-up updates" : "Release notes"}>
@@ -171,7 +171,7 @@ export function UpdatesSections({ theme, compact }: { theme: Theme; compact: boo
171
171
  {h.reason && <Text style={t.small}>{h.reason}</Text>}
172
172
  </View>)}
173
173
  </Disclosure>}
174
- {sheet != null && <ReleaseNotesSheet theme={theme} compact={compact} all={sheet} onClose={() => setSheet(null)} />}
174
+ {sheet && <ReleaseNotesSheet theme={theme} compact={compact} onClose={() => setSheet(false)} />}
175
175
  </View>;
176
176
  }
177
177
 
package/index.client.tsx CHANGED
@@ -114,7 +114,7 @@ export default function contribute(host: PluginClientContext) {
114
114
  let nextToken = 0;
115
115
  const openNext = (from: string | null) => client.openScreen({ screenId: OVERVIEW, params: { next: String(++nextToken), ...(from ? { from } : {}) } });
116
116
 
117
- const removeDisplay = contributeDisplay(client, { id: "follow-up-overview", title: "Follow-up", Component: sidebarItem(sources, OVERVIEW) });
117
+ const removeDisplay = contributeDisplay(client, { id: "follow-up-overview", title: "Follow-up", Component: sidebarItem(sources, OVERVIEW, { openSettings: category => openSettings(category as SettingsCategory) }) });
118
118
  const briefDeps: BriefDeps = {
119
119
  signOff: agentId => void inbox.signOff([agentId]), openNext,
120
120
  openAgent: agentId => client.openScreen({ screenId: OVERVIEW, params: { next: String(++nextToken), open: agentId } }),
package/index.server.ts CHANGED
@@ -70,6 +70,7 @@ import { Wait, waitStatus, type WaitPaseoConfig } from "./server/wait";
70
70
  import { removeGlobalRegistrations } from "./server/mcp-registrations";
71
71
  import { TrustBypass } from "./server/trust-bypass";
72
72
  import { scopes } from "./server/scopes";
73
+ import { TurnEnd } from "./server/turn-end";
73
74
  import { updateObligation } from "./server/obligations";
74
75
  import { Inbox, INBOX_WRITE_MS, type GuardPause } from "./server/inbox";
75
76
  import { daemonDirectory, guardPath } from "./server/inbox-directory";
@@ -109,6 +110,7 @@ import { newWorkspaceTarget, sendReport, type ReportSendDeps } from "./server/re
109
110
  type ServerInfoClient = { getLastServerInfoMessage?: () => ServerInfo };
110
111
  import { inboxAnswer } from "./server/etag";
111
112
  import { CheckWatches } from "./server/check-watches";
113
+ import { ScheduledTasks } from "./server/scheduled-tasks";
112
114
  import { githubOffChecksAnswer, waitForChecksAnswer } from "./server/wait-for-checks";
113
115
  import { jobAgentRunner, type JobPaseo } from "./server/job-agent";
114
116
  import { AiJobs } from "./server/ai-jobs";
@@ -265,6 +267,17 @@ export default function contribute(server: PluginServerContext) {
265
267
  },
266
268
  });
267
269
  engine.checkWatches = checkWatches;
270
+ // Scheduled tasks (a-scheduled-task-arrives-once-at-its-time): a task's time trigger goes out once, at its time,
271
+ // Auto-send or not; the agent is read the same way as for a checks verdict (no load).
272
+ const scheduledTasks = new ScheduledTasks({
273
+ snapshot: () => store.snapshot(),
274
+ mutateWorkspace: (id, work) => store.mutateWorkspace(id, work),
275
+ agent: async id => {
276
+ const a = gateway.directory.cached(id) ?? (await gateway.directory.read({ fresh: "agents" })).agents.find(r => r.agent.id === id)?.agent;
277
+ return a ? { status: a.status, archived: !!a.archivedAt, workspaceId: a.workspaceId ?? null } : null;
278
+ },
279
+ });
280
+ engine.scheduledTasks = scheduledTasks;
268
281
  engine.wording = { reviewFix: repo => commandName(prWorkflow.reviewFix(repo)) };
269
282
  actions.settleTasks = w => engine.settleTasks(w);
270
283
  const governor = new Governor();
@@ -379,6 +392,7 @@ export default function contribute(server: PluginServerContext) {
379
392
  const queue = new MessageQueue(directory, { deliverTo: (target, text, messageId, by, images) => gateway.deliverTo(target, text, messageId, by, images), arrived: (agentId, messageId, since, marker) => gateway.arrivedMessage(agentId, messageId, since, marker), probe: () => gateway.probe() }, { health: writeHealth, images: imageStore });
380
393
  engine.attachQueue(queue);
381
394
  checkWatches.attachQueue(queue);
395
+ scheduledTasks.attachQueue(queue);
382
396
  inbox.attachQueue(queue);
383
397
  // Overseer forwards and reports handed to an agent: no record of their own, so the queue item is their status
384
398
  // (follow_queue_list). Archived agents cancel, with the reason on the item.
@@ -415,6 +429,31 @@ export default function contribute(server: PluginServerContext) {
415
429
  queue.enqueue({ id: `message:${agentId}:${messageId}`, kind: "message", key, ref: { agentId }, messageId, text, ...(by ? { by } : {}), ...(images.length ? { images } : {}), priority: "now", state: "queued" });
416
430
  };
417
431
  onDaemonReconnect(() => queue.reconnected());
432
+ // Turn-end checks for a provider without Follow-up's hook (server/turn-end.ts): the hook's checks, as one queued message.
433
+ const turnEnd = new TurnEnd({
434
+ input: async (agentId, _provider, _items, _startedAt) => {
435
+ const w = agentTrackedWorkspace(await store.snapshot(), agentId);
436
+ if (!w) return null;
437
+ // Only this workspace's scopes (a-nudge-costs-its-workspace), never the whole state's.
438
+ const entry = scopes({ workspaces: [w] } as unknown as Parameters<typeof scopes>[0])[agentId] ?? null;
439
+ const json = (name: string) => readFile(join(directory, "hook-state", name), "utf8").then(t => JSON.parse(t) as Record<string, unknown>, () => null);
440
+ const synced = await json(`sync-${agentId}.json`);
441
+ const called = await json(`needs-you-${agentId}.json`) as NeedsYouRecord | null;
442
+ const receipt = /^[\w-]+$/.test(w.id) ? await json(`task-nudges-${w.id}.json`) : null;
443
+ const settings = await inboxSettings();
444
+ return {
445
+ entry, receipt: (receipt ?? {}) as never,
446
+ syncedAt: synced && synced.workspaceId === w.id && typeof synced.at === "number" ? synced.at : null,
447
+ needsYouAt: typeof called?.at === "number" ? called.at : null,
448
+ nudge: settings.enable_inbox === true && settings.enable_brief_nudge === true && !inbox.pendingPermissions().includes(agentId),
449
+ };
450
+ },
451
+ saveReceipt: async (workspaceId, receipt) => { if (/^[\w-]+$/.test(workspaceId)) await writeFile(join(directory, "hook-state", `task-nudges-${workspaceId}.json`), JSON.stringify(receipt), { mode: 0o600 }); },
452
+ send: async (agentId, workspaceId, text, turnId) => {
453
+ const messageId = randomUUID();
454
+ queue.enqueue({ id: `turn-end:${agentId}:${turnId ?? messageId}`, kind: "message", key: workspaceId, ref: { agentId }, messageId, text, priority: "now", state: "queued" });
455
+ },
456
+ });
418
457
  /**
419
458
  * Stores a field's pasted images, runs the action with their refs, and removes any the action didn't queue (a
420
459
  * repeated answer, an ask already open, a refusal): only a queue item keeps an image file.
@@ -1221,21 +1260,21 @@ export default function contribute(server: PluginServerContext) {
1221
1260
  // What's new and Settings → General. Follow-up's own install comes from Paseo's plugin list, read once per worker.
1222
1261
  const versions = new VersionsStore(directory);
1223
1262
  const updatesStore = new UpdatesStore(directory);
1224
- let self: Promise<SelfInstall & { name: string | null; notes: ReleaseNote[] }> | null = null;
1263
+ let self: Promise<SelfInstall & { name: string | null; notes: ReleaseNote[]; releases: string | null }> | null = null;
1225
1264
  const selfInstall = () => self ??= withDaemon(async c => describeSelf(await c.listPlugins?.() ?? [])).then(async row => {
1226
- const pkg = row.path ? await readPackage(row.path) : { version: null, name: null, notes: [] };
1265
+ const pkg = row.path ? await readPackage(row.path) : { version: null, name: null, notes: [], releases: null };
1227
1266
  const version = pkg.version ?? row.version;
1228
1267
  if (!version) throw new Error("Paseo's plugin list doesn't show Follow-up's version yet.");
1229
1268
  // Fresh or existing comes from setup's own record, decided once before anything else wrote state.
1230
1269
  const existing = await onboarding.init().then(f => f.install === "existing", () => true);
1231
1270
  await versions.started(version, existing).catch(() => undefined);
1232
- return { ...row, version, name: pkg.name, notes: pkg.notes };
1271
+ return { ...row, version, name: pkg.name, notes: pkg.notes, releases: pkg.releases };
1233
1272
  }).catch(error => { self = null; throw error; });
1234
1273
  // Record the version at start (in the background), so "Updated to X 2h ago" counts from the reload, not first view.
1235
1274
  void ready.then(() => selfInstall()).catch(() => undefined);
1236
1275
  const releaseNotesView = async (): Promise<ReleaseNotesView> => {
1237
1276
  const [me, file, updates] = await Promise.all([selfInstall(), versions.read(), updatesStore.read()]);
1238
- 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 });
1277
+ 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, releases: me.releases });
1239
1278
  };
1240
1279
  handle(rpc.releaseNotesRpc, async () => releaseNotesView());
1241
1280
  handle(rpc.whatsNewSeenRpc, async ({ version }) => { await versions.seen(version); return releaseNotesView(); });
@@ -2100,6 +2139,7 @@ export default function contribute(server: PluginServerContext) {
2100
2139
  // The shared directory learns from events instead of polling Paseo (see DaemonDirectory). Registered first so the
2101
2140
  // handlers below read the patched rows.
2102
2141
  server.on("agent.turn_started", async event => gateway.directory.turnStarted(event.agent, event.turnId)),
2142
+ server.on("agent.turn_started", async event => turnEnd.turnStarted(event.agent.id)),
2103
2143
  server.on("agent.turn_ended", async event => gateway.directory.turnEnded(event.agent, event.outcome)),
2104
2144
  server.on("agent.turn_ended", async event => contextRequests.turnEnded(event.agent.id)),
2105
2145
  server.on("agent.permission_requested", async event => gateway.directory.permissionRequested(event.agent.id, event.request as { id?: string })),
@@ -2206,6 +2246,8 @@ export default function contribute(server: PluginServerContext) {
2206
2246
  const compaction = event.outcome.kind === "canceled" && await compactionJustDelivered(event.agent.id, Date.parse(interruption!.at)).catch(() => false);
2207
2247
  const nudged = await turnEnded(store, event.agent.id, event.outcome, event.turnId ?? null, items, { interruption, guarded, newerTurn, compaction });
2208
2248
  if (nudged) void engine.nudge(nudged);
2249
+ // A provider without the hook: the Stop hook's checks, from this same read (an-agent-on-any-provider-gets-follow-up).
2250
+ await turnEnd.turnEnded(event.agent, event.outcome, event.turnId ?? null, items).catch(() => undefined);
2209
2251
  }),
2210
2252
  server.on("workspace.archived", async event => { await ready; if (!loadError && !stopped) await store.mutate(state => { const w = state.workspaces.find(w => w.id === event.workspace.id); if (w) w.archived = true; }); }),
2211
2253
  ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paseo-follow-up",
3
3
  "private": false,
4
- "version": "2.4.2",
4
+ "version": "2.6.0-beta.1",
5
5
  "description": "Every agent, one inbox. Follow-up brings what all your coding agents need from you into one ranked list, and follows their work through merge, deploy and after.",
6
6
  "type": "module",
7
7
  "files": [
@@ -35,16 +35,18 @@ export function toolsDetached(isNative, current, mine) { return isNative && !!cu
35
35
  export const detachedNotice = "Follow-up was updated while this session was open, so its follow_* tools are detached and fail with \"Tool not found\" until this session reopens (Paseo reopens it before your next prompt). Until then use the bridge, which runs the same tools with their unprefixed names: node \"$FOLLOW_UP_CLI\" call <tool> '<json>' --compact (for example sync_workspace or needs_you). Do not mention this to the developer.";
36
36
  const quietRevision = 1;
37
37
  const quietInstruction = "Do routine bookkeeping silently. Do not announce tracker calls, say you updated/synced the sidebar, recap panel state, or add plugin-status commentary/final paragraphs. Put receipts and evidence in the tools. User-facing messages should cover the actual work outcome, or a decision/blocker requiring the developer; answer sidebar status only when explicitly asked. If this continuation is bookkeeping only, use the tools and finish without another recap or repeating your previous answer.";
38
- const stopReason = "Silently complete this workspace's sidebar bookkeeping before finishing.";
38
+ export const stopReason = "Silently complete this workspace's sidebar bookkeeping before finishing.";
39
39
  // Kept identical to NEEDS_YOU_NUDGE in shared/brief.ts (a test checks it).
40
- const nudgeReason = "Before you stop, call needs_you once with what the developer has to do next: a decision with options (or questions=[\"Q18\"] for one that is already an open question), an action only they can take, or kind=done (\"Nothing needed\" plus what you finished), which means nothing for the developer and won't flag you. Then stop; don't repeat your reply.";
40
+ export const nudgeReason = "Before you stop, call needs_you once with what the developer has to do next: a decision with options (or questions=[\"Q18\"] for one that is already an open question), an action only they can take, or kind=done (\"Nothing needed\" plus what you finished), which means nothing for the developer and won't flag you. Then stop; don't repeat your reply.";
41
41
 
42
42
  /**
43
43
  * R2: whether to nudge a Claude Code root agent that ended its turn without needs_you. Pure, so every skip is testable.
44
44
  * At most once per turn: Claude's stop_hook_active and our own per-turn `stopped` marker both end it.
45
45
  */
46
46
  /** due-by-fact: the line above the due tasks a turn end names. */
47
- const dueHeader = "Follow-up: these tasks are due. For each, do it and close it with update_obligation (status=done with evidence), or keep it with recheck=\"YYYY-MM-DD\" and why in evidence.";
47
+ /** The first line of the turn-end message a provider without this hook gets instead (server/turn-end.ts). */
48
+ export const turnEndPrefix = "Follow-up turn-end check:";
49
+ export const dueHeader = "Follow-up: these tasks are due. For each, do it and close it with update_obligation (status=done with evidence), or keep it with recheck=\"YYYY-MM-DD\" and why in evidence.";
48
50
  /**
49
51
  * The due tasks to name at this turn end: due entries (from scopes.json) whose time passed, not yet named twice for
50
52
  * this fact and revision and not within a day, oldest first, at most 3; and the receipt counting them. A copy of
@@ -216,7 +218,7 @@ function paragraphs(lease, contributor, workflow, directory) {
216
218
  "If you keep a Claude artifact (or doc) summarizing this workspace's goal, decisions and status, register its link once with set_spec after the first publish. Republish to the same URL; call set_spec again only if the link changes.",
217
219
  "Keep actual follow-up tasks current with update_obligation: production behavior checks, migrations and decisions, with concise titles, PR dependencies and evidence. Do not add merge/approval/deploy checklist tasks. Deployment-dependent work waits for verified serving revisions and existing production permissions. A task waiting on a PR or another agent is status=waiting; blocked is only for the developer. One decision, one card: ask it once with ask_question (task set to the task), then mark the task blocked with question=\"Q<n>\"; ask= is only for a decision you haven't asked, and need=action when the developer must do something and tell you (the card gets Done). Follow-up shows a blocked task and your turn-end needs_you about it as one item. Once it is answered, act on the answer and move the task.",
218
220
  "Stakeholder replies are follow-up too. When asked to update a requester, capture the original Slack threadUrl, recipient and explicit developer authorization in the task's communication field; referenced messages alone do not authorize posting. Use a concise progress task now and, when needed, a verify-and-reply task with purpose=verified after the relevant deployed PRs. Read existing thread replies and refresh evidence before posting; distinguish fixed, deployed and verified. Record the actual sent replyUrl and result before marking done. If posting is unavailable or its outcome is uncertain, keep the task blocked and check the thread before any retry; never claim a draft was sent. Auto authorizes delivery to you, not external messages. Communication-only requests do not authorize repairs, benchmarks, migrations or other production writes.",
219
- "A task comes due by itself when its afterPrs reach dependencyStage, or on its recheck date (update_obligation recheck=\"YYYY-MM-DD\"; a task with no PRs defaults to 3 days after your last update). At your turn\u2019s end Follow-up names due tasks: do each and close it with evidence, or keep it with a new recheck and why. A trigger={event:\"now\"|\"merge\"|\"deploy\",delayDays:0} also sends a task to you as a message; set one only from the developer\u2019s requested timing; never infer timing from a title or enable_follow_up alone. Merge/deploy triggers require owned afterPrs; delayDays=14 waits fourteen days after the last dependency event. Now requires no PR dependencies or delay. Deployment timing starts at the first verified fully serving observation and remains conservative when history is unknown. Preserve existing trigger fields on updates; trigger=null removes it. Auto controls delivery, not timing or production permissions.",
221
+ "A task comes due by itself when its afterPrs reach dependencyStage, or on its recheck date (update_obligation recheck=\"YYYY-MM-DD\"; a task with no PRs defaults to 3 days after your last update). At your turn\u2019s end Follow-up names due tasks: do each and close it with evidence, or keep it with a new recheck and why. A trigger={event:\"now\"|\"merge\"|\"deploy\",delayDays:0} also sends a task to you as a message; set one only from the developer\u2019s requested timing; never infer timing from a title or enable_follow_up alone. trigger={event:\"at\",at:\"<ISO time with offset>\"} or {event:\"at\",inMinutes:30} sends it to you once at that time, Auto-send on or off: set it from a time the developer named, or yourself on a waiting task to check back on something Follow-up can\u2019t see (a registry, a release window, a reply); never a sleep loop or a timer of your own (CI: wait_for_checks). Merge/deploy triggers require owned afterPrs; delayDays=14 waits fourteen days after the last dependency event. Now requires no PR dependencies or delay. Deployment timing starts at the first verified fully serving observation and remains conservative when history is unknown. Preserve existing trigger fields on updates; trigger=null removes it. Auto controls delivery, not timing or production permissions.",
220
222
  batchParagraph(workflow) + " For post-deploy tasks, verify the currently serving revision contains every dependency and record behavioral results separately. Acknowledge the header's batch ID with acknowledge_batch before finishing: completed with the result, or blocked with the reason (humanOnly=true when only a person can move it, such as a stale review the reviewer must re-review or dismiss). Verify the entire goal and post-merge work before declare_done; acknowledge a completion batch first. " + mergeLine(workflow),
221
223
  "Before ending this turn, reconcile the sidebar with what you actually did and call sync_workspace with a short summary, including when no changes are needed. Acknowledge any assigned batch. When the entire goal is fulfilled, use declare_done; otherwise preserve remaining work. Do not launch recovery, start queued repairs, merge, toggle merge-when-ready, or archive as part of this bookkeeping. Auto still governs separate follow-up sends. Subagents report to the main agent instead of claiming workspace ownership.",
222
224
  `Prefer the native follow-up MCP tools. For a full historical record, use workspace_status with detail=full. CLI compatibility fallback: FOLLOW_UP_CLIENT_ENTRY=${quote(lease.clientEntry)} node ${quote(join(directory, "mcp.mjs"))} call <tool> '<json>' --compact. Omit --compact only when an existing script needs the full response. Never ask the developer to maintain the sidebar or run this bridge.`,
@@ -5,7 +5,7 @@ import { ONBOARDING_ACTIONS, ONBOARDING_STEPS } from "../shared/onboarding";
5
5
  import { setPrWorkflowInputSchema } from "../shared/pr-workflow";
6
6
  import { prStatsInputSchema, setPrStatsInputSchema, statsRepoName } from "../shared/pr-stats-settings";
7
7
  import { reviewerListSchema } from "../shared/reviewers";
8
- import { taskTriggerSchema } from "../shared/task-trigger";
8
+ import { taskTriggerInputSchema } from "../shared/task-trigger";
9
9
  import { UPDATE_MODES } from "../shared/updates";
10
10
  import { briefChoiceSchema, reportKindSchema } from "../shared/contracts";
11
11
  import { actionChangeSchema, settingsChangeSchema } from "../shared/dispatch";
@@ -126,7 +126,7 @@ export const RPC_TOOLS: readonly RpcTool[] = [
126
126
  { name: "set_workspace_spec", rpc: "follow.workspace-spec", kind: "planned",
127
127
  input: z.strictObject({ workspaceId: id.optional(), action: z.enum(["set", "remove", "reset"]).optional(), url: z.string().trim().min(1).max(2000).optional(), title: z.string().trim().max(120).nullable().optional(), ...confirm }) },
128
128
  { name: "set_task_trigger", rpc: "follow.set-task-trigger", kind: "planned",
129
- input: z.strictObject({ workspaceId: id.optional(), obligationId: id.optional(), expectedRevision: z.number().int().nonnegative().optional(), trigger: taskTriggerSchema.nullable().optional(), afterPrs: z.array(id).optional(), ...confirm }),
129
+ input: z.strictObject({ workspaceId: id.optional(), obligationId: id.optional(), expectedRevision: z.number().int().nonnegative().optional(), trigger: taskTriggerInputSchema.strict().nullable().optional(), afterPrs: z.array(id).optional(), ...confirm }),
130
130
  toRpc: a => ({ workspaceId: a.workspaceId, obligationId: a.obligationId, expectedRevision: a.expectedRevision, trigger: a.trigger ?? null, afterPrs: a.afterPrs ?? [] }) },
131
131
  // Linked items: the list sheet (read, Add link, remove, Undo) for any workspace
132
132
  { name: "link_items", rpc: "follow.linked-items", kind: "read", input: z.strictObject({ workspaceId: id }) },
package/server/ai-jobs.ts CHANGED
@@ -5,6 +5,7 @@ import { basename, dirname, join } from "node:path";
5
5
  import type { z } from "zod";
6
6
  import { guardFor, refusedCalls, type ToolGrant } from "./job-guard";
7
7
  import { guardedProvider } from "../shared/agent-settings";
8
+ import { GUARDED_PHRASE } from "../shared/provider-support";
8
9
 
9
10
  /**
10
11
  * Small bounded model jobs: a prompt in, validated JSON out. Shared by Summaries and the Overseer ranker.
@@ -25,7 +26,7 @@ export type JobSpec<T> = {
25
26
  prompt: string;
26
27
  schema: z.ZodType<T>;
27
28
  system?: string;
28
- /** Any Paseo provider id; "claude" (default) and "codex" run through their headless CLI, the rest as a hidden agent. */
29
+ /** Any Paseo provider id; "claude" (default), "codex" and "pi" run through their headless CLI, the rest as a hidden agent. */
29
30
  provider?: string;
30
31
  /** The provider's model: "haiku" (Claude's default here), "sonnet", "gpt-6-luna"… */
31
32
  model?: string;
@@ -40,7 +41,7 @@ export type JobSpec<T> = {
40
41
  runner?: Runner;
41
42
  /**
42
43
  * The prompt carries words someone else wrote (an issue, a thread, a chat, a plan, mail). Such a job runs only on a
43
- * provider Follow-up can take every tool away from (`guardedProvider`); on any other it is refused before it starts
44
+ * provider Follow-up can take every tool away from (`guardedProvider`, shared/provider-support.ts); on any other it is refused before it starts
44
45
  * (a-job-that-reads-outside-content-can-only-read).
45
46
  */
46
47
  outside?: boolean;
@@ -87,7 +88,7 @@ export class AiJobs {
87
88
  if (this.stopped) return done({ ok: false, reason: "stopped", error: "Follow-up is stopping.", costUsd: null, durationMs: 0 });
88
89
  const provider = spec.provider ?? "claude";
89
90
  // Someone else's words never reach a model that has tools: refused before any runner, the tests' included.
90
- if (spec.outside && !guardedProvider(provider)) return done({ ok: false, reason: "unguarded", error: `This job reads words other people wrote, and Follow-up can't take ${provider}'s tools away. Pick Claude or Codex in Settings → Agents.`, costUsd: null, durationMs: 0 });
91
+ if (spec.outside && !guardedProvider(provider)) return done({ ok: false, reason: "unguarded", error: `This job reads words other people wrote, and Follow-up can't take ${provider}'s tools away. Pick ${GUARDED_PHRASE} in Settings → Agents.`, costUsd: null, durationMs: 0 });
91
92
  // An injected runner (tests) always wins, so a job can never reach the real CLI from a test; then the job's own.
92
93
  const runner = this.opts.runner ?? spec.runner ?? this.opts.runners?.[provider] ?? defaultRunner(provider) ?? this.opts.generic;
93
94
  if (!runner) return done({ ok: false, reason: "failed", error: `${provider} can't run one-shot jobs here; pick another provider in Settings → Agents.`, costUsd: null, durationMs: 0 });
@@ -185,10 +186,30 @@ export function parseCodexEvents(stdout: string): RunOutput {
185
186
  }
186
187
  const codexError = (raw: string) => { try { const j = JSON.parse(raw); return String(j?.error?.message ?? raw).slice(0, 200); } catch { return raw.slice(0, 200); } };
187
188
 
188
- /** Claude's own default for jobs; Codex uses its CLI default when no model is set. */
189
+ /**
190
+ * `pi -p` with no tools at all and nothing loaded from the developer's setup: no extensions, skills, prompt templates
191
+ * or context files, no saved session (flags from Pi's README). The prompt goes on stdin, which print mode merges into
192
+ * the message; the reply is the printed text. Pi reports no cost.
193
+ */
194
+ export function piArgs(input: Pick<RunInput, "model" | "system"> & { thinking?: string | null }): string[] {
195
+ return ["-p", "--no-tools", "--no-extensions", "--no-skills", "--no-prompt-templates", "--no-context-files", "--no-session",
196
+ ...(input.model ? ["--model", input.model] : []), ...(input.thinking ? ["--thinking", input.thinking] : []), "--system-prompt", input.system,
197
+ "Answer the material below as the system prompt says."];
198
+ }
199
+ export function parsePiOutput(stdout: string): RunOutput {
200
+ if (!stdout.trim()) throw new Error("Pi returned no reply.");
201
+ return { text: stdout, costUsd: null, inputTokens: null, outputTokens: null };
202
+ }
203
+ /** Spawns `pi` the same way as the other CLIs: an argument array, the prompt on stdin, from the temp dir. */
204
+ export function piRunner(command = "pi"): Runner {
205
+ return input => spawnJob(command, piArgs(input), input.prompt, parsePiOutput, input, childEnv({}, {}));
206
+ }
207
+
208
+ /** Claude's own default for jobs; Codex and Pi use their CLI default when no model is set. */
189
209
  export const DEFAULT_MODEL: Record<string, string> = { claude: "haiku" };
210
+ /** The providers whose own CLI runs a job with no tools (shared/provider-support.ts CLI_GUARD_PROVIDERS). */
190
211
  export function defaultRunner(provider: string): Runner | null {
191
- return provider === "claude" ? claudeRunner() : provider === "codex" ? codexRunner() : null;
212
+ return provider === "claude" ? claudeRunner() : provider === "codex" ? codexRunner() : provider === "pi" ? piRunner() : null;
192
213
  }
193
214
 
194
215
  /** The envelope of a one-turn reply is a few KB; anything near this is runaway output. */
package/server/engine.ts CHANGED
@@ -15,6 +15,7 @@ import { ACTIVE_SCOPE_MIGRATION, followsByDefault, migrateActiveScope } from "..
15
15
  import { replyRecorded } from "../shared/communication";
16
16
  import { DeliveryDeferred, ConversationGone } from "./delivery";
17
17
  import type { CheckWatches } from "./check-watches";
18
+ import type { ScheduledTasks } from "./scheduled-tasks";
18
19
  import type { MessageQueue, Resolution, Target } from "./message-queue";
19
20
  import type { ImageRef } from "../shared/images";
20
21
  import { PASEO_UNREACHABLE, deliveryOf, type NewQueueItem, type QueueItem, type QueueItemInput } from "../shared/queue";
@@ -414,9 +415,12 @@ export class Engine {
414
415
  * never from a read of their own (waiting-for-checks-adds-no-github-read). A nudge's pass judges only its workspaces.
415
416
  */
416
417
  checkWatches: Pick<CheckWatches, "watched" | "evaluate"> | null = null;
418
+ /** Scheduled tasks (server/scheduled-tasks.ts): a task's time trigger fires from the pass its due time started. */
419
+ scheduledTasks: Pick<ScheduledTasks, "evaluate"> | null = null;
417
420
  private async afterPass(affected?: ReadonlySet<string>): Promise<void> {
418
- if (!this.checkWatches || this.stopped) return;
419
- await this.checkWatches.evaluate(affected).catch(error => console.warn(`[follow-up] couldn't check the waits for checks: ${error instanceof Error ? error.message : String(error)}`));
421
+ if (this.stopped) return;
422
+ if (this.checkWatches) await this.checkWatches.evaluate(affected).catch(error => console.warn(`[follow-up] couldn't check the waits for checks: ${error instanceof Error ? error.message : String(error)}`));
423
+ if (this.scheduledTasks && !this.stopped) await this.scheduledTasks.evaluate(affected).catch(error => console.warn(`[follow-up] couldn't send the scheduled tasks: ${error instanceof Error ? error.message : String(error)}`));
420
424
  }
421
425
  /**
422
426
  * A nudge's discovery (a-nudge-costs-its-workspace): only the nudged workspaces and their dirty agents (the kept turn
@@ -37,16 +37,18 @@ export const hookSource: string = [
37
37
  "export const detachedNotice = \"Follow-up was updated while this session was open, so its follow_* tools are detached and fail with \\\"Tool not found\\\" until this session reopens (Paseo reopens it before your next prompt). Until then use the bridge, which runs the same tools with their unprefixed names: node \\\"$FOLLOW_UP_CLI\\\" call <tool> '<json>' --compact (for example sync_workspace or needs_you). Do not mention this to the developer.\";",
38
38
  "const quietRevision = 1;",
39
39
  "const quietInstruction = \"Do routine bookkeeping silently. Do not announce tracker calls, say you updated/synced the sidebar, recap panel state, or add plugin-status commentary/final paragraphs. Put receipts and evidence in the tools. User-facing messages should cover the actual work outcome, or a decision/blocker requiring the developer; answer sidebar status only when explicitly asked. If this continuation is bookkeeping only, use the tools and finish without another recap or repeating your previous answer.\";",
40
- "const stopReason = \"Silently complete this workspace's sidebar bookkeeping before finishing.\";",
40
+ "export const stopReason = \"Silently complete this workspace's sidebar bookkeeping before finishing.\";",
41
41
  "// Kept identical to NEEDS_YOU_NUDGE in shared/brief.ts (a test checks it).",
42
- "const nudgeReason = \"Before you stop, call needs_you once with what the developer has to do next: a decision with options (or questions=[\\\"Q18\\\"] for one that is already an open question), an action only they can take, or kind=done (\\\"Nothing needed\\\" plus what you finished), which means nothing for the developer and won't flag you. Then stop; don't repeat your reply.\";",
42
+ "export const nudgeReason = \"Before you stop, call needs_you once with what the developer has to do next: a decision with options (or questions=[\\\"Q18\\\"] for one that is already an open question), an action only they can take, or kind=done (\\\"Nothing needed\\\" plus what you finished), which means nothing for the developer and won't flag you. Then stop; don't repeat your reply.\";",
43
43
  "",
44
44
  "/**",
45
45
  " * R2: whether to nudge a Claude Code root agent that ended its turn without needs_you. Pure, so every skip is testable.",
46
46
  " * At most once per turn: Claude's stop_hook_active and our own per-turn `stopped` marker both end it.",
47
47
  " */",
48
48
  "/** due-by-fact: the line above the due tasks a turn end names. */",
49
- "const dueHeader = \"Follow-up: these tasks are due. For each, do it and close it with update_obligation (status=done with evidence), or keep it with recheck=\\\"YYYY-MM-DD\\\" and why in evidence.\";",
49
+ "/** The first line of the turn-end message a provider without this hook gets instead (server/turn-end.ts). */",
50
+ "export const turnEndPrefix = \"Follow-up turn-end check:\";",
51
+ "export const dueHeader = \"Follow-up: these tasks are due. For each, do it and close it with update_obligation (status=done with evidence), or keep it with recheck=\\\"YYYY-MM-DD\\\" and why in evidence.\";",
50
52
  "/**",
51
53
  " * The due tasks to name at this turn end: due entries (from scopes.json) whose time passed, not yet named twice for",
52
54
  " * this fact and revision and not within a day, oldest first, at most 3; and the receipt counting them. A copy of",
@@ -218,7 +220,7 @@ export const hookSource: string = [
218
220
  " \"If you keep a Claude artifact (or doc) summarizing this workspace's goal, decisions and status, register its link once with set_spec after the first publish. Republish to the same URL; call set_spec again only if the link changes.\",",
219
221
  " \"Keep actual follow-up tasks current with update_obligation: production behavior checks, migrations and decisions, with concise titles, PR dependencies and evidence. Do not add merge/approval/deploy checklist tasks. Deployment-dependent work waits for verified serving revisions and existing production permissions. A task waiting on a PR or another agent is status=waiting; blocked is only for the developer. One decision, one card: ask it once with ask_question (task set to the task), then mark the task blocked with question=\\\"Q<n>\\\"; ask= is only for a decision you haven't asked, and need=action when the developer must do something and tell you (the card gets Done). Follow-up shows a blocked task and your turn-end needs_you about it as one item. Once it is answered, act on the answer and move the task.\",",
220
222
  " \"Stakeholder replies are follow-up too. When asked to update a requester, capture the original Slack threadUrl, recipient and explicit developer authorization in the task's communication field; referenced messages alone do not authorize posting. Use a concise progress task now and, when needed, a verify-and-reply task with purpose=verified after the relevant deployed PRs. Read existing thread replies and refresh evidence before posting; distinguish fixed, deployed and verified. Record the actual sent replyUrl and result before marking done. If posting is unavailable or its outcome is uncertain, keep the task blocked and check the thread before any retry; never claim a draft was sent. Auto authorizes delivery to you, not external messages. Communication-only requests do not authorize repairs, benchmarks, migrations or other production writes.\",",
221
- " \"A task comes due by itself when its afterPrs reach dependencyStage, or on its recheck date (update_obligation recheck=\\\"YYYY-MM-DD\\\"; a task with no PRs defaults to 3 days after your last update). At your turn\\u2019s end Follow-up names due tasks: do each and close it with evidence, or keep it with a new recheck and why. A trigger={event:\\\"now\\\"|\\\"merge\\\"|\\\"deploy\\\",delayDays:0} also sends a task to you as a message; set one only from the developer\\u2019s requested timing; never infer timing from a title or enable_follow_up alone. Merge/deploy triggers require owned afterPrs; delayDays=14 waits fourteen days after the last dependency event. Now requires no PR dependencies or delay. Deployment timing starts at the first verified fully serving observation and remains conservative when history is unknown. Preserve existing trigger fields on updates; trigger=null removes it. Auto controls delivery, not timing or production permissions.\",",
223
+ " \"A task comes due by itself when its afterPrs reach dependencyStage, or on its recheck date (update_obligation recheck=\\\"YYYY-MM-DD\\\"; a task with no PRs defaults to 3 days after your last update). At your turn\\u2019s end Follow-up names due tasks: do each and close it with evidence, or keep it with a new recheck and why. A trigger={event:\\\"now\\\"|\\\"merge\\\"|\\\"deploy\\\",delayDays:0} also sends a task to you as a message; set one only from the developer\\u2019s requested timing; never infer timing from a title or enable_follow_up alone. trigger={event:\\\"at\\\",at:\\\"<ISO time with offset>\\\"} or {event:\\\"at\\\",inMinutes:30} sends it to you once at that time, Auto-send on or off: set it from a time the developer named, or yourself on a waiting task to check back on something Follow-up can\\u2019t see (a registry, a release window, a reply); never a sleep loop or a timer of your own (CI: wait_for_checks). Merge/deploy triggers require owned afterPrs; delayDays=14 waits fourteen days after the last dependency event. Now requires no PR dependencies or delay. Deployment timing starts at the first verified fully serving observation and remains conservative when history is unknown. Preserve existing trigger fields on updates; trigger=null removes it. Auto controls delivery, not timing or production permissions.\",",
222
224
  " batchParagraph(workflow) + \" For post-deploy tasks, verify the currently serving revision contains every dependency and record behavioral results separately. Acknowledge the header's batch ID with acknowledge_batch before finishing: completed with the result, or blocked with the reason (humanOnly=true when only a person can move it, such as a stale review the reviewer must re-review or dismiss). Verify the entire goal and post-merge work before declare_done; acknowledge a completion batch first. \" + mergeLine(workflow),",
223
225
  " \"Before ending this turn, reconcile the sidebar with what you actually did and call sync_workspace with a short summary, including when no changes are needed. Acknowledge any assigned batch. When the entire goal is fulfilled, use declare_done; otherwise preserve remaining work. Do not launch recovery, start queued repairs, merge, toggle merge-when-ready, or archive as part of this bookkeeping. Auto still governs separate follow-up sends. Subagents report to the main agent instead of claiming workspace ownership.\",",
224
226
  " `Prefer the native follow-up MCP tools. For a full historical record, use workspace_status with detail=full. CLI compatibility fallback: FOLLOW_UP_CLIENT_ENTRY=${quote(lease.clientEntry)} node ${quote(join(directory, \"mcp.mjs\"))} call <tool> '<json>' --compact. Omit --compact only when an existing script needs the full response. Never ask the developer to maintain the sidebar or run this bridge.`,",
@@ -4,7 +4,7 @@ import type { Runner, RunInput } from "./ai-jobs";
4
4
 
5
5
  /**
6
6
  * One-shot jobs on any Paseo provider: the job runs as a short-lived agent in a background workspace, so it never shows
7
- * in the developer's workspace or agent lists, and is archived as soon as it answers. Claude and Codex keep their
7
+ * in the developer's workspace or agent lists, and is archived as soon as it answers. Claude, Codex and Pi keep their
8
8
  * headless CLI fast path (ai-jobs.ts); this is for every other provider.
9
9
  *
10
10
  * Paseo 0.15.2 refuses `internal` agents from clients ("create a background workspace instead"), so a background
@@ -33,6 +33,17 @@ export type JobAgentOptions = {
33
33
  directory: string;
34
34
  };
35
35
 
36
+ /**
37
+ * A job agent gets no tools wherever its provider can be told so (shared/provider-support.ts SESSION_GUARD_PROVIDERS):
38
+ * OpenCode takes a session permission rule, and Paseo turns `permission: "deny"` into `*` denied for every tool, its
39
+ * own MCP tools included, before any prompt; Auto Accept stays off (Paseo turns it on for an unattended agent
40
+ * otherwise). A job never needs a tool, so every job there is locked, not only one that reads other people's words.
41
+ * Belt and braces: a job that still asks for a permission fails and is archived (status "permission").
42
+ */
43
+ export function lockedConfig(provider: string): Record<string, unknown> {
44
+ return provider === "opencode" ? { providerOptions: { permission: "deny", auto_accept: false } } : {};
45
+ }
46
+
36
47
  /** The provider string Paseo's agent config takes: "opencode/qwen3-coder", or the provider alone for its default model. */
37
48
  export const providerModel = (provider: string, model: string) => model ? `${provider}/${model}` : provider;
38
49
 
@@ -54,7 +65,7 @@ export function jobAgentRunner(opts: JobAgentOptions): Runner {
54
65
  };
55
66
  const create = async (paseo: JobPaseo, input: RunInput) => {
56
67
  const options = {
57
- config: { provider: providerModel(input.provider, input.model), systemPrompt: input.system, ...(input.thinking ? { thinkingOptionId: input.thinking } : {}) },
68
+ config: { provider: providerModel(input.provider, input.model), systemPrompt: input.system, ...(input.thinking ? { thinkingOptionId: input.thinking } : {}), ...lockedConfig(input.provider) },
58
69
  title: `${JOBS_TITLE}: one-shot`, labels: { [JOB_LABEL]: "1" }, prompt: input.prompt, autoArchive: true,
59
70
  };
60
71
  // A saved workspace can be archived or gone (a fresh Paseo home): make a new one once, then give up.