paseo-follow-up 2.2.0-beta.1 → 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/client/brief.tsx +4 -2
- 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 +11 -4
- package/index.server.ts +62 -4
- package/package.json +1 -1
- package/server/agent-actions.ts +1 -1
- package/server/agent-hook.mjs +1 -1
- package/server/agent-parity.ts +9 -0
- 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 +6 -2
- package/server/mcp.mjs +6 -2
- package/server/message-queue.ts +34 -12
- package/server/transcript.ts +56 -0
- package/shared/attention.ts +3 -2
- package/shared/catch-up.ts +249 -0
- package/shared/chat.ts +1 -1
- package/shared/contracts.ts +15 -0
- package/shared/questions.ts +7 -2
- package/shared/queue.ts +28 -3
- package/shared/status-invariants.ts +14 -0
package/server/agent-hook.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const directory = dirname(fileURLToPath(import.meta.url));
|
|
|
13
13
|
/** 1.4.0-beta.2: launched with Follow-up's tools served by Paseo's MCP (follow_<name>), or the follow-up bridge (<name>). Agents opened before the upgrade carry no flag and keep the bridge names. */
|
|
14
14
|
let native = env("TOOLS") === "native";
|
|
15
15
|
// Tool names that read unambiguously in prose; kept identical to server/mcp.mjs's underscore names (a test checks it).
|
|
16
|
-
export const TOOL_NAMES = ["workspace_status", "sync_workspace", "enroll_workspace", "register_pr", "exclude_stack", "update_obligation", "acknowledge_batch", "ask_question", "record_answer", "withdraw_question", "set_spec", "link_item", "unlink_item", "link_items", "set_linked_items", "workspace_about", "agent_settings", "needs_you", "declare_done", "list_prs", "add_reviewers", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "inbox_list", "sign_off", "snooze_workspace", "set_finish_flags", "set_priorities", "agent_digest", "route_candidates", "send_to_agent", "start_workspace", "display_settings", "set_display", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "rank_status", "rerank_priorities", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "run_recovery", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "updates_status", "check_updates", "set_updates", "install_update", "make_main_agent", "retry_move", "report_issue", "report_send", "ai_rename"];
|
|
16
|
+
export const TOOL_NAMES = ["workspace_status", "sync_workspace", "enroll_workspace", "register_pr", "exclude_stack", "update_obligation", "acknowledge_batch", "ask_question", "record_answer", "withdraw_question", "set_spec", "link_item", "unlink_item", "link_items", "set_linked_items", "workspace_about", "agent_settings", "needs_you", "declare_done", "list_prs", "add_reviewers", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "inbox_list", "sign_off", "snooze_workspace", "set_finish_flags", "set_priorities", "agent_digest", "route_candidates", "send_to_agent", "start_workspace", "display_settings", "set_display", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "rank_status", "rerank_priorities", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "run_recovery", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "updates_status", "check_updates", "set_updates", "install_update", "make_main_agent", "retry_move", "report_issue", "report_send", "ai_rename", "catch_up_deck", "context_requests", "ask_context", "context_reply"];
|
|
17
17
|
const toolPattern = new RegExp(`(?<![\\w])(${TOOL_NAMES.join("|")})(?![\\w])`, "g");
|
|
18
18
|
/** Names Follow-up's tools the way this agent has them. */
|
|
19
19
|
export function named(text, isNative = native) { return isNative ? text.replace(toolPattern, "follow_$1") : text; }
|
package/server/agent-parity.ts
CHANGED
|
@@ -69,6 +69,14 @@ export const RPC_TOOLS: readonly RpcTool[] = [
|
|
|
69
69
|
{ name: "overseer_start", rpc: "follow.overseer-start", kind: "planned", before: { rpc: "follow.overseer-status" }, input: z.strictObject({ ...confirm }) },
|
|
70
70
|
{ name: "overseer_restart", rpc: "follow.overseer-restart", kind: "planned", before: { rpc: "follow.overseer-status" }, input: z.strictObject({ ...confirm }) },
|
|
71
71
|
{ name: "overseer_ask", rpc: "follow.overseer-ask", kind: "planned", input: z.strictObject({ text: z.string().trim().min(1).max(2000).optional(), ...confirm }) },
|
|
72
|
+
// Catch up: the deck, and More context (ask, read the asks); the asked agent answers with context_reply
|
|
73
|
+
{ name: "catch_up_deck", rpc: "follow.catch-up-deck", kind: "read", input: none },
|
|
74
|
+
{ name: "context_requests", rpc: "follow.context-list", kind: "read", input: z.strictObject({ workspaceId: id.optional() }) },
|
|
75
|
+
{ name: "ask_context", rpc: "follow.context-ask", kind: "planned", before: { rpc: "follow.context-list", input: a => ({ workspaceId: a.workspaceId ?? undefined }) },
|
|
76
|
+
input: z.strictObject({ workspaceId: id.nullable().optional(), agentId: id.nullable().optional(), cardKey: z.string().min(1).max(400).optional(), card: z.string().trim().min(1).max(300).optional(),
|
|
77
|
+
target: z.enum(["overseer", "agent"]).optional(), ask: z.string().trim().min(1).max(2000).optional(), ...confirm }),
|
|
78
|
+
toRpc: a => ({ workspaceId: a.workspaceId ?? null, agentId: a.agentId ?? null, cardKey: a.cardKey, card: a.card, target: a.target, ask: a.ask }),
|
|
79
|
+
guard: (a, caller) => a.target === "agent" && a.agentId === caller ? "ask_context asks another agent about its card; explain your own ask in your reply." : null },
|
|
72
80
|
// Needs-you: the brief card and the inbox's other actions
|
|
73
81
|
// The message queue: what waits to go to agents, and Retry or Cancel on one item (a card's Retry, Needs you's message row).
|
|
74
82
|
{ name: "queue_list", rpc: "follow.queue-list", kind: "read", input: z.strictObject({ workspaceId: id.optional(), agentId: id.optional() }) },
|
|
@@ -206,5 +214,6 @@ export const PARITY: Record<string, { tools: readonly string[]; note?: string }
|
|
|
206
214
|
* note says where an agent finds what the developer found.
|
|
207
215
|
*/
|
|
208
216
|
export const VIEW_PARITY: Record<string, { tools: readonly string[]; note: string }> = {
|
|
217
|
+
"catch-up": { tools: ["catch_up_deck", "answer_question", "brief_action", "inbox_act", "snooze", "ask_context"], note: "Catch up deals Needs you one card at a time; moving between cards (Skip, Back) changes only the developer's view. catch_up_deck reads the same deck, and every act on a card is a tool: answer_question, brief_action, inbox_act and snooze (Later), ask_context (More context). A permission is Paseo's own respond_to_permission." },
|
|
209
218
|
"section-search": { tools: ["workspace_status", "list_prs"], note: "The panel's Pull requests, Tasks and Activity search filters lists an agent already reads whole: workspace_status returns the workspace's PRs (title, branch, failed checks), tasks with their evidence, questions with their answers, and the sends, merges and PR actions the timeline is drawn from; list_prs returns every tracked PR with its checks." },
|
|
210
219
|
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { WriteBehind } from "./write-behind";
|
|
5
|
+
import { CONTEXT_ANSWER_MAX, contextFileSchema, pruneContext, type ContextFile, type ContextRequest, type ContextTarget } from "../shared/catch-up";
|
|
6
|
+
|
|
7
|
+
export const CONTEXT_FILE = "context.json";
|
|
8
|
+
|
|
9
|
+
export type AskInput = { workspaceId: string | null; agentId: string | null; cardKey: string; card: string; target: ContextTarget; ask: string };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Catch up's More context requests (docs/needs-you.md#catch-up): what the developer asked about a card, who answers
|
|
13
|
+
* (the Overseer or the card's agent), and the answer once `context_reply` brings it. The value lives in memory and
|
|
14
|
+
* saves behind the reply (an-ack-never-waits-on-the-disk); a change calls `onChange`, which pushes Home's feed, so the
|
|
15
|
+
* client learns an answer arrived without polling. Small by construction: at most CONTEXT_MAX requests, none older
|
|
16
|
+
* than CONTEXT_KEEP_MS.
|
|
17
|
+
*/
|
|
18
|
+
export class ContextRequests {
|
|
19
|
+
private value: ContextFile | null = null;
|
|
20
|
+
readonly persist: WriteBehind<ContextFile>;
|
|
21
|
+
onChange: () => void = () => undefined;
|
|
22
|
+
constructor(readonly directory: string, private now: () => number = Date.now) {
|
|
23
|
+
this.persist = new WriteBehind({ path: join(directory, CONTEXT_FILE), encode: v => JSON.stringify(v) });
|
|
24
|
+
}
|
|
25
|
+
async flush(): Promise<void> { await this.persist.flush(); }
|
|
26
|
+
|
|
27
|
+
private async load(): Promise<ContextFile> {
|
|
28
|
+
if (this.value) return this.value;
|
|
29
|
+
let value: ContextFile;
|
|
30
|
+
try { value = contextFileSchema.parse(JSON.parse(await readFile(join(this.directory, CONTEXT_FILE), "utf8"))); }
|
|
31
|
+
catch { value = { requests: [] }; } // Lost context requests cost a re-ask, never a broken Home.
|
|
32
|
+
this.value ??= value;
|
|
33
|
+
return this.value;
|
|
34
|
+
}
|
|
35
|
+
private save(requests: ContextRequest[]): void {
|
|
36
|
+
this.value = contextFileSchema.parse({ requests: pruneContext(requests, this.now()) });
|
|
37
|
+
this.persist.set(this.value);
|
|
38
|
+
this.onChange();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async list(filter: { workspaceId?: string } = {}): Promise<ContextRequest[]> {
|
|
42
|
+
const { requests } = await this.load();
|
|
43
|
+
const live = pruneContext(requests, this.now());
|
|
44
|
+
return filter.workspaceId ? live.filter(r => r.workspaceId === filter.workspaceId) : live;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Records an ask. One open ask per card: asking again while it's open returns that one (`fresh: false`). */
|
|
48
|
+
async ask(input: AskInput, by: string, askedOf: string | null): Promise<{ request: ContextRequest; fresh: boolean }> {
|
|
49
|
+
const { requests } = await this.load();
|
|
50
|
+
const open = requests.find(r => r.cardKey === input.cardKey && r.state === "asking");
|
|
51
|
+
if (open) return { request: open, fresh: false };
|
|
52
|
+
const request: ContextRequest = {
|
|
53
|
+
id: `ctx-${randomUUID()}`, ...input, askedOf, state: "asking", answer: null, error: null,
|
|
54
|
+
askedAt: new Date(this.now()).toISOString(), settledAt: null, by,
|
|
55
|
+
};
|
|
56
|
+
this.save([...requests, request]);
|
|
57
|
+
return { request, fresh: true };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private async update(id: string, change: (r: ContextRequest) => ContextRequest | null): Promise<ContextRequest | null> {
|
|
61
|
+
const { requests } = await this.load();
|
|
62
|
+
const i = requests.findIndex(r => r.id === id);
|
|
63
|
+
if (i < 0) return null;
|
|
64
|
+
const next = change(requests[i]);
|
|
65
|
+
if (!next || next === requests[i]) return requests[i];
|
|
66
|
+
this.save(requests.map((r, j) => j === i ? next : r));
|
|
67
|
+
return next;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Who replies is learnt after the send (the Overseer's id). */
|
|
71
|
+
setAskedOf(id: string, askedOf: string): Promise<ContextRequest | null> {
|
|
72
|
+
return this.update(id, r => r.askedOf === askedOf ? r : { ...r, askedOf });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The asked agent's answer (context_reply). Only the agent it was asked of may answer it (ownership comes from the
|
|
77
|
+
* daemon, invariant 5); an answer to a settled request replaces it, so a corrected reply wins.
|
|
78
|
+
*/
|
|
79
|
+
async reply(id: string, caller: string, text: string): Promise<ContextRequest> {
|
|
80
|
+
const r = (await this.list()).find(x => x.id === id);
|
|
81
|
+
if (!r) throw new Error(`No open context request ${id}. It may have expired; the developer can ask again.`);
|
|
82
|
+
if (r.askedOf !== caller) throw new Error("This context request was asked of another agent.");
|
|
83
|
+
const answer = text.trim().slice(0, CONTEXT_ANSWER_MAX);
|
|
84
|
+
if (!answer) throw new Error("context_reply: give text, the explanation for the developer.");
|
|
85
|
+
return (await this.update(id, x => ({ ...x, state: "answered", answer, error: null, settledAt: new Date(this.now()).toISOString() })))!;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The send failed for good (no Overseer, the agent archived): the card comes back saying so. */
|
|
89
|
+
fail(id: string, error: string): Promise<ContextRequest | null> {
|
|
90
|
+
return this.update(id, r => r.state !== "asking" ? r : { ...r, state: "failed", error: error.slice(0, 500), settledAt: new Date(this.now()).toISOString() });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* An asked agent's turn ended. If it started after the ask and the agent didn't reply with the tool, the answer is in
|
|
95
|
+
* its chat: the card comes back with Open chat. Costs a lookup in a list of at most CONTEXT_MAX; no reads.
|
|
96
|
+
*/
|
|
97
|
+
private started = new Map<string, number>();
|
|
98
|
+
/** An agent's turn started: remembered only while that agent owes a reply. */
|
|
99
|
+
turnStarted(agentId: string): void {
|
|
100
|
+
if (this.value?.requests.some(r => r.state === "asking" && r.askedOf === agentId)) this.started.set(agentId, this.now());
|
|
101
|
+
}
|
|
102
|
+
async turnEnded(agentId: string): Promise<void> {
|
|
103
|
+
const turnStartedAt = this.started.get(agentId) ?? null;
|
|
104
|
+
this.started.delete(agentId);
|
|
105
|
+
if (!this.value?.requests.some(r => r.state === "asking" && r.askedOf === agentId)) return;
|
|
106
|
+
for (const r of this.value.requests.filter(r => r.state === "asking" && r.askedOf === agentId)) {
|
|
107
|
+
if (turnStartedAt === null || turnStartedAt < Date.parse(r.askedAt)) continue;
|
|
108
|
+
await this.update(r.id, x => x.state !== "asking" ? x : { ...x, state: "chat", settledAt: new Date(this.now()).toISOString() });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
package/server/daemon.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { ConversationGone } from "./delivery";
|
|
|
28
28
|
import { compactionDelivered, turnIdOf } from "../shared/status";
|
|
29
29
|
import { activeWindowMs, backgroundCount, isLive, isLoaded, recentlyUsed, workspaceActive, conversationGone, DEFAULT_ACTIVE_WINDOW_DAYS, DAY_MS } from "./agent-load";
|
|
30
30
|
import { HistoryCache } from "./history-cache";
|
|
31
|
-
import { agentRecord,
|
|
31
|
+
import { agentRecord, markerInFile, transcriptFile } from "./transcript";
|
|
32
32
|
import { DaemonDirectory, type DirectoryRows } from "./directory";
|
|
33
33
|
import { traceDaemon } from "./request-trace";
|
|
34
34
|
import type { TurnTimeline } from "./turn-timeline";
|
|
@@ -620,19 +620,24 @@ export class PaseoGateway implements Gateway {
|
|
|
620
620
|
/**
|
|
621
621
|
* Whether `messageId` reached the agent since `since`. A loaded agent: its timeline, where Paseo records the message
|
|
622
622
|
* with its clientMessageId when it accepts it (before the provider runs). An unloaded one is never read (that would
|
|
623
|
-
* wake it, Invariant 1): its provider transcript on disk is searched for `marker` instead,
|
|
624
|
-
*
|
|
623
|
+
* wake it, Invariant 1): its provider transcript on disk is searched for `marker` instead, as it is for a loaded agent
|
|
624
|
+
* whose timeline read can't tell (a busy one); it says "not there" only when the part read reaches back to the send
|
|
625
|
+
* (markerInFile). Null: unknown.
|
|
625
626
|
*/
|
|
626
627
|
async arrivedMessage(agentId: string, messageId: string, since: string, marker: string): Promise<boolean | null> {
|
|
627
|
-
const
|
|
628
|
+
const sinceMs = Date.parse(since) - 60_000;
|
|
629
|
+
const timeline = await this.connect(async client => {
|
|
628
630
|
const a = (await client.fetchAgent(agentId))?.agent;
|
|
629
631
|
if (!a) return null;
|
|
630
|
-
if (!isLoaded(a)) return
|
|
631
|
-
return timelineHas(client, agentId, messageId,
|
|
632
|
+
if (!isLoaded(a)) return null;
|
|
633
|
+
return timelineHas(client, agentId, messageId, sinceMs);
|
|
632
634
|
}).catch(() => null);
|
|
633
|
-
|
|
634
|
-
|
|
635
|
+
// The timeline can't tell (the agent isn't loaded, or a busy one wrote more than the read's pages since the send):
|
|
636
|
+
// the provider transcript on disk decides, read back to the send. Only an unconfirmed item gets here.
|
|
637
|
+
return timeline ?? this.transcriptArrived(agentId, marker, sinceMs);
|
|
635
638
|
}
|
|
639
|
+
/** The transcript half of arrivedMessage (tests replace it): markerInFile over the agent's provider transcript. */
|
|
640
|
+
transcriptArrived: (agentId: string, marker: string, sinceMs: number) => Promise<boolean | null> = (agentId, marker, sinceMs) => transcriptHas(paseoHome, agentId, marker, sinceMs);
|
|
636
641
|
async handoff(w: Workspace, callerId: string): Promise<{ batchId: string; fromAgentId: string } | null> {
|
|
637
642
|
return this.connect(async client => {
|
|
638
643
|
const caller = (await client.fetchAgent(callerId))?.agent;
|
|
@@ -755,15 +760,17 @@ async function timelineHas(client: Daemon, agentId: string, messageId: string, s
|
|
|
755
760
|
}
|
|
756
761
|
return null;
|
|
757
762
|
}
|
|
758
|
-
/**
|
|
759
|
-
|
|
763
|
+
/**
|
|
764
|
+
* The agent's provider transcript on disk holds `marker`, read back from its end to the send (markerInFile, at most
|
|
765
|
+
* MARKER_READ_MAX_BYTES). Never wakes the agent. False only when the part read reaches back to `sinceMs` and holds no marker: the agent isn't loaded, so nothing of Paseo's is still
|
|
766
|
+
* holding the message, and a provider writes a prompt to its transcript when it takes it. Anything else is unknown.
|
|
767
|
+
*/
|
|
768
|
+
async function transcriptHas(home: string, agentId: string, marker: string, sinceMs: number): Promise<boolean | null> {
|
|
760
769
|
if (!marker) return null;
|
|
761
770
|
try {
|
|
762
771
|
const record = await agentRecord(home, agentId);
|
|
763
772
|
const file = record && await transcriptFile(record);
|
|
764
773
|
if (!file) return null;
|
|
765
|
-
|
|
766
|
-
const needle = JSON.stringify(marker).slice(1, -1);
|
|
767
|
-
return tail.some(line => line.includes(needle)) ? true : null;
|
|
774
|
+
return await markerInFile(file, sinceMs, marker);
|
|
768
775
|
} catch { return null; }
|
|
769
776
|
}
|
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\"]],",
|
|
@@ -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"]],
|
|
@@ -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/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).
|