@getpaseo/server 0.16.1 → 0.16.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/dist/server/builtin-plugins/package.json +1 -1
- package/dist/server/builtin-plugins/worktree-include/server/copy.ts +162 -16
- package/dist/server/server/agent/agent-manager.js +2 -1
- package/dist/server/server/agent/providers/claude/agent.js +34 -2
- package/dist/server/server/agent/providers/omp/agent.d.ts +1 -0
- package/dist/server/server/agent/providers/omp/agent.js +22 -0
- package/dist/server/server/agent/providers/omp/rpc-types.d.ts +4 -0
- package/dist/server/server/agent/providers/omp/rpc-types.js +8 -0
- package/dist/server/server/agent/tools/paseo-tools.js +8 -2
- package/dist/server/server/bootstrap.js +2 -2
- package/dist/server/server/file-observer/index.d.ts +1 -0
- package/dist/server/server/file-observer/index.js +14 -1
- package/dist/server/server/file-observer/internal/observation.js +4 -0
- package/dist/server/server/hub/relationship-controller.js +26 -15
- package/dist/server/server/hub/relationship-remote.d.ts +1 -1
- package/dist/server/server/hub/relationship-remote.js +2 -2
- package/dist/server/server/resolve-worktree-creation-intent.d.ts +1 -1
- package/dist/server/server/session/workspace-recovery/workspace-recovery-service.js +30 -4
- package/dist/server/server/test-fixtures/reconciliation-registries.d.ts +1 -0
- package/dist/server/server/websocket-server.d.ts +5 -0
- package/dist/server/server/websocket-server.js +10 -2
- package/dist/server/server/workspace-archive-service.js +10 -2
- package/dist/server/server/workspace-git-service.d.ts +1 -0
- package/dist/server/server/workspace-git-service.js +31 -5
- package/dist/server/server/workspace-registry.d.ts +2 -0
- package/dist/server/server/workspace-registry.js +2 -0
- package/dist/server/terminal/terminal-worker-process.js +16 -14
- package/dist/server/terminal/terminal-worker-socket-path.d.ts +15 -1
- package/dist/server/terminal/terminal-worker-socket-path.js +57 -9
- package/dist/server/terminal-worker/terminal-worker.mjs +51 -23
- package/dist/server/utils/worktree.d.ts +14 -1
- package/dist/server/utils/worktree.js +58 -7
- package/dist/server/web-ui/_expo/static/js/web/{index-6de36f49f1c767e50d1cf95ae05eb46a.js → index-3d51f4c450eeff5bd838a646e9c611f2.js} +16 -16
- package/dist/server/web-ui/_expo/static/js/web/index-3d51f4c450eeff5bd838a646e9c611f2.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-3d51f4c450eeff5bd838a646e9c611f2.js.gz +0 -0
- package/dist/server/web-ui/index.html +1 -1
- package/dist/server/web-ui/index.html.br +0 -0
- package/dist/server/web-ui/index.html.gz +0 -0
- package/package.json +6 -6
- package/dist/server/web-ui/_expo/static/js/web/index-6de36f49f1c767e50d1cf95ae05eb46a.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-6de36f49f1c767e50d1cf95ae05eb46a.js.gz +0 -0
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright (c) 2026 Carlos Precioso.
|
|
3
3
|
import { execFile } from "node:child_process";
|
|
4
4
|
import { constants, existsSync } from "node:fs";
|
|
5
|
-
import { copyFile, mkdir } from "node:fs/promises";
|
|
5
|
+
import { copyFile, mkdir, mkdtemp, readFile, rm } from "node:fs/promises";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
6
7
|
import { dirname, join } from "node:path";
|
|
7
8
|
import { promisify } from "node:util";
|
|
8
9
|
|
|
@@ -22,37 +23,33 @@ async function git(cwd: string, args: string[], input?: string): Promise<string>
|
|
|
22
23
|
return stdout;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
// `git check-ignore --stdin` reads each path as a pathspec, so a name such as `:(x`
|
|
27
|
+
// would be parsed as pathspec magic. A `./` prefix keeps every path literal.
|
|
28
|
+
async function checkIgnore(cwd: string, args: string[], paths: string[]): Promise<string[]> {
|
|
29
|
+
const input = paths.map((path) => `./${path}\0`).join("");
|
|
30
|
+
let output: string;
|
|
26
31
|
try {
|
|
27
|
-
|
|
32
|
+
output = await git(cwd, [...args, "check-ignore", "--stdin", "-z"], input);
|
|
28
33
|
} catch (error) {
|
|
29
34
|
// `git check-ignore` exits 1 when nothing matched.
|
|
30
|
-
if ((error as { code?: number }).code === 1) return
|
|
35
|
+
if ((error as { code?: number }).code === 1) return [];
|
|
31
36
|
throw error;
|
|
32
37
|
}
|
|
38
|
+
return splitNul(output).map((path) => path.replace(/^\.\//, ""));
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
const splitNul = (s: string) => s.split("\0").filter(Boolean);
|
|
42
|
+
const isDirectory = (entry: string) => entry.endsWith("/");
|
|
36
43
|
|
|
37
44
|
// Copy files that match .worktreeinclude (gitignore syntax)
|
|
38
45
|
// AND are gitignored, so tracked files are never touched.
|
|
39
46
|
export async function copyWorktreeIncludes(worktree: string, source: string): Promise<CopyResult> {
|
|
40
47
|
if (!existsSync(join(source, INCLUDE_FILE))) return { kind: "no-include-file" };
|
|
41
48
|
|
|
42
|
-
const matches =
|
|
43
|
-
await git(source, [
|
|
44
|
-
"ls-files",
|
|
45
|
-
"--others",
|
|
46
|
-
"--ignored",
|
|
47
|
-
`--exclude-from=${INCLUDE_FILE}`,
|
|
48
|
-
"-z",
|
|
49
|
-
]),
|
|
50
|
-
);
|
|
49
|
+
const matches = await findIncludedFiles(source);
|
|
51
50
|
if (matches.length === 0) return { kind: "copied", copied: [], skipped: [] };
|
|
52
51
|
|
|
53
|
-
const ignored =
|
|
54
|
-
await gitAllowExit1(source, ["check-ignore", "--stdin", "-z"], matches.join("\0") + "\0"),
|
|
55
|
-
);
|
|
52
|
+
const ignored = await checkIgnore(source, [], matches);
|
|
56
53
|
|
|
57
54
|
const copied: string[] = [];
|
|
58
55
|
const skipped: string[] = [];
|
|
@@ -69,3 +66,152 @@ export async function copyWorktreeIncludes(worktree: string, source: string): Pr
|
|
|
69
66
|
}
|
|
70
67
|
return { kind: "copied", copied, skipped };
|
|
71
68
|
}
|
|
69
|
+
|
|
70
|
+
// Git lists a directory it ignores as a whole, such as node_modules/, as one entry.
|
|
71
|
+
// Only directories that a pattern matches or names a path inside are searched, and
|
|
72
|
+
// only as deep as the pattern names, so creating a worktree does not walk every file
|
|
73
|
+
// in large ignored trees.
|
|
74
|
+
async function findIncludedFiles(source: string): Promise<string[]> {
|
|
75
|
+
const ignored = splitNul(
|
|
76
|
+
await git(source, [
|
|
77
|
+
"ls-files",
|
|
78
|
+
"--others",
|
|
79
|
+
"--ignored",
|
|
80
|
+
"--exclude-standard",
|
|
81
|
+
"--directory",
|
|
82
|
+
"-z",
|
|
83
|
+
]),
|
|
84
|
+
);
|
|
85
|
+
if (ignored.length === 0) return [];
|
|
86
|
+
|
|
87
|
+
const ignoreCase = await sourceIgnoresCase(source);
|
|
88
|
+
const patterns = parsePatterns(await readFile(join(source, INCLUDE_FILE), "utf8"));
|
|
89
|
+
const matched = new Set(await matchIncludePatterns(source, ignored, ignoreCase));
|
|
90
|
+
const files = ignored.filter((entry) => !isDirectory(entry) && matched.has(entry));
|
|
91
|
+
const searched = new Set<string>();
|
|
92
|
+
// Git also lists an untracked folder that holds ignored entries, which are listed on
|
|
93
|
+
// their own, so only folders Git ignores as a whole are searched.
|
|
94
|
+
const directories = await checkIgnore(source, [], ignored.filter(isDirectory));
|
|
95
|
+
for (const directory of directories) {
|
|
96
|
+
if (matched.has(directory)) {
|
|
97
|
+
searched.add(directory);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
for (const pattern of patterns) {
|
|
101
|
+
const inside = searchedPathInside(pattern, directory, ignoreCase);
|
|
102
|
+
if (inside !== null) searched.add(inside);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (searched.size === 0) return files;
|
|
106
|
+
|
|
107
|
+
const pathspecs = [...searched].map(
|
|
108
|
+
(path) => `:(${ignoreCase ? "literal,icase" : "literal"})${path}`,
|
|
109
|
+
);
|
|
110
|
+
const inside: string[] = [];
|
|
111
|
+
for (const batch of commandLineBatches(pathspecs)) {
|
|
112
|
+
const listed = await git(source, [
|
|
113
|
+
"ls-files",
|
|
114
|
+
"--others",
|
|
115
|
+
"--ignored",
|
|
116
|
+
`--exclude-from=${INCLUDE_FILE}`,
|
|
117
|
+
"-z",
|
|
118
|
+
"--",
|
|
119
|
+
...batch,
|
|
120
|
+
]);
|
|
121
|
+
inside.push(...splitNul(listed));
|
|
122
|
+
}
|
|
123
|
+
return [...new Set([...files, ...inside])];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Windows caps a command line at 32,767 characters, so a pattern such as `**/.env` in a
|
|
127
|
+
// repo with many ignored folders searches them over several Git calls.
|
|
128
|
+
const COMMAND_LINE_BATCH_CHARS = 16_000;
|
|
129
|
+
|
|
130
|
+
function commandLineBatches(args: string[]): string[][] {
|
|
131
|
+
const batches: string[][] = [];
|
|
132
|
+
let batch: string[] = [];
|
|
133
|
+
let length = 0;
|
|
134
|
+
for (const arg of args) {
|
|
135
|
+
if (batch.length > 0 && length + arg.length + 1 > COMMAND_LINE_BATCH_CHARS) {
|
|
136
|
+
batches.push(batch);
|
|
137
|
+
batch = [];
|
|
138
|
+
length = 0;
|
|
139
|
+
}
|
|
140
|
+
batch.push(arg);
|
|
141
|
+
length += arg.length + 1;
|
|
142
|
+
}
|
|
143
|
+
if (batch.length > 0) batches.push(batch);
|
|
144
|
+
return batches;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Match entries against .worktreeinclude alone, in a scratch repository where no other
|
|
148
|
+
// ignore rules apply. Directory entries keep their trailing slash, so directory
|
|
149
|
+
// patterns match them without anything on disk.
|
|
150
|
+
async function matchIncludePatterns(
|
|
151
|
+
source: string,
|
|
152
|
+
entries: string[],
|
|
153
|
+
ignoreCase: boolean,
|
|
154
|
+
): Promise<string[]> {
|
|
155
|
+
const scratch = await mkdtemp(join(tmpdir(), "paseo-worktree-include-"));
|
|
156
|
+
try {
|
|
157
|
+
// An empty template keeps the user's template `info/exclude` out of the matching.
|
|
158
|
+
await git(scratch, ["init", "-q", "--template="]);
|
|
159
|
+
return await checkIgnore(
|
|
160
|
+
scratch,
|
|
161
|
+
[
|
|
162
|
+
"-c",
|
|
163
|
+
`core.excludesFile=${join(source, INCLUDE_FILE)}`,
|
|
164
|
+
"-c",
|
|
165
|
+
`core.ignoreCase=${ignoreCase}`,
|
|
166
|
+
],
|
|
167
|
+
entries,
|
|
168
|
+
);
|
|
169
|
+
} finally {
|
|
170
|
+
await rm(scratch, { recursive: true, force: true });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// The scratch repository would otherwise take core.ignoreCase from the temp folder.
|
|
175
|
+
async function sourceIgnoresCase(source: string): Promise<boolean> {
|
|
176
|
+
try {
|
|
177
|
+
return (await git(source, ["config", "--type=bool", "core.ignoreCase"])).trim() === "true";
|
|
178
|
+
} catch {
|
|
179
|
+
// `git config` exits 1 when the key is unset.
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function parsePatterns(contents: string): string[] {
|
|
185
|
+
// Git skips a leading UTF-8 byte order mark in exclude files.
|
|
186
|
+
return contents
|
|
187
|
+
.replace(/^\uFEFF/, "")
|
|
188
|
+
.split(/\r?\n/)
|
|
189
|
+
.map((line) => line.trimEnd())
|
|
190
|
+
.filter((line) => line !== "" && !line.startsWith("#") && !line.startsWith("!"));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// A pattern with a slash before its end is anchored to the checkout root, so it can
|
|
194
|
+
// name a path inside `directory` when its literal start and the directory overlap.
|
|
195
|
+
// Without `**`, a pattern matches paths of exactly its own depth, so a directory that
|
|
196
|
+
// deep or deeper can hold no match below it. Returns the narrowest path to search: the
|
|
197
|
+
// whole path when the pattern has no glob, else the folder before its first glob, or
|
|
198
|
+
// `directory` itself when the path ends above it.
|
|
199
|
+
function searchedPathInside(
|
|
200
|
+
pattern: string,
|
|
201
|
+
rawDirectory: string,
|
|
202
|
+
ignoreCase: boolean,
|
|
203
|
+
): string | null {
|
|
204
|
+
// Git folds only ASCII letters when it ignores case.
|
|
205
|
+
const fold = (text: string) =>
|
|
206
|
+
ignoreCase ? text.replace(/[A-Z]+/g, (letters) => letters.toLowerCase()) : text;
|
|
207
|
+
const path = fold(pattern.replace(/^\//, ""));
|
|
208
|
+
const directory = fold(rawDirectory);
|
|
209
|
+
const depth = (text: string) => text.replace(/\/$/, "").split("/").length;
|
|
210
|
+
if (depth(path) < 2) return null;
|
|
211
|
+
if (!path.includes("**") && depth(directory) >= depth(path)) return null;
|
|
212
|
+
const globAt = path.search(/[*?[\\]/);
|
|
213
|
+
const literal = globAt === -1 ? path : path.slice(0, globAt);
|
|
214
|
+
if (!literal.startsWith(directory) && !directory.startsWith(literal)) return null;
|
|
215
|
+
const searched = globAt === -1 ? literal : literal.slice(0, literal.lastIndexOf("/") + 1);
|
|
216
|
+
return searched.length > directory.length ? searched : directory;
|
|
217
|
+
}
|
|
@@ -3606,7 +3606,8 @@ export class AgentManager {
|
|
|
3606
3606
|
this.traceHandleStreamEventStart(agent, event, eventTurnId, isForegroundEvent);
|
|
3607
3607
|
if (eventTurnId &&
|
|
3608
3608
|
isTurnTerminalEvent(event) &&
|
|
3609
|
-
this.runs.hasFinalizedTurn(agent, eventTurnId)
|
|
3609
|
+
this.runs.hasFinalizedTurn(agent, eventTurnId) &&
|
|
3610
|
+
this.runs.getTurnId(agent.id) !== eventTurnId) {
|
|
3610
3611
|
return false;
|
|
3611
3612
|
}
|
|
3612
3613
|
// Only update timestamp for live events, not history replay
|
|
@@ -1715,6 +1715,14 @@ class ClaudeAgentSession {
|
|
|
1715
1715
|
this.pendingPermissions = new Map();
|
|
1716
1716
|
this.activeForegroundTurnId = null;
|
|
1717
1717
|
this.autonomousTurn = null;
|
|
1718
|
+
/**
|
|
1719
|
+
* The turn the last background task notification started. A notification that arrives while no
|
|
1720
|
+
* turn runs starts a turn, and Claude's next run belongs to it unless Claude announces another
|
|
1721
|
+
* start first: a later notification starts the next turn, and a queued command (the user's
|
|
1722
|
+
* message, a scheduled wake-up) starts its own. When Claude does not respond, the notification is
|
|
1723
|
+
* a turn in itself. See observeNotificationTurn.
|
|
1724
|
+
*/
|
|
1725
|
+
this.notificationTurnId = null;
|
|
1718
1726
|
this.subscribers = new Set();
|
|
1719
1727
|
this.timelineAssembler = new TimelineAssembler();
|
|
1720
1728
|
this.taskState = new ClaudeTaskState();
|
|
@@ -1992,6 +2000,7 @@ class ClaudeAgentSession {
|
|
|
1992
2000
|
this.rememberRewindUserAnchor(sdkUserMessageId);
|
|
1993
2001
|
const turnId = this.createTurnId("foreground");
|
|
1994
2002
|
this.activeForegroundTurnId = turnId;
|
|
2003
|
+
this.notificationTurnId = null;
|
|
1995
2004
|
this.foregroundHasVisibleActivity = false;
|
|
1996
2005
|
this.activeTurnHasAssistantText = false;
|
|
1997
2006
|
this.withheldErrorReply = [];
|
|
@@ -2061,7 +2070,10 @@ class ClaudeAgentSession {
|
|
|
2061
2070
|
return { status: "unavailable" };
|
|
2062
2071
|
}
|
|
2063
2072
|
const activeTurnId = this.activeForegroundTurnId ?? this.autonomousTurn?.id;
|
|
2064
|
-
|
|
2073
|
+
// A compacting turn still takes a steer: Claude Code holds a `next` message until the
|
|
2074
|
+
// compaction finishes. Refusing it makes the manager replace the turn, and that interrupt
|
|
2075
|
+
// cancels the compaction.
|
|
2076
|
+
if (activeTurnId !== options.expectedTurnId) {
|
|
2065
2077
|
return { status: "unavailable" };
|
|
2066
2078
|
}
|
|
2067
2079
|
// Capture both ends of the live SDK stream before creating or delivering the message. There
|
|
@@ -2455,6 +2467,7 @@ class ClaudeAgentSession {
|
|
|
2455
2467
|
this.activeForegroundQuery = null;
|
|
2456
2468
|
this.activeForegroundInput = null;
|
|
2457
2469
|
this.autonomousTurn = null;
|
|
2470
|
+
this.notificationTurnId = null;
|
|
2458
2471
|
this.cancelCurrentTurn = null;
|
|
2459
2472
|
this.turnState = "idle";
|
|
2460
2473
|
this.sidechainTracker.clear();
|
|
@@ -3360,8 +3373,9 @@ class ClaudeAgentSession {
|
|
|
3360
3373
|
return;
|
|
3361
3374
|
}
|
|
3362
3375
|
this.autonomousTurn = {
|
|
3363
|
-
id: this.createTurnId("autonomous"),
|
|
3376
|
+
id: this.notificationTurnId ?? this.createTurnId("autonomous"),
|
|
3364
3377
|
};
|
|
3378
|
+
this.notificationTurnId = null;
|
|
3365
3379
|
this.activeForegroundQuery = this.query;
|
|
3366
3380
|
this.activeForegroundInput = this.input;
|
|
3367
3381
|
this.activeTurnHasAssistantText = false;
|
|
@@ -3602,6 +3616,22 @@ class ClaudeAgentSession {
|
|
|
3602
3616
|
this.mainTurnInFlight = true;
|
|
3603
3617
|
}
|
|
3604
3618
|
}
|
|
3619
|
+
/**
|
|
3620
|
+
* Tracks notificationTurnId from the starts Claude announces between turns. A task a subagent
|
|
3621
|
+
* started reports to that subagent, so its notification starts no main-session turn.
|
|
3622
|
+
*/
|
|
3623
|
+
observeNotificationTurn(message) {
|
|
3624
|
+
if (this.activeForegroundTurnId || this.autonomousTurn)
|
|
3625
|
+
return;
|
|
3626
|
+
if (message.type === "system" && message.subtype === "task_notification") {
|
|
3627
|
+
if (this.taskProtocolSource.resolveTaskOwner(message.task_id, message.tool_use_id))
|
|
3628
|
+
return;
|
|
3629
|
+
this.notificationTurnId = this.createTurnId("autonomous");
|
|
3630
|
+
}
|
|
3631
|
+
else if (readClaudeCommandLifecycle(message)?.state === "started") {
|
|
3632
|
+
this.notificationTurnId = null;
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3605
3635
|
/**
|
|
3606
3636
|
* Only the main session's own turn start opens an autonomous turn. Everything a background
|
|
3607
3637
|
* subagent emits (its task frames, its own background jobs' notifications, rate limit events)
|
|
@@ -3618,6 +3648,7 @@ class ClaudeAgentSession {
|
|
|
3618
3648
|
return;
|
|
3619
3649
|
}
|
|
3620
3650
|
this.observeMainTurnBracket(message);
|
|
3651
|
+
this.observeNotificationTurn(message);
|
|
3621
3652
|
if (this.shouldSuppressStaleResult(message)) {
|
|
3622
3653
|
return;
|
|
3623
3654
|
}
|
|
@@ -4082,6 +4113,7 @@ class ClaudeAgentSession {
|
|
|
4082
4113
|
type: "timeline",
|
|
4083
4114
|
item: taskNotificationItem,
|
|
4084
4115
|
provider: "claude",
|
|
4116
|
+
...(this.notificationTurnId ? { turnId: this.notificationTurnId } : {}),
|
|
4085
4117
|
});
|
|
4086
4118
|
}
|
|
4087
4119
|
}
|
|
@@ -162,6 +162,7 @@ export declare class OmpAgentSession implements AgentSession {
|
|
|
162
162
|
private handleExtensionUiRequest;
|
|
163
163
|
private mapExtensionUiSideEffect;
|
|
164
164
|
private handleCommandOutput;
|
|
165
|
+
private handleThinkingLevelChanged;
|
|
165
166
|
private handleExtraRuntimeEvent;
|
|
166
167
|
private emitActiveToolCall;
|
|
167
168
|
private emitTodoItem;
|
|
@@ -1288,7 +1288,29 @@ export class OmpAgentSession {
|
|
|
1288
1288
|
item: { type: "assistant_message", text },
|
|
1289
1289
|
});
|
|
1290
1290
|
}
|
|
1291
|
+
// OMP changes the level on its own, e.g. `/switch @role` or a model switch that carries a level.
|
|
1292
|
+
handleThinkingLevelChanged(event) {
|
|
1293
|
+
if (event.type !== "thinking_level_changed") {
|
|
1294
|
+
return false;
|
|
1295
|
+
}
|
|
1296
|
+
const thinkingLevel = normalizeOmpThinkingOption(event.configured ?? event.thinkingLevel);
|
|
1297
|
+
if (!thinkingLevel || thinkingLevel === this.lastKnownThinkingOptionId) {
|
|
1298
|
+
return true;
|
|
1299
|
+
}
|
|
1300
|
+
this.lastKnownThinkingOptionId = thinkingLevel;
|
|
1301
|
+
this.config.thinkingOptionId = thinkingLevel;
|
|
1302
|
+
this.state = { ...this.state, thinkingLevel };
|
|
1303
|
+
this.emit({
|
|
1304
|
+
type: "thinking_option_changed",
|
|
1305
|
+
provider: this.provider,
|
|
1306
|
+
thinkingOptionId: thinkingLevel,
|
|
1307
|
+
});
|
|
1308
|
+
return true;
|
|
1309
|
+
}
|
|
1291
1310
|
handleExtraRuntimeEvent(event) {
|
|
1311
|
+
if (this.handleThinkingLevelChanged(event)) {
|
|
1312
|
+
return true;
|
|
1313
|
+
}
|
|
1292
1314
|
if (event.type === "model_changed") {
|
|
1293
1315
|
void this.refreshState()
|
|
1294
1316
|
.then(() => this.emit({
|
|
@@ -2139,6 +2139,10 @@ export declare const OmpRuntimeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
2139
2139
|
}, z.core.$loose>;
|
|
2140
2140
|
}, z.core.$loose>, z.ZodObject<{
|
|
2141
2141
|
type: z.ZodLiteral<"model_changed">;
|
|
2142
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
2143
|
+
type: z.ZodLiteral<"thinking_level_changed">;
|
|
2144
|
+
thinkingLevel: z.ZodOptional<z.ZodString>;
|
|
2145
|
+
configured: z.ZodOptional<z.ZodString>;
|
|
2142
2146
|
}, z.core.$loose>], "type">;
|
|
2143
2147
|
export declare const OmpRpcCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2144
2148
|
type: z.ZodLiteral<"prompt">;
|
|
@@ -508,6 +508,14 @@ export const OmpRuntimeEventSchema = z.discriminatedUnion("type", [
|
|
|
508
508
|
OmpRpcHostToolCancelRequestSchema,
|
|
509
509
|
OmpRpcHostToolUpdateSchema,
|
|
510
510
|
z.object({ type: z.literal("model_changed") }).passthrough(),
|
|
511
|
+
z
|
|
512
|
+
.object({
|
|
513
|
+
type: z.literal("thinking_level_changed"),
|
|
514
|
+
thinkingLevel: z.string().optional(),
|
|
515
|
+
// The user's selector ("auto") when it differs from the level OMP runs.
|
|
516
|
+
configured: z.string().optional(),
|
|
517
|
+
})
|
|
518
|
+
.passthrough(),
|
|
511
519
|
]);
|
|
512
520
|
const OmpCommandBase = { id: z.string().optional() };
|
|
513
521
|
export const OmpRpcCommandSchema = z.discriminatedUnion("type", [
|
|
@@ -1535,6 +1535,12 @@ function createToolCatalog(options, scope) {
|
|
|
1535
1535
|
};
|
|
1536
1536
|
return response;
|
|
1537
1537
|
});
|
|
1538
|
+
// Match the WebSocket snapshot: idle agents can still own background work.
|
|
1539
|
+
async function projectLiveAgent(agent) {
|
|
1540
|
+
const snapshot = await serializeSnapshotWithMetadata(agentStorage, agent, childLogger);
|
|
1541
|
+
const backgroundWork = agentManager.getAgentBackgroundWorkSummary(agent.id);
|
|
1542
|
+
return backgroundWork ? { ...snapshot, backgroundWork } : snapshot;
|
|
1543
|
+
}
|
|
1538
1544
|
registerTool("get_agent_status", {
|
|
1539
1545
|
title: "Get agent status",
|
|
1540
1546
|
description: "Return the latest snapshot for an agent, including lifecycle state, capabilities, and pending permissions.",
|
|
@@ -1548,7 +1554,7 @@ function createToolCatalog(options, scope) {
|
|
|
1548
1554
|
}, async ({ agentId }) => {
|
|
1549
1555
|
const snapshot = agentManager.getAgent(agentId);
|
|
1550
1556
|
if (snapshot) {
|
|
1551
|
-
const structuredSnapshot = await
|
|
1557
|
+
const structuredSnapshot = await projectLiveAgent(snapshot);
|
|
1552
1558
|
return {
|
|
1553
1559
|
content: [],
|
|
1554
1560
|
structuredContent: ensureValidJson({
|
|
@@ -1599,7 +1605,7 @@ function createToolCatalog(options, scope) {
|
|
|
1599
1605
|
manager: agentManager,
|
|
1600
1606
|
storage: agentStorage,
|
|
1601
1607
|
workspaces: options.workspaceRegistry,
|
|
1602
|
-
projectLive:
|
|
1608
|
+
projectLive: projectLiveAgent,
|
|
1603
1609
|
projectStored: (record) => buildStoredAgentPayload(record, new Set(providerSnapshotManager.listRegisteredProviderIds()), (provider, own) => agentManager.effectiveOptionsFor(provider, own)),
|
|
1604
1610
|
isProviderVisible: () => true,
|
|
1605
1611
|
isStoredProviderAvailable: (record) => isStoredAgentProviderAvailable(record, new Set(providerSnapshotManager.listRegisteredProviderIds())),
|
|
@@ -96,7 +96,7 @@ export async function fanOutReconciledWorkspaceUpdates(input) {
|
|
|
96
96
|
}
|
|
97
97
|
}));
|
|
98
98
|
}
|
|
99
|
-
import { VoiceAssistantWebSocketServer } from "./websocket-server.js";
|
|
99
|
+
import { VoiceAssistantWebSocketServer, isDaemonOriginAllowed } from "./websocket-server.js";
|
|
100
100
|
import { WorkspaceSetupRuntime } from "./workspace-setup-runtime.js";
|
|
101
101
|
import { createWorkspaceLabelService } from "./workspace-labels/index.js";
|
|
102
102
|
import { createGitHubService } from "../services/github-service.js";
|
|
@@ -515,7 +515,7 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
|
|
|
515
515
|
});
|
|
516
516
|
app.use((req, res, next) => {
|
|
517
517
|
const origin = req.headers.origin;
|
|
518
|
-
if (origin && (
|
|
518
|
+
if (origin && isDaemonOriginAllowed(origin, req.headers.host ?? null, allowedOrigins)) {
|
|
519
519
|
res.setHeader("Access-Control-Allow-Origin", origin);
|
|
520
520
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
521
521
|
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
|
|
@@ -36,7 +36,20 @@ class FileObserverService {
|
|
|
36
36
|
createBackend: this.createBackend,
|
|
37
37
|
onClosed: () => state.observations.delete(observation),
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
const { signal } = options;
|
|
40
|
+
signal?.throwIfAborted();
|
|
41
|
+
const abort = () => void observation.close();
|
|
42
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
43
|
+
try {
|
|
44
|
+
await observation.start();
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
signal?.removeEventListener("abort", abort);
|
|
48
|
+
}
|
|
49
|
+
if (signal?.aborted) {
|
|
50
|
+
await observation.close();
|
|
51
|
+
throw signal.reason;
|
|
52
|
+
}
|
|
40
53
|
if (this.closePromise) {
|
|
41
54
|
await observation.close();
|
|
42
55
|
throw new Error("File observer is closed");
|
|
@@ -21,6 +21,10 @@ class Observation {
|
|
|
21
21
|
if (!rootStats.isDirectory()) {
|
|
22
22
|
throw new Error(`File observation requires a directory: ${this.root}`);
|
|
23
23
|
}
|
|
24
|
+
// An aborted subscription can close the observation while the root is being read; the backend
|
|
25
|
+
// must not start after its close has already finished.
|
|
26
|
+
if (!this.isActive())
|
|
27
|
+
return;
|
|
24
28
|
try {
|
|
25
29
|
await this.backend.start();
|
|
26
30
|
}
|
|
@@ -148,7 +148,7 @@ export class HubRelationshipController {
|
|
|
148
148
|
}
|
|
149
149
|
async start() {
|
|
150
150
|
if (this.record?.state === "active")
|
|
151
|
-
this.openSocket(
|
|
151
|
+
this.openSocket(false);
|
|
152
152
|
if (this.record?.state === "pending") {
|
|
153
153
|
const enrollmentGeneration = this.beginEnrollmentAttempt();
|
|
154
154
|
try {
|
|
@@ -322,7 +322,7 @@ export class HubRelationshipController {
|
|
|
322
322
|
this.record = active;
|
|
323
323
|
this.retry = null;
|
|
324
324
|
this.retryAttempt = 0;
|
|
325
|
-
this.openSocket(
|
|
325
|
+
this.openSocket(false);
|
|
326
326
|
}
|
|
327
327
|
catch (error) {
|
|
328
328
|
if (enrollmentGeneration !== this.enrollmentGeneration)
|
|
@@ -338,14 +338,17 @@ export class HubRelationshipController {
|
|
|
338
338
|
this.inFlightEnrollments.delete(settled);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
|
-
openSocket(
|
|
341
|
+
openSocket(reconnecting) {
|
|
342
|
+
const record = this.record;
|
|
343
|
+
if (record?.state !== "active")
|
|
344
|
+
return;
|
|
342
345
|
const generation = ++this.generation;
|
|
343
346
|
this.state = reconnecting ? "reconnecting" : "connecting";
|
|
344
347
|
const events = {
|
|
345
|
-
connected: (socket, sessionProtocol) => this.socketConnected(generation,
|
|
348
|
+
connected: (socket, sessionProtocol) => this.socketConnected(generation, socket, sessionProtocol),
|
|
346
349
|
rejected: (statusCode) => this.socketRejected(generation, statusCode),
|
|
347
|
-
closed: (code) => this.socketClosed(generation,
|
|
348
|
-
failed: (error) => this.socketFailed(generation,
|
|
350
|
+
closed: (code, reason) => this.socketClosed(generation, code, reason),
|
|
351
|
+
failed: (error) => this.socketFailed(generation, error),
|
|
349
352
|
};
|
|
350
353
|
this.socket = this.options.remote.openSocket({
|
|
351
354
|
daemonId: record.relationship.daemonId,
|
|
@@ -353,12 +356,12 @@ export class HubRelationshipController {
|
|
|
353
356
|
credential: record.credential.secret,
|
|
354
357
|
}, events);
|
|
355
358
|
}
|
|
356
|
-
socketConnected(generation,
|
|
357
|
-
|
|
359
|
+
socketConnected(generation, socket, sessionProtocol) {
|
|
360
|
+
const record = this.record;
|
|
361
|
+
if (generation !== this.generation || record?.state !== "active") {
|
|
358
362
|
socket.close();
|
|
359
363
|
return;
|
|
360
364
|
}
|
|
361
|
-
this.retryAttempt = 0;
|
|
362
365
|
this.state = "connected";
|
|
363
366
|
this.connectedAt = this.clock.now().toISOString();
|
|
364
367
|
this.lastError = null;
|
|
@@ -387,26 +390,34 @@ export class HubRelationshipController {
|
|
|
387
390
|
return;
|
|
388
391
|
this.revoke(`Hub rejected socket authentication (${statusCode})`);
|
|
389
392
|
}
|
|
390
|
-
socketClosed(generation,
|
|
393
|
+
socketClosed(generation, code, reason) {
|
|
391
394
|
if (generation !== this.generation)
|
|
392
395
|
return;
|
|
396
|
+
if (code === 4403 && reason === "daemon session permissions do not match enrollment") {
|
|
397
|
+
this.lastError =
|
|
398
|
+
"Hub and daemon permissions differ. Run `paseo hub permissions grant <permission>` or `paseo hub permissions revoke <permission>` on this daemon to reapply your intended permissions.";
|
|
399
|
+
this.scheduleSocket(true);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
393
402
|
if (code === 4403) {
|
|
394
403
|
this.revoke("Hub revoked this relationship");
|
|
395
404
|
return;
|
|
396
405
|
}
|
|
397
406
|
if (this.record?.state === "active")
|
|
398
|
-
this.scheduleSocket(
|
|
407
|
+
this.scheduleSocket();
|
|
399
408
|
}
|
|
400
|
-
socketFailed(generation,
|
|
409
|
+
socketFailed(generation, error) {
|
|
401
410
|
if (generation !== this.generation)
|
|
402
411
|
return;
|
|
403
412
|
this.lastError = error.message;
|
|
404
413
|
if (this.record?.state === "active")
|
|
405
|
-
this.scheduleSocket(
|
|
414
|
+
this.scheduleSocket();
|
|
406
415
|
}
|
|
407
|
-
scheduleSocket(
|
|
416
|
+
scheduleSocket(permissionMismatch = false) {
|
|
417
|
+
if (this.state === "connected" && !permissionMismatch)
|
|
418
|
+
this.retryAttempt = 0;
|
|
408
419
|
this.state = "reconnecting";
|
|
409
|
-
this.schedule(() => this.openSocket(
|
|
420
|
+
this.schedule(() => this.openSocket(true));
|
|
410
421
|
}
|
|
411
422
|
scheduleEnrollment(record, enrollmentGeneration) {
|
|
412
423
|
if (enrollmentGeneration !== this.enrollmentGeneration)
|
|
@@ -34,7 +34,7 @@ export interface HubSocketCredentials {
|
|
|
34
34
|
export interface HubSocketEvents {
|
|
35
35
|
connected(socket: WebSocketLike, sessionProtocol: "legacy" | "session-v1"): void;
|
|
36
36
|
rejected(statusCode: 401 | 403): void;
|
|
37
|
-
closed(code: number): void;
|
|
37
|
+
closed(code: number, reason?: string): void;
|
|
38
38
|
failed(error: Error): void;
|
|
39
39
|
}
|
|
40
40
|
export interface HubSocketConnection {
|
|
@@ -160,12 +160,12 @@ export class DirectHubRelationshipRemote {
|
|
|
160
160
|
}
|
|
161
161
|
events.closed(1006);
|
|
162
162
|
});
|
|
163
|
-
socket.once("close", (code) => {
|
|
163
|
+
socket.once("close", (code, reason) => {
|
|
164
164
|
stopHeartbeat();
|
|
165
165
|
if (settled)
|
|
166
166
|
return;
|
|
167
167
|
settled = true;
|
|
168
|
-
events.closed(code);
|
|
168
|
+
events.closed(code, reason.toString());
|
|
169
169
|
});
|
|
170
170
|
socket.once("error", fail);
|
|
171
171
|
return socket;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ForgeService } from "../services/forge-service.js";
|
|
2
2
|
import type { WorktreeSource } from "../utils/worktree.js";
|
|
3
3
|
export type WorktreeCreationIntent = Exclude<WorktreeSource, {
|
|
4
|
-
kind: "restore" | "restore-from-base";
|
|
4
|
+
kind: "restore" | "restore-from-base" | "restore-commit";
|
|
5
5
|
}>;
|
|
6
6
|
export interface ResolveWorktreeCreationIntentInput {
|
|
7
7
|
worktreeSlug?: string;
|