paseo-dsh 0.2.17 → 0.2.19
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/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 +5 -2
- package/server/bridge-assets.ts +1 -1
- package/server/dsh-command.d.mts +7 -0
- package/server/dsh-command.mjs +40 -0
- package/server/dsh-process.ts +94 -19
- package/server/provider.ts +34 -7
- package/server/session.ts +558 -21
- package/server/timeline.ts +39 -8
- package/shared/image-preview.ts +28 -0
- package/shared/settings.ts +93 -0
package/server/timeline.ts
CHANGED
|
@@ -47,6 +47,11 @@ function stringField(source: Record<string, unknown>, key: string): string | und
|
|
|
47
47
|
return typeof value === "string" && value !== "" ? value : undefined;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/** DSH returns `started subagent <childId>` when a subagent starts. */
|
|
51
|
+
function childSessionIdOf(output: string | undefined): string | undefined {
|
|
52
|
+
return output?.match(/^\s*started subagent ([A-Za-z0-9][A-Za-z0-9_-]*)\s*$/)?.[1];
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
/** Map one DSH tool call onto the richest Paseo tool detail available. */
|
|
51
56
|
function toolDetail(name: string, input: Record<string, unknown>, output?: string): ProviderToolCallDetail {
|
|
52
57
|
const filePath = stringField(input, "file_path") ?? stringField(input, "filePath");
|
|
@@ -64,6 +69,7 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
|
|
|
64
69
|
};
|
|
65
70
|
}
|
|
66
71
|
case "read":
|
|
72
|
+
case "read_image":
|
|
67
73
|
return {
|
|
68
74
|
type: "read",
|
|
69
75
|
filePath: filePath ?? "",
|
|
@@ -98,6 +104,7 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
|
|
|
98
104
|
...(output === undefined ? {} : { content: output }),
|
|
99
105
|
};
|
|
100
106
|
case "web_fetch":
|
|
107
|
+
case "webfetch":
|
|
101
108
|
return {
|
|
102
109
|
type: "fetch",
|
|
103
110
|
url: stringField(input, "url") ?? "",
|
|
@@ -112,14 +119,18 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
|
|
|
112
119
|
// emits the same item next to the approval buttons. The plan has to be
|
|
113
120
|
// visible *before* the choice, so this is the copy that carries it.
|
|
114
121
|
return { type: "plan", text: stringField(input, "plan") ?? "" };
|
|
115
|
-
case "subagent":
|
|
122
|
+
case "subagent": {
|
|
123
|
+
const childSessionId = childSessionIdOf(output);
|
|
116
124
|
return {
|
|
117
125
|
type: "sub_agent",
|
|
126
|
+
subAgentType: "Sub-agent",
|
|
118
127
|
...(stringField(input, "description") === undefined
|
|
119
128
|
? {}
|
|
120
129
|
: { description: stringField(input, "description") as string }),
|
|
130
|
+
...(childSessionId === undefined ? {} : { childSessionId }),
|
|
121
131
|
log: output ?? "",
|
|
122
132
|
};
|
|
133
|
+
}
|
|
123
134
|
default:
|
|
124
135
|
return {
|
|
125
136
|
type: "unknown",
|
|
@@ -129,17 +140,37 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
|
|
|
129
140
|
}
|
|
130
141
|
}
|
|
131
142
|
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
type TodoStatus = "pending" | "in_progress" | "completed";
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Extract `todo_write` items into Paseo's native todo row.
|
|
147
|
+
*
|
|
148
|
+
* Paseo decides between pending, in progress and completed from `status`; the
|
|
149
|
+
* older `completed` boolean alone makes every unfinished task look pending.
|
|
150
|
+
*/
|
|
151
|
+
function todoItems(
|
|
152
|
+
input: Record<string, unknown>,
|
|
153
|
+
): Array<{ text: string; completed: boolean; status: TodoStatus; activeForm?: string }> | null {
|
|
134
154
|
const raw = input.todos;
|
|
135
155
|
if (!Array.isArray(raw)) return null;
|
|
136
156
|
const items = raw
|
|
137
157
|
.filter(isRecord)
|
|
138
|
-
.map((todo) =>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
.map((todo) => {
|
|
159
|
+
const status: TodoStatus =
|
|
160
|
+
todo.status === "completed"
|
|
161
|
+
? "completed"
|
|
162
|
+
: todo.status === "in_progress"
|
|
163
|
+
? "in_progress"
|
|
164
|
+
: "pending";
|
|
165
|
+
const activeForm = stringField(todo, "activeForm");
|
|
166
|
+
return {
|
|
167
|
+
text:
|
|
168
|
+
stringField(todo, "content") ?? stringField(todo, "text") ?? activeForm ?? "",
|
|
169
|
+
completed: status === "completed",
|
|
170
|
+
status,
|
|
171
|
+
...(activeForm === undefined ? {} : { activeForm }),
|
|
172
|
+
};
|
|
173
|
+
})
|
|
143
174
|
.filter((todo) => todo.text !== "");
|
|
144
175
|
return items.length === 0 ? null : items;
|
|
145
176
|
}
|
|
@@ -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
|
+
];
|