paseo-dsh 0.2.21 → 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 +3 -3
- package/OVERVIEW.zh-CN.md +3 -3
- 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 +93 -1
- package/client/locales/zh-CN.json +92 -1
- package/client/messages.ts +44 -2
- package/client/react-native.d.ts +3 -0
- package/client/settings-screen.tsx +13 -7
- package/client/stream-stats.tsx +25 -17
- package/client/timeline.tsx +155 -113
- package/index.client.tsx +42 -4
- package/index.server.ts +12 -1
- package/package.json +2 -2
- package/paseo-plugin.json +1 -1
- 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 +399 -45
- package/server/timeline.ts +61 -1
- package/shared/dsh-plugins-api.ts +175 -0
package/server/timeline.ts
CHANGED
|
@@ -184,6 +184,7 @@ export class TimelineBuilder {
|
|
|
184
184
|
#items = new Map<string, ProviderTimelineItem>();
|
|
185
185
|
#toolNames = new Map<string, string>();
|
|
186
186
|
#toolInputs = new Map<string, Record<string, unknown>>();
|
|
187
|
+
#delegations = new Set<string>();
|
|
187
188
|
|
|
188
189
|
/**
|
|
189
190
|
* Fold one DSH session event into zero or more complete Paseo item snapshots.
|
|
@@ -200,6 +201,15 @@ export class TimelineBuilder {
|
|
|
200
201
|
return this.#toolCall(data);
|
|
201
202
|
case "tool/result":
|
|
202
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
|
+
}
|
|
203
213
|
case "turn/end":
|
|
204
214
|
return this.#turnEnd(data);
|
|
205
215
|
default:
|
|
@@ -212,6 +222,35 @@ export class TimelineBuilder {
|
|
|
212
222
|
return [item];
|
|
213
223
|
}
|
|
214
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
|
+
|
|
215
254
|
#assistantMessage(data: Record<string, unknown>): ProviderTimelineItem[] {
|
|
216
255
|
const message = isRecord(data.message) ? data.message : undefined;
|
|
217
256
|
const content = message?.content;
|
|
@@ -271,6 +310,22 @@ export class TimelineBuilder {
|
|
|
271
310
|
return this.#emitToolCall(callId, name, input, status === "running" ? "running" : status);
|
|
272
311
|
}
|
|
273
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
|
+
|
|
274
329
|
#toolResult(data: Record<string, unknown>): ProviderTimelineItem[] {
|
|
275
330
|
const message = isRecord(data.message) ? data.message : undefined;
|
|
276
331
|
const callId = stringField(data, "toolCallId") ?? (message === undefined ? undefined : stringField(message, "toolCallId"));
|
|
@@ -287,13 +342,18 @@ export class TimelineBuilder {
|
|
|
287
342
|
out.push(...this.#put({ type: "todo", id: `todo:${callId}`, items }));
|
|
288
343
|
}
|
|
289
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
|
+
}
|
|
290
350
|
out.push(
|
|
291
351
|
...this.#put({
|
|
292
352
|
type: "tool_call",
|
|
293
353
|
id: `tool:${callId}`,
|
|
294
354
|
callId,
|
|
295
355
|
name,
|
|
296
|
-
detail
|
|
356
|
+
detail,
|
|
297
357
|
...(failed
|
|
298
358
|
? { status: "failed" as const, error: { message: output || "tool failed" } }
|
|
299
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
|
+
});
|