paseo-follow-up 1.4.0-beta.1 → 1.4.0-beta.10

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.
Files changed (63) hide show
  1. package/OVERVIEW.md +10 -3
  2. package/README.md +33 -2
  3. package/client/agents.tsx +127 -0
  4. package/client/brief.tsx +189 -68
  5. package/client/chat.tsx +12 -4
  6. package/client/display.tsx +22 -4
  7. package/client/home-chrome.tsx +69 -17
  8. package/client/home-list.tsx +20 -10
  9. package/client/home-view.ts +55 -8
  10. package/client/home.tsx +68 -17
  11. package/client/inbox-store.ts +15 -7
  12. package/client/keys.ts +3 -0
  13. package/client/large.tsx +9 -10
  14. package/client/live.tsx +8 -6
  15. package/client/panel.tsx +13 -10
  16. package/client/pill.tsx +10 -6
  17. package/client/pr-controls.tsx +1 -1
  18. package/client/settings.tsx +2 -0
  19. package/client/visibility.ts +7 -0
  20. package/client/workspace-data.ts +37 -0
  21. package/docs/screenshots/decision-card-answered-phone-light.png +0 -0
  22. package/docs/screenshots/decision-card-expanded-chat-light.png +0 -0
  23. package/docs/screenshots/decision-card-partial-phone-dark.png +0 -0
  24. package/docs/screenshots/decision-card-unanswered-phone-dark.png +0 -0
  25. package/index.client.tsx +13 -3
  26. package/index.server.ts +197 -69
  27. package/package.json +5 -3
  28. package/server/about.ts +15 -4
  29. package/server/agent-actions.ts +11 -2
  30. package/server/agent-hook.mjs +78 -13
  31. package/server/agent-mcp.ts +1 -104
  32. package/server/agent-settings.ts +124 -0
  33. package/server/ai-jobs.ts +86 -21
  34. package/server/daemon.ts +133 -101
  35. package/server/directory.ts +165 -0
  36. package/server/etag.ts +14 -0
  37. package/server/hook-source.ts +1 -1
  38. package/server/inbox-directory.ts +14 -19
  39. package/server/inbox.ts +28 -1
  40. package/server/mcp-registrations.ts +113 -0
  41. package/server/mcp-source.ts +1 -1
  42. package/server/mcp.d.mts +14 -0
  43. package/server/mcp.mjs +15 -3
  44. package/server/native-tools.ts +68 -0
  45. package/server/overseer-prompt-source.ts +1 -1
  46. package/server/overseer-prompt.md +1 -0
  47. package/server/overseer.ts +72 -8
  48. package/server/questions.ts +1 -1
  49. package/server/ranker.ts +313 -0
  50. package/server/recovery-config.ts +17 -0
  51. package/server/session-mcp.ts +2 -2
  52. package/server/trust-bypass.ts +104 -0
  53. package/shared/about.ts +6 -3
  54. package/shared/agent-settings.ts +169 -0
  55. package/shared/brief.ts +44 -0
  56. package/shared/chat.ts +8 -3
  57. package/shared/contracts.ts +22 -2
  58. package/shared/display.ts +16 -1
  59. package/shared/home.ts +2 -2
  60. package/shared/overseer.ts +10 -2
  61. package/shared/questions.ts +17 -0
  62. package/shared/ranker.ts +135 -0
  63. package/shared/search.ts +25 -5
package/OVERVIEW.md CHANGED
@@ -5,7 +5,8 @@ Follow-up watches every pull request a Paseo workspace opens until the work is a
5
5
  ## What you see
6
6
 
7
7
  - Home: every workspace grouped by what it needs from you (Needs you, Follow-up is fixing, Running, Waiting on others, Quiet), with the selected one beside the list so you can allow a permission, answer, merge, reply or sign off in place, and a brief with what Follow-up did while you were away. Above the list: the status counts, provider limits from Smart Session when it's installed, a search over names, branches, PRs, agents and asks, and a sort menu (Priority, Recent, Oldest waiting, Name, By project).
8
- - The Overseer (1.4 beta), pinned on Home: one agent you talk to about all your workspaces. It forwards your asks to the agent that owns them, asks you when it isn't sure, and starts a new workspace only when you say so.
8
+ - The Overseer (1.4 beta), pinned on Home: one agent you talk to about all your workspaces. It forwards your asks to the agent that owns them, asks you when it isn't sure, and starts a new workspace only when you say so. You can ask it from Home's search box (the last row, "Ask the Overseer: …") or with ⌘K → Follow-up: Ask the Overseer.
9
+ - AI priority (1.4 beta): Home's Priority sort ranked from your Linear issues, Slack DMs and mentions, GitHub review requests and the weekly plan, each row with a one-line reason that names its source. It runs hourly on workdays, only when something changed, and Re-rank now is in the sort menu.
9
10
  - What's this about?, a collapsible section at the top of Home's detail pane and the workspace panel: a one-line gist, a short AI overview of what the workspace is for and where it stands, and its linked Linear issues, PRs, Slack threads and docs.
