paseo-follow-up 2.4.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.server.ts CHANGED
@@ -109,6 +109,7 @@ import { newWorkspaceTarget, sendReport, type ReportSendDeps } from "./server/re
109
109
  type ServerInfoClient = { getLastServerInfoMessage?: () => ServerInfo };
110
110
  import { inboxAnswer } from "./server/etag";
111
111
  import { CheckWatches } from "./server/check-watches";
112
+ import { ScheduledTasks } from "./server/scheduled-tasks";
112
113
  import { githubOffChecksAnswer, waitForChecksAnswer } from "./server/wait-for-checks";
113
114
  import { jobAgentRunner, type JobPaseo } from "./server/job-agent";
114
115
  import { AiJobs } from "./server/ai-jobs";
@@ -265,6 +266,17 @@ export default function contribute(server: PluginServerContext) {
265
266
  },
266
267
  });
267
268
  engine.checkWatches = checkWatches;
269
+ // Scheduled tasks (a-scheduled-task-arrives-once-at-its-time): a task's time trigger goes out once, at its time,
270
+ // Auto-send or not; the agent is read the same way as for a checks verdict (no load).
271
+ const scheduledTasks = new ScheduledTasks({
272
+ snapshot: () => store.snapshot(),
273
+ mutateWorkspace: (id, work) => store.mutateWorkspace(id, work),
274
+ agent: async id => {
275
+ const a = gateway.directory.cached(id) ?? (await gateway.directory.read({ fresh: "agents" })).agents.find(r => r.agent.id === id)?.agent;
276
+ return a ? { status: a.status, archived: !!a.archivedAt, workspaceId: a.workspaceId ?? null } : null;
277
+ },
278
+ });
279
+ engine.scheduledTasks = scheduledTasks;
268
280
  engine.wording = { reviewFix: repo => commandName(prWorkflow.reviewFix(repo)) };
269
281
  actions.settleTasks = w => engine.settleTasks(w);
270
282
  const governor = new Governor();
@@ -379,6 +391,7 @@ export default function contribute(server: PluginServerContext) {
379
391
  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
392
  engine.attachQueue(queue);
381
393
  checkWatches.attachQueue(queue);
394
+ scheduledTasks.attachQueue(queue);
382
395
  inbox.attachQueue(queue);
383
396
  // Overseer forwards and reports handed to an agent: no record of their own, so the queue item is their status
384
397
  // (follow_queue_list). Archived agents cancel, with the reason on the item.
@@ -1221,21 +1234,21 @@ export default function contribute(server: PluginServerContext) {
1221
1234
  // What's new and Settings → General. Follow-up's own install comes from Paseo's plugin list, read once per worker.
1222
1235
  const versions = new VersionsStore(directory);
1223
1236
  const updatesStore = new UpdatesStore(directory);
1224
- let self: Promise<SelfInstall & { name: string | null; notes: ReleaseNote[] }> | null = null;
1237
+ let self: Promise<SelfInstall & { name: string | null; notes: ReleaseNote[]; releases: string | null }> | null = null;
1225
1238
  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: [] };
1239
+ const pkg = row.path ? await readPackage(row.path) : { version: null, name: null, notes: [], releases: null };
1227
1240
  const version = pkg.version ?? row.version;
1228
1241
  if (!version) throw new Error("Paseo's plugin list doesn't show Follow-up's version yet.");
1229
1242
  // Fresh or existing comes from setup's own record, decided once before anything else wrote state.
1230
1243
  const existing = await onboarding.init().then(f => f.install === "existing", () => true);
1231
1244
  await versions.started(version, existing).catch(() => undefined);
1232
- return { ...row, version, name: pkg.name, notes: pkg.notes };
1245
+ return { ...row, version, name: pkg.name, notes: pkg.notes, releases: pkg.releases };
1233
1246
  }).catch(error => { self = null; throw error; });
1234
1247
  // Record the version at start (in the background), so "Updated to X 2h ago" counts from the reload, not first view.
1235
1248
  void ready.then(() => selfInstall()).catch(() => undefined);
1236
1249
  const releaseNotesView = async (): Promise<ReleaseNotesView> => {
1237
1250
  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 });
1251
+ 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
1252
  };
1240
1253
  handle(rpc.releaseNotesRpc, async () => releaseNotesView());
1241
1254
  handle(rpc.whatsNewSeenRpc, async ({ version }) => { await versions.seen(version); return releaseNotesView(); });
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "paseo-follow-up",
3
3
  "private": false,
4
- "version": "2.4.1",
5
- "description": "Follows every workspace your coding agents work in until it's done: one list of what needs you.",
4
+ "version": "2.5.0",
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": [
8
8
  "paseo-plugin.json",
package/paseo-plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "follow-up",
3
3
  "name": "Follow-up",
4
4
  "icon": "assets/icon.png",
