paseo-follow-up 2.5.0 → 2.6.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/OVERVIEW.md +1 -1
- package/README.md +0 -1
- package/client/brief-since.tsx +4 -3
- package/client/catch-up.tsx +56 -15
- package/client/header.tsx +5 -3
- package/client/home-data.ts +3 -1
- package/client/home-list.tsx +19 -11
- package/client/home-view.ts +8 -1
- package/client/home.tsx +29 -10
- package/client/keys.ts +2 -0
- package/client/kit.tsx +5 -2
- package/client/large.tsx +5 -3
- package/client/live.tsx +4 -3
- package/client/merge-button.tsx +3 -2
- package/client/messages.tsx +5 -1
- package/client/more-context.tsx +17 -4
- package/client/morning-brief-settings.tsx +5 -4
- package/client/needs-you.tsx +5 -4
- package/client/new-settings.tsx +8 -7
- package/client/now-lines.tsx +60 -0
- package/client/onboarding.tsx +55 -123
- package/client/paged-list.tsx +115 -0
- package/client/panel.tsx +24 -8
- package/client/pr-stats-settings.tsx +3 -2
- package/client/pr-stats.tsx +10 -10
- package/client/questions.tsx +63 -40
- package/client/release-notes.tsx +10 -9
- package/client/reviewers.tsx +8 -3
- package/client/row-open.ts +28 -0
- package/client/section-search.tsx +5 -3
- package/client/settings.tsx +11 -8
- package/client/setup-dialog.tsx +168 -0
- package/client/setup-gate.tsx +69 -0
- package/client/setup-ui.ts +27 -0
- package/client/shipping.tsx +5 -4
- package/client/stacks.tsx +11 -3
- package/client/tasks.tsx +5 -1
- package/client/your-questions.tsx +375 -0
- package/index.client.tsx +11 -3
- package/index.server.ts +162 -32
- package/package.json +1 -1
- package/server/agent-actions.ts +23 -14
- package/server/agent-hook.mjs +7 -5
- package/server/agent-parity.ts +21 -6
- package/server/ai-jobs.ts +26 -5
- package/server/brief-timeline.ts +47 -0
- package/server/context-requests.ts +90 -21
- package/server/directory.ts +6 -0
- package/server/discovery.ts +2 -0
- package/server/engine.ts +3 -0
- package/server/hook-source.ts +7 -5
- package/server/inbox-classifier.ts +17 -0
- package/server/inbox.ts +9 -3
- package/server/job-agent.ts +13 -2
- package/server/mcp-source.ts +23 -15
- package/server/mcp.mjs +23 -15
- package/server/obligations.ts +4 -1
- package/server/session-prompt.ts +30 -3
- package/server/turn-end.ts +133 -0
- package/server/wait-jobs.ts +18 -2
- package/server/wait.ts +17 -12
- package/shared/activity.ts +2 -1
- package/shared/agent-settings.ts +9 -8
- package/shared/catch-up.ts +65 -20
- package/shared/chat.ts +2 -2
- package/shared/compass.ts +5 -4
- package/shared/contracts.ts +52 -8
- package/shared/history.ts +160 -0
- package/shared/home-keys.ts +1 -0
- package/shared/home.ts +54 -8
- package/shared/job-rows.ts +2 -2
- package/shared/list.ts +4 -1
- package/shared/message-sender.ts +2 -0
- package/shared/model.ts +8 -0
- package/shared/new-name.ts +4 -1
- package/shared/now.ts +228 -0
- package/shared/onboarding.ts +17 -13
- package/shared/paged.ts +96 -0
- package/shared/provider-support.ts +83 -34
- package/shared/recommend.ts +1 -1
- package/shared/settings-nav.ts +3 -1
- package/shared/setup-popup.ts +28 -0
- package/shared/sort.ts +8 -1
- package/shared/status.ts +3 -1
- package/shared/wait.ts +2 -2
- package/shared/your-questions.ts +133 -0
- package/skills/follow-up/SKILL.md +1 -1
package/index.server.ts
CHANGED
|
@@ -17,9 +17,11 @@ import { agentSetSpec, developerSetSpec } from "./server/spec";
|
|
|
17
17
|
import type { PluginServerContext, PluginHandlerContext, PluginHookContext, PluginSessionOpenRequest } from "@getpaseo/plugin/server";
|
|
18
18
|
import type { PluginRpcContract, PluginSubscriptionContract } from "@getpaseo/plugin";
|
|
19
19
|
import { ValueFeed, WorkspacesFeed } from "./server/feeds";
|
|
20
|
-
import { ContextRequests, contextRecipient } from "./server/context-requests";
|
|
21
|
-
import {
|
|
20
|
+
import { ContextRequests, contextRecipient, questionRecipient } from "./server/context-requests";
|
|
21
|
+
import { agentQuestionPrompt, questionHistory, questionsByWorkspace, questionTask } from "./shared/your-questions";
|
|
22
|
+
import { agentContextPrompt, contextFor, deckCards, type ContextVia } from "./shared/catch-up";
|
|
22
23
|
import { buildHome } from "./shared/home";
|
|
24
|
+
import { workspaceNow } from "./shared/now";
|
|
23
25
|
import { needsYou } from "./shared/attention";
|
|
24
26
|
import type { SortMode } from "./shared/sort";
|
|
25
27
|
import type { ZodType, output as zOutput } from "zod";
|
|
@@ -28,6 +30,7 @@ import { DISMISSED_ASK_NOTE, isTimeZone, sameAsk } from "./shared/inbox";
|
|
|
28
30
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
29
31
|
import { join } from "node:path";
|
|
30
32
|
import { randomUUID } from "node:crypto";
|
|
33
|
+
import { activityPage, agentView, boundHistory } from "./shared/history";
|
|
31
34
|
import * as rpc from "./shared/contracts";
|
|
32
35
|
import { LogRing } from "./server/report-issue/diagnostics";
|
|
33
36
|
import { followUpReporter } from "./server/report-issue-adapter";
|
|
@@ -70,8 +73,10 @@ import { Wait, waitStatus, type WaitPaseoConfig } from "./server/wait";
|
|
|
70
73
|
import { removeGlobalRegistrations } from "./server/mcp-registrations";
|
|
71
74
|
import { TrustBypass } from "./server/trust-bypass";
|
|
72
75
|
import { scopes } from "./server/scopes";
|
|
76
|
+
import { TurnEnd } from "./server/turn-end";
|
|
73
77
|
import { updateObligation } from "./server/obligations";
|
|
74
78
|
import { Inbox, INBOX_WRITE_MS, type GuardPause } from "./server/inbox";
|
|
79
|
+
import { BriefTimeline } from "./server/brief-timeline";
|
|
75
80
|
import { daemonDirectory, guardPath } from "./server/inbox-directory";
|
|
76
81
|
import { fileSources } from "./server/inbox-classifier";
|
|
77
82
|
import { onBeforeSend, onDaemonReconnect } from "./server/daemon";
|
|
@@ -89,7 +94,7 @@ import { projectRepo } from "./server/daemon";
|
|
|
89
94
|
import { batchArchive, pruneUnsent } from "./server/batch-archive";
|
|
90
95
|
import { statusCheck } from "./server/status-check";
|
|
91
96
|
import { NO_USAGE, usageKey } from "./shared/usage";
|
|
92
|
-
import { activeWindowMs, DEFAULT_ACTIVE_WINDOW_DAYS } from "./server/agent-load";
|
|
97
|
+
import { isLoaded, activeWindowMs, DEFAULT_ACTIVE_WINDOW_DAYS } from "./server/agent-load";
|
|
93
98
|
import { ACTIVE_SCOPE_MIGRATION, PRUNE_MIGRATION, autoSendsByDefault, FOLLOW_EVERY_MIGRATION, followsByDefault, followsEvery, migrateFollowEvery, optedOut } from "./shared/settings";
|
|
94
99
|
import { Overseer, OVERSEER_TOOLS, type OverseerPaseo, type OverseerTool, providerModel } from "./server/overseer";
|
|
95
100
|
import { OVERSEER_LABEL, isOverseerAgent } from "./shared/overseer";
|
|
@@ -142,7 +147,7 @@ import { busyAgents, type Busy } from "./shared/update-policy";
|
|
|
142
147
|
import { VersionsStore, demoOverride, describeSelf, readPackage, type SelfInstall } from "./server/release-notes";
|
|
143
148
|
import { updatesViewSchema, type UpdatesView } from "./shared/updates";
|
|
144
149
|
import { PLUGIN_NAME, releaseNotesViewSchema, type ReleaseNote, type ReleaseNotesView } from "./shared/changelog";
|
|
145
|
-
import { BRIEF_KIND, BRIEF_VERSION, prState, prStates, validateNeedsYou, type
|
|
150
|
+
import { BRIEF_KIND, BRIEF_VERSION, prState, prStates, validateNeedsYou, type NeedsYouRecord } from "./shared/brief";
|
|
146
151
|
import { foldedAsk } from "./shared/needs-block";
|
|
147
152
|
import { ImageStore } from "./server/image-store";
|
|
148
153
|
import type { ImageRef, ImageUpload } from "./shared/images";
|
|
@@ -308,18 +313,26 @@ export default function contribute(server: PluginServerContext) {
|
|
|
308
313
|
// The brief's timeline rows need a plugin session; the handler contexts carry one. Rows wait until one is seen.
|
|
309
314
|
type PaseoApi = PluginHandlerContext["paseo"];
|
|
310
315
|
let api: PaseoApi | null = null;
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
+
const briefTimeline = new BriefTimeline({
|
|
317
|
+
loaded: id => isLoaded(gateway.directory.cached(id))
|
|
318
|
+
? withDaemon(async client => (await client.fetchAgent(id))?.agent ?? null)
|
|
319
|
+
: Promise.resolve(null),
|
|
320
|
+
current: id => inbox.brief(id),
|
|
321
|
+
append: async (agentId, brief) => {
|
|
322
|
+
if (!api) throw new Error("The plugin session isn't ready");
|
|
323
|
+
await api.agents.ref(agentId).timeline.append({ type: "plugin", id: brief.id, kind: BRIEF_KIND, version: BRIEF_VERSION, data: brief });
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
// Discovery already reads agent metadata. Its updates are the retry signal, including idle agents reloaded
|
|
327
|
+
// without a turn. No per-agent observer, poll or timeline read is added.
|
|
328
|
+
gateway.directory.onAgentsChanged = () => { void briefTimeline.changed(); };
|
|
316
329
|
let catalogKicked = false;
|
|
317
330
|
const seen = (paseo: PaseoApi) => {
|
|
318
331
|
api = paseo;
|
|
319
332
|
// The first Paseo handle: read the provider catalog once in the background, so a helper left on its default runs
|
|
320
333
|
// on a provider Paseo has from its first job (runnableRole), without any RPC waiting on it.
|
|
321
334
|
if (!catalogKicked) { catalogKicked = true; queueMicrotask(() => void providerCatalog.read().catch(() => undefined)); }
|
|
322
|
-
|
|
335
|
+
void briefTimeline.changed();
|
|
323
336
|
};
|
|
324
337
|
const needsYouPath = (agentId: string) => join(directory, "hook-state", `needs-you-${agentId}.json`);
|
|
325
338
|
const trackedMain = async (agentId: string) => (await store.snapshot()).workspaces.find(w => w.enable_tracking && !w.archived && w.mainAgentId === agentId) ?? null;
|
|
@@ -339,7 +352,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
339
352
|
enabled: inboxSettings,
|
|
340
353
|
overseer: async () => (await overseer?.state())?.agentId ?? null,
|
|
341
354
|
briefs: {
|
|
342
|
-
sink:
|
|
355
|
+
sink: (agentId, brief) => briefTimeline.sink(agentId, brief),
|
|
343
356
|
async call(agentId) {
|
|
344
357
|
if (!/^[\w-]+$/.test(agentId)) return null;
|
|
345
358
|
try { return JSON.parse(await readFile(needsYouPath(agentId), "utf8")) as NeedsYouRecord; } catch { return null; }
|
|
@@ -428,6 +441,31 @@ export default function contribute(server: PluginServerContext) {
|
|
|
428
441
|
queue.enqueue({ id: `message:${agentId}:${messageId}`, kind: "message", key, ref: { agentId }, messageId, text, ...(by ? { by } : {}), ...(images.length ? { images } : {}), priority: "now", state: "queued" });
|
|
429
442
|
};
|
|
430
443
|
onDaemonReconnect(() => queue.reconnected());
|
|
444
|
+
// Turn-end checks for a provider without Follow-up's hook (server/turn-end.ts): the hook's checks, as one queued message.
|
|
445
|
+
const turnEnd = new TurnEnd({
|
|
446
|
+
input: async (agentId, _provider, _items, _startedAt) => {
|
|
447
|
+
const w = agentTrackedWorkspace(await store.snapshot(), agentId);
|
|
448
|
+
if (!w) return null;
|
|
449
|
+
// Only this workspace's scopes (a-nudge-costs-its-workspace), never the whole state's.
|
|
450
|
+
const entry = scopes({ workspaces: [w] } as unknown as Parameters<typeof scopes>[0])[agentId] ?? null;
|
|
451
|
+
const json = (name: string) => readFile(join(directory, "hook-state", name), "utf8").then(t => JSON.parse(t) as Record<string, unknown>, () => null);
|
|
452
|
+
const synced = await json(`sync-${agentId}.json`);
|
|
453
|
+
const called = await json(`needs-you-${agentId}.json`) as NeedsYouRecord | null;
|
|
454
|
+
const receipt = /^[\w-]+$/.test(w.id) ? await json(`task-nudges-${w.id}.json`) : null;
|
|
455
|
+
const settings = await inboxSettings();
|
|
456
|
+
return {
|
|
457
|
+
entry, receipt: (receipt ?? {}) as never,
|
|
458
|
+
syncedAt: synced && synced.workspaceId === w.id && typeof synced.at === "number" ? synced.at : null,
|
|
459
|
+
needsYouAt: typeof called?.at === "number" ? called.at : null,
|
|
460
|
+
nudge: settings.enable_inbox === true && settings.enable_brief_nudge === true && !inbox.pendingPermissions().includes(agentId),
|
|
461
|
+
};
|
|
462
|
+
},
|
|
463
|
+
saveReceipt: async (workspaceId, receipt) => { if (/^[\w-]+$/.test(workspaceId)) await writeFile(join(directory, "hook-state", `task-nudges-${workspaceId}.json`), JSON.stringify(receipt), { mode: 0o600 }); },
|
|
464
|
+
send: async (agentId, workspaceId, text, turnId) => {
|
|
465
|
+
const messageId = randomUUID();
|
|
466
|
+
queue.enqueue({ id: `turn-end:${agentId}:${turnId ?? messageId}`, kind: "message", key: workspaceId, ref: { agentId }, messageId, text, priority: "now", state: "queued" });
|
|
467
|
+
},
|
|
468
|
+
});
|
|
431
469
|
/**
|
|
432
470
|
* Stores a field's pasted images, runs the action with their refs, and removes any the action didn't queue (a
|
|
433
471
|
* repeated answer, an ask already open, a refusal): only a queue item keeps an image file.
|
|
@@ -757,16 +795,44 @@ export default function contribute(server: PluginServerContext) {
|
|
|
757
795
|
return { tracked: true, ...view, workspaces: view.workspaces.map(w => ({ ...w, title: w.title.slice(0, 200), agentStatus: w.agentStatus.slice(0, 40), state: w.state.slice(0, 200) })) };
|
|
758
796
|
});
|
|
759
797
|
handle(rpc.listRpc, async ({ since }) => { if (waiting) return { workspaces: [], full: false, removed: [], error: waiting }; await ready; return { ...listCache.answer(await store.snapshot(), since), error: loadError ?? hookError ?? writeHealth.message() ?? engine.error }; });
|
|
760
|
-
|
|
761
|
-
handle(rpc.
|
|
798
|
+
// Settled history is bounded (shared/history.ts boundHistory); the Activity card pages the rest with follow.activity.
|
|
799
|
+
handle(rpc.getRpc, async ({ workspaceId }) => { if (waiting) return { workspace: null, error: waiting }; await ready; const w = (await store.snapshot()).workspaces.find(w => w.id === workspaceId && w.enable_tracking); return { workspace: w ? boundHistory(w) : null, error: loadError ?? hookError ?? writeHealth.message() ?? engine.error }; });
|
|
800
|
+
handle(rpc.activityRpc, async ({ workspaceId, tab, query, offset, limit }) => {
|
|
801
|
+
const empty = { timeline: [], questions: [], offset: 0, total: 0, counts: { timeline: 0, questions: 0 }, all: 0 };
|
|
802
|
+
if (waiting) return { ...empty, error: waiting };
|
|
803
|
+
await ready;
|
|
804
|
+
const w = (await store.snapshot()).workspaces.find(w => w.id === workspaceId && w.enable_tracking);
|
|
805
|
+
if (!w) return { ...empty, error: "This workspace isn't followed." };
|
|
806
|
+
return { ...activityPage(w, { tab, query, offset, limit }), error: null };
|
|
807
|
+
});
|
|
808
|
+
handle(rpc.syncWorkspaceRpc, async ({ agentId, summary, milestone }, { paseo }) => {
|
|
762
809
|
await requireReady();
|
|
763
810
|
const workspaceId = await callerWorkspaceId(agentId, paseo, false);
|
|
764
811
|
const w = agentWorkspace(await store.snapshot(), agentId, "write", workspaceId, "pr");
|
|
765
812
|
if (w.archived) throw new Error(`Only an active workspace root agent can confirm sidebar sync: expected ${w.mainAgentId}, received ${agentId}.`);
|
|
813
|
+
// What the agent is working on (shared/now.ts): stored per agent on the record, so every surface reads it with
|
|
814
|
+
// the rest of the workspace. Omitted keeps the last one; null clears it; the same one again writes nothing.
|
|
815
|
+
if (milestone !== undefined) await store.mutateWorkspace(w.id, current => {
|
|
816
|
+
const before = current.milestones?.[agentId];
|
|
817
|
+
if (milestone === null) { if (before) delete current.milestones![agentId]; return; }
|
|
818
|
+
const next = { now: milestone.now, done: milestone.done ?? [], next: milestone.next ?? [] };
|
|
819
|
+
if (before && JSON.stringify([before.now, before.done, before.next]) === JSON.stringify([next.now, next.done, next.next])) return;
|
|
820
|
+
current.milestones = { ...current.milestones, [agentId]: { ...next, at: new Date().toISOString() } };
|
|
821
|
+
});
|
|
766
822
|
await agentHooks.confirm(w.id, agentId, summary);
|
|
767
823
|
return { workspaceId: w.id, synced: true as const };
|
|
768
824
|
});
|
|
769
|
-
handle(rpc.
|
|
825
|
+
handle(rpc.workspaceNowRpc, async ({ agentId }, { paseo }) => {
|
|
826
|
+
await requireReady();
|
|
827
|
+
const workspaceId = await callerWorkspaceId(agentId, paseo);
|
|
828
|
+
const w = agentWorkspace(await store.snapshot(), agentId, "read", workspaceId, "pr");
|
|
829
|
+
// The inbox rows the worker already holds (no daemon read, nothing woken): the same rows every client draws from.
|
|
830
|
+
// Before Paseo's agent list first loads there are none: each state then reads unknown, never a made-up idle.
|
|
831
|
+
const rows = await inbox.list().then(list => list.rows, () => []);
|
|
832
|
+
return { workspaceId: w.id, agents: workspaceNow(w, rows, Date.now()) };
|
|
833
|
+
});
|
|
834
|
+
// Finished items are a count plus the newest few, paged by history/offset/limit (shared/history.ts agentView), summary and full alike.
|
|
835
|
+
handle(rpc.agentStatusRpc, async ({ agentId, history, offset, limit }, { paseo }) => { await requireReady(); const workspaceId = await callerWorkspaceId(agentId, paseo); const w = agentWorkspace(await store.snapshot(), agentId, "read", workspaceId, "pr"); return agentView(w, { kind: history, offset, limit }, { dismissed: dismissedNeeds(w, Date.now()), dismissedAsk: await inbox.dismissedAsk(agentId), prWorkflow: prWorkflow.agentWorkflow(workspaceRepo(w), touchedRepos(w)), nextMessageInfo: nextMessageInfo(w, Date.now()), sending: sendingOf(w, Date.now(), { held: !governor.allowsBackground() }) }); });
|
|
770
836
|
handle(rpc.activateRpc, async ({ workspaceId }) => { await requireReady(); return engine.activate(workspaceId); });
|
|
771
837
|
handle(rpc.sendRpc, async ({ workspaceId, batchId }) => { await requireReady(); return engine.sendPending(workspaceId, batchId); });
|
|
772
838
|
handle(rpc.recoverRpc, async ({ workspaceId }) => { await requireReady(); return engine.startRecovery(workspaceId); });
|
|
@@ -1158,24 +1224,78 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1158
1224
|
if (running) return imageSupport(running);
|
|
1159
1225
|
return imageSupport({ provider: (await overseer!.agentInfo()).configured.provider });
|
|
1160
1226
|
});
|
|
1161
|
-
// Catch up's More context: the
|
|
1162
|
-
// 36) to
|
|
1163
|
-
//
|
|
1227
|
+
// Your questions and Catch up's More context: the question is recorded and answered at once, and goes through the
|
|
1228
|
+
// message queue (invariant 36) to an agent that has context_reply (an-ask-goes-only-to-an-agent-that-can-answer-it):
|
|
1229
|
+
// about a card, the card's workspace's main agent; a free question, the agent named (/ask's chat) or the main agent.
|
|
1230
|
+
// Asking may wake it: the developer asked, the one exception to never-wake (invariant 1).
|
|
1231
|
+
const askAgent = async (input: { workspaceId?: string | null; agentId?: string | null; cardKey?: string | null; card?: string; target?: "agent" | "overseer"; ask: string; via?: ContextVia; parentId?: string | null }, by: string, caller: string | null, images: ImageUpload[] | undefined) => {
|
|
1232
|
+
// The worker's own snapshot, never a daemon read (an-ack-never-waits).
|
|
1233
|
+
const state = await store.snapshot();
|
|
1234
|
+
let to: { agentId: string; workspaceId: string | null };
|
|
1235
|
+
if (input.cardKey) {
|
|
1236
|
+
const w = input.workspaceId ? state.workspaces.find(x => x.id === input.workspaceId) : undefined;
|
|
1237
|
+
const r = contextRecipient(w, caller);
|
|
1238
|
+
if ("error" in r) throw new Error(r.error);
|
|
1239
|
+
to = { agentId: r.agentId, workspaceId: input.workspaceId ?? null };
|
|
1240
|
+
} else {
|
|
1241
|
+
const r = questionRecipient(state.workspaces, input, caller);
|
|
1242
|
+
if ("error" in r) throw new Error(r.error);
|
|
1243
|
+
to = r;
|
|
1244
|
+
}
|
|
1245
|
+
const parent = input.parentId ? await contextRequests.get(input.parentId) : null;
|
|
1246
|
+
return withImages(images, async refs => {
|
|
1247
|
+
const out = await contextRequests.ask({ workspaceId: to.workspaceId, agentId: input.agentId ?? to.agentId, cardKey: input.cardKey ?? null, card: input.card ?? "", target: "agent", ask: input.ask,
|
|
1248
|
+
via: caller ? "tool" : input.via ?? (input.cardKey ? "more" : "field"), parentId: input.parentId ?? null }, by, to.agentId);
|
|
1249
|
+
if (out.fresh) enqueueMessage(to.agentId, out.request.cardKey ? agentContextPrompt(out.request) : agentQuestionPrompt(out.request, parent), out.request.id, by, refs);
|
|
1250
|
+
return out;
|
|
1251
|
+
});
|
|
1252
|
+
};
|
|
1164
1253
|
handle(rpc.contextAskRpc, async (input, context) => {
|
|
1165
1254
|
await requireReady();
|
|
1166
1255
|
const actor = actorOf(context);
|
|
1167
|
-
// The worker's own snapshot, never a daemon read (an-ack-never-waits).
|
|
1168
|
-
const w = input.workspaceId ? (await store.snapshot()).workspaces.find(x => x.id === input.workspaceId) : undefined;
|
|
1169
|
-
const to = contextRecipient(w, actor.kind === "agent" ? actor.agentId : null);
|
|
1170
|
-
if ("error" in to) throw new Error(to.error);
|
|
1171
1256
|
const { images, ...ask } = input;
|
|
1172
|
-
const out = await
|
|
1173
|
-
const out = await contextRequests.ask({ ...ask, target: "agent" }, actorBy(actor), to.agentId);
|
|
1174
|
-
if (out.fresh) enqueueMessage(to.agentId, agentContextPrompt(out.request), out.request.id, actorBy(actor), refs);
|
|
1175
|
-
return out;
|
|
1176
|
-
});
|
|
1257
|
+
const out = await askAgent(ask, actorBy(actor), actor.kind === "agent" ? actor.agentId : null, images);
|
|
1177
1258
|
return input.target === "overseer" ? { ...out, note: "More context always asks the card's own main agent, which can answer on the card; the Overseer can't, so target is ignored." } : out;
|
|
1178
1259
|
});
|
|
1260
|
+
// What happens to a question after it is asked (Your questions): every act is the developer's click or an agent's
|
|
1261
|
+
// confirmed question_action, by the same path; an agent's never reads the answer for the developer.
|
|
1262
|
+
handle(rpc.questionActionRpc, async ({ id, action, text, images }, context) => {
|
|
1263
|
+
await requireReady();
|
|
1264
|
+
const actor = actorOf(context);
|
|
1265
|
+
const by = actorBy(actor);
|
|
1266
|
+
const r = await contextRequests.get(id);
|
|
1267
|
+
if (!r) throw new Error(`No question ${id}. It may have expired (questions are kept 30 days).`);
|
|
1268
|
+
// Agents act on others, not themselves (invariant 4): the asked agent answers with context_reply, nothing more.
|
|
1269
|
+
if (actor.kind === "agent" && actor.agentId === r.askedOf) throw new Error("This question was asked of you: answer it with context_reply; what happens to it next is the developer's call.");
|
|
1270
|
+
if (action === "done") return { request: await contextRequests.done(id, by) };
|
|
1271
|
+
if (action === "withdraw") {
|
|
1272
|
+
const request = await contextRequests.withdraw(id, by);
|
|
1273
|
+
// A message still queued is dropped; one already out stays (its answer, if any, is in the chat).
|
|
1274
|
+
if (r.askedOf) await queue.cancel(`message:${r.askedOf}:${id}`, "The question was withdrawn.").catch(() => undefined);
|
|
1275
|
+
return { request };
|
|
1276
|
+
}
|
|
1277
|
+
if (action === "reply") {
|
|
1278
|
+
if (!text) throw new Error("Reply needs text: the follow-up question.");
|
|
1279
|
+
if (r.state === "asking") throw new Error("This question is still asking; wait for its answer, or withdraw it.");
|
|
1280
|
+
const out = await askAgent({ workspaceId: r.workspaceId, agentId: r.askedOf, ask: text, via: r.via === "slash" ? "slash" : "field", parentId: r.id }, by, actor.kind === "agent" ? actor.agentId : null, images);
|
|
1281
|
+
const request = by === "developer" ? (await contextRequests.read(id)) ?? r : r;
|
|
1282
|
+
return { request, reply: out.request };
|
|
1283
|
+
}
|
|
1284
|
+
// Make a task: update_obligation's server path, owned by the agent that answered, the Q&A as its note.
|
|
1285
|
+
if (r.task) return { request: r, taskId: r.task.id };
|
|
1286
|
+
if (r.state === "asking" || r.state === "withdrawn") throw new Error("Make a task needs an answer first.");
|
|
1287
|
+
if (!r.workspaceId || !r.askedOf) throw new Error("This question has no workspace to hold a task.");
|
|
1288
|
+
const { title, note } = questionTask(r);
|
|
1289
|
+
const result = await store.mutate(state => {
|
|
1290
|
+
const w = state.workspaces.find(x => x.id === r.workspaceId && x.enable_tracking);
|
|
1291
|
+
if (!w) throw new Error("Follow-up no longer tracks this question's workspace, so it can't hold a task.");
|
|
1292
|
+
const obligation = updateObligation(w, { title, status: "pending", note, caller: r.askedOf!, new: true });
|
|
1293
|
+
syncTaskQuestions(w, Date.now());
|
|
1294
|
+
changed(w); return { workspaceId: w.id, taskId: obligation.id };
|
|
1295
|
+
});
|
|
1296
|
+
void engine.nudge(result.workspaceId);
|
|
1297
|
+
return { request: await contextRequests.tasked(id, result.taskId, by), taskId: result.taskId };
|
|
1298
|
+
});
|
|
1179
1299
|
// Built when read (a-derived-view-is-built-when-read), from state the worker holds: no daemon request but the
|
|
1180
1300
|
// directory's cached workspace list.
|
|
1181
1301
|
handle(rpc.catchUpDeckRpc, async () => {
|
|
@@ -1183,15 +1303,19 @@ export default function contribute(server: PluginServerContext) {
|
|
|
1183
1303
|
const [state, list, paseoList, priorities, settings, context] = await Promise.all([store.snapshot(), inbox.list(), paseoWorkspaces(), priorityStore.read(), inboxSettings(), contextRequests.list()]);
|
|
1184
1304
|
const tracked = state.workspaces.filter(w => w.enable_tracking);
|
|
1185
1305
|
const byId = new Map(tracked.map(w => [w.id, w]));
|
|
1186
|
-
const model = buildHome({ rows: list.rows, tracked, paseo: paseoList, now: Date.now(), sort: (settings as { home_sort?: SortMode }).home_sort, priorities });
|
|
1187
|
-
const
|
|
1306
|
+
const model = buildHome({ rows: list.rows, tracked, paseo: paseoList, now: Date.now(), sort: (settings as { home_sort?: SortMode }).home_sort, priorities, questions: context });
|
|
1307
|
+
const unread = questionsByWorkspace(context);
|
|
1308
|
+
const cards = deckCards({ model, rows: list.rows, items: id => { const w = byId.get(id); return w ? needsYou(w) : []; }, answers: id => unread.get(id)?.unread ?? [] });
|
|
1188
1309
|
return { cards: cards.map(c => {
|
|
1189
1310
|
const r = contextFor(context, { workspaceId: c.s.workspaceId, cardKey: c.key });
|
|
1190
1311
|
return { key: c.key, kind: c.kind, workspaceId: c.s.workspaceId, agentId: c.s.agentId, title: c.s.title, line: c.s.line, questionId: c.questionId ?? null,
|
|
1191
1312
|
item: c.item && "title" in c.item ? String((c.item as { title?: unknown }).title ?? "") || null : null, context: r ? { id: r.id, state: r.state, target: r.target } : null };
|
|
1192
1313
|
}) };
|
|
1193
1314
|
});
|
|
1194
|
-
handle(rpc.contextListRpc, async ({ workspaceId }) =>
|
|
1315
|
+
handle(rpc.contextListRpc, async ({ workspaceId, state, query }) => {
|
|
1316
|
+
const all = await contextRequests.list(workspaceId ? { workspaceId } : {});
|
|
1317
|
+
return { requests: state || query ? questionHistory(all, { filter: state, query }).reverse() : all };
|
|
1318
|
+
});
|
|
1195
1319
|
// Paseo 0.17's own PR watch (subscribe_change_request): named only for PRs Follow-up can't see. No feature flag says
|
|
1196
1320
|
// it's there; server_info's version does, read from the connection's last hello (no request).
|
|
1197
1321
|
const hostVersion = async () => { try { return String(((await withDaemon(async client => (client as ServerInfoClient).getLastServerInfoMessage?.())) as { version?: unknown } | null)?.version ?? ""); } catch { return ""; } };
|
|
@@ -2113,8 +2237,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
2113
2237
|
// The shared directory learns from events instead of polling Paseo (see DaemonDirectory). Registered first so the
|
|
2114
2238
|
// handlers below read the patched rows.
|
|
2115
2239
|
server.on("agent.turn_started", async event => gateway.directory.turnStarted(event.agent, event.turnId)),
|
|
2240
|
+
server.on("agent.turn_started", async event => turnEnd.turnStarted(event.agent.id)),
|
|
2116
2241
|
server.on("agent.turn_ended", async event => gateway.directory.turnEnded(event.agent, event.outcome)),
|
|
2117
|
-
server.on("agent.turn_ended", async event => contextRequests.turnEnded(event.agent.id)),
|
|
2118
2242
|
server.on("agent.permission_requested", async event => gateway.directory.permissionRequested(event.agent.id, event.request as { id?: string })),
|
|
2119
2243
|
server.on("agent.permission_resolved", async event => gateway.directory.permissionResolved(event.agent.id, event.requestId)),
|
|
2120
2244
|
server.on("agent.archived", async event => gateway.directory.agentArchived(event.agent.id, event.archivedAt)),
|
|
@@ -2201,9 +2325,9 @@ export default function contribute(server: PluginServerContext) {
|
|
|
2201
2325
|
if (assigned) {
|
|
2202
2326
|
const guarded = interruption && await sessionGuardOwnsInterruption(event.agent.id, interruption).catch(() => false);
|
|
2203
2327
|
if (["canceled", "failed"].includes(event.outcome.kind) && !guarded) await store.mutateWorkspace(assigned.id, w => { const b = w.batches.find(b => b.recipientAgentId === event.agent.id && ["sending", "sent", "uncertain"].includes(b.state)); if (b) { b.state = "blocked"; b.result = b.acknowledgmentError ? `Recovery acknowledgment was refused: ${b.acknowledgmentError.error}` : "Recovery stopped or failed. Check its agent before retrying."; } });
|
|
2204
|
-
void engine.nudge(assigned.id); return;
|
|
2328
|
+
void engine.nudge(assigned.id); await contextRequests.turnEnded(event.agent.id, null); return;
|
|
2205
2329
|
}
|
|
2206
|
-
if (!agentTrackedWorkspace(await store.snapshot(), event.agent.id)) return;
|
|
2330
|
+
if (!agentTrackedWorkspace(await store.snapshot(), event.agent.id)) { await contextRequests.turnEnded(event.agent.id, null); return; }
|
|
2207
2331
|
// Since Paseo 0.13 the lifecycle payload deliberately contains no history.
|
|
2208
2332
|
// Read the ended turn through the plugin-owned API, outside the state lock: one read from the agent's cursor,
|
|
2209
2333
|
// shared with the inbox's handler and with discovery, which the read is kept for (a-turn-s-timeline-is-read-once).
|
|
@@ -2219,6 +2343,11 @@ export default function contribute(server: PluginServerContext) {
|
|
|
2219
2343
|
const compaction = event.outcome.kind === "canceled" && await compactionJustDelivered(event.agent.id, Date.parse(interruption!.at)).catch(() => false);
|
|
2220
2344
|
const nudged = await turnEnded(store, event.agent.id, event.outcome, event.turnId ?? null, items, { interruption, guarded, newerTurn, compaction });
|
|
2221
2345
|
if (nudged) void engine.nudge(nudged);
|
|
2346
|
+
// A provider without the hook: the Stop hook's checks, from this same read (an-agent-on-any-provider-gets-follow-up).
|
|
2347
|
+
await turnEnd.turnEnded(event.agent, event.outcome, event.turnId ?? null, items).catch(() => undefined);
|
|
2348
|
+
// Your questions' turn-end capture, from this same read (any provider): an ask this turn answered without
|
|
2349
|
+
// context_reply takes the agent's last message after it as its answer (null items: "answered in its chat").
|
|
2350
|
+
await contextRequests.turnEnded(event.agent.id, items).catch(() => undefined);
|
|
2222
2351
|
}),
|
|
2223
2352
|
server.on("workspace.archived", async event => { await ready; if (!loadError && !stopped) await store.mutate(state => { const w = state.workspaces.find(w => w.id === event.workspace.id); if (w) w.archived = true; }); }),
|
|
2224
2353
|
];
|
|
@@ -2232,6 +2361,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
2232
2361
|
const stop = () => stopping ??= (async () => {
|
|
2233
2362
|
process.off("disconnect", hostGone);
|
|
2234
2363
|
restoreConsole();
|
|
2364
|
+
gateway.directory.onAgentsChanged = () => {};
|
|
2235
2365
|
stopped = true; wait.close(); updater.stop(); pluginMove.stop(); governor.stop(); if (timer) clearTimeout(timer); if (aboutTimer) clearTimeout(aboutTimer); if (linkedTimer) clearTimeout(linkedTimer); if (titleTimer) clearTimeout(titleTimer); aiJobs.stop(); dispatcher.stop(); ranker = null; if (inboxTimer) clearTimeout(inboxTimer); inbox.stop(); queue.stop(); rpcTiming.stop(); if (hookTimer) clearInterval(hookTimer); if (dueTimer) clearInterval(dueTimer); memoryWatch?.stop(); displayOff?.(); usageWatch?.close(); removers.forEach(remove => remove());
|
|
2236
2366
|
// One deadline for every wait (worker-stop-never-waits-on-a-stuck-pass, server/teardown.ts): start-up and the work
|
|
2237
2367
|
// in flight may be stuck on a daemon or CLI that never answers. Work that ends inside the deadline is saved; what
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.6.0-beta.2",
|
|
5
5
|
"description": "Every agent, one inbox. Follow-up brings what all your coding agents need from you into one ranked list, and follows their work through merge, deploy and after.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
package/server/agent-actions.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { mergeBlockers } from "../shared/pr-actions";
|
|
|
9
9
|
import { recoveryBatch } from "../shared/follow-up";
|
|
10
10
|
import { prLink, type PrLink } from "../shared/presentation";
|
|
11
11
|
import { flagHeadline } from "../shared/headline";
|
|
12
|
-
import { resolveUntil, type InboxRow } from "../shared/inbox";
|
|
12
|
+
import { resolveUntil, sectionOf, type InboxRow } from "../shared/inbox";
|
|
13
13
|
import { needKey, needsYou } from "../shared/attention";
|
|
14
14
|
import type { Pr, State, Workspace } from "../shared/model";
|
|
15
15
|
import { configuredReviewers, reviewerLoginSchema, noReviewers, resolveReviewers, reviewerConfig, reviewerLabel, withoutAuthor, type ReviewerEntry } from "../shared/reviewers";
|
|
@@ -29,6 +29,7 @@ import { DISPLAY_KEYS, displayPreferences, HOME_DETAIL_DEFAULT, CATCH_UP_RAIL_DE
|
|
|
29
29
|
import { DEFAULT_SEARCH_SHORTCUT, NEW_SHORTCUTS, SEARCH_SHORTCUTS } from "../shared/search-key";
|
|
30
30
|
import { DEFAULT_SORT, SORT_MODES } from "../shared/sort";
|
|
31
31
|
import { SCALE } from "../shared/scale";
|
|
32
|
+
import { boundDone, newestFirst, pageInput } from "../shared/paged";
|
|
32
33
|
import { dispatchInputSchema } from "../shared/dispatch";
|
|
33
34
|
import type { DispatchInput, DispatchPlan } from "./dispatch";
|
|
34
35
|
|
|
@@ -56,7 +57,7 @@ export function rowPrs(state: State, r: InboxRow, now: number): PrLink[] {
|
|
|
56
57
|
return [...out.values()];
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
export const AGENT_TOOLS = ["make_main_agent", "list_prs", "add_reviewers", "merge", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "track", "inbox_list", "sign_off", "snooze", "snooze_workspace", "set_finish_flags", "set_priorities", "workspace_about", "agent_settings", "brief_settings", "set_brief_settings", "brief_plan", "set_brief_plan", "brief_chat_search", "brief_sources", "set_brief_sources", "compass", "compass_find", "set_compass", "read_compass", "compass_note", "why_suggested", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "pr_stats", "pr_stats_settings", "set_pr_stats", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "priorities", "rank_status", "rerank_priorities", "usage", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "dismiss_question", "dismiss_item", "run_recovery", "refresh", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "link_items", "set_linked_items", "updates_status", "check_updates", "set_updates", "install_update", "display_settings", "set_display", "retry_move", "report_issue", "report_send", "ai_rename", "catch_up_deck", "context_requests", "ask_context", "dispatch", "linear_queue", "sweep_queue", "dispatch_sources", "dispatch_records", "dispatch_undo", "dispatch_actions", "set_dispatch_actions", "dispatch_settings", "set_dispatch_settings"] as const;
|
|
60
|
+
export const AGENT_TOOLS = ["make_main_agent", "list_prs", "add_reviewers", "merge", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "track", "inbox_list", "sign_off", "snooze", "snooze_workspace", "set_finish_flags", "set_priorities", "workspace_about", "agent_settings", "brief_settings", "set_brief_settings", "brief_plan", "set_brief_plan", "brief_chat_search", "brief_sources", "set_brief_sources", "compass", "compass_find", "set_compass", "read_compass", "compass_note", "why_suggested", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "pr_stats", "pr_stats_settings", "set_pr_stats", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "priorities", "rank_status", "rerank_priorities", "usage", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "dismiss_question", "dismiss_item", "run_recovery", "refresh", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "link_items", "set_linked_items", "updates_status", "check_updates", "set_updates", "install_update", "display_settings", "set_display", "retry_move", "report_issue", "report_send", "ai_rename", "catch_up_deck", "context_requests", "ask_context", "question_action", "dispatch", "linear_queue", "sweep_queue", "dispatch_sources", "dispatch_records", "dispatch_undo", "dispatch_actions", "set_dispatch_actions", "dispatch_settings", "set_dispatch_settings"] as const;
|
|
60
61
|
export type AgentTool = typeof AGENT_TOOLS[number];
|
|
61
62
|
/** Tools that only read. */
|
|
62
63
|
export const READ_ONLY_TOOLS: readonly AgentTool[] = ["list_prs", "inbox_list", "workspace_about", "agent_settings", "display_settings", ...RPC_TOOLS.filter(t => t.kind === "read").map(t => t.name as AgentTool)];
|
|
@@ -177,7 +178,7 @@ const id = z.string().trim().min(1).max(200);
|
|
|
177
178
|
const confirm = { planId: id.optional(), confirm: z.boolean().optional() };
|
|
178
179
|
const agentIds = z.array(id).min(1).max(SCALE.agents);
|
|
179
180
|
export const TOOL_INPUT = {
|
|
180
|
-
list_prs: z.strictObject({ workspace: id.optional(), needs_reviewers: z.boolean().optional(), ready_to_merge: z.boolean().optional(), include_closed: z.boolean().optional() }),
|
|
181
|
+
list_prs: z.strictObject({ workspace: id.optional(), needs_reviewers: z.boolean().optional(), ready_to_merge: z.boolean().optional(), include_closed: z.boolean().optional(), ...pageInput }),
|
|
181
182
|
add_reviewers: z.strictObject({ prs: z.array(prKey).min(1).max(SCALE.perWorkspace).optional(), reviewers: z.array(login).min(1).max(15).optional(), ...confirm }),
|
|
182
183
|
merge: z.strictObject({ pr: prKey.optional(), scope: z.enum(["target", "downstack"]).optional(), ...confirm }),
|
|
183
184
|
enable_merge_when_ready: z.strictObject({ pr: prKey.optional(), scope: z.enum(["target", "downstack"]).optional(), ...confirm }),
|
|
@@ -187,7 +188,7 @@ export const TOOL_INPUT = {
|
|
|
187
188
|
clear_hold: z.strictObject({ workspace: id }),
|
|
188
189
|
retry_batch: z.strictObject({ workspace: id, batchId: id.optional(), task: z.string().max(400).optional() }).refine(a => !!a.batchId !== !!a.task, "retry_batch: give batchId or task, not both"),
|
|
189
190
|
track: z.strictObject({ workspace: id }),
|
|
190
|
-
inbox_list: z.strictObject({ flagged_only: z.boolean().optional() }),
|
|
191
|
+
inbox_list: z.strictObject({ flagged_only: z.boolean().optional(), ...pageInput }),
|
|
191
192
|
workspace_about: z.strictObject({ workspaceId: id, refresh: z.boolean().optional() }),
|
|
192
193
|
agent_settings: z.strictObject({}),
|
|
193
194
|
sign_off: z.strictObject({ agentIds: agentIds.optional(), ...confirm }),
|
|
@@ -310,11 +311,13 @@ export class AgentActions {
|
|
|
310
311
|
const input = t.toRpc ? t.toRpc(given) : given;
|
|
311
312
|
// Every RPC an agent tool runs carries the acting agent, so its handler never records the developer.
|
|
312
313
|
const actor = agentActor(caller, await this.d.agentTitle?.(caller).catch(() => null));
|
|
313
|
-
if (t.kind === "read")
|
|
314
|
+
if (t.kind === "read") { const out = await this.d.rpc.call(t.rpc, input, actor); return t.view ? t.view(out, given) : out; }
|
|
314
315
|
if (t.kind === "write") { const out = await this.d.rpc.call(t.rpc, input, actor); await this.note(caller, caller, t.name); return out; }
|
|
315
316
|
// Planned: the RPC's own contract checks the arguments now, so a bad call fails at the dry run.
|
|
316
317
|
const checked = await this.d.rpc.validate(t.rpc, input).catch((error: unknown) => { throw new Error(`${t.name}: ${error instanceof Error ? error.message : String(error)}`); });
|
|
317
|
-
|
|
318
|
+
// `before` is what the read tool for the same RPC shows, bounded the same way (its view, first page).
|
|
319
|
+
const reader = t.before ? RPC_TOOLS.find(r => r.kind === "read" && r.rpc === t.before!.rpc && r.view) : undefined;
|
|
320
|
+
const before = t.before ? await this.d.rpc.call(t.before.rpc, t.before.input ? t.before.input(given) : {}).then(out => reader?.view ? reader.view(out, {}) : out).catch(() => null) : undefined;
|
|
318
321
|
const planId = this.plan(caller, t.name as AgentTool, async () => { const out = await this.d.rpc!.call(t.rpc, checked, actor); await this.note(caller, caller, t.name); return out; });
|
|
319
322
|
// The plan names the images by name and size, never their bytes.
|
|
320
323
|
const shown = images ? { ...(checked as Record<string, unknown>), images: images.map(i => ({ name: i.name, mimeType: i.mimeType, bytes: base64Bytes(i.data) })) } : checked;
|
|
@@ -389,18 +392,21 @@ export class AgentActions {
|
|
|
389
392
|
failedSources: r?.failed ?? [], error: view.error };
|
|
390
393
|
}
|
|
391
394
|
|
|
392
|
-
private async listPrs(args: { workspace?: string; needs_reviewers?: boolean; ready_to_merge?: boolean; include_closed?: boolean }) {
|
|
395
|
+
private async listPrs(args: { workspace?: string; needs_reviewers?: boolean; ready_to_merge?: boolean; include_closed?: boolean; offset?: number; limit?: number }) {
|
|
393
396
|
const state = await this.d.store.snapshot();
|
|
394
397
|
const tracked = this.tracked(state);
|
|
395
398
|
// Stable ids remain exact identities. Text queries share Home's layout-aware matcher.
|
|
396
399
|
const exact = tracked.find(w => w.id === args.workspace);
|
|
397
400
|
const workspaces = exact ? [exact] : searchRows(tracked, w => [{ field: "name", text: w.title }], args.workspace ?? "");
|
|
398
401
|
if (args.workspace && !workspaces.length) throw new Error(`No tracked workspace matches ${args.workspace}.`);
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
.filter(r =>
|
|
402
|
-
.filter(r => !args.
|
|
403
|
-
|
|
402
|
+
const closed = (r: { state: string }) => ["MERGED", "CLOSED"].includes(r.state);
|
|
403
|
+
const rows = workspaces.flatMap(w => w.prs.map(p => ({ p, r: prRow(w, p) })))
|
|
404
|
+
.filter(({ r }) => args.include_closed || !closed(r))
|
|
405
|
+
.filter(({ r }) => !args.needs_reviewers || r.needsReviewers)
|
|
406
|
+
.filter(({ r }) => !args.ready_to_merge || r.mergeable);
|
|
407
|
+
// Open PRs in full; merged and closed ones (include_closed) as the newest few and a count, paged by offset/limit.
|
|
408
|
+
const bounded = boundDone(rows, ({ r }) => closed(r), { newestFirst: newestFirst(rows, ({ p }) => Date.parse(p.snapshot?.mergedAt ?? p.snapshot?.observedAt ?? "") || 0), hint: "list_prs include_closed offset/limit pages these (newest first)", offset: args.offset, limit: args.limit });
|
|
409
|
+
return { prs: bounded.items.map(({ r }) => r), ...(args.include_closed ? { closed: bounded.done } : {}), workspaces: workspaces.map(w => ({ id: w.id, title: w.title, mainAgentId: w.mainAgentId, enable_auto_sends: w.enable_auto_sends, hold: w.hold, pendingBatches: w.batches.filter(b => b.state === "pending" && !recoveryBatch(b)).map(b => ({ id: b.id, tasks: b.tasks.length })), retryableBatches: w.batches.filter(b => ["blocked", "uncertain"].includes(b.state)).map(b => ({ id: b.id, state: b.state, result: b.result })) })) };
|
|
404
410
|
}
|
|
405
411
|
|
|
406
412
|
/** Dry run: who would be asked on each PR, and what stops it. The same checks the Add reviewers button makes. */
|
|
@@ -526,13 +532,16 @@ export class AgentActions {
|
|
|
526
532
|
return { dryRun: true, planId, workspaceId: preview.id, snooze: preview.snooze ?? null, next: `Only on the developer's request: call snooze_workspace with confirm=true and planId=${planId}.` };
|
|
527
533
|
}
|
|
528
534
|
|
|
529
|
-
private async inboxList(caller: string, args: { flagged_only?: boolean }) {
|
|
535
|
+
private async inboxList(caller: string, args: { flagged_only?: boolean; offset?: number; limit?: number }) {
|
|
530
536
|
const { enabled, rows } = await this.d.inbox.list();
|
|
531
537
|
const now = this.now();
|
|
532
538
|
const state = await this.d.store.snapshot();
|
|
533
539
|
const tracked = new Map(state.workspaces.map(w => [w.id, w]));
|
|
534
540
|
const held = !!this.d.autoSendsHeld?.();
|
|
535
|
-
|
|
541
|
+
// Flagged, snoozed, running and signed-off-today rows (and your own) in full; quiet ones as the newest few and a count.
|
|
542
|
+
const listed = rows.filter(r => !args.flagged_only || r.needs && !r.snooze);
|
|
543
|
+
const bounded = boundDone(listed, r => r.agentId !== caller && sectionOf(r, now) === null, { newestFirst: newestFirst(listed, r => Date.parse(r.lastActivityAt ?? "") || 0), hint: "inbox_list offset/limit pages these (newest first)", offset: args.offset, limit: args.limit });
|
|
544
|
+
return { enabled, you: caller, quiet: bounded.done, rows: bounded.items.map(r => {
|
|
536
545
|
const head = flagHeadline(r, now);
|
|
537
546
|
// Home's Sending row rides its workspace's main agent: queued or sent, when and why, and whether send_repairs would go through.
|
|
538
547
|
const w = r.workspaceId ? tracked.get(r.workspaceId) : undefined;
|
package/server/agent-hook.mjs
CHANGED
|
@@ -18,7 +18,7 @@ let native = env("TOOLS") === "native";
|
|
|
18
18
|
*/
|
|
19
19
|
const inPrompt = new Set(String(env("SYSTEM_PROMPT") ?? "").split(",").filter(Boolean));
|
|
20
20
|
// Tool names that read unambiguously in prose; kept identical to server/mcp.mjs's underscore names (a test checks it).
|
|
21
|
-
export const TOOL_NAMES = ["workspace_status", "brief_settings", "set_brief_settings", "brief_plan", "set_brief_plan", "brief_chat_search", "brief_sources", "set_brief_sources", "compass_find", "set_compass", "read_compass", "compass_note", "why_suggested", "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", "pr_stats", "pr_stats_settings", "set_pr_stats", "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", "dismiss_question", "dismiss_item", "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", "linear_queue", "sweep_queue", "dispatch_sources", "dispatch_records", "dispatch_undo", "dispatch_actions", "set_dispatch_actions", "dispatch_settings", "set_dispatch_settings", "wait_for_checks"];
|
|
21
|
+
export const TOOL_NAMES = ["workspace_status", "workspace_now", "brief_settings", "set_brief_settings", "brief_plan", "set_brief_plan", "brief_chat_search", "brief_sources", "set_brief_sources", "compass_find", "set_compass", "read_compass", "compass_note", "why_suggested", "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", "pr_stats", "pr_stats_settings", "set_pr_stats", "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", "dismiss_question", "dismiss_item", "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", "question_action", "context_reply", "linear_queue", "sweep_queue", "dispatch_sources", "dispatch_records", "dispatch_undo", "dispatch_actions", "set_dispatch_actions", "dispatch_settings", "set_dispatch_settings", "wait_for_checks"];
|
|
22
22
|
const toolPattern = new RegExp(`(?<![\\w])(${TOOL_NAMES.join("|")})(?![\\w])`, "g");
|
|
23
23
|
/** Names Follow-up's tools the way this agent has them. */
|
|
24
24
|
export function named(text, isNative = native) { return isNative ? text.replace(toolPattern, "follow_$1") : text; }
|
|
@@ -35,16 +35,18 @@ export function toolsDetached(isNative, current, mine) { return isNative && !!cu
|
|
|
35
35
|
export const detachedNotice = "Follow-up was updated while this session was open, so its follow_* tools are detached and fail with \"Tool not found\" until this session reopens (Paseo reopens it before your next prompt). Until then use the bridge, which runs the same tools with their unprefixed names: node \"$FOLLOW_UP_CLI\" call <tool> '<json>' --compact (for example sync_workspace or needs_you). Do not mention this to the developer.";
|
|
36
36
|
const quietRevision = 1;
|
|
37
37
|
const quietInstruction = "Do routine bookkeeping silently. Do not announce tracker calls, say you updated/synced the sidebar, recap panel state, or add plugin-status commentary/final paragraphs. Put receipts and evidence in the tools. User-facing messages should cover the actual work outcome, or a decision/blocker requiring the developer; answer sidebar status only when explicitly asked. If this continuation is bookkeeping only, use the tools and finish without another recap or repeating your previous answer.";
|
|
38
|
-
const stopReason = "Silently complete this workspace's sidebar bookkeeping before finishing.";
|
|
38
|
+
export const stopReason = "Silently complete this workspace's sidebar bookkeeping before finishing.";
|
|
39
39
|
// Kept identical to NEEDS_YOU_NUDGE in shared/brief.ts (a test checks it).
|
|
40
|
-
const nudgeReason = "Before you stop, call needs_you once with what the developer has to do next: a decision with options (or questions=[\"Q18\"] for one that is already an open question), an action only they can take, or kind=done (\"Nothing needed\" plus what you finished), which means nothing for the developer and won't flag you. Then stop; don't repeat your reply.";
|
|
40
|
+
export const nudgeReason = "Before you stop, call needs_you once with what the developer has to do next: a decision with options (or questions=[\"Q18\"] for one that is already an open question), an action only they can take, or kind=done (\"Nothing needed\" plus what you finished), which means nothing for the developer and won't flag you. Then stop; don't repeat your reply.";
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* R2: whether to nudge a Claude Code root agent that ended its turn without needs_you. Pure, so every skip is testable.
|
|
44
44
|
* At most once per turn: Claude's stop_hook_active and our own per-turn `stopped` marker both end it.
|
|
45
45
|
*/
|
|
46
46
|
/** due-by-fact: the line above the due tasks a turn end names. */
|
|
47
|
-
|
|
47
|
+
/** The first line of the turn-end message a provider without this hook gets instead (server/turn-end.ts). */
|
|
48
|
+
export const turnEndPrefix = "Follow-up turn-end check:";
|
|
49
|
+
export const dueHeader = "Follow-up: these tasks are due. For each, do it and close it with update_obligation (status=done with evidence), or keep it with recheck=\"YYYY-MM-DD\" and why in evidence.";
|
|
48
50
|
/**
|
|
49
51
|
* The due tasks to name at this turn end: due entries (from scopes.json) whose time passed, not yet named twice for
|
|
50
52
|
* this fact and revision and not within a day, oldest first, at most 3; and the receipt counting them. A copy of
|
|
@@ -218,7 +220,7 @@ function paragraphs(lease, contributor, workflow, directory) {
|
|
|
218
220
|
"Stakeholder replies are follow-up too. When asked to update a requester, capture the original Slack threadUrl, recipient and explicit developer authorization in the task's communication field; referenced messages alone do not authorize posting. Use a concise progress task now and, when needed, a verify-and-reply task with purpose=verified after the relevant deployed PRs. Read existing thread replies and refresh evidence before posting; distinguish fixed, deployed and verified. Record the actual sent replyUrl and result before marking done. If posting is unavailable or its outcome is uncertain, keep the task blocked and check the thread before any retry; never claim a draft was sent. Auto authorizes delivery to you, not external messages. Communication-only requests do not authorize repairs, benchmarks, migrations or other production writes.",
|
|
219
221
|
"A task comes due by itself when its afterPrs reach dependencyStage, or on its recheck date (update_obligation recheck=\"YYYY-MM-DD\"; a task with no PRs defaults to 3 days after your last update). At your turn\u2019s end Follow-up names due tasks: do each and close it with evidence, or keep it with a new recheck and why. A trigger={event:\"now\"|\"merge\"|\"deploy\",delayDays:0} also sends a task to you as a message; set one only from the developer\u2019s requested timing; never infer timing from a title or enable_follow_up alone. trigger={event:\"at\",at:\"<ISO time with offset>\"} or {event:\"at\",inMinutes:30} sends it to you once at that time, Auto-send on or off: set it from a time the developer named, or yourself on a waiting task to check back on something Follow-up can\u2019t see (a registry, a release window, a reply); never a sleep loop or a timer of your own (CI: wait_for_checks). Merge/deploy triggers require owned afterPrs; delayDays=14 waits fourteen days after the last dependency event. Now requires no PR dependencies or delay. Deployment timing starts at the first verified fully serving observation and remains conservative when history is unknown. Preserve existing trigger fields on updates; trigger=null removes it. Auto controls delivery, not timing or production permissions.",
|
|
220
222
|
batchParagraph(workflow) + " For post-deploy tasks, verify the currently serving revision contains every dependency and record behavioral results separately. Acknowledge the header's batch ID with acknowledge_batch before finishing: completed with the result, or blocked with the reason (humanOnly=true when only a person can move it, such as a stale review the reviewer must re-review or dismiss). Verify the entire goal and post-merge work before declare_done; acknowledge a completion batch first. " + mergeLine(workflow),
|
|
221
|
-
"Before ending this turn, reconcile the sidebar with what you actually did and call sync_workspace with a short summary, including when no changes are needed. Acknowledge any assigned batch. When the entire goal is fulfilled, use declare_done; otherwise preserve remaining work. Do not launch recovery, start queued repairs, merge, toggle merge-when-ready, or archive as part of this bookkeeping. Auto still governs separate follow-up sends. Subagents report to the main agent instead of claiming workspace ownership.",
|
|
223
|
+
"Before ending this turn, reconcile the sidebar with what you actually did and call sync_workspace with a short summary, including when no changes are needed. Pass milestone when the milestone you're on changed. Acknowledge any assigned batch. When the entire goal is fulfilled, use declare_done; otherwise preserve remaining work. Do not launch recovery, start queued repairs, merge, toggle merge-when-ready, or archive as part of this bookkeeping. Auto still governs separate follow-up sends. Subagents report to the main agent instead of claiming workspace ownership.",
|
|
222
224
|
`Prefer the native follow-up MCP tools. For a full historical record, use workspace_status with detail=full. CLI compatibility fallback: FOLLOW_UP_CLIENT_ENTRY=${quote(lease.clientEntry)} node ${quote(join(directory, "mcp.mjs"))} call <tool> '<json>' --compact. Omit --compact only when an existing script needs the full response. Never ask the developer to maintain the sidebar or run this bridge.`,
|
|
223
225
|
];
|
|
224
226
|
}
|