paseo-follow-up 2.3.0-beta.2 → 2.3.0-beta.4
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/dismiss.tsx +115 -14
- package/client/header.tsx +3 -2
- package/client/home-chrome.tsx +44 -11
- package/client/home.tsx +2 -1
- package/client/needs-you.tsx +3 -2
- package/client/panel.tsx +6 -5
- package/client/settings-screens.ts +41 -0
- package/client/settings.tsx +26 -8
- package/client/sidebar-view.tsx +6 -5
- package/client/stacks.tsx +9 -1
- package/client/theme.ts +12 -0
- package/client/updates.tsx +5 -5
- package/index.client.tsx +7 -4
- package/package.json +1 -1
- package/server/agent-actions.ts +5 -1
- package/server/engine.ts +18 -3
- package/server/github.ts +124 -16
- package/server/local-titles.ts +9 -12
- package/server/mcp-source.ts +2 -0
- package/server/mcp.mjs +2 -0
- package/shared/chat.ts +5 -15
- package/shared/created.ts +13 -21
- package/shared/layout-swap.ts +63 -0
- package/shared/model.ts +5 -0
- package/shared/overseer.ts +7 -1
- package/shared/poll.ts +44 -11
- package/shared/presentation.ts +14 -0
- package/shared/search.ts +39 -7
- package/shared/settings-nav.ts +14 -2
- package/shared/tool-result.ts +70 -0
package/client/stacks.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { View } from "react-native";
|
|
|
2
2
|
import { Pressable, Text } from "./text";
|
|
3
3
|
import { Icon } from "@getpaseo/plugin/client/ui";
|
|
4
4
|
import type { Pr, Workspace } from "../shared/model";
|
|
5
|
-
import { compactPrStatus, orderedStacks, settledForDisplay } from "../shared/presentation";
|
|
5
|
+
import { compactPrStatus, githubWaitLine, orderedStacks, settledForDisplay } from "../shared/presentation";
|
|
6
6
|
import { mergeQueued, prTone, stackOrder } from "../shared/attention";
|
|
7
7
|
import { reviewersMissing } from "../shared/pr-workflow";
|
|
8
8
|
import { isGithubFlow } from "../shared/pr-actions";
|
|
@@ -123,6 +123,7 @@ export function StacksCard({ workspace: w, theme, compact, open, toggle, onOpen,
|
|
|
123
123
|
const showRepo = new Set(w.prs.map(p => p.repo)).size > 1;
|
|
124
124
|
const openCount = w.prs.filter(p => p.snapshot?.state === "OPEN").length;
|
|
125
125
|
const inFlight = w.prActions.filter(a => a.state === "sending");
|
|
126
|
+
const wait = githubWaitLine(w, Date.now());
|
|
126
127
|
const settledOpen = open("settled");
|
|
127
128
|
const settledPrs = settled.reduce((n, s) => n + s.prs.length, 0);
|
|
128
129
|
// Every PR in the order the card draws them, settled stacks included: the search's "n of N" and its filter.
|
|
@@ -135,6 +136,13 @@ export function StacksCard({ workspace: w, theme, compact, open, toggle, onOpen,
|
|
|
135
136
|
<View style={{ paddingTop: 3 }}><Spinner color={c.accent} size={12} /></View>
|
|
136
137
|
<RichText style={[t.meta, { flex: 1, color: c.foreground }]}>{a.result || (isGithubFlow(w.prs.find(p => p.key === a.prs[0])?.snapshot) ? "Sending to GitHub…" : "Submitting to Graphite…")}</RichText>
|
|
137
138
|
</View>)}
|
|
139
|
+
{!hits && wait && <View accessible accessibilityLabel={wait.label} style={{ flexDirection: "row", gap: 8, paddingHorizontal: 12, paddingVertical: 8, borderTopWidth: 1, borderTopColor: c.border }}>
|
|
140
|
+
<View style={{ paddingTop: 2 }}><Icon name="CirclePause" size={13} color={c.foregroundMuted} /></View>
|
|
141
|
+
<View style={{ flex: 1, gap: 2 }}>
|
|
142
|
+
<Text style={[t.meta, { color: c.foreground, fontVariant: ["tabular-nums"] }]}>{wait.title}</Text>
|
|
143
|
+
<Text style={t.meta}>{wait.detail}</Text>
|
|
144
|
+
</View>
|
|
145
|
+
</View>}
|
|
138
146
|
{!hits && <HeldMerges workspace={w} theme={theme} compact={compact} framed />}
|
|
139
147
|
{!hits && !w.prs.length && <View style={{ paddingHorizontal: 12, paddingVertical: 10, borderTopWidth: 1, borderTopColor: c.border, gap: 4 }}>
|
|
140
148
|
<Text style={t.body}>No PRs yet</Text>
|
package/client/theme.ts
CHANGED
|
@@ -41,6 +41,18 @@ export function readable(color: string, colors: Colors): string {
|
|
|
41
41
|
return color;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* A status hue as a solid fill under white text: darkened until white reads on it (4.5:1), then by `shade` (hover
|
|
46
|
+
* 0.9, pressed 0.82). Dark hosts' danger red is a light text red; as a fill it is deepened, light hosts' red already passes.
|
|
47
|
+
*/
|
|
48
|
+
export function solidFor(color: string, shade = 1): string {
|
|
49
|
+
const rgb = channels(color);
|
|
50
|
+
if (!rgb) return color;
|
|
51
|
+
let k = 1;
|
|
52
|
+
while (k > 0.3 && 1.05 / (luminance(rgb.map(v => v * k)) + 0.05) < 4.5) k -= 0.02;
|
|
53
|
+
return `rgb(${rgb.map(v => Math.round(v * k * shade)).join(", ")})`;
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
export function withAlpha(color: string, alpha: number): string {
|
|
45
57
|
const rgb = channels(color);
|
|
46
58
|
return rgb ? `rgba(${rgb.join(", ")}, ${alpha})` : color;
|
package/client/updates.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
7
7
|
import { dismissUpdateNoticeRpc, installUpdateRpc, retryMoveRpc, setUpdatesRpc, updatesRpc } from "../shared/contracts";
|
|
8
8
|
import { moveLine } from "../shared/plugin-move";
|
|
9
9
|
import { MODE_HINT, MODE_LABEL, UPDATE_MODES, WHATS_NEW_LABEL, channelHint, checkedText, copyCommand, statusCopy, versionMark, whatsNewHint, type StatusAction, type UpdateMode, type UpdatesChange, type UpdatesView } from "../shared/updates";
|
|
10
|
-
import {
|
|
10
|
+
import type { SettingsCategory } from "../shared/settings-nav";
|
|
11
11
|
import type { Channel } from "../shared/version";
|
|
12
12
|
import { Button, errorText, space, text, useNow, type Theme } from "./kit";
|
|
13
13
|
import { Spinner } from "./motion";
|
|
@@ -28,7 +28,7 @@ export function useUpdates(check?: "settings") {
|
|
|
28
28
|
|
|
29
29
|
const toneColor = (tone: "success" | "warning" | "muted", c: Theme["colors"]) => tone === "success" ? c.statusSuccess : tone === "warning" ? c.statusWarning : c.foregroundMuted;
|
|
30
30
|
/** Home's top line: an update to install (Tell me mode) or a rollback. One slot; the rollback wins. */
|
|
31
|
-
export function UpdateNotice({ theme, compact, openSettings }: { theme: Theme; compact: boolean; openSettings: () => void }) {
|
|
31
|
+
export function UpdateNotice({ theme, compact, openSettings }: { theme: Theme; compact: boolean; openSettings: (category?: SettingsCategory) => void }) {
|
|
32
32
|
const c = theme.colors; const t = text(c);
|
|
33
33
|
const query = useUpdates(); const cache = useQueryClient(); const toast = useToast();
|
|
34
34
|
const dismiss = useRpc(dismissUpdateNoticeRpc); const install = useRpc(installUpdateRpc);
|
|
@@ -53,7 +53,7 @@ export function UpdateNotice({ theme, compact, openSettings }: { theme: Theme; c
|
|
|
53
53
|
</Pressable>
|
|
54
54
|
</View>
|
|
55
55
|
<View style={{ flexDirection: "row", gap: 8, paddingLeft: 25 }}>
|
|
56
|
-
{rolled ? <Button title="Details" theme={theme} compact={compact} onPress={() =>
|
|
56
|
+
{rolled ? <Button title="Details" theme={theme} compact={compact} onPress={() => openSettings("general")} />
|
|
57
57
|
: confirm ? <>
|
|
58
58
|
<Button title="Install now" theme={theme} compact={compact} loading={run.isPending} onPress={() => run.mutate(() => install({ version: n.version, anyway: true }))} />
|
|
59
59
|
<Button title="Cancel" kind="ghost" theme={theme} compact={compact} onPress={() => setConfirm(false)} />
|
|
@@ -212,7 +212,7 @@ export function UpdatesStep({ theme, compact }: { theme: Theme; compact: boolean
|
|
|
212
212
|
* accessibility label still says it. Loading takes no width; a failed read shows nothing. `touch`: a 44pt box
|
|
213
213
|
* (react-native-web ignores hitSlop).
|
|
214
214
|
*/
|
|
215
|
-
export function VersionMark({ theme, touch, openSettings }: { theme: Theme; touch: boolean; openSettings: () => void }) {
|
|
215
|
+
export function VersionMark({ theme, touch, openSettings }: { theme: Theme; touch: boolean; openSettings: (category?: SettingsCategory) => void }) {
|
|
216
216
|
const c = theme.colors; const t = text(c, touch);
|
|
217
217
|
const query = useUpdates();
|
|
218
218
|
if (!query.data) return null;
|
|
@@ -220,7 +220,7 @@ export function VersionMark({ theme, touch, openSettings }: { theme: Theme; touc
|
|
|
220
220
|
const style = touch ? t.meta : t.small;
|
|
221
221
|
const box = touch ? { minHeight: 44, paddingHorizontal: 10, justifyContent: "center" as const } : { paddingHorizontal: 4, paddingVertical: 4 };
|
|
222
222
|
return <Pressable accessibilityRole="button" accessibilityLabel={mark.label} accessibilityHint="Opens Follow-up settings, General" hitSlop={touch ? undefined : 8}
|
|
223
|
-
onPress={() =>
|
|
223
|
+
onPress={() => openSettings("general")} style={[box, { flexShrink: 1, minWidth: 0 }]}>
|
|
224
224
|
{state => { const hover = !!(state as { hovered?: boolean }).hovered || state.pressed; const line = hover ? { color: c.foreground, textDecorationLine: "underline" as const } : null;
|
|
225
225
|
return <Text numberOfLines={1} style={[style, line]}>{mark.version}</Text>; }}
|
|
226
226
|
</Pressable>;
|
package/index.client.tsx
CHANGED
|
@@ -26,7 +26,8 @@ import { inboxSidebarView, sidebarViewHost } from "./client/sidebar-view";
|
|
|
26
26
|
import { OVERSEER_KEY } from "./client/home-list";
|
|
27
27
|
import { contributeBrief } from "./client/brief";
|
|
28
28
|
import { clientTimeZoneRpc, setOnboardingRpc } from "./shared/contracts";
|
|
29
|
-
import {
|
|
29
|
+
import { createSettings } from "./client/settings-screens";
|
|
30
|
+
import type { SettingsCategory } from "./shared/settings-nav";
|
|
30
31
|
import { openReportSheet, ReportSheetHost, setReportFallback } from "./client/report-issue";
|
|
31
32
|
import { openRename, RenameHost } from "./client/rename";
|
|
32
33
|
import { setReportError } from "./client/toast-store";
|
|
@@ -54,7 +55,6 @@ export default function contribute(host: PluginClientContext) {
|
|
|
54
55
|
.catch(() => { if (attempt < 4) setTimeout(() => reportTimeZone(attempt + 1), [5_000, 30_000, 120_000, 600_000][attempt]); });
|
|
55
56
|
};
|
|
56
57
|
reportTimeZone();
|
|
57
|
-
const openSettings = (category?: string) => { if (isCategory(category)) writeCategory(category); client.openSettings("projects"); };
|
|
58
58
|
const openOverview = () => client.openScreen({ screenId: OVERVIEW });
|
|
59
59
|
const openLog = () => client.openScreen({ screenId: OVERVIEW, params: { view: "log" } });
|
|
60
60
|
const openCatchUp = () => client.openScreen({ screenId: OVERVIEW, params: { view: "catchup", at: "0", n: String(Date.now()) } });
|
|
@@ -67,7 +67,10 @@ export default function contribute(host: PluginClientContext) {
|
|
|
67
67
|
setReportFallback(() => client.openScreen({ screenId: OVERVIEW }));
|
|
68
68
|
setReportError((message, at) => openReportSheet({ kind: "bug", error: message, at }));
|
|
69
69
|
const reportHost = (props: PluginSurfaceProps | PluginWorkspacePanelProps) => <><ReportSheetHost theme={props.theme} layout={props.layout} openAgent={props.navigation ? agentId => props.navigation!.openAgent({ agentId }) : undefined} /><RenameHost theme={props.theme} compact={props.layout.compact} /></>;
|
|
70
|
-
const Settings = (props: PluginSurfaceProps) => <><FollowSettings {...props} openSetup={openSetup} openReport={() => openReportSheet()} />{reportHost(props)}</>;
|
|
70
|
+
const Settings = (props: PluginSurfaceProps & { category?: SettingsCategory }) => <><FollowSettings {...props} openSetup={openSetup} openReport={() => openReportSheet()} />{reportHost(props)}</>;
|
|
71
|
+
// Paseo 0.16: one settings screen per category (its own tabs); 0.15: one screen with Follow-up's tabs (client/settings-screens.ts).
|
|
72
|
+
const settings = createSettings(client, Settings);
|
|
73
|
+
const openSettings = settings.open;
|
|
71
74
|
const store = createLiveStore(client);
|
|
72
75
|
const inbox = createInboxStore(host);
|
|
73
76
|
// A brief's x (client/dismiss.tsx) updates the inbox rows at once, like Sign off.
|
|
@@ -107,7 +110,7 @@ export default function contribute(host: PluginClientContext) {
|
|
|
107
110
|
client.addScreen({ id: OVERVIEW, title: "Follow-up", Component: Overview }),
|
|
108
111
|
client.addScreen({ id: LARGE_SCREEN, title: params => store.get(params.workspaceId ?? "")?.title ?? "Follow-up", Component: Large }),
|
|
109
112
|
...LEGACY_SETTINGS_SCREENS.map(id => client.addScreen({ id, title: "Follow-up settings", Component: Settings })),
|
|
110
|
-
|
|
113
|
+
settings.remove,
|
|
111
114
|
client.addWorkspacePanel({ id: PANEL, title: "Follow-up", icon: FOLLOW_UP_ICON, locations: ["workspace", "explorer"], Component: Panel }),
|
|
112
115
|
client.addCommandCenterItem({ id: "open-follow-up", title: "Follow-up: open for this workspace", icon: FOLLOW_UP_ICON, keywords: ["PR", "stack", "repairs", "done", "archive"], context: "workspace", onSelect({ openPanel }) { openPanel(PANEL, { location: location() }); } }),
|
|
113
116
|
client.addCommandCenterItem({ id: "open-follow-up-large", title: "Follow-up: open the larger view", icon: "Maximize2", keywords: ["expand", "full screen", "maximize", "PR", "stack"], context: "workspace", onSelect({ workspace, openScreen }) { openScreen({ screenId: LARGE_SCREEN, params: { workspaceId: workspace.id } }); } }),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.3.0-beta.
|
|
4
|
+
"version": "2.3.0-beta.4",
|
|
5
5
|
"description": "A Paseo plugin that follows every workspace until the work is done: one Home for what needs you, questions you answer anywhere, and repairs that send themselves.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
package/server/agent-actions.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { searchRows } from "../shared/search";
|
|
1
2
|
import { sendingOf } from "../shared/sending";
|
|
2
3
|
import { agentActor, type Actor } from "../shared/actor";
|
|
3
4
|
import { conditionId, noProgressSends } from "../shared/send-decision";
|
|
@@ -363,7 +364,10 @@ export class AgentActions {
|
|
|
363
364
|
|
|
364
365
|
private async listPrs(args: { workspace?: string; needs_reviewers?: boolean; ready_to_merge?: boolean; include_closed?: boolean }) {
|
|
365
366
|
const state = await this.d.store.snapshot();
|
|
366
|
-
const
|
|
367
|
+
const tracked = this.tracked(state);
|
|
368
|
+
// Stable ids remain exact identities. Text queries share Home's layout-aware matcher.
|
|
369
|
+
const exact = tracked.find(w => w.id === args.workspace);
|
|
370
|
+
const workspaces = exact ? [exact] : searchRows(tracked, w => [{ field: "name", text: w.title }], args.workspace ?? "");
|
|
367
371
|
if (args.workspace && !workspaces.length) throw new Error(`No tracked workspace matches ${args.workspace}.`);
|
|
368
372
|
const prs = workspaces.flatMap(w => w.prs.map(p => prRow(w, p)))
|
|
369
373
|
.filter(r => args.include_closed || !["MERGED", "CLOSED"].includes(r.state))
|
package/server/engine.ts
CHANGED
|
@@ -130,7 +130,7 @@ export class Engine {
|
|
|
130
130
|
statusCheck: (w: Workspace, now: number, inputs?: string) => Promise<void> = async () => {};
|
|
131
131
|
/** Background refreshes skipped while paused, for tests and the resource check. */
|
|
132
132
|
skipped = 0;
|
|
133
|
-
constructor(readonly store: Store, private github: Pick<Github, "observe"
|
|
133
|
+
constructor(readonly store: Store, private github: Pick<Github, "observe"> & Partial<Pick<Github, "waitUntil">>, private gateway: Gateway, private now = Date.now, private settleMs = 60_000, private nudgeMs = NUDGE_MS) {}
|
|
134
134
|
async recover(): Promise<void> {
|
|
135
135
|
await this.store.mutate(state => {
|
|
136
136
|
for (const w of state.workspaces) {
|
|
@@ -182,6 +182,17 @@ export class Engine {
|
|
|
182
182
|
this.running = this.store.batch(() => this.run(o)).catch(() => { this.error = "Follow-up refresh failed. Saved work is intact; refresh will retry."; }).finally(() => { this.running = null; });
|
|
183
183
|
return this.running;
|
|
184
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* When Follow-up's GitHub reads resume for this workspace's open PRs, while the account's budget is under the reserve
|
|
187
|
+
* (`Github.waitUntil`): the earliest reset among their repositories, or null when reads run. Merged and closed PRs
|
|
188
|
+
* aren't read anyway, so a workspace with only those says nothing.
|
|
189
|
+
*/
|
|
190
|
+
private githubWait(w: Workspace): string | null {
|
|
191
|
+
if (!this.github.waitUntil) return null;
|
|
192
|
+
const until = [...new Set(w.prs.filter(p => p.snapshot?.state !== "MERGED" && p.snapshot?.state !== "CLOSED").map(p => p.repo))]
|
|
193
|
+
.map(repo => this.github.waitUntil!(repo)).filter((t): t is number => t !== null && t > this.now());
|
|
194
|
+
return until.length ? new Date(Math.min(...until)).toISOString() : null;
|
|
195
|
+
}
|
|
185
196
|
/** Reads one workspace's PRs fresh and records what came back, nothing else (a Refresh of a dormant workspace). */
|
|
186
197
|
private async refreshPrs(w: Workspace): Promise<void> {
|
|
187
198
|
const observations = await this.github.observe(w.prs, { background: true, fresh: new Set(w.prs.map(p => p.key)) });
|
|
@@ -257,15 +268,17 @@ export class Engine {
|
|
|
257
268
|
// left, same runtime, no PR read or error it hasn't recorded, and a full pass under OBSERVE_FULL_MS ago (time-based
|
|
258
269
|
// rules, like the 120 s acknowledgement, run on that pass). The checks cost a ~200-byte JSON and a shallow compare per PR.
|
|
259
270
|
const runtimeKey = JSON.stringify(runtime);
|
|
271
|
+
const githubWait = this.githubWait(original);
|
|
260
272
|
const last = this.observedPass.get(original.id);
|
|
261
273
|
// A scheduled task due since the last pass makes it a full pass, so a trigger fires at its time, not up to a minute late.
|
|
262
|
-
const untouched = !!last && last.w === original && last.runtime === runtimeKey && this.now() - last.at < OBSERVE_FULL_MS && this.now() < last.dueAt && o.workspaceId !== original.id &&
|
|
274
|
+
const untouched = (original.githubWait?.until ?? null) === githubWait && !!last && last.w === original && last.runtime === runtimeKey && this.now() - last.at < OBSERVE_FULL_MS && this.now() < last.dueAt && o.workspaceId !== original.id &&
|
|
263
275
|
original.prs.every(p => { const seen = observations.get(p.key); return !seen || seen.error === p.error && sameSnapshot(seen.snapshot, p.snapshot, !isHot(original) && !awaitsRead(original)); });
|
|
264
276
|
if (!untouched) this.observationWrites++;
|
|
265
277
|
if (!untouched) await this.store.mutateWorkspace(original.id, w => {
|
|
266
278
|
w.runtimeBusy = runtime.busy; w.runtimeReason = runtime.reason; w.taskAgents = runtime.taskAgents;
|
|
267
279
|
w.backgroundBusy = runtime.backgroundBusy ?? false;
|
|
268
280
|
w.mainBusy = repairWait(runtime);
|
|
281
|
+
if ((w.githubWait?.until ?? null) !== githubWait) w.githubWait = githubWait ? { until: githubWait } : null;
|
|
269
282
|
if (runtime.mainTitle !== undefined && (w.mainAgentTitle ?? null) !== runtime.mainTitle) w.mainAgentTitle = runtime.mainTitle;
|
|
270
283
|
if (runtime.gone && w.goneAgent?.agentId !== w.mainAgentId) w.goneAgent = { agentId: w.mainAgentId, at: new Date(this.now()).toISOString(), reason: runtime.gone };
|
|
271
284
|
if (w.goneAgent?.agentId === w.mainAgentId) w.runtimeReason = GONE_REASON;
|
|
@@ -396,7 +409,9 @@ export class Engine {
|
|
|
396
409
|
if (state.workspaceOptOuts?.includes(workspaceId)) state.workspaceOptOuts = state.workspaceOptOuts.filter(id => id !== workspaceId);
|
|
397
410
|
});
|
|
398
411
|
const activated = findWorkspace(await this.store.snapshot(), workspaceId);
|
|
399
|
-
|
|
412
|
+
// Its PRs fresh, everything else with the usual backoff: before 2026-11-19 this was a full fresh read of every
|
|
413
|
+
// tracked PR (~100 GraphQL points per follow at 100 open PRs).
|
|
414
|
+
void this.tick({ background: true, workspaceId });
|
|
400
415
|
return activated;
|
|
401
416
|
}
|
|
402
417
|
/** Records the developer's answer, then queues it unless they chose to copy it or put it in chat. */
|
package/server/github.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { PrWorkflow } from "../shared/pr-workflow";
|
|
|
5
5
|
import type { Pr, Snapshot } from "../shared/model";
|
|
6
6
|
import type { Deployments } from "./deployments";
|
|
7
7
|
import { notSetUpEvidence } from "../shared/task-trigger";
|
|
8
|
-
import { budgetTier, cadence, dueForRead, type Budget } from "../shared/poll";
|
|
8
|
+
import { budgetTier, cadence, dueForRead, probeVerdict, SAFETY_READ_MS, type Budget, type Fingerprint } from "../shared/poll";
|
|
9
9
|
import { cliApi, githubApi, type GithubApi } from "./github-api";
|
|
10
10
|
import { splitReviewers, TEAM_SLUG, USER_LOGIN } from "../shared/reviewers";
|
|
11
11
|
const exec = promisify(execFile);
|
|
@@ -68,21 +68,58 @@ export function parsePr(pr: Node, trunk: string, observedAt: string, required: s
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/** Check counts by state: the whole connection's, whatever page of nodes comes back. */
|
|
72
|
+
const COUNTS = "checkRunCountsByState{state count} statusContextCountsByState{state count}";
|
|
73
|
+
/**
|
|
74
|
+
* A probe's fields (shared/poll.ts, change-first reads): everything the full read decides on that GitHub can report
|
|
75
|
+
* without per-check or per-comment nodes. ~3 requests per PR, so ~1 point per 33 PRs; the full read is ~107 per PR.
|
|
76
|
+
*/
|
|
77
|
+
const PROBE = `updatedAt state headRefOid baseRefName isDraft mergeable mergeStateStatus reviewDecision isInMergeQueue autoMergeRequest{enabledAt}
|
|
78
|
+
reviewThreads(first:100){pageInfo{hasNextPage} nodes{id isResolved}}
|
|
79
|
+
commits(last:1){nodes{commit{statusCheckRollup{contexts(first:1){${COUNTS}}}}}}`;
|
|
80
|
+
/** PRs per probe query (one account, any number of its repositories): ~300 requests, about 3 points. */
|
|
81
|
+
const PROBE_CHUNK = 100;
|
|
82
|
+
const RUNNING_STATES = new Set(["QUEUED", "IN_PROGRESS", "PENDING", "WAITING", "REQUESTED", "EXPECTED"]);
|
|
83
|
+
const FAILED_STATES = new Set(["FAILURE", "ERROR", "TIMED_OUT", "CANCELLED", "ACTION_REQUIRED", "STARTUP_FAILURE"]);
|
|
84
|
+
/**
|
|
85
|
+
* The fingerprint of a PR as a probe or a full read returned it, or null when it can't be compared (threads past one
|
|
86
|
+
* page, no updatedAt or no check counts: an older GitHub), which leaves that PR on full reads.
|
|
87
|
+
*/
|
|
88
|
+
export function fingerprint(pr: Node): Fingerprint | null {
|
|
89
|
+
const threads = pr.reviewThreads;
|
|
90
|
+
if (typeof pr.updatedAt !== "string" || !threads || !Array.isArray(threads.nodes) || threads.pageInfo?.hasNextPage !== false) return null;
|
|
91
|
+
const contexts = pr.commits?.nodes?.[0]?.commit?.statusCheckRollup?.contexts;
|
|
92
|
+
if (contexts && (!Array.isArray(contexts.checkRunCountsByState) || !Array.isArray(contexts.statusContextCountsByState))) return null;
|
|
93
|
+
const counts: [string, number][] = [
|
|
94
|
+
...(contexts?.checkRunCountsByState ?? []).map((c: Node): [string, number] => [`run:${c.state}`, Number(c.count) || 0]),
|
|
95
|
+
...(contexts?.statusContextCountsByState ?? []).map((c: Node): [string, number] => [`status:${c.state}`, Number(c.count) || 0]),
|
|
96
|
+
].filter(([, n]) => n > 0).sort(([a], [b]) => a.localeCompare(b));
|
|
97
|
+
const sum = (states: Set<string>) => counts.reduce((total, [key, n]) => total + (states.has(key.slice(key.indexOf(":") + 1)) ? n : 0), 0);
|
|
98
|
+
const unresolved = threads.nodes.filter((t: Node) => !t.isResolved).map((t: Node) => String(t.id)).sort();
|
|
99
|
+
return {
|
|
100
|
+
core: JSON.stringify([pr.updatedAt, pr.state, pr.headRefOid, pr.baseRefName, !!pr.isDraft, pr.mergeable ?? null, pr.mergeStateStatus ?? null, pr.reviewDecision ?? null, pr.isInMergeQueue ?? null, !!pr.autoMergeRequest, unresolved]),
|
|
101
|
+
checks: JSON.stringify(counts), running: sum(RUNNING_STATES), failed: sum(FAILED_STATES),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
71
105
|
/** Ruleset rules for a ref (GraphQL `Ref.rules`), the same set REST `rules/branches/<branch>` returns. */
|
|
72
106
|
const RULES = "rules(first:100){pageInfo{hasNextPage} nodes{type repositoryRuleset{enforcement} parameters{...on RequiredStatusChecksParameters{requiredStatusChecks{context}}}}}";
|
|
73
|
-
const fields = `number title url state headRefOid headRefName baseRefName isDraft mergeable mergeStateStatus reviewDecision mergedAt mergeCommit{oid} isInMergeQueue autoMergeRequest{enabledAt}
|
|
107
|
+
const fields = `number title url state updatedAt headRefOid headRefName baseRefName isDraft mergeable mergeStateStatus reviewDecision mergedAt mergeCommit{oid} isInMergeQueue autoMergeRequest{enabledAt}
|
|
74
108
|
author{login}
|
|
75
109
|
reviewRequests(first:100){pageInfo{hasNextPage} nodes{requestedReviewer{__typename ...on User{login} ...on Team{slug}}}}
|
|
76
110
|
latestReviews(first:100){pageInfo{hasNextPage} nodes{state author{__typename login}}}
|
|
77
111
|
baseRef{branchProtectionRule{requiredStatusCheckContexts} ${RULES} associatedPullRequests(first:100,states:[OPEN]){nodes{number headRefName state headRepository{nameWithOwner}}}}
|
|
78
112
|
reviewThreads(first:100){pageInfo{hasNextPage} nodes{id isResolved comments(last:1){nodes{updatedAt}}}}
|
|
79
|
-
commits(last:1){nodes{commit{statusCheckRollup{contexts(first:100){pageInfo{hasNextPage} nodes{
|
|
113
|
+
commits(last:1){nodes{commit{statusCheckRollup{contexts(first:100){${COUNTS} pageInfo{hasNextPage} nodes{
|
|
80
114
|
...on CheckRun{name status conclusion} ...on StatusContext{context state}
|
|
81
115
|
}}}}}}`;
|
|
82
116
|
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Merged or closed with a complete snapshot: final. Never read again except on its workspace's Refresh, and never in
|
|
119
|
+
* error. Closed joined merged on 2026-11-19: closed PRs were re-read every minute forever. A reopened PR shows on
|
|
120
|
+
* the workspace's Refresh, or when its agent registers it again.
|
|
121
|
+
*/
|
|
122
|
+
const finalMerged = (p: Pr): boolean => (p.snapshot?.state === "MERGED" || p.snapshot?.state === "CLOSED") && !!p.snapshot.complete;
|
|
86
123
|
|
|
87
124
|
export class GithubWriteError extends Error { constructor(message: string, readonly uncertain: boolean) { super(message); } }
|
|
88
125
|
type Method = "squash" | "merge" | "rebase";
|
|
@@ -194,17 +231,39 @@ export class Github {
|
|
|
194
231
|
const last = this.last.get(p.key);
|
|
195
232
|
return cadence(last?.snapshot, p.error || last?.error, this.changedAt.get(p.key) ?? null, this.now()) !== "idle";
|
|
196
233
|
}
|
|
197
|
-
/** Requests GitHub reads made, for tests and the poll-cost harness. */
|
|
198
|
-
readonly stats = { graphql: 0, rest: 0, skipped: 0, points: 0 };
|
|
234
|
+
/** Requests GitHub reads made, for tests and the poll-cost harness. `probes`: probe queries; `unchanged`: PRs a probe settled. */
|
|
235
|
+
readonly stats = { graphql: 0, rest: 0, skipped: 0, points: 0, probes: 0, unchanged: 0 };
|
|
236
|
+
/** Each PR's fingerprint from its last full read, and when that read was (change-first reads, shared/poll.ts). */
|
|
237
|
+
private fingerprints = new Map<string, Fingerprint>();
|
|
238
|
+
private fullAt = new Map<string, number>();
|
|
239
|
+
private noteBudget(owner: string, rate: Node | undefined): void {
|
|
240
|
+
if (!rate || typeof rate.remaining !== "number") return;
|
|
241
|
+
this.budgets.set(owner, { remaining: rate.remaining, resetAt: Date.parse(rate.resetAt) || this.now() + 3_600_000, ...(typeof rate.limit === "number" ? { limit: rate.limit } : {}) });
|
|
242
|
+
this.stats.points += Number(rate.cost) || 0;
|
|
243
|
+
}
|
|
244
|
+
private outOfBudget(owner: string, error: unknown): void {
|
|
245
|
+
this.budgets.set(owner, { remaining: 0, resetAt: (error as { resetAt?: number }).resetAt ?? this.now() + 10 * 60_000 });
|
|
246
|
+
}
|
|
247
|
+
/** A due PR that a probe may settle: read in full before, nothing wrong with that read, not asked for fresh. */
|
|
248
|
+
private probeable(p: Pr, o: { background?: boolean; fresh?: Set<string> }): boolean {
|
|
249
|
+
const last = this.last.get(p.key);
|
|
250
|
+
return !!o.background && !o.fresh?.has(p.key) && !!last?.snapshot?.complete && !last.error && !p.error && this.fingerprints.has(p.key) && this.now() - (this.fullAt.get(p.key) ?? 0) < SAFETY_READ_MS;
|
|
251
|
+
}
|
|
199
252
|
/**
|
|
200
253
|
* Reads every PR fresh, unless `background` (the engine's timer tick) allows backoff. Then only `fresh` keys,
|
|
201
254
|
* `hot` keys (busy workspaces) and hot PRs force their repository to be read this tick.
|
|
255
|
+
*
|
|
256
|
+
* Change-first (invariant `github-reads-scale-with-change`): a due PR read in full before is probed first, one query
|
|
257
|
+
* per account for every such PR, and read in full only when the probe saw a change that matters (`probeVerdict`).
|
|
258
|
+
* A fresh request (Refresh, opening the panel) and a foreground read (agent tools, actions) read in full.
|
|
202
259
|
*/
|
|
203
260
|
async observe(prs: Pr[], o: { background?: boolean; fresh?: Set<string>; hot?: Set<string> } = {}): Promise<Map<string, Observation>> {
|
|
204
261
|
const result = new Map<string, Observation>();
|
|
205
262
|
const repositories = [...new Set(prs.map(p => p.repo))];
|
|
206
263
|
const modes = new Map<string, PrWorkflow>();
|
|
207
264
|
for (const repo of repositories) modes.set(repo, this.workflow ? await this.workflow(repo).catch((): PrWorkflow => "github") : "graphite");
|
|
265
|
+
const full = new Map<string, Pr[]>();
|
|
266
|
+
const probes = new Map<string, Pr[]>();
|
|
208
267
|
for (const repo of repositories) {
|
|
209
268
|
const targets = [...new Map(prs.filter(p => p.repo === repo).map(p => [p.key, p])).values()];
|
|
210
269
|
const owner = repo.split("/")[0];
|
|
@@ -212,29 +271,66 @@ export class Github {
|
|
|
212
271
|
const pinned = (p: Pr) => o.hot?.has(p.key) || o.fresh?.has(p.key);
|
|
213
272
|
const repoUrgent = targets.some(p => pinned(p) || this.hot(p));
|
|
214
273
|
// Per-PR backoff (shared/poll.ts): only due PRs go into this tick's queries; the rest reuse their last
|
|
215
|
-
// observation.
|
|
274
|
+
// observation.
|
|
216
275
|
const due = targets.filter(p => {
|
|
217
|
-
// Merged is final:
|
|
276
|
+
// Merged or closed is final: one whose status is known isn't read again, not even on a cold start. Only the
|
|
218
277
|
// developer's Refresh of its workspace (fresh) reads it.
|
|
219
278
|
// A stored error doesn't undo that (2.0.1-beta.0 left some behind): the skip below reports no error, clearing it.
|
|
220
279
|
if (finalMerged(p) && !o.fresh?.has(p.key)) return false;
|
|
221
280
|
if (tier === "critical") return false;
|
|
281
|
+
// Under the reserve, background reads stop; the developer's Refresh and foreground reads (agent tools) still go.
|
|
282
|
+
if (tier === "reserve" && o.background && !o.fresh?.has(p.key)) return false;
|
|
222
283
|
if (!o.background || !this.last.has(p.key) || o.fresh?.has(p.key) || o.hot?.has(p.key)) return true;
|
|
223
284
|
const last = this.last.get(p.key)!;
|
|
224
285
|
return dueForRead({ snapshot: last.snapshot, error: p.error || last.error, changedAt: this.changedAt.get(p.key) ?? null, readAt: this.readAt.get(p.key) ?? 0, now: this.now(), tier, repoUrgent, since: this.changedAt.get(p.key) ?? this.seenAt.get(p.key) ?? null });
|
|
225
286
|
});
|
|
226
287
|
const dueKeys = new Set(due.map(p => p.key));
|
|
227
288
|
for (const p of targets) if (!dueKeys.has(p.key)) { this.stats.skipped++; result.set(p.key, finalMerged(p) ? { snapshot: { ...p.snapshot! }, error: null } : this.standIn(p, owner)); }
|
|
228
|
-
|
|
289
|
+
for (const p of due) { const into = this.probeable(p, o) ? probes : full; into.set(into === probes ? owner : repo, [...(into.get(into === probes ? owner : repo) ?? []), p]); }
|
|
290
|
+
}
|
|
291
|
+
// Probes: one query per account (owner) for up to PROBE_CHUNK PRs across its repositories.
|
|
292
|
+
for (const [owner, group] of probes) {
|
|
293
|
+
for (let offset = 0; offset < group.length; offset += PROBE_CHUNK) {
|
|
294
|
+
const chunk = group.slice(offset, offset + PROBE_CHUNK);
|
|
295
|
+
const byRepo = [...new Set(chunk.map(p => p.repo))];
|
|
296
|
+
const query = `query{rateLimit{cost remaining resetAt limit} ${byRepo.map((repo, r) => {
|
|
297
|
+
const [o, n] = repo.split("/");
|
|
298
|
+
return `r${r}:repository(owner:${JSON.stringify(o)},name:${JSON.stringify(n)}){${chunk.filter(p => p.repo === repo).map(p => `p${p.number}:pullRequest(number:${p.number}){${PROBE}}`).join(" ")}}`;
|
|
299
|
+
}).join(" ")}}`;
|
|
300
|
+
const reread = (p: Pr) => full.set(p.repo, [...(full.get(p.repo) ?? []), p]);
|
|
301
|
+
try {
|
|
302
|
+
this.stats.graphql++; this.stats.probes++;
|
|
303
|
+
const payload = await this.api.graphql(byRepo[0], query, {});
|
|
304
|
+
if (((payload.errors ?? []) as Node[]).some(e => e.type === "RATE_LIMITED" || e.type === "RATE_LIMIT")) throw Object.assign(new Error("rate limited"), { rateLimited: true });
|
|
305
|
+
this.noteBudget(owner, payload.data?.rateLimit);
|
|
306
|
+
for (const p of chunk) {
|
|
307
|
+
const data = payload.data?.[`r${byRepo.indexOf(p.repo)}`]?.[`p${p.number}`];
|
|
308
|
+
const seen = data ? fingerprint(data) : null;
|
|
309
|
+
const before = this.fingerprints.get(p.key)!;
|
|
310
|
+
if (!seen || probeVerdict(before, seen, this.now() - (this.fullAt.get(p.key) ?? 0)) === "read") { reread(p); continue; }
|
|
311
|
+
// Nothing the full read decides on moved: the last observation is current as of now.
|
|
312
|
+
this.stats.unchanged++; this.readAt.set(p.key, this.now());
|
|
313
|
+
result.set(p.key, { snapshot: { ...this.last.get(p.key)!.snapshot!, observedAt: new Date(this.now()).toISOString() }, error: null });
|
|
314
|
+
}
|
|
315
|
+
} catch (error) {
|
|
316
|
+
if (rateLimited(error)) { this.outOfBudget(owner, error); for (const p of chunk) result.set(p.key, this.standIn(p, owner)); continue; }
|
|
317
|
+
// Any other probe failure: the full read decides (and reports) for these PRs.
|
|
318
|
+
for (const p of chunk) reread(p);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
for (const [repo, due] of full) {
|
|
323
|
+
const owner = repo.split("/")[0];
|
|
229
324
|
for (let offset = 0; offset < due.length; offset += CHUNK) {
|
|
230
325
|
const group = due.slice(offset, offset + CHUNK);
|
|
231
|
-
|
|
232
|
-
|
|
326
|
+
// A probe (or an earlier chunk) that hit the limit stops the rest of this tick's reads on that account.
|
|
327
|
+
if (budgetTier(this.budgets.get(owner), this.now()) === "critical") { for (const p of group) result.set(p.key, this.standIn(p, owner)); continue; }
|
|
328
|
+
const [, name] = repo.split("/");
|
|
329
|
+
const query = `query($owner:String!,$name:String!){rateLimit{cost remaining resetAt limit} repository(owner:$owner,name:$name){defaultBranchRef{name branchProtectionRule{requiredStatusCheckContexts} ${RULES}} squashMergeAllowed mergeCommitAllowed rebaseMergeAllowed autoMergeAllowed viewerDefaultMergeMethod mergeQueue{id} ${group.map((p, i) => `p${i}:pullRequest(number:${p.number}){${fields}}`).join(" ")}}}`;
|
|
233
330
|
try {
|
|
234
331
|
this.stats.graphql++;
|
|
235
332
|
const payload = await this.api.graphql(repo, query, { owner, name });
|
|
236
|
-
|
|
237
|
-
if (rate && typeof rate.remaining === "number") { this.budgets.set(owner, { remaining: rate.remaining, resetAt: Date.parse(rate.resetAt) || this.now() + 3_600_000 }); this.stats.points += Number(rate.cost) || 0; }
|
|
333
|
+
this.noteBudget(owner, payload.data?.rateLimit);
|
|
238
334
|
for (const p of group) this.readAt.set(p.key, this.now());
|
|
239
335
|
// A partial response fails only the PRs its errors point at. An error outside any PR fails the group.
|
|
240
336
|
const broken = new Set<string>(); const rulesBroken = new Set<string>();
|
|
@@ -270,6 +366,9 @@ export class Github {
|
|
|
270
366
|
const trunkChecks = open && stacked(data) ? [...(repository.defaultBranchRef.branchProtectionRule?.requiredStatusCheckContexts ?? []), ...await rulesFor(trunk, trunkRules)] : [];
|
|
271
367
|
const required = [...new Set([...(data.baseRef?.branchProtectionRule?.requiredStatusCheckContexts ?? []), ...base, ...trunkChecks])];
|
|
272
368
|
const snapshot = parsePr(data, trunk, new Date(this.now()).toISOString(), required);
|
|
369
|
+
const print = fingerprint(data);
|
|
370
|
+
if (print) this.fingerprints.set(p.key, print); else this.fingerprints.delete(p.key);
|
|
371
|
+
this.fullAt.set(p.key, this.now());
|
|
273
372
|
if (modes.get(repo) === "github") {
|
|
274
373
|
// GitHub mode: merge-when-ready is GitHub's auto-merge, and the repository's merge settings travel with the PR.
|
|
275
374
|
snapshot.prWorkflow = "github"; snapshot.repoMerge = repoMerge(repository);
|
|
@@ -281,7 +380,7 @@ export class Github {
|
|
|
281
380
|
} catch (error) {
|
|
282
381
|
// Out of GraphQL budget: don't fail. Keep the last observations and wait for the reset.
|
|
283
382
|
if (rateLimited(error)) {
|
|
284
|
-
this.
|
|
383
|
+
this.outOfBudget(owner, error);
|
|
285
384
|
for (const p of group) result.set(p.key, this.standIn(p, owner));
|
|
286
385
|
continue;
|
|
287
386
|
}
|
|
@@ -331,6 +430,15 @@ export class Github {
|
|
|
331
430
|
}
|
|
332
431
|
/** Each owner's GraphQL budget from the last query's rateLimit (owners on one account report the same). */
|
|
333
432
|
budget(owner: string): Budget | undefined { return this.budgets.get(owner); }
|
|
433
|
+
/**
|
|
434
|
+
* While Follow-up holds back reads on this repository's account for the budget (the reserve or less), when they
|
|
435
|
+
* resume (GitHub's reset); null when reads run. Feeds the workspace's "GitHub budget low" line (Workspace.githubWait).
|
|
436
|
+
*/
|
|
437
|
+
waitUntil(repo: string): number | null {
|
|
438
|
+
const budget = this.budgets.get(repo.split("/")[0]);
|
|
439
|
+
const tier = budgetTier(budget, this.now());
|
|
440
|
+
return tier === "reserve" || tier === "critical" ? budget!.resetAt : null;
|
|
441
|
+
}
|
|
334
442
|
/** Keeps each PR's last observation for backoff, and when its content last changed (observedAt aside). */
|
|
335
443
|
private remember(key: string, value: Observation): void {
|
|
336
444
|
const { observedAt: _, deployment: __, ...content } = value.snapshot ?? ({} as Partial<Snapshot>);
|
package/server/local-titles.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { constants } from "node:fs";
|
|
2
2
|
import { open } from "node:fs/promises";
|
|
3
3
|
import { isClaudeArtifact } from "../shared/spec";
|
|
4
|
+
import { toolResult } from "../shared/tool-result";
|
|
4
5
|
import { receiptTitle, rememberTitle, shortTitle, type TitleIndex } from "../shared/local-titles";
|
|
5
6
|
|
|
6
7
|
export const TITLE_READ_BYTES = 8192;
|
|
@@ -16,12 +17,8 @@ export async function readTitleHtml(path: string): Promise<string | null> {
|
|
|
16
17
|
} finally { await file.close(); }
|
|
17
18
|
} catch { return null; }
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (Array.isArray(output)) return output.map(resultText).join("\n");
|
|
22
|
-
if (output && typeof output === "object") return resultText((output as { text?: unknown }).text);
|
|
23
|
-
return "";
|
|
24
|
-
}
|
|
20
|
+
/** A tool result's text, in every shape Paseo sends (shared/tool-result.ts). */
|
|
21
|
+
export const resultText = (output: unknown): string => toolResult(output).text;
|
|
25
22
|
export function artifactPublishUrl(output: unknown): string | null {
|
|
26
23
|
const url = /^(?:Published \S.*? at|Created a new Artifact at) (https:\/\/claude\.ai\/(?:code\/)?artifact\/[\w-]+)(?=[\s(.,]|$)/.exec(resultText(output).trimStart())?.[1];
|
|
27
24
|
return url && isClaudeArtifact(url) ? url : null;
|
|
@@ -32,8 +29,9 @@ export async function receiptTitles(entries: readonly { item: unknown }[], readH
|
|
|
32
29
|
const titles: TitleIndex = new Map();
|
|
33
30
|
for (const entry of entries) {
|
|
34
31
|
const v = object(entry.item), detail = object(v.detail), input = object(detail.input);
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const result = toolResult(detail.output);
|
|
33
|
+
if (v.type !== "tool_call" || v.status !== "completed" || v.error || result.isError) continue;
|
|
34
|
+
const output = result.text;
|
|
37
35
|
if (v.name === "Artifact") {
|
|
38
36
|
const action = input.action ?? "publish";
|
|
39
37
|
if (input.asset === true || !["publish", "read"].includes(String(action))) continue;
|
|
@@ -42,15 +40,14 @@ export async function receiptTitles(entries: readonly { item: unknown }[], readH
|
|
|
42
40
|
let html: string | null = null;
|
|
43
41
|
if (!shortTitle(input.title) && action === "publish" && typeof input.file_path === "string") html = await readHtml(input.file_path).catch(() => null);
|
|
44
42
|
// Read returns raw HTML or a title-labelled summary; structured read.result is preserved by Paseo too.
|
|
45
|
-
const read = object(object
|
|
43
|
+
const read = object(result.object?.read);
|
|
46
44
|
if (action === "read") html = typeof read.result === "string" ? read.result : output;
|
|
47
|
-
const named = action === "read" ? shortTitle(object
|
|
45
|
+
const named = action === "read" ? shortTitle(result.object?.title) ?? shortTitle(/^(?:Title|Artifact title):\s*(.+)$/im.exec(output)?.[1]) : null;
|
|
48
46
|
rememberTitle(titles, url, receiptTitle(named ? { ...input, title: named } : input, html));
|
|
49
47
|
}
|
|
50
48
|
if (v.name === "mcp__claude_ai_Claude_Docs__batch") {
|
|
51
49
|
// Each successful create result carries its URL; pair by operation index rather than guessing from prose.
|
|
52
|
-
|
|
53
|
-
try { if (output) parsed = JSON.parse(output); } catch { /* structured output may already be present */ }
|
|
50
|
+
const parsed = result.value;
|
|
54
51
|
const operations = Array.isArray(input.batch) ? input.batch : Array.isArray(input.operations) ? input.operations : [];
|
|
55
52
|
const results = Array.isArray(parsed) ? parsed : object(parsed).results ?? object(parsed).batch;
|
|
56
53
|
if (!Array.isArray(results)) continue;
|
package/server/mcp-source.ts
CHANGED
|
@@ -274,6 +274,8 @@ export const mcpSource: string = [
|
|
|
274
274
|
" recentAnswers: (w.questions ?? []).filter(q => q.answer).slice(-5).map(q => ({ id: q.id, title: q.title, choice: q.answer.choice, words: q.answer.words, delivery: q.answer.delivery.state })),",
|
|
275
275
|
" batches: w.batches.filter(b => ![\"completed\", \"cancelled\"].includes(b.state)).map(b => ({ id: b.id, state: b.state, tasks: b.tasks, result: b.result, recipientAgentId: b.recipientAgentId, contextPath: b.contextPath })),",
|
|
276
276
|
" nextMessage: w.nextMessageInfo ?? null, sending: w.sending ?? null, heldTasks: w.heldTasks ?? [],",
|
|
277
|
+
" // GitHub budget low: Follow-up's PR reads wait until this time (null: they run); PR statuses are from the last read.",
|
|
278
|
+
" githubWait: w.githubWait ?? null,",
|
|
277
279
|
" excludedStacks: w.excludedStacks.map(s => ({ name: s.name, reason: s.reason, prs: s.prs.map(p => p.key) })), ...(w.prWorkflow ? { prWorkflow: w.prWorkflow } : {}), detail: \"summary\" };",
|
|
278
280
|
"}",
|
|
279
281
|
"function compact(tool, input, result) {",
|
package/server/mcp.mjs
CHANGED
|
@@ -272,6 +272,8 @@ function currentWork(w) {
|
|
|
272
272
|
recentAnswers: (w.questions ?? []).filter(q => q.answer).slice(-5).map(q => ({ id: q.id, title: q.title, choice: q.answer.choice, words: q.answer.words, delivery: q.answer.delivery.state })),
|
|
273
273
|
batches: w.batches.filter(b => !["completed", "cancelled"].includes(b.state)).map(b => ({ id: b.id, state: b.state, tasks: b.tasks, result: b.result, recipientAgentId: b.recipientAgentId, contextPath: b.contextPath })),
|
|
274
274
|
nextMessage: w.nextMessageInfo ?? null, sending: w.sending ?? null, heldTasks: w.heldTasks ?? [],
|
|
275
|
+
// GitHub budget low: Follow-up's PR reads wait until this time (null: they run); PR statuses are from the last read.
|
|
276
|
+
githubWait: w.githubWait ?? null,
|
|
275
277
|
excludedStacks: w.excludedStacks.map(s => ({ name: s.name, reason: s.reason, prs: s.prs.map(p => p.key) })), ...(w.prWorkflow ? { prWorkflow: w.prWorkflow } : {}), detail: "summary" };
|
|
276
278
|
}
|
|
277
279
|
function compact(tool, input, result) {
|
package/shared/chat.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { onBehalfOf } from "./actor";
|
|
2
2
|
import { BRIDGE_TOOL, BRIDGE_SHELL_CALL, splitBatchText, isRecoveryText } from "./legacy";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { toolResult } from "./tool-result";
|
|
4
5
|
|
|
5
6
|
/** Follow-up's own messages and tool calls, recognised in agent chats so they render as compact rows. */
|
|
6
7
|
export const FOLLOW_TOOLS = ["workspace_status", "sync_workspace", "enroll_workspace", "register_pr", "exclude_stack", "update_obligation", "acknowledge_batch", "declare_done", "ask_question", "record_answer", "withdraw_question", "set_spec"] as const;
|
|
@@ -51,18 +52,7 @@ export type ToolRow = z.infer<typeof toolRowSchema>;
|
|
|
51
52
|
function record(value: unknown): value is Record<string, unknown> {
|
|
52
53
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
53
54
|
}
|
|
54
|
-
/**
|
|
55
|
-
export function readText(value: unknown): string | undefined {
|
|
56
|
-
if (value === null || value === undefined) return "";
|
|
57
|
-
if (typeof value === "string") return value;
|
|
58
|
-
if (Array.isArray(value)) {
|
|
59
|
-
const parts = value.map(part => typeof part === "string" ? part : record(part) && typeof part.text === "string" ? part.text : undefined);
|
|
60
|
-
return parts.every(p => p !== undefined) ? parts.join("\n") : undefined;
|
|
61
|
-
}
|
|
62
|
-
if (!record(value)) return undefined;
|
|
63
|
-
const key = ["output", "content", "text", "message", "result"].find(name => name in value);
|
|
64
|
-
return key ? readText(value[key]) : undefined;
|
|
65
|
-
}
|
|
55
|
+
/** The JSON object in a result's text (toolResult's text: Claude's { output }, MCP content, or a plain string). */
|
|
66
56
|
function json(text: string | undefined): Record<string, unknown> | null {
|
|
67
57
|
if (!text) return null;
|
|
68
58
|
const parse = (body: string) => { try { const value = JSON.parse(body); return record(value) ? value : null; } catch { return null; } };
|
|
@@ -184,14 +174,14 @@ export function followTimelineItem(item: TimelineToolCall, ledger: MomentLedger)
|
|
|
184
174
|
let output: string | undefined;
|
|
185
175
|
if (tool) {
|
|
186
176
|
if (record(detail) && record(detail.input)) input = detail.input;
|
|
187
|
-
output = record(detail) && "output" in detail ?
|
|
177
|
+
output = record(detail) && "output" in detail ? toolResult(detail.output).text : undefined;
|
|
188
178
|
} else if (record(detail) && detail.type === "shell" && typeof detail.command === "string") {
|
|
189
179
|
const call = followShellCall(detail.command);
|
|
190
180
|
if (!call) return undefined;
|
|
191
|
-
tool = call.tool; input = call.input; output =
|
|
181
|
+
tool = call.tool; input = call.input; output = toolResult(detail.output).text || undefined;
|
|
192
182
|
} else return undefined;
|
|
193
183
|
if (TOOL_PRESENTATION[tool] !== "moment" || item.status !== "completed") return undefined;
|
|
194
|
-
if (record(detail) &&
|
|
184
|
+
if (record(detail) && toolResult(detail.output).isError) return undefined;
|
|
195
185
|
const row = toolRow(tool, "completed", input, output);
|
|
196
186
|
if (tool !== "declare_done") return row;
|
|
197
187
|
if (!row.done) return undefined;
|