@getpaseo/server 0.16.0 → 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 +9 -16
- package/dist/server/server/agent/providers/claude/agent.d.ts +1 -0
- package/dist/server/server/agent/providers/claude/agent.js +41 -7
- package/dist/server/server/agent/providers/claude/bypass-approval.d.ts +5 -0
- package/dist/server/server/agent/providers/claude/bypass-approval.js +37 -0
- package/dist/server/server/agent/providers/claude/model-discovery.d.ts +2 -0
- package/dist/server/server/agent/providers/claude/model-discovery.js +55 -11
- package/dist/server/server/agent/providers/codex-app-server-agent.js +3 -0
- package/dist/server/server/agent/providers/model-label.d.ts +5 -0
- package/dist/server/server/agent/providers/model-label.js +21 -0
- package/dist/server/server/agent/providers/omp/agent.d.ts +2 -2
- package/dist/server/server/agent/providers/omp/agent.js +23 -26
- package/dist/server/server/agent/providers/omp/map-omp-model.js +2 -1
- 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/providers/opencode-agent.js +15 -10
- package/dist/server/server/agent/providers/pi/agent.d.ts +1 -2
- package/dist/server/server/agent/providers/pi/agent.js +4 -28
- package/dist/server/server/agent/timeline-projection.d.ts +6 -0
- package/dist/server/server/agent/timeline-projection.js +12 -8
- 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/checkout-git.js +9 -1
- 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-c6834d1a59b83addc7491f02fc3b6494.js → index-3d51f4c450eeff5bd838a646e9c611f2.js} +24 -24
- 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 +7 -7
- package/dist/server/web-ui/_expo/static/js/web/index-c6834d1a59b83addc7491f02fc3b6494.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-c6834d1a59b83addc7491f02fc3b6494.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
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProviderOptionsValidationError } from "./provider-options.js";
|
|
2
2
|
import { AgentNotFoundError, ensureAgentLoaded } from "./agent-loading.js";
|
|
3
|
-
import { projectTimelineRows } from "./timeline-projection.js";
|
|
3
|
+
import { continuesAssistantMessage, projectTimelineRows } from "./timeline-projection.js";
|
|
4
4
|
import { describeHookAgent, publishAgentStream } from "../plugins/lifecycle/index.js";
|
|
5
5
|
import { applyRecordPatch } from "../record-patch.js";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
@@ -2833,25 +2833,17 @@ export class AgentManager {
|
|
|
2833
2833
|
null);
|
|
2834
2834
|
}
|
|
2835
2835
|
getLastAssistantMessageSegmentFromTimeline(timeline) {
|
|
2836
|
-
// Collect the
|
|
2837
|
-
//
|
|
2836
|
+
// Collect the chunks of the last assistant message (Claude streams chunks). A turn the
|
|
2837
|
+
// provider starts on its own has no user message before its reply.
|
|
2838
2838
|
const chunks = [];
|
|
2839
|
-
let replyTurnId;
|
|
2840
2839
|
let startsAtBeginning = false;
|
|
2841
2840
|
for (let i = timeline.length - 1; i >= 0; i--) {
|
|
2842
|
-
const { item
|
|
2843
|
-
if (
|
|
2844
|
-
if (chunks.length) {
|
|
2845
|
-
break;
|
|
2846
|
-
}
|
|
2847
|
-
continue;
|
|
2848
|
-
}
|
|
2849
|
-
if (chunks.length === 0) {
|
|
2850
|
-
replyTurnId = turnId;
|
|
2851
|
-
}
|
|
2852
|
-
else if (turnId !== replyTurnId) {
|
|
2841
|
+
const { item } = timeline[i];
|
|
2842
|
+
if (chunks.length > 0 && !continuesAssistantMessage(timeline[i], timeline[i + 1])) {
|
|
2853
2843
|
break;
|
|
2854
2844
|
}
|
|
2845
|
+
if (item.type !== "assistant_message")
|
|
2846
|
+
continue;
|
|
2855
2847
|
chunks.push(item.text);
|
|
2856
2848
|
startsAtBeginning = i === 0;
|
|
2857
2849
|
}
|
|
@@ -3614,7 +3606,8 @@ export class AgentManager {
|
|
|
3614
3606
|
this.traceHandleStreamEventStart(agent, event, eventTurnId, isForegroundEvent);
|
|
3615
3607
|
if (eventTurnId &&
|
|
3616
3608
|
isTurnTerminalEvent(event) &&
|
|
3617
|
-
this.runs.hasFinalizedTurn(agent, eventTurnId)
|
|
3609
|
+
this.runs.hasFinalizedTurn(agent, eventTurnId) &&
|
|
3610
|
+
this.runs.getTurnId(agent.id) !== eventTurnId) {
|
|
3618
3611
|
return false;
|
|
3619
3612
|
}
|
|
3620
3613
|
// Only update timestamp for live events, not history replay
|
|
@@ -50,6 +50,7 @@ export declare class ClaudeAgentClient implements AgentClient {
|
|
|
50
50
|
resumeSession(handle: AgentPersistenceHandle, overrides?: Partial<AgentSessionConfig>, launchContext?: AgentLaunchContext): Promise<AgentSession>;
|
|
51
51
|
getCatalogCacheKey(_options: FetchCatalogOptions): Promise<string>;
|
|
52
52
|
fetchCatalog(_options: FetchCatalogOptions, context?: ProviderRefreshContext): Promise<ProviderCatalog>;
|
|
53
|
+
shutdown(): Promise<void>;
|
|
53
54
|
resolveDefaultModeId({ env: launchEnv }: ResolveAgentDefaultModeInput): Promise<string>;
|
|
54
55
|
private buildProviderEnv;
|
|
55
56
|
listControls(config: AgentSessionConfig): Promise<AgentDraftControls>;
|
|
@@ -9,6 +9,7 @@ import path from "node:path";
|
|
|
9
9
|
import { LRUCache } from "lru-cache";
|
|
10
10
|
import stripAnsi from "strip-ansi";
|
|
11
11
|
import { createImportDescriptorScheduler } from "./import-descriptor-scheduler.js";
|
|
12
|
+
import { bypassApprovesAsk } from "./bypass-approval.js";
|
|
12
13
|
import { mapClaudeCanceledToolCall, mapClaudeCompletedToolCall, mapClaudeFailedToolCall, mapClaudeRunningToolCall, } from "./tool-call-mapper.js";
|
|
13
14
|
import { mapTaskNotificationSystemRecordToToolCall, mapTaskNotificationUserContentToToolCall, readTaskNotificationToolUseIdFromHistoryRecord, readTaskNotificationFromHistoryRecord, } from "./task-notification-tool-call.js";
|
|
14
15
|
import { isClaudeInterruptPlaceholderText } from "./interrupt-placeholder.js";
|
|
@@ -32,7 +33,7 @@ import { buildBinaryDiagnosticRows, buildCommandResolutionDiagnosticRows, format
|
|
|
32
33
|
import { appendOrReplaceGrowingAssistantMessage, runProviderTurn } from "../provider-runner.js";
|
|
33
34
|
import { applyClaudeToolPolicy, ClaudeProviderOptionsSchema, } from "./options.js";
|
|
34
35
|
import { renderPromptAttachmentAsText } from "../../prompt-attachments.js";
|
|
35
|
-
import { discoverClaudeModels } from "./model-discovery.js";
|
|
36
|
+
import { discoverClaudeModels, killExitingClaudeModelDiscoveries } from "./model-discovery.js";
|
|
36
37
|
import { claudeQuery } from "./query.js";
|
|
37
38
|
import { findSteeredMessageParent, realClaudeRewindSdk, revertClaudeConversation, revertClaudeFiles, } from "./rewind.js";
|
|
38
39
|
import { normalizeProviderReplayTimestamp } from "../../provider-history-timestamps.js";
|
|
@@ -1229,6 +1230,9 @@ export class ClaudeAgentClient {
|
|
|
1229
1230
|
...modeCatalog,
|
|
1230
1231
|
};
|
|
1231
1232
|
}
|
|
1233
|
+
async shutdown() {
|
|
1234
|
+
await killExitingClaudeModelDiscoveries();
|
|
1235
|
+
}
|
|
1232
1236
|
async resolveDefaultModeId({ env: launchEnv }) {
|
|
1233
1237
|
return claudeModeCatalog(this.buildProviderEnv(launchEnv)).defaultModeId;
|
|
1234
1238
|
}
|
|
@@ -1711,6 +1715,14 @@ class ClaudeAgentSession {
|
|
|
1711
1715
|
this.pendingPermissions = new Map();
|
|
1712
1716
|
this.activeForegroundTurnId = null;
|
|
1713
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;
|
|
1714
1726
|
this.subscribers = new Set();
|
|
1715
1727
|
this.timelineAssembler = new TimelineAssembler();
|
|
1716
1728
|
this.taskState = new ClaudeTaskState();
|
|
@@ -1782,10 +1794,8 @@ class ClaudeAgentSession {
|
|
|
1782
1794
|
this.closed = false;
|
|
1783
1795
|
this.openOptionsPatch = {};
|
|
1784
1796
|
this.handlePermissionRequest = async (toolName, input, options) => {
|
|
1785
|
-
// Decide before publishing anything: bypassed
|
|
1786
|
-
|
|
1787
|
-
const needsUserAnswer = toolName === "AskUserQuestion" || toolName === "ExitPlanMode";
|
|
1788
|
-
if (this.currentMode === "bypassPermissions" && !needsUserAnswer) {
|
|
1797
|
+
// Decide before publishing anything: bypassed asks never enter the permission UI.
|
|
1798
|
+
if (this.currentMode === "bypassPermissions" && bypassApprovesAsk(toolName, options)) {
|
|
1789
1799
|
return { behavior: "allow", updatedInput: input, toolUseID: options.toolUseID };
|
|
1790
1800
|
}
|
|
1791
1801
|
const requestId = `permission-${randomUUID()}`;
|
|
@@ -1990,6 +2000,7 @@ class ClaudeAgentSession {
|
|
|
1990
2000
|
this.rememberRewindUserAnchor(sdkUserMessageId);
|
|
1991
2001
|
const turnId = this.createTurnId("foreground");
|
|
1992
2002
|
this.activeForegroundTurnId = turnId;
|
|
2003
|
+
this.notificationTurnId = null;
|
|
1993
2004
|
this.foregroundHasVisibleActivity = false;
|
|
1994
2005
|
this.activeTurnHasAssistantText = false;
|
|
1995
2006
|
this.withheldErrorReply = [];
|
|
@@ -2059,7 +2070,10 @@ class ClaudeAgentSession {
|
|
|
2059
2070
|
return { status: "unavailable" };
|
|
2060
2071
|
}
|
|
2061
2072
|
const activeTurnId = this.activeForegroundTurnId ?? this.autonomousTurn?.id;
|
|
2062
|
-
|
|
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) {
|
|
2063
2077
|
return { status: "unavailable" };
|
|
2064
2078
|
}
|
|
2065
2079
|
// Capture both ends of the live SDK stream before creating or delivering the message. There
|
|
@@ -2453,6 +2467,7 @@ class ClaudeAgentSession {
|
|
|
2453
2467
|
this.activeForegroundQuery = null;
|
|
2454
2468
|
this.activeForegroundInput = null;
|
|
2455
2469
|
this.autonomousTurn = null;
|
|
2470
|
+
this.notificationTurnId = null;
|
|
2456
2471
|
this.cancelCurrentTurn = null;
|
|
2457
2472
|
this.turnState = "idle";
|
|
2458
2473
|
this.sidechainTracker.clear();
|
|
@@ -3358,8 +3373,9 @@ class ClaudeAgentSession {
|
|
|
3358
3373
|
return;
|
|
3359
3374
|
}
|
|
3360
3375
|
this.autonomousTurn = {
|
|
3361
|
-
id: this.createTurnId("autonomous"),
|
|
3376
|
+
id: this.notificationTurnId ?? this.createTurnId("autonomous"),
|
|
3362
3377
|
};
|
|
3378
|
+
this.notificationTurnId = null;
|
|
3363
3379
|
this.activeForegroundQuery = this.query;
|
|
3364
3380
|
this.activeForegroundInput = this.input;
|
|
3365
3381
|
this.activeTurnHasAssistantText = false;
|
|
@@ -3600,6 +3616,22 @@ class ClaudeAgentSession {
|
|
|
3600
3616
|
this.mainTurnInFlight = true;
|
|
3601
3617
|
}
|
|
3602
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
|
+
}
|
|
3603
3635
|
/**
|
|
3604
3636
|
* Only the main session's own turn start opens an autonomous turn. Everything a background
|
|
3605
3637
|
* subagent emits (its task frames, its own background jobs' notifications, rate limit events)
|
|
@@ -3616,6 +3648,7 @@ class ClaudeAgentSession {
|
|
|
3616
3648
|
return;
|
|
3617
3649
|
}
|
|
3618
3650
|
this.observeMainTurnBracket(message);
|
|
3651
|
+
this.observeNotificationTurn(message);
|
|
3619
3652
|
if (this.shouldSuppressStaleResult(message)) {
|
|
3620
3653
|
return;
|
|
3621
3654
|
}
|
|
@@ -4080,6 +4113,7 @@ class ClaudeAgentSession {
|
|
|
4080
4113
|
type: "timeline",
|
|
4081
4114
|
item: taskNotificationItem,
|
|
4082
4115
|
provider: "claude",
|
|
4116
|
+
...(this.notificationTurnId ? { turnId: this.notificationTurnId } : {}),
|
|
4083
4117
|
});
|
|
4084
4118
|
}
|
|
4085
4119
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CanUseTool } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
type PermissionOptions = Parameters<CanUseTool>[2];
|
|
3
|
+
export declare function bypassApprovesAsk(toolName: string, options: PermissionOptions): boolean;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=bypass-approval.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// In bypassPermissions, Claude Code still forwards an ask when the user configured one
|
|
2
|
+
// (a permissions.ask rule, including managed policy, or a PreToolUse hook), when the tool
|
|
3
|
+
// needs an answer, or when one of its own checks fires. Bypass approves only Claude's own
|
|
4
|
+
// checks. A missing or unknown reason type stays with the user.
|
|
5
|
+
// `subcommandResults` is left out: a compound or piped command uses it as a container,
|
|
6
|
+
// including when a user's ask rule matched one of its parts. `sandboxOverride` is left
|
|
7
|
+
// out: in Bypass, Claude Code forwards it only when the user's read block or hook raised it.
|
|
8
|
+
const CLAUDE_OWN_CHECK_TYPES = new Set([
|
|
9
|
+
"safetyCheck",
|
|
10
|
+
"workingDir",
|
|
11
|
+
"mode",
|
|
12
|
+
"classifier",
|
|
13
|
+
"asyncAgent",
|
|
14
|
+
]);
|
|
15
|
+
// Settings the user or organization chose, which Claude Code reports under its own types:
|
|
16
|
+
// permissions.blockReadsOutsideWorkingDirectories, and an organization's ask limit.
|
|
17
|
+
const CONFIGURED_ASK_CODES = new Set([
|
|
18
|
+
"outside_reads_blocked",
|
|
19
|
+
"org_ask_ceiling",
|
|
20
|
+
]);
|
|
21
|
+
const QUESTION_TOOLS = new Set(["AskUserQuestion", "ExitPlanMode"]);
|
|
22
|
+
export function bypassApprovesAsk(toolName, options) {
|
|
23
|
+
if (QUESTION_TOOLS.has(toolName) || options.matchedAskRule) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// The SDK forwards these from Claude Code without declaring them on CanUseTool.
|
|
27
|
+
if ("requiresUserInteraction" in options && options.requiresUserInteraction === true) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const reasonCode = "decisionReasonCode" in options ? options.decisionReasonCode : undefined;
|
|
31
|
+
if (typeof reasonCode === "string" && CONFIGURED_ASK_CODES.has(reasonCode)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const reasonType = "decisionReasonType" in options ? options.decisionReasonType : undefined;
|
|
35
|
+
return typeof reasonType === "string" && CLAUDE_OWN_CHECK_TYPES.has(reasonType);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=bypass-approval.js.map
|
|
@@ -9,5 +9,7 @@ interface ClaudeModelDiscoveryOptions {
|
|
|
9
9
|
}
|
|
10
10
|
type OpenDiscoveryQuery = (input: ClaudeQueryInput, context: ClaudeQueryContext) => Pick<Query, "supportedModels" | "close">;
|
|
11
11
|
export declare function discoverClaudeModels(options: ClaudeModelDiscoveryOptions, openQuery?: OpenDiscoveryQuery): Promise<ModelInfo[]>;
|
|
12
|
+
/** Kills discovery processes still exiting after their wait ended. Called on daemon shutdown. */
|
|
13
|
+
export declare function killExitingClaudeModelDiscoveries(): Promise<void>;
|
|
12
14
|
export {};
|
|
13
15
|
//# sourceMappingURL=model-discovery.d.ts.map
|
|
@@ -2,14 +2,19 @@ import os from "node:os";
|
|
|
2
2
|
import { raceProviderRefreshAbort } from "../../provider-refresh-deadline.js";
|
|
3
3
|
import { terminateWithTreeKill } from "../../../../utils/tree-kill.js";
|
|
4
4
|
import { claudeQuery } from "./query.js";
|
|
5
|
+
const DISCOVERY_WAIT_MS = 5000;
|
|
6
|
+
// Long enough for the CLI to finish an OAuth token refresh it started before the wait ended.
|
|
7
|
+
const DISCOVERY_EXIT_GRACE_MS = 60000;
|
|
8
|
+
// Discovery processes left to exit on their own after their caller stopped waiting.
|
|
9
|
+
const exitingDiscoveries = new Map();
|
|
5
10
|
// The curated catalog survives a failed or slow probe. This process never receives
|
|
6
11
|
// a prompt and must not persist a session or launch user MCP servers/hooks.
|
|
7
12
|
export async function discoverClaudeModels(options, openQuery = claudeQuery) {
|
|
8
|
-
const
|
|
13
|
+
const waitController = new AbortController();
|
|
9
14
|
const signal = options.signal
|
|
10
|
-
? AbortSignal.any([options.signal,
|
|
11
|
-
:
|
|
12
|
-
const timer = setTimeout(() =>
|
|
15
|
+
? AbortSignal.any([options.signal, waitController.signal])
|
|
16
|
+
: waitController.signal;
|
|
17
|
+
const timer = setTimeout(() => waitController.abort(new Error("Claude model discovery timed out")), DISCOVERY_WAIT_MS);
|
|
13
18
|
let endInput;
|
|
14
19
|
const ended = new Promise((resolve) => {
|
|
15
20
|
endInput = resolve;
|
|
@@ -41,7 +46,8 @@ export async function discoverClaudeModels(options, openQuery = claudeQuery) {
|
|
|
41
46
|
strictMcpConfig: true,
|
|
42
47
|
settingSources: ["user"],
|
|
43
48
|
settings: { disableAllHooks: true },
|
|
44
|
-
abortController:
|
|
49
|
+
// No abortController: the SDK kills the process when it aborts, and the end of
|
|
50
|
+
// the wait must not.
|
|
45
51
|
},
|
|
46
52
|
}, {
|
|
47
53
|
runtimeSettings: options.runtimeSettings,
|
|
@@ -54,14 +60,52 @@ export async function discoverClaudeModels(options, openQuery = claudeQuery) {
|
|
|
54
60
|
finally {
|
|
55
61
|
clearTimeout(timer);
|
|
56
62
|
endInput();
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
if (query && child && !hasExited(child)) {
|
|
64
|
+
// The CLI may be refreshing an expired OAuth token, even after it has answered.
|
|
65
|
+
// Claude Code rotates the refresh token before saving the new pair, so killing it now
|
|
66
|
+
// leaves a revoked token on disk and logs the user out (#9314). With its input ended
|
|
67
|
+
// it exits once that work is done; the grace period and daemon shutdown bound the wait.
|
|
68
|
+
letDiscoveryExit(query, child);
|
|
59
69
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
await terminateWithTreeKill(child, { gracefulTimeoutMs: 200, forceTimeoutMs: 200 });
|
|
63
|
-
}
|
|
70
|
+
else {
|
|
71
|
+
await retireDiscovery(query, child);
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
}
|
|
75
|
+
/** Kills discovery processes still exiting after their wait ended. Called on daemon shutdown. */
|
|
76
|
+
export async function killExitingClaudeModelDiscoveries() {
|
|
77
|
+
await Promise.all(Array.from(exitingDiscoveries.values(), (kill) => kill()));
|
|
78
|
+
}
|
|
79
|
+
function letDiscoveryExit(query, child) {
|
|
80
|
+
function forget() {
|
|
81
|
+
clearTimeout(graceTimer);
|
|
82
|
+
child.off("exit", onExit);
|
|
83
|
+
exitingDiscoveries.delete(child);
|
|
84
|
+
}
|
|
85
|
+
function onExit() {
|
|
86
|
+
forget();
|
|
87
|
+
query.close();
|
|
88
|
+
}
|
|
89
|
+
async function kill() {
|
|
90
|
+
forget();
|
|
91
|
+
await retireDiscovery(query, child);
|
|
92
|
+
}
|
|
93
|
+
const graceTimer = setTimeout(() => void kill(), DISCOVERY_EXIT_GRACE_MS);
|
|
94
|
+
graceTimer.unref();
|
|
95
|
+
child.once("exit", onExit);
|
|
96
|
+
exitingDiscoveries.set(child, kill);
|
|
97
|
+
}
|
|
98
|
+
async function retireDiscovery(query, child) {
|
|
99
|
+
try {
|
|
100
|
+
query?.close();
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
if (child) {
|
|
104
|
+
await terminateWithTreeKill(child, { gracefulTimeoutMs: 200, forceTimeoutMs: 200 });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function hasExited(child) {
|
|
109
|
+
return child.exitCode !== null || child.signalCode !== null;
|
|
110
|
+
}
|
|
67
111
|
//# sourceMappingURL=model-discovery.js.map
|
|
@@ -4090,6 +4090,9 @@ export class CodexAppServerAgentSession {
|
|
|
4090
4090
|
return this.background.stopItem(id);
|
|
4091
4091
|
}
|
|
4092
4092
|
async canStopRuntime() {
|
|
4093
|
+
// A history session released its app-server once it read the thread, so nothing runs.
|
|
4094
|
+
if (this.connectionState === "history-ready")
|
|
4095
|
+
return true;
|
|
4093
4096
|
if (!this.client ||
|
|
4094
4097
|
this.client.hasPendingRequests() ||
|
|
4095
4098
|
!this.currentThreadId ||
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Drops an upstream "Vendor: " prefix ("OpenAI: GPT-5.5"). A colon inside parentheses or after a
|
|
2
|
+
// comma belongs to the model name ("DeepSeek V4 (ctx: 128k)"), so it is kept.
|
|
3
|
+
function stripVendorPrefix(label) {
|
|
4
|
+
const vendorSeparatorIndex = label.indexOf(": ");
|
|
5
|
+
if (vendorSeparatorIndex === -1 || /[(),]/.test(label.slice(0, vendorSeparatorIndex))) {
|
|
6
|
+
return label;
|
|
7
|
+
}
|
|
8
|
+
return label.slice(vendorSeparatorIndex + 2).trim();
|
|
9
|
+
}
|
|
10
|
+
// The label Pi and OMP show for a model from their catalogs. A model name is either a path
|
|
11
|
+
// ("google/gemini_2.5-flash", as OpenRouter reports it) or free text that can contain slashes
|
|
12
|
+
// and underscores ("IQ3_S ... 52/56"). Only paths are shortened.
|
|
13
|
+
export function modelDisplayLabel(model) {
|
|
14
|
+
const text = model.name?.trim().replace(/\s+/g, " ") || model.id.trim();
|
|
15
|
+
if (/\s/.test(text)) {
|
|
16
|
+
return stripVendorPrefix(text);
|
|
17
|
+
}
|
|
18
|
+
const lastSegment = text.split("/").findLast((segment) => segment.length > 0) ?? text;
|
|
19
|
+
return stripVendorPrefix(lastSegment.replace(/_+/g, " "));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=model-label.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProviderOptions } from "@getpaseo/protocol/agent-types";
|
|
2
2
|
import type { Logger } from "pino";
|
|
3
|
-
import { type AgentCapabilityFlags, type AgentClient, type AgentDraftControls, type AgentOptionControl, type AgentLaunchContext, type AgentMode, type
|
|
3
|
+
import { type AgentCapabilityFlags, type AgentClient, type AgentDraftControls, type AgentOptionControl, type AgentLaunchContext, type AgentMode, type AgentPermissionRequest, type AgentPermissionResponse, type AgentProviderNotice, type AgentPersistenceHandle, type AgentPromptInput, type AgentProvider, type AgentResumeSessionOptions, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type FetchCatalogOptions, type ImportableProviderSession, type ImportProviderSessionContext, type ImportProviderSessionInput, type ListImportableSessionsOptions, type ProviderCatalog, type ProviderRefreshContext, type SteerActiveTurnOptions, type SteerResult } from "../../agent-sdk-types.js";
|
|
4
4
|
import { type ProviderRuntimeSettings } from "../../provider-launch-config.js";
|
|
5
5
|
export { formatOmpVersionSupport, resolveOmpDiagnosticPaths } from "./provider-config.js";
|
|
6
6
|
import type { OmpRuntime, OmpRuntimeSession } from "./runtime.js";
|
|
@@ -47,7 +47,6 @@ interface OmpAgentSessionOptions {
|
|
|
47
47
|
*/
|
|
48
48
|
live?: boolean;
|
|
49
49
|
}
|
|
50
|
-
export declare function transformOmpModels(models: AgentModelDefinition[]): AgentModelDefinition[];
|
|
51
50
|
export declare class OmpAgentSession implements AgentSession {
|
|
52
51
|
readonly provider: AgentProvider;
|
|
53
52
|
readonly capabilities: AgentCapabilityFlags;
|
|
@@ -163,6 +162,7 @@ export declare class OmpAgentSession implements AgentSession {
|
|
|
163
162
|
private handleExtensionUiRequest;
|
|
164
163
|
private mapExtensionUiSideEffect;
|
|
165
164
|
private handleCommandOutput;
|
|
165
|
+
private handleThinkingLevelChanged;
|
|
166
166
|
private handleExtraRuntimeEvent;
|
|
167
167
|
private emitActiveToolCall;
|
|
168
168
|
private emitTodoItem;
|