paseo-recap 0.2.5 → 0.3.0
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 +5 -5
- package/README.md +15 -14
- package/client/format.ts +0 -5
- package/client/pills.tsx +37 -68
- package/client/recap-card.tsx +16 -34
- package/client/recap-line.tsx +1 -1
- package/client/recap-subscription.ts +49 -0
- package/index.client.tsx +1 -1
- package/index.server.ts +60 -28
- package/package.json +4 -4
- package/paseo-plugin.json +1 -1
- package/server/paseo-types.ts +4 -2
- package/server/process.ts +38 -26
- package/server/recap-stream.ts +39 -0
- package/server/scheduler.ts +43 -24
- package/server/store.ts +133 -61
- package/shared/recap.ts +11 -1
package/OVERVIEW.md
CHANGED
|
@@ -4,15 +4,15 @@ Recaps work with every provider Paseo runs, including Claude, Codex, OpenCode, O
|
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
7
|
-
Recaps are written by a command line tool on the host running the Paseo daemon. At least one of `claude`, `codex`, or `opencode` must be on the daemon's `PATH` and logged in. Recaps use that existing login, so they count toward the same plan or API usage.
|
|
7
|
+
Recap requires Paseo 0.16.0 or later. Recaps are written by a command line tool on the host running the Paseo daemon. At least one of `claude`, `codex`, or `opencode` must be on the daemon's `PATH` and logged in. Recaps use that existing login, so they count toward the same plan or API usage.
|
|
8
8
|
|
|
9
9
|
## What you get
|
|
10
10
|
|
|
11
11
|
- **Recap line.** About 40 words after a completed turn, with a **Next** step when one was agreed or asked.
|
|
12
|
-
- **Recap pill.** A pill above the composer
|
|
12
|
+
- **Recap pill.** A pill above the composer shows how old the latest recap is and updates as recaps are generated. Tap it to read the recap, generate one now, regenerate it, or see the previous four. The `/paseo-recap` command generates a recap immediately. Claude agents keep their own `/recap` from Claude Code.
|
|
13
13
|
- **Automatic timing.** The first recap comes after your third message, then one after each completed turn once the agent has been quiet for 10 seconds. Replying sooner skips that turn.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Automatic recaps skip background agents, canceled or failed turns, pending permissions, context compaction, and providers at 90% or more of their usage limit. Visible subagents can be recapped manually from their pill or automatically if you enable **Recap subagents**.
|
|
16
16
|
|
|
17
17
|
## Settings
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@ Open **Settings → Plugins → paseo-recap → Recap**.
|
|
|
21
21
|
- **Generate recaps automatically.** Turns automatic recaps on or off. The pill and `/paseo-recap` always work.
|
|
22
22
|
- **Every N turns**, **Wait after a turn**, and **Start after** control when automatic recaps run.
|
|
23
23
|
- **Recent exchanges to read.** How many of your messages and the replies a recap reads, from 1 to 100. The default is 8.
|
|
24
|
-
- **Recap subagents** and **Wait for subagents.** Recap agents started by other agents, and hold a parent's recap while its subagents run, for up to 10 minutes.
|
|
24
|
+
- **Recap subagents** and **Wait for subagents.** Recap visible agents started by other agents, and hold a parent's recap while its visible subagents run, for up to 10 minutes.
|
|
25
25
|
- **Recap model.** Recaps pick a model the way Paseo's metadata generation does: the models set in Paseo's metadata generation settings, then Paseo's small models that are installed, such as Claude Haiku. By default an agent whose own provider has one of those small models is recapped by it first. You can also choose any Claude, Codex, or OpenCode model by name. The settings page lists the exact models that will run.
|
|
26
26
|
|
|
27
27
|
## Data and permissions
|
|
@@ -32,7 +32,7 @@ With **Same as agent** or **Metadata model**, a model that is unavailable or fai
|
|
|
32
32
|
|
|
33
33
|
Claude runs with no tools, MCP servers, or user settings. Codex runs in a read-only sandbox with your own Codex configuration, which includes any MCP servers you have set up there. OpenCode runs its read-only plan agent. OpenCode 1.x uses `--pure`; 2.x has no equivalent, so OpenCode plugins load. Each run uses a temporary folder. Claude and Codex runs are not saved as sessions. OpenCode always saves one, and the plugin deletes it right after the run; if that deletion fails, the session stays in OpenCode. On OpenCode 2.x, both the run and session deletion use `--standalone` to avoid a persistent background service.
|
|
34
34
|
|
|
35
|
-
Recaps are saved
|
|
35
|
+
Recaps are saved in the agent's Paseo metadata and cleared when it is archived. When Recap starts, it clears recaps for active agents whose latest entry is more than 30 days old. Recap imports old file-based recaps for agents that still exist and keeps the source as `recaps.json.migrated`.
|
|
36
36
|
|
|
37
37
|
## Limits
|
|
38
38
|
|
package/README.md
CHANGED
|
@@ -20,15 +20,14 @@ OpenCode, OMP, Pi, and custom agents.
|
|
|
20
20
|
metadata generation models, then Paseo's small models that are installed, such as Claude Haiku.
|
|
21
21
|
Never the agent's large model. Or choose any Claude, Codex, or OpenCode model; the settings screen
|
|
22
22
|
shows exactly which models will run.
|
|
23
|
-
- **Quiet and cheap.** About 40 words, from recent text only. Skips
|
|
24
|
-
permissions, context compaction, and providers near their usage limit.
|
|
25
|
-
with Claude Haiku.
|
|
23
|
+
- **Quiet and cheap.** About 40 words, from recent text only. Skips background agents, canceled
|
|
24
|
+
turns, pending permissions, context compaction, and providers near their usage limit.
|
|
26
25
|
|
|
27
26
|
<p align="center"><img src="docs/images/recap-card.png" width="420" alt="The Recap card, opened from the pill, with the summary, the next step, and Regenerate"></p>
|
|
28
27
|
|
|
29
28
|
## Requirements
|
|
30
29
|
|
|
31
|
-
- Paseo **0.
|
|
30
|
+
- Paseo **0.16.0** or later, with plugins enabled (**Settings → Plugins → Enable plugins**, or
|
|
32
31
|
`"pluginsEnabled": true` in `~/.paseo/config.json`)
|
|
33
32
|
- At least one of the `claude`, `codex`, or `opencode` CLIs on the daemon's `PATH`, logged in
|
|
34
33
|
|
|
@@ -58,7 +57,7 @@ you type.
|
|
|
58
57
|
| Wait after a turn (seconds) | 10 | Quiet time before a recap; replying sooner skips that turn (0–3600) |
|
|
59
58
|
| Start after (messages) | 3 | Your messages before an agent's first recap, as in Claude Code (1–50) |
|
|
60
59
|
| Recent exchanges to read | 8 | Your messages and the replies a recap reads, within ~8,000 tokens (1–100) |
|
|
61
|
-
| Recap subagents | Off | Also recap agents started by other agents |
|
|
60
|
+
| Recap subagents | Off | Also recap visible agents started by other agents |
|
|
62
61
|
| Wait for subagents | Off | Hold an agent's recap while its subagents run, up to 10 minutes |
|
|
63
62
|
| Recap model | Same as agent | Same as agent, Metadata model, or Claude / Codex / OpenCode with any model id |
|
|
64
63
|
|
|
@@ -68,9 +67,9 @@ you type.
|
|
|
68
67
|
the recent user and assistant text and short error messages (up to 300 characters each), never
|
|
69
68
|
tool output, file contents, or reasoning, and asks a local CLI for a structured
|
|
70
69
|
`{ summary, next_action }` recap.
|
|
71
|
-
2. The recap
|
|
72
|
-
|
|
73
|
-
date.
|
|
70
|
+
2. The latest recap and up to four earlier recaps are saved in the agent's Paseo metadata. The
|
|
71
|
+
plugin appends a row to the conversation and pushes changes to the pill and the card. A new turn
|
|
72
|
+
cancels a pending recap and marks the last one out of date.
|
|
74
73
|
3. CLIs run one-shot in a temporary directory with your existing login. Claude and Codex save no
|
|
75
74
|
session; OpenCode's session is deleted right after the run (logged if that fails).
|
|
76
75
|
At most two run at once; a CLI that is missing, logged out, or rate limited is skipped for ten
|
|
@@ -82,8 +81,8 @@ you type.
|
|
|
82
81
|
| `codex` | `codex exec --ephemeral --sandbox read-only --output-schema … --disable hooks`, low reasoning effort, with your Codex configuration |
|
|
83
82
|
| `opencode` | 1.x: `opencode run --pure --agent plan --format json`; 2.x: `opencode run --standalone --agent plan --format json`; the session is deleted afterwards, also with `--standalone` on 2.x |
|
|
84
83
|
|
|
85
|
-
See [docs/design.md](docs/design.md) for the
|
|
86
|
-
|
|
84
|
+
See [docs/design.md](docs/design.md) for the original design and its comparison with Claude Code,
|
|
85
|
+
Codex, and OMP.
|
|
87
86
|
|
|
88
87
|
## Privacy and security
|
|
89
88
|
|
|
@@ -97,8 +96,10 @@ Code, Codex, and OMP.
|
|
|
97
96
|
`plan` agent, which rejects permission requests. OpenCode 1.x uses `--pure`; 2.x has no equivalent,
|
|
98
97
|
so OpenCode plugins load. On 2.x, both the run and session deletion use `--standalone` to avoid a
|
|
99
98
|
persistent background service.
|
|
100
|
-
-
|
|
101
|
-
|
|
99
|
+
- Archiving an agent clears its saved recap. At startup, Recap clears active agents' recaps whose
|
|
100
|
+
latest entry is more than 30 days old. It imports the previous version's
|
|
101
|
+
`$PASEO_HOME/plugin-data/paseo-recap/recaps.json` for agents that still exist and renames the file
|
|
102
|
+
to `recaps.json.migrated`. Conversation rows live in daemon memory and disappear after a restart.
|
|
102
103
|
- Like every Paseo plugin, this is trusted code that runs unsandboxed on the daemon host.
|
|
103
104
|
|
|
104
105
|
## Development
|
|
@@ -115,14 +116,14 @@ paseo plugin logs paseo-recap
|
|
|
115
116
|
|
|
116
117
|
| Path | Contents |
|
|
117
118
|
|---|---|
|
|
118
|
-
| `index.server.ts` | Daemon entry: lifecycle hooks, RPCs, timeline rows |
|
|
119
|
+
| `index.server.ts` | Daemon entry: lifecycle hooks, RPCs, recap subscription, timeline rows |
|
|
119
120
|
| `index.client.tsx` | App entry: recap line, pill, settings screen, `/paseo-recap` |
|
|
120
121
|
| `server/scheduler.ts` | Per-agent state machine: when to recap |
|
|
121
122
|
| `server/history.ts`, `server/prompt.ts` | What a recap reads and the prompt |
|
|
122
123
|
| `server/models.ts`, `server/generators.ts`, `server/cli.ts`, `server/process.ts` | Which model runs, queue and fallback, per-CLI arguments, process runner |
|
|
123
124
|
| `server/store.ts`, `server/usage.ts` | Recap storage, usage-limit guard |
|
|
124
125
|
| `client/` | Recap line, pill and card, settings screen |
|
|
125
|
-
| `shared/recap.ts` | Providers, settings schema, recap types, RPC contracts |
|
|
126
|
+
| `shared/recap.ts` | Providers, settings schema, recap types, RPC and subscription contracts |
|
|
126
127
|
|
|
127
128
|
## Releasing
|
|
128
129
|
|
package/client/format.ts
CHANGED
|
@@ -30,11 +30,6 @@ export function pillPresentation(view: RecapView | undefined, now: number): Pill
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/** A recap is on its way: worth polling closely so the pill never lingers on stale progress. */
|
|
34
|
-
export function isPending(view: RecapView): boolean {
|
|
35
|
-
return view.state === "waiting" || view.state === "generating";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
33
|
function providerLabel(provider: string): string {
|
|
39
34
|
return isRecapProvider(provider) ? RECAP_PROVIDERS[provider].label : provider;
|
|
40
35
|
}
|
package/client/pills.tsx
CHANGED
|
@@ -5,15 +5,10 @@ import type {
|
|
|
5
5
|
PluginClientContext,
|
|
6
6
|
} from "@getpaseo/plugin/client";
|
|
7
7
|
import { ActivityIndicator } from "react-native";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import type { RecapEvent, RecapView } from "../shared/recap";
|
|
9
|
+
import { pillPresentation, type PillPresentation } from "./format";
|
|
10
10
|
import { makeRecapPopover } from "./recap-card";
|
|
11
|
-
|
|
12
|
-
const TICK_MS = 2_000;
|
|
13
|
-
const IDLE_POLL_MS = 30_000;
|
|
14
|
-
/** After agent activity, poll every tick: a recap lands a few seconds after the idle delay. */
|
|
15
|
-
const ACTIVE_WINDOW_MS = 30_000;
|
|
16
|
-
const UPDATE_DEBOUNCE_MS = 1_000;
|
|
11
|
+
import { subscribeToRecaps } from "./recap-subscription";
|
|
17
12
|
|
|
18
13
|
/** Sized to the icon slot, as Paseo's own pills draw their loading spinner. */
|
|
19
14
|
function SpinnerIcon({ size, color }: PluginButtonIconProps) {
|
|
@@ -32,14 +27,10 @@ function pillButton({
|
|
|
32
27
|
export interface RecapPills {
|
|
33
28
|
start(): void;
|
|
34
29
|
stop(): void;
|
|
35
|
-
refresh(): Promise<void>;
|
|
36
|
-
/** Shows progress on an agent's pill while a manual recap request runs, then its result. */
|
|
37
|
-
track<T>(agentId: string, request: Promise<T>): Promise<T>;
|
|
38
30
|
}
|
|
39
31
|
|
|
40
32
|
/**
|
|
41
|
-
* Keeps
|
|
42
|
-
* without any agent update, so the list is also polled, faster right after agent activity.
|
|
33
|
+
* Keeps composer pills and their popovers in sync over one subscription per host.
|
|
43
34
|
*
|
|
44
35
|
* A factory rather than a class: plugin client bundles reach Hermes (iOS, Android) without Metro's
|
|
45
36
|
* transforms, and Hermes rejects class syntax (getpaseo/paseo#5783).
|
|
@@ -47,47 +38,34 @@ export interface RecapPills {
|
|
|
47
38
|
export function createRecapPills(client: PluginClientContext): RecapPills {
|
|
48
39
|
const pills = new Map<string, PluginButtonRegistration>();
|
|
49
40
|
const lifetime = new AbortController();
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
let
|
|
53
|
-
let refreshing = false;
|
|
54
|
-
let lastRefreshAt = 0;
|
|
55
|
-
let activeUntil = 0;
|
|
41
|
+
const listeners = new Set<() => void>();
|
|
42
|
+
let views: Map<string, RecapView> | undefined;
|
|
43
|
+
let ageTimer: ReturnType<typeof setInterval> | undefined;
|
|
56
44
|
|
|
57
|
-
const render = (): void => {
|
|
58
|
-
|
|
59
|
-
for (const [agentId, pill] of pills) {
|
|
60
|
-
pill.update(pillButton(pillPresentation(views.get(agentId), now)));
|
|
61
|
-
}
|
|
45
|
+
const render = (agentId: string): void => {
|
|
46
|
+
pills.get(agentId)?.update(pillButton(pillPresentation(views?.get(agentId), Date.now())));
|
|
62
47
|
};
|
|
63
48
|
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.error("[paseo-recap] failed to load recaps", error);
|
|
74
|
-
} finally {
|
|
75
|
-
refreshing = false;
|
|
49
|
+
const update = (event: RecapEvent): void => {
|
|
50
|
+
if (event.type === "snapshot") {
|
|
51
|
+
views = new Map(event.recaps.map((view) => [view.agentId, view]));
|
|
52
|
+
for (const agentId of pills.keys()) render(agentId);
|
|
53
|
+
} else {
|
|
54
|
+
const { view } = event;
|
|
55
|
+
if (view.recap || view.state !== "idle" || view.error) views?.set(view.agentId, view);
|
|
56
|
+
else views?.delete(view.agentId);
|
|
57
|
+
render(view.agentId);
|
|
76
58
|
}
|
|
59
|
+
for (const listener of listeners) listener();
|
|
77
60
|
};
|
|
78
61
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
void refresh();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const popover = makeRecapPopover({ cachedView: (agentId) => views.get(agentId), track });
|
|
62
|
+
const popover = makeRecapPopover({
|
|
63
|
+
getView: (agentId) => views ? (views.get(agentId) ?? null) : undefined,
|
|
64
|
+
subscribe(listener) {
|
|
65
|
+
listeners.add(listener);
|
|
66
|
+
return () => { listeners.delete(listener); };
|
|
67
|
+
},
|
|
68
|
+
});
|
|
91
69
|
|
|
92
70
|
const register = (agent: { id: string; workspaceId?: string | null }): void => {
|
|
93
71
|
if (lifetime.signal.aborted || !agent.workspaceId) return;
|
|
@@ -98,7 +76,7 @@ export function createRecapPills(client: PluginClientContext): RecapPills {
|
|
|
98
76
|
agentId: agent.id,
|
|
99
77
|
button: {
|
|
100
78
|
title: "Session recap",
|
|
101
|
-
...pillButton(pillPresentation(views
|
|
79
|
+
...pillButton(pillPresentation(views?.get(agent.id), Date.now())),
|
|
102
80
|
behavior: { kind: "popover", Content: popover },
|
|
103
81
|
},
|
|
104
82
|
});
|
|
@@ -115,50 +93,41 @@ export function createRecapPills(client: PluginClientContext): RecapPills {
|
|
|
115
93
|
pills.clear();
|
|
116
94
|
};
|
|
117
95
|
|
|
118
|
-
const scheduleRefresh = (): void => {
|
|
119
|
-
if (debounce) clearTimeout(debounce);
|
|
120
|
-
debounce = setTimeout(() => {
|
|
121
|
-
debounce = null;
|
|
122
|
-
void refresh();
|
|
123
|
-
}, UPDATE_DEBOUNCE_MS);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
96
|
const start = (): void => {
|
|
97
|
+
subscribeToRecaps(client, update, lifetime.signal);
|
|
127
98
|
client.paseo.agents
|
|
128
99
|
.list({ subscribe: {}, signal: lifetime.signal })
|
|
129
100
|
.then(({ subscription }) => {
|
|
101
|
+
if (lifetime.signal.aborted) return subscription.release();
|
|
130
102
|
subscription.subscribe({
|
|
131
103
|
snapshot: ({ entries }) => {
|
|
132
104
|
removeAll();
|
|
133
105
|
for (const { agent } of entries) register(agent);
|
|
134
|
-
scheduleRefresh();
|
|
135
106
|
},
|
|
136
107
|
update: (message) => {
|
|
137
108
|
if (message.type !== "agent_update") return;
|
|
138
109
|
const update = message.payload;
|
|
139
110
|
if (update.kind === "remove") remove(update.agentId);
|
|
140
111
|
else if (!pills.has(update.agent.id)) register(update.agent);
|
|
141
|
-
activeUntil = Date.now() + ACTIVE_WINDOW_MS;
|
|
142
|
-
scheduleRefresh();
|
|
143
112
|
},
|
|
144
113
|
});
|
|
145
114
|
})
|
|
146
115
|
.catch((error: unknown) => {
|
|
147
116
|
if (!lifetime.signal.aborted) console.error("[paseo-recap] agent observation failed", error);
|
|
148
117
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
118
|
+
// Keep the displayed ages current without requesting data from the daemon.
|
|
119
|
+
ageTimer = setInterval(() => {
|
|
120
|
+
for (const [agentId, view] of views ?? []) {
|
|
121
|
+
if (view.recap) render(agentId);
|
|
122
|
+
}
|
|
123
|
+
}, 60_000);
|
|
154
124
|
};
|
|
155
125
|
|
|
156
126
|
const stop = (): void => {
|
|
157
127
|
lifetime.abort();
|
|
158
|
-
|
|
159
|
-
if (poll) clearInterval(poll);
|
|
128
|
+
clearInterval(ageTimer);
|
|
160
129
|
removeAll();
|
|
161
130
|
};
|
|
162
131
|
|
|
163
|
-
return { start, stop
|
|
132
|
+
return { start, stop };
|
|
164
133
|
}
|
package/client/recap-card.tsx
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type { PluginButtonContentProps, PluginHostProps } from "@getpaseo/plugin/client";
|
|
2
2
|
import { useRpc } from "@getpaseo/plugin/client";
|
|
3
|
-
import { Icon } from "@getpaseo/plugin/client/
|
|
4
|
-
import { useMutation
|
|
5
|
-
import { useMemo, useState, type ReactNode } from "react";
|
|
3
|
+
import { Icon } from "@getpaseo/plugin/client/ui";
|
|
4
|
+
import { useMutation } from "@tanstack/react-query";
|
|
5
|
+
import { useMemo, useState, useSyncExternalStore, type ReactNode } from "react";
|
|
6
6
|
import { ActivityIndicator, Pressable, Text, View } from "react-native";
|
|
7
|
-
import {
|
|
7
|
+
import { recapRegenerateRpc, type RecapView, type StoredRecap } from "../shared/recap";
|
|
8
8
|
import { relativeTime } from "./format";
|
|
9
9
|
|
|
10
|
-
const GENERATING_POLL_MS = 2_000;
|
|
11
|
-
|
|
12
|
-
function recapQueryKey(agentId: string) {
|
|
13
|
-
return ["paseo-recap", "recap", agentId] as const;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
10
|
type Theme = PluginHostProps["theme"];
|
|
17
11
|
|
|
18
12
|
// Sizes follow Paseo's own controls: 15 px content text, 14 px secondary text, 32 px small and
|
|
@@ -95,10 +89,9 @@ function RecapBody({
|
|
|
95
89
|
|
|
96
90
|
/** What the card needs from the pills that open it. */
|
|
97
91
|
export interface RecapPopoverSource {
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
track<T>(agentId: string, request: Promise<T>): Promise<T>;
|
|
92
|
+
/** Undefined while the first snapshot is loading. Null when there is no recap. */
|
|
93
|
+
getView(agentId: string): RecapView | null | undefined;
|
|
94
|
+
subscribe(listener: () => void): () => void;
|
|
102
95
|
}
|
|
103
96
|
|
|
104
97
|
export function makeRecapPopover(source: RecapPopoverSource) {
|
|
@@ -114,34 +107,23 @@ function RecapCard({
|
|
|
114
107
|
agentId,
|
|
115
108
|
source,
|
|
116
109
|
}: PluginButtonContentProps & { agentId: string; source: RecapPopoverSource }) {
|
|
117
|
-
const getRecap = useRpc(recapGetRpc);
|
|
118
110
|
const regenerateRecap = useRpc(recapRegenerateRpc);
|
|
119
|
-
const queryClient = useQueryClient();
|
|
120
111
|
const [showEarlier, setShowEarlier] = useState(false);
|
|
121
112
|
const styles = useRecapStyles(theme);
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// Paseo sizes a popover to its first render; starting from the pill's data avoids opening at
|
|
126
|
-
// the size of a loading spinner and clipping the recap that arrives a moment later.
|
|
127
|
-
initialData: () => source.cachedView(agentId),
|
|
128
|
-
refetchInterval: (current) =>
|
|
129
|
-
current.state.data?.state === "generating" ? GENERATING_POLL_MS : false,
|
|
130
|
-
});
|
|
113
|
+
const getView = () => source.getView(agentId);
|
|
114
|
+
const view = useSyncExternalStore(source.subscribe, getView, getView);
|
|
115
|
+
const loading = view === undefined;
|
|
131
116
|
const regenerate = useMutation({
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (view) queryClient.setQueryData(recapQueryKey(agentId), view);
|
|
136
|
-
else void query.refetch();
|
|
117
|
+
async mutationFn() {
|
|
118
|
+
const result = await regenerateRecap({ agentId });
|
|
119
|
+
if (result.error) throw new Error(result.error);
|
|
137
120
|
},
|
|
138
121
|
});
|
|
139
122
|
|
|
140
|
-
const view = query.data;
|
|
141
123
|
const recap = view?.recap ?? null;
|
|
142
124
|
const previous = view?.previous ?? [];
|
|
143
125
|
const generating = view?.state === "generating" || regenerate.isPending;
|
|
144
|
-
const error =
|
|
126
|
+
const error = view?.error ?? (regenerate.error ? "Could not generate a recap." : null);
|
|
145
127
|
|
|
146
128
|
const generateButton = (
|
|
147
129
|
<Pressable
|
|
@@ -180,7 +162,7 @@ function RecapCard({
|
|
|
180
162
|
|
|
181
163
|
return (
|
|
182
164
|
<View style={{ gap: 12, maxWidth: layout.compact ? undefined : 400 }}>
|
|
183
|
-
{
|
|
165
|
+
{loading ? <ActivityIndicator color={theme.colors.foregroundMuted} /> : null}
|
|
184
166
|
{recap ? (
|
|
185
167
|
// With a recap shown, regenerating is secondary: quiet buttons on the metadata line.
|
|
186
168
|
<RecapBody
|
|
@@ -196,7 +178,7 @@ function RecapCard({
|
|
|
196
178
|
) : (
|
|
197
179
|
// Without one, Generate is the card's main action.
|
|
198
180
|
<>
|
|
199
|
-
{!
|
|
181
|
+
{!loading && !generating ? (
|
|
200
182
|
<Text style={styles.meta}>No recap yet. One appears after this agent's next turn, or generate it now.</Text>
|
|
201
183
|
) : null}
|
|
202
184
|
<View style={styles.row}>{generateButton}</View>
|
package/client/recap-line.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PluginTimelineItemProps } from "@getpaseo/plugin/client";
|
|
2
|
-
import { Icon } from "@getpaseo/plugin/client/
|
|
2
|
+
import { Icon } from "@getpaseo/plugin/client/ui";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { Text, View } from "react-native";
|
|
5
5
|
import type { RecapTimelineData } from "../shared/recap";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PluginClientContext, PluginSubscriptionHandle } from "@getpaseo/plugin/client";
|
|
2
|
+
import { recapSubscription, type RecapEvent } from "../shared/recap";
|
|
3
|
+
|
|
4
|
+
const INITIAL_RETRY_MS = 1_000;
|
|
5
|
+
const MAX_RETRY_MS = 30_000;
|
|
6
|
+
|
|
7
|
+
/** The SDK reconnects its transport; retry a subscription that the server itself has closed. */
|
|
8
|
+
export function subscribeToRecaps(
|
|
9
|
+
client: Pick<PluginClientContext, "subscribe">,
|
|
10
|
+
onEvent: (event: RecapEvent) => void,
|
|
11
|
+
signal: AbortSignal,
|
|
12
|
+
): void {
|
|
13
|
+
let delay = INITIAL_RETRY_MS;
|
|
14
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
15
|
+
let current: PluginSubscriptionHandle | undefined;
|
|
16
|
+
|
|
17
|
+
function open(): void {
|
|
18
|
+
if (signal.aborted) return;
|
|
19
|
+
let closed = false;
|
|
20
|
+
const retry = (error?: unknown) => {
|
|
21
|
+
if (closed || signal.aborted) return;
|
|
22
|
+
closed = true;
|
|
23
|
+
current?.();
|
|
24
|
+
current = undefined;
|
|
25
|
+
if (error) console.error("[paseo-recap] recap subscription closed", error);
|
|
26
|
+
timer = setTimeout(open, delay);
|
|
27
|
+
delay = Math.min(delay * 2, MAX_RETRY_MS);
|
|
28
|
+
};
|
|
29
|
+
try {
|
|
30
|
+
const handle = client.subscribe(recapSubscription, {}, (event) => {
|
|
31
|
+
if (closed || signal.aborted) return;
|
|
32
|
+
delay = INITIAL_RETRY_MS;
|
|
33
|
+
onEvent(event);
|
|
34
|
+
}, { onClosed: ({ error }) => retry(error) });
|
|
35
|
+
if (closed || signal.aborted) handle();
|
|
36
|
+
else current = handle;
|
|
37
|
+
void handle.ready.catch(retry);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
retry(error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (signal.aborted) return;
|
|
44
|
+
signal.addEventListener("abort", () => {
|
|
45
|
+
clearTimeout(timer);
|
|
46
|
+
current?.();
|
|
47
|
+
}, { once: true });
|
|
48
|
+
open();
|
|
49
|
+
}
|
package/index.client.tsx
CHANGED
|
@@ -31,7 +31,7 @@ export default function contribute(client: PluginClientContext) {
|
|
|
31
31
|
context: "agent",
|
|
32
32
|
async onSubmit({ agent, rpc }) {
|
|
33
33
|
// The pill shows progress; the RPC resolves once the recap is written.
|
|
34
|
-
const view = await
|
|
34
|
+
const view = await rpc(recapRegenerateRpc, { agentId: agent.id });
|
|
35
35
|
if (view.error) throw new Error(view.error);
|
|
36
36
|
},
|
|
37
37
|
});
|
package/index.server.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { RecapGenerator } from "./server/generators";
|
|
|
7
7
|
import { describeModelPlan, resolveCandidates, type GeneratorInputs } from "./server/models";
|
|
8
8
|
import type { PaseoApi } from "./server/paseo-types";
|
|
9
9
|
import { runProcess } from "./server/process";
|
|
10
|
+
import { createRecapStream } from "./server/recap-stream";
|
|
10
11
|
import { RecapScheduler } from "./server/scheduler";
|
|
11
12
|
import { RecapStore } from "./server/store";
|
|
12
13
|
import { UsageGuard } from "./server/usage";
|
|
@@ -17,11 +18,14 @@ import {
|
|
|
17
18
|
recapModelPlanRpc,
|
|
18
19
|
recapRegenerateRpc,
|
|
19
20
|
recapSettings,
|
|
21
|
+
recapSubscription,
|
|
20
22
|
type RecapSettings,
|
|
21
23
|
type RecapTimelineData,
|
|
22
24
|
} from "./shared/recap";
|
|
23
25
|
|
|
24
26
|
const TIMELINE_FETCH_LIMIT = 500;
|
|
27
|
+
const INITIAL_LOAD_RETRY_MS = 1_000;
|
|
28
|
+
const MAX_LOAD_RETRY_MS = 30_000;
|
|
25
29
|
|
|
26
30
|
function log(message: string, detail?: unknown): void {
|
|
27
31
|
if (detail === undefined) console.error(`[paseo-recap] ${message}`);
|
|
@@ -35,7 +39,8 @@ function storePath(): string {
|
|
|
35
39
|
|
|
36
40
|
export default function contribute(server: PluginServerContext) {
|
|
37
41
|
const settings = server.registerSettings(recapSettings);
|
|
38
|
-
const store = new RecapStore(storePath(), log);
|
|
42
|
+
const store = new RecapStore(() => requirePaseo().agents, storePath(), log);
|
|
43
|
+
const stream = createRecapStream();
|
|
39
44
|
const tempRoot = join(tmpdir(), "paseo-recap");
|
|
40
45
|
const generator = new RecapGenerator({ runProcess, env: process.env, tempRoot, now: Date.now, log });
|
|
41
46
|
const usage = new UsageGuard(
|
|
@@ -68,6 +73,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
68
73
|
const scheduler = new RecapScheduler({
|
|
69
74
|
store,
|
|
70
75
|
readSettings,
|
|
76
|
+
onChange: stream.update,
|
|
71
77
|
log,
|
|
72
78
|
async generate(prompt, signal, { agentProvider, trigger }) {
|
|
73
79
|
const [inputs, current] = await Promise.all([readGeneratorInputs(requirePaseo()), readSettings()]);
|
|
@@ -108,53 +114,77 @@ export default function contribute(server: PluginServerContext) {
|
|
|
108
114
|
},
|
|
109
115
|
});
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
let ready: Promise<void> | undefined;
|
|
118
|
+
let loadRetry: ReturnType<typeof setTimeout> | undefined;
|
|
119
|
+
let retryDelay = INITIAL_LOAD_RETRY_MS;
|
|
120
|
+
let disposed = false;
|
|
121
|
+
const loadStore = async (): Promise<void> => {
|
|
122
|
+
try {
|
|
123
|
+
const restored = await store.load();
|
|
124
|
+
if (!disposed) {
|
|
125
|
+
for (const agentId of restored) stream.update(scheduler.view(agentId));
|
|
126
|
+
}
|
|
127
|
+
} catch (error) {
|
|
128
|
+
log("could not load saved recaps", errorMessage(error));
|
|
129
|
+
if (disposed) return;
|
|
130
|
+
loadRetry = setTimeout(() => void loadStore(), retryDelay);
|
|
131
|
+
retryDelay = Math.min(retryDelay * 2, MAX_LOAD_RETRY_MS);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const initialize = (api: PaseoApi): Promise<void> => {
|
|
135
|
+
paseo = api;
|
|
136
|
+
// The SDK supplies the connection with the first hook or client request.
|
|
137
|
+
ready ??= (async () => {
|
|
138
|
+
await mkdir(tempRoot, { recursive: true, mode: 0o700 }).catch((error: unknown) => {
|
|
139
|
+
log("could not create recap temp directory", errorMessage(error));
|
|
140
|
+
});
|
|
141
|
+
if (!disposed) await loadStore();
|
|
142
|
+
})();
|
|
143
|
+
return ready;
|
|
144
|
+
};
|
|
115
145
|
|
|
116
146
|
const unsubscribers = [
|
|
117
|
-
server.
|
|
118
|
-
|
|
119
|
-
await ready;
|
|
147
|
+
server.addHook("agent.turn.before", async ({ agent }, { paseo }) => {
|
|
148
|
+
await initialize(paseo);
|
|
120
149
|
scheduler.turnStarted(agent);
|
|
121
150
|
}),
|
|
122
|
-
server.
|
|
123
|
-
|
|
124
|
-
await ready;
|
|
151
|
+
server.addHook("agent.turn.after", async ({ agent, outcome }, { paseo }) => {
|
|
152
|
+
await initialize(paseo);
|
|
125
153
|
await scheduler.turnEnded(agent, outcome);
|
|
126
154
|
}),
|
|
127
|
-
server.
|
|
155
|
+
server.addHook("agent.permission.before", async ({ agent, request }, { paseo }) => {
|
|
156
|
+
await initialize(paseo);
|
|
128
157
|
scheduler.permissionRequested(agent, request.id);
|
|
129
158
|
}),
|
|
130
|
-
server.
|
|
131
|
-
await
|
|
159
|
+
server.addHook("agent.permission.after", async ({ agent, requestId }, { paseo }) => {
|
|
160
|
+
await initialize(paseo);
|
|
132
161
|
await scheduler.permissionResolved(agent, requestId);
|
|
133
162
|
}),
|
|
134
|
-
server.
|
|
135
|
-
await
|
|
163
|
+
server.addHook("agent.archive.after", async ({ agent }, { paseo }) => {
|
|
164
|
+
await initialize(paseo);
|
|
136
165
|
await scheduler.archived(agent);
|
|
137
166
|
}),
|
|
138
167
|
];
|
|
139
168
|
|
|
140
|
-
server.handle(recapGetRpc, async ({ agentId },
|
|
141
|
-
|
|
142
|
-
await ready;
|
|
169
|
+
server.handle(recapGetRpc, async ({ agentId }, { paseo }) => {
|
|
170
|
+
await initialize(paseo);
|
|
143
171
|
return scheduler.view(agentId);
|
|
144
172
|
});
|
|
145
|
-
server.handle(recapListRpc, async (_input,
|
|
146
|
-
|
|
147
|
-
await ready;
|
|
173
|
+
server.handle(recapListRpc, async (_input, { paseo }) => {
|
|
174
|
+
await initialize(paseo);
|
|
148
175
|
return { recaps: scheduler.list() };
|
|
149
176
|
});
|
|
150
|
-
server.handle(
|
|
151
|
-
|
|
152
|
-
|
|
177
|
+
server.handle(recapSubscription, async (_input, { paseo, push, signal }) => {
|
|
178
|
+
await initialize(paseo);
|
|
179
|
+
await stream.subscribe(() => scheduler.list(), push, signal);
|
|
180
|
+
});
|
|
181
|
+
server.handle(recapModelPlanRpc, async ({ generator }, { paseo }) => {
|
|
182
|
+
await initialize(paseo);
|
|
183
|
+
return describeModelPlan(generator, await readGeneratorInputs(paseo));
|
|
153
184
|
});
|
|
154
|
-
server.handle(recapRegenerateRpc, async ({ agentId },
|
|
155
|
-
paseo = context.paseo;
|
|
156
|
-
await ready;
|
|
185
|
+
server.handle(recapRegenerateRpc, async ({ agentId }, { paseo }) => {
|
|
157
186
|
try {
|
|
187
|
+
await initialize(paseo);
|
|
158
188
|
return await scheduler.regenerate(agentId);
|
|
159
189
|
} catch (error) {
|
|
160
190
|
log(`manual recap failed for agent ${agentId}`, errorMessage(error));
|
|
@@ -163,6 +193,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
163
193
|
});
|
|
164
194
|
|
|
165
195
|
return () => {
|
|
196
|
+
disposed = true;
|
|
197
|
+
clearTimeout(loadRetry);
|
|
166
198
|
for (const unsubscribe of unsubscribers) unsubscribe();
|
|
167
199
|
scheduler.dispose();
|
|
168
200
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-recap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Writes a short recap of each agent's goal, progress, and next step after every turn, like Claude Code's session recap.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"test": "vitest run"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@getpaseo/client": "
|
|
23
|
-
"@getpaseo/plugin": "0.
|
|
24
|
-
"@getpaseo/protocol": "
|
|
22
|
+
"@getpaseo/client": "0.17.5",
|
|
23
|
+
"@getpaseo/plugin": "0.17.5",
|
|
24
|
+
"@getpaseo/protocol": "0.17.5",
|
|
25
25
|
"@tanstack/react-query": "^5.90.11",
|
|
26
26
|
"@types/node": "^22.20.5",
|
|
27
27
|
"@types/react": "~19.2.0",
|