paseo-dsh 0.2.18 → 0.2.20
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 +2 -0
- package/README.md +4 -0
- package/THIRD-PARTY-NOTICES.md +36 -0
- package/client/react-native.d.ts +4 -0
- package/client/settings-screen.tsx +144 -0
- package/client/timeline.tsx +1444 -0
- package/index.client.tsx +10 -1
- package/index.server.ts +57 -0
- package/lib/doctor.mjs +14 -2
- package/package.json +6 -2
- package/server/bridge-assets.ts +2 -1
- package/server/dsh-command.d.mts +7 -0
- package/server/dsh-command.mjs +40 -0
- package/server/dsh-process.ts +18 -11
- package/server/provider.ts +29 -9
- package/server/session.ts +48 -47
- package/server/timeline.ts +2 -0
- package/shared/image-preview.ts +28 -0
- package/shared/settings.ts +93 -0
package/server/dsh-process.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderMcpServerConfig, ProviderToolPolicy } from "@getpaseo/plugin/server/provider";
|
|
1
2
|
/**
|
|
2
3
|
* One `dsh --profile paseo` child process, speaking the bridge's stdio JSON-RPC.
|
|
3
4
|
*
|
|
@@ -9,12 +10,13 @@
|
|
|
9
10
|
*/
|
|
10
11
|
import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
|
|
11
12
|
import { existsSync } from "node:fs";
|
|
13
|
+
import { resolveDshCommand } from "./dsh-command.mjs";
|
|
12
14
|
|
|
13
15
|
/** Provider/model/thinking route pinned for the life of one process. */
|
|
14
16
|
export interface DshRoute {
|
|
15
17
|
provider: string;
|
|
16
18
|
model: string;
|
|
17
|
-
reasoningEffort?: string;
|
|
19
|
+
reasoningEffort?: string | null;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/** One question the model asked, mirroring DSH's `AskUserQuestionItem`. */
|
|
@@ -150,6 +152,9 @@ export interface DshProcessOptions extends DshProcessHandlers {
|
|
|
150
152
|
preset?: string;
|
|
151
153
|
/** Extra environment for the child; merged over the daemon's environment. */
|
|
152
154
|
env?: Record<string, string>;
|
|
155
|
+
mcpServers?: Readonly<Record<string, ProviderMcpServerConfig>>;
|
|
156
|
+
systemPrompt?: string;
|
|
157
|
+
toolPolicy?: ProviderToolPolicy;
|
|
153
158
|
/**
|
|
154
159
|
* Whether `start()` pins a route with `initialize`. Catalog reads skip it,
|
|
155
160
|
* because `paseo/catalog` needs no agent and a bad route must not hide the
|
|
@@ -158,14 +163,10 @@ export interface DshProcessOptions extends DshProcessHandlers {
|
|
|
158
163
|
initializeRoute?: boolean;
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
].filter((value): value is string => typeof value === "string" && value.length > 0);
|
|
166
|
-
|
|
167
|
-
function resolveBinary(): string {
|
|
168
|
-
for (const candidate of BINARY_CANDIDATES) {
|
|
166
|
+
function resolveBinary(env: NodeJS.ProcessEnv): string {
|
|
167
|
+
const candidates = [env.DSH_BINARY, "dsh", `${env.HOME ?? ""}/.local/bin/dsh`]
|
|
168
|
+
.filter((value): value is string => typeof value === "string" && value.length > 0);
|
|
169
|
+
for (const candidate of candidates) {
|
|
169
170
|
if (candidate.includes("/") && existsSync(candidate)) return candidate;
|
|
170
171
|
if (!candidate.includes("/")) return candidate;
|
|
171
172
|
}
|
|
@@ -205,10 +206,12 @@ export class DshProcess {
|
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
async #start(): Promise<void> {
|
|
208
|
-
const
|
|
209
|
+
const env = { ...process.env, ...this.#options.env };
|
|
210
|
+
const launch = resolveDshCommand(resolveBinary(env), env, this.#options.cwd);
|
|
211
|
+
const child = spawn(launch.command, [...launch.args, "--profile", env.DSH_PASEO_PROFILE ?? "paseo"], {
|
|
209
212
|
cwd: this.#options.cwd,
|
|
210
213
|
stdio: ["pipe", "pipe", "pipe"],
|
|
211
|
-
env
|
|
214
|
+
env,
|
|
212
215
|
});
|
|
213
216
|
this.#child = child;
|
|
214
217
|
|
|
@@ -245,6 +248,10 @@ export class DshProcess {
|
|
|
245
248
|
}
|
|
246
249
|
|
|
247
250
|
await this.#request("initialize", {
|
|
251
|
+
sessionId: this.#options.sessionId,
|
|
252
|
+
mcpServers: this.#options.mcpServers ?? {},
|
|
253
|
+
...(this.#options.systemPrompt === undefined ? {} : { systemPrompt: this.#options.systemPrompt }),
|
|
254
|
+
...(this.#options.toolPolicy === undefined ? {} : { toolPolicy: this.#options.toolPolicy }),
|
|
248
255
|
cwd: this.#options.cwd,
|
|
249
256
|
provider: this.#options.route.provider,
|
|
250
257
|
model: this.#options.route.model,
|
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.
|
|
@@ -738,52 +748,31 @@ export class DshSession {
|
|
|
738
748
|
/** Apply a composer change: model, mode, thinking option or settings. */
|
|
739
749
|
async configure(changes: ProviderConfigChanges): Promise<void> {
|
|
740
750
|
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;
|
|
751
|
+
if ((changes.model !== undefined && changes.model !== null) || changes.thinkingOption !== undefined) {
|
|
752
|
+
const next = changes.model == null ? this.#route : parseRoute(changes.model, this.#route);
|
|
753
|
+
const switched = next.provider !== this.#route.provider || next.model !== this.#route.model;
|
|
754
|
+
let effort = changes.thinkingOption === undefined
|
|
755
|
+
? switched ? undefined : this.#thinkingOption
|
|
756
|
+
: changes.thinkingOption === null || changes.thinkingOption === "" ? undefined : changes.thinkingOption;
|
|
766
757
|
// 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
|
-
);
|
|
758
|
+
// declare, and a saved or host-default choice can name one. Serve only what
|
|
759
|
+
// this model advertises and drop anything else; the read-back reports it.
|
|
760
|
+
if (effort !== undefined && !offersThinking(this.#options.models, next, effort)) {
|
|
761
|
+
this.#options.log(`ignoring unsupported thinking option "${effort}" for ${next.provider}/${next.model}`);
|
|
762
|
+
effort = undefined;
|
|
775
763
|
}
|
|
776
|
-
|
|
764
|
+
// Commit model and effort together, then publish only the native result.
|
|
765
|
+
// A failed validation leaves the previous UI selection intact.
|
|
777
766
|
const applied = await process.setConfig({
|
|
778
|
-
provider:
|
|
779
|
-
model:
|
|
767
|
+
provider: next.provider,
|
|
768
|
+
model: next.model,
|
|
780
769
|
reasoningEffort: effort ?? null,
|
|
781
770
|
});
|
|
782
|
-
this.#
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
771
|
+
this.#applyModelSelection(applied);
|
|
772
|
+
if (switched) {
|
|
773
|
+
this.#usageGeneration += 1;
|
|
774
|
+
this.#emitUsage({}, true);
|
|
775
|
+
}
|
|
787
776
|
}
|
|
788
777
|
|
|
789
778
|
if (changes.mode !== undefined && changes.mode !== null) {
|
|
@@ -1598,6 +1587,18 @@ export class DshSession {
|
|
|
1598
1587
|
this.#options.emit({ type: "session.permission", sessionId: this.id, request: permission });
|
|
1599
1588
|
});
|
|
1600
1589
|
}
|
|
1590
|
+
|
|
1591
|
+
#applyModelSelection(applied: { provider: string; model: string; reasoningEffort: string | null }): void {
|
|
1592
|
+
if (typeof applied.provider !== "string" || typeof applied.model !== "string") {
|
|
1593
|
+
throw new Error("DSH returned an incomplete model selection");
|
|
1594
|
+
}
|
|
1595
|
+
this.#route = {
|
|
1596
|
+
provider: applied.provider,
|
|
1597
|
+
model: applied.model,
|
|
1598
|
+
...(applied.reasoningEffort == null ? {} : { reasoningEffort: applied.reasoningEffort }),
|
|
1599
|
+
};
|
|
1600
|
+
this.#thinkingOption = applied.reasoningEffort ?? undefined;
|
|
1601
|
+
}
|
|
1601
1602
|
}
|
|
1602
1603
|
|
|
1603
1604
|
/**
|
package/server/timeline.ts
CHANGED
|
@@ -69,6 +69,7 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
case "read":
|
|
72
|
+
case "read_image":
|
|
72
73
|
return {
|
|
73
74
|
type: "read",
|
|
74
75
|
filePath: filePath ?? "",
|
|
@@ -103,6 +104,7 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
|
|
|
103
104
|
...(output === undefined ? {} : { content: output }),
|
|
104
105
|
};
|
|
105
106
|
case "web_fetch":
|
|
107
|
+
case "webfetch":
|
|
106
108
|
return {
|
|
107
109
|
type: "fetch",
|
|
108
110
|
url: stringField(input, "url") ?? "",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reads an image file so the timeline can draw it. The bytes never travel
|
|
6
|
+
* through the provider timeline, so the daemon side loads the file and returns
|
|
7
|
+
* a data URI (or the reason it cannot be shown).
|
|
8
|
+
*
|
|
9
|
+
* Files above the soft limit are reported as `tooLarge` so the client can ask
|
|
10
|
+
* the reader before paying the base64/WebSocket cost; `allowLarge` bypasses it
|
|
11
|
+
* up to the daemon's hard ceiling.
|
|
12
|
+
*/
|
|
13
|
+
export const imagePreviewRpc = defineRpc({
|
|
14
|
+
name: "file.image",
|
|
15
|
+
input: z.object({
|
|
16
|
+
cwd: z.string(),
|
|
17
|
+
path: z.string(),
|
|
18
|
+
allowLarge: z.boolean().optional(),
|
|
19
|
+
}),
|
|
20
|
+
output: z.object({
|
|
21
|
+
dataUri: z.string().nullable(),
|
|
22
|
+
mime: z.string().nullable(),
|
|
23
|
+
error: z.string().nullable(),
|
|
24
|
+
bytes: z.number().nullable(),
|
|
25
|
+
limit: z.number().nullable(),
|
|
26
|
+
tooLarge: z.boolean(),
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { defineSettings } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Host-scoped presentation knobs for the DSH timeline rows and the tool drawer.
|
|
6
|
+
*
|
|
7
|
+
* The timeline row's own margin stacks on top of the host item spacing (Paseo
|
|
8
|
+
* already puts 16px between timeline items), so negative values tighten the
|
|
9
|
+
* visible gap while positive values widen it.
|
|
10
|
+
*/
|
|
11
|
+
export const timelineStyleSettings = defineSettings({
|
|
12
|
+
id: "timeline-style",
|
|
13
|
+
scope: "host",
|
|
14
|
+
version: 3,
|
|
15
|
+
migrate(values, fromVersion) {
|
|
16
|
+
if (!isRecord(values)) return values;
|
|
17
|
+
const { liveToolRowMarginY: _dropped, liveRowMarginY, ...rest } = values;
|
|
18
|
+
if (fromVersion < 2) {
|
|
19
|
+
rest["liveReasoningRowMarginY"] = typeof liveRowMarginY === "number" ? liveRowMarginY : 8;
|
|
20
|
+
}
|
|
21
|
+
return rest;
|
|
22
|
+
},
|
|
23
|
+
schema: z.object({
|
|
24
|
+
toolRowMarginY: z.number().min(-16).max(24).default(-8),
|
|
25
|
+
liveReasoningRowMarginY: z.number().min(-16).max(24).default(8),
|
|
26
|
+
toolRowPaddingY: z.number().min(0).max(12).default(0),
|
|
27
|
+
toolRowMinHeight: z.number().min(12).max(64).default(16),
|
|
28
|
+
toolRowGap: z.number().min(0).max(24).default(6),
|
|
29
|
+
commandMaxHeightRatio: z.number().min(0.1).max(0.6).default(0.25),
|
|
30
|
+
commandMinHeight: z.number().min(60).max(360).default(120),
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
35
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type TimelineStyleValues = z.output<typeof timelineStyleSettings.schema>;
|
|
39
|
+
export type TimelineStyleKey = keyof TimelineStyleValues;
|
|
40
|
+
|
|
41
|
+
export const TIMELINE_STYLE_DEFAULTS: TimelineStyleValues = {
|
|
42
|
+
toolRowMarginY: -8,
|
|
43
|
+
liveReasoningRowMarginY: 8,
|
|
44
|
+
toolRowPaddingY: 0,
|
|
45
|
+
toolRowMinHeight: 16,
|
|
46
|
+
toolRowGap: 6,
|
|
47
|
+
commandMaxHeightRatio: 0.25,
|
|
48
|
+
commandMinHeight: 120,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export interface TimelineStyleField {
|
|
52
|
+
key: TimelineStyleKey;
|
|
53
|
+
label: string;
|
|
54
|
+
hint: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const TIMELINE_STYLE_FIELDS: readonly TimelineStyleField[] = [
|
|
58
|
+
{
|
|
59
|
+
key: "toolRowMarginY",
|
|
60
|
+
label: "工具之间的额外间距",
|
|
61
|
+
hint: "叠加在宿主固定 16px 之上,可填负数:8 → 约 24px,-8 → 约 8px,-16 → 约 0px。范围 -16 ~ 24。",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: "liveReasoningRowMarginY",
|
|
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
|
+
];
|