paseo-recap 0.2.0 → 0.2.1
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/recap-card.tsx +4 -5
- package/client/settings-screen.tsx +2 -2
- package/index.server.ts +9 -9
- package/package.json +4 -3
- package/paseo-plugin.json +1 -0
- package/server/generators.ts +1 -1
- package/server/history.ts +4 -17
- package/server/scheduler.ts +10 -14
- package/server/store.ts +4 -10
- package/server/usage.ts +4 -2
package/client/recap-card.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import { relativeTime } from "./format";
|
|
|
9
9
|
|
|
10
10
|
const GENERATING_POLL_MS = 2_000;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
function recapQueryKey(agentId: string) {
|
|
13
13
|
return ["paseo-recap", "recap", agentId] as const;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -38,7 +38,6 @@ function useRecapStyles(theme: Theme) {
|
|
|
38
38
|
row: { flexDirection: "row" as const, alignItems: "center" as const, gap: 8 },
|
|
39
39
|
button: { ...button, backgroundColor: theme.colors.surface2 },
|
|
40
40
|
ghostButton: { ...button, minHeight: 28, gap: 6, backgroundColor: "transparent" },
|
|
41
|
-
metaRow: { flexDirection: "row" as const, alignItems: "center" as const, gap: 8 },
|
|
42
41
|
metaText: { flex: 1, color: theme.colors.foregroundMuted, fontSize: 12 },
|
|
43
42
|
// Ghost buttons have no background; outdent them so their labels line up with the card edge.
|
|
44
43
|
actions: { flexDirection: "row" as const, alignItems: "center" as const, marginRight: -button.paddingHorizontal },
|
|
@@ -51,13 +50,13 @@ function useRecapStyles(theme: Theme) {
|
|
|
51
50
|
}, [theme]);
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
function recapAge(recap: StoredRecap, now: number): string {
|
|
55
54
|
const age = relativeTime(recap.generatedAt, now);
|
|
56
55
|
return age === "now" ? "Just now" : `${age} ago`;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
/** Summary, next action, and metadata of one recap. Plain text only: model output is untrusted. */
|
|
60
|
-
|
|
59
|
+
function RecapBody({
|
|
61
60
|
theme,
|
|
62
61
|
recap,
|
|
63
62
|
muted = false,
|
|
@@ -81,7 +80,7 @@ export function RecapBody({
|
|
|
81
80
|
{recap.nextAction}
|
|
82
81
|
</Text>
|
|
83
82
|
) : null}
|
|
84
|
-
<View style={styles.
|
|
83
|
+
<View style={styles.row}>
|
|
85
84
|
<Text style={styles.metaText}>
|
|
86
85
|
{recap.stale && !muted ? "Out of date · " : ""}
|
|
87
86
|
{recapAge(recap, Date.now())}
|
|
@@ -12,13 +12,13 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
12
12
|
import { useEffect, useRef, useState } from "react";
|
|
13
13
|
import { Text } from "react-native";
|
|
14
14
|
import {
|
|
15
|
+
isRecapProvider,
|
|
15
16
|
MODEL_ID_PATTERN,
|
|
17
|
+
RECAP_PROVIDERS,
|
|
16
18
|
recapModelPlanRpc,
|
|
17
19
|
recapSettings,
|
|
18
20
|
SETTING_RANGES,
|
|
19
21
|
type GeneratorChoice,
|
|
20
|
-
isRecapProvider,
|
|
21
|
-
RECAP_PROVIDERS,
|
|
22
22
|
type GeneratorMode,
|
|
23
23
|
type RecapProvider,
|
|
24
24
|
type RecapSettings,
|
package/index.server.ts
CHANGED
|
@@ -2,24 +2,24 @@ import type { PluginServerContext } from "@getpaseo/plugin/server";
|
|
|
2
2
|
import { mkdir } from "node:fs/promises";
|
|
3
3
|
import { homedir, tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { errorMessage, RecapSkippedError } from "./server/errors";
|
|
6
|
+
import { RecapGenerator } from "./server/generators";
|
|
7
|
+
import { describeModelPlan, resolveCandidates, type GeneratorInputs } from "./server/models";
|
|
8
|
+
import type { PaseoApi } from "./server/paseo-types";
|
|
9
|
+
import { runProcess } from "./server/process";
|
|
10
|
+
import { RecapScheduler } from "./server/scheduler";
|
|
11
|
+
import { RecapStore } from "./server/store";
|
|
12
|
+
import { UsageGuard } from "./server/usage";
|
|
5
13
|
import {
|
|
14
|
+
RECAP_TIMELINE_KIND,
|
|
6
15
|
recapGetRpc,
|
|
7
16
|
recapListRpc,
|
|
8
17
|
recapModelPlanRpc,
|
|
9
18
|
recapRegenerateRpc,
|
|
10
|
-
RECAP_TIMELINE_KIND,
|
|
11
19
|
recapSettings,
|
|
12
20
|
type RecapSettings,
|
|
13
21
|
type RecapTimelineData,
|
|
14
22
|
} from "./shared/recap";
|
|
15
|
-
import { errorMessage, RecapSkippedError } from "./server/errors";
|
|
16
|
-
import { RecapGenerator } from "./server/generators";
|
|
17
|
-
import { describeModelPlan, resolveCandidates, type GeneratorInputs } from "./server/models";
|
|
18
|
-
import type { PaseoApi } from "./server/paseo-types";
|
|
19
|
-
import { runProcess } from "./server/process";
|
|
20
|
-
import { RecapScheduler } from "./server/scheduler";
|
|
21
|
-
import { RecapStore } from "./server/store";
|
|
22
|
-
import { UsageGuard } from "./server/usage";
|
|
23
23
|
|
|
24
24
|
const TIMELINE_FETCH_LIMIT = 500;
|
|
25
25
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-recap",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
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": [
|
|
7
7
|
"paseo-plugin.json",
|
|
@@ -43,5 +43,6 @@
|
|
|
43
43
|
"paseo",
|
|
44
44
|
"paseo-plugin",
|
|
45
45
|
"recap"
|
|
46
|
-
]
|
|
46
|
+
],
|
|
47
|
+
"author": "Kingsley (https://github.com/kingsleydon)"
|
|
47
48
|
}
|
package/paseo-plugin.json
CHANGED
package/server/generators.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { GeneratorCandidate } from "./models";
|
|
|
6
6
|
import { sanitizeEnv, type RunProcess } from "./process";
|
|
7
7
|
import { RECAP_JSON_SCHEMA, type ParsedRecap } from "./prompt";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const GENERATE_TIMEOUT_MS = 60_000;
|
|
10
10
|
/** Many agents can finish at once; recaps queue instead of spawning a CLI per agent. */
|
|
11
11
|
export const MAX_CONCURRENT_GENERATIONS = 2;
|
|
12
12
|
const UNAVAILABLE_COOLDOWN_MS = 10 * 60_000;
|
package/server/history.ts
CHANGED
|
@@ -22,26 +22,13 @@ export interface Exchange {
|
|
|
22
22
|
errors: string[];
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
history: string;
|
|
28
|
-
/** Number of user messages in the whole timeline. */
|
|
29
|
-
userTurns: number;
|
|
30
|
-
/** First unfinished item of the latest todo list, if any. */
|
|
31
|
-
activeTask: string | null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function buildRecapInput(
|
|
25
|
+
/** Labeled, budgeted text of the last `maxExchanges` exchanges; empty when there is nothing to recap. */
|
|
26
|
+
export function buildRecapHistory(
|
|
35
27
|
timeline: readonly AgentTimelineItem[],
|
|
36
28
|
maxHistoryBytes: number,
|
|
37
29
|
maxExchanges: number,
|
|
38
|
-
):
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
history: formatHistory(exchanges.slice(-maxExchanges), maxHistoryBytes),
|
|
42
|
-
userTurns: countUserTurns(timeline),
|
|
43
|
-
activeTask: latestActiveTask(timeline),
|
|
44
|
-
};
|
|
30
|
+
): string {
|
|
31
|
+
return formatHistory(collectExchanges(timeline).slice(-maxExchanges), maxHistoryBytes);
|
|
45
32
|
}
|
|
46
33
|
|
|
47
34
|
/**
|
package/server/scheduler.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { PluginHookAgent, PluginTurnOutcome } from "@getpaseo/plugin/server";
|
|
2
2
|
import type { RecapSettings, RecapState, RecapView, StoredRecap } from "../shared/recap";
|
|
3
|
-
import { NoGeneratorError, RecapSkippedError } from "./errors";
|
|
3
|
+
import { errorMessage, NoGeneratorError, RecapSkippedError } from "./errors";
|
|
4
4
|
import type { GeneratedRecap } from "./generators";
|
|
5
|
+
import { buildRecapHistory, countUserTurns, isCompacting, latestActiveTask, trimForRecap } from "./history";
|
|
5
6
|
import type { AgentTimelineItem } from "./paseo-types";
|
|
6
|
-
import { buildRecapInput, countUserTurns, isCompacting, latestActiveTask, trimForRecap } from "./history";
|
|
7
7
|
import { historyBudget, renderPrompt } from "./prompt";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const MAX_CONSECUTIVE_FAILURES = 3;
|
|
10
10
|
export const RETRY_DELAY_MS = 30_000;
|
|
11
11
|
/**
|
|
12
12
|
* A child agent blocks its parent's recap (its work is still landing) only this long; a child
|
|
@@ -16,7 +16,7 @@ export const CHILD_BLOCK_MAX_MS = 10 * 60_000;
|
|
|
16
16
|
|
|
17
17
|
const GENERIC_FAILURE = "Could not generate a recap.";
|
|
18
18
|
const NO_GENERATOR =
|
|
19
|
-
"No recap model is available. Log in to the claude or
|
|
19
|
+
"No recap model is available. Log in to the claude, codex, or opencode CLI, or pick a model in the plugin settings.";
|
|
20
20
|
|
|
21
21
|
export interface AgentContext {
|
|
22
22
|
timeline: readonly AgentTimelineItem[];
|
|
@@ -184,7 +184,7 @@ export class RecapScheduler {
|
|
|
184
184
|
} catch (error) {
|
|
185
185
|
entry.state = "error";
|
|
186
186
|
entry.error = "Could not read the conversation.";
|
|
187
|
-
this.#deps.log(`could not fetch timeline for agent ${agentId}`,
|
|
187
|
+
this.#deps.log(`could not fetch timeline for agent ${agentId}`, errorMessage(error));
|
|
188
188
|
return this.view(agentId);
|
|
189
189
|
}
|
|
190
190
|
entry.timeline = trimForRecap(context.timeline);
|
|
@@ -307,8 +307,8 @@ export class RecapScheduler {
|
|
|
307
307
|
if (abort.signal.aborted || entry.revision !== revision || this.#disposed) return;
|
|
308
308
|
const timeline = entry.timeline ?? [];
|
|
309
309
|
const context = { goal: entry.title, activeTask: latestActiveTask(timeline) };
|
|
310
|
-
const
|
|
311
|
-
if (
|
|
310
|
+
const history = buildRecapHistory(timeline, historyBudget(context), historyExchanges);
|
|
311
|
+
if (history === "") {
|
|
312
312
|
entry.state = "idle";
|
|
313
313
|
entry.error = trigger === "manual" ? "There is no conversation to recap yet." : null;
|
|
314
314
|
return;
|
|
@@ -316,7 +316,7 @@ export class RecapScheduler {
|
|
|
316
316
|
entry.state = "generating";
|
|
317
317
|
entry.error = null;
|
|
318
318
|
try {
|
|
319
|
-
const generated = await this.#deps.generate(renderPrompt(
|
|
319
|
+
const generated = await this.#deps.generate(renderPrompt(history, context), abort.signal, {
|
|
320
320
|
agentProvider: entry.provider,
|
|
321
321
|
trigger,
|
|
322
322
|
});
|
|
@@ -339,7 +339,7 @@ export class RecapScheduler {
|
|
|
339
339
|
entry.turnsSinceRecap = 0;
|
|
340
340
|
entry.state = "idle";
|
|
341
341
|
await this.#deps.publish(recap).catch((error: unknown) => {
|
|
342
|
-
this.#deps.log(`could not show recap for agent ${entry.id}`,
|
|
342
|
+
this.#deps.log(`could not show recap for agent ${entry.id}`, errorMessage(error));
|
|
343
343
|
});
|
|
344
344
|
} catch (error) {
|
|
345
345
|
if (abort.signal.aborted || entry.revision !== revision) return;
|
|
@@ -359,7 +359,7 @@ export class RecapScheduler {
|
|
|
359
359
|
entry.failures++;
|
|
360
360
|
entry.state = "error";
|
|
361
361
|
entry.error = GENERIC_FAILURE;
|
|
362
|
-
this.#deps.log(`recap failed for agent ${entry.id}`,
|
|
362
|
+
this.#deps.log(`recap failed for agent ${entry.id}`, errorMessage(error));
|
|
363
363
|
// Release the in-flight slot first; eligibility rejects agents with work in flight.
|
|
364
364
|
if (entry.inFlight?.abort === abort) entry.inFlight = null;
|
|
365
365
|
if (trigger === "auto" && entry.failures < MAX_CONSECUTIVE_FAILURES) {
|
|
@@ -428,7 +428,3 @@ export class RecapScheduler {
|
|
|
428
428
|
return entry;
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
|
|
432
|
-
function errorText(error: unknown): string {
|
|
433
|
-
return error instanceof Error ? error.message : String(error);
|
|
434
|
-
}
|
package/server/store.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { dirname } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { StoredRecapSchema, type StoredRecap } from "../shared/recap";
|
|
5
|
+
import { errorMessage } from "./errors";
|
|
6
|
+
import { parseJson } from "./json";
|
|
5
7
|
|
|
6
8
|
/** Earlier recaps kept per agent besides the latest (OMP journals every recap; we keep a few). */
|
|
7
9
|
export const PREVIOUS_RECAPS_KEPT = 4;
|
|
@@ -39,7 +41,7 @@ export class RecapStore {
|
|
|
39
41
|
if (isErrno(error, "ENOENT")) return;
|
|
40
42
|
throw error;
|
|
41
43
|
}
|
|
42
|
-
const parsed = StoreFileSchema.safeParse(
|
|
44
|
+
const parsed = StoreFileSchema.safeParse(parseJson(text));
|
|
43
45
|
if (!parsed.success) {
|
|
44
46
|
this.#log("recap store is unreadable; starting empty", this.#path);
|
|
45
47
|
return;
|
|
@@ -99,19 +101,11 @@ export class RecapStore {
|
|
|
99
101
|
};
|
|
100
102
|
this.#writeChain = this.#writeChain.then(write, write);
|
|
101
103
|
return this.#writeChain.catch((error: unknown) => {
|
|
102
|
-
this.#log("failed to persist recaps", error
|
|
104
|
+
this.#log("failed to persist recaps", errorMessage(error));
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
|
|
107
|
-
function safeJson(text: string): unknown {
|
|
108
|
-
try {
|
|
109
|
-
return JSON.parse(text);
|
|
110
|
-
} catch {
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
109
|
function isErrno(error: unknown, code: string): boolean {
|
|
116
110
|
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
117
111
|
}
|
package/server/usage.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { errorMessage } from "./errors";
|
|
2
|
+
|
|
1
3
|
/** Automatic recaps skip a provider once any of its usage windows passes this share. */
|
|
2
|
-
|
|
4
|
+
const USAGE_SKIP_PERCENT = 90;
|
|
3
5
|
const USAGE_CACHE_MS = 5 * 60_000;
|
|
4
6
|
|
|
5
7
|
/** Minimal shape of Paseo's provider usage report (`paseo.providers.listUsage()`). */
|
|
@@ -48,7 +50,7 @@ export class UsageGuard {
|
|
|
48
50
|
this.#pending ??= this.#fetch()
|
|
49
51
|
.then((providers) => providersNearLimit(providers))
|
|
50
52
|
.catch((error: unknown) => {
|
|
51
|
-
this.#log("could not read provider usage", error
|
|
53
|
+
this.#log("could not read provider usage", errorMessage(error));
|
|
52
54
|
return new Set<string>();
|
|
53
55
|
})
|
|
54
56
|
.then((near) => {
|