5
- "description": "Follow every workspace until the work is done: one Home for what needs you, questions you answer anywhere, and repairs that send themselves.",
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
  "media": [
7
7
  "docs/screenshots/follow-up-slide-1-cover.png",
8
8
  "https://cdn.jsdelivr.net/gh/tomgrin10/paseo-follow-up@635e600d3390e23ea786492780755afda591bb45/docs/screenshots/follow-up-demo-v2.mp4",
@@ -216,7 +216,7 @@ function paragraphs(lease, contributor, workflow, directory) {
216
216
  "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
217
  "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
218
  "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.",
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. 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
220
  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
221
  "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
222
  `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/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
@@ -218,7 +218,7 @@ export const hookSource: string = [
218
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.\",",
219
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.\",",
220
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.\",",
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.\",",
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.\",",
222
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),",
223
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.\",",
224
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.`,",
@@ -19,14 +19,14 @@ export const mcpSource: string = [
19
19
  "const integer = { type: \"integer\", minimum: 1 };",
20
20
  "const array = { type: \"array\", items: string };",
21
21
  "const communication = { type: \"object\", properties: { threadUrl: string, recipient: string, purpose: { type: \"string\", enum: [\"progress\", \"verified\"] }, authorization: string, replyUrl: { type: [\"string\", \"null\"] } }, required: [\"threadUrl\", \"recipient\"], additionalProperties: false };",
22
- "const trigger = { type: [\"object\", \"null\"], properties: { event: { type: \"string\", enum: [\"now\", \"merge\", \"deploy\"] }, delayDays: { type: \"integer\", minimum: 0, maximum: 3650 } }, required: [\"event\"], additionalProperties: false };",
22
+ "const trigger = { type: [\"object\", \"null\"], properties: { event: { type: \"string\", enum: [\"now\", \"merge\", \"deploy\", \"at\"] }, delayDays: { type: \"integer\", minimum: 0, maximum: 3650 }, at: { type: \"string\", description: \"event at: an ISO time with its offset, like 2026-11-26T12:15:00+02:00\" }, inMinutes: { type: \"integer\", minimum: 1, maximum: 43200, description: \"event at: this many minutes from now, instead of at\" } }, required: [\"event\"], additionalProperties: false };",
23
23
  "const tools = [",
24
24
  " [\"workspace_status\", \"Read the tracked workspace's durable goal, PRs, tasks, work queue and optional recovery history. Read after compaction. Returns current work by default; detail=full includes complete evidence/history. Normal follow-up does not require recovery.\", \"follow.agent-status\", { detail: { type: \"string\", enum: [\"summary\", \"full\"] } }, []],",
25
25
  " [\"sync_workspace\", \"Silently confirm the sidebar matches your work before finishing, after registering owned PRs and substantive tasks. Call even when no changes are needed. Keep the summary in this tool; never announce sync or recap sidebar/plugin status to the developer. Does not declare Done, run recovery, or start repairs. Tracked root agents only.\", \"follow.sync\", { summary: { ...string, minLength: 1, maxLength: 1000 } }, [\"summary\"]],",
26
26
  " [\"enroll_workspace\", \"Refine this developer-activated workspace's goal. Ownership is initialized by Track this workspace or the project’s default-tracking setting. This tool cannot activate another workspace. Never ask the developer to enter this. Keep the goal concise; new scope reopens completion.\", \"follow.enroll\", { goal: string }, [\"goal\"]],",
27
27
  " [\"register_pr\", \"Register a PR produced by this workspace. Call after every submission. Register parents first; repeat to update its stack or parent after restacking. Supply a disposition for a deliberately closed PR. Set agentMerges: true when you merge this PR yourself (no human review): Follow-up then never asks the developer to add reviewers or merge it, and the workspace reads as waiting on you; set it false to hand the merge back. In a repository set to No review (set_pr_workflow review \\\"none\\\") every PR counts as agentMerges unless you set it false.\", \"follow.register-pr\", { repo: string, number: integer, stack: string, parentNumber: { type: [\"integer\", \"null\"], minimum: 1 }, disposition: string, agentMerges: boolean }, [\"repo\", \"number\", \"stack\"]],",
28
28
  " [\"exclude_stack\", \"Correct an unrelated stack registration. Preserve its PRs and requirements in an exclusion audit; future registration is blocked. reason must cite the scope/ownership evidence. obligationIds may include related tasks without PR dependencies. Keep external dependencies separate from owned work.\", \"follow.exclude-stack\", { stack: string, reason: string, obligationIds: array }, [\"stack\", \"reason\"]],",
29
- " [\"update_obligation\", \"Record concrete follow-up: verification, migrations, decisions or stakeholder replies. Never add approve/merge/deploy checklist tasks. afterPrs uses owner/repo#number keys. A task comes due by itself when its afterPrs reach dependencyStage, or on recheck (\\\"YYYY-MM-DD\\\"; a task with no PRs defaults to 3 days after your last update); at your turn's end Follow-up names due tasks: do them and close with evidence, or keep them with a new recheck and why. trigger={event:\\\"now\\\"|\\\"merge\\\"|\\\"deploy\\\",delayDays:0} also sends the task to you as a message; set it only from the developer’s 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. For Slack replies, communication records the original threadUrl, recipient, purpose (progress or verified), explicit developer authorization and sent replyUrl. Empty authorization never queues a reply; Auto does not authorize external posts. Use a verify-and-reply task after deployment for the final update. Read the thread first; mark blocked when posting is unavailable or uncertain, never treat a draft as sent. Done requires replyUrl and evidence; preserve fields when updating. status=working records you as the agent doing it; pass workingAgentId when another agent (your subagent) is.\", \"follow.obligation\", { id: string, workingAgentId: string, title: string, status: { type: \"string\", enum: [\"pending\", \"waiting\", \"working\", \"blocked\", \"done\", \"waived\"] }, afterPrs: array, dependencyStage: { type: \"string\", enum: [\"merged\", \"deployed\"] }, evidence: string, ask: { ...string, description: \"With blocked, only for a decision you haven't asked: the question the developer must answer (waiting on a PR or agent is status=waiting). Asked already with ask_question? Pass question instead.\" }, question: { type: \"string\", pattern: \"^Q\\\\d+$\", description: \"With blocked: the question (Q<n>) this task waits on, asked with ask_question (task set to this task). No second card is made.\" }, need: { type: \"string\", enum: [\"decision\", \"action\"], description: \"With blocked and ask: decision (they choose; the card takes their answer) or action (they do something and report back, e.g. share a page, approve, log in; the card has Done). Left out: read from the ask.\" }, enable_follow_up: boolean, communication, trigger, recheck: { type: \"string\", description: \"When to look at this task again: \\\"YYYY-MM-DD\\\". Set it when you keep a due task open, with why in evidence.\" }, new: { type: \"boolean\", description: \"Add a separate task even though a similar open one exists.\" } }, [\"title\", \"status\"]],",
29
+ " [\"update_obligation\", \"Record concrete follow-up: verification, migrations, decisions or stakeholder replies. Never add approve/merge/deploy checklist tasks. afterPrs uses owner/repo#number keys. A task comes due by itself when its afterPrs reach dependencyStage, or on recheck (\\\"YYYY-MM-DD\\\"; a task with no PRs defaults to 3 days after your last update); at your turn's end Follow-up names due tasks: do them and close with evidence, or keep them with a new recheck and why. trigger={event:\\\"now\\\"|\\\"merge\\\"|\\\"deploy\\\",delayDays:0} also sends the task to you as a message; set it only from the developer’s 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't 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. For Slack replies, communication records the original threadUrl, recipient, purpose (progress or verified), explicit developer authorization and sent replyUrl. Empty authorization never queues a reply; Auto does not authorize external posts. Use a verify-and-reply task after deployment for the final update. Read the thread first; mark blocked when posting is unavailable or uncertain, never treat a draft as sent. Done requires replyUrl and evidence; preserve fields when updating. status=working records you as the agent doing it; pass workingAgentId when another agent (your subagent) is.\", \"follow.obligation\", { id: string, workingAgentId: string, title: string, status: { type: \"string\", enum: [\"pending\", \"waiting\", \"working\", \"blocked\", \"done\", \"waived\"] }, afterPrs: array, dependencyStage: { type: \"string\", enum: [\"merged\", \"deployed\"] }, evidence: string, ask: { ...string, description: \"With blocked, only for a decision you haven't asked: the question the developer must answer (waiting on a PR or agent is status=waiting). Asked already with ask_question? Pass question instead.\" }, question: { type: \"string\", pattern: \"^Q\\\\d+$\", description: \"With blocked: the question (Q<n>) this task waits on, asked with ask_question (task set to this task). No second card is made.\" }, need: { type: \"string\", enum: [\"decision\", \"action\"], description: \"With blocked and ask: decision (they choose; the card takes their answer) or action (they do something and report back, e.g. share a page, approve, log in; the card has Done). Left out: read from the ask.\" }, enable_follow_up: boolean, communication, trigger, recheck: { type: \"string\", description: \"When to look at this task again: \\\"YYYY-MM-DD\\\". Set it when you keep a due task open, with why in evidence.\" }, new: { type: \"boolean\", description: \"Add a separate task even though a similar open one exists.\" } }, [\"title\", \"status\"]],",
30
30
  " [\"acknowledge_batch\", \"Record a follow-up result. Complete only after verifying all tasks; blocked surfaces the reason to the developer. in_progress when you or your own subagent are already working on these tasks (say where it stands): not a failure, and Follow-up won't send the same tasks again until that work ends or they change on GitHub. Blocked with humanOnly=true when nothing is left for an agent and only a person can move it (a reviewer must re-review or dismiss a stale review, access must be granted): the developer gets a PR item, not an agent failure. When only part of it waits on a person (one thread needs the reviewer's call), name that part in waitingOn with any outcome and carry on with the rest: the developer gets it as a person item, and later messages tell you to leave it. Always acknowledge before ending a repair turn. Keep the result within 2000 characters.\", \"follow.acknowledge\", { batchId: string, outcome: { type: \"string\", enum: [\"completed\", \"blocked\", \"in_progress\"] }, result: { ...string, maxLength: 2000 }, humanOnly: { type: \"boolean\" }, waitingOn: { ...string, maxLength: 500 } }, [\"batchId\", \"outcome\", \"result\"]],",
31
31
  " [\"ask_question\", \"Ask the developer a decision you can't make yourself. Give a short title, the question, lettered options A, B, C… with what each means for them, and recommend the option you'd pick. Set big only when building ahead would send something off this computer, set something people or programs outside the repo rely on, or most remaining work would build on it. Link a PR (owner/repo#number) or task id when it is about one. When a task waits on this decision, set task, then mark it blocked with update_obligation question=\\\"Q<n>\\\" (not ask): one decision, one card. The reply says the question mode and exactly what to do until the answer arrives. Asking something already open returns the open question (\\\"Already open as Q18\\\") instead of a second one; to change an open question's options, ask again with supersedes=\\\"Q18\\\". At the end of the turn point at it with needs_you questions=[\\\"Q18\\\"], don't restate it. URLs and owner/repo#123 in the question, background and options are clickable for the developer. Every card already ends with a built-in \\\"Something else\\\" choice where the developer writes their own answer; don't add an \\\"Other\\\" option yourself.\", \"follow.ask-question\", { title: { ...string, maxLength: 120 }, question: { ...string, maxLength: 2000 }, options: { type: \"array\", maxItems: 26, items: { type: \"object\", properties: { letter: { type: \"string\", pattern: \"^[A-Z]$\" }, label: { ...string, maxLength: 200 }, consequence: { ...string, maxLength: 600 } }, required: [\"letter\", \"label\"], additionalProperties: false } }, recommend: string, big: string, background: string, links: { type: \"array\", maxItems: 10, items: { type: \"object\", properties: { url: string, path: string, label: string }, additionalProperties: false } }, pr: string, task: string, supersedes: { type: \"string\", pattern: \"^Q\\\\d+$\" } }, [\"title\", \"question\"]],",
32
32
  " [\"record_answer\", \"Record the developer's answer when they answered a question in chat instead of in Follow-up. choice is an option letter, \\\"other\\\" when they chose none of your options (words is then required: their answer), or their short answer when there were no options; words is what they said.\", \"follow.record-answer\", { id: string, choice: string, words: string }, [\"id\", \"choice\"]],",
@@ -140,7 +140,7 @@ export const mcpSource: string = [
140
140
  " [\"run_recovery\", \"Run recovery on a workspace, like Run recovery: a separate agent reads its history for missed PRs and tasks. { workspaceId }.\" + ask, \"follow.agent-act\", { workspaceId: string, ...planned }, []],",
141
141
  " [\"refresh\", \"Refresh PR status now, like Refresh. Cheap; use when status looks stale.\", \"follow.agent-act\", { workspaceId: string }, []],",
142
142
  " [\"set_workspace_spec\", \"Set, remove or reset any workspace's spec link: { workspaceId, action set|remove|reset, url, title }.\" + ask, \"follow.agent-act\", { workspaceId: string, action: string, url: string, title: { type: [\"string\", \"null\"] }, ...planned }, []],",
143
- " [\"set_task_trigger\", \"Schedule a task to run now, on merge or on deploy (trigger { event, delayDays } or null), with afterPrs: { workspaceId, obligationId, expectedRevision, trigger, afterPrs }.\" + ask, \"follow.agent-act\", { workspaceId: string, obligationId: string, expectedRevision: { type: \"integer\", minimum: 0 }, trigger, afterPrs: array, ...planned }, []],",
143
+ " [\"set_task_trigger\", \"Schedule a task to run now, on merge, on deploy or at a time (trigger { event, delayDays } or { event: \\\"at\\\", at | inMinutes } or null), with afterPrs: { workspaceId, obligationId, expectedRevision, trigger, afterPrs }.\" + ask, \"follow.agent-act\", { workspaceId: string, obligationId: string, expectedRevision: { type: \"integer\", minimum: 0 }, trigger, afterPrs: array, ...planned }, []],",
144
144
  " [\"pr_controls\", \"Read a PR's merge controls as the PR sheet shows them (Send to Paseo pairing, Graphite in Chrome): { workspaceId, prKey }.\" + read, \"follow.agent-act\", { workspaceId: string, prKey }, [\"workspaceId\", \"prKey\"]],",
145
145
  " [\"browser_status\", \"Read whether Send to Paseo is paired and which repositories it may control.\" + read, \"follow.agent-act\", {}, []],",
146
146
  " [\"release_notes\", \"Read Follow-up's release notes: the installed version, the version it updated from (previous) and when (updatedAt, ms), and every shipped version's notes, newest first. What's new shows the notes after previous, once per device, unless enable_whats_new is off (set_updates).\" + read, \"follow.agent-act\", {}, []],",
package/server/mcp.mjs CHANGED
@@ -17,14 +17,14 @@ const boolean = { type: "boolean" };
17
17
  const integer = { type: "integer", minimum: 1 };
18
18
  const array = { type: "array", items: string };
19
19
  const communication = { type: "object", properties: { threadUrl: string, recipient: string, purpose: { type: "string", enum: ["progress", "verified"] }, authorization: string, replyUrl: { type: ["string", "null"] } }, required: ["threadUrl", "recipient"], additionalProperties: false };
20
- const trigger = { type: ["object", "null"], properties: { event: { type: "string", enum: ["now", "merge", "deploy"] }, delayDays: { type: "integer", minimum: 0, maximum: 3650 } }, required: ["event"], additionalProperties: false };
20
+ const trigger = { type: ["object", "null"], properties: { event: { type: "string", enum: ["now", "merge", "deploy", "at"] }, delayDays: { type: "integer", minimum: 0, maximum: 3650 }, at: { type: "string", description: "event at: an ISO time with its offset, like 2026-11-26T12:15:00+02:00" }, inMinutes: { type: "integer", minimum: 1, maximum: 43200, description: "event at: this many minutes from now, instead of at" } }, required: ["event"], additionalProperties: false };
21
21
  const tools = [
22
22
  ["workspace_status", "Read the tracked workspace's durable goal, PRs, tasks, work queue and optional recovery history. Read after compaction. Returns current work by default; detail=full includes complete evidence/history. Normal follow-up does not require recovery.", "follow.agent-status", { detail: { type: "string", enum: ["summary", "full"] } }, []],
23
23
  ["sync_workspace", "Silently confirm the sidebar matches your work before finishing, after registering owned PRs and substantive tasks. Call even when no changes are needed. Keep the summary in this tool; never announce sync or recap sidebar/plugin status to the developer. Does not declare Done, run recovery, or start repairs. Tracked root agents only.", "follow.sync", { summary: { ...string, minLength: 1, maxLength: 1000 } }, ["summary"]],
24
24
  ["enroll_workspace", "Refine this developer-activated workspace's goal. Ownership is initialized by Track this workspace or the project’s default-tracking setting. This tool cannot activate another workspace. Never ask the developer to enter this. Keep the goal concise; new scope reopens completion.", "follow.enroll", { goal: string }, ["goal"]],
25
25
  ["register_pr", "Register a PR produced by this workspace. Call after every submission. Register parents first; repeat to update its stack or parent after restacking. Supply a disposition for a deliberately closed PR. Set agentMerges: true when you merge this PR yourself (no human review): Follow-up then never asks the developer to add reviewers or merge it, and the workspace reads as waiting on you; set it false to hand the merge back. In a repository set to No review (set_pr_workflow review \"none\") every PR counts as agentMerges unless you set it false.", "follow.register-pr", { repo: string, number: integer, stack: string, parentNumber: { type: ["integer", "null"], minimum: 1 }, disposition: string, agentMerges: boolean }, ["repo", "number", "stack"]],
26
26
  ["exclude_stack", "Correct an unrelated stack registration. Preserve its PRs and requirements in an exclusion audit; future registration is blocked. reason must cite the scope/ownership evidence. obligationIds may include related tasks without PR dependencies. Keep external dependencies separate from owned work.", "follow.exclude-stack", { stack: string, reason: string, obligationIds: array }, ["stack", "reason"]],
27
- ["update_obligation", "Record concrete follow-up: verification, migrations, decisions or stakeholder replies. Never add approve/merge/deploy checklist tasks. afterPrs uses owner/repo#number keys. A task comes due by itself when its afterPrs reach dependencyStage, or on recheck (\"YYYY-MM-DD\"; a task with no PRs defaults to 3 days after your last update); at your turn's end Follow-up names due tasks: do them and close with evidence, or keep them with a new recheck and why. trigger={event:\"now\"|\"merge\"|\"deploy\",delayDays:0} also sends the task to you as a message; set it only from the developer’s 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. For Slack replies, communication records the original threadUrl, recipient, purpose (progress or verified), explicit developer authorization and sent replyUrl. Empty authorization never queues a reply; Auto does not authorize external posts. Use a verify-and-reply task after deployment for the final update. Read the thread first; mark blocked when posting is unavailable or uncertain, never treat a draft as sent. Done requires replyUrl and evidence; preserve fields when updating. status=working records you as the agent doing it; pass workingAgentId when another agent (your subagent) is.", "follow.obligation", { id: string, workingAgentId: string, title: string, status: { type: "string", enum: ["pending", "waiting", "working", "blocked", "done", "waived"] }, afterPrs: array, dependencyStage: { type: "string", enum: ["merged", "deployed"] }, evidence: string, ask: { ...string, description: "With blocked, only for a decision you haven't asked: the question the developer must answer (waiting on a PR or agent is status=waiting). Asked already with ask_question? Pass question instead." }, question: { type: "string", pattern: "^Q\\d+$", description: "With blocked: the question (Q<n>) this task waits on, asked with ask_question (task set to this task). No second card is made." }, need: { type: "string", enum: ["decision", "action"], description: "With blocked and ask: decision (they choose; the card takes their answer) or action (they do something and report back, e.g. share a page, approve, log in; the card has Done). Left out: read from the ask." }, enable_follow_up: boolean, communication, trigger, recheck: { type: "string", description: "When to look at this task again: \"YYYY-MM-DD\". Set it when you keep a due task open, with why in evidence." }, new: { type: "boolean", description: "Add a separate task even though a similar open one exists." } }, ["title", "status"]],
27
+ ["update_obligation", "Record concrete follow-up: verification, migrations, decisions or stakeholder replies. Never add approve/merge/deploy checklist tasks. afterPrs uses owner/repo#number keys. A task comes due by itself when its afterPrs reach dependencyStage, or on recheck (\"YYYY-MM-DD\"; a task with no PRs defaults to 3 days after your last update); at your turn's end Follow-up names due tasks: do them and close with evidence, or keep them with a new recheck and why. trigger={event:\"now\"|\"merge\"|\"deploy\",delayDays:0} also sends the task to you as a message; set it only from the developer’s 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't 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. For Slack replies, communication records the original threadUrl, recipient, purpose (progress or verified), explicit developer authorization and sent replyUrl. Empty authorization never queues a reply; Auto does not authorize external posts. Use a verify-and-reply task after deployment for the final update. Read the thread first; mark blocked when posting is unavailable or uncertain, never treat a draft as sent. Done requires replyUrl and evidence; preserve fields when updating. status=working records you as the agent doing it; pass workingAgentId when another agent (your subagent) is.", "follow.obligation", { id: string, workingAgentId: string, title: string, status: { type: "string", enum: ["pending", "waiting", "working", "blocked", "done", "waived"] }, afterPrs: array, dependencyStage: { type: "string", enum: ["merged", "deployed"] }, evidence: string, ask: { ...string, description: "With blocked, only for a decision you haven't asked: the question the developer must answer (waiting on a PR or agent is status=waiting). Asked already with ask_question? Pass question instead." }, question: { type: "string", pattern: "^Q\\d+$", description: "With blocked: the question (Q<n>) this task waits on, asked with ask_question (task set to this task). No second card is made." }, need: { type: "string", enum: ["decision", "action"], description: "With blocked and ask: decision (they choose; the card takes their answer) or action (they do something and report back, e.g. share a page, approve, log in; the card has Done). Left out: read from the ask." }, enable_follow_up: boolean, communication, trigger, recheck: { type: "string", description: "When to look at this task again: \"YYYY-MM-DD\". Set it when you keep a due task open, with why in evidence." }, new: { type: "boolean", description: "Add a separate task even though a similar open one exists." } }, ["title", "status"]],
28
28
  ["acknowledge_batch", "Record a follow-up result. Complete only after verifying all tasks; blocked surfaces the reason to the developer. in_progress when you or your own subagent are already working on these tasks (say where it stands): not a failure, and Follow-up won't send the same tasks again until that work ends or they change on GitHub. Blocked with humanOnly=true when nothing is left for an agent and only a person can move it (a reviewer must re-review or dismiss a stale review, access must be granted): the developer gets a PR item, not an agent failure. When only part of it waits on a person (one thread needs the reviewer's call), name that part in waitingOn with any outcome and carry on with the rest: the developer gets it as a person item, and later messages tell you to leave it. Always acknowledge before ending a repair turn. Keep the result within 2000 characters.", "follow.acknowledge", { batchId: string, outcome: { type: "string", enum: ["completed", "blocked", "in_progress"] }, result: { ...string, maxLength: 2000 }, humanOnly: { type: "boolean" }, waitingOn: { ...string, maxLength: 500 } }, ["batchId", "outcome", "result"]],
29
29
  ["ask_question", "Ask the developer a decision you can't make yourself. Give a short title, the question, lettered options A, B, C… with what each means for them, and recommend the option you'd pick. Set big only when building ahead would send something off this computer, set something people or programs outside the repo rely on, or most remaining work would build on it. Link a PR (owner/repo#number) or task id when it is about one. When a task waits on this decision, set task, then mark it blocked with update_obligation question=\"Q<n>\" (not ask): one decision, one card. The reply says the question mode and exactly what to do until the answer arrives. Asking something already open returns the open question (\"Already open as Q18\") instead of a second one; to change an open question's options, ask again with supersedes=\"Q18\". At the end of the turn point at it with needs_you questions=[\"Q18\"], don't restate it. URLs and owner/repo#123 in the question, background and options are clickable for the developer. Every card already ends with a built-in \"Something else\" choice where the developer writes their own answer; don't add an \"Other\" option yourself.", "follow.ask-question", { title: { ...string, maxLength: 120 }, question: { ...string, maxLength: 2000 }, options: { type: "array", maxItems: 26, items: { type: "object", properties: { letter: { type: "string", pattern: "^[A-Z]$" }, label: { ...string, maxLength: 200 }, consequence: { ...string, maxLength: 600 } }, required: ["letter", "label"], additionalProperties: false } }, recommend: string, big: string, background: string, links: { type: "array", maxItems: 10, items: { type: "object", properties: { url: string, path: string, label: string }, additionalProperties: false } }, pr: string, task: string, supersedes: { type: "string", pattern: "^Q\\d+$" } }, ["title", "question"]],
30
30
  ["record_answer", "Record the developer's answer when they answered a question in chat instead of in Follow-up. choice is an option letter, \"other\" when they chose none of your options (words is then required: their answer), or their short answer when there were no options; words is what they said.", "follow.record-answer", { id: string, choice: string, words: string }, ["id", "choice"]],
@@ -138,7 +138,7 @@ const actionTools = [
138
138
  ["run_recovery", "Run recovery on a workspace, like Run recovery: a separate agent reads its history for missed PRs and tasks. { workspaceId }." + ask, "follow.agent-act", { workspaceId: string, ...planned }, []],
139
139
  ["refresh", "Refresh PR status now, like Refresh. Cheap; use when status looks stale.", "follow.agent-act", { workspaceId: string }, []],
140
140
  ["set_workspace_spec", "Set, remove or reset any workspace's spec link: { workspaceId, action set|remove|reset, url, title }." + ask, "follow.agent-act", { workspaceId: string, action: string, url: string, title: { type: ["string", "null"] }, ...planned }, []],
141
- ["set_task_trigger", "Schedule a task to run now, on merge or on deploy (trigger { event, delayDays } or null), with afterPrs: { workspaceId, obligationId, expectedRevision, trigger, afterPrs }." + ask, "follow.agent-act", { workspaceId: string, obligationId: string, expectedRevision: { type: "integer", minimum: 0 }, trigger, afterPrs: array, ...planned }, []],
141
+ ["set_task_trigger", "Schedule a task to run now, on merge, on deploy or at a time (trigger { event, delayDays } or { event: \"at\", at | inMinutes } or null), with afterPrs: { workspaceId, obligationId, expectedRevision, trigger, afterPrs }." + ask, "follow.agent-act", { workspaceId: string, obligationId: string, expectedRevision: { type: "integer", minimum: 0 }, trigger, afterPrs: array, ...planned }, []],
142
142
  ["pr_controls", "Read a PR's merge controls as the PR sheet shows them (Send to Paseo pairing, Graphite in Chrome): { workspaceId, prKey }." + read, "follow.agent-act", { workspaceId: string, prKey }, ["workspaceId", "prKey"]],
143
143
  ["browser_status", "Read whether Send to Paseo is paired and which repositories it may control." + read, "follow.agent-act", {}, []],
144
144
  ["release_notes", "Read Follow-up's release notes: the installed version, the version it updated from (previous) and when (updatedAt, ms), and every shipped version's notes, newest first. What's new shows the notes after previous, once per device, unless enable_whats_new is off (set_updates)." + read, "follow.agent-act", {}, []],
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import type { Obligation, Workspace } from "../shared/model";
3
3
  import { lifecycleOnly } from "../shared/follow-up";
4
4
  import { communicationKey, communicationSchema, replyRecorded, type Communication } from "../shared/communication";
5
- import type { TaskTrigger } from "../shared/task-trigger";
5
+ import { storedTrigger, type TaskTrigger, type TaskTriggerInput } from "../shared/task-trigger";
6
6
  import { currentQuestion } from "../shared/questions";
7
7
  import { RECHECK_DAYS } from "../shared/task-due";
8
8
  import { sameTask, similarLines, similarOpen } from "../shared/task-dup";
@@ -16,7 +16,7 @@ type Update = {
16
16
  /** While blocked: what the ask wants of the developer, a decision or an action they take and report back. */
17
17
  need?: "decision" | "action";
18
18
  dependencyStage?: "merged" | "deployed"; enable_follow_up?: boolean; communication?: Pick<Communication, "threadUrl" | "recipient"> & Partial<Communication>;
19
- trigger?: TaskTrigger | null;
19
+ trigger?: TaskTriggerInput | TaskTrigger | null;
20
20
  /** due-by-fact: when to look at it again, "YYYY-MM-DD" or an ISO time. An open task with no PRs gets RECHECK_DAYS out by default. */
21
21
  recheck?: string;
22
22
  /** The clock (tests); defaults to Date.now(). */
@@ -68,14 +68,16 @@ export function updateObligation(w: Workspace, input: Update): Obligation {
68
68
  const destination = communication ? communicationSchema.parse({ ...existing?.communication, ...communication }) : existing?.communication;
69
69
  if (destination?.replyUrl && !replyRecorded(destination)) throw new Error("The reply receipt must be a different message in the original Slack workspace/channel/thread.");
70
70
  if (destination && status === "done" && !replyRecorded(destination)) throw new Error("A draft is not a sent reply. Record communication.replyUrl before completing this task; use blocked when posting is unavailable or uncertain.");
71
- const trigger = input.trigger === undefined ? existing?.trigger : input.trigger;
71
+ const now = input.now ?? Date.now();
72
+ // An at trigger's time is resolved and checked here (inMinutes from now, an ISO time with its offset); the same time
73
+ // again keeps whether it already went out (a-scheduled-task-arrives-once-at-its-time).
74
+ const trigger = input.trigger === undefined ? existing?.trigger : storedTrigger(input.trigger, existing?.trigger, now);
72
75
  if (trigger?.event === "now" && (afterPrs.length || trigger.delayDays)) throw new Error("Now requires no PR dependencies or delay. Choose a merge/deploy trigger for delayed work.");
73
- if (trigger && trigger.event !== "now" && !afterPrs.length) throw new Error("Select at least one owned PR for a merge/deploy trigger.");
76
+ if (trigger && (trigger.event === "merge" || trigger.event === "deploy") && !afterPrs.length) throw new Error("Select at least one owned PR for a merge/deploy trigger.");
74
77
  const stage = trigger?.event === "merge" ? "merged" : trigger?.event === "deploy" ? "deployed" : dependencyStage ?? existing?.dependencyStage ?? "deployed";
75
78
  const followUp = enable_follow_up ?? (input.trigger !== undefined ? !!trigger : existing?.enable_follow_up ?? false);
76
79
  // due-by-fact: every open task knows what moves it. With no PRs that is a re-check date: the agent's, else
77
80
  // RECHECK_DAYS from this update (an update is the agent looking at it). A finished task records when.
78
- const now = input.now ?? Date.now();
79
81
  const recheck = input.recheck === undefined ? undefined : /^\d{4}-\d{2}-\d{2}$/.test(input.recheck) ? Date.parse(`${input.recheck}T00:00:00Z`) : Date.parse(input.recheck);
80
82
  if (recheck !== undefined && !Number.isFinite(recheck)) throw new Error("recheck is a date: \"YYYY-MM-DD\" or an ISO time.");
81
83
  const finished = ["done", "waived"].includes(status);
@@ -3,7 +3,7 @@ import type { ZodType } from "zod";
3
3
  import { readFile, writeFile, rename, mkdir } from "node:fs/promises";
4
4
  import { join } from "node:path";
5
5
  import { compareVersions } from "../shared/version";
6
- import { parseChangelog, LEGACY_BASELINE, type InstallKind, type ReleaseNote } from "../shared/changelog";
6
+ import { parseChangelog, releasesUrl, LEGACY_BASELINE, type InstallKind, type ReleaseNote } from "../shared/changelog";
7
7
 
8
8
  /**
9
9
  * Follow-up's own install, as Paseo describes it: where it lives, which version, and from what source. Read from the
@@ -24,12 +24,12 @@ export function describeSelf(rows: readonly PluginRow[]): Omit<SelfInstall, "ver
24
24
  return { id: row.id, path: row.path, version: row.installation?.currentRevision ?? null, installKind, status: row.status ?? null, error: row.error ?? null, registry };
25
25
  }
26
26
 
27
- /** The installed package's version, its display name (the manifest's `name`) and CHANGELOG.md, read from the plugin's own folder. */
28
- export async function readPackage(path: string): Promise<{ version: string | null; name: string | null; notes: ReleaseNote[] }> {
29
- const pkg = await readFile(join(path, "package.json"), "utf8").then(t => JSON.parse(t) as { version?: string }, () => null);
27
+ /** The installed package's version, its display name (the manifest's `name`), CHANGELOG.md and release pages, read from the plugin's own folder. */
28
+ export async function readPackage(path: string): Promise<{ version: string | null; name: string | null; notes: ReleaseNote[]; releases: string | null }> {
29
+ const pkg = await readFile(join(path, "package.json"), "utf8").then(t => JSON.parse(t) as { version?: string; repository?: unknown }, () => null);
30
30
  const manifest = await readFile(join(path, "paseo-plugin.json"), "utf8").then(t => JSON.parse(t) as { name?: unknown }, () => null);
31
31
  const notes = await readFile(join(path, "CHANGELOG.md"), "utf8").then(parseChangelog, () => []);
32
- return { version: pkg?.version ?? null, name: typeof manifest?.name === "string" && manifest.name.trim() ? manifest.name.trim() : null, notes };
32
+ return { version: pkg?.version ?? null, name: typeof manifest?.name === "string" && manifest.name.trim() ? manifest.name.trim() : null, notes, releases: releasesUrl(pkg?.repository) };
33
33
  }
34
34
 
35
35
  /** versions.json: which version this host runs, the one before it, and the host-wide What's new record. */
@@ -0,0 +1,92 @@
1
+ import type { MessageQueue, Resolution } from "./message-queue";
2
+ import type { QueueItem } from "../shared/queue";
3
+ import type { State, Workspace } from "../shared/model";
4
+ import { followUpObligations } from "../shared/follow-up";
5
+ import { pendingAt, scheduledText } from "../shared/task-trigger";
6
+
7
+ /** What the channel needs to know about the agent when the message goes: nothing here loads it. */
8
+ export type ScheduledAgent = { status: string; archived: boolean; workspaceId: string | null } | null;
9
+ export const scheduledItemId = (workspaceId: string, obligationId: string, at: string) => `scheduled:${workspaceId}:${obligationId}:${at}`;
10
+ /** Why a time trigger didn't go out, as the task row says it ("Not sent · the agent was archived"). */
11
+ export const NOT_SENT = { archived: "the agent was archived", closed: "the agent was closed", workspace: "the workspace was archived", none: "the workspace has no main agent" } as const;
12
+
13
+ /**
14
+ * Scheduled tasks (a-scheduled-task-arrives-once-at-its-time): a task whose trigger is a time goes to its main agent
15
+ * once, at that time, whether Auto-send is on or not: someone named the time (the developer in the sheet, or the agent
16
+ * for its own check-back). `evaluate` runs after each engine pass, whose untouched-pass skip already ends at the
17
+ * earliest due time (engine nextDue), so it fires within a tick and never before. A due trigger is saved as one
18
+ * `scheduled` queue message first (a-message-is-saved-before-sent-and-arrives-once) and then marked `queuedAt` on the
19
+ * task, so a crash between the two re-enqueues the same id, which the queue returns as it is. A closed or archived
20
+ * agent gets nothing, and the task row says why (`notSent`); a worker down at the time fires once, late, on its first
21
+ * pass. The channel resolves the agent when it goes, waits for a running turn to end, and sends to an idle one even
22
+ * when Paseo unloaded it: it asked for this message, as with wait_for_checks (the one exception to invariant 1).
23
+ */
24
+ export class ScheduledTasks {
25
+ private queue: MessageQueue | null = null;
26
+ /** Fired triggers (tests). */
27
+ readonly fired: { workspaceId: string; obligationId: string; at: string; sent: boolean; why: string }[] = [];
28
+ constructor(private deps: {
29
+ snapshot: () => Promise<State>;
30
+ mutateWorkspace: (id: string, work: (w: Workspace) => void) => Promise<unknown>;
31
+ agent: (agentId: string) => Promise<ScheduledAgent>;
32
+ now?: () => number;
33
+ }) {}
34
+ private now(): number { return (this.deps.now ?? Date.now)(); }
35
+
36
+ /** After an engine pass: every due time trigger in those workspaces (all when `ids` is absent). */
37
+ async evaluate(ids?: ReadonlySet<string>): Promise<void> {
38
+ const state = await this.deps.snapshot();
39
+ const now = this.now();
40
+ for (const w of state.workspaces) {
41
+ if (ids && !ids.has(w.id) || !w.enable_tracking) continue;
42
+ const due = followUpObligations(w).filter(o => o.enable_follow_up && !["done", "waived"].includes(o.status) && pendingAt(o.trigger) && Date.parse(o.trigger!.at!) <= now);
43
+ for (const o of due) await this.fire(w, o.id, o.trigger!.at!, now);
44
+ }
45
+ }
46
+
47
+ private async fire(w: Workspace, obligationId: string, at: string, now: number): Promise<void> {
48
+ const o = w.obligations.find(x => x.id === obligationId)!;
49
+ const agent = w.archived ? null : await this.deps.agent(w.mainAgentId).catch(() => undefined);
50
+ // Unknown (Paseo unreachable): try on the next pass; never a guess either way.
51
+ if (agent === undefined) return;
52
+ const why = w.archived ? NOT_SENT.workspace : !w.mainAgentId ? NOT_SENT.none : !agent || agent.archived ? NOT_SENT.archived : agent.status === "closed" ? NOT_SENT.closed : null;
53
+ if (!why && this.queue) {
54
+ this.queue.enqueue({ id: scheduledItemId(w.id, o.id, at), kind: "scheduled", key: w.id, ref: { workspaceId: w.id, obligationId: o.id, agentId: w.mainAgentId, at },
55
+ messageId: `scheduled-${o.id}-${Date.parse(at).toString(36)}`, text: scheduledText(o, at, now), priority: "now", state: "queued" });
56
+ }
57
+ if (!why && !this.queue) return;
58
+ await this.mark(w.id, o.id, at, t => { if (why) t.notSent = why; else t.queuedAt = new Date(now).toISOString(); });
59
+ this.fired.push({ workspaceId: w.id, obligationId: o.id, at, sent: !why, why: why ?? "queued" });
60
+ }
61
+
62
+ /** Writes onto the task's trigger only while it is still the same time (an edit since wins). */
63
+ private async mark(workspaceId: string, obligationId: string, at: string, edit: (t: NonNullable<Workspace["obligations"][number]["trigger"]>) => void): Promise<void> {
64
+ await this.deps.mutateWorkspace(workspaceId, w => {
65
+ const o = w.obligations.find(x => x.id === obligationId);
66
+ if (o?.trigger?.event === "at" && o.trigger.at === at) edit(o.trigger);
67
+ }).catch(error => console.warn(`[follow-up] couldn't record a scheduled task: ${error instanceof Error ? error.message : String(error)}`));
68
+ }
69
+
70
+ /** The queue's `scheduled` channel: the main agent, resolved when it goes; never woken from closed or archived. */
71
+ attachQueue(queue: MessageQueue): void {
72
+ this.queue = queue;
73
+ queue.register("scheduled", {
74
+ resolve: async (item): Promise<Resolution> => {
75
+ let agent: ScheduledAgent;
76
+ try { agent = await this.deps.agent(item.ref.agentId!); }
77
+ catch { return { defer: "Paseo unreachable" }; }
78
+ if (!agent || agent.archived) return { cancel: NOT_SENT.archived };
79
+ if (agent.status === "closed") return { cancel: NOT_SENT.closed };
80
+ if (item.state === "queued" && ["running", "initializing"].includes(agent.status)) return { defer: "waits for the agent's turn to end" };
81
+ return { target: { workspaceId: agent.workspaceId, recipients: [item.ref.agentId!] } };
82
+ },
83
+ // The task row mirrors the message: Sent once it left, Not sent (and why) if it was cancelled.
84
+ project: async (item: QueueItem) => {
85
+ const { workspaceId, obligationId, at } = item.ref;
86
+ if (!workspaceId || !obligationId || !at) return;
87
+ if (item.state === "sent") await this.mark(workspaceId, obligationId, at, t => { t.sentAt = item.envelope?.at ?? new Date(this.now()).toISOString(); });
88
+ else if (item.state === "cancelled") await this.mark(workspaceId, obligationId, at, t => { t.notSent = (item.reason ?? "it was cancelled").slice(0, 200); });
89
+ },
90
+ });
91
+ }
92
+ }