paseo-dsh 0.2.19 → 0.2.21
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 -2
- package/OVERVIEW.zh-CN.md +15 -0
- package/README.md +6 -2
- package/client/locales/en.json +123 -0
- package/client/locales/zh-CN.json +122 -0
- package/client/messages.ts +43 -0
- package/client/settings-screen.tsx +26 -19
- package/client/stream-stats.tsx +49 -34
- package/client/timeline.tsx +344 -67
- package/index.server.ts +18 -6
- package/package.json +9 -6
- package/paseo-plugin.json +8 -2
- package/server/bridge-assets.ts +2 -1
- package/server/dsh-process.ts +9 -1
- package/server/provider.ts +29 -9
- package/server/session.ts +59 -50
- package/server/timeline.ts +8 -3
- package/shared/image-preview.ts +8 -1
- package/shared/settings.ts +14 -43
package/server/provider.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
type ProviderThinkingOption,
|
|
21
21
|
} from "@getpaseo/plugin/server/provider";
|
|
22
22
|
import { DshProcess, type DshCatalog } from "./dsh-process";
|
|
23
|
-
import { DshSession, MODES, parseRoute } from "./session";
|
|
23
|
+
import { DshSession, MODES, offersThinking, parseRoute } from "./session";
|
|
24
24
|
|
|
25
25
|
const CAPABILITIES = [
|
|
26
26
|
"prompt.message",
|
|
@@ -55,6 +55,7 @@ const CAPABILITIES = [
|
|
|
55
55
|
// only reproduce conversation state.
|
|
56
56
|
"session.revert.conversation",
|
|
57
57
|
"permission",
|
|
58
|
+
"permission.tool_policy",
|
|
58
59
|
] as const;
|
|
59
60
|
|
|
60
61
|
/** Provider id registered with Paseo; distinct from the ACP `deepseek-harness` entry. */
|
|
@@ -348,6 +349,14 @@ class DshConnection implements ProviderConnection {
|
|
|
348
349
|
const { sessionId, config } = input;
|
|
349
350
|
const display = this.#display ?? (await loadCatalog(config.cwd));
|
|
350
351
|
this.#display = display;
|
|
352
|
+
const route = { ...parseRoute(config.model, display.fallbackRoute) };
|
|
353
|
+
// Only an option the model offers reaches initialize; configure() below
|
|
354
|
+
// drops any other with a log, as it does for live changes.
|
|
355
|
+
if (config.thinkingOption === null || config.thinkingOption === "") {
|
|
356
|
+
route.reasoningEffort = null;
|
|
357
|
+
} else if (config.thinkingOption !== undefined && offersThinking(display.models, route, config.thinkingOption)) {
|
|
358
|
+
route.reasoningEffort = config.thinkingOption;
|
|
359
|
+
}
|
|
351
360
|
|
|
352
361
|
// DSH's session id: the Paseo-minted one normally, but the native id when
|
|
353
362
|
// Paseo reopens an imported session under a fresh agent id.
|
|
@@ -355,7 +364,6 @@ class DshConnection implements ProviderConnection {
|
|
|
355
364
|
const dshSessionId =
|
|
356
365
|
isRecord(nativeId) && typeof nativeId["sessionId"] === "string" ? nativeId["sessionId"] : sessionId;
|
|
357
366
|
|
|
358
|
-
const route = parseRoute(config.model, display.fallbackRoute);
|
|
359
367
|
const settings = config.settings ?? {};
|
|
360
368
|
// Carry the preset into `open()` so the process can queue it before the agent
|
|
361
369
|
// exists: that is what puts the right id in the session header, instead of
|
|
@@ -367,6 +375,9 @@ class DshConnection implements ProviderConnection {
|
|
|
367
375
|
dshSessionId,
|
|
368
376
|
cwd: config.cwd,
|
|
369
377
|
env: config.env ?? {},
|
|
378
|
+
mcpServers: config.mcpServers,
|
|
379
|
+
...(config.systemPrompt === undefined ? {} : { systemPrompt: config.systemPrompt }),
|
|
380
|
+
...(config.toolPolicy === undefined ? {} : { toolPolicy: config.toolPolicy }),
|
|
370
381
|
route,
|
|
371
382
|
mode: config.mode ?? "build",
|
|
372
383
|
...(initialPreset === undefined ? {} : { initialPreset }),
|
|
@@ -380,12 +391,22 @@ class DshConnection implements ProviderConnection {
|
|
|
380
391
|
});
|
|
381
392
|
this.#sessions.set(sessionId, session);
|
|
382
393
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
394
|
+
try {
|
|
395
|
+
await session.open();
|
|
396
|
+
// Fresh agents receive the choice at initialize. A resumed agent owns a
|
|
397
|
+
// durable selection, so apply only the caller's explicit overrides.
|
|
398
|
+
if (config.model !== undefined || config.thinkingOption !== undefined) {
|
|
399
|
+
await session.configure({
|
|
400
|
+
...(config.model === undefined ? {} : { model: config.model }),
|
|
401
|
+
...(config.thinkingOption === undefined ? {} : { thinkingOption: config.thinkingOption }),
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
this.#sessions.delete(sessionId);
|
|
407
|
+
await session.close();
|
|
408
|
+
throw error;
|
|
387
409
|
}
|
|
388
|
-
|
|
389
410
|
// The preset already reached the process before `initialize` (see
|
|
390
411
|
// `initialPreset` above), so this only covers a choice that lands later — a
|
|
391
412
|
// resumed session or a pick made while the session was still opening. The
|
|
@@ -407,8 +428,7 @@ class DshConnection implements ProviderConnection {
|
|
|
407
428
|
await session.loadCommands();
|
|
408
429
|
await session.loadPermission();
|
|
409
430
|
await session.loadPresets();
|
|
410
|
-
//
|
|
411
|
-
// above), so measuring occupancy cannot race the preset any more.
|
|
431
|
+
// initialize validated the composed agent before these independent reads.
|
|
412
432
|
void session.refreshUsage();
|
|
413
433
|
} catch (error) {
|
|
414
434
|
process.stderr.write(`[${PROVIDER_ID}] command catalog failed: ${messageOf(error)}\n`);
|
package/server/session.ts
CHANGED
|
@@ -21,6 +21,8 @@ import type {
|
|
|
21
21
|
ProviderTimelineItem,
|
|
22
22
|
ProviderToolCallDetail,
|
|
23
23
|
ProviderUsage,
|
|
24
|
+
ProviderMcpServerConfig,
|
|
25
|
+
ProviderToolPolicy,
|
|
24
26
|
} from "@getpaseo/plugin/server/provider";
|
|
25
27
|
import type { JsonValue } from "./json-value";
|
|
26
28
|
import {
|
|
@@ -56,6 +58,9 @@ export interface DshSessionOptions {
|
|
|
56
58
|
dshSessionId?: string;
|
|
57
59
|
cwd: string;
|
|
58
60
|
env: Record<string, string>;
|
|
61
|
+
mcpServers?: Readonly<Record<string, ProviderMcpServerConfig>>;
|
|
62
|
+
systemPrompt?: string;
|
|
63
|
+
toolPolicy?: ProviderToolPolicy;
|
|
59
64
|
route: DshRoute;
|
|
60
65
|
mode: string;
|
|
61
66
|
/**
|
|
@@ -115,6 +120,12 @@ export function parseRoute(model: string | undefined, fallback: DshRoute): DshRo
|
|
|
115
120
|
return { provider: model.slice(0, slash), model: model.slice(slash + 1) };
|
|
116
121
|
}
|
|
117
122
|
|
|
123
|
+
/** Whether the catalog offers `option` as a thinking choice for the route's model. */
|
|
124
|
+
export function offersThinking(models: readonly ProviderModel[], route: DshRoute, option: string): boolean {
|
|
125
|
+
const id = `${route.provider}/${route.model}`;
|
|
126
|
+
return models.find((entry) => entry.id === id)?.thinkingOptions?.some((entry) => entry.id === option) ?? false;
|
|
127
|
+
}
|
|
128
|
+
|
|
118
129
|
/** One DSH subagent child session observed through the bridge. */
|
|
119
130
|
interface ChildSessionState {
|
|
120
131
|
id: string;
|
|
@@ -245,7 +256,7 @@ export class DshSession {
|
|
|
245
256
|
this.#options = options;
|
|
246
257
|
this.#route = options.route;
|
|
247
258
|
this.#mode = options.mode === "plan" ? "plan" : "build";
|
|
248
|
-
this.#thinkingOption = options.route.reasoningEffort;
|
|
259
|
+
this.#thinkingOption = options.route.reasoningEffort ?? undefined;
|
|
249
260
|
}
|
|
250
261
|
|
|
251
262
|
/** Spawn the process, pin the route, and reconcile the requested mode. */
|
|
@@ -256,6 +267,9 @@ export class DshSession {
|
|
|
256
267
|
sessionId: this.#dshSessionId,
|
|
257
268
|
...(this.#options.initialPreset === undefined ? {} : { preset: this.#options.initialPreset }),
|
|
258
269
|
env: this.#options.env,
|
|
270
|
+
mcpServers: this.#options.mcpServers,
|
|
271
|
+
systemPrompt: this.#options.systemPrompt,
|
|
272
|
+
toolPolicy: this.#options.toolPolicy,
|
|
259
273
|
onEvent: (payload) => this.#onSessionEvent(payload),
|
|
260
274
|
onAssistantStream: (frame) => this.#onAssistantStream(frame),
|
|
261
275
|
onStatus: (payload) => this.#onStatus(payload),
|
|
@@ -278,6 +292,7 @@ export class DshSession {
|
|
|
278
292
|
});
|
|
279
293
|
this.#process = process;
|
|
280
294
|
await process.start();
|
|
295
|
+
this.#applyModelSelection(await process.setConfig({}));
|
|
281
296
|
if (this.#mode === "plan") {
|
|
282
297
|
await process.setPlan(true);
|
|
283
298
|
}
|
|
@@ -343,11 +358,6 @@ export class DshSession {
|
|
|
343
358
|
return this.#options.models.find((entry) => entry.id === id)?.thinkingOptions ?? [];
|
|
344
359
|
}
|
|
345
360
|
|
|
346
|
-
/** Thinking-effort ids the current model actually declares; empty means none. */
|
|
347
|
-
#supportedEfforts(): string[] {
|
|
348
|
-
return this.#thinking().map((option) => option.id);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
361
|
/**
|
|
352
362
|
* Publish the session's `/` menu: DSH's registered human commands plus every
|
|
353
363
|
* user-invocable skill.
|
|
@@ -393,9 +403,13 @@ export class DshSession {
|
|
|
393
403
|
// A preset whose plugins failed to mount can still be listed. Mark it so the
|
|
394
404
|
// composer does not offer it as a working choice: selecting it would be
|
|
395
405
|
// rejected and silently snap back to the current preset.
|
|
406
|
+
//
|
|
407
|
+
// The composer draws this label itself and the daemon has no idea which
|
|
408
|
+
// language the app is showing, so the marker is written in both languages
|
|
409
|
+
// instead of picking one.
|
|
396
410
|
this.#presetOptions = info.presets.map((preset) => ({
|
|
397
411
|
value: preset.id,
|
|
398
|
-
label: `${preset.name ?? preset.id}${preset.broken === undefined ? "" : "
|
|
412
|
+
label: `${preset.name ?? preset.id}${preset.broken === undefined ? "" : " (unavailable / 不可用)"}`,
|
|
399
413
|
}));
|
|
400
414
|
}
|
|
401
415
|
|
|
@@ -530,7 +544,9 @@ export class DshSession {
|
|
|
530
544
|
type: "notification",
|
|
531
545
|
id: `preset-error:${Date.now()}`,
|
|
532
546
|
level: "error",
|
|
533
|
-
|
|
547
|
+
// Rendered by the host as written: both languages, so neither reader
|
|
548
|
+
// gets a message in the other one.
|
|
549
|
+
message: `Preset switch failed / 切换预设失败:${message}`,
|
|
534
550
|
});
|
|
535
551
|
}
|
|
536
552
|
}
|
|
@@ -738,52 +754,31 @@ export class DshSession {
|
|
|
738
754
|
/** Apply a composer change: model, mode, thinking option or settings. */
|
|
739
755
|
async configure(changes: ProviderConfigChanges): Promise<void> {
|
|
740
756
|
const process = this.#require();
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
if (changes.model !== undefined && changes.model !== null) {
|
|
750
|
-
const next = parseRoute(changes.model, this.#route);
|
|
751
|
-
const applied = await process.setConfig({
|
|
752
|
-
provider: next.provider,
|
|
753
|
-
model: next.model,
|
|
754
|
-
reasoningEffort: next.reasoningEffort ?? null,
|
|
755
|
-
});
|
|
756
|
-
this.#route = {
|
|
757
|
-
provider: applied.provider,
|
|
758
|
-
model: applied.model,
|
|
759
|
-
...(applied.reasoningEffort === null ? {} : { reasoningEffort: applied.reasoningEffort }),
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
if (changes.thinkingOption !== undefined) {
|
|
764
|
-
const requested =
|
|
765
|
-
changes.thinkingOption === null || changes.thinkingOption === "" ? undefined : changes.thinkingOption;
|
|
757
|
+
if ((changes.model !== undefined && changes.model !== null) || changes.thinkingOption !== undefined) {
|
|
758
|
+
const next = changes.model == null ? this.#route : parseRoute(changes.model, this.#route);
|
|
759
|
+
const switched = next.provider !== this.#route.provider || next.model !== this.#route.model;
|
|
760
|
+
let effort = changes.thinkingOption === undefined
|
|
761
|
+
? switched ? undefined : this.#thinkingOption
|
|
762
|
+
: changes.thinkingOption === null || changes.thinkingOption === "" ? undefined : changes.thinkingOption;
|
|
766
763
|
// The runtime rejects a whole turn when handed an effort the model does not
|
|
767
|
-
// declare, and
|
|
768
|
-
//
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
this.#options.log(
|
|
773
|
-
`ignoring unsupported thinking option "${requested}" for ${this.#route.provider}/${this.#route.model}`,
|
|
774
|
-
);
|
|
764
|
+
// declare, and a saved or host-default choice can name one. Serve only what
|
|
765
|
+
// this model advertises and drop anything else; the read-back reports it.
|
|
766
|
+
if (effort !== undefined && !offersThinking(this.#options.models, next, effort)) {
|
|
767
|
+
this.#options.log(`ignoring unsupported thinking option "${effort}" for ${next.provider}/${next.model}`);
|
|
768
|
+
effort = undefined;
|
|
775
769
|
}
|
|
776
|
-
|
|
770
|
+
// Commit model and effort together, then publish only the native result.
|
|
771
|
+
// A failed validation leaves the previous UI selection intact.
|
|
777
772
|
const applied = await process.setConfig({
|
|
778
|
-
provider:
|
|
779
|
-
model:
|
|
773
|
+
provider: next.provider,
|
|
774
|
+
model: next.model,
|
|
780
775
|
reasoningEffort: effort ?? null,
|
|
781
776
|
});
|
|
782
|
-
this.#
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
777
|
+
this.#applyModelSelection(applied);
|
|
778
|
+
if (switched) {
|
|
779
|
+
this.#usageGeneration += 1;
|
|
780
|
+
this.#emitUsage({}, true);
|
|
781
|
+
}
|
|
787
782
|
}
|
|
788
783
|
|
|
789
784
|
if (changes.mode !== undefined && changes.mode !== null) {
|
|
@@ -831,7 +826,9 @@ export class DshSession {
|
|
|
831
826
|
type: "notification",
|
|
832
827
|
id: `preset-error:${Date.now()}`,
|
|
833
828
|
level: "error",
|
|
834
|
-
|
|
829
|
+
// Rendered by the host as written: both languages, so neither reader
|
|
830
|
+
// gets a message in the other one.
|
|
831
|
+
message: `Preset switch failed / 切换预设失败:${message}`,
|
|
835
832
|
});
|
|
836
833
|
}
|
|
837
834
|
}
|
|
@@ -1598,6 +1595,18 @@ export class DshSession {
|
|
|
1598
1595
|
this.#options.emit({ type: "session.permission", sessionId: this.id, request: permission });
|
|
1599
1596
|
});
|
|
1600
1597
|
}
|
|
1598
|
+
|
|
1599
|
+
#applyModelSelection(applied: { provider: string; model: string; reasoningEffort: string | null }): void {
|
|
1600
|
+
if (typeof applied.provider !== "string" || typeof applied.model !== "string") {
|
|
1601
|
+
throw new Error("DSH returned an incomplete model selection");
|
|
1602
|
+
}
|
|
1603
|
+
this.#route = {
|
|
1604
|
+
provider: applied.provider,
|
|
1605
|
+
model: applied.model,
|
|
1606
|
+
...(applied.reasoningEffort == null ? {} : { reasoningEffort: applied.reasoningEffort }),
|
|
1607
|
+
};
|
|
1608
|
+
this.#thinkingOption = applied.reasoningEffort ?? undefined;
|
|
1609
|
+
}
|
|
1601
1610
|
}
|
|
1602
1611
|
|
|
1603
1612
|
/**
|
package/server/timeline.ts
CHANGED
|
@@ -111,9 +111,12 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
|
|
|
111
111
|
...(output === undefined ? {} : { result: output }),
|
|
112
112
|
};
|
|
113
113
|
case "todo_write":
|
|
114
|
-
|
|
114
|
+
// The protocol has no todo or question detail type, and inventing one
|
|
115
|
+
// would break the shape the host validates. These two tools carry their
|
|
116
|
+
// own input, so the row is derived from the tool name on the client.
|
|
117
|
+
return { type: "unknown", input: input as unknown as JsonValue, output: (output ?? null) as JsonValue };
|
|
115
118
|
case "ask_user_question":
|
|
116
|
-
return { type: "
|
|
119
|
+
return { type: "unknown", input: input as unknown as JsonValue, output: (output ?? null) as JsonValue };
|
|
117
120
|
case "exit_plan_mode":
|
|
118
121
|
// Paseo renders this as the readable plan card, and its own Codex adapter
|
|
119
122
|
// emits the same item next to the approval buttons. The plan has to be
|
|
@@ -123,7 +126,9 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
|
|
|
123
126
|
const childSessionId = childSessionIdOf(output);
|
|
124
127
|
return {
|
|
125
128
|
type: "sub_agent",
|
|
126
|
-
|
|
129
|
+
// Drawn by the host as written, and the daemon cannot see the app
|
|
130
|
+
// language, so both languages are spelled out.
|
|
131
|
+
subAgentType: "Sub-agent / 子代理",
|
|
127
132
|
...(stringField(input, "description") === undefined
|
|
128
133
|
? {}
|
|
129
134
|
: { description: stringField(input, "description") as string }),
|
package/shared/image-preview.ts
CHANGED
|
@@ -9,6 +9,10 @@ import { z } from "zod";
|
|
|
9
9
|
* Files above the soft limit are reported as `tooLarge` so the client can ask
|
|
10
10
|
* the reader before paying the base64/WebSocket cost; `allowLarge` bypasses it
|
|
11
11
|
* up to the daemon's hard ceiling.
|
|
12
|
+
*
|
|
13
|
+
* Failures cross the wire as a code plus the raw operating-system detail, never
|
|
14
|
+
* as a sentence: the daemon does not know which language the app is showing,
|
|
15
|
+
* so the client is the one that phrases the reason.
|
|
12
16
|
*/
|
|
13
17
|
export const imagePreviewRpc = defineRpc({
|
|
14
18
|
name: "file.image",
|
|
@@ -20,9 +24,12 @@ export const imagePreviewRpc = defineRpc({
|
|
|
20
24
|
output: z.object({
|
|
21
25
|
dataUri: z.string().nullable(),
|
|
22
26
|
mime: z.string().nullable(),
|
|
23
|
-
|
|
27
|
+
errorCode: z.enum(["unsupported-format", "not-file", "too-large", "too-large-hard", "unreadable"]).nullable(),
|
|
28
|
+
errorDetail: z.string().nullable(),
|
|
24
29
|
bytes: z.number().nullable(),
|
|
25
30
|
limit: z.number().nullable(),
|
|
26
31
|
tooLarge: z.boolean(),
|
|
27
32
|
}),
|
|
28
33
|
});
|
|
34
|
+
|
|
35
|
+
export type ImageErrorCode = z.infer<typeof imagePreviewRpc.output>["errorCode"] & string;
|
package/shared/settings.ts
CHANGED
|
@@ -48,46 +48,17 @@ export const TIMELINE_STYLE_DEFAULTS: TimelineStyleValues = {
|
|
|
48
48
|
commandMinHeight: 120,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
label: "正在输出的思考行额外间距",
|
|
66
|
-
hint: "只作用于正在流式输出的思考行。默认 8,负值可能重叠。",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
key: "toolRowPaddingY",
|
|
70
|
-
label: "工具行上下内边距(行内留白)",
|
|
71
|
-
hint: "只改行内留白,不改工具之间的距离;要缩小行间距请改上面的“工具之间的额外间距”。范围 0 ~ 12。",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
key: "toolRowMinHeight",
|
|
75
|
-
label: "工具行最小高度",
|
|
76
|
-
hint: "整行至少多高;配合内边距 0 可压到接近图标高度(约 17px)。范围 12 ~ 64。",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
key: "toolRowGap",
|
|
80
|
-
label: "图标与文字的水平间距",
|
|
81
|
-
hint: "图标、动词、目标之间。范围 0 ~ 24。",
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
key: "commandMaxHeightRatio",
|
|
85
|
-
label: "命令块最大高度(窗口占比)",
|
|
86
|
-
hint: "0.25 表示最多占窗口高度的四分之一;超过后命令块内部滚动,输出区始终保留。范围 0.1 ~ 0.6。",
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
key: "commandMinHeight",
|
|
90
|
-
label: "命令块最小高度上限",
|
|
91
|
-
hint: "窗口很小时仍给命令块保留的高度(像素)。范围 60 ~ 360。",
|
|
92
|
-
},
|
|
93
|
-
];
|
|
51
|
+
/**
|
|
52
|
+
* Editor order for the settings screen. The label and hint text lives in the
|
|
53
|
+
* client locale catalogs (`settings.field.<key>.label` / `.hint`), so the shared
|
|
54
|
+
* contract carries keys only and the app language decides the wording.
|
|
55
|
+
*/
|
|
56
|
+
export const TIMELINE_STYLE_KEYS = [
|
|
57
|
+
"toolRowMarginY",
|
|
58
|
+
"liveReasoningRowMarginY",
|
|
59
|
+
"toolRowPaddingY",
|
|
60
|
+
"toolRowMinHeight",
|
|
61
|
+
"toolRowGap",
|
|
62
|
+
"commandMaxHeightRatio",
|
|
63
|
+
"commandMinHeight",
|
|
64
|
+
] as const satisfies readonly TimelineStyleKey[];
|