paseo-follow-up 2.5.0 → 2.6.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +1 -1
- package/README.md +0 -1
- package/client/brief-since.tsx +4 -3
- package/client/catch-up.tsx +56 -15
- package/client/header.tsx +5 -3
- package/client/home-data.ts +3 -1
- package/client/home-list.tsx +19 -11
- package/client/home-view.ts +8 -1
- package/client/home.tsx +29 -10
- package/client/keys.ts +2 -0
- package/client/kit.tsx +5 -2
- package/client/large.tsx +5 -3
- package/client/live.tsx +4 -3
- package/client/merge-button.tsx +3 -2
- package/client/messages.tsx +5 -1
- package/client/more-context.tsx +17 -4
- package/client/morning-brief-settings.tsx +5 -4
- package/client/needs-you.tsx +5 -4
- package/client/new-settings.tsx +8 -7
- package/client/now-lines.tsx +60 -0
- package/client/onboarding.tsx +55 -123
- package/client/paged-list.tsx +115 -0
- package/client/panel.tsx +24 -8
- package/client/pr-stats-settings.tsx +3 -2
- package/client/pr-stats.tsx +10 -10
- package/client/questions.tsx +63 -40
- package/client/release-notes.tsx +10 -9
- package/client/reviewers.tsx +8 -3
- package/client/row-open.ts +28 -0
- package/client/section-search.tsx +5 -3
- package/client/settings.tsx +11 -8
- package/client/setup-dialog.tsx +168 -0
- package/client/setup-gate.tsx +69 -0
- package/client/setup-ui.ts +27 -0
- package/client/shipping.tsx +5 -4
- package/client/stacks.tsx +11 -3
- package/client/tasks.tsx +5 -1
- package/client/your-questions.tsx +375 -0
- package/index.client.tsx +11 -3
- package/index.server.ts +162 -32
- package/package.json +1 -1
- package/server/agent-actions.ts +23 -14
- package/server/agent-hook.mjs +7 -5
- package/server/agent-parity.ts +21 -6
- package/server/ai-jobs.ts +26 -5
- package/server/brief-timeline.ts +47 -0
- package/server/context-requests.ts +90 -21
- package/server/directory.ts +6 -0
- package/server/discovery.ts +2 -0
- package/server/engine.ts +3 -0
- package/server/hook-source.ts +7 -5
- package/server/inbox-classifier.ts +17 -0
- package/server/inbox.ts +9 -3
- package/server/job-agent.ts +13 -2
- package/server/mcp-source.ts +23 -15
- package/server/mcp.mjs +23 -15
- package/server/obligations.ts +4 -1
- package/server/session-prompt.ts +30 -3
- package/server/turn-end.ts +133 -0
- package/server/wait-jobs.ts +18 -2
- package/server/wait.ts +17 -12
- package/shared/activity.ts +2 -1
- package/shared/agent-settings.ts +9 -8
- package/shared/catch-up.ts +65 -20
- package/shared/chat.ts +2 -2
- package/shared/compass.ts +5 -4
- package/shared/contracts.ts +52 -8
- package/shared/history.ts +160 -0
- package/shared/home-keys.ts +1 -0
- package/shared/home.ts +54 -8
- package/shared/job-rows.ts +2 -2
- package/shared/list.ts +4 -1
- package/shared/message-sender.ts +2 -0
- package/shared/model.ts +8 -0
- package/shared/new-name.ts +4 -1
- package/shared/now.ts +228 -0
- package/shared/onboarding.ts +17 -13
- package/shared/paged.ts +96 -0
- package/shared/provider-support.ts +83 -34
- package/shared/recommend.ts +1 -1
- package/shared/settings-nav.ts +3 -1
- package/shared/setup-popup.ts +28 -0
- package/shared/sort.ts +8 -1
- package/shared/status.ts +3 -1
- package/shared/wait.ts +2 -2
- package/shared/your-questions.ts +133 -0
- package/skills/follow-up/SKILL.md +1 -1
package/server/agent-parity.ts
CHANGED
|
@@ -13,6 +13,8 @@ import { linearQueueInputSchema } from "../shared/contracts";
|
|
|
13
13
|
import { briefPlanInputSchema, compassSetSchema, planChangeSchema, queueChangeSchema } from "../shared/morning-brief";
|
|
14
14
|
import { sourcesChangeSchema } from "../shared/brief-sources";
|
|
15
15
|
import { noteActionBase } from "../shared/compass";
|
|
16
|
+
import { boundDone, newestFirst, pageInput } from "../shared/paged";
|
|
17
|
+
import { compareVersions } from "../shared/version";
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Agent parity, part 2 (1.4.0-beta.21): tools that are a developer RPC one-to-one. A read runs the RPC's handler; a
|
|
@@ -37,6 +39,8 @@ export type RpcTool = {
|
|
|
37
39
|
/** A read RPC whose answer the dry run shows as `before`. */
|
|
38
40
|
before?: { rpc: string; input?: (args: Record<string, any>) => unknown };
|
|
39
41
|
guard?: (args: Record<string, any>, caller: string) => string | null;
|
|
42
|
+
/** A read's answer as the agent gets it, from the RPC's answer and the tool's arguments (bounding a list that grows). */
|
|
43
|
+
view?: (out: any, args: Record<string, any>) => unknown;
|
|
40
44
|
};
|
|
41
45
|
|
|
42
46
|
const id = z.string().trim().min(1).max(200);
|
|
@@ -86,15 +90,21 @@ export const RPC_TOOLS: readonly RpcTool[] = [
|
|
|
86
90
|
{ name: "overseer_start", rpc: "follow.overseer-start", kind: "planned", before: { rpc: "follow.overseer-status" }, input: z.strictObject({ ...confirm }) },
|
|
87
91
|
{ name: "overseer_restart", rpc: "follow.overseer-restart", kind: "planned", before: { rpc: "follow.overseer-status" }, input: z.strictObject({ ...confirm }) },
|
|
88
92
|
{ name: "overseer_ask", rpc: "follow.overseer-ask", kind: "planned", input: z.strictObject({ text: z.string().trim().min(1).max(2000).optional(), images: imagePaths, ...confirm }) },
|
|
89
|
-
// Catch up
|
|
93
|
+
// Catch up's deck; Your questions and More context (ask, read, act); the asked agent answers with context_reply
|
|
90
94
|
{ name: "catch_up_deck", rpc: "follow.catch-up-deck", kind: "read", input: none },
|
|
91
|
-
|
|
95
|
+
// Questions still asking in full; settled ones (answers up to 4000 characters, read or not) as the newest few and a count:
|
|
96
|
+
// 30 days of unread answers would run past TOOL_BUDGET. state=open narrows to the unread ones, and offset/limit pages them.
|
|
97
|
+
{ name: "context_requests", rpc: "follow.context-list", kind: "read", input: z.strictObject({ workspaceId: id.optional(), state: z.enum(["all", "open", "tasks"]).optional(), query: z.string().max(200).optional(), ...pageInput }), toRpc: ({ offset: _o, limit: _l, ...a }) => a,
|
|
98
|
+
view: (out: { requests: { state: string; askedAt: string; settledAt: string | null}[] }, a) => { const b = boundDone(out.requests, r => r.state !== "asking", { newestFirst: newestFirst(out.requests, r => Date.parse(r.settledAt ?? r.askedAt) || 0), hint: "context_requests offset/limit pages these (newest first)", offset: a.offset, limit: a.limit }); return { requests: b.items, settled: b.done }; } },
|
|
92
99
|
{ name: "ask_context", rpc: "follow.context-ask", kind: "planned", before: { rpc: "follow.context-list", input: a => ({ workspaceId: a.workspaceId ?? undefined }) },
|
|
93
100
|
input: z.strictObject({ workspaceId: id.nullable().optional(), agentId: id.nullable().optional(), cardKey: z.string().min(1).max(400).optional(), card: z.string().trim().min(1).max(300).optional(),
|
|
94
101
|
target: z.enum(["overseer", "agent"]).optional(), ask: z.string().trim().min(1).max(2000).optional(), images: imagePaths, ...confirm }),
|
|
95
|
-
//
|
|
96
|
-
// agent
|
|
97
|
-
toRpc: a => ({ workspaceId: a.workspaceId ?? null, agentId: a.agentId ?? null, cardKey: a.cardKey, card: a.card, target: a.target, ask: a.ask, ...(a.images ? { images: a.images } : {}) }) },
|
|
102
|
+
// With cardKey: More context, to the card's workspace main agent (target accepted and ignored). Without: a free
|
|
103
|
+
// question to agentId, else the workspace's main agent. Never the caller itself (an-ask-goes-only-to-an-agent-that-can-answer-it).
|
|
104
|
+
toRpc: a => ({ workspaceId: a.workspaceId ?? null, agentId: a.agentId ?? null, cardKey: a.cardKey ?? null, ...(a.card ? { card: a.card } : {}), target: a.target, ask: a.ask, ...(a.images ? { images: a.images } : {}) }) },
|
|
105
|
+
{ name: "question_action", rpc: "follow.question-action", kind: "planned", before: { rpc: "follow.context-list", input: () => ({}) },
|
|
106
|
+
input: z.strictObject({ id: z.string().min(1).max(80).optional(), action: z.enum(["done", "reply", "task", "withdraw"]).optional(), text: z.string().trim().min(1).max(2000).optional(), images: imagePaths, ...confirm }),
|
|
107
|
+
toRpc: a => ({ id: a.id, action: a.action, ...(a.text ? { text: a.text } : {}), ...(a.images ? { images: a.images } : {}) }) },
|
|
98
108
|
// Needs-you: the brief card and the inbox's other actions
|
|
99
109
|
// The message queue: what waits to go to agents, and Retry or Cancel on one item (a card's Retry, Needs you's message row).
|
|
100
110
|
{ name: "queue_list", rpc: "follow.queue-list", kind: "read", input: z.strictObject({ workspaceId: id.optional(), agentId: id.optional() }) },
|
|
@@ -136,7 +146,9 @@ export const RPC_TOOLS: readonly RpcTool[] = [
|
|
|
136
146
|
{ name: "pr_controls", rpc: "follow.pr-control-status", kind: "read", input: z.strictObject({ workspaceId: id, prKey: z.string().trim().regex(/^[\w.-]+\/[\w.-]+#\d+$/) }) },
|
|
137
147
|
{ name: "browser_status", rpc: "follow.browser-status", kind: "read", input: none },
|
|
138
148
|
// What's new: the installed version, the one before it and when, and every shipped note (newest first)
|
|
139
|
-
|
|
149
|
+
// The notes since the version this host updated from in full; older ones (they only grow) as the newest few and a count.
|
|
150
|
+
{ name: "release_notes", rpc: "follow.release-notes", kind: "read", input: z.strictObject({ ...pageInput }), toRpc: () => ({}),
|
|
151
|
+
view: (out: { previous: string | null; notes: { version: string }[] }, a) => { const b = boundDone(out.notes, n => !out.previous || compareVersions(n.version, out.previous) <= 0, { newestFirst: (x, y) => compareVersions(y.version, x.version), hint: "release_notes offset/limit pages these (newest first)", offset: a.offset, limit: a.limit }); return { ...out, notes: b.items, older: b.done }; } },
|
|
140
152
|
// Settings → General: status (mode, channel, newest versions, phase, pending notes, history), Check now, mode/channel, Install now
|
|
141
153
|
{ name: "updates_status", rpc: "follow.updates", kind: "read", input: none },
|
|
142
154
|
{ name: "check_updates", rpc: "follow.updates", kind: "write", input: none, toRpc: () => ({ check: "manual" }) },
|
|
@@ -205,6 +217,8 @@ export const DISPLAY_TOOLS = ["display_settings", "set_display"] as const;
|
|
|
205
217
|
export const PARITY: Record<string, { tools: readonly string[]; note?: string } | { exempt: string } | { pending: string }> = {
|
|
206
218
|
"follow.list": { tools: ["list_prs", "workspace_status"] },
|
|
207
219
|
"follow.get": { tools: ["list_prs", "workspace_status"] },
|
|
220
|
+
// The Activity card's pages: workspace_status pages the same history (questions, batches) with its own offset.
|
|
221
|
+
"follow.activity": { tools: ["workspace_status"] },
|
|
208
222
|
"follow.control": { tools: ["set_auto_send", "clear_hold", "retry_batch", "make_main_agent", "snooze_workspace"] },
|
|
209
223
|
"follow.send": { tools: ["send_repairs"] },
|
|
210
224
|
"follow.recover": { tools: ["run_recovery"] },
|
|
@@ -255,6 +269,7 @@ export const PARITY: Record<string, { tools: readonly string[]; note?: string }
|
|
|
255
269
|
"follow.context-ask": { tools: ["ask_context"] },
|
|
256
270
|
"follow.image-support": { exempt: "The field's warning before Send. An agent's tool passes image paths to the same RPCs, and the server leaves images off for a recipient that can't take them and says so in the message (imageSupport), so a tool never has to ask first." },
|
|
257
271
|
"follow.context-list": { tools: ["context_requests"] },
|
|
272
|
+
"follow.question-action": { tools: ["question_action"] },
|
|
258
273
|
"follow.inbox-brief": { tools: ["inbox_brief"] },
|
|
259
274
|
"follow.queue-action": { tools: ["queue_action"] },
|
|
260
275
|
"follow.inbox-act": { tools: ["sign_off", "snooze", "set_finish_flags", "inbox_act"] },
|
package/server/ai-jobs.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { basename, dirname, join } from "node:path";
|
|
|
5
5
|
import type { z } from "zod";
|
|
6
6
|
import { guardFor, refusedCalls, type ToolGrant } from "./job-guard";
|
|
7
7
|
import { guardedProvider } from "../shared/agent-settings";
|
|
8
|
+
import { GUARDED_PHRASE } from "../shared/provider-support";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Small bounded model jobs: a prompt in, validated JSON out. Shared by Summaries and the Overseer ranker.
|
|
@@ -25,7 +26,7 @@ export type JobSpec<T> = {
|
|
|
25
26
|
prompt: string;
|
|
26
27
|
schema: z.ZodType<T>;
|
|
27
28
|
system?: string;
|
|
28
|
-
/** Any Paseo provider id; "claude" (default) and "
|
|
29
|
+
/** Any Paseo provider id; "claude" (default), "codex" and "pi" run through their headless CLI, the rest as a hidden agent. */
|
|
29
30
|
provider?: string;
|
|
30
31
|
/** The provider's model: "haiku" (Claude's default here), "sonnet", "gpt-6-luna"… */
|
|
31
32
|
model?: string;
|
|
@@ -40,7 +41,7 @@ export type JobSpec<T> = {
|
|
|
40
41
|
runner?: Runner;
|
|
41
42
|
/**
|
|
42
43
|
* The prompt carries words someone else wrote (an issue, a thread, a chat, a plan, mail). Such a job runs only on a
|
|
43
|
-
* provider Follow-up can take every tool away from (`guardedProvider
|
|
44
|
+
* provider Follow-up can take every tool away from (`guardedProvider`, shared/provider-support.ts); on any other it is refused before it starts
|
|
44
45
|
* (a-job-that-reads-outside-content-can-only-read).
|
|
45
46
|
*/
|
|
46
47
|
outside?: boolean;
|
|
@@ -87,7 +88,7 @@ export class AiJobs {
|
|
|
87
88
|
if (this.stopped) return done({ ok: false, reason: "stopped", error: "Follow-up is stopping.", costUsd: null, durationMs: 0 });
|
|
88
89
|
const provider = spec.provider ?? "claude";
|
|
89
90
|
// Someone else's words never reach a model that has tools: refused before any runner, the tests' included.
|
|
90
|
-
if (spec.outside && !guardedProvider(provider)) return done({ ok: false, reason: "unguarded", error: `This job reads words other people wrote, and Follow-up can't take ${provider}'s tools away. Pick
|
|
91
|
+
if (spec.outside && !guardedProvider(provider)) return done({ ok: false, reason: "unguarded", error: `This job reads words other people wrote, and Follow-up can't take ${provider}'s tools away. Pick ${GUARDED_PHRASE} in Settings → Agents.`, costUsd: null, durationMs: 0 });
|
|
91
92
|
// An injected runner (tests) always wins, so a job can never reach the real CLI from a test; then the job's own.
|
|
92
93
|
const runner = this.opts.runner ?? spec.runner ?? this.opts.runners?.[provider] ?? defaultRunner(provider) ?? this.opts.generic;
|
|
93
94
|
if (!runner) return done({ ok: false, reason: "failed", error: `${provider} can't run one-shot jobs here; pick another provider in Settings → Agents.`, costUsd: null, durationMs: 0 });
|
|
@@ -185,10 +186,30 @@ export function parseCodexEvents(stdout: string): RunOutput {
|
|
|
185
186
|
}
|
|
186
187
|
const codexError = (raw: string) => { try { const j = JSON.parse(raw); return String(j?.error?.message ?? raw).slice(0, 200); } catch { return raw.slice(0, 200); } };
|
|
187
188
|
|
|
188
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* `pi -p` with no tools at all and nothing loaded from the developer's setup: no extensions, skills, prompt templates
|
|
191
|
+
* or context files, no saved session (flags from Pi's README). The prompt goes on stdin, which print mode merges into
|
|
192
|
+
* the message; the reply is the printed text. Pi reports no cost.
|
|
193
|
+
*/
|
|
194
|
+
export function piArgs(input: Pick<RunInput, "model" | "system"> & { thinking?: string | null }): string[] {
|
|
195
|
+
return ["-p", "--no-tools", "--no-extensions", "--no-skills", "--no-prompt-templates", "--no-context-files", "--no-session",
|
|
196
|
+
...(input.model ? ["--model", input.model] : []), ...(input.thinking ? ["--thinking", input.thinking] : []), "--system-prompt", input.system,
|
|
197
|
+
"Answer the material below as the system prompt says."];
|
|
198
|
+
}
|
|
199
|
+
export function parsePiOutput(stdout: string): RunOutput {
|
|
200
|
+
if (!stdout.trim()) throw new Error("Pi returned no reply.");
|
|
201
|
+
return { text: stdout, costUsd: null, inputTokens: null, outputTokens: null };
|
|
202
|
+
}
|
|
203
|
+
/** Spawns `pi` the same way as the other CLIs: an argument array, the prompt on stdin, from the temp dir. */
|
|
204
|
+
export function piRunner(command = "pi"): Runner {
|
|
205
|
+
return input => spawnJob(command, piArgs(input), input.prompt, parsePiOutput, input, childEnv({}, {}));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Claude's own default for jobs; Codex and Pi use their CLI default when no model is set. */
|
|
189
209
|
export const DEFAULT_MODEL: Record<string, string> = { claude: "haiku" };
|
|
210
|
+
/** The providers whose own CLI runs a job with no tools (shared/provider-support.ts CLI_GUARD_PROVIDERS). */
|
|
190
211
|
export function defaultRunner(provider: string): Runner | null {
|
|
191
|
-
return provider === "claude" ? claudeRunner() : provider === "codex" ? codexRunner() : null;
|
|
212
|
+
return provider === "claude" ? claudeRunner() : provider === "codex" ? codexRunner() : provider === "pi" ? piRunner() : null;
|
|
192
213
|
}
|
|
193
214
|
|
|
194
215
|
/** The envelope of a one-turn reply is a few KB; anything near this is runaway output. */
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Brief } from "../shared/brief";
|
|
2
|
+
import { isLoaded, type LoadSignals } from "../shared/agent-load";
|
|
3
|
+
|
|
4
|
+
/** Brief rows wait for discovery, never resume an agent and never run a retry timer. */
|
|
5
|
+
export class BriefTimeline {
|
|
6
|
+
private pending = new Map<string, { brief: Brief; deferred: boolean }>();
|
|
7
|
+
private running = new Map<string, Promise<void>>();
|
|
8
|
+
constructor(private o: { loaded(id: string): Promise<LoadSignals | null>; current(id: string): Promise<Brief | null>; append(id: string, brief: Brief): Promise<void> }) {}
|
|
9
|
+
|
|
10
|
+
async sink(id: string, brief: Brief): Promise<void> {
|
|
11
|
+
const previous = this.pending.get(id);
|
|
12
|
+
this.pending.set(id, { brief, deferred: previous?.brief.id === brief.id && previous.deferred || false });
|
|
13
|
+
await this.deliver(id);
|
|
14
|
+
}
|
|
15
|
+
async changed(): Promise<void> { await Promise.all([...this.pending.keys()].map(id => this.deliver(id))); }
|
|
16
|
+
|
|
17
|
+
private deliver(id: string): Promise<void> {
|
|
18
|
+
const running = this.running.get(id);
|
|
19
|
+
if (running) return running;
|
|
20
|
+
const run = this.flush(id).finally(() => { this.running.delete(id); });
|
|
21
|
+
this.running.set(id, run);
|
|
22
|
+
return run;
|
|
23
|
+
}
|
|
24
|
+
private async flush(id: string): Promise<void> {
|
|
25
|
+
while (this.pending.has(id)) {
|
|
26
|
+
const pending = this.pending.get(id)!;
|
|
27
|
+
try {
|
|
28
|
+
// Metadata only, freshly fetched: a cached loaded row can outlive a close or a compaction reload.
|
|
29
|
+
const agent = await this.o.loaded(id);
|
|
30
|
+
const current = await this.o.current(id);
|
|
31
|
+
if (this.pending.get(id) !== pending) continue;
|
|
32
|
+
const replaced = !current || current.id !== pending.brief.id;
|
|
33
|
+
// A collapsed update emitted by the inbox still updates the old row while loaded. Once delivery has
|
|
34
|
+
// waited, an obsolete card is dropped; it must not appear for the first time after a newer brief.
|
|
35
|
+
if (replaced && (pending.deferred || pending.brief.state === "open")) { this.pending.delete(id); continue; }
|
|
36
|
+
if (!isLoaded(agent)) { pending.deferred = true; return; }
|
|
37
|
+
await this.o.append(id, replaced ? pending.brief : current!);
|
|
38
|
+
if (this.pending.get(id) === pending) this.pending.delete(id);
|
|
39
|
+
} catch {
|
|
40
|
+
pending.deferred = true;
|
|
41
|
+
// The session may not exist yet, or the runtime unloaded between metadata and append. Keep the row;
|
|
42
|
+
// discovery's next update (or the first session handle) retries it, without a per-agent poll.
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { randomBytes } from "node:crypto";
|
|
4
4
|
import { WriteBehind } from "./write-behind";
|
|
5
|
-
import {
|
|
5
|
+
import { compactionOnly } from "./inbox-classifier";
|
|
6
|
+
import { CONTEXT_ANSWER_MAX, CONTEXT_VERSION, contextFileSchema, plainAnswer, pruneContext, sameCard, type ContextFile, type ContextRequest, type ContextTarget, type ContextVia } from "../shared/catch-up";
|
|
7
|
+
import { capturedAnswer, migrateContext, newQuestionId } from "../shared/your-questions";
|
|
6
8
|
|
|
7
9
|
export const CONTEXT_FILE = "context.json";
|
|
8
10
|
|
|
9
|
-
export type AskInput = { workspaceId: string | null; agentId: string | null; cardKey: string; card: string; target: ContextTarget; ask: string };
|
|
11
|
+
export type AskInput = { workspaceId: string | null; agentId: string | null; cardKey: string | null; card: string; target: ContextTarget; ask: string; via?: ContextVia; parentId?: string | null };
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* an-ask-goes-only-to-an-agent-that-can-answer-it: who a More context ask goes to. Always the card's workspace's main
|
|
@@ -21,12 +23,32 @@ export function contextRecipient(workspace: { enable_tracking: boolean; mainAgen
|
|
|
21
23
|
return { agentId: workspace.mainAgentId };
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
type TrackedLite = { id: string; enable_tracking: boolean; archived?: boolean; mainAgentId: string; contributorAgentIds?: string[] };
|
|
24
27
|
/**
|
|
25
|
-
*
|
|
28
|
+
* an-ask-goes-only-to-an-agent-that-can-answer-it, for a free question (no card): who answers. A named agent (the one
|
|
29
|
+
* whose chat ran /ask, or an agent tool's `agentId`) is asked when it is a tracked workspace's main agent or one of its
|
|
30
|
+
* contributors, the roles that get context_reply; otherwise the workspace's main agent. Never the caller itself.
|
|
31
|
+
*/
|
|
32
|
+
export function questionRecipient(workspaces: readonly TrackedLite[], input: { workspaceId?: string | null; agentId?: string | null }, caller: string | null): { agentId: string; workspaceId: string } | { error: string } {
|
|
33
|
+
const live = workspaces.filter(w => w.enable_tracking && !w.archived);
|
|
34
|
+
if (input.agentId) {
|
|
35
|
+
const w = live.find(x => x.mainAgentId === input.agentId || x.contributorAgentIds?.includes(input.agentId!));
|
|
36
|
+
if (!w || (input.workspaceId && w.id !== input.workspaceId)) return { error: "Follow-up doesn't track this agent's workspace, so its answer can't land in Your questions. Ask in its chat instead." };
|
|
37
|
+
if (caller && caller === input.agentId) return { error: "You can't ask yourself; explain it in your reply." };
|
|
38
|
+
return { agentId: input.agentId, workspaceId: w.id };
|
|
39
|
+
}
|
|
40
|
+
const w = input.workspaceId ? live.find(x => x.id === input.workspaceId) : undefined;
|
|
41
|
+
if (!w?.mainAgentId) return { error: "Follow-up doesn't track this workspace, so no agent can answer in Your questions. Open its chat to ask there." };
|
|
42
|
+
if (caller && caller === w.mainAgentId) return { error: "You can't ask yourself; explain it in your reply." };
|
|
43
|
+
return { agentId: w.mainAgentId, workspaceId: w.id };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Your questions and Catch up's More context requests (docs/needs-you.md#your-questions): what the developer asked about a card, who answers
|
|
26
48
|
* (the card's workspace's main agent), and the answer once `context_reply` brings it. The value lives in memory and
|
|
27
49
|
* saves behind the reply (an-ack-never-waits-on-the-disk); a change calls `onChange`, which pushes Home's feed, so the
|
|
28
|
-
* client learns an answer arrived without polling. Small by construction: at most CONTEXT_MAX requests
|
|
29
|
-
* than CONTEXT_KEEP_MS.
|
|
50
|
+
* client learns an answer arrived without polling. Small by construction: at most CONTEXT_MAX requests a workspace,
|
|
51
|
+
* none older than CONTEXT_KEEP_MS (30 days).
|
|
30
52
|
*/
|
|
31
53
|
export class ContextRequests {
|
|
32
54
|
private value: ContextFile | null = null;
|
|
@@ -40,19 +62,21 @@ export class ContextRequests {
|
|
|
40
62
|
private async load(): Promise<ContextFile> {
|
|
41
63
|
if (this.value) return this.value;
|
|
42
64
|
let value: ContextFile;
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
let migrated = false;
|
|
66
|
+
// v1 → v2 on load (shared/your-questions.ts migrateContext): old asks become history rows already read.
|
|
67
|
+
try { ({ file: value, migrated } = migrateContext(JSON.parse(await readFile(join(this.directory, CONTEXT_FILE), "utf8")))); }
|
|
68
|
+
catch { value = { version: CONTEXT_VERSION, requests: [] }; } // Lost questions cost a re-ask, never a broken Home.
|
|
45
69
|
if (this.value) return this.value;
|
|
46
70
|
// 2.2.0-beta.3 could ask the Overseer, which has no context_reply: an ask of it still open never ends on its own.
|
|
47
71
|
// Its answer, if any, is in the Overseer's chat (an-ask-goes-only-to-an-agent-that-can-answer-it).
|
|
48
72
|
const at = new Date(this.now()).toISOString();
|
|
49
73
|
const stuck = value.requests.some(r => r.target === "overseer" && r.state === "asking");
|
|
50
|
-
this.value = stuck ? { requests: value.requests.map(r => r.target === "overseer" && r.state === "asking" ? { ...r, state: "chat" as const, settledAt: at } : r) } : value;
|
|
51
|
-
if (stuck) this.persist.set(this.value);
|
|
74
|
+
this.value = stuck ? { version: CONTEXT_VERSION, requests: value.requests.map(r => r.target === "overseer" && r.state === "asking" ? { ...r, state: "chat" as const, settledAt: at } : r) } : value;
|
|
75
|
+
if (stuck || migrated) this.persist.set(this.value);
|
|
52
76
|
return this.value;
|
|
53
77
|
}
|
|
54
78
|
private save(requests: ContextRequest[]): void {
|
|
55
|
-
this.value = contextFileSchema.parse({ requests: pruneContext(requests, this.now()) });
|
|
79
|
+
this.value = contextFileSchema.parse({ version: CONTEXT_VERSION, requests: pruneContext(requests, this.now()) });
|
|
56
80
|
this.persist.set(this.value);
|
|
57
81
|
this.onChange();
|
|
58
82
|
}
|
|
@@ -63,17 +87,20 @@ export class ContextRequests {
|
|
|
63
87
|
return filter.workspaceId ? live.filter(r => r.workspaceId === filter.workspaceId) : live;
|
|
64
88
|
}
|
|
65
89
|
|
|
90
|
+
async get(id: string): Promise<ContextRequest | null> { return (await this.list()).find(r => r.id === id) ?? null; }
|
|
91
|
+
|
|
66
92
|
/**
|
|
67
|
-
* Records
|
|
68
|
-
* asking again while it's open returns that one (`fresh: false`).
|
|
93
|
+
* Records a question. One open ask per card, from whichever surface (`sameCard`: Catch up's key or the question's
|
|
94
|
+
* own): asking again while it's open returns that one (`fresh: false`). A free question (no card) is always new.
|
|
69
95
|
*/
|
|
70
96
|
async ask(input: AskInput, by: string, askedOf: string | null): Promise<{ request: ContextRequest; fresh: boolean }> {
|
|
71
97
|
const { requests } = await this.load();
|
|
72
|
-
const
|
|
98
|
+
const card = input.cardKey;
|
|
99
|
+
const open = card ? requests.find(r => r.state === "asking" && sameCard(r, { workspaceId: input.workspaceId, cardKey: card })) : undefined;
|
|
73
100
|
if (open) return { request: open, fresh: false };
|
|
74
101
|
const request: ContextRequest = {
|
|
75
|
-
id:
|
|
76
|
-
askedAt: new Date(this.now()).toISOString(), settledAt: null, deliveredAt: null, by,
|
|
102
|
+
id: newQuestionId(id => requests.some(r => r.id === id), () => randomBytes(4).toString("hex")), ...input, via: input.via ?? "more", parentId: input.parentId ?? null, askedOf, state: "asking", answer: null, error: null,
|
|
103
|
+
askedAt: new Date(this.now()).toISOString(), settledAt: null, deliveredAt: null, by, readAt: null, done: null, task: null,
|
|
77
104
|
};
|
|
78
105
|
this.save([...requests, request]);
|
|
79
106
|
return { request, fresh: true };
|
|
@@ -114,13 +141,55 @@ export class ContextRequests {
|
|
|
114
141
|
|
|
115
142
|
/**
|
|
116
143
|
* An agent's turn ended. Every ask it owes that was delivered before now and still has no context_reply settles as
|
|
117
|
-
* `chat
|
|
118
|
-
*
|
|
119
|
-
*
|
|
144
|
+
* `chat`. Turn-end capture: `items` are the turn's timeline items the worker already read for this turn end
|
|
145
|
+
* (a-turn-s-timeline-is-read-once; any provider, no hook), and the agent's last message after the question is
|
|
146
|
+
* stored as its answer, "from its chat". Without items (the turn couldn't be read) it stays `chat` with no answer:
|
|
147
|
+
* Open chat. Delivery, not the turn's start, is the test, so a prompt steered into a turn already running counts,
|
|
148
|
+
* and nothing in memory is lost on a restart. No reads of its own.
|
|
120
149
|
*/
|
|
121
|
-
async turnEnded(agentId: string): Promise<void> {
|
|
150
|
+
async turnEnded(agentId: string, items: readonly unknown[] | null = null): Promise<void> {
|
|
151
|
+
// a-compaction-is-not-a-finish: a turn that only compacted answered nothing; the question waits for the next turn.
|
|
152
|
+
if (items && compactionOnly(items)) return;
|
|
122
153
|
const owed = (await this.list()).filter(r => r.state === "asking" && r.askedOf === agentId && r.deliveredAt && Date.parse(r.deliveredAt) <= this.now());
|
|
123
|
-
for (const r of owed)
|
|
154
|
+
for (const r of owed) {
|
|
155
|
+
const answer = capturedAnswer(items, r.id);
|
|
156
|
+
await this.update(r.id, x => x.state !== "asking" ? x : { ...x, state: "chat", answer, settledAt: new Date(this.now()).toISOString() });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Done, Make a task's record, Withdraw: what happened to a question after it was asked. `by` is "developer" or
|
|
162
|
+
* "agent:<id>"; only the developer's act marks the answer read (only-developer-acts-as-developer).
|
|
163
|
+
*/
|
|
164
|
+
async done(id: string, by: string): Promise<ContextRequest> {
|
|
165
|
+
const r = await this.must(id);
|
|
166
|
+
if (r.state === "asking") throw new Error("This question is still asking; withdraw it instead.");
|
|
167
|
+
const at = new Date(this.now()).toISOString();
|
|
168
|
+
return (await this.update(id, x => ({ ...x, done: x.done ?? { at, by }, readAt: by === "developer" ? x.readAt ?? at : x.readAt })))!;
|
|
169
|
+
}
|
|
170
|
+
/** The developer read it (Reply, Make a task): marks read without closing it. Agents never do this. */
|
|
171
|
+
async read(id: string): Promise<ContextRequest | null> {
|
|
172
|
+
const at = new Date(this.now()).toISOString();
|
|
173
|
+
return this.update(id, x => x.readAt ? x : { ...x, readAt: at });
|
|
174
|
+
}
|
|
175
|
+
async tasked(id: string, taskId: string, by: string): Promise<ContextRequest> {
|
|
176
|
+
const r = await this.must(id);
|
|
177
|
+
if (r.state === "asking" || r.state === "withdrawn") throw new Error("Make a task needs an answer first.");
|
|
178
|
+
if (r.task) return r;
|
|
179
|
+
const at = new Date(this.now()).toISOString();
|
|
180
|
+
return (await this.update(id, x => ({ ...x, task: { id: taskId, at, by }, readAt: by === "developer" ? x.readAt ?? at : x.readAt })))!;
|
|
181
|
+
}
|
|
182
|
+
/** Withdraw while asking: settles as withdrawn (the caller drops the message if it is still queued). */
|
|
183
|
+
async withdraw(id: string, by: string): Promise<ContextRequest> {
|
|
184
|
+
const r = await this.must(id);
|
|
185
|
+
if (r.state !== "asking") throw new Error("Only a question still asking can be withdrawn.");
|
|
186
|
+
const at = new Date(this.now()).toISOString();
|
|
187
|
+
return (await this.update(id, x => x.state !== "asking" ? x : { ...x, state: "withdrawn", settledAt: at, done: { at, by }, readAt: at }))!;
|
|
188
|
+
}
|
|
189
|
+
private async must(id: string): Promise<ContextRequest> {
|
|
190
|
+
const r = await this.get(id);
|
|
191
|
+
if (!r) throw new Error(`No question ${id}. It may have expired (questions are kept 30 days).`);
|
|
192
|
+
return r;
|
|
124
193
|
}
|
|
125
194
|
|
|
126
195
|
/**
|
package/server/directory.ts
CHANGED
|
@@ -30,6 +30,8 @@ export const LOOKUP_MAX = 40;
|
|
|
30
30
|
* agent (a timeline or subagent read) re-checks that one agent first: see `live`.
|
|
31
31
|
*/
|
|
32
32
|
export class DaemonDirectory {
|
|
33
|
+
/** Discovery metadata changed; passive consumers can retry work for agents now loaded. */
|
|
34
|
+
onAgentsChanged: () => void = () => {};
|
|
33
35
|
private rows: (DirectoryRows & { at: number; agentsAt: number; projectsAt: number }) | null = null;
|
|
34
36
|
/**
|
|
35
37
|
* In-flight reads, joined by every concurrent caller (concurrent-readers-share-one-request): one request per list,
|
|
@@ -106,6 +108,7 @@ export class DaemonDirectory {
|
|
|
106
108
|
this.rememberArchived(this.rows?.agents); this.rememberArchived(fresh.agents);
|
|
107
109
|
const at = this.now();
|
|
108
110
|
this.rows = { ...fresh, at, agentsAt: at, projectsAt: at }; this.agentsTick = this.tick;
|
|
111
|
+
this.onAgentsChanged();
|
|
109
112
|
if (failedProjects) this.projectsStale = true;
|
|
110
113
|
return this.rows;
|
|
111
114
|
} catch (error) { this.dirty = true; throw error; }
|
|
@@ -122,6 +125,7 @@ export class DaemonDirectory {
|
|
|
122
125
|
const agents = await this.connect(client => this.list("fetch_agents_request", cursor => client.fetchAgents({ page: { limit: 100, ...(cursor ? { cursor } : {}) } })));
|
|
123
126
|
this.rememberArchived(this.rows?.agents); this.rememberArchived(agents);
|
|
124
127
|
if (this.rows) { this.rows.agents = agents; this.rows.agentsAt = this.now(); this.agentsTick = this.tick; }
|
|
128
|
+
this.onAgentsChanged();
|
|
125
129
|
return this.rows!;
|
|
126
130
|
}
|
|
127
131
|
private refreshProjects(): Promise<DirectoryRows> {
|
|
@@ -201,6 +205,7 @@ export class DaemonDirectory {
|
|
|
201
205
|
const i = this.rows.agents.findIndex(row => row.agent.id === id);
|
|
202
206
|
if (i >= 0) this.rows.agents[i] = { agent }; else this.rows.agents.push({ agent });
|
|
203
207
|
}
|
|
208
|
+
this.onAgentsChanged();
|
|
204
209
|
return agent;
|
|
205
210
|
}
|
|
206
211
|
|
|
@@ -220,6 +225,7 @@ export class DaemonDirectory {
|
|
|
220
225
|
const agent = this.cached(id);
|
|
221
226
|
if (!agent) { this.dirty = true; return false; }
|
|
222
227
|
change(agent);
|
|
228
|
+
this.onAgentsChanged();
|
|
223
229
|
return true;
|
|
224
230
|
}
|
|
225
231
|
|
package/server/discovery.ts
CHANGED
|
@@ -158,6 +158,8 @@ export function applyDiscovery(state: State, discovered: DiscoveredWorkspace[],
|
|
|
158
158
|
// A new main agent, or a new message to the gone one, means its conversation can be tried again.
|
|
159
159
|
if (w.goneAgent && (w.goneAgent.agentId !== w.mainAgentId || (row.messageAt && row.messageAt > w.goneAgent.at))) w.goneAgent = null;
|
|
160
160
|
if (row.contributorAgentIds) w.contributorAgentIds = row.contributorAgentIds;
|
|
161
|
+
// What an agent said it is working on leaves with the agent (shared/now.ts).
|
|
162
|
+
if (w.milestones) for (const id of Object.keys(w.milestones)) if (id !== w.mainAgentId && !w.contributorAgentIds?.includes(id)) delete w.milestones[id];
|
|
161
163
|
if (!w.enable_tracking && followsByDefault(state, row)) { w.enable_auto_sends = startsWithAutoSend(state, w); w.enable_tracking = true; }
|
|
162
164
|
if (!w.inventory) {
|
|
163
165
|
w.inventory = { revision: 1, syncedRevision: 0, candidates: [], historyComplete: false, historyError: null, scannedMessageAt: null };
|
package/server/engine.ts
CHANGED
|
@@ -802,6 +802,8 @@ export class Engine {
|
|
|
802
802
|
w.declaration = null;
|
|
803
803
|
const alreadyDone = !!w.completion;
|
|
804
804
|
settleDoneChecks(w, this.now());
|
|
805
|
+
// Done: nobody is working toward the goal any more, so what each agent said it was on goes (shared/now.ts).
|
|
806
|
+
if (!alreadyDone) delete w.milestones;
|
|
805
807
|
if (!alreadyDone) w.completion = { summary: message, declaredAt: new Date(this.now()).toISOString(), ...(gate.unconfirmed.length ? { unconfirmed: gate.unconfirmed } : {}) };
|
|
806
808
|
return { workspace: w, blockers, unconfirmed: gate.unconfirmed, alreadyDone, next: doneGuidance(gate, alreadyDone) };
|
|
807
809
|
});
|
|
@@ -929,6 +931,7 @@ function settleDoneChecks(w: Workspace, now: number): void {
|
|
|
929
931
|
}
|
|
930
932
|
/** Records a stored declaration as Done; the Done check it answers is no longer needed. */
|
|
931
933
|
function acceptDeclaration(w: Workspace, gate: CompletionGate, now: number): void {
|
|
934
|
+
delete w.milestones;
|
|
932
935
|
w.completion = { summary: w.declaration!.summary, declaredAt: new Date(now).toISOString(), ...(gate.unconfirmed.length ? { unconfirmed: gate.unconfirmed } : {}) };
|
|
933
936
|
w.declaration = null;
|
|
934
937
|
settleDoneChecks(w, now);
|
package/server/hook-source.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const hookSource: string = [
|
|
|
20
20
|
" */",
|
|
21
21
|
"const inPrompt = new Set(String(env(\"SYSTEM_PROMPT\") ?? \"\").split(\",\").filter(Boolean));",
|
|
22
22
|
"// Tool names that read unambiguously in prose; kept identical to server/mcp.mjs's underscore names (a test checks it).",
|
|
23
|
-
"export const TOOL_NAMES = [\"workspace_status\", \"brief_settings\", \"set_brief_settings\", \"brief_plan\", \"set_brief_plan\", \"brief_chat_search\", \"brief_sources\", \"set_brief_sources\", \"compass_find\", \"set_compass\", \"read_compass\", \"compass_note\", \"why_suggested\", \"sync_workspace\", \"enroll_workspace\", \"register_pr\", \"exclude_stack\", \"update_obligation\", \"acknowledge_batch\", \"ask_question\", \"record_answer\", \"withdraw_question\", \"set_spec\", \"link_item\", \"unlink_item\", \"link_items\", \"set_linked_items\", \"workspace_about\", \"agent_settings\", \"needs_you\", \"declare_done\", \"list_prs\", \"add_reviewers\", \"enable_merge_when_ready\", \"disable_merge_when_ready\", \"send_repairs\", \"set_auto_send\", \"clear_hold\", \"retry_batch\", \"inbox_list\", \"sign_off\", \"snooze_workspace\", \"set_finish_flags\", \"set_priorities\", \"agent_digest\", \"route_candidates\", \"send_to_agent\", \"start_workspace\", \"display_settings\", \"set_display\", \"follow_settings\", \"set_follow_settings\", \"project_settings\", \"set_project_tracking\", \"pr_workflow\", \"set_pr_workflow\", \"pr_stats\", \"pr_stats_settings\", \"set_pr_stats\", \"reviewer_settings\", \"reviewer_suggestions\", \"save_reviewers\", \"set_agent_setting\", \"set_wait_for_jobs\", \"onboarding_status\", \"onboarding_checks\", \"set_onboarding\", \"rank_status\", \"rerank_priorities\", \"overseer_status\", \"overseer_start\", \"overseer_restart\", \"overseer_ask\", \"inbox_brief\", \"brief_action\", \"queue_list\", \"queue_action\", \"inbox_act\", \"answer_question\", \"dismiss_question\", \"dismiss_item\", \"run_recovery\", \"set_workspace_spec\", \"set_task_trigger\", \"pr_controls\", \"browser_status\", \"trust_bypass_status\", \"release_notes\", \"updates_status\", \"check_updates\", \"set_updates\", \"install_update\", \"make_main_agent\", \"retry_move\", \"report_issue\", \"report_send\", \"ai_rename\", \"catch_up_deck\", \"context_requests\", \"ask_context\", \"context_reply\", \"linear_queue\", \"sweep_queue\", \"dispatch_sources\", \"dispatch_records\", \"dispatch_undo\", \"dispatch_actions\", \"set_dispatch_actions\", \"dispatch_settings\", \"set_dispatch_settings\", \"wait_for_checks\"];",
|
|
23
|
+
"export const TOOL_NAMES = [\"workspace_status\", \"workspace_now\", \"brief_settings\", \"set_brief_settings\", \"brief_plan\", \"set_brief_plan\", \"brief_chat_search\", \"brief_sources\", \"set_brief_sources\", \"compass_find\", \"set_compass\", \"read_compass\", \"compass_note\", \"why_suggested\", \"sync_workspace\", \"enroll_workspace\", \"register_pr\", \"exclude_stack\", \"update_obligation\", \"acknowledge_batch\", \"ask_question\", \"record_answer\", \"withdraw_question\", \"set_spec\", \"link_item\", \"unlink_item\", \"link_items\", \"set_linked_items\", \"workspace_about\", \"agent_settings\", \"needs_you\", \"declare_done\", \"list_prs\", \"add_reviewers\", \"enable_merge_when_ready\", \"disable_merge_when_ready\", \"send_repairs\", \"set_auto_send\", \"clear_hold\", \"retry_batch\", \"inbox_list\", \"sign_off\", \"snooze_workspace\", \"set_finish_flags\", \"set_priorities\", \"agent_digest\", \"route_candidates\", \"send_to_agent\", \"start_workspace\", \"display_settings\", \"set_display\", \"follow_settings\", \"set_follow_settings\", \"project_settings\", \"set_project_tracking\", \"pr_workflow\", \"set_pr_workflow\", \"pr_stats\", \"pr_stats_settings\", \"set_pr_stats\", \"reviewer_settings\", \"reviewer_suggestions\", \"save_reviewers\", \"set_agent_setting\", \"set_wait_for_jobs\", \"onboarding_status\", \"onboarding_checks\", \"set_onboarding\", \"rank_status\", \"rerank_priorities\", \"overseer_status\", \"overseer_start\", \"overseer_restart\", \"overseer_ask\", \"inbox_brief\", \"brief_action\", \"queue_list\", \"queue_action\", \"inbox_act\", \"answer_question\", \"dismiss_question\", \"dismiss_item\", \"run_recovery\", \"set_workspace_spec\", \"set_task_trigger\", \"pr_controls\", \"browser_status\", \"trust_bypass_status\", \"release_notes\", \"updates_status\", \"check_updates\", \"set_updates\", \"install_update\", \"make_main_agent\", \"retry_move\", \"report_issue\", \"report_send\", \"ai_rename\", \"catch_up_deck\", \"context_requests\", \"ask_context\", \"question_action\", \"context_reply\", \"linear_queue\", \"sweep_queue\", \"dispatch_sources\", \"dispatch_records\", \"dispatch_undo\", \"dispatch_actions\", \"set_dispatch_actions\", \"dispatch_settings\", \"set_dispatch_settings\", \"wait_for_checks\"];",
|
|
24
24
|
"const toolPattern = new RegExp(`(?<![\\\\w])(${TOOL_NAMES.join(\"|\")})(?![\\\\w])`, \"g\");",
|
|
25
25
|
"/** Names Follow-up's tools the way this agent has them. */",
|
|
26
26
|
"export function named(text, isNative = native) { return isNative ? text.replace(toolPattern, \"follow_$1\") : text; }",
|
|
@@ -37,16 +37,18 @@ export const hookSource: string = [
|
|
|
37
37
|
"export const detachedNotice = \"Follow-up was updated while this session was open, so its follow_* tools are detached and fail with \\\"Tool not found\\\" until this session reopens (Paseo reopens it before your next prompt). Until then use the bridge, which runs the same tools with their unprefixed names: node \\\"$FOLLOW_UP_CLI\\\" call <tool> '<json>' --compact (for example sync_workspace or needs_you). Do not mention this to the developer.\";",
|
|
38
38
|
"const quietRevision = 1;",
|
|
39
39
|
"const quietInstruction = \"Do routine bookkeeping silently. Do not announce tracker calls, say you updated/synced the sidebar, recap panel state, or add plugin-status commentary/final paragraphs. Put receipts and evidence in the tools. User-facing messages should cover the actual work outcome, or a decision/blocker requiring the developer; answer sidebar status only when explicitly asked. If this continuation is bookkeeping only, use the tools and finish without another recap or repeating your previous answer.\";",
|
|
40
|
-
"const stopReason = \"Silently complete this workspace's sidebar bookkeeping before finishing.\";",
|
|
40
|
+
"export const stopReason = \"Silently complete this workspace's sidebar bookkeeping before finishing.\";",
|
|
41
41
|
"// Kept identical to NEEDS_YOU_NUDGE in shared/brief.ts (a test checks it).",
|
|
42
|
-
"const nudgeReason = \"Before you stop, call needs_you once with what the developer has to do next: a decision with options (or questions=[\\\"Q18\\\"] for one that is already an open question), an action only they can take, or kind=done (\\\"Nothing needed\\\" plus what you finished), which means nothing for the developer and won't flag you. Then stop; don't repeat your reply.\";",
|
|
42
|
+
"export const nudgeReason = \"Before you stop, call needs_you once with what the developer has to do next: a decision with options (or questions=[\\\"Q18\\\"] for one that is already an open question), an action only they can take, or kind=done (\\\"Nothing needed\\\" plus what you finished), which means nothing for the developer and won't flag you. Then stop; don't repeat your reply.\";",
|
|
43
43
|
"",
|
|
44
44
|
"/**",
|
|
45
45
|
" * R2: whether to nudge a Claude Code root agent that ended its turn without needs_you. Pure, so every skip is testable.",
|
|
46
46
|
" * At most once per turn: Claude's stop_hook_active and our own per-turn `stopped` marker both end it.",
|
|
47
47
|
" */",
|
|
48
48
|
"/** due-by-fact: the line above the due tasks a turn end names. */",
|
|
49
|
-
"
|
|
49
|
+
"/** The first line of the turn-end message a provider without this hook gets instead (server/turn-end.ts). */",
|
|
50
|
+
"export const turnEndPrefix = \"Follow-up turn-end check:\";",
|
|
51
|
+
"export const dueHeader = \"Follow-up: these tasks are due. For each, do it and close it with update_obligation (status=done with evidence), or keep it with recheck=\\\"YYYY-MM-DD\\\" and why in evidence.\";",
|
|
50
52
|
"/**",
|
|
51
53
|
" * The due tasks to name at this turn end: due entries (from scopes.json) whose time passed, not yet named twice for",
|
|
52
54
|
" * this fact and revision and not within a day, oldest first, at most 3; and the receipt counting them. A copy of",
|
|
@@ -220,7 +222,7 @@ export const hookSource: string = [
|
|
|
220
222
|
" \"Stakeholder replies are follow-up too. When asked to update a requester, capture the original Slack threadUrl, recipient and explicit developer authorization in the task's communication field; referenced messages alone do not authorize posting. Use a concise progress task now and, when needed, a verify-and-reply task with purpose=verified after the relevant deployed PRs. Read existing thread replies and refresh evidence before posting; distinguish fixed, deployed and verified. Record the actual sent replyUrl and result before marking done. If posting is unavailable or its outcome is uncertain, keep the task blocked and check the thread before any retry; never claim a draft was sent. Auto authorizes delivery to you, not external messages. Communication-only requests do not authorize repairs, benchmarks, migrations or other production writes.\",",
|
|
221
223
|
" \"A task comes due by itself when its afterPrs reach dependencyStage, or on its recheck date (update_obligation recheck=\\\"YYYY-MM-DD\\\"; a task with no PRs defaults to 3 days after your last update). At your turn\\u2019s end Follow-up names due tasks: do each and close it with evidence, or keep it with a new recheck and why. A trigger={event:\\\"now\\\"|\\\"merge\\\"|\\\"deploy\\\",delayDays:0} also sends a task to you as a message; set one only from the developer\\u2019s requested timing; never infer timing from a title or enable_follow_up alone. trigger={event:\\\"at\\\",at:\\\"<ISO time with offset>\\\"} or {event:\\\"at\\\",inMinutes:30} sends it to you once at that time, Auto-send on or off: set it from a time the developer named, or yourself on a waiting task to check back on something Follow-up can\\u2019t see (a registry, a release window, a reply); never a sleep loop or a timer of your own (CI: wait_for_checks). Merge/deploy triggers require owned afterPrs; delayDays=14 waits fourteen days after the last dependency event. Now requires no PR dependencies or delay. Deployment timing starts at the first verified fully serving observation and remains conservative when history is unknown. Preserve existing trigger fields on updates; trigger=null removes it. Auto controls delivery, not timing or production permissions.\",",
|
|
222
224
|
" batchParagraph(workflow) + \" For post-deploy tasks, verify the currently serving revision contains every dependency and record behavioral results separately. Acknowledge the header's batch ID with acknowledge_batch before finishing: completed with the result, or blocked with the reason (humanOnly=true when only a person can move it, such as a stale review the reviewer must re-review or dismiss). Verify the entire goal and post-merge work before declare_done; acknowledge a completion batch first. \" + mergeLine(workflow),",
|
|
223
|
-
" \"Before ending this turn, reconcile the sidebar with what you actually did and call sync_workspace with a short summary, including when no changes are needed. Acknowledge any assigned batch. When the entire goal is fulfilled, use declare_done; otherwise preserve remaining work. Do not launch recovery, start queued repairs, merge, toggle merge-when-ready, or archive as part of this bookkeeping. Auto still governs separate follow-up sends. Subagents report to the main agent instead of claiming workspace ownership.\",",
|
|
225
|
+
" \"Before ending this turn, reconcile the sidebar with what you actually did and call sync_workspace with a short summary, including when no changes are needed. Pass milestone when the milestone you're on changed. Acknowledge any assigned batch. When the entire goal is fulfilled, use declare_done; otherwise preserve remaining work. Do not launch recovery, start queued repairs, merge, toggle merge-when-ready, or archive as part of this bookkeeping. Auto still governs separate follow-up sends. Subagents report to the main agent instead of claiming workspace ownership.\",",
|
|
224
226
|
" `Prefer the native follow-up MCP tools. For a full historical record, use workspace_status with detail=full. CLI compatibility fallback: FOLLOW_UP_CLIENT_ENTRY=${quote(lease.clientEntry)} node ${quote(join(directory, \"mcp.mjs\"))} call <tool> '<json>' --compact. Omit --compact only when an existing script needs the full response. Never ask the developer to maintain the sidebar or run this bridge.`,",
|
|
225
227
|
" ];",
|
|
226
228
|
"}",
|
|
@@ -76,6 +76,23 @@ export function finishedReply(items: readonly unknown[], saved: { at?: unknown;
|
|
|
76
76
|
return typeof reply?.text === "string" ? reply.text : null;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* The turn did nothing but compact (a-compaction-is-not-a-finish): its timeline shows a compaction and nothing the agent
|
|
81
|
+
* produced (no reply, reasoning, tool call, to-do list or error). The prompt (`/compact`, Smart Session's request, none
|
|
82
|
+
* for a provider's own auto-compaction), plugins' cards and notifications aren't the agent's work. An empty read proves
|
|
83
|
+
* nothing (the read may have failed), so it is never a compaction; neither is a tail that reaches an earlier turn's reply.
|
|
84
|
+
*/
|
|
85
|
+
const AGENT_WORK = new Set(["assistant_message", "reasoning", "tool_call", "todo", "error"]);
|
|
86
|
+
export function compactionOnly(items: readonly unknown[]): boolean {
|
|
87
|
+
let compacted = false;
|
|
88
|
+
for (const item of items) {
|
|
89
|
+
const type = (item as { type?: unknown } | null)?.type;
|
|
90
|
+
if (type === "compaction") compacted = true;
|
|
91
|
+
else if (typeof type === "string" && AGENT_WORK.has(type)) return false;
|
|
92
|
+
}
|
|
93
|
+
return compacted;
|
|
94
|
+
}
|
|
95
|
+
|
|
79
96
|
/** Readers over the other plugins' plugin-data. Unknown versions or shapes read as "not theirs". */
|
|
80
97
|
export function fileSources(paseoHome: string, ledger: () => Promise<Ledger>): Sources {
|
|
81
98
|
const data = (...p: string[]) => join(paseoHome, "plugin-data", ...p);
|
package/server/inbox.ts
CHANGED
|
@@ -17,7 +17,8 @@ import type { State as FollowState, Workspace as FollowWorkspace } from "../shar
|
|
|
17
17
|
import { reviewersAskStands } from "../shared/attention";
|
|
18
18
|
import { followUpObligations } from "../shared/follow-up";
|
|
19
19
|
import { configuredReviewers, reviewerLabel, withoutAuthor } from "../shared/reviewers";
|
|
20
|
-
import { classify, finishedReply, turnPrompt, type Sources } from "./inbox-classifier";
|
|
20
|
+
import { classify, compactionOnly, finishedReply, turnPrompt, type Sources } from "./inbox-classifier";
|
|
21
|
+
import { isCompactCommand } from "../shared/status";
|
|
21
22
|
import { STALE_BRIEF } from "../shared/errors";
|
|
22
23
|
import type { Question } from "../shared/questions";
|
|
23
24
|
import { briefAnswer, briefAsks, briefAnswers, briefOrigin, briefQuestionsEvent, briefStep, pickBrief, shouldReopen, validPick, type Brief, type BriefEvent, type BriefKind, type BriefSources, type NeedsYouRecord, type PrState } from "../shared/brief";
|
|
@@ -459,8 +460,10 @@ export class Inbox {
|
|
|
459
460
|
const sender = prompt.from ?? await classify(prompt.message, agent.id, at, this.o.sources);
|
|
460
461
|
// Only the developer's own message answers the open brief. Another agent's message, Follow-up's prompts, a
|
|
461
462
|
// continuation after compaction or a schedule start a turn but leave the card open: its questions still are.
|
|
462
|
-
|
|
463
|
-
|
|
463
|
+
// A developer's /compact asks for a compaction, not an answer: the ask stays open (a-compaction-is-not-a-finish).
|
|
464
|
+
const answers = sender === "tom" && !isCompactCommand(prompt.message?.text);
|
|
465
|
+
const brief: BriefEvent = answers ? { type: "message", text: prompt.message?.text ?? null } : { type: "turn_start" };
|
|
466
|
+
await this.apply([{ agentId: root.rootId, event: { type: "message", from: answers ? "tom" : "automation" }, brief: () => brief }]);
|
|
464
467
|
}
|
|
465
468
|
|
|
466
469
|
async turnEnded(agent: { id: string; workspaceId: string | null; parentAgentId?: string | null }, outcome: { kind: "completed" } | { kind: "failed"; error: { message: string } } | { kind: "canceled"; reason: string }, turnId: string | null): Promise<void> {
|
|
@@ -483,6 +486,9 @@ export class Inbox {
|
|
|
483
486
|
const stated = await this.sources(agent.id, since, turnId);
|
|
484
487
|
if (outcome.kind === "completed") {
|
|
485
488
|
const items = await (this.o.directory.turnItems?.(agent.id, turnId) ?? this.o.directory.tail(agent.id, 20)).catch(() => []);
|
|
489
|
+
// A turn that only compacted (/compact, Smart Session's request, a provider's auto-compaction) is not the agent
|
|
490
|
+
// finishing: no flag, no brief, and the ask from before stays open and current (a-compaction-is-not-a-finish).
|
|
491
|
+
if (compactionOnly(items)) return;
|
|
486
492
|
// Never Follow-up's own bookkeeping continuation's reply (finishedReply).
|
|
487
493
|
const saved = /^[\w-]+$/.test(agent.id) ? await readFile(join(this.hookState, `bookkeeping-${agent.id}.json`), "utf8").then(t => JSON.parse(t), () => null) : null;
|
|
488
494
|
const reply = { text: finishedReply(items, saved, turnAt) };
|
package/server/job-agent.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Runner, RunInput } from "./ai-jobs";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* One-shot jobs on any Paseo provider: the job runs as a short-lived agent in a background workspace, so it never shows
|
|
7
|
-
* in the developer's workspace or agent lists, and is archived as soon as it answers. Claude and
|
|
7
|
+
* in the developer's workspace or agent lists, and is archived as soon as it answers. Claude, Codex and Pi keep their
|
|
8
8
|
* headless CLI fast path (ai-jobs.ts); this is for every other provider.
|
|
9
9
|
*
|
|
10
10
|
* Paseo 0.15.2 refuses `internal` agents from clients ("create a background workspace instead"), so a background
|
|
@@ -33,6 +33,17 @@ export type JobAgentOptions = {
|
|
|
33
33
|
directory: string;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* A job agent gets no tools wherever its provider can be told so (shared/provider-support.ts SESSION_GUARD_PROVIDERS):
|
|
38
|
+
* OpenCode takes a session permission rule, and Paseo turns `permission: "deny"` into `*` denied for every tool, its
|
|
39
|
+
* own MCP tools included, before any prompt; Auto Accept stays off (Paseo turns it on for an unattended agent
|
|
40
|
+
* otherwise). A job never needs a tool, so every job there is locked, not only one that reads other people's words.
|
|
41
|
+
* Belt and braces: a job that still asks for a permission fails and is archived (status "permission").
|
|
42
|
+
*/
|
|
43
|
+
export function lockedConfig(provider: string): Record<string, unknown> {
|
|
44
|
+
return provider === "opencode" ? { providerOptions: { permission: "deny", auto_accept: false } } : {};
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
/** The provider string Paseo's agent config takes: "opencode/qwen3-coder", or the provider alone for its default model. */
|
|
37
48
|
export const providerModel = (provider: string, model: string) => model ? `${provider}/${model}` : provider;
|
|
38
49
|
|
|
@@ -54,7 +65,7 @@ export function jobAgentRunner(opts: JobAgentOptions): Runner {
|
|
|
54
65
|
};
|
|
55
66
|
const create = async (paseo: JobPaseo, input: RunInput) => {
|
|
56
67
|
const options = {
|
|
57
|
-
config: { provider: providerModel(input.provider, input.model), systemPrompt: input.system, ...(input.thinking ? { thinkingOptionId: input.thinking } : {}) },
|
|
68
|
+
config: { provider: providerModel(input.provider, input.model), systemPrompt: input.system, ...(input.thinking ? { thinkingOptionId: input.thinking } : {}), ...lockedConfig(input.provider) },
|
|
58
69
|
title: `${JOBS_TITLE}: one-shot`, labels: { [JOB_LABEL]: "1" }, prompt: input.prompt, autoArchive: true,
|
|
59
70
|
};
|
|
60
71
|
// A saved workspace can be archived or gone (a fresh Paseo home): make a new one once, then give up.
|