@getpaseo/server 0.11.0-beta.4 → 0.11.0-beta.5
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/scripts/supervisor.js +10 -0
- package/dist/server/builtin-plugins/antigravity-provider/server/internal/process.ts +4 -3
- package/dist/server/builtin-plugins/antigravity-provider/server/internal/signals.ts +2 -5
- package/dist/server/builtin-plugins/claude-usage-source/server/usage.ts +5 -2
- package/dist/server/builtin-plugins/codex-usage-source/server/usage.ts +7 -1
- package/dist/server/builtin-plugins/muse-provider/server/catalog.ts +1 -4
- package/dist/server/builtin-plugins/muse-provider/server/connection.ts +41 -14
- package/dist/server/builtin-plugins/muse-provider/server/provider.ts +12 -13
- package/dist/server/builtin-plugins/muse-provider/server/session.ts +20 -19
- package/dist/server/builtin-plugins/muse-provider/server/sessions.ts +4 -1
- package/dist/server/builtin-plugins/muse-provider/server/usage.ts +20 -7
- package/dist/server/builtin-plugins/muse-provider/server/wire.ts +15 -8
- package/dist/server/builtin-plugins/package.json +1 -1
- package/dist/server/executable-resolution/executable-resolution.d.ts +0 -1
- package/dist/server/executable-resolution/executable-resolution.js +0 -3
- package/dist/server/server/agent/providers/claude/agent.js +30 -12
- package/dist/server/server/agent/providers/jsonl-rpc-process.d.ts +2 -2
- package/dist/server/server/agent/providers/jsonl-rpc-process.js +9 -11
- package/dist/server/server/agent/providers/omp/agent.d.ts +1 -0
- package/dist/server/server/agent/providers/omp/agent.js +24 -4
- package/dist/server/server/agent/providers/omp/cli-runtime.js +4 -4
- package/dist/server/server/agent/providers/omp/rpc-types.d.ts +365 -0
- package/dist/server/server/agent/providers/omp/rpc-types.js +54 -0
- package/dist/server/server/plugins/bundle-evaluator.js +2 -1
- package/dist/server/server/plugins/index.d.ts +21 -0
- package/dist/server/server/plugins/usage-sources/index.js +54 -22
- package/dist/server/server/session/daemon/npm-global-cli.js +4 -2
- package/dist/server/utils/spawn.d.ts +1 -1
- package/dist/server/utils/spawn.js +5 -33
- package/dist/server/web-ui/_expo/static/js/web/{index-244720b41ed4a2ce25809182e2510d6d.js → index-88d552b322a98d03fa394582d599904b.js} +24 -24
- package/dist/server/web-ui/_expo/static/js/web/index-88d552b322a98d03fa394582d599904b.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-88d552b322a98d03fa394582d599904b.js.gz +0 -0
- package/dist/server/web-ui/index.html +10 -1
- package/dist/server/web-ui/index.html.br +0 -0
- package/dist/server/web-ui/index.html.gz +0 -0
- package/dist/src/executable-resolution/executable-resolution.js +0 -3
- package/dist/src/utils/spawn.js +5 -33
- package/package.json +6 -6
- package/dist/server/utils/windows-command.d.ts +0 -15
- package/dist/server/utils/windows-command.js +0 -41
- package/dist/server/web-ui/_expo/static/js/web/index-244720b41ed4a2ce25809182e2510d6d.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-244720b41ed4a2ce25809182e2510d6d.js.gz +0 -0
- package/dist/src/utils/windows-command.js +0 -41
|
@@ -94,6 +94,14 @@ function createDurableLog(options, reportFailure) {
|
|
|
94
94
|
},
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
+
// The program that started the daemon can close its end of stdout or stderr, as
|
|
98
|
+
// `paseo daemon run | head -1` does. Drop the output nobody reads and keep supervising
|
|
99
|
+
// the worker; daemon.log still records it.
|
|
100
|
+
function ignoreClosedOutput(error) {
|
|
101
|
+
if (error.code !== "EPIPE") {
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
97
105
|
export function runSupervisor(options) {
|
|
98
106
|
const restartOnCrash = options.restartOnCrash ?? false;
|
|
99
107
|
const workerArgs = options.workerArgs ?? process.argv.slice(2);
|
|
@@ -373,6 +381,8 @@ export function runSupervisor(options) {
|
|
|
373
381
|
};
|
|
374
382
|
process.on("SIGINT", () => forwardSignal("SIGINT"));
|
|
375
383
|
process.on("SIGTERM", () => forwardSignal("SIGTERM"));
|
|
384
|
+
process.stdout.on("error", ignoreClosedOutput);
|
|
385
|
+
process.stderr.on("error", ignoreClosedOutput);
|
|
376
386
|
process.stdout.write(`[${options.name}] ${options.startupMessage}\n`);
|
|
377
387
|
writeLifecycleLog(options.startupMessage);
|
|
378
388
|
spawnWorker();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
|
2
|
+
import { spawnProcess } from "@getpaseo/plugin/server";
|
|
2
3
|
import { signalProcess } from "./signals.js";
|
|
3
4
|
import { createInterface } from "node:readline";
|
|
4
5
|
import type { ProviderLaunch, ProviderSessionConfig } from "@getpaseo/plugin/server/provider";
|
|
@@ -49,7 +50,7 @@ function driverArgs(options: DriverOptions): string[] {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export function startDriver(options: DriverOptions): Driver {
|
|
52
|
-
const child =
|
|
53
|
+
const child = spawnProcess(options.launch.command, driverArgs(options), {
|
|
53
54
|
cwd: options.config.cwd,
|
|
54
55
|
env: { ...options.launch.env, ...options.config.env },
|
|
55
56
|
detached: process.platform !== "win32",
|
|
@@ -183,7 +184,7 @@ interface ProbeOptions {
|
|
|
183
184
|
}
|
|
184
185
|
export function probe(options: ProbeOptions): Promise<string> {
|
|
185
186
|
return new Promise((resolve, reject) => {
|
|
186
|
-
const child =
|
|
187
|
+
const child = spawnProcess(options.launch.command, [...options.launch.args, ...options.args], {
|
|
187
188
|
env: options.launch.env,
|
|
188
189
|
cwd: options.cwd,
|
|
189
190
|
stdio: "pipe",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { promisify } from "node:util";
|
|
1
|
+
import { execCommand } from "@getpaseo/plugin/server";
|
|
3
2
|
|
|
4
3
|
interface SignalOptions {
|
|
5
4
|
platform: NodeJS.Platform;
|
|
@@ -11,8 +10,6 @@ type SignalPlan =
|
|
|
11
10
|
| { type: "group"; pid: number; signal: NodeJS.Signals }
|
|
12
11
|
| { type: "tree"; command: "taskkill"; args: string[] };
|
|
13
12
|
|
|
14
|
-
const executeFile = promisify(execFile);
|
|
15
|
-
|
|
16
13
|
export function signalPlan(options: SignalOptions): SignalPlan {
|
|
17
14
|
if (options.platform === "win32") {
|
|
18
15
|
return { type: "tree", command: "taskkill", args: ["/PID", String(options.pid), "/T", "/F"] };
|
|
@@ -32,7 +29,7 @@ export function signalProcess(options: SignalOptions): void | Promise<void> {
|
|
|
32
29
|
|
|
33
30
|
async function killTree(plan: Extract<SignalPlan, { type: "tree" }>): Promise<void> {
|
|
34
31
|
try {
|
|
35
|
-
await
|
|
32
|
+
await execCommand(plan.command, plan.args, { shell: false });
|
|
36
33
|
} catch (error) {
|
|
37
34
|
// taskkill reports an already-exited PID with exit code 128.
|
|
38
35
|
if (!(error instanceof Error && "code" in error && error.code === 128)) throw error;
|
|
@@ -380,7 +380,10 @@ export async function discover(
|
|
|
380
380
|
for (const input of candidates) {
|
|
381
381
|
const credentials = await resolveClaudeCredentials(input, lookup);
|
|
382
382
|
if (!credentials) continue;
|
|
383
|
-
const
|
|
383
|
+
const harness = { pi: "Pi", omp: "OMP", claude: "Claude", keychain: "Claude" }[
|
|
384
|
+
input.route.store
|
|
385
|
+
];
|
|
386
|
+
const fallback = { key: hashAccountKey(JSON.stringify(input.route)), harness, input };
|
|
384
387
|
if (credentials.expires !== undefined && credentials.expires <= (lookup.now ?? Date.now)()) {
|
|
385
388
|
accounts.push(fallback);
|
|
386
389
|
continue;
|
|
@@ -391,7 +394,7 @@ export async function discover(
|
|
|
391
394
|
fetchApi,
|
|
392
395
|
lookup.now ?? Date.now,
|
|
393
396
|
);
|
|
394
|
-
accounts.push("status" in profile ? fallback : { ...profile, input });
|
|
397
|
+
accounts.push("status" in profile ? fallback : { ...profile, harness, input });
|
|
395
398
|
} catch {
|
|
396
399
|
// Keep the login visible; fetching usage reports the vendor failure.
|
|
397
400
|
accounts.push(fallback);
|
|
@@ -72,7 +72,8 @@ export async function discover(
|
|
|
72
72
|
const present: UsageAccount[] = [];
|
|
73
73
|
for (const input of candidates) {
|
|
74
74
|
const auth = await readAuth(input, lookup);
|
|
75
|
-
if (auth)
|
|
75
|
+
if (auth)
|
|
76
|
+
present.push({ ...accountIdentity(auth, input), harness: harnessLabel(input), input });
|
|
76
77
|
}
|
|
77
78
|
return present;
|
|
78
79
|
}
|
|
@@ -294,3 +295,8 @@ function accountIdentity(auth: Auth, input: CodexUsageInput): { key: string; lab
|
|
|
294
295
|
claimString(id?.["email"]);
|
|
295
296
|
return { key: key ?? hashAccountKey(JSON.stringify(input.route)), ...(label ? { label } : {}) };
|
|
296
297
|
}
|
|
298
|
+
|
|
299
|
+
function harnessLabel(input: CodexUsageInput): string {
|
|
300
|
+
const labels = { codex: "Codex", opencode: "OpenCode", pi: "Pi", omp: "OMP" };
|
|
301
|
+
return labels[input.route.store];
|
|
302
|
+
}
|
|
@@ -63,10 +63,7 @@ export class Catalog {
|
|
|
63
63
|
|
|
64
64
|
export function presentCatalog(response: z.infer<typeof catalogSchema>): ProviderCatalog {
|
|
65
65
|
const models = response.models.map((model) => {
|
|
66
|
-
|
|
67
|
-
if (Array.isArray(model.reasoningEffortVariants) && model.reasoningEffortVariants.length > 0)
|
|
68
|
-
supported = model.reasoningEffortVariants;
|
|
69
|
-
else if (model.variants.length > 0) supported = model.variants;
|
|
66
|
+
const supported = model.variants.length > 0 ? model.variants : efforts;
|
|
70
67
|
return {
|
|
71
68
|
id: model.modelId,
|
|
72
69
|
label: model.displayLabel,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderLaunch } from "@getpaseo/plugin/server/provider";
|
|
2
|
-
import {
|
|
2
|
+
import { spawnProcess, terminateProcess } from "@getpaseo/plugin/server";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
import { createInterface } from "node:readline";
|
|
5
5
|
import { setTimeout as delay } from "node:timers/promises";
|
|
@@ -35,6 +35,7 @@ export class MspConnection {
|
|
|
35
35
|
private stderr = "";
|
|
36
36
|
private failure: MuseError | null = null;
|
|
37
37
|
private closing = false;
|
|
38
|
+
private closeResult: Promise<void> | null = null;
|
|
38
39
|
private readonly exited: Promise<void>;
|
|
39
40
|
|
|
40
41
|
constructor(
|
|
@@ -42,15 +43,20 @@ export class MspConnection {
|
|
|
42
43
|
launch: ProviderLaunch;
|
|
43
44
|
cwd?: string;
|
|
44
45
|
timeoutMs?: number;
|
|
46
|
+
startupTimeoutMs?: number;
|
|
45
47
|
serveArgs?: string[];
|
|
46
48
|
},
|
|
47
49
|
) {
|
|
48
50
|
const { launch, cwd } = options;
|
|
49
|
-
this.child =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
this.child = spawnProcess(
|
|
52
|
+
launch.command,
|
|
53
|
+
[...launch.args, "serve", ...(options.serveArgs ?? [])],
|
|
54
|
+
{
|
|
55
|
+
env: launch.env,
|
|
56
|
+
cwd,
|
|
57
|
+
stdio: "pipe",
|
|
58
|
+
},
|
|
59
|
+
);
|
|
54
60
|
this.child.stderr.setEncoding("utf8");
|
|
55
61
|
this.child.stderr.on("data", (chunk: string) => {
|
|
56
62
|
this.stderr = (this.stderr + chunk).slice(-8192);
|
|
@@ -62,7 +68,7 @@ export class MspConnection {
|
|
|
62
68
|
} catch (error) {
|
|
63
69
|
const message = error instanceof Error ? error.message : String(error);
|
|
64
70
|
this.fail(new MuseError("invalidFrame", `Invalid MSP frame: ${message}`));
|
|
65
|
-
this.
|
|
71
|
+
void this.close().catch(() => {});
|
|
66
72
|
}
|
|
67
73
|
});
|
|
68
74
|
this.child.stdin.on("error", () => {
|
|
@@ -89,6 +95,7 @@ export class MspConnection {
|
|
|
89
95
|
},
|
|
90
96
|
},
|
|
91
97
|
initializedSchema,
|
|
98
|
+
this.options.startupTimeoutMs ?? 30000,
|
|
92
99
|
);
|
|
93
100
|
if (response.schema.fingerprint !== fingerprint) {
|
|
94
101
|
process.stderr.write(
|
|
@@ -123,7 +130,12 @@ export class MspConnection {
|
|
|
123
130
|
}
|
|
124
131
|
}
|
|
125
132
|
}
|
|
126
|
-
async request<T>(
|
|
133
|
+
async request<T>(
|
|
134
|
+
method: string,
|
|
135
|
+
params: object,
|
|
136
|
+
schema: z.ZodType<T>,
|
|
137
|
+
timeoutMs = this.options.timeoutMs ?? 10000,
|
|
138
|
+
): Promise<T> {
|
|
127
139
|
if (this.failure) throw this.failure;
|
|
128
140
|
if (this.closing) throw new MuseError("closed", "Muse host is closing");
|
|
129
141
|
const id = ++this.sequence;
|
|
@@ -131,22 +143,31 @@ export class MspConnection {
|
|
|
131
143
|
const timer = setTimeout(() => {
|
|
132
144
|
this.pending.delete(id);
|
|
133
145
|
reject(new MuseError("timeout", `Muse ${method} timed out`));
|
|
134
|
-
},
|
|
146
|
+
}, timeoutMs);
|
|
135
147
|
this.pending.set(id, { resolve, reject, timer });
|
|
136
148
|
this.write({ jsonrpc: "2.0", id, method, params });
|
|
137
149
|
});
|
|
138
150
|
return schema.parse(response);
|
|
139
151
|
}
|
|
140
|
-
|
|
141
|
-
if (this.
|
|
152
|
+
close(): Promise<void> {
|
|
153
|
+
if (this.closeResult) return this.closeResult;
|
|
142
154
|
this.closing = true;
|
|
155
|
+
this.closeResult = this.finishClose();
|
|
156
|
+
return this.closeResult;
|
|
157
|
+
}
|
|
158
|
+
private async finishClose(): Promise<void> {
|
|
143
159
|
this.child.stdin.end();
|
|
144
160
|
const drained = await Promise.race([
|
|
145
161
|
this.exited.then(() => true),
|
|
146
|
-
delay(1000).then(() => false),
|
|
162
|
+
delay(1000, undefined, { ref: false }).then(() => false),
|
|
147
163
|
]);
|
|
148
|
-
if (
|
|
149
|
-
await this.
|
|
164
|
+
if (drained) return;
|
|
165
|
+
await terminateProcess(this.child);
|
|
166
|
+
const stopped = await Promise.race([
|
|
167
|
+
this.exited.then(() => true),
|
|
168
|
+
delay(5000, undefined, { ref: false }).then(() => false),
|
|
169
|
+
]);
|
|
170
|
+
if (!stopped) throw new MuseError("timeout", "Muse host did not close after termination");
|
|
150
171
|
}
|
|
151
172
|
private write(frame: object): void {
|
|
152
173
|
this.child.stdin.write(JSON.stringify(frame) + "\n");
|
|
@@ -170,6 +191,12 @@ export class MspConnection {
|
|
|
170
191
|
return;
|
|
171
192
|
}
|
|
172
193
|
if (frame.id === undefined) throw new MuseError("invalidFrame", "MSP response has no id");
|
|
194
|
+
if (frame.id === null) {
|
|
195
|
+
if (!frame.error) throw new MuseError("invalidFrame", "MSP result has a null id");
|
|
196
|
+
this.fail(new MuseError(frame.error.data?.kind ?? "rpc", frame.error.message));
|
|
197
|
+
void this.close().catch(() => {});
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
173
200
|
const pending = this.pending.get(frame.id);
|
|
174
201
|
if (!pending) return;
|
|
175
202
|
clearTimeout(pending.timer);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@getpaseo/plugin/server/provider";
|
|
11
11
|
import { serveArgs } from "./options.js";
|
|
12
12
|
import { Usage } from "./usage.js";
|
|
13
|
-
import {
|
|
13
|
+
import { execCommand } from "@getpaseo/plugin/server";
|
|
14
14
|
import { Catalog, launchKey } from "./catalog.js";
|
|
15
15
|
import { MspConnection } from "./connection.js";
|
|
16
16
|
import { MuseError, actionableError } from "./errors.js";
|
|
@@ -63,24 +63,23 @@ function requireLaunch(launch: ProviderLaunch | undefined): ProviderLaunch {
|
|
|
63
63
|
async function status(launch: ProviderLaunch): Promise<ProviderStatus> {
|
|
64
64
|
let host: MspConnection | undefined;
|
|
65
65
|
try {
|
|
66
|
-
const versionText = await
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
);
|
|
76
|
-
});
|
|
66
|
+
const { stdout: versionText } = await execCommand(
|
|
67
|
+
launch.command,
|
|
68
|
+
[...launch.args, "--version"],
|
|
69
|
+
{
|
|
70
|
+
env: launch.env,
|
|
71
|
+
timeout: 3000,
|
|
72
|
+
maxBuffer: 8192,
|
|
73
|
+
},
|
|
74
|
+
);
|
|
77
75
|
const match = /\b(\d+)\.(\d+)\.(\d+)\b/.exec(versionText);
|
|
78
76
|
if (!match) return { available: false, diagnostic: "Muse returned an unrecognized version." };
|
|
79
77
|
const major = Number(match[1]);
|
|
80
78
|
const minor = Number(match[2]);
|
|
81
79
|
if (major < 1 || (major === 1 && minor < 3))
|
|
82
80
|
return { available: false, diagnostic: `Update Muse Code: found ${match[0]}, need ≥1.3.0` };
|
|
83
|
-
|
|
81
|
+
// Leave room for the version probe, account read and cleanup within the status RPC deadline.
|
|
82
|
+
host = new MspConnection({ launch, timeoutMs: 3000, startupTimeoutMs: 20000 });
|
|
84
83
|
await host.initialize();
|
|
85
84
|
const account = await host.request("account/read", {}, accountSchema);
|
|
86
85
|
if (account.state === "loggedOut")
|
|
@@ -66,8 +66,7 @@ interface Live {
|
|
|
66
66
|
export class Session {
|
|
67
67
|
private readonly host: MspConnection;
|
|
68
68
|
private liveState: Live | undefined;
|
|
69
|
-
private providerId
|
|
70
|
-
private cursor: string | undefined;
|
|
69
|
+
private providerId: string | undefined;
|
|
71
70
|
private config: ProviderSessionConfig;
|
|
72
71
|
private catalog: ProviderCatalog = { models: [], modes };
|
|
73
72
|
private readonly approvals = new Map<string, WireApproval>();
|
|
@@ -110,9 +109,11 @@ export class Session {
|
|
|
110
109
|
if (input.persistence.version !== 1)
|
|
111
110
|
throw new MuseError("invalidPersistence", "Unsupported Muse persistence version");
|
|
112
111
|
const saved = persistenceSchema.parse(input.persistence.data);
|
|
112
|
+
// A fresh timeline needs history. MSP cursor resumes return only the suffix,
|
|
113
|
+
// so even legacy persistence cursors cannot restore this session's projection.
|
|
113
114
|
response = await this.host.command(
|
|
114
115
|
"session/resume",
|
|
115
|
-
{ sessionId: saved.sessionId,
|
|
116
|
+
{ sessionId: saved.sessionId, config: { mcpServers } },
|
|
116
117
|
sessionSchema,
|
|
117
118
|
);
|
|
118
119
|
this.config = {
|
|
@@ -167,11 +168,10 @@ export class Session {
|
|
|
167
168
|
},
|
|
168
169
|
),
|
|
169
170
|
};
|
|
170
|
-
this.providerId = response.session.providerId;
|
|
171
|
-
this.cursor = response.viewCursor;
|
|
171
|
+
this.providerId = response.session.providerId ?? undefined;
|
|
172
172
|
this.config = {
|
|
173
173
|
...this.config,
|
|
174
|
-
model: response.session.modelId,
|
|
174
|
+
model: response.session.modelId ?? this.config.model,
|
|
175
175
|
mode: response.session.approvalMode?.mode ?? this.config.mode ?? "onRequest",
|
|
176
176
|
};
|
|
177
177
|
this.options.emit({
|
|
@@ -194,14 +194,7 @@ export class Session {
|
|
|
194
194
|
for (const notification of this.buffered) this.enqueue(notification);
|
|
195
195
|
this.buffered.length = 0;
|
|
196
196
|
await this.notifications;
|
|
197
|
-
this.
|
|
198
|
-
await this.host.request("model/list", { sessionId: this.live().nativeId }, catalogSchema),
|
|
199
|
-
);
|
|
200
|
-
const selected = this.catalog.models.find((model) => model.id === this.config.model);
|
|
201
|
-
this.config = {
|
|
202
|
-
...this.config,
|
|
203
|
-
thinkingOption: this.config.thinkingOption ?? selected?.defaultThinkingOptionId,
|
|
204
|
-
};
|
|
197
|
+
await this.readCatalog();
|
|
205
198
|
await this.live().commands.refresh();
|
|
206
199
|
this.publishPersistence();
|
|
207
200
|
this.publishConfig();
|
|
@@ -229,6 +222,19 @@ export class Session {
|
|
|
229
222
|
for (const approval of pending.approvals) await this.permission(approval);
|
|
230
223
|
for (const question of pending.userInputs) this.live().questions.requested(question);
|
|
231
224
|
}
|
|
225
|
+
private async readCatalog(): Promise<void> {
|
|
226
|
+
this.catalog = presentCatalog(
|
|
227
|
+
await this.host.request("model/list", { sessionId: this.live().nativeId }, catalogSchema),
|
|
228
|
+
);
|
|
229
|
+
const model = this.config.model ?? this.catalog.defaultModel;
|
|
230
|
+
const selected = this.catalog.models.find((entry) => entry.id === model);
|
|
231
|
+
this.config = {
|
|
232
|
+
...this.config,
|
|
233
|
+
model,
|
|
234
|
+
thinkingOption: this.config.thinkingOption ?? selected?.defaultThinkingOptionId,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
232
238
|
async prompt(prompt: ProviderPrompt): Promise<void> {
|
|
233
239
|
if (await this.live().commands.compact(prompt)) return;
|
|
234
240
|
const id = commandId();
|
|
@@ -405,10 +411,6 @@ export class Session {
|
|
|
405
411
|
}
|
|
406
412
|
await this.processNotification(notification);
|
|
407
413
|
this.live().recovery.activity(envelope.viewCursor, this.activeTurnIds().length > 0);
|
|
408
|
-
if (envelope.viewCursor) {
|
|
409
|
-
this.cursor = envelope.viewCursor;
|
|
410
|
-
this.publishPersistence();
|
|
411
|
-
}
|
|
412
414
|
}
|
|
413
415
|
private async processNotification(notification: Notification): Promise<void> {
|
|
414
416
|
switch (notification.method) {
|
|
@@ -591,7 +593,6 @@ export class Session {
|
|
|
591
593
|
version: 1,
|
|
592
594
|
data: {
|
|
593
595
|
sessionId: this.live().nativeId,
|
|
594
|
-
...(this.cursor ? { cursor: this.cursor } : {}),
|
|
595
596
|
...(this.config.model ? { model: this.config.model } : {}),
|
|
596
597
|
...(this.config.thinkingOption ? { thinkingOption: this.config.thinkingOption } : {}),
|
|
597
598
|
},
|
|
@@ -38,7 +38,10 @@ export class Sessions {
|
|
|
38
38
|
updatedAt: session.updatedAt,
|
|
39
39
|
persistence: {
|
|
40
40
|
version: 1,
|
|
41
|
-
data: {
|
|
41
|
+
data: {
|
|
42
|
+
sessionId: session.sessionId,
|
|
43
|
+
...(session.modelId === null ? {} : { model: session.modelId }),
|
|
44
|
+
},
|
|
42
45
|
},
|
|
43
46
|
});
|
|
44
47
|
if (input.limit && summaries.length >= input.limit) return summaries;
|
|
@@ -16,6 +16,13 @@ import { usageSchema } from "./wire.js";
|
|
|
16
16
|
|
|
17
17
|
const inputSchema = z.object({ account: z.string() }).strict();
|
|
18
18
|
type Observation = z.infer<typeof usageSchema>;
|
|
19
|
+
|
|
20
|
+
function accountKey(env: ProviderLaunch["env"]): string {
|
|
21
|
+
// MSP 1.4.1 has no stable account ID; swapping accounts in one config directory shares a report ID.
|
|
22
|
+
const configHome = env.XDG_CONFIG_HOME ?? path.join(env.HOME ?? homedir(), ".config");
|
|
23
|
+
return hashAccountKey(path.resolve(configHome, "muse"));
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
export class Usage {
|
|
20
27
|
private readonly launches = new Map<string, ProviderLaunch>();
|
|
21
28
|
private readonly sessions = new Map<
|
|
@@ -23,10 +30,7 @@ export class Usage {
|
|
|
23
30
|
{ account: string; read: () => Promise<Observation> }
|
|
24
31
|
>();
|
|
25
32
|
remember(launch: ProviderLaunch): { account: string } {
|
|
26
|
-
|
|
27
|
-
const configHome =
|
|
28
|
-
launch.env.XDG_CONFIG_HOME ?? path.join(launch.env.HOME ?? homedir(), ".config");
|
|
29
|
-
const key = hashAccountKey(path.resolve(configHome, "muse"));
|
|
33
|
+
const key = accountKey(launch.env);
|
|
30
34
|
this.launches.set(key, launch);
|
|
31
35
|
return { account: key };
|
|
32
36
|
}
|
|
@@ -60,12 +64,21 @@ export class Usage {
|
|
|
60
64
|
label: "Muse Code",
|
|
61
65
|
icon: "icon.svg",
|
|
62
66
|
input: inputSchema,
|
|
63
|
-
discover: async () =>
|
|
64
|
-
[
|
|
67
|
+
discover: async (scope) => {
|
|
68
|
+
let accounts: string[];
|
|
69
|
+
if (scope.kind === "global") {
|
|
70
|
+
accounts = [...this.launches.keys()];
|
|
71
|
+
} else {
|
|
72
|
+
if (scope.provider !== "muse") return [];
|
|
73
|
+
const account = accountKey(scope.env);
|
|
74
|
+
accounts = this.launches.has(account) ? [account] : [];
|
|
75
|
+
}
|
|
76
|
+
return accounts.map((account) => ({
|
|
65
77
|
key: account,
|
|
66
78
|
label: "Muse Code",
|
|
67
79
|
input: { account },
|
|
68
|
-
}))
|
|
80
|
+
}));
|
|
81
|
+
},
|
|
69
82
|
fetch: async (input) => {
|
|
70
83
|
const { account } = inputSchema.parse(input);
|
|
71
84
|
const launch = this.launches.get(account);
|
|
@@ -87,7 +87,7 @@ export const notificationSchema = z.object({
|
|
|
87
87
|
});
|
|
88
88
|
export const frameSchema = z.object({
|
|
89
89
|
jsonrpc: z.literal("2.0"),
|
|
90
|
-
id: z.union([z.string(), z.number()]).optional(),
|
|
90
|
+
id: z.union([z.string(), z.number()]).nullable().optional(),
|
|
91
91
|
method: z.string().optional(),
|
|
92
92
|
params: z.unknown().optional(),
|
|
93
93
|
result: z.unknown().optional(),
|
|
@@ -115,16 +115,20 @@ export const catalogSchema = z.object({
|
|
|
115
115
|
contextLimit: z.number().nullable(),
|
|
116
116
|
isDefault: z.boolean(),
|
|
117
117
|
defaultReasoningEffort: effortSchema.nullable().optional(),
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
// Validate consumed fields only. Muse's described subset (reasoningEffortVariants)
|
|
119
|
+
// is presentation metadata; its shape must not gate catalog discovery or session startup.
|
|
120
|
+
variants: z
|
|
121
|
+
.union([z.array(effortSchema), z.literal("unknown")])
|
|
122
|
+
.transform((variants) => (variants === "unknown" ? [] : variants))
|
|
123
|
+
.default([]),
|
|
120
124
|
}),
|
|
121
125
|
),
|
|
122
126
|
});
|
|
123
127
|
export const sessionSchema = z.object({
|
|
124
128
|
session: z.object({
|
|
125
129
|
sessionId: z.string(),
|
|
126
|
-
modelId: z.string(),
|
|
127
|
-
providerId: z.string(),
|
|
130
|
+
modelId: z.string().nullable(),
|
|
131
|
+
providerId: z.string().nullable(),
|
|
128
132
|
approvalMode: z.object({ mode: approvalModeSchema }).optional(),
|
|
129
133
|
}),
|
|
130
134
|
viewCursor: z.string(),
|
|
@@ -139,11 +143,14 @@ export const sessionSchema = z.object({
|
|
|
139
143
|
});
|
|
140
144
|
export const persistenceSchema = z.object({
|
|
141
145
|
sessionId: z.string(),
|
|
142
|
-
cursor: z.string().optional(),
|
|
143
146
|
model: z.string().optional(),
|
|
144
147
|
thinkingOption: effortSchema.optional(),
|
|
145
148
|
});
|
|
146
|
-
export const deltaSchema = z.object({
|
|
149
|
+
export const deltaSchema = z.object({
|
|
150
|
+
itemId: z.string(),
|
|
151
|
+
field: z.string().default("text"),
|
|
152
|
+
delta: z.string(),
|
|
153
|
+
});
|
|
147
154
|
export const turnSchema = z.object({
|
|
148
155
|
turnId: z.string(),
|
|
149
156
|
commandId: z.string().optional(),
|
|
@@ -241,7 +248,7 @@ export const sessionListSchema = z.object({
|
|
|
241
248
|
workspaceRoot: z.string().nullable(),
|
|
242
249
|
title: z.string().optional(),
|
|
243
250
|
updatedAt: z.string(),
|
|
244
|
-
modelId: z.string(),
|
|
251
|
+
modelId: z.string().nullable(),
|
|
245
252
|
}),
|
|
246
253
|
),
|
|
247
254
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import type { ProcessEnvRecord } from "../server/paseo-env.js";
|
|
3
|
-
export { quoteWindowsArgument, quoteWindowsCommand } from "../utils/windows-command.js";
|
|
4
3
|
export declare function probeExecutable(executablePath: string, options?: number | ExecutableResolutionOptions): Promise<boolean>;
|
|
5
4
|
/**
|
|
6
5
|
* Check a literal executable path. PATH search is handled by findExecutable().
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { execCommand } from "../utils/spawn.js";
|
|
4
|
-
import { isWindowsCommandScript } from "../utils/windows-command.js";
|
|
5
4
|
import { windowsExecutableResolution } from "./windows.js";
|
|
6
|
-
export { quoteWindowsArgument, quoteWindowsCommand } from "../utils/windows-command.js";
|
|
7
5
|
const require = createRequire(import.meta.url);
|
|
8
6
|
const which = require("which");
|
|
9
7
|
const PROBE_TIMEOUT_MS = 2000;
|
|
@@ -61,7 +59,6 @@ export async function probeExecutable(executablePath, options = PROBE_TIMEOUT_MS
|
|
|
61
59
|
timeout: timeoutMs,
|
|
62
60
|
killSignal: "SIGKILL",
|
|
63
61
|
maxBuffer: 64 * 1024,
|
|
64
|
-
shell: isWindowsCommandScript(executablePath),
|
|
65
62
|
});
|
|
66
63
|
return true;
|
|
67
64
|
}
|
|
@@ -3428,16 +3428,7 @@ class ClaudeAgentSession {
|
|
|
3428
3428
|
return {
|
|
3429
3429
|
type: "timeline",
|
|
3430
3430
|
provider: "claude",
|
|
3431
|
-
item: {
|
|
3432
|
-
...toolCall,
|
|
3433
|
-
detail: {
|
|
3434
|
-
type: "sub_agent",
|
|
3435
|
-
...(declaration.title ? { subAgentType: declaration.title } : {}),
|
|
3436
|
-
...(declaration.description ? { description: declaration.description } : {}),
|
|
3437
|
-
log: "",
|
|
3438
|
-
actions: [],
|
|
3439
|
-
},
|
|
3440
|
-
},
|
|
3431
|
+
item: { ...toolCall, detail: buildClaudeSubagentCardDetail(declaration) },
|
|
3441
3432
|
};
|
|
3442
3433
|
}
|
|
3443
3434
|
appendSidechainResultEvents(message, events) {
|
|
@@ -3956,6 +3947,7 @@ class ClaudeAgentSession {
|
|
|
3956
3947
|
const sidechainEntries = [parentContent, ...sidechains.contents]
|
|
3957
3948
|
.flatMap(parseClaudeHistoryRecords)
|
|
3958
3949
|
.filter((entry) => entry.isSidechain === true && typeof entry.agentId === "string");
|
|
3950
|
+
const parentFacts = readClaudeReplayParentFacts(parentEntries);
|
|
3959
3951
|
// Replay produces the same observations the live task protocol produces, then folds them
|
|
3960
3952
|
// with the same function, so identity and status are derived once for both paths.
|
|
3961
3953
|
const subagentReplay = observeReplaySubagents({
|
|
@@ -3965,7 +3957,7 @@ class ClaudeAgentSession {
|
|
|
3965
3957
|
entries,
|
|
3966
3958
|
parentFacts: readClaudeReplayParentFacts(entries),
|
|
3967
3959
|
})),
|
|
3968
|
-
parent:
|
|
3960
|
+
parent: parentFacts,
|
|
3969
3961
|
convertEntry: (entry) => this.convertHistoryEntry(entry),
|
|
3970
3962
|
});
|
|
3971
3963
|
const observations = [
|
|
@@ -3990,6 +3982,7 @@ class ClaudeAgentSession {
|
|
|
3990
3982
|
const replay = {
|
|
3991
3983
|
restoredIds: restoredProviderSubagentIds,
|
|
3992
3984
|
toolOwners: subagentReplay.toolOwners,
|
|
3985
|
+
subagentToolCalls: parentFacts.toolCalls,
|
|
3993
3986
|
};
|
|
3994
3987
|
if (observations.length === 0)
|
|
3995
3988
|
return replay;
|
|
@@ -4045,7 +4038,10 @@ class ClaudeAgentSession {
|
|
|
4045
4038
|
return;
|
|
4046
4039
|
}
|
|
4047
4040
|
const taskSnapshot = this.taskState.observe(entry);
|
|
4048
|
-
const items = [
|
|
4041
|
+
const items = [
|
|
4042
|
+
...(taskSnapshot ? [taskSnapshot] : []),
|
|
4043
|
+
...this.convertHistoryEntry(entry).map((item) => labelReplayedSubagentCard(item, replay.subagentToolCalls)),
|
|
4044
|
+
];
|
|
4049
4045
|
const isVisibleUserEntry = entry.type === "user" &&
|
|
4050
4046
|
typeof entry.uuid === "string" &&
|
|
4051
4047
|
!isSyntheticHistoryUserEntry(entry) &&
|
|
@@ -4662,6 +4658,28 @@ function parseClaudeHistoryRecords(content) {
|
|
|
4662
4658
|
}
|
|
4663
4659
|
return entries;
|
|
4664
4660
|
}
|
|
4661
|
+
/** The parent's card for a subagent, labeled with its type and task. */
|
|
4662
|
+
function buildClaudeSubagentCardDetail(facts) {
|
|
4663
|
+
return {
|
|
4664
|
+
type: "sub_agent",
|
|
4665
|
+
...(facts.title ? { subAgentType: facts.title } : {}),
|
|
4666
|
+
...(facts.description ? { description: facts.description } : {}),
|
|
4667
|
+
log: "",
|
|
4668
|
+
actions: [],
|
|
4669
|
+
};
|
|
4670
|
+
}
|
|
4671
|
+
/**
|
|
4672
|
+
* Live, a Task call's card is built from the task protocol's declaration. Replay has no task
|
|
4673
|
+
* protocol, so the generic tool mapper leaves the card unlabeled; label it from the same facts.
|
|
4674
|
+
*/
|
|
4675
|
+
function labelReplayedSubagentCard(item, subagentToolCalls) {
|
|
4676
|
+
if (item.type !== "tool_call")
|
|
4677
|
+
return item;
|
|
4678
|
+
const facts = subagentToolCalls.get(item.callId);
|
|
4679
|
+
if (!facts)
|
|
4680
|
+
return item;
|
|
4681
|
+
return { ...item, detail: buildClaudeSubagentCardDetail(facts) };
|
|
4682
|
+
}
|
|
4665
4683
|
/**
|
|
4666
4684
|
* Collect what the parent transcript knows about its Task calls, in the shape the shared replay
|
|
4667
4685
|
* source consumes. The agentId scrape is kept only as a fallback for sessions recorded before
|
|
@@ -71,9 +71,9 @@ export declare class JsonlRpcProcess {
|
|
|
71
71
|
close(error?: Error): Promise<void>;
|
|
72
72
|
private terminate;
|
|
73
73
|
private handleStdoutChunk;
|
|
74
|
-
/** Route a complete logical frame to its consumer (
|
|
74
|
+
/** Route a complete logical frame to its consumer (pending request or subscriber). */
|
|
75
75
|
private dispatchFrame;
|
|
76
|
-
private
|
|
76
|
+
private settleRequest;
|
|
77
77
|
private handleStdinError;
|
|
78
78
|
private failAll;
|
|
79
79
|
}
|