paseo-dsh 0.2.20 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +4 -4
- package/OVERVIEW.zh-CN.md +15 -0
- package/README.md +6 -6
- package/client/dsh-plugins-page.tsx +960 -0
- package/client/guard.tsx +115 -0
- package/client/i18n.ts +100 -0
- package/client/labels.ts +23 -0
- package/client/locales/en.json +215 -0
- package/client/locales/zh-CN.json +213 -0
- package/client/messages.ts +85 -0
- package/client/react-native.d.ts +3 -0
- package/client/settings-screen.tsx +34 -21
- package/client/stream-stats.tsx +71 -48
- package/client/timeline.tsx +442 -123
- package/index.client.tsx +42 -4
- package/index.server.ts +30 -7
- package/package.json +8 -6
- package/paseo-plugin.json +8 -2
- package/server/bootstrap.ts +8 -2
- package/server/bridge-assets.ts +3 -2
- package/server/dsh-plugins-rpc.ts +45 -0
- package/server/dsh-plugins.ts +970 -0
- package/server/dsh-process.ts +61 -11
- package/server/provider.ts +25 -7
- package/server/session.ts +410 -48
- package/server/timeline.ts +69 -4
- package/shared/dsh-plugins-api.ts +175 -0
- package/shared/image-preview.ts +8 -1
- package/shared/settings.ts +14 -43
package/server/dsh-process.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ProviderMcpServerConfig, ProviderToolPolicy } from "@getpaseo/plug
|
|
|
2
2
|
/**
|
|
3
3
|
* One `dsh --profile paseo` child process, speaking the bridge's stdio JSON-RPC.
|
|
4
4
|
*
|
|
5
|
-
* A process owns
|
|
5
|
+
* A process owns one root agent session and its native children. DSH pins the working directory,
|
|
6
6
|
* provider, model and reasoning effort at `initialize`, so a session per
|
|
7
7
|
* process is what lets Paseo run several workspaces against one provider.
|
|
8
8
|
*
|
|
@@ -37,6 +37,8 @@ export interface DshAnswer {
|
|
|
37
37
|
|
|
38
38
|
/** A server -> client question request raised by the DSH bridge. */
|
|
39
39
|
export interface DshQuestionRequest {
|
|
40
|
+
requestId?: string;
|
|
41
|
+
sessionId?: string;
|
|
40
42
|
callId: string | null;
|
|
41
43
|
timed: boolean;
|
|
42
44
|
questions: DshQuestion[];
|
|
@@ -49,6 +51,10 @@ export interface DshSessionEvent {
|
|
|
49
51
|
parentSessionId?: string;
|
|
50
52
|
origin?: string;
|
|
51
53
|
cwd?: string;
|
|
54
|
+
toolCallId?: string;
|
|
55
|
+
rootToolCallId?: string;
|
|
56
|
+
toolName?: string;
|
|
57
|
+
toolTitle?: string;
|
|
52
58
|
event: { type: string; [key: string]: unknown };
|
|
53
59
|
}
|
|
54
60
|
|
|
@@ -60,6 +66,22 @@ export interface DshStatusEvent {
|
|
|
60
66
|
parentSessionId?: string;
|
|
61
67
|
origin?: string;
|
|
62
68
|
cwd?: string;
|
|
69
|
+
toolCallId?: string;
|
|
70
|
+
rootToolCallId?: string;
|
|
71
|
+
toolName?: string;
|
|
72
|
+
toolTitle?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface DshApprovalRequest {
|
|
76
|
+
requestId?: string;
|
|
77
|
+
sessionId?: string;
|
|
78
|
+
callId?: string;
|
|
79
|
+
toolName: string;
|
|
80
|
+
reason?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface DshAssistantStream extends Omit<DshStatusEvent, "status"> {
|
|
84
|
+
frame: DshAssistantFrame;
|
|
63
85
|
}
|
|
64
86
|
|
|
65
87
|
/** One model the runtime advertises, with its adapter-owned reasoning efforts. */
|
|
@@ -129,7 +151,10 @@ export interface DshAssistantFrame {
|
|
|
129
151
|
|
|
130
152
|
export interface DshProcessHandlers {
|
|
131
153
|
onEvent(payload: DshSessionEvent): void;
|
|
132
|
-
onAssistantStream?(frame: DshAssistantFrame): void;
|
|
154
|
+
onAssistantStream?(frame: DshAssistantFrame, payload?: DshAssistantStream): void;
|
|
155
|
+
onChild?(payload: Omit<DshStatusEvent, "status">): void;
|
|
156
|
+
onApproval?(request: DshApprovalRequest): Promise<{ behavior: "allow" | "deny" }>;
|
|
157
|
+
onRequestCancelled?(requestId: string): void;
|
|
133
158
|
onStatus(payload: DshStatusEvent): void;
|
|
134
159
|
onQuestion(request: DshQuestionRequest): Promise<DshAnswer>;
|
|
135
160
|
onLog(line: string): void;
|
|
@@ -163,7 +188,7 @@ export interface DshProcessOptions extends DshProcessHandlers {
|
|
|
163
188
|
initializeRoute?: boolean;
|
|
164
189
|
}
|
|
165
190
|
|
|
166
|
-
function
|
|
191
|
+
export function resolveDshBinary(env: NodeJS.ProcessEnv = process.env): string {
|
|
167
192
|
const candidates = [env.DSH_BINARY, "dsh", `${env.HOME ?? ""}/.local/bin/dsh`]
|
|
168
193
|
.filter((value): value is string => typeof value === "string" && value.length > 0);
|
|
169
194
|
for (const candidate of candidates) {
|
|
@@ -207,7 +232,7 @@ export class DshProcess {
|
|
|
207
232
|
|
|
208
233
|
async #start(): Promise<void> {
|
|
209
234
|
const env = { ...process.env, ...this.#options.env };
|
|
210
|
-
const launch = resolveDshCommand(
|
|
235
|
+
const launch = resolveDshCommand(resolveDshBinary(env), env, this.#options.cwd);
|
|
211
236
|
const child = spawn(launch.command, [...launch.args, "--profile", env.DSH_PASEO_PROFILE ?? "paseo"], {
|
|
212
237
|
cwd: this.#options.cwd,
|
|
213
238
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -322,12 +347,13 @@ export class DshProcess {
|
|
|
322
347
|
text: string,
|
|
323
348
|
contentBlocks?: unknown[],
|
|
324
349
|
delivery?: "auto" | "steer",
|
|
325
|
-
|
|
350
|
+
sessionId = this.#options.sessionId,
|
|
351
|
+
): Promise<{ disposition?: "started" | "steered" | "unavailable"; messageId?: string; seq?: number }> {
|
|
326
352
|
return (await this.#request("session/prompt", {
|
|
327
|
-
sessionId
|
|
353
|
+
sessionId,
|
|
328
354
|
contentBlocks: contentBlocks ?? [{ type: "text", text }],
|
|
329
355
|
...(delivery === undefined ? {} : { delivery }),
|
|
330
|
-
})) as { messageId?: string; seq?: number };
|
|
356
|
+
})) as { disposition?: "started" | "steered" | "unavailable"; messageId?: string; seq?: number };
|
|
331
357
|
}
|
|
332
358
|
|
|
333
359
|
/**
|
|
@@ -350,8 +376,12 @@ export class DshProcess {
|
|
|
350
376
|
}
|
|
351
377
|
|
|
352
378
|
/** Cancel the running turn while keeping the session usable afterwards. */
|
|
353
|
-
async cancel(): Promise<void> {
|
|
354
|
-
await this.#request("session/cancel", { sessionId
|
|
379
|
+
async cancel(sessionId = this.#options.sessionId): Promise<void> {
|
|
380
|
+
await this.#request("session/cancel", { sessionId });
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
async closeChild(sessionId: string): Promise<void> {
|
|
384
|
+
await this.#request("session/close", { sessionId });
|
|
355
385
|
}
|
|
356
386
|
|
|
357
387
|
/** Select plan mode and return the committed state. */
|
|
@@ -505,6 +535,7 @@ export class DshProcess {
|
|
|
505
535
|
try {
|
|
506
536
|
const params = (frame.params ?? {}) as DshQuestionRequest;
|
|
507
537
|
const answer = await this.#options.onQuestion({
|
|
538
|
+
...params,
|
|
508
539
|
callId: params.callId ?? null,
|
|
509
540
|
timed: params.timed === true,
|
|
510
541
|
questions: params.questions ?? [],
|
|
@@ -524,11 +555,30 @@ export class DshProcess {
|
|
|
524
555
|
this.#options.onEvent(frame.params as DshSessionEvent);
|
|
525
556
|
return;
|
|
526
557
|
}
|
|
558
|
+
if (method === "session.child") {
|
|
559
|
+
this.#options.onChild?.(frame.params as Omit<DshStatusEvent, "status">);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (method === "paseo/request/cancel") {
|
|
563
|
+
const params = frame.params as { requestId?: string } | undefined;
|
|
564
|
+
if (params?.requestId !== undefined) this.#options.onRequestCancelled?.(params.requestId);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
if (method === "paseo/approval" && id !== undefined) {
|
|
568
|
+
try {
|
|
569
|
+
const response = await this.#options.onApproval?.(frame.params as unknown as DshApprovalRequest);
|
|
570
|
+
this.#send({ jsonrpc: "2.0", id, result: response ?? { behavior: "deny" } });
|
|
571
|
+
} catch (error) {
|
|
572
|
+
this.#send({ jsonrpc: "2.0", id, error: { code: -32000, message: toError(error, "approval cancelled").message } });
|
|
573
|
+
}
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
527
576
|
if (method === "session.status") {
|
|
528
577
|
const params = frame.params as
|
|
529
578
|
| { sessionId?: string; status?: string; parentSessionId?: string; origin?: string; cwd?: string }
|
|
530
579
|
| undefined;
|
|
531
580
|
this.#options.onStatus({
|
|
581
|
+
...params,
|
|
532
582
|
sessionId: params?.sessionId ?? this.#options.sessionId,
|
|
533
583
|
status: params?.status ?? "unknown",
|
|
534
584
|
...(params?.parentSessionId === undefined ? {} : { parentSessionId: params.parentSessionId }),
|
|
@@ -538,8 +588,8 @@ export class DshProcess {
|
|
|
538
588
|
return;
|
|
539
589
|
}
|
|
540
590
|
if (method === "assistant.stream") {
|
|
541
|
-
const params = frame.params as
|
|
542
|
-
if (params?.frame !== undefined) this.#options.onAssistantStream?.(params.frame);
|
|
591
|
+
const params = frame.params as DshAssistantStream | undefined;
|
|
592
|
+
if (params?.frame !== undefined) this.#options.onAssistantStream?.(params.frame, params);
|
|
543
593
|
return;
|
|
544
594
|
}
|
|
545
595
|
if (method !== undefined) {
|
package/server/provider.ts
CHANGED
|
@@ -211,6 +211,7 @@ class DshConnection implements ProviderConnection {
|
|
|
211
211
|
readonly capabilities: readonly string[];
|
|
212
212
|
readonly #listeners = new Set<(event: ProviderEvent) => void>();
|
|
213
213
|
readonly #sessions = new Map<string, DshSession>();
|
|
214
|
+
readonly #childOwners = new Map<string, DshSession>();
|
|
214
215
|
#display: DisplayCatalog | undefined;
|
|
215
216
|
#closed = false;
|
|
216
217
|
|
|
@@ -243,6 +244,7 @@ class DshConnection implements ProviderConnection {
|
|
|
243
244
|
this.#closed = true;
|
|
244
245
|
const sessions = [...this.#sessions.values()];
|
|
245
246
|
this.#sessions.clear();
|
|
247
|
+
this.#childOwners.clear();
|
|
246
248
|
await Promise.allSettled(sessions.map((session) => session.close()));
|
|
247
249
|
}
|
|
248
250
|
|
|
@@ -255,35 +257,42 @@ class DshConnection implements ProviderConnection {
|
|
|
255
257
|
case "session.open":
|
|
256
258
|
return this.#open(input);
|
|
257
259
|
case "session.prompt":
|
|
258
|
-
return this.#require(input.sessionId).prompt(input.prompt);
|
|
260
|
+
return this.#require(input.sessionId).prompt(input.prompt, input.sessionId);
|
|
259
261
|
case "session.permission":
|
|
260
|
-
this.#require(input.sessionId).resolvePermission(input.permissionId, input.response);
|
|
262
|
+
this.#require(input.sessionId).resolvePermission(input.permissionId, input.response, input.sessionId);
|
|
261
263
|
return;
|
|
262
264
|
case "session.revert": {
|
|
263
265
|
// The capability is conversation-only; a files/both request reaching
|
|
264
266
|
// here would be a host bug and must fail loudly instead of pretending
|
|
265
267
|
// the working tree was restored.
|
|
266
|
-
const session = this.#
|
|
268
|
+
const session = this.#requireRoot(input.sessionId);
|
|
267
269
|
await session.revert(input.token, input.scope);
|
|
268
270
|
this.#emit({ type: "request.completed", requestId: input.requestId });
|
|
269
271
|
return;
|
|
270
272
|
}
|
|
271
273
|
case "session.configure": {
|
|
272
|
-
const session = this.#
|
|
274
|
+
const session = this.#requireRoot(input.sessionId);
|
|
273
275
|
await session.configure(input.changes);
|
|
274
276
|
this.#emit({ type: "session.config", sessionId: input.sessionId, config: session.configState() });
|
|
275
277
|
this.#emit({ type: "request.completed", requestId: input.requestId });
|
|
276
278
|
return;
|
|
277
279
|
}
|
|
278
280
|
case "session.interrupt": {
|
|
279
|
-
await this.#require(input.sessionId).interrupt();
|
|
281
|
+
await this.#require(input.sessionId).interrupt(input.sessionId);
|
|
280
282
|
this.#emit({ type: "request.completed", requestId: input.requestId });
|
|
281
283
|
return;
|
|
282
284
|
}
|
|
283
285
|
case "session.close": {
|
|
286
|
+
const owner = this.#childOwners.get(input.sessionId);
|
|
287
|
+
if (owner !== undefined) {
|
|
288
|
+
await owner.closeChild(input.sessionId);
|
|
289
|
+
this.#emit({ type: "request.completed", requestId: input.requestId });
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
284
292
|
const session = this.#sessions.get(input.sessionId);
|
|
285
293
|
this.#sessions.delete(input.sessionId);
|
|
286
294
|
await session?.close();
|
|
295
|
+
for (const [id, owner] of this.#childOwners) if (owner === session) this.#childOwners.delete(id);
|
|
287
296
|
this.#emit({ type: "session.closed", sessionId: input.sessionId });
|
|
288
297
|
this.#emit({ type: "request.completed", requestId: input.requestId });
|
|
289
298
|
return;
|
|
@@ -384,7 +393,11 @@ class DshConnection implements ProviderConnection {
|
|
|
384
393
|
models: display.models,
|
|
385
394
|
thinkingOptions: display.thinkingOptions,
|
|
386
395
|
capabilities: this.capabilities,
|
|
387
|
-
emit: (event) =>
|
|
396
|
+
emit: (event) => {
|
|
397
|
+
if (event.type === "session.opened" && event.parentSessionId !== undefined) this.#childOwners.set(event.sessionId, session);
|
|
398
|
+
if (event.type === "session.closed") this.#childOwners.delete(event.sessionId);
|
|
399
|
+
this.#emit(event);
|
|
400
|
+
},
|
|
388
401
|
log: (line) => {
|
|
389
402
|
process.stderr.write(`[${PROVIDER_ID}] ${line}\n`);
|
|
390
403
|
},
|
|
@@ -474,11 +487,16 @@ class DshConnection implements ProviderConnection {
|
|
|
474
487
|
}
|
|
475
488
|
|
|
476
489
|
#require(sessionId: string): DshSession {
|
|
477
|
-
const session = this.#sessions.get(sessionId);
|
|
490
|
+
const session = this.#sessions.get(sessionId) ?? this.#childOwners.get(sessionId);
|
|
478
491
|
if (session === undefined) throw new Error(`unknown session: ${sessionId}`);
|
|
479
492
|
return session;
|
|
480
493
|
}
|
|
481
494
|
|
|
495
|
+
#requireRoot(sessionId: string): DshSession {
|
|
496
|
+
if (this.#childOwners.has(sessionId)) throw new Error(`configuration and rewind are not supported on native child session: ${sessionId}`);
|
|
497
|
+
return this.#require(sessionId);
|
|
498
|
+
}
|
|
499
|
+
|
|
482
500
|
#emit(event: ProviderEvent): void {
|
|
483
501
|
for (const listener of [...this.#listeners]) {
|
|
484
502
|
try {
|