paseo-follow-up 2.1.0 → 2.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/README.md +6 -2
- package/client/brief.tsx +8 -6
- package/client/dock.ts +70 -0
- package/client/docked-pane.tsx +108 -0
- package/client/home.tsx +27 -29
- package/client/onboarding.tsx +17 -40
- package/client/questions.tsx +35 -18
- package/client/release-notes.tsx +3 -2
- package/client/updates.tsx +7 -5
- package/index.server.ts +65 -7
- package/package.json +1 -1
- package/server/agent-actions.ts +1 -1
- package/server/agent-hook.mjs +1 -1
- package/server/agent-parity.ts +10 -1
- package/server/context-requests.ts +111 -0
- package/server/daemon.ts +20 -13
- package/server/delivery.ts +8 -0
- package/server/hook-source.ts +1 -1
- package/server/mcp-source.ts +9 -5
- package/server/mcp.mjs +9 -5
- package/server/message-queue.ts +34 -12
- package/server/transcript.ts +56 -0
- package/server/updater.ts +7 -6
- package/server/updates.ts +4 -2
- package/shared/attention.ts +3 -2
- package/shared/catch-up.ts +249 -0
- package/shared/changelog.ts +28 -22
- package/shared/chat.ts +1 -1
- package/shared/contracts.ts +15 -0
- package/shared/questions.ts +54 -0
- package/shared/queue.ts +28 -3
- package/shared/status-invariants.ts +14 -0
- package/shared/updates.ts +11 -3
package/server/delivery.ts
CHANGED
|
@@ -4,6 +4,14 @@ export class DeliveryDeferred extends Error {}
|
|
|
4
4
|
/** The provider no longer has the agent's conversation: every send fails, so Follow-up stops sending to it. */
|
|
5
5
|
export class ConversationGone extends Error { constructor(readonly agentId: string, reason: string) { super(reason); this.name = "ConversationGone"; } }
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Paseo 0.16 refused the messageId itself (its per-agent, per-messageId receipt): agent_request_outcome_unknown (a
|
|
9
|
+
* receipt left pending by a daemon that died mid-send; every later send under that id is refused for good) or
|
|
10
|
+
* agent_request_key_conflict (the id was used for other text). Nothing was sent now; whether the first one landed is
|
|
11
|
+
* for the chat to say.
|
|
12
|
+
*/
|
|
13
|
+
export const idRefused = (error: unknown): boolean => /agent_request_(outcome_unknown|key_conflict)/.test(error instanceof Error ? error.message : String(error));
|
|
14
|
+
|
|
7
15
|
/** A UUID-shaped id fixed by `seed`: the same answer always goes out under the same messageId. */
|
|
8
16
|
export function stableMessageId(seed: string): string {
|
|
9
17
|
const h = createHash("sha256").update(seed).digest("hex");
|
package/server/hook-source.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const hookSource: string = [
|
|
|
15
15
|
"/** 1.4.0-beta.2: launched with Follow-up's tools served by Paseo's MCP (follow_<name>), or the follow-up bridge (<name>). Agents opened before the upgrade carry no flag and keep the bridge names. */",
|
|
16
16
|
"let native = env(\"TOOLS\") === \"native\";",
|
|
17
17
|
"// Tool names that read unambiguously in prose; kept identical to server/mcp.mjs's underscore names (a test checks it).",
|
|
18
|
-
"export const TOOL_NAMES = [\"workspace_status\", \"sync_workspace\", \"enroll_workspace\", \"register_pr\", \"exclude_stack\", \"update_obligation\", \"acknowledge_batch\", \"ask_question\", \"record_answer\", \"withdraw_question\", \"set_spec\", \"link_item\", \"unlink_item\", \"link_items\", \"set_linked_items\", \"workspace_about\", \"agent_settings\", \"needs_you\", \"declare_done\", \"list_prs\", \"add_reviewers\", \"enable_merge_when_ready\", \"disable_merge_when_ready\", \"send_repairs\", \"set_auto_send\", \"clear_hold\", \"retry_batch\", \"inbox_list\", \"sign_off\", \"snooze_workspace\", \"set_finish_flags\", \"set_priorities\", \"agent_digest\", \"route_candidates\", \"send_to_agent\", \"start_workspace\", \"display_settings\", \"set_display\", \"follow_settings\", \"set_follow_settings\", \"project_settings\", \"set_project_tracking\", \"pr_workflow\", \"set_pr_workflow\", \"reviewer_settings\", \"reviewer_suggestions\", \"save_reviewers\", \"set_agent_setting\", \"set_wait_for_jobs\", \"onboarding_status\", \"onboarding_checks\", \"set_onboarding\", \"rank_status\", \"rerank_priorities\", \"overseer_status\", \"overseer_start\", \"overseer_restart\", \"overseer_ask\", \"inbox_brief\", \"brief_action\", \"queue_list\", \"queue_action\", \"inbox_act\", \"answer_question\", \"run_recovery\", \"set_workspace_spec\", \"set_task_trigger\", \"pr_controls\", \"browser_status\", \"trust_bypass_status\", \"release_notes\", \"updates_status\", \"check_updates\", \"set_updates\", \"install_update\", \"make_main_agent\", \"retry_move\", \"report_issue\", \"report_send\", \"ai_rename\"];",
|
|
18
|
+
"export const TOOL_NAMES = [\"workspace_status\", \"sync_workspace\", \"enroll_workspace\", \"register_pr\", \"exclude_stack\", \"update_obligation\", \"acknowledge_batch\", \"ask_question\", \"record_answer\", \"withdraw_question\", \"set_spec\", \"link_item\", \"unlink_item\", \"link_items\", \"set_linked_items\", \"workspace_about\", \"agent_settings\", \"needs_you\", \"declare_done\", \"list_prs\", \"add_reviewers\", \"enable_merge_when_ready\", \"disable_merge_when_ready\", \"send_repairs\", \"set_auto_send\", \"clear_hold\", \"retry_batch\", \"inbox_list\", \"sign_off\", \"snooze_workspace\", \"set_finish_flags\", \"set_priorities\", \"agent_digest\", \"route_candidates\", \"send_to_agent\", \"start_workspace\", \"display_settings\", \"set_display\", \"follow_settings\", \"set_follow_settings\", \"project_settings\", \"set_project_tracking\", \"pr_workflow\", \"set_pr_workflow\", \"reviewer_settings\", \"reviewer_suggestions\", \"save_reviewers\", \"set_agent_setting\", \"set_wait_for_jobs\", \"onboarding_status\", \"onboarding_checks\", \"set_onboarding\", \"rank_status\", \"rerank_priorities\", \"overseer_status\", \"overseer_start\", \"overseer_restart\", \"overseer_ask\", \"inbox_brief\", \"brief_action\", \"queue_list\", \"queue_action\", \"inbox_act\", \"answer_question\", \"run_recovery\", \"set_workspace_spec\", \"set_task_trigger\", \"pr_controls\", \"browser_status\", \"trust_bypass_status\", \"release_notes\", \"updates_status\", \"check_updates\", \"set_updates\", \"install_update\", \"make_main_agent\", \"retry_move\", \"report_issue\", \"report_send\", \"ai_rename\", \"catch_up_deck\", \"context_requests\", \"ask_context\", \"context_reply\"];",
|
|
19
19
|
"const toolPattern = new RegExp(`(?<![\\\\w])(${TOOL_NAMES.join(\"|\")})(?![\\\\w])`, \"g\");",
|
|
20
20
|
"/** Names Follow-up's tools the way this agent has them. */",
|
|
21
21
|
"export function named(text, isNative = native) { return isNative ? text.replace(toolPattern, \"follow_$1\") : text; }",
|
package/server/mcp-source.ts
CHANGED
|
@@ -30,6 +30,7 @@ export const mcpSource: string = [
|
|
|
30
30
|
" [\"acknowledge_batch\", \"Record a follow-up result. Complete only after verifying all tasks; blocked surfaces the reason to the developer. Always acknowledge before ending a repair turn. Keep the result within 2000 characters.\", \"follow.acknowledge\", { batchId: string, outcome: { type: \"string\", enum: [\"completed\", \"blocked\"] }, result: { ...string, maxLength: 2000 } }, [\"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. 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\"]],",
|
|
33
|
+
" [\"context_reply\", \"Answer the developer's More context ask with the requestId it gave: { requestId, text }, plain words. Only when asked.\", \"follow.context-reply\", { requestId: { ...string, maxLength: 80 }, text: { ...string, minLength: 1, maxLength: 4000 } }, [\"requestId\", \"text\"]],",
|
|
33
34
|
" [\"withdraw_question\", \"Withdraw a question that no longer matters, with a short reason.\", \"follow.withdraw-question\", { id: string, reason: string }, [\"id\", \"reason\"]],",
|
|
34
35
|
" [\"set_spec\", \"Register the link to this workspace's spec: the Claude artifact (or doc) you keep summarizing the goal, decisions and status. Call it once after the first publish, with the URL from the publish result, and again only if the link changes. Follow-up shows it in the workspace header.\", \"follow.set-spec\", { url: { ...string, maxLength: 2000 }, title: { ...string, maxLength: 120 } }, [\"url\"]],",
|
|
35
36
|
" [\"link_item\", \"Link what this workspace's work is about: the Linear issue, Slack thread, doc or artifact you started from or opened for it. ref is its URL or Linear key; why is one short line. Don't link things you only mention. A PR isn't a linked item: register it with register_pr. An unknown Linear key is refused.\", \"follow.link-item\", { ref: { ...string, maxLength: 2000 }, why: { ...string, maxLength: 140 }, title: { ...string, maxLength: 200 } }, [\"ref\"]],",
|
|
@@ -92,6 +93,9 @@ export const mcpSource: string = [
|
|
|
92
93
|
" [\"overseer_start\", \"Start the Overseer, like Start on Home.\" + ask, \"follow.agent-act\", { ...planned }, []],",
|
|
93
94
|
" [\"overseer_restart\", \"Restart the Overseer (with the model Settings → Agents names now).\" + ask, \"follow.agent-act\", { ...planned }, []],",
|
|
94
95
|
" [\"overseer_ask\", \"Send the developer's words to the Overseer, as its box on Home does: { text }.\" + ask, \"follow.agent-act\", { text: string, ...planned }, []],",
|
|
96
|
+
" [\"catch_up_deck\", \"Read Catch up's deck: everything that needs the developer, one card per ask in Home's order, with any More context ask on it.\" + read, \"follow.agent-act\", {}, []],",
|
|
97
|
+
" [\"context_requests\", \"Read Catch up's More context asks: what the developer asked about a card, who answers, the state and the answer.\" + read, \"follow.agent-act\", { workspaceId: string }, []],",
|
|
98
|
+
" [\"ask_context\", \"Ask the Overseer or a card's agent to explain a card for the developer, like Catch up's More context: { workspaceId, agentId, cardKey, card, target: overseer | agent, ask } (cardKey and card from catch_up_deck).\" + ask, \"follow.agent-act\", { workspaceId: string, agentId: string, cardKey: string, card: string, target: { type: \"string\", enum: [\"overseer\", \"agent\"] }, ask: string, ...planned }, []],",
|
|
95
99
|
" [\"queue_list\", \"Read Follow-up's message queue: answers, repairs and forwards waiting to reach agents, with each one's state (queued, sending, retrying, failed), why it waits and when it tries next, plus the newest sent: { workspaceId?, agentId? }.\" + read, \"follow.agent-act\", { workspaceId: string, agentId: string }, []],",
|
|
96
100
|
" [\"queue_action\", \"Retry a queued or failed message now, or cancel it so it never goes: { itemId, action: retry | cancel } (ids from queue_list).\" + ask, \"follow.agent-act\", { itemId: string, action: { type: \"string\", enum: [\"retry\", \"cancel\"] }, ...planned }, []],",
|
|
97
101
|
" [\"inbox_brief\", \"Read another agent's full Needs-you brief (decisions, options, links): { agentId }.\" + read, \"follow.agent-act\", { agentId: string }, [\"agentId\"]],",
|
|
@@ -104,10 +108,10 @@ export const mcpSource: string = [
|
|
|
104
108
|
" [\"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 }, []],",
|
|
105
109
|
" [\"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\"]],",
|
|
106
110
|
" [\"browser_status\", \"Read whether Send to Paseo is paired and which repositories it may control.\" + read, \"follow.agent-act\", {}, []],",
|
|
107
|
-
" [\"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.\" + read, \"follow.agent-act\", {}, []],",
|
|
108
|
-
" [\"updates_status\", \"Read Settings → General: installed version and install kind, mode (auto|notify|off), channel (stable|beta), newest version per channel, last and next check, phase (current, available, waiting, installing, settling, updated, rolled-back, install-failed, untrusted), notes for the pending version, install history, and move (2.0's one-time move to its new plugin id: phase none|waiting|moving|moved|rolled-back|failed|manual, with the reason).\" + read, \"follow.agent-act\", {}, []],",
|
|
111
|
+
" [\"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\", {}, []],",
|
|
112
|
+
" [\"updates_status\", \"Read Settings → General: installed version and install kind, mode (auto|notify|off), channel (stable|beta), enable_whats_new, newest version per channel, last and next check, phase (current, available, waiting, installing, settling, updated, rolled-back, install-failed, untrusted), notes for the pending version, install history, and move (2.0's one-time move to its new plugin id: phase none|waiting|moving|moved|rolled-back|failed|manual, with the reason).\" + read, \"follow.agent-act\", {}, []],",
|
|
109
113
|
" [\"check_updates\", \"Ask the registry for a newer Follow-up now, like Check now. Works when updates are Off. Calls a few seconds apart share one request; call it only when asked. Returns updates_status.\", \"follow.agent-act\", {}, []],",
|
|
110
|
-
" [\"set_updates\", \"Change how Follow-up updates, like Settings → General: { mode: auto|notify|off, channel: stable|beta }.\" + ask, \"follow.agent-act\", { mode: { type: \"string\", enum: [\"auto\", \"notify\", \"off\"] }, channel: { type: \"string\", enum: [\"stable\", \"beta\"] }, ...planned }, []],",
|
|
114
|
+
" [\"set_updates\", \"Change how Follow-up updates, like Settings → General: { mode: auto|notify|off, channel: stable|beta, enable_whats_new: show What's new once after an update that brings new release notes (betas never; off records each update as seen) }.\" + ask, \"follow.agent-act\", { mode: { type: \"string\", enum: [\"auto\", \"notify\", \"off\"] }, channel: { type: \"string\", enum: [\"stable\", \"beta\"] }, enable_whats_new: boolean, ...planned }, []],",
|
|
111
115
|
" [\"install_update\", \"Install a newer Follow-up, like Install now: { version } from updates_status. It waits for a quiet moment (no agent mid-turn) unless anyway: true. Rolled back automatically if the new version doesn't come up. Never installs a version whose provenance failed.\" + ask, \"follow.agent-act\", { version: string, anyway: boolean, ...planned }, [\"version\"]],",
|
|
112
116
|
" [\"retry_move\", \"Try Follow-up's move to its new plugin id again, like Settings → General's Try again, after updates_status shows move.phase rolled-back or failed. It waits for a quiet moment like an update and rolls back by itself if the new id doesn't come up.\" + ask, \"follow.agent-act\", { ...planned }, []],",
|
|
113
117
|
" [\"trust_bypass_status\", \"Read how many permission prompts trust bypass approved today, and the latest ones.\" + read, \"follow.agent-act\", {}, []],",
|
|
@@ -130,7 +134,7 @@ export const mcpSource: string = [
|
|
|
130
134
|
"const overseerNames = new Set(overseerTools.map(t => t[0]));",
|
|
131
135
|
"const overseerInstruction = \"You are Follow-up's Overseer. Route the developer's asks with route_candidates and send_to_agent; ask with needs_you kind=decision when unsure; start_workspace only when the developer asked or approved. Never merge, post to people or archive.\";",
|
|
132
136
|
"const actionNames = new Set(actionTools.map(t => t[0]));",
|
|
133
|
-
"const readOnlyTools = new Set([\"queue_list\", \"workspace_status\", \"list_prs\", \"inbox_list\", \"workstreams\", \"agent_digest\", \"route_candidates\", \"workspace_about\", \"link_items\", \"agent_settings\", \"display_settings\", \"follow_settings\", \"project_settings\", \"pr_workflow\", \"reviewer_settings\", \"reviewer_suggestions\", \"onboarding_status\", \"onboarding_checks\", \"priorities\", \"rank_status\", \"usage\", \"overseer_status\", \"inbox_brief\", \"pr_controls\", \"browser_status\", \"trust_bypass_status\", \"release_notes\", \"updates_status\"]);",
|
|
137
|
+
"const readOnlyTools = new Set([\"catch_up_deck\", \"context_requests\", \"queue_list\", \"workspace_status\", \"list_prs\", \"inbox_list\", \"workstreams\", \"agent_digest\", \"route_candidates\", \"workspace_about\", \"link_items\", \"agent_settings\", \"display_settings\", \"follow_settings\", \"project_settings\", \"pr_workflow\", \"reviewer_settings\", \"reviewer_suggestions\", \"onboarding_status\", \"onboarding_checks\", \"priorities\", \"rank_status\", \"usage\", \"overseer_status\", \"inbox_brief\", \"pr_controls\", \"browser_status\", \"trust_bypass_status\", \"release_notes\", \"updates_status\"]);",
|
|
134
138
|
"const destructiveTools = new Set([\"merge\"]);",
|
|
135
139
|
"const actionInstruction = \"Follow-up's action tools let you do anything the developer can click, across every tracked workspace and every Settings tab. Read freely: list_prs, inbox_list, inbox_brief, workspace_about, agent_settings, display_settings, follow_settings, project_settings, pr_workflow, reviewer_settings, onboarding_status, priorities, rank_status, usage, overseer_status, pr_controls. Hand the main role on, or claim it, with make_main_agent. Act only when the developer asks (\\\"the PRs look good, assign reviewers on all\\\": list_prs needs_reviewers=true, add_reviewers with those keys, then confirm the plan): add_reviewers, merge, enable/disable_merge_when_ready, send_repairs, set_auto_send, clear_hold, retry_batch, track, run_recovery, set_priorities, rerank_priorities; settings with set_display (trust bypass too), set_follow_settings, set_project_tracking, set_pr_workflow, save_reviewers, set_agent_setting, set_wait_for_jobs, set_onboarding; snooze_workspace; ai_rename; and sign_off/snooze/set_finish_flags/inbox_act/brief_action/answer_question for other agents. Planned tools return a dry run showing what changes; run it with confirm=true and its planId. Never sign yourself off or answer your own brief.\";",
|
|
136
140
|
"",
|
|
@@ -149,7 +153,7 @@ export const mcpSource: string = [
|
|
|
149
153
|
" // Contributors get make_main_agent only (its claim rules apply); recovery sessions get none.",
|
|
150
154
|
" const acting = !actions || recovery ? [] : contributor ? actionTools.filter(t => t[0] === \"make_main_agent\" || t[0] === \"report_issue\") : actionTools;",
|
|
151
155
|
" if (briefOnly) return [...(brief ? tools.filter(t => t[0] === \"needs_you\") : []), ...acting];",
|
|
152
|
-
" return [...tools.filter(t => t[0] === \"needs_you\" ? brief && !recovery && !contributor : contributor ? [\"workspace_status\", \"register_pr\", \"sync_workspace\", \"link_item\", \"unlink_item\"].includes(t[0]) : !recovery || ![\"declare_done\", \"sync_workspace\", \"ask_question\", \"record_answer\", \"withdraw_question\", \"set_spec\", \"link_item\", \"unlink_item\"].includes(t[0])), ...acting];",
|
|
156
|
+
" return [...tools.filter(t => t[0] === \"needs_you\" ? brief && !recovery && !contributor : contributor ? [\"workspace_status\", \"register_pr\", \"sync_workspace\", \"link_item\", \"unlink_item\"].includes(t[0]) : !recovery || ![\"declare_done\", \"sync_workspace\", \"ask_question\", \"record_answer\", \"withdraw_question\", \"set_spec\", \"link_item\", \"unlink_item\", \"context_reply\"].includes(t[0])), ...acting];",
|
|
153
157
|
"}",
|
|
154
158
|
"/** Whether this session may call needs_you: launched as a root agent (FOLLOW_UP_BRIEF) and the inbox is on. */",
|
|
155
159
|
"async function briefEnabled() {",
|
package/server/mcp.mjs
CHANGED
|
@@ -28,6 +28,7 @@ const tools = [
|
|
|
28
28
|
["acknowledge_batch", "Record a follow-up result. Complete only after verifying all tasks; blocked surfaces the reason to the developer. Always acknowledge before ending a repair turn. Keep the result within 2000 characters.", "follow.acknowledge", { batchId: string, outcome: { type: "string", enum: ["completed", "blocked"] }, result: { ...string, maxLength: 2000 } }, ["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. 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"]],
|
|
31
|
+
["context_reply", "Answer the developer's More context ask with the requestId it gave: { requestId, text }, plain words. Only when asked.", "follow.context-reply", { requestId: { ...string, maxLength: 80 }, text: { ...string, minLength: 1, maxLength: 4000 } }, ["requestId", "text"]],
|
|
31
32
|
["withdraw_question", "Withdraw a question that no longer matters, with a short reason.", "follow.withdraw-question", { id: string, reason: string }, ["id", "reason"]],
|
|
32
33
|
["set_spec", "Register the link to this workspace's spec: the Claude artifact (or doc) you keep summarizing the goal, decisions and status. Call it once after the first publish, with the URL from the publish result, and again only if the link changes. Follow-up shows it in the workspace header.", "follow.set-spec", { url: { ...string, maxLength: 2000 }, title: { ...string, maxLength: 120 } }, ["url"]],
|
|
33
34
|
["link_item", "Link what this workspace's work is about: the Linear issue, Slack thread, doc or artifact you started from or opened for it. ref is its URL or Linear key; why is one short line. Don't link things you only mention. A PR isn't a linked item: register it with register_pr. An unknown Linear key is refused.", "follow.link-item", { ref: { ...string, maxLength: 2000 }, why: { ...string, maxLength: 140 }, title: { ...string, maxLength: 200 } }, ["ref"]],
|
|
@@ -90,6 +91,9 @@ const actionTools = [
|
|
|
90
91
|
["overseer_start", "Start the Overseer, like Start on Home." + ask, "follow.agent-act", { ...planned }, []],
|
|
91
92
|
["overseer_restart", "Restart the Overseer (with the model Settings → Agents names now)." + ask, "follow.agent-act", { ...planned }, []],
|
|
92
93
|
["overseer_ask", "Send the developer's words to the Overseer, as its box on Home does: { text }." + ask, "follow.agent-act", { text: string, ...planned }, []],
|
|
94
|
+
["catch_up_deck", "Read Catch up's deck: everything that needs the developer, one card per ask in Home's order, with any More context ask on it." + read, "follow.agent-act", {}, []],
|
|
95
|
+
["context_requests", "Read Catch up's More context asks: what the developer asked about a card, who answers, the state and the answer." + read, "follow.agent-act", { workspaceId: string }, []],
|
|
96
|
+
["ask_context", "Ask the Overseer or a card's agent to explain a card for the developer, like Catch up's More context: { workspaceId, agentId, cardKey, card, target: overseer | agent, ask } (cardKey and card from catch_up_deck)." + ask, "follow.agent-act", { workspaceId: string, agentId: string, cardKey: string, card: string, target: { type: "string", enum: ["overseer", "agent"] }, ask: string, ...planned }, []],
|
|
93
97
|
["queue_list", "Read Follow-up's message queue: answers, repairs and forwards waiting to reach agents, with each one's state (queued, sending, retrying, failed), why it waits and when it tries next, plus the newest sent: { workspaceId?, agentId? }." + read, "follow.agent-act", { workspaceId: string, agentId: string }, []],
|
|
94
98
|
["queue_action", "Retry a queued or failed message now, or cancel it so it never goes: { itemId, action: retry | cancel } (ids from queue_list)." + ask, "follow.agent-act", { itemId: string, action: { type: "string", enum: ["retry", "cancel"] }, ...planned }, []],
|
|
95
99
|
["inbox_brief", "Read another agent's full Needs-you brief (decisions, options, links): { agentId }." + read, "follow.agent-act", { agentId: string }, ["agentId"]],
|
|
@@ -102,10 +106,10 @@ const actionTools = [
|
|
|
102
106
|
["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 }, []],
|
|
103
107
|
["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"]],
|
|
104
108
|
["browser_status", "Read whether Send to Paseo is paired and which repositories it may control." + read, "follow.agent-act", {}, []],
|
|
105
|
-
["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." + read, "follow.agent-act", {}, []],
|
|
106
|
-
["updates_status", "Read Settings → General: installed version and install kind, mode (auto|notify|off), channel (stable|beta), newest version per channel, last and next check, phase (current, available, waiting, installing, settling, updated, rolled-back, install-failed, untrusted), notes for the pending version, install history, and move (2.0's one-time move to its new plugin id: phase none|waiting|moving|moved|rolled-back|failed|manual, with the reason)." + read, "follow.agent-act", {}, []],
|
|
109
|
+
["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", {}, []],
|
|
110
|
+
["updates_status", "Read Settings → General: installed version and install kind, mode (auto|notify|off), channel (stable|beta), enable_whats_new, newest version per channel, last and next check, phase (current, available, waiting, installing, settling, updated, rolled-back, install-failed, untrusted), notes for the pending version, install history, and move (2.0's one-time move to its new plugin id: phase none|waiting|moving|moved|rolled-back|failed|manual, with the reason)." + read, "follow.agent-act", {}, []],
|
|
107
111
|
["check_updates", "Ask the registry for a newer Follow-up now, like Check now. Works when updates are Off. Calls a few seconds apart share one request; call it only when asked. Returns updates_status.", "follow.agent-act", {}, []],
|
|
108
|
-
["set_updates", "Change how Follow-up updates, like Settings → General: { mode: auto|notify|off, channel: stable|beta }." + ask, "follow.agent-act", { mode: { type: "string", enum: ["auto", "notify", "off"] }, channel: { type: "string", enum: ["stable", "beta"] }, ...planned }, []],
|
|
112
|
+
["set_updates", "Change how Follow-up updates, like Settings → General: { mode: auto|notify|off, channel: stable|beta, enable_whats_new: show What's new once after an update that brings new release notes (betas never; off records each update as seen) }." + ask, "follow.agent-act", { mode: { type: "string", enum: ["auto", "notify", "off"] }, channel: { type: "string", enum: ["stable", "beta"] }, enable_whats_new: boolean, ...planned }, []],
|
|
109
113
|
["install_update", "Install a newer Follow-up, like Install now: { version } from updates_status. It waits for a quiet moment (no agent mid-turn) unless anyway: true. Rolled back automatically if the new version doesn't come up. Never installs a version whose provenance failed." + ask, "follow.agent-act", { version: string, anyway: boolean, ...planned }, ["version"]],
|
|
110
114
|
["retry_move", "Try Follow-up's move to its new plugin id again, like Settings → General's Try again, after updates_status shows move.phase rolled-back or failed. It waits for a quiet moment like an update and rolls back by itself if the new id doesn't come up." + ask, "follow.agent-act", { ...planned }, []],
|
|
111
115
|
["trust_bypass_status", "Read how many permission prompts trust bypass approved today, and the latest ones." + read, "follow.agent-act", {}, []],
|
|
@@ -128,7 +132,7 @@ const overseerTools = [
|
|
|
128
132
|
const overseerNames = new Set(overseerTools.map(t => t[0]));
|
|
129
133
|
const overseerInstruction = "You are Follow-up's Overseer. Route the developer's asks with route_candidates and send_to_agent; ask with needs_you kind=decision when unsure; start_workspace only when the developer asked or approved. Never merge, post to people or archive.";
|
|
130
134
|
const actionNames = new Set(actionTools.map(t => t[0]));
|
|
131
|
-
const readOnlyTools = new Set(["queue_list", "workspace_status", "list_prs", "inbox_list", "workstreams", "agent_digest", "route_candidates", "workspace_about", "link_items", "agent_settings", "display_settings", "follow_settings", "project_settings", "pr_workflow", "reviewer_settings", "reviewer_suggestions", "onboarding_status", "onboarding_checks", "priorities", "rank_status", "usage", "overseer_status", "inbox_brief", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "updates_status"]);
|
|
135
|
+
const readOnlyTools = new Set(["catch_up_deck", "context_requests", "queue_list", "workspace_status", "list_prs", "inbox_list", "workstreams", "agent_digest", "route_candidates", "workspace_about", "link_items", "agent_settings", "display_settings", "follow_settings", "project_settings", "pr_workflow", "reviewer_settings", "reviewer_suggestions", "onboarding_status", "onboarding_checks", "priorities", "rank_status", "usage", "overseer_status", "inbox_brief", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "updates_status"]);
|
|
132
136
|
const destructiveTools = new Set(["merge"]);
|
|
133
137
|
const actionInstruction = "Follow-up's action tools let you do anything the developer can click, across every tracked workspace and every Settings tab. Read freely: list_prs, inbox_list, inbox_brief, workspace_about, agent_settings, display_settings, follow_settings, project_settings, pr_workflow, reviewer_settings, onboarding_status, priorities, rank_status, usage, overseer_status, pr_controls. Hand the main role on, or claim it, with make_main_agent. Act only when the developer asks (\"the PRs look good, assign reviewers on all\": list_prs needs_reviewers=true, add_reviewers with those keys, then confirm the plan): add_reviewers, merge, enable/disable_merge_when_ready, send_repairs, set_auto_send, clear_hold, retry_batch, track, run_recovery, set_priorities, rerank_priorities; settings with set_display (trust bypass too), set_follow_settings, set_project_tracking, set_pr_workflow, save_reviewers, set_agent_setting, set_wait_for_jobs, set_onboarding; snooze_workspace; ai_rename; and sign_off/snooze/set_finish_flags/inbox_act/brief_action/answer_question for other agents. Planned tools return a dry run showing what changes; run it with confirm=true and its planId. Never sign yourself off or answer your own brief.";
|
|
134
138
|
|
|
@@ -147,7 +151,7 @@ function toolList(recovery = env("RECOVERY") === "1", contributor = false, brief
|
|
|
147
151
|
// Contributors get make_main_agent only (its claim rules apply); recovery sessions get none.
|
|
148
152
|
const acting = !actions || recovery ? [] : contributor ? actionTools.filter(t => t[0] === "make_main_agent" || t[0] === "report_issue") : actionTools;
|
|
149
153
|
if (briefOnly) return [...(brief ? tools.filter(t => t[0] === "needs_you") : []), ...acting];
|
|
150
|
-
return [...tools.filter(t => t[0] === "needs_you" ? brief && !recovery && !contributor : contributor ? ["workspace_status", "register_pr", "sync_workspace", "link_item", "unlink_item"].includes(t[0]) : !recovery || !["declare_done", "sync_workspace", "ask_question", "record_answer", "withdraw_question", "set_spec", "link_item", "unlink_item"].includes(t[0])), ...acting];
|
|
154
|
+
return [...tools.filter(t => t[0] === "needs_you" ? brief && !recovery && !contributor : contributor ? ["workspace_status", "register_pr", "sync_workspace", "link_item", "unlink_item"].includes(t[0]) : !recovery || !["declare_done", "sync_workspace", "ask_question", "record_answer", "withdraw_question", "set_spec", "link_item", "unlink_item", "context_reply"].includes(t[0])), ...acting];
|
|
151
155
|
}
|
|
152
156
|
/** Whether this session may call needs_you: launched as a root agent (FOLLOW_UP_BRIEF) and the inbox is on. */
|
|
153
157
|
async function briefEnabled() {
|
package/server/message-queue.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
3
3
|
import { realpathSync } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
|
-
import { MESSAGE_STUCK_MS, PASEO_UNREACHABLE, PROBE_MS, PROBE_SLOW_MS, PROBE_BACKOFF_AFTER_MS, envelopeText,
|
|
6
|
-
import { ConversationGone, DeliveryDeferred, realTimers, stableMessageId, withDeadline, type Timers } from "./delivery";
|
|
5
|
+
import { MESSAGE_STUCK_MS, PASEO_UNREACHABLE, PROBE_MS, PROBE_SLOW_MS, PROBE_BACKOFF_AFTER_MS, envelopeText, ambiguousDelay, GONE_REASON, QUEUE_ATTEMPT_MS, QUEUE_CAP_MS, QUEUE_QUIET_MS, QUEUE_RECENT, neverLeftDelay, queueFileSchema, queueItemSchema, type QueueFile, type QueueItem, type QueueItemInput, type NewQueueItem, type QueueKind } from "../shared/queue";
|
|
6
|
+
import { ConversationGone, DeliveryDeferred, idRefused, realTimers, stableMessageId, withDeadline, type Timers } from "./delivery";
|
|
7
7
|
import { WriteBehind, type WriteHealth } from "./write-behind";
|
|
8
8
|
import type { Workspace } from "../shared/model";
|
|
9
9
|
|
|
@@ -17,7 +17,8 @@ import type { Workspace } from "../shared/model";
|
|
|
17
17
|
* forever, and at once on worker start and when the daemon connection comes back. It never ends in failed.
|
|
18
18
|
* - A send that left unconfirmed (an error after the message went out, the attempt's deadline) is `uncertain`: before
|
|
19
19
|
* any resend the agent's chat is read for the messageId (Courier.arrived). There: sent. Not there: resent. Unknown:
|
|
20
|
-
* the next AMBIGUOUS_MS step,
|
|
20
|
+
* the next AMBIGUOUS_MS step, its last step repeating until the chat can tell: never failed. Only a gone conversation
|
|
21
|
+
* (ConversationGone) ends failed, the one way out that isn't delivered or a next try. Paseo never refuses a resend by messageId (it
|
|
21
22
|
* only skips the timeline row; the provider runs the prompt again), so a blind resend arrives twice.
|
|
22
23
|
* - The recipient is resolved when the envelope goes out (Channel.resolve), never at enqueue: an answer whose asker was
|
|
23
24
|
* archived reaches the workspace's agent, and a workspace no longer followed cancels it with a reason on the card.
|
|
@@ -49,6 +50,8 @@ export interface Courier {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export const QUEUE_FILE = "queue.json";
|
|
53
|
+
/** Why an uncertain item waits (Retrying's reason): the same words the card shows from the first unconfirmed send. */
|
|
54
|
+
export const UNKNOWN_REASON = "Paseo didn't confirm it";
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
57
|
* FOLLOW_UP_QUEUE_TIME_SCALE shrinks the retry ladder, for harness runs only. It counts only when the data dir is under
|
|
@@ -99,13 +102,18 @@ export class MessageQueue {
|
|
|
99
102
|
|
|
100
103
|
register(kind: QueueKind, channel: Channel): void { this.channels.set(kind, channel); }
|
|
101
104
|
|
|
102
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Reads queue.json. A send a reload interrupted is `uncertain`: its chat is read before anything is resent. A Failed
|
|
107
|
+
* item whose target isn't gone (an older version gave up after the ladder of unknowns) goes back to checking, so no
|
|
108
|
+
* message stays stopped short across an upgrade (a-queued-message-never-stops-short).
|
|
109
|
+
*/
|
|
103
110
|
async load(): Promise<void> {
|
|
104
111
|
let file: QueueFile = { version: 1, items: [], recent: [], migrations: [] };
|
|
105
112
|
try { file = queueFileSchema.parse(JSON.parse(await readFile(join(this.directory, QUEUE_FILE), "utf8"))); }
|
|
106
113
|
catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") console.warn(`[follow-up] queue.json unreadable, starting empty: ${error instanceof Error ? error.message : String(error)}`); }
|
|
107
114
|
for (const item of file.items) {
|
|
108
115
|
if (item.state === "sending") Object.assign(item, { state: "uncertain", reason: "Follow-up reloaded mid-send", nextAt: this.iso() });
|
|
116
|
+
else if (item.state === "failed" && !item.gone) Object.assign(item, item.envelope ? { state: "uncertain", reason: UNKNOWN_REASON, nextAt: this.iso() } : { state: "queued", reason: null, nextAt: this.iso() });
|
|
109
117
|
this.items.set(item.id, item);
|
|
110
118
|
}
|
|
111
119
|
this.recent = file.recent; this.migrations = file.migrations; this.loaded = true;
|
|
@@ -265,9 +273,10 @@ export class MessageQueue {
|
|
|
265
273
|
const arrived = await this.check(item, r.target);
|
|
266
274
|
if (arrived.found) { await this.settle(item, "sent", null, arrived.found); return null; }
|
|
267
275
|
if (arrived.unknown) {
|
|
276
|
+
// An unknown isn't a no: check again on the ladder, its last step for as long as the chat can't tell. Never
|
|
277
|
+
// failed here (a-queued-message-never-stops-short): only a gone target stops a message.
|
|
278
|
+
Object.assign(item, { reason: UNKNOWN_REASON, nextAt: this.iso(ambiguousDelay(item.unknowns) * this.scale) });
|
|
268
279
|
item.unknowns++;
|
|
269
|
-
if (item.unknowns >= AMBIGUOUS_MS.length) { item.state = "failed"; item.nextAt = null; item.reason = "Follow-up couldn't confirm the agent got it."; }
|
|
270
|
-
else item.nextAt = this.iso(AMBIGUOUS_MS[item.unknowns] * this.scale);
|
|
271
280
|
await this.project(item); this.save();
|
|
272
281
|
return null;
|
|
273
282
|
}
|
|
@@ -277,9 +286,13 @@ export class MessageQueue {
|
|
|
277
286
|
private async check(item: QueueItem, target: Target): Promise<{ found: string | null; unknown: boolean }> {
|
|
278
287
|
const env = item.envelope!;
|
|
279
288
|
const marker = item.text.split("\n")[0]!.slice(0, 200);
|
|
289
|
+
// Every id it went out under: a resend under a fresh id (a refused one) mustn't hide that the first one landed.
|
|
290
|
+
const ids = [...new Set([...item.sentIds, env.messageId])];
|
|
291
|
+
// An earlier id went out before this envelope: read back to the item's start for it.
|
|
292
|
+
const since = ids.length > 1 ? item.createdAt : env.at;
|
|
280
293
|
let unknown = false;
|
|
281
|
-
for (const agentId of env.to ? [env.to] : target.recipients) {
|
|
282
|
-
const seen = await this.courier.arrived(agentId,
|
|
294
|
+
for (const agentId of env.to ? [env.to] : target.recipients) for (const id of ids) {
|
|
295
|
+
const seen = await this.courier.arrived(agentId, id, since, marker).catch(() => null);
|
|
283
296
|
if (seen === true) return { found: agentId, unknown: false };
|
|
284
297
|
if (seen === null) unknown = true;
|
|
285
298
|
}
|
|
@@ -291,9 +304,12 @@ export class MessageQueue {
|
|
|
291
304
|
* the chat showed it missing is the same message again.
|
|
292
305
|
*/
|
|
293
306
|
private async send(items: QueueItem[], target: Target): Promise<void> {
|
|
294
|
-
const
|
|
307
|
+
const base = items.length === 1 ? items[0]!.messageId : stableMessageId(`envelope:${items.map(i => i.id).join("|")}`);
|
|
308
|
+
// A messageId Paseo refused for good (a stuck receipt) is replaced by one derived from it, the same on every resend.
|
|
309
|
+
const generation = Math.max(...items.map(i => i.generation));
|
|
310
|
+
const messageId = generation ? stableMessageId(`${base}:${generation}`) : base;
|
|
295
311
|
const at = this.iso();
|
|
296
|
-
for (const item of items) Object.assign(item, { state: "sending", envelope: { messageId, to: null, at }, nextAt: null });
|
|
312
|
+
for (const item of items) Object.assign(item, { state: "sending", envelope: { messageId, to: null, at }, nextAt: null, sentIds: item.sentIds.includes(messageId) ? item.sentIds : [...item.sentIds, messageId].slice(-50) });
|
|
297
313
|
await this.saveNow();
|
|
298
314
|
for (const item of items) await this.project(item);
|
|
299
315
|
if (this.stopped) return;
|
|
@@ -308,8 +324,14 @@ export class MessageQueue {
|
|
|
308
324
|
if (this.stopped) return;
|
|
309
325
|
for (const item of items) {
|
|
310
326
|
if (error instanceof DeliveryDeferred) { item.envelope = null; await this.neverLeft(item, error.message); continue; }
|
|
311
|
-
if (error instanceof ConversationGone) { Object.assign(item, { state: "failed", nextAt: null, gone: error.agentId, reason:
|
|
312
|
-
|
|
327
|
+
if (error instanceof ConversationGone) { Object.assign(item, { state: "failed", nextAt: null, gone: error.agentId, reason: GONE_REASON }); await this.project(item); continue; }
|
|
328
|
+
// Each unconfirmed send climbs the same ladder as a check that can't tell, so an agent Paseo can't load yet
|
|
329
|
+
// (every send times out, every check says it isn't there) is tried at 15 s, 1 min, 5 min, then every 15 min,
|
|
330
|
+
// not every 15 s.
|
|
331
|
+
Object.assign(item, { state: "uncertain", reason: UNKNOWN_REASON, nextAt: this.iso(ambiguousDelay(item.unknowns) * this.scale) });
|
|
332
|
+
item.unknowns++;
|
|
333
|
+
// Paseo refused this id for good: the resend (only after the chat shows it missing) goes under a fresh one.
|
|
334
|
+
if (idRefused(error) && item.generation === generation) item.generation++;
|
|
313
335
|
await this.project(item);
|
|
314
336
|
}
|
|
315
337
|
if (!(error instanceof DeliveryDeferred)) console.warn(`[follow-up] message to ${target.recipients.join(", ")} not confirmed: ${error instanceof Error ? error.message : String(error)}`);
|
package/server/transcript.ts
CHANGED
|
@@ -160,6 +160,62 @@ const HEAD_BYTES = 256 * 1024;
|
|
|
160
160
|
export type TranscriptItem = { type: "user_message" | "assistant_message" | "tool_call"; text?: string; name?: string; detail?: { output: string } };
|
|
161
161
|
|
|
162
162
|
/** The first and last bytes of a file; lines cut at the edges are dropped. */
|
|
163
|
+
/**
|
|
164
|
+
* Whether a transcript's read part holds `marker` since `sinceMs`: true when a line has it; false only when the read
|
|
165
|
+
* part provably reaches back to `sinceMs` (the whole file was read, or its first dated line is no later) and no line has
|
|
166
|
+
* it; null otherwise. Lines are JSONL (Claude and Codex both date each line with `timestamp`).
|
|
167
|
+
*/
|
|
168
|
+
export function markerSince(lines: readonly string[], whole: boolean, sinceMs: number, marker: string): boolean | null {
|
|
169
|
+
if (!marker) return null;
|
|
170
|
+
const needle = JSON.stringify(marker).slice(1, -1);
|
|
171
|
+
if (lines.some(line => line.includes(needle))) return true;
|
|
172
|
+
return whole || reachesBack(lines, sinceMs) ? false : null;
|
|
173
|
+
}
|
|
174
|
+
/** Whether the first dated line (`"timestamp"`) is no later than `sinceMs`: the lines cover everything since then. */
|
|
175
|
+
function reachesBack(lines: readonly string[], sinceMs: number): boolean {
|
|
176
|
+
for (const line of lines) {
|
|
177
|
+
const m = /"timestamp"\s*:\s*"([^"]+)"/.exec(line);
|
|
178
|
+
if (!m) continue;
|
|
179
|
+
const at = Date.parse(m[1]!);
|
|
180
|
+
if (Number.isFinite(at)) return at <= sinceMs;
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
/** How far back from its end a transcript is read for a send's marker, in chunks. Only an unconfirmed send reads it. */
|
|
187
|
+
export const MARKER_READ_MAX_BYTES = 32 * 1024 * 1024;
|
|
188
|
+
const MARKER_CHUNK_BYTES = 1024 * 1024;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Whether the transcript at `path` holds `marker` since `sinceMs`, read backwards from its end in 1 MB chunks until a
|
|
192
|
+
* chunk reaches back past `sinceMs`, the file's start, or MARKER_READ_MAX_BYTES: a busy agent writes megabytes between a
|
|
193
|
+
* send and its check, so a fixed tail can't say "not there". Each chunk is searched raw for the marker first; only the
|
|
194
|
+
* chunk's first dated line is parsed. Same answers as markerSince.
|
|
195
|
+
*/
|
|
196
|
+
export async function markerInFile(path: string, sinceMs: number, marker: string, maxBytes = MARKER_READ_MAX_BYTES): Promise<boolean | null> {
|
|
197
|
+
if (!marker) return null;
|
|
198
|
+
const needle = Buffer.from(JSON.stringify(marker).slice(1, -1));
|
|
199
|
+
const handle = await open(path, "r");
|
|
200
|
+
try {
|
|
201
|
+
const size = (await handle.stat()).size;
|
|
202
|
+
let end = size; let carry = Buffer.alloc(0);
|
|
203
|
+
while (end > 0 && size - end < maxBytes) {
|
|
204
|
+
const start = Math.max(0, end - MARKER_CHUNK_BYTES);
|
|
205
|
+
const buf = Buffer.alloc(end - start);
|
|
206
|
+
const { bytesRead } = await handle.read(buf, 0, buf.length, start);
|
|
207
|
+
// The chunk plus the next one's head, so a marker cut at the edge is still found.
|
|
208
|
+
const joined = Buffer.concat([buf.subarray(0, bytesRead), carry.subarray(0, needle.length)]);
|
|
209
|
+
if (joined.includes(needle)) return true;
|
|
210
|
+
if (start === 0) return false;
|
|
211
|
+
const lines = buf.subarray(0, bytesRead).toString("utf8").split("\n"); lines.shift();
|
|
212
|
+
if (reachesBack(lines, sinceMs)) return false;
|
|
213
|
+
carry = buf.subarray(0, bytesRead); end = start;
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
} finally { await handle.close(); }
|
|
217
|
+
}
|
|
218
|
+
|
|
163
219
|
export async function headAndTail(path: string): Promise<{ head: string[]; tail: string[] }> {
|
|
164
220
|
const handle = await open(path, "r");
|
|
165
221
|
try {
|
package/server/updater.ts
CHANGED
|
@@ -129,9 +129,10 @@ export class Updater {
|
|
|
129
129
|
/** A turn started or ended somewhere: if an update is waiting for a quiet moment, look again. */
|
|
130
130
|
activity(): void { void this.d.read().then(f => { if (f.ready) return this.evaluate(); }).catch(() => undefined); }
|
|
131
131
|
|
|
132
|
-
async setSettings(change: { mode?: UpdateMode; channel?: Channel }): Promise<void> {
|
|
132
|
+
async setSettings(change: { mode?: UpdateMode; channel?: Channel; enable_whats_new?: boolean }): Promise<void> {
|
|
133
133
|
const file = await this.d.read();
|
|
134
|
-
const next: UpdatesFile = { ...file, ...(change.mode ? { mode: change.mode } : {}), ...(change.channel ? { channel: change.channel } : {})
|
|
134
|
+
const next: UpdatesFile = { ...file, ...(change.mode ? { mode: change.mode } : {}), ...(change.channel ? { channel: change.channel } : {}),
|
|
135
|
+
...(typeof change.enable_whats_new === "boolean" ? { enable_whats_new: change.enable_whats_new } : {}) };
|
|
135
136
|
// A channel or mode change re-decides what's waiting.
|
|
136
137
|
if (change.channel && change.channel !== file.channel) delete next.ready;
|
|
137
138
|
if (change.mode && change.mode !== "auto" && next.ready && !next.ready.manual) delete next.ready;
|
|
@@ -262,20 +263,20 @@ export class Updater {
|
|
|
262
263
|
}
|
|
263
264
|
|
|
264
265
|
async view(): Promise<UpdatesView> {
|
|
265
|
-
const { file, me, mode, channel } = await this.settings();
|
|
266
|
+
const { file, me, mode, channel, enable_whats_new } = await this.settings();
|
|
266
267
|
const snap = await this.d.registry.snapshot();
|
|
267
268
|
const now = this.now();
|
|
268
269
|
const events = await readEvents(this.d.directory);
|
|
269
270
|
const channels = { stable: offerVersion("stable", snap), beta: offerVersion("beta", snap) };
|
|
270
|
-
const base = { version: me.version, installKind: me.installKind, mode, channel, channels, checkedAt: snap.okAt, registryError: snap.error,
|
|
271
|
+
const base = { version: me.version, installKind: me.installKind, mode, channel, enable_whats_new, channels, checkedAt: snap.okAt, registryError: snap.error,
|
|
271
272
|
nextCheckAt: mode === "off" || me.installKind !== "npm" ? null : (snap.checkedAt ?? now) + CHECK_INTERVAL_MS, pendingNotes: [] as UpdatesView["pendingNotes"], history: historyOf(events) };
|
|
272
273
|
const phase = await this.phase(file, me.version, mode, channel, snap, events, now);
|
|
273
274
|
const dismissed = new Set(file.dismissed ?? []);
|
|
274
275
|
let notice: UpdatesView["notice"] = null;
|
|
275
276
|
if (me.installKind === "npm") {
|
|
276
277
|
if (phase.kind === "rolled-back") notice = { id: `rolled-back:${phase.version}`, kind: "rolled-back", version: phase.version, from: phase.from };
|
|
277
|
-
//
|
|
278
|
-
//
|
|
278
|
+
// Every newer stable earns a Home notice in Tell me mode; prereleases stay in Settings → General.
|
|
279
|
+
// The rollback notice reports a failure, not an available update.
|
|
279
280
|
else if (phase.kind === "available" && mode === "notify" && announcesUpdate(me.version, phase.version)) notice = { id: `available:${phase.version}`, kind: "available", version: phase.version, from: null };
|
|
280
281
|
if (notice && dismissed.has(notice.id)) notice = null;
|
|
281
282
|
}
|
package/server/updates.ts
CHANGED
|
@@ -7,6 +7,8 @@ import type { UpdateMode } from "../shared/updates";
|
|
|
7
7
|
export type UpdatesFile = {
|
|
8
8
|
mode?: UpdateMode;
|
|
9
9
|
channel?: Channel;
|
|
10
|
+
/** Show What's new after an update (Settings → General); absent means on. Off records each version as seen quietly. */
|
|
11
|
+
enable_whats_new?: boolean;
|
|
10
12
|
/** Home notices the developer closed, by id. */
|
|
11
13
|
dismissed?: string[];
|
|
12
14
|
/** A newer version allowed to install, waiting for a quiet moment. `manual`: Install now asked for it. */
|
|
@@ -39,7 +41,7 @@ export class UpdatesStore {
|
|
|
39
41
|
* Defaults: the channel follows the installed version. An existing install starts at Tell me; a fresh one at Install
|
|
40
42
|
* automatically, which setup shows pre-selected and saves when passed or skipped.
|
|
41
43
|
*/
|
|
42
|
-
export function settingsOf(file: UpdatesFile, version: string, fallback: UpdateMode = "notify"): { mode: UpdateMode; channel: Channel } {
|
|
43
|
-
return { mode: file.mode ?? fallback, channel: isChannel(file.channel) ? file.channel : defaultChannel(version) };
|
|
44
|
+
export function settingsOf(file: UpdatesFile, version: string, fallback: UpdateMode = "notify"): { mode: UpdateMode; channel: Channel; enable_whats_new: boolean } {
|
|
45
|
+
return { mode: file.mode ?? fallback, channel: isChannel(file.channel) ? file.channel : defaultChannel(version), enable_whats_new: file.enable_whats_new !== false };
|
|
44
46
|
}
|
|
45
47
|
|
package/shared/attention.ts
CHANGED
|
@@ -196,8 +196,9 @@ function computeNeedsYou(w: Workspace, now: number): NeedItem[] {
|
|
|
196
196
|
const numbers = a.prs.map(key => `#${key.split("#")[1]}`).join(", ");
|
|
197
197
|
items.push({ kind: "check", key: `check:${a.id}`, actionId: a.id, ...(a.prs.length === 1 ? linkFor(a.prs[0]) : {}), title: `Check the ${a.kind === "merge" ? "merge" : a.kind === "request_reviewers" ? "reviewer request" : "merge-when-ready change"} on ${numbers}`, detail: a.result });
|
|
198
198
|
}
|
|
199
|
-
// The queue's rare loud case (a-message-is-saved-before-sent-and-arrives-once): the
|
|
200
|
-
//
|
|
199
|
+
// The queue's rare loud case (a-message-is-saved-before-sent-and-arrives-once): the agent's conversation is gone, so
|
|
200
|
+
// it is the developer's to check and Retry. Everything else, an unknown arrival included, retries on its own
|
|
201
|
+
// (a-queued-message-never-stops-short).
|
|
201
202
|
for (const q of questions.filter(q => q.answer?.delivery.state === "failed"))
|
|
202
203
|
items.push({ kind: "answer", key: `answer:${q.id}`, questionId: q.id, title: `Your ${q.id} answer: Failed`, detail: deliveryStatus({ state: "failed", reason: q.answer!.delivery.reason }).detail });
|
|
203
204
|
// A message with no card of its own that didn't go out (a-message-is-saved-before-sent-and-arrives-once).
|