10
11
  - A workspace panel for the open workspace only, with a Home button: PRs merged, what needs you, what needs fixing, a bar with one segment per PR, and what the agent is doing now. "Open full" on Home docks it beside the agent's chat.
11
12
  - A Needs you card with one button per decision: Send repairs, Merge, Resume, Retry, or Answer.
@@ -31,7 +32,9 @@ Every root agent Paseo launches (tracked or not) gets Follow-up's action tools:
31
32
 
32
33
  ## Data and access
33
34
 
34
- This is a trusted, unsandboxed plugin. It reads workspace metadata, saved agent history and configuration, GitHub status and existing CLI authentication, and keeps its state in `plugin-data/follow-through` on the daemon host. It registers scoped MCP tools and reversible provider hooks for tracked sessions and, while the Needs-you inbox is on, the `needs_you` tool and its Stop-hook nudge for root agents (see below). To find the spec link it reads completed Claude Artifact publish results in the workspace's root sessions, never page content, chat links or the repository; a link you set wins over the agent's, which wins over detection. Repair prompts go to your configured agent and provider. For the provider meters it calls the Smart Session plugin's `smart-session.subscriptions` and `smart-session.budget` RPCs at most once a minute, or reads the newest rows of its `plugin-data/smart-session/accounts-YYYY-MM.jsonl`; it never asks ZeroSub to refresh or switch. It has no Slack identity and no background channel scanning; replies to stakeholders need your authorization and a sent-message receipt from the agent.
35
+ This is a trusted, unsandboxed plugin. It reads workspace metadata, saved agent history and configuration, GitHub status and existing CLI authentication, and keeps its state in `plugin-data/follow-through` on the daemon host. It attaches scoped agent tools per session (served by Paseo's own MCP as `follow_*` on Paseo 0.15+, a per-launch stdio bridge otherwise; never a global MCP registration, and it removes the user-scope `follow-through` entry older versions wrote, keeping a `.follow-through-unregister.bak` of each file) and reversible provider hooks for tracked sessions and, while the Needs-you inbox is on, the `needs_you` tool and its Stop-hook nudge for root agents (see below). To find the spec link it reads completed Claude Artifact publish results in the workspace's root sessions, never page content, chat links or the repository; a link you set wins over the agent's, which wins over detection. Repair prompts go to your configured agent and provider. For the provider meters it calls the Smart Session plugin's `smart-session.subscriptions` and `smart-session.budget` RPCs at most once a minute, or reads the newest rows of its `plugin-data/smart-session/accounts-YYYY-MM.jsonl`; it never asks ZeroSub to refresh or switch. It has no Slack identity and no background channel scanning; replies to stakeholders need your authorization and a sent-message receipt from the agent.
36
+
37
+ Follow-up reads Paseo's agent, workspace and project lists into one in-memory directory shared by discovery, runtime checks, the Needs-you inbox, the Overseer and every client RPC. It reads the lists once at start, then patches the directory from lifecycle events: turn started or ended, permission requested or resolved, agent created, closed or archived, workspace created or archived. A change marks it dirty, and a dirty directory re-reads at most once a minute; a clean one re-reads every ten minutes. Before anything that would load an agent (a timeline or provider-subagent read), Follow-up re-reads that one agent, because the cached copy may predate Paseo unloading it. Provider subagents are asked about only when a send is due or waiting for acknowledgment, or completion is being checked. The Done label is sent only when it changes. In the app, the panel, the larger view and the pill draw from the client's shared workspace poll, which runs every 15 s plus a refresh shortly after Paseo reports an agent change. The inbox runs the same way and passes the tag of the list it holds, so an unchanged list comes back empty. Display preferences re-read once a minute. None of these poll while the app is hidden.
35
38
 
36
39
  Reviewer lists live in `plugin-data/follow-through/reviewers.json` (owner-only), apart from `state.json`. Each list is per repository, plus a default for repositories without one, and each user keeps their own. Collaborator and team suggestions are read with `gh api` only when you open Add reviewer. They are cached for ten minutes, and never polled.
37
40
 
@@ -40,4 +43,8 @@ The Needs-you inbox (beta) keeps one flag per root agent in `plugin-data/follow-
40
43
  The brief (beta) is stored on the agent's inbox entry and appended to its timeline as a Follow-up row; re-appending replaces that row, and the restart check ignores the `updatedAt` change the append causes because it never reads `updatedAt`. To build a brief Follow-up reads only what it already has: the agent's `needs_you` call, the permission request's title, the failed turn's error message, Session Guard's note and reset time for a paused agent, and its own PR state. It does not read or quote the agent's reply. While the inbox is on, every root Paseo agent on Claude Code or Codex gets Follow-up's MCP bridge with the `needs_you` tool only (tracked main agents keep their full set), and `plugin-data/follow-through/brief.json` records whether the inbox and the nudge are on and which agents have a permission prompt showing. Clicking an option or Retry sends one message as you; it is logged in the delivery ledger as yours, so it clears the flag. The Stop hook, part of the same reversible provider hooks Follow-up already installs, now also runs for those root Claude Code sessions: if the turn ended without `needs_you`, it blocks the stop once with a one-line request to call it, records that it did in `hook-state`, and never blocks the same turn again. It reads `brief.json`, its own per-turn marker and the time of the agent's last `needs_you` call, and nothing else. Turn it off with *Ask agents to state what they need*; turning the inbox off stops it too.
41
44
 
42
45
  The Overseer (beta) is one Claude agent in a Follow-up workspace under `plugin-data/follow-through/overseer-home`, labelled `follow-up.overseer=1` and created only when you click Start. Its id is kept in `plugin-data/follow-through/overseer.json`. Discovery, tracking, auto-send and Needs you skip its workspace. At the start of each of its turns, the provider hook adds a digest from `plugin-data/follow-through/overseer-digest.json` and records what it showed in `hook-state/overseer-seen-<agent>.json`. The worker builds that file from Paseo's workspace list (metadata only, at most once a minute) and Follow-up's own state. It rewrites the file only when the content changes, and skips it while the resource governor pauses background work. Its tools are `workstreams`, `agent_digest`, `route_candidates`, `send_to_agent` and `start_workspace`. For an agent that isn't loaded, `agent_digest` reads the provider's transcript on disk, read-only (Claude Code's `projects/<cwd>/<session>.jsonl`, Codex's `sessions/**/rollout-*-<thread>.jsonl`; only the last 512 KB, and never the credentials in Paseo's agent record). Without a transcript it uses Follow-up's goal and PR titles. It never reads that agent's timeline. `send_to_agent` writes your words to the delivery ledger first: as yours only when they answer that agent's open ask, otherwise as Follow-up's. It wakes a resting agent only because you asked for it. `start_workspace` runs only after your approval, through a dry run and confirm. The Overseer can't merge, archive or post anywhere.
43
- "What's this about?" keeps its overviews in `plugin-data/follow-through/about.json` (gist, overview, linked rows, when and from what; never raw history) and logs each model call's duration and cost to `ai-jobs.jsonl`. To write one it reads the root agent's latest steps from its live timeline only when Paseo already has the agent loaded; otherwise it reads the first and last part of the agent's provider transcript on disk (Claude Code's `~/.claude/projects`, Codex's `~/.codex/sessions`), read-only, and never wakes the agent. It reads subagent titles from Paseo's agent list, PR titles and bodies with `gh pr view`, and only the Linear issues and Slack threads the workspace itself links, through `mcpproxy call tool-read` (`linear:get_issue`, `slack-user:slack_read_thread`); there are no searches. The model is a headless `claude -p` (Haiku) with no tools, no MCP servers, no settings and no saved session, one turn, a 90-second timeout, one call at a time. Overviews are written ahead of time only for non-dormant workspaces in Needs you, at most 60 a day, and not while a Claude account is above 85% of a limit or the resource governor has paused background work; above its higher threshold, opening the section shows the cached overview and writes none.
46
+ "What's this about?" keeps its overviews in `plugin-data/follow-through/about.json` (gist, overview, linked rows, when and from what; never raw history) and logs each model call's duration and cost to `ai-jobs.jsonl`. To write one it reads the root agent's latest steps from its live timeline only when Paseo already has the agent loaded; otherwise it reads the first and last part of the agent's provider transcript on disk (Claude Code's `~/.claude/projects`, Codex's `~/.codex/sessions`), read-only, and never wakes the agent. It reads subagent titles from Paseo's agent list, PR titles and bodies with `gh pr view`, and only the Linear issues and Slack threads the workspace itself links, through `mcpproxy call tool-read` (`linear:get_issue`, `slack-user:slack_read_thread`); there are no searches. The model is set under Settings → Agents (default Haiku). With Claude it runs as a headless `claude -p` with no tools, no MCP servers, no settings and no saved session. With Codex it runs as `codex exec --ephemeral` with no user config or rules, no shell tool and a read-only sandbox in an empty temporary folder. Either way it gets one turn, a 90-second timeout, and runs one call at a time; on timeout the whole process group is killed. Overviews are written ahead of time only for non-dormant workspaces in Needs you, at most 60 a day by default (Settings → Agents), and not while a Claude account is above 85% of a limit or the resource governor has paused background work; above its higher threshold, opening the section shows the cached overview and writes none.
47
+
48
+ Settings → Agents (`plugin-data/follow-through/agents.json`, its own file) chooses the provider, model, effort and mode for What's this about?, the Overseer, recovery agents and the priority ranker. Missing or invalid entries use the defaults. The provider and model list comes from Paseo's provider snapshot. It is read only when that settings screen opens, and cached for ten minutes. A changed Overseer setting is never applied mid-conversation: Home offers a restart, and the new Overseer is handed the old one's last steps (read from its transcript on disk when it isn't loaded). The old agent is left as it is. A recovery agent on a different provider than the main agent keeps the main agent's system prompt, MCP servers and tool policy, and drops its provider-specific model, mode and options. `FOLLOW_UP_OVERSEER_PROVIDER` ("provider/model") overrides the Overseer's setting; it exists only for isolated test daemons.
49
+
50
+ The ranker behind AI priority (beta) runs inside Follow-up's worker as bounded one-shot jobs (Claude or Codex, per the ranker role) through the shared job runner (`server/ai-jobs.ts`), one at a time and only while the resource governor allows background work. It reads Follow-up's own state, `mcpproxy call tool-read` for `linear:list_issues` (assigned to you) and `slack-user:slack_search_public_and_private` (DMs and mentions, last 48 hours), `gh search prs --review-requested=@me`, and the planning artifact through one Claude turn limited to the Artifact tool. It hashes those inputs and calls the model only when they changed. It writes only `plugin-data/follow-through/priorities.json` (its ranking, which replaces its previous one) and `ranker.json` (input hash, run count, source health, the day's plan summary, and Linear issues no workspace covers). It never stores raw artifact HTML or share keys. The provider, model, cadence and daily cap come from the ranker role in Settings → Agents; the plan reader always uses Claude, the only provider with the Artifact tool.
package/README.md CHANGED
@@ -139,6 +139,8 @@ An overview is written when you open the section and none exists, or when the in
139
139
 
140
140
  One agent you talk to about all your workspaces. It sits pinned at the top of Home's list, under the morning brief. Click **Start the Overseer** once, and Follow-up creates it in its own workspace, which is never tracked, never shown under Needs you, and never sent repairs. Its row shows whether it is idle, working, or asking you something. Selecting it opens the conversation in the right pane with a reply box, and **Open full** opens its chat.
141
141
 
142
+ **Ask from anywhere.** Type in Home's search box and the last row is always **Ask the Overseer: <what you typed>**. Arrow down to it and press Enter (or tap it), and it goes to the Overseer as you wrote it. The search clears and its conversation opens. If no workspace matches, it is the only row, so Enter sends it straight away; a single word that matches nothing waits for ↓ or a tap, so a typo never reaches an agent. The first ask starts the Overseer, so you don't have to click Start first. While the Overseer is on, ⌘K → **Follow-up: Ask the Overseer** opens it from any screen with the reply box focused. Both work on the phone too.
143
+
142
144
  - **It routes your asks; it doesn't do the work.** "Tell the HER-1312 agent to use option A" goes to the agent that owns HER-1312, and the Overseer answers in one line: "Sent to Okta SCIM sync (key HER-1312)". It scores candidates by Linear key, PR number, branch, workspace name, open asks and recent activity. When no candidate stands out, it asks you with a decision (the top two or three plus **New workspace**) instead of guessing.
143
145
  - **What it forwards keeps your voice.** A forwarded message starts "From Tom via Overseer:". It clears that agent's Needs-you flag only when it answers the agent's open ask. A new task leaves the ask standing.
144
146
  - **New workspaces only on your word.** It starts one, branched off main and named from the task, only after you asked or picked **New workspace**, and only through a dry run and confirm.
@@ -146,14 +148,42 @@ One agent you talk to about all your workspaces. It sits pinned at the top of Ho
146
148
  - **It is cheap to keep.** Each turn begins with a digest of what changed since the last one, built from Paseo's workspace metadata and Follow-up's own state. That's about 800 tokens at 100 workspaces, with resting workspaces in one line. The digest file is rewritten only when its content changes, and not at all while the resource governor pauses background work. The Overseer never reads the timeline of an agent that isn't loaded, because that would load the agent for an hour. Instead it reads the agent's transcript from disk, or Follow-up's cached goal and PRs. Sending to a resting agent wakes it, so that happens only when you ask for it, and the reply says "woke …".
147
149
  - **Archived it by accident?** Follow-up starts a new one with a handoff from the old one's last steps.
148
150
 
149
- Turn it off under Settings → **Overseer (beta)**.
151
+ Turn it off under Settings → **Overseer (beta)**. While it's off, search has no ask row.
152
+
153
+ #### AI priority (1.4 beta)
154
+
155
+ Home's **Priority** sort can come from a ranker that reads what's happening outside Paseo: your assigned Linear issues (priority, due date, project and milestone), Slack DMs and mentions from the last 48 hours, open GitHub review requests, and the CPO's weekly planning artifact. Each row then shows a one-line reason that names its source, such as "HER-1312 · Urgent · due today" or "Slack: Dana asked twice". Needs you still comes first, whatever the score.
156
+
157
+ - **When it runs:** about once an hour, Sunday to Thursday from 08:00 to 20:00 Israel time. **Re-rank now** in the sort menu runs it at any time, and so does asking the Overseer what to work on first. The menu says when it last ranked and names any source it couldn't read ("Ranked 12m ago · Slack unavailable").
158
+ - **What it costs:** it calls the model only when its inputs changed since the last run, and at most 24 times a day (Re-rank now isn't capped). A run at about 100 workspaces is one Sonnet call of roughly 10k input tokens, about $0.06 and 20 s. The weekly plan is read at most once a day, for about $0.03. Each run's cost and duration go to `ai-jobs.jsonl`.
159
+ - **What it touches:** everything is read-only: Follow-up's own state, read-only Linear and Slack tools through mcpproxy, `gh search prs`, and one read of the planning artifact with Claude's Artifact tool and no other tools. It never posts, comments or publishes. The artifact's link comes from `FOLLOW_UP_PLAN_URL`, or else from the morning-brief skill's source list (link only, without any share key).
160
+ - Linear issues assigned to you that no workspace covers are kept for a later "Not started" group; they aren't shown yet.
161
+
162
+ Turn it off under Settings → **Overseer (beta)** → **AI priority**.
163
+
164
+ ![Home sorted by Priority: each row shows the ranker's reason and source, such as "HER-1312 · Urgent · due today" from Linear and "Slack: Dana asked twice" from Slack](docs/media/overseer/priority-dark.png)
165
+
166
+ ![Home's search with "scim" typed: the matching workspace, then the active row "Ask the Overseer: scim" with an Enter hint](docs/media/overseer/omnibox-ask-dark.png)
167
+
168
+ ### Choosing models
169
+
170
+ Settings → **Agents** has one card for each agent Follow-up runs for you. Each card says what the agent does and what it uses now ("Claude · Haiku"). It lets you pick the provider, model, effort and, for full agents, the permission mode, and each card has **Reset to default**. The list comes from the providers and models Paseo knows about, read when you open the screen. Providers that aren't installed or are turned off are listed with the reason.
171
+
172
+ | Agent | Default | Notes |
173
+ |---|---|---|
174
+ | What's this about? | Claude · Haiku | One small call per overview, no tools. Claude (`claude -p`) or Codex (`codex exec`). Also sets how many overviews are written ahead per day (60). |
175
+ | Overseer | Claude · newest Opus, Bypass | A change applies when you restart it. Its pane on Home offers **Restart with …**, and the new Overseer gets the old one's last steps. |
176
+ | Recovery | Same as main agent | Or pick a provider and model. Switching provider keeps the main agent's tools and instructions. |
177
+ | Priority ranker | Claude · Sonnet, hourly, up to 24 a day | One call per run, no tools. Claude or Codex. |
178
+
179
+ The choices live in `agents.json` in Follow-up's data folder. Anything missing or invalid there falls back to the default. Agents can read the choices with the read-only `agent_settings` tool. The About footer names the model that wrote each overview ("Summarized by Haiku · 2h ago").
150
180
 
151
181
  ![Home with the Overseer selected: the pinned row asks which agent should take a broken export, and the pane shows the conversation, the routed task and the decision with two candidates plus New workspace](docs/media/overseer/overseer-dark.png)
152
182
 
153
183
  Install the beta:
154
184
 
155
185
  ```sh
156
- paseo plugin update follow-through --version 1.4.0-beta.1
186
+ paseo plugin update follow-through --version 1.4.0-beta.10
157
187
  # or, for a fresh install:
158
188
  paseo plugin install npm:paseo-follow-up@beta
159
189
  ```
@@ -173,6 +203,7 @@ Betas publish to npm's `beta` dist-tag, so `paseo plugin update` without `--vers
173
203
  - Follow-up never merges, turns on merge when ready, requests reviewers or archives on its own. **Merge** re-checks the stack, lists any PRs underneath that would merge first, and asks again.
174
204
  - A merged PR is not the end: tasks such as production checks and open questions keep the workspace open until the main agent declares Done and everything has settled.
175
205
  - Answers go out only when you click Send. Follow-up never answers for you.
206
+ - **It stays light on Paseo (1.4).** Follow-up keeps one shared view of Paseo's agents and workspaces. It reads the full list once at start, then updates it from Paseo's events: turns, permissions, archives and new agents or workspaces. It re-reads the list at most once a minute after a change, and every ten minutes otherwise. Home, the workspace panel, the pills and the Needs-you inbox all read that shared view, so opening them never makes Paseo list your workspaces again. In the app, the panel and pills draw from one shared poll that refreshes when an agent changes. The Needs-you list answers "unchanged" in a few bytes when nothing moved, and nothing polls while the app is in the background. At 120 workspaces and idle, Follow-up's worker makes about 1 request a minute to Paseo, down from about 60. With the app open it was about 140.
176
207
 
177
208
  ### Agents can do what you can click
178
209
 
@@ -0,0 +1,127 @@
1
+ import { ActivityIndicator, Text, View } from "react-native";
2
+ import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
3
+ import { useRpc } from "@getpaseo/plugin/client";
4
+ import { SettingsAction, SettingsCard, SettingsSection, SettingsSelect, useToast } from "@getpaseo/plugin/client/ui";
5
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
6
+ import { agentSettingsRpc, setAgentSettingRpc } from "../shared/contracts";
7
+ import { AGENT_ROLES, JOB_PROVIDERS, ROLE_DEFAULTS, ROLE_INFO, isJobRole, modelName, providerName, type AgentRole, type AgentSettingsView, type CatalogProvider, type SavedRole } from "../shared/agent-settings";
8
+ import { Button, errorText, text, type Theme } from "./kit";
9
+
10
+ const key = ["follow-through", "agent-settings"];
11
+ const SAME = "__same";
12
+ const DEFAULT = "__default";
13
+ /** Each provider's "don't ask" mode, used when a Paseo agent role moves to it. */
14
+ const BYPASS: Record<string, string> = { claude: "bypassPermissions", codex: "full-access" };
15
+
16
+ type Role = AgentSettingsView["roles"][number];
17
+
18
+ /**
19
+ * Settings → Agents: one card per special role. What it does and what it uses now, then provider, model, effort,
20
+ * mode and limits. The provider catalog is read once when this screen opens (cached on the server), never polled.
21
+ */
22
+ export function AgentSettings({ theme, compact }: Pick<PluginSurfaceProps, "theme"> & { compact: boolean }) {
23
+ const c = theme.colors; const t = text(c);
24
+ const read = useRpc(agentSettingsRpc); const write = useRpc(setAgentSettingRpc); const cache = useQueryClient(); const toast = useToast();
25
+ const query = useQuery({ queryKey: key, queryFn: () => read({ catalog: true }), staleTime: 5 * 60_000,
26
+ // Only while Paseo is still discovering providers (right after it starts): ask again until they settle.
27
+ refetchInterval: q => (q.state.data as AgentSettingsView | undefined)?.catalog?.providers.some(p => p.reason === "Still loading") && q.state.dataUpdateCount < 10 ? 5000 : false });
28
+ const change = useMutation({
29
+ mutationFn: (input: { role: AgentRole; entry: SavedRole | null }) => write(input),
30
+ onSuccess: (value, input) => {
31
+ cache.setQueryData(key, value);
32
+ void cache.invalidateQueries({ queryKey: ["follow-through", "about"] });
33
+ const r = value.roles.find(x => x.role === input.role);
34
+ if (r) toast.show(input.role === "overseer" ? `Overseer: ${r.summary}. Restart it from Home to switch.` : `${ROLE_INFO[input.role].title}: ${r.summary}`, { variant: "success" });
35
+ },
36
+ onError: error => toast.error(errorText(error)),
37
+ });
38
+ const data = query.data;
39
+ const info = "Which agent Follow-up uses for each of its own jobs. Defaults: Claude Haiku for overviews, Claude Opus for the Overseer, the main agent's own setup for recovery, Claude Sonnet for priority ranking. What's this about? and the ranker are one-shot jobs, so they run on Claude or Codex only; the Overseer and recovery can use any provider Paseo has. Changes apply from the next call; the Overseer switches when you restart it.";
40
+ return <SettingsSection title="Agents" info={info}>
41
+ {query.isPending && <ActivityIndicator accessibilityLabel="Loading agent settings" color={c.foregroundMuted} style={{ alignSelf: "flex-start", marginVertical: 8 }} />}
42
+ {query.error && <SettingsCard><SettingsAction label="Couldn't load agent settings" hint={errorText(query.error)} actionLabel="Retry" onPress={() => void query.refetch()} /></SettingsCard>}
43
+ {data?.catalog?.error && <SettingsCard><SettingsAction label="Couldn't read Paseo's providers" hint={`${data.catalog.error} The current choices still work; pickers show only what's saved.`} actionLabel="Retry" onPress={() => void read({ catalog: true, fresh: true }).then(v => cache.setQueryData(key, v), e => toast.error(errorText(e)))} /></SettingsCard>}
44
+ {/* Once for the section, not per card: what can't be picked and why. */}
45
+ {!!data?.catalog?.providers.some(p => !p.available) && <Text style={[t.meta, { paddingHorizontal: 4 }]}>{`Not available in Paseo: ${data.catalog.providers.filter(p => !p.available).map(p => `${p.label} (${(p.reason ?? "unavailable").replace(/\.$/, "")})`).join(", ")}.`}</Text>}
46
+ {data && AGENT_ROLES.map(role => {
47
+ const r = data.roles.find(x => x.role === role);
48
+ return r ? <RoleCard key={role} r={r} invalid={data.invalid.includes(role)} catalog={data.catalog?.providers ?? []} busy={change.isPending}
49
+ save={entry => change.mutate({ role, entry })} theme={theme} compact={compact} /> : null;
50
+ })}
51
+ </SettingsSection>;
52
+ }
53
+
54
+ function RoleCard({ r, invalid, catalog, busy, save, theme, compact }: { r: Role; invalid: boolean; catalog: CatalogProvider[]; busy: boolean; save: (entry: SavedRole | null) => void; theme: Theme; compact: boolean }) {
55
+ const c = theme.colors; const t = text(c);
56
+ const role = r.role;
57
+ const jobs = isJobRole(role);
58
+ const usable = catalog.filter(p => p.available && (!jobs || (JOB_PROVIDERS as readonly string[]).includes(p.id)));
59
+ const current = catalog.find(p => p.id === r.provider);
60
+ const base: SavedRole = { provider: r.provider, model: r.model, thinking: r.thinking, ...(jobs ? {} : { mode: r.mode }), ...(role === "recovery" ? { same: r.same } : {}),
61
+ ...(jobs ? { dailyCap: r.dailyCap ?? undefined, maxPromptChars: r.maxPromptChars ?? undefined } : {}), ...(role === "ranker" ? { cadenceMinutes: r.cadenceMinutes ?? undefined } : {}) };
62
+ const set = (patch: SavedRole) => save({ ...base, ...patch });
63
+ const providerLabel = providerName(r.provider, current?.label);
64
+ // Saved on a provider Paseo can't use right now: say so plainly, with what happens and the way out.
65
+ const blocked = !r.same && catalog.length > 0 && !usable.some(p => p.id === r.provider);
66
+ const blockedReason = !current ? "not in Paseo's provider list" : !current.available ? (current.reason ?? "unavailable").replace(/\.$/, "") : "can't run one-shot jobs";
67
+
68
+ const providerOptions = [
69
+ ...(role === "recovery" ? [{ value: SAME, label: "Same as main agent" }] : []),
70
+ ...usable.map(p => ({ value: p.id, label: p.label })),
71
+ ...(!r.same && !usable.some(p => p.id === r.provider) ? [{ value: r.provider, label: `${providerLabel} · unavailable` }] : []),
72
+ ];
73
+ const pickProvider = (value: string) => {
74
+ if (value === SAME) return set({ same: true });
75
+ const p = catalog.find(x => x.id === value);
76
+ const defaults = ROLE_DEFAULTS[role];
77
+ const same = value === defaults.provider;
78
+ set({ same: false, provider: value, model: same ? defaults.model : null, thinking: null, ...(jobs ? {} : { mode: same ? defaults.mode : BYPASS[value] ?? p?.defaultMode ?? null }) });
79
+ };
80
+
81
+ const models = current?.models ?? [];
82
+ const model = r.model ? models.find(m => m.id === r.model) : null;
83
+ const providerDefault = models.find(m => m.isDefault);
84
+ const defaultModel = role === "overseer" && r.provider === "claude" ? "Default (newest Opus)" : providerDefault ? `Default (${providerDefault.label})` : "Default";
85
+ const modelOptions = [{ value: DEFAULT, label: defaultModel }, ...models.map(m => ({ value: m.id, label: m.label })),
86
+ ...(r.model && !model ? [{ value: r.model, label: modelName(r.model) }] : [])];
87
+ const thinking = (model ?? providerDefault)?.thinking ?? [];
88
+ const thinkingDefault = thinking.find(o => o.isDefault);
89
+ const modes = current?.modes ?? [];
90
+ const modeDefault = modes.find(m => m.id === current?.defaultMode);
91
+ const modeLabel = (m: { id: string; label: string }) => BYPASS[r.provider] === m.id ? `${m.label} · no prompts` : m.label;
92
+
93
+ const reset = <Button theme={theme} compact={compact} kind="ghost" icon="RotateCcw" title="Reset to default" accessibilityHint={`Back to ${roleDefaultText(role)}`} disabled={busy || (r.isDefault && !invalid)} onPress={() => save(null)} />;
94
+ return <SettingsCard>
95
+ <View style={{ paddingHorizontal: 16, paddingTop: 14, paddingBottom: 10, gap: 2 }}>
96
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
97
+ <Text accessibilityRole="header" style={[t.title, { flex: 1 }]}>{ROLE_INFO[role].title}</Text>
98
+ {!compact && reset}
99
+ </View>
100
+ <Text style={t.meta}>{ROLE_INFO[role].does}{role === "overseer" ? " A running Overseer keeps its model until you restart it from Home." : ""}</Text>
101
+ {invalid && <Text style={t.meta}>Part of the saved setting wasn't valid, so its default is used.</Text>}
102
+ {blocked && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusWarning }]}>{`${providerLabel} isn't available (${blockedReason}). ${role === "about" ? "Overviews will fail" : role === "ranker" ? "Ranking will fail" : role === "overseer" ? "Starting or restarting the Overseer will fail" : "Recovery agents won't start"} until you pick another provider or reset.`}</Text>}
103
+ </View>
104
+ <SettingsSelect label="Provider" value={r.same ? SAME : r.provider} options={providerOptions} disabled={busy || !catalog.length} onValueChange={pickProvider} />
105
+ {!r.same && <SettingsSelect label="Model" value={r.model ?? DEFAULT} options={modelOptions} disabled={busy || !catalog.length}
106
+ onValueChange={value => set({ model: value === DEFAULT ? null : value, thinking: null })} />}
107
+ {!r.same && (thinking.length > 0 || !!r.thinking) && <SettingsSelect label="Effort" hint={!thinking.length && !blocked && model ? "This model lists no effort levels in Paseo; the saved one is still passed on." : undefined} value={r.thinking ?? DEFAULT}
108
+ options={[{ value: DEFAULT, label: thinkingDefault ? `Default (${thinkingDefault.label})` : "Default" }, ...thinking.map(o => ({ value: o.id, label: o.label })), ...(r.thinking && !thinking.some(o => o.id === r.thinking) ? [{ value: r.thinking, label: r.thinking }] : [])]} disabled={busy}
109
+ onValueChange={value => set({ thinking: value === DEFAULT ? null : value })} />}
110
+ {!jobs && !r.same && modes.length > 0 && <SettingsSelect label="Permissions" hint="It runs unattended, so pick a mode that doesn't prompt." value={r.mode ?? DEFAULT}
111
+ options={[{ value: DEFAULT, label: modeDefault ? `Default (${modeLabel(modeDefault)})` : "Default" }, ...modes.map(m => ({ value: m.id, label: modeLabel(m) }))]} disabled={busy}
112
+ onValueChange={value => set({ mode: value === DEFAULT ? null : value })} />}
113
+ {role === "about" && <SettingsSelect label="Written ahead per day" hint="Overviews written in the background for workspaces in Needs you. Opening a workspace always writes one when needed."
114
+ value={String(r.dailyCap ?? 60)} options={withCurrent([0, 20, 60, 120, 200], r.dailyCap ?? 60).map(n => ({ value: String(n), label: n === 0 ? "None" : String(n) }))} disabled={busy}
115
+ onValueChange={value => set({ dailyCap: Number(value) })} />}
116
+ {role === "ranker" && <SettingsSelect label="Ranks every" value={String(r.cadenceMinutes ?? 60)} disabled={busy}
117
+ options={withCurrent([15, 30, 60, 120, 240], r.cadenceMinutes ?? 60).map(n => ({ value: String(n), label: n < 60 ? `${n} minutes` : n === 60 ? "Hour" : `${n / 60} hours` }))}
118
+ onValueChange={value => set({ cadenceMinutes: Number(value) })} />}
119
+ {role === "ranker" && <SettingsSelect label="At most per day" value={String(r.dailyCap ?? 24)} disabled={busy}
120
+ options={withCurrent([6, 12, 24, 48, 96], r.dailyCap ?? 24).map(n => ({ value: String(n), label: String(n) }))}
121
+ onValueChange={value => set({ dailyCap: Number(value) })} />}
122
+ {compact && <View style={{ flexDirection: "row", paddingHorizontal: 8, paddingVertical: 6 }}>{reset}</View>}
123
+ </SettingsCard>;
124
+ }
125
+
126
+ const roleDefaultText = (role: AgentRole) => role === "recovery" ? "the main agent's setup" : role === "overseer" ? "Claude, newest Opus" : role === "about" ? "Claude Haiku" : "Claude Sonnet, hourly";
127
+ const withCurrent = (list: number[], value: number) => [...new Set([...list, value])].sort((a, b) => a - b);