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/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 }),
|
|
@@ -179,6 +184,7 @@ export class TimelineBuilder {
|
|
|
179
184
|
#items = new Map<string, ProviderTimelineItem>();
|
|
180
185
|
#toolNames = new Map<string, string>();
|
|
181
186
|
#toolInputs = new Map<string, Record<string, unknown>>();
|
|
187
|
+
#delegations = new Set<string>();
|
|
182
188
|
|
|
183
189
|
/**
|
|
184
190
|
* Fold one DSH session event into zero or more complete Paseo item snapshots.
|
|
@@ -195,6 +201,15 @@ export class TimelineBuilder {
|
|
|
195
201
|
return this.#toolCall(data);
|
|
196
202
|
case "tool/result":
|
|
197
203
|
return this.#toolResult(data);
|
|
204
|
+
case "tool/ptc-dispatch":
|
|
205
|
+
return this.#ptcSpecialResult(data);
|
|
206
|
+
case "tool/ptc-dispatch-start": {
|
|
207
|
+
const callId = stringField(data, "subCallId");
|
|
208
|
+
const name = stringField(data, "name");
|
|
209
|
+
if (callId === undefined || name === undefined || !["subagent", "subagent_fork", "workflow"].includes(name)) return [];
|
|
210
|
+
const input = parseArguments(data.arguments);
|
|
211
|
+
return this.subagent(callId, name, stringField(input, "description"));
|
|
212
|
+
}
|
|
198
213
|
case "turn/end":
|
|
199
214
|
return this.#turnEnd(data);
|
|
200
215
|
default:
|
|
@@ -207,6 +222,35 @@ export class TimelineBuilder {
|
|
|
207
222
|
return [item];
|
|
208
223
|
}
|
|
209
224
|
|
|
225
|
+
/** Native provenance also identifies custom delegation tool aliases. */
|
|
226
|
+
subagent(callId: string, name: string, description?: string, childSessionId?: string): ProviderTimelineItem[] {
|
|
227
|
+
this.#delegations.add(callId);
|
|
228
|
+
this.#toolNames.set(callId, name);
|
|
229
|
+
const input = { ...this.#toolInputs.get(callId), ...(description === undefined ? {} : { description }) };
|
|
230
|
+
this.#toolInputs.set(callId, input);
|
|
231
|
+
const previous = this.#items.get(`tool:${callId}`);
|
|
232
|
+
const detail = previous?.type === "tool_call" && previous.detail.type === "sub_agent" ? previous.detail : undefined;
|
|
233
|
+
return this.#put({
|
|
234
|
+
type: "tool_call", id: `tool:${callId}`, callId, name,
|
|
235
|
+
status: previous?.type === "tool_call" ? previous.status : "running", error: null,
|
|
236
|
+
detail: { type: "sub_agent", subAgentType: "Sub-agent / 子代理", log: detail?.log ?? "",
|
|
237
|
+
...(description === undefined ? {} : { description }),
|
|
238
|
+
...(childSessionId === undefined ? {} : { childSessionId }),
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** End a display's spinner on cancellation or a disconnected runtime. */
|
|
244
|
+
finishPending(status: "completed" | "failed" | "canceled"): ProviderTimelineItem[] {
|
|
245
|
+
const out: ProviderTimelineItem[] = [];
|
|
246
|
+
for (const item of this.#items.values()) {
|
|
247
|
+
if (item.type === "tool_call" && this.#delegations.has(item.callId) && item.status === "running") {
|
|
248
|
+
out.push(...this.#put({ ...item, status }));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
|
|
210
254
|
#assistantMessage(data: Record<string, unknown>): ProviderTimelineItem[] {
|
|
211
255
|
const message = isRecord(data.message) ? data.message : undefined;
|
|
212
256
|
const content = message?.content;
|
|
@@ -266,6 +310,22 @@ export class TimelineBuilder {
|
|
|
266
310
|
return this.#emitToolCall(callId, name, input, status === "running" ? "running" : status);
|
|
267
311
|
}
|
|
268
312
|
|
|
313
|
+
/** Keep semantic cards, without flattening internal file/shell dispatches. */
|
|
314
|
+
#ptcSpecialResult(data: Record<string, unknown>): ProviderTimelineItem[] {
|
|
315
|
+
const callId = stringField(data, "subCallId");
|
|
316
|
+
if (callId === undefined) return [];
|
|
317
|
+
const name = stringField(data, "name");
|
|
318
|
+
if (name === undefined) return [];
|
|
319
|
+
const input = parseArguments(data.arguments);
|
|
320
|
+
if (!["subagent", "subagent_fork", "workflow"].includes(name) && !this.#delegations.has(callId)) return [];
|
|
321
|
+
this.#delegations.add(callId);
|
|
322
|
+
this.#toolNames.set(callId, name);
|
|
323
|
+
this.#toolInputs.set(callId, input);
|
|
324
|
+
return this.#toolResult({
|
|
325
|
+
message: { toolCallId: callId, content: data.content, isError: data.isError },
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
269
329
|
#toolResult(data: Record<string, unknown>): ProviderTimelineItem[] {
|
|
270
330
|
const message = isRecord(data.message) ? data.message : undefined;
|
|
271
331
|
const callId = stringField(data, "toolCallId") ?? (message === undefined ? undefined : stringField(message, "toolCallId"));
|
|
@@ -282,13 +342,18 @@ export class TimelineBuilder {
|
|
|
282
342
|
out.push(...this.#put({ type: "todo", id: `todo:${callId}`, items }));
|
|
283
343
|
}
|
|
284
344
|
}
|
|
345
|
+
let detail = toolDetail(this.#delegations.has(callId) ? "subagent" : name, input, output || undefined);
|
|
346
|
+
const previous = this.#items.get(`tool:${callId}`);
|
|
347
|
+
if (detail.type === "sub_agent" && previous?.type === "tool_call" && previous.detail.type === "sub_agent") {
|
|
348
|
+
detail = { ...previous.detail, ...detail };
|
|
349
|
+
}
|
|
285
350
|
out.push(
|
|
286
351
|
...this.#put({
|
|
287
352
|
type: "tool_call",
|
|
288
353
|
id: `tool:${callId}`,
|
|
289
354
|
callId,
|
|
290
355
|
name,
|
|
291
|
-
detail
|
|
356
|
+
detail,
|
|
292
357
|
...(failed
|
|
293
358
|
? { status: "failed" as const, error: { message: output || "tool failed" } }
|
|
294
359
|
: { status: "completed" as const, error: null }),
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Wire contract between the DSH Plugins page and the plugin server.
|
|
6
|
+
*
|
|
7
|
+
* Kept in one file so the client and server cannot drift: both import these
|
|
8
|
+
* schemas, and Paseo parses every input/output at the RPC boundary.
|
|
9
|
+
*
|
|
10
|
+
* Failures cross this boundary as a code plus optional raw detail. The daemon
|
|
11
|
+
* never writes user-facing sentences: the page chooses the language.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export const jobKindSchema = z.enum(["install", "remove", "update", "check"]);
|
|
15
|
+
export const jobStateSchema = z.enum(["running", "succeeded", "failed"]);
|
|
16
|
+
|
|
17
|
+
export const failureCodeSchema = z.enum([
|
|
18
|
+
"profile-unreadable",
|
|
19
|
+
"profile-invalid",
|
|
20
|
+
"invalid-platform",
|
|
21
|
+
"lock-timeout",
|
|
22
|
+
"invalid-name",
|
|
23
|
+
"protected",
|
|
24
|
+
"not-installed",
|
|
25
|
+
"not-a-bundle",
|
|
26
|
+
"invalid-spec",
|
|
27
|
+
"registry-unreadable",
|
|
28
|
+
"registry-invalid",
|
|
29
|
+
"already-installed",
|
|
30
|
+
"not-removable",
|
|
31
|
+
"not-in-dependencies",
|
|
32
|
+
"invalid-version",
|
|
33
|
+
"check-failed",
|
|
34
|
+
"disposed",
|
|
35
|
+
"busy",
|
|
36
|
+
"job-missing",
|
|
37
|
+
"spawn-failed",
|
|
38
|
+
"command-failed",
|
|
39
|
+
"request-failed",
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
const failureFields = {
|
|
43
|
+
errorCode: failureCodeSchema.optional(),
|
|
44
|
+
errorDetail: z.string().optional(),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const bundleRowSchema = z.object({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
module: z.string().optional(),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const bundleInfoSchema = z.object({
|
|
53
|
+
name: z.string(),
|
|
54
|
+
version: z.string().optional(),
|
|
55
|
+
description: z.string().optional(),
|
|
56
|
+
enabled: z.boolean(),
|
|
57
|
+
installed: z.boolean(),
|
|
58
|
+
kind: z.enum(["bundle", "dependency", "missing"]),
|
|
59
|
+
protected: z.boolean(),
|
|
60
|
+
official: z.boolean(),
|
|
61
|
+
client: z.boolean(),
|
|
62
|
+
platformSupported: z.boolean(),
|
|
63
|
+
platformReason: z.string().optional(),
|
|
64
|
+
removable: z.boolean(),
|
|
65
|
+
updatable: z.boolean(),
|
|
66
|
+
update: z.string().optional(),
|
|
67
|
+
rows: z.array(bundleRowSchema),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const pluginsSnapshotSchema = z.object({
|
|
71
|
+
profile: z.string(),
|
|
72
|
+
dir: z.string(),
|
|
73
|
+
displayDir: z.string(),
|
|
74
|
+
bundles: z.array(bundleInfoSchema),
|
|
75
|
+
busy: z.boolean(),
|
|
76
|
+
activeJobId: z.string().optional(),
|
|
77
|
+
activeJobKind: jobKindSchema.optional(),
|
|
78
|
+
...failureFields,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const jobStatusSchema = z.object({
|
|
82
|
+
id: z.string(),
|
|
83
|
+
kind: jobKindSchema,
|
|
84
|
+
state: jobStateSchema,
|
|
85
|
+
output: z.string(),
|
|
86
|
+
updates: z.record(z.string(), z.string()).optional(),
|
|
87
|
+
startedAt: z.number(),
|
|
88
|
+
finishedAt: z.number().optional(),
|
|
89
|
+
...failureFields,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export const setEnabledInputSchema = z.object({
|
|
93
|
+
name: z.string().min(1),
|
|
94
|
+
enabled: z.boolean(),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export const setEnabledOutputSchema = z.object({
|
|
98
|
+
ok: z.boolean(),
|
|
99
|
+
changed: z.boolean(),
|
|
100
|
+
enabled: z.boolean(),
|
|
101
|
+
...failureFields,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export const inspectSpecInputSchema = z.object({
|
|
105
|
+
spec: z.string().min(1),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export const inspectSpecOutputSchema = z.object({
|
|
109
|
+
ok: z.boolean(),
|
|
110
|
+
name: z.string().optional(),
|
|
111
|
+
version: z.string().optional(),
|
|
112
|
+
description: z.string().optional(),
|
|
113
|
+
client: z.boolean(),
|
|
114
|
+
...failureFields,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const startJobInputSchema = z.discriminatedUnion("kind", [
|
|
118
|
+
z.object({ kind: z.literal("install"), spec: z.string().min(1) }),
|
|
119
|
+
z.object({ kind: z.literal("remove"), name: z.string().min(1) }),
|
|
120
|
+
z.object({ kind: z.literal("update"), name: z.string().min(1), version: z.string().min(1) }),
|
|
121
|
+
z.object({ kind: z.literal("check") }),
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
export const startJobOutputSchema = z.object({
|
|
125
|
+
ok: z.boolean(),
|
|
126
|
+
id: z.string().optional(),
|
|
127
|
+
...failureFields,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export const jobIdInputSchema = z.object({
|
|
131
|
+
id: z.string().min(1),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export type JobKind = z.infer<typeof jobKindSchema>;
|
|
135
|
+
export type JobState = z.infer<typeof jobStateSchema>;
|
|
136
|
+
export type FailureCode = z.infer<typeof failureCodeSchema>;
|
|
137
|
+
export type BundleRow = z.infer<typeof bundleRowSchema>;
|
|
138
|
+
export type BundleInfo = z.infer<typeof bundleInfoSchema>;
|
|
139
|
+
export type PluginsSnapshot = z.infer<typeof pluginsSnapshotSchema>;
|
|
140
|
+
export type JobStatus = z.infer<typeof jobStatusSchema>;
|
|
141
|
+
export type SetEnabledInput = z.infer<typeof setEnabledInputSchema>;
|
|
142
|
+
export type SetEnabledOutput = z.infer<typeof setEnabledOutputSchema>;
|
|
143
|
+
export type InspectSpecOutput = z.infer<typeof inspectSpecOutputSchema>;
|
|
144
|
+
export type StartJobInput = z.infer<typeof startJobInputSchema>;
|
|
145
|
+
export type StartJobOutput = z.infer<typeof startJobOutputSchema>;
|
|
146
|
+
|
|
147
|
+
export const listRpc = defineRpc({
|
|
148
|
+
name: "dsh-plugins.list",
|
|
149
|
+
input: z.object({}),
|
|
150
|
+
output: pluginsSnapshotSchema,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export const setEnabledRpc = defineRpc({
|
|
154
|
+
name: "dsh-plugins.set-enabled",
|
|
155
|
+
input: setEnabledInputSchema,
|
|
156
|
+
output: setEnabledOutputSchema,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
export const inspectSpecRpc = defineRpc({
|
|
160
|
+
name: "dsh-plugins.inspect",
|
|
161
|
+
input: inspectSpecInputSchema,
|
|
162
|
+
output: inspectSpecOutputSchema,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export const startJobRpc = defineRpc({
|
|
166
|
+
name: "dsh-plugins.start-job",
|
|
167
|
+
input: startJobInputSchema,
|
|
168
|
+
output: startJobOutputSchema,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
export const jobStatusRpc = defineRpc({
|
|
172
|
+
name: "dsh-plugins.job",
|
|
173
|
+
input: jobIdInputSchema,
|
|
174
|
+
output: jobStatusSchema,
|
|
175
|
+
});
|
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[];
|