paseo-dsh 0.2.20 → 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 +2 -2
- package/OVERVIEW.zh-CN.md +15 -0
- package/README.md +2 -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 +8 -6
- package/paseo-plugin.json +8 -2
- package/server/session.ts +11 -3
- package/server/timeline.ts +8 -3
- package/shared/image-preview.ts +8 -1
- package/shared/settings.ts +14 -43
package/client/timeline.tsx
CHANGED
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
PluginClientContext,
|
|
15
15
|
PluginTimelineItemProps,
|
|
16
16
|
} from "@getpaseo/plugin/client";
|
|
17
|
-
import { useAgent, useRpc, useSettings } from "@getpaseo/plugin/client";
|
|
17
|
+
import { useAgent, useRpc, useSettings, useTranslation } from "@getpaseo/plugin/client";
|
|
18
18
|
import { Icon, copyText, useToast } from "@getpaseo/plugin/client/react-native";
|
|
19
19
|
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
|
20
20
|
import * as ReactNative from "react-native";
|
|
@@ -44,8 +44,9 @@ const ImageView = (ReactNative as unknown as {
|
|
|
44
44
|
}).Image;
|
|
45
45
|
|
|
46
46
|
import { z } from "zod";
|
|
47
|
-
import { imagePreviewRpc } from "../shared/image-preview";
|
|
47
|
+
import { imagePreviewRpc, type ImageErrorCode } from "../shared/image-preview";
|
|
48
48
|
import { TIMELINE_STYLE_DEFAULTS, timelineStyleSettings, type TimelineStyleValues } from "../shared/settings";
|
|
49
|
+
import { messages, type BrowserVerbKey, type ToolVerb, type ToolVerbKey } from "./messages";
|
|
49
50
|
|
|
50
51
|
type Phase = "streaming" | "complete";
|
|
51
52
|
type Theme = PluginTimelineItemProps<unknown>["theme"];
|
|
@@ -63,6 +64,16 @@ const reasoningSchema = z.object({
|
|
|
63
64
|
|
|
64
65
|
const toolDetailSchema = z.record(z.string(), z.unknown());
|
|
65
66
|
|
|
67
|
+
const todoSchema = z.object({
|
|
68
|
+
items: z.array(
|
|
69
|
+
z.object({
|
|
70
|
+
text: z.string(),
|
|
71
|
+
status: z.string(),
|
|
72
|
+
activeForm: z.string().optional(),
|
|
73
|
+
}),
|
|
74
|
+
),
|
|
75
|
+
});
|
|
76
|
+
|
|
66
77
|
const toolSchema = z.object({
|
|
67
78
|
name: z.string(),
|
|
68
79
|
status: z.string(),
|
|
@@ -73,6 +84,7 @@ const toolSchema = z.object({
|
|
|
73
84
|
});
|
|
74
85
|
|
|
75
86
|
type ReasoningData = z.infer<typeof reasoningSchema>;
|
|
87
|
+
type TodoData = z.infer<typeof todoSchema>;
|
|
76
88
|
type ToolData = z.infer<typeof toolSchema>;
|
|
77
89
|
|
|
78
90
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
@@ -233,6 +245,7 @@ const runningDotPulse = Platform.OS === "web"
|
|
|
233
245
|
|
|
234
246
|
/** The breathing accent dot that stands in for a running tool's glyph. */
|
|
235
247
|
function RunningDot({ color }: { color: string }) {
|
|
248
|
+
const { t } = useTranslation(messages);
|
|
236
249
|
const pulseRef = useRef<{ interpolate(config: { inputRange: number[]; outputRange: number[] }): unknown } | null>(null);
|
|
237
250
|
if (pulseRef.current === null) pulseRef.current = new RNAnimated.Animated.Value(0);
|
|
238
251
|
const pulse = pulseRef.current;
|
|
@@ -258,11 +271,11 @@ function RunningDot({ color }: { color: string }) {
|
|
|
258
271
|
};
|
|
259
272
|
if (Platform.OS === "web") {
|
|
260
273
|
return (
|
|
261
|
-
<View accessibilityRole="progressbar" accessibilityLabel="
|
|
274
|
+
<View accessibilityRole="progressbar" accessibilityLabel={t("timeline.row.running")} style={[shape, runningDotPulse as never]} />
|
|
262
275
|
);
|
|
263
276
|
}
|
|
264
277
|
return (
|
|
265
|
-
<AnimatedView accessibilityRole="progressbar" accessibilityLabel="
|
|
278
|
+
<AnimatedView accessibilityRole="progressbar" accessibilityLabel={t("timeline.row.running")} style={[shape, { opacity }]} />
|
|
266
279
|
);
|
|
267
280
|
}
|
|
268
281
|
|
|
@@ -294,14 +307,15 @@ function CommandBlock({ text, theme, maxHeight }: { text: string; theme: Theme;
|
|
|
294
307
|
|
|
295
308
|
/** Image preview for a read_image tool call; bytes come from the daemon RPC. */
|
|
296
309
|
function ImagePreview({ agentId, path, theme }: { agentId: string; path: string; theme: Theme }) {
|
|
310
|
+
const { t } = useTranslation(messages);
|
|
297
311
|
const cwd = useAgent(agentId, (agent) => agent.cwd) ?? "";
|
|
298
312
|
const readImage = useRpc(imagePreviewRpc);
|
|
299
313
|
const window = useWindowDimensions();
|
|
300
314
|
const [state, setState] = useState<
|
|
301
315
|
| { status: "loading" }
|
|
302
316
|
| { status: "ready"; uri: string }
|
|
303
|
-
| { status: "tooLarge";
|
|
304
|
-
| { status: "error";
|
|
317
|
+
| { status: "tooLarge"; bytes: number; limit: number }
|
|
318
|
+
| { status: "error"; code: ImageErrorCode; detail: string | null }
|
|
305
319
|
>({ status: "loading" });
|
|
306
320
|
|
|
307
321
|
const load = useCallback(
|
|
@@ -312,13 +326,17 @@ function ImagePreview({ agentId, path, theme }: { agentId: string; path: string;
|
|
|
312
326
|
if (result.dataUri !== null) {
|
|
313
327
|
setState({ status: "ready", uri: result.dataUri });
|
|
314
328
|
} else if (result.tooLarge) {
|
|
315
|
-
setState({ status: "tooLarge",
|
|
329
|
+
setState({ status: "tooLarge", bytes: result.bytes ?? 0, limit: result.limit ?? 0 });
|
|
316
330
|
} else {
|
|
317
|
-
setState({ status: "error",
|
|
331
|
+
setState({ status: "error", code: result.errorCode ?? "unreadable", detail: result.errorDetail });
|
|
318
332
|
}
|
|
319
333
|
})
|
|
320
334
|
.catch((error: unknown) => {
|
|
321
|
-
setState({
|
|
335
|
+
setState({
|
|
336
|
+
status: "error",
|
|
337
|
+
code: "unreadable",
|
|
338
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
339
|
+
});
|
|
322
340
|
});
|
|
323
341
|
},
|
|
324
342
|
[cwd, path, readImage],
|
|
@@ -329,20 +347,38 @@ function ImagePreview({ agentId, path, theme }: { agentId: string; path: string;
|
|
|
329
347
|
}, [load]);
|
|
330
348
|
|
|
331
349
|
if (state.status === "loading") {
|
|
332
|
-
return <Text style={[styles.imageHint, { color: theme.colors.foregroundMuted }]}
|
|
350
|
+
return <Text style={[styles.imageHint, { color: theme.colors.foregroundMuted }]}>{t("timeline.row.loadingImage")}</Text>;
|
|
333
351
|
}
|
|
334
352
|
if (state.status === "tooLarge") {
|
|
335
353
|
return (
|
|
336
354
|
<View style={styles.imageTooLarge}>
|
|
337
|
-
<Text style={[styles.imageHint, { color: theme.colors.foregroundMuted }]}>
|
|
338
|
-
|
|
339
|
-
|
|
355
|
+
<Text style={[styles.imageHint, { color: theme.colors.foregroundMuted }]}>
|
|
356
|
+
{t("timeline.image.tooLarge", {
|
|
357
|
+
size: (state.bytes / 1024 / 1024).toFixed(1),
|
|
358
|
+
limit: Math.round(state.limit / 1024 / 1024),
|
|
359
|
+
})}
|
|
360
|
+
</Text>
|
|
361
|
+
<Pressable onPress={() => load(true)} accessibilityLabel={t("timeline.row.loadAnyway")} hitSlop={6}>
|
|
362
|
+
<Text style={[styles.imageLoadAnyway, { color: theme.colors.accent }]}>{t("timeline.row.loadAnyway")}</Text>
|
|
340
363
|
</Pressable>
|
|
341
364
|
</View>
|
|
342
365
|
);
|
|
343
366
|
}
|
|
344
367
|
if (state.status === "error") {
|
|
345
|
-
|
|
368
|
+
const base = state.code === "unsupported-format"
|
|
369
|
+
? t("timeline.image.unsupportedFormat")
|
|
370
|
+
: state.code === "not-file"
|
|
371
|
+
? t("timeline.image.notFile")
|
|
372
|
+
: state.code === "too-large-hard"
|
|
373
|
+
? t("timeline.image.tooLargeHard")
|
|
374
|
+
: t("timeline.image.unreadable");
|
|
375
|
+
return (
|
|
376
|
+
<Text style={[styles.imageHint, { color: theme.colors.statusDanger }]}>
|
|
377
|
+
{state.detail === null || state.detail === ""
|
|
378
|
+
? base
|
|
379
|
+
: `${base} · ${t("timeline.image.detail", { message: state.detail })}`}
|
|
380
|
+
</Text>
|
|
381
|
+
);
|
|
346
382
|
}
|
|
347
383
|
return (
|
|
348
384
|
<View
|
|
@@ -354,7 +390,7 @@ function ImagePreview({ agentId, path, theme }: { agentId: string; path: string;
|
|
|
354
390
|
<ImageView
|
|
355
391
|
source={{ uri: state.uri }}
|
|
356
392
|
resizeMode="contain"
|
|
357
|
-
accessibilityLabel="
|
|
393
|
+
accessibilityLabel={t("timeline.row.imagePreview")}
|
|
358
394
|
style={styles.image}
|
|
359
395
|
/>
|
|
360
396
|
</View>
|
|
@@ -387,12 +423,13 @@ function SheetPanel({
|
|
|
387
423
|
children: ReactNode;
|
|
388
424
|
}) {
|
|
389
425
|
const toast = useToast();
|
|
426
|
+
const { t } = useTranslation(messages);
|
|
390
427
|
const copy = useCallback(() => {
|
|
391
428
|
if (copyValue === undefined) return;
|
|
392
429
|
void copyText(copyValue)
|
|
393
|
-
.then(() => toast.show("
|
|
394
|
-
.catch(() => toast.error("
|
|
395
|
-
}, [copyValue, toast]);
|
|
430
|
+
.then(() => toast.show(t("timeline.row.copied")))
|
|
431
|
+
.catch(() => toast.error(t("timeline.row.copyFailed")));
|
|
432
|
+
}, [copyValue, toast, t]);
|
|
396
433
|
const window = useWindowDimensions();
|
|
397
434
|
const style = useTimelineStyle();
|
|
398
435
|
return (
|
|
@@ -402,14 +439,14 @@ function SheetPanel({
|
|
|
402
439
|
<Icon name={icon} size={16} color={theme.colors.foregroundMuted} />
|
|
403
440
|
<Text numberOfLines={1} style={[styles.sheetTitle, { color: theme.colors.foreground }]}>{title}</Text>
|
|
404
441
|
{copyValue === undefined ? null : (
|
|
405
|
-
<Pressable onPress={copy} accessibilityLabel="
|
|
442
|
+
<Pressable onPress={copy} accessibilityLabel={t("timeline.row.copy")} hitSlop={8}>
|
|
406
443
|
<Icon name="Copy" size={16} color={theme.colors.foregroundMuted} />
|
|
407
444
|
</Pressable>
|
|
408
445
|
)}
|
|
409
446
|
{onToggleFullscreen === undefined ? null : (
|
|
410
447
|
<Pressable
|
|
411
448
|
onPress={onToggleFullscreen}
|
|
412
|
-
accessibilityLabel={fullscreen ? "
|
|
449
|
+
accessibilityLabel={fullscreen ? t("timeline.row.exitFullscreen") : t("timeline.row.fullscreen")}
|
|
413
450
|
hitSlop={8}
|
|
414
451
|
>
|
|
415
452
|
<Icon
|
|
@@ -419,7 +456,7 @@ function SheetPanel({
|
|
|
419
456
|
/>
|
|
420
457
|
</Pressable>
|
|
421
458
|
)}
|
|
422
|
-
<Pressable onPress={onClose} accessibilityLabel="
|
|
459
|
+
<Pressable onPress={onClose} accessibilityLabel={t("timeline.row.close")} hitSlop={8}>
|
|
423
460
|
<Icon name="X" size={18} color={theme.colors.foregroundMuted} />
|
|
424
461
|
</Pressable>
|
|
425
462
|
</View>
|
|
@@ -469,6 +506,8 @@ function DetailSheet({
|
|
|
469
506
|
children: ReactNode;
|
|
470
507
|
}) {
|
|
471
508
|
const [full, setFull] = useState(false);
|
|
509
|
+
const { t } = useTranslation(messages);
|
|
510
|
+
const backdropLabel = t("timeline.row.close");
|
|
472
511
|
useEffect(() => {
|
|
473
512
|
if (!open) setFull(false);
|
|
474
513
|
}, [open]);
|
|
@@ -476,7 +515,7 @@ function DetailSheet({
|
|
|
476
515
|
return (
|
|
477
516
|
<Modal visible={open} transparent animationType={Platform.OS === "web" ? "none" : "slide"} onRequestClose={onClose} statusBarTranslucent>
|
|
478
517
|
<View style={styles.modalRoot}>
|
|
479
|
-
<Pressable style={styles.backdrop} onPress={onClose} accessibilityLabel=
|
|
518
|
+
<Pressable style={styles.backdrop} onPress={onClose} accessibilityLabel={backdropLabel} />
|
|
480
519
|
<View
|
|
481
520
|
style={[
|
|
482
521
|
styles.nativeSheet,
|
|
@@ -507,12 +546,15 @@ function DetailSheet({
|
|
|
507
546
|
}
|
|
508
547
|
|
|
509
548
|
function ReasoningRow({ item, theme, layout }: PluginTimelineItemProps<ReasoningData>) {
|
|
549
|
+
const { t } = useTranslation(messages);
|
|
510
550
|
const streaming = item.data.phase === "streaming";
|
|
511
551
|
const inline = layout.platform === "web";
|
|
512
552
|
const [open, setOpen] = useState(false);
|
|
513
553
|
const window = useWindowDimensions();
|
|
514
554
|
const text = item.data.text;
|
|
515
|
-
const preview = streaming
|
|
555
|
+
const preview = streaming
|
|
556
|
+
? lastSentence(text) || t("timeline.thinking.live")
|
|
557
|
+
: firstSentence(text) || t("timeline.thinking.done");
|
|
516
558
|
const revealed = usePacedText(text, streaming && open);
|
|
517
559
|
const spacing = useTimelineStyle();
|
|
518
560
|
// The live tail is laid out by the host with its own gap; a negative pull
|
|
@@ -530,7 +572,7 @@ function ReasoningRow({ item, theme, layout }: PluginTimelineItemProps<Reasoning
|
|
|
530
572
|
<View>
|
|
531
573
|
<Pressable
|
|
532
574
|
accessibilityRole="button"
|
|
533
|
-
accessibilityLabel={streaming ? "
|
|
575
|
+
accessibilityLabel={streaming ? t("timeline.thinking.live") : t("timeline.thinking.done")}
|
|
534
576
|
onPress={() => (inline ? setOpen((value) => !value) : setOpen(true))}
|
|
535
577
|
hitSlop={6}
|
|
536
578
|
style={({ pressed }: { pressed: boolean }) => [
|
|
@@ -541,7 +583,7 @@ function ReasoningRow({ item, theme, layout }: PluginTimelineItemProps<Reasoning
|
|
|
541
583
|
<View style={styles.lead}>
|
|
542
584
|
<Icon name="Brain" size={14} color={streaming ? theme.colors.accent : theme.colors.foregroundMuted} />
|
|
543
585
|
</View>
|
|
544
|
-
<Text style={[styles.verb, { color: theme.colors.foregroundMuted }]}
|
|
586
|
+
<Text style={[styles.verb, { color: theme.colors.foregroundMuted }]}>{t("timeline.thinking.verb")}</Text>
|
|
545
587
|
<Text numberOfLines={1} style={[styles.target, { color: theme.colors.foregroundMuted }]}>
|
|
546
588
|
{preview}
|
|
547
589
|
</Text>
|
|
@@ -572,7 +614,7 @@ function ReasoningRow({ item, theme, layout }: PluginTimelineItemProps<Reasoning
|
|
|
572
614
|
<DetailSheet
|
|
573
615
|
open={open}
|
|
574
616
|
onClose={() => setOpen(false)}
|
|
575
|
-
title="
|
|
617
|
+
title={t("timeline.thinking.verb")}
|
|
576
618
|
icon="Brain"
|
|
577
619
|
theme={theme}
|
|
578
620
|
copyValue={revealed}
|
|
@@ -584,11 +626,24 @@ function ReasoningRow({ item, theme, layout }: PluginTimelineItemProps<Reasoning
|
|
|
584
626
|
);
|
|
585
627
|
}
|
|
586
628
|
|
|
587
|
-
type ToolKind =
|
|
629
|
+
type ToolKind =
|
|
630
|
+
| "shell"
|
|
631
|
+
| "read"
|
|
632
|
+
| "write"
|
|
633
|
+
| "edit"
|
|
634
|
+
| "search"
|
|
635
|
+
| "fetch"
|
|
636
|
+
| "mcp"
|
|
637
|
+
| "browser"
|
|
638
|
+
| "code"
|
|
639
|
+
| "todo"
|
|
640
|
+
| "question"
|
|
641
|
+
| "other";
|
|
588
642
|
|
|
589
643
|
interface ToolLook {
|
|
590
644
|
icon: string;
|
|
591
|
-
|
|
645
|
+
/** Resolved when the row renders, so a language switch re-words it. */
|
|
646
|
+
verb: ToolVerb;
|
|
592
647
|
target: string;
|
|
593
648
|
mark?: string;
|
|
594
649
|
}
|
|
@@ -666,6 +721,9 @@ function toolKindOf(name: string, detail: Record<string, unknown> | undefined):
|
|
|
666
721
|
if (type === "edit") return "edit";
|
|
667
722
|
if (type === "search") return "search";
|
|
668
723
|
if (type === "fetch") return "fetch";
|
|
724
|
+
// These two carry no native detail shape, so their rows are chosen by name.
|
|
725
|
+
if (name === "todo_write") return "todo";
|
|
726
|
+
if (name === "ask_user_question") return "question";
|
|
669
727
|
if (name.startsWith("mcp__")) return "mcp";
|
|
670
728
|
if (name === "run_code") return "code";
|
|
671
729
|
if (/(?:^|_)browser_/.test(name)) return "browser";
|
|
@@ -677,17 +735,17 @@ function toolKindOf(name: string, detail: Record<string, unknown> | undefined):
|
|
|
677
735
|
return "other";
|
|
678
736
|
}
|
|
679
737
|
|
|
680
|
-
const BROWSER_VERBS: Readonly<Array<[RegExp,
|
|
681
|
-
[/^(?:navigate|open|goto|go|new_tab|open_url)$/, "
|
|
682
|
-
[/^(?:click|press|tap)$/, "
|
|
683
|
-
[/^(?:type|fill|input|press_key|key)$/, "
|
|
684
|
-
[/^(?:snapshot|screenshot|capture)$/, "
|
|
685
|
-
[/^(?:scroll)$/, "
|
|
686
|
-
[/^(?:back|forward|reload)$/, "
|
|
687
|
-
[/^(?:wait)$/, "
|
|
688
|
-
[/^(?:close|close_tab)$/, "
|
|
689
|
-
[/^(?:evaluate|run|run_code)$/, "
|
|
690
|
-
[/^(?:find|search)$/, "
|
|
738
|
+
const BROWSER_VERBS: Readonly<Array<[RegExp, BrowserVerbKey]>> = [
|
|
739
|
+
[/^(?:navigate|open|goto|go|new_tab|open_url)$/, "timeline.browser.open"],
|
|
740
|
+
[/^(?:click|press|tap)$/, "timeline.browser.click"],
|
|
741
|
+
[/^(?:type|fill|input|press_key|key)$/, "timeline.browser.type"],
|
|
742
|
+
[/^(?:snapshot|screenshot|capture)$/, "timeline.browser.snapshot"],
|
|
743
|
+
[/^(?:scroll)$/, "timeline.browser.scroll"],
|
|
744
|
+
[/^(?:back|forward|reload)$/, "timeline.browser.navigate"],
|
|
745
|
+
[/^(?:wait)$/, "timeline.browser.wait"],
|
|
746
|
+
[/^(?:close|close_tab)$/, "timeline.browser.close"],
|
|
747
|
+
[/^(?:evaluate|run|run_code)$/, "timeline.browser.run"],
|
|
748
|
+
[/^(?:find|search)$/, "timeline.browser.find"],
|
|
691
749
|
];
|
|
692
750
|
|
|
693
751
|
/** Strip the server prefix and the `browser_` stem so verbs can match on the action. */
|
|
@@ -697,11 +755,11 @@ function browserAction(name: string): string {
|
|
|
697
755
|
return bare;
|
|
698
756
|
}
|
|
699
757
|
|
|
700
|
-
function browserVerb(action: string):
|
|
758
|
+
function browserVerb(action: string): ToolVerbKey | BrowserVerbKey {
|
|
701
759
|
for (const [pattern, verb] of BROWSER_VERBS) {
|
|
702
760
|
if (pattern.test(action)) return verb;
|
|
703
761
|
}
|
|
704
|
-
return "
|
|
762
|
+
return "timeline.tool.browser";
|
|
705
763
|
}
|
|
706
764
|
|
|
707
765
|
function firstLine(text: string | undefined): string | undefined {
|
|
@@ -725,7 +783,7 @@ function toolLook(data: ToolData): ToolLook {
|
|
|
725
783
|
const mark = program === undefined ? undefined : PROGRAM_MARKS[program];
|
|
726
784
|
return {
|
|
727
785
|
icon: "SquareTerminal",
|
|
728
|
-
verb: "
|
|
786
|
+
verb: "timeline.tool.command",
|
|
729
787
|
target: firstLine(command) ?? data.name,
|
|
730
788
|
...(mark === undefined ? {} : { mark }),
|
|
731
789
|
};
|
|
@@ -734,7 +792,7 @@ function toolLook(data: ToolData): ToolLook {
|
|
|
734
792
|
const image = data.name === "read_image";
|
|
735
793
|
return {
|
|
736
794
|
icon: image ? "Image" : "FileText",
|
|
737
|
-
verb: image ? "
|
|
795
|
+
verb: image ? "timeline.tool.image" : "timeline.tool.read",
|
|
738
796
|
target: stringField(detail, "filePath")
|
|
739
797
|
?? stringField(input, "file_path")
|
|
740
798
|
?? stringField(input, "path")
|
|
@@ -742,9 +800,9 @@ function toolLook(data: ToolData): ToolLook {
|
|
|
742
800
|
};
|
|
743
801
|
}
|
|
744
802
|
case "write":
|
|
745
|
-
return { icon: "Pencil", verb: "
|
|
803
|
+
return { icon: "Pencil", verb: "timeline.tool.write", target: stringField(detail, "filePath") ?? data.name };
|
|
746
804
|
case "edit":
|
|
747
|
-
return { icon: "Pencil", verb: "
|
|
805
|
+
return { icon: "Pencil", verb: "timeline.tool.edit", target: stringField(detail, "filePath") ?? data.name };
|
|
748
806
|
case "search": {
|
|
749
807
|
const query = stringField(detail, "query")
|
|
750
808
|
?? stringField(input, "query")
|
|
@@ -752,14 +810,14 @@ function toolLook(data: ToolData): ToolLook {
|
|
|
752
810
|
?? data.name;
|
|
753
811
|
return {
|
|
754
812
|
icon: "Search",
|
|
755
|
-
verb: stringField(detail, "toolName") === "web_search" ? "
|
|
813
|
+
verb: stringField(detail, "toolName") === "web_search" ? "timeline.tool.webSearch" : "timeline.tool.search",
|
|
756
814
|
target: query,
|
|
757
815
|
};
|
|
758
816
|
}
|
|
759
817
|
case "fetch":
|
|
760
818
|
return {
|
|
761
819
|
icon: "Globe",
|
|
762
|
-
verb: "
|
|
820
|
+
verb: "timeline.tool.fetch",
|
|
763
821
|
target: hostOf(stringField(detail, "url") ?? stringField(input, "url") ?? data.name),
|
|
764
822
|
};
|
|
765
823
|
case "mcp": {
|
|
@@ -767,7 +825,7 @@ function toolLook(data: ToolData): ToolLook {
|
|
|
767
825
|
const browser = parsed !== undefined && parsed.tool.includes("browser_");
|
|
768
826
|
return {
|
|
769
827
|
icon: browser ? "Globe" : "Plug",
|
|
770
|
-
verb: browser ? "
|
|
828
|
+
verb: browser ? "timeline.tool.browser" : { text: "MCP" },
|
|
771
829
|
target: parsed === undefined ? data.name : `${parsed.server} / ${parsed.tool}`,
|
|
772
830
|
};
|
|
773
831
|
}
|
|
@@ -786,13 +844,26 @@ function toolLook(data: ToolData): ToolLook {
|
|
|
786
844
|
case "code":
|
|
787
845
|
return {
|
|
788
846
|
icon: "Code",
|
|
789
|
-
verb: "
|
|
847
|
+
verb: "timeline.tool.code",
|
|
790
848
|
target: stringField(input, "description") ?? firstLine(stringField(input, "code")) ?? "run_code",
|
|
791
849
|
};
|
|
850
|
+
case "todo": {
|
|
851
|
+
const items = todoEntries(input);
|
|
852
|
+
const done = items.filter((entry) => entry.status === "completed").length;
|
|
853
|
+
// A plain `done/total` keeps the target language-neutral: the verb is the
|
|
854
|
+
// only word this row needs.
|
|
855
|
+
return { icon: "ListChecks", verb: "timeline.tool.tasks", target: `${done}/${items.length}` };
|
|
856
|
+
}
|
|
857
|
+
case "question":
|
|
858
|
+
return {
|
|
859
|
+
icon: "HelpCircle",
|
|
860
|
+
verb: "timeline.tool.question",
|
|
861
|
+
target: firstLine(questionLines(input)) ?? data.name,
|
|
862
|
+
};
|
|
792
863
|
default:
|
|
793
864
|
return {
|
|
794
865
|
icon: "Wrench",
|
|
795
|
-
verb: data.name,
|
|
866
|
+
verb: { text: data.name },
|
|
796
867
|
target: stringField(input, "url")
|
|
797
868
|
?? stringField(input, "file_path")
|
|
798
869
|
?? stringField(input, "path")
|
|
@@ -804,11 +875,11 @@ function toolLook(data: ToolData): ToolLook {
|
|
|
804
875
|
}
|
|
805
876
|
}
|
|
806
877
|
|
|
807
|
-
function
|
|
808
|
-
if (status === "running") return "
|
|
809
|
-
if (status === "failed") return "
|
|
810
|
-
if (status === "canceled") return "
|
|
811
|
-
return "
|
|
878
|
+
function statusKey(status: string) {
|
|
879
|
+
if (status === "running") return "timeline.status.running" as const;
|
|
880
|
+
if (status === "failed") return "timeline.status.failed" as const;
|
|
881
|
+
if (status === "canceled") return "timeline.status.canceled" as const;
|
|
882
|
+
return "timeline.status.done" as const;
|
|
812
883
|
}
|
|
813
884
|
|
|
814
885
|
function statusColor(status: string, theme: Theme): string {
|
|
@@ -817,6 +888,73 @@ function statusColor(status: string, theme: Theme): string {
|
|
|
817
888
|
return theme.colors.foregroundMuted;
|
|
818
889
|
}
|
|
819
890
|
|
|
891
|
+
interface TodoEntry {
|
|
892
|
+
text: string;
|
|
893
|
+
status: string;
|
|
894
|
+
activeForm?: string;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
const TODO_MARKS: Readonly<Record<string, string>> = {
|
|
898
|
+
completed: "✓",
|
|
899
|
+
in_progress: "◐",
|
|
900
|
+
pending: "○",
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
/** The `input` object of a tool detail, whichever detail shape it is. */
|
|
904
|
+
function detailInput(detail: unknown): Record<string, unknown> | undefined {
|
|
905
|
+
const record = isRecord(detail) ? detail : undefined;
|
|
906
|
+
return isRecord(record?.input) ? record.input : undefined;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/** The checklist a `todo_write` call carries, normalized for drawing. */
|
|
910
|
+
function todoEntries(input: Record<string, unknown> | undefined): TodoEntry[] {
|
|
911
|
+
const raw = input?.todos;
|
|
912
|
+
if (!Array.isArray(raw)) return [];
|
|
913
|
+
return raw.flatMap((entry) => {
|
|
914
|
+
if (!isRecord(entry)) return [];
|
|
915
|
+
const text = stringField(entry, "content") ?? stringField(entry, "text");
|
|
916
|
+
if (text === undefined) return [];
|
|
917
|
+
const activeForm = stringField(entry, "activeForm");
|
|
918
|
+
const status = stringField(entry, "status")
|
|
919
|
+
?? (entry.completed === true ? "completed" : "pending");
|
|
920
|
+
return [{
|
|
921
|
+
text,
|
|
922
|
+
status: status === "in_progress" || status === "completed" ? status : "pending",
|
|
923
|
+
...(activeForm === undefined ? {} : { activeForm }),
|
|
924
|
+
}];
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
function checklist(items: TodoEntry[]): string {
|
|
929
|
+
return items
|
|
930
|
+
.map((entry) => {
|
|
931
|
+
// The in-progress wording is what the model is doing right now; the rest
|
|
932
|
+
// stay in their plain form so the list reads as the model wrote it.
|
|
933
|
+
const label = entry.status === "in_progress" ? entry.activeForm ?? entry.text : entry.text;
|
|
934
|
+
return `${TODO_MARKS[entry.status] ?? "○"} ${label}`;
|
|
935
|
+
})
|
|
936
|
+
.join("\n");
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/** The questions and option labels of an `ask_user_question` call. */
|
|
940
|
+
function questionLines(input: Record<string, unknown> | undefined): string {
|
|
941
|
+
const raw = input?.questions;
|
|
942
|
+
if (!Array.isArray(raw)) return stringField(input, "question") ?? "";
|
|
943
|
+
const lines: string[] = [];
|
|
944
|
+
for (const entry of raw) {
|
|
945
|
+
if (!isRecord(entry)) continue;
|
|
946
|
+
const question = stringField(entry, "question") ?? stringField(entry, "header");
|
|
947
|
+
if (question === undefined) continue;
|
|
948
|
+
lines.push(question);
|
|
949
|
+
const options = Array.isArray(entry.options) ? entry.options : [];
|
|
950
|
+
for (const option of options) {
|
|
951
|
+
const label = isRecord(option) ? stringField(option, "label") : typeof option === "string" ? option : undefined;
|
|
952
|
+
if (label !== undefined) lines.push(` - ${label}`);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
return lines.join("\n");
|
|
956
|
+
}
|
|
957
|
+
|
|
820
958
|
function readContent(content: string): string {
|
|
821
959
|
const match = /<content>\n?([\s\S]*?)\n?<\/content>/.exec(content);
|
|
822
960
|
const body = match?.[1] ?? content;
|
|
@@ -831,6 +969,17 @@ function toolContent(data: ToolData): string | undefined {
|
|
|
831
969
|
if (detail === undefined) return undefined;
|
|
832
970
|
const type = stringField(detail, "type");
|
|
833
971
|
const input = isRecord(detail.input) ? detail.input : undefined;
|
|
972
|
+
const kind = toolKindOf(data.name, detail);
|
|
973
|
+
// These two have no detail type of their own, so their drawer body is built
|
|
974
|
+
// from the call's own input rather than from the generic JSON dump.
|
|
975
|
+
if (kind === "todo") {
|
|
976
|
+
const items = todoEntries(input);
|
|
977
|
+
return items.length === 0 ? undefined : checklist(items);
|
|
978
|
+
}
|
|
979
|
+
if (kind === "question") {
|
|
980
|
+
const lines = questionLines(input);
|
|
981
|
+
return lines === "" ? undefined : lines;
|
|
982
|
+
}
|
|
834
983
|
const parts: string[] = [];
|
|
835
984
|
switch (type) {
|
|
836
985
|
case "shell": {
|
|
@@ -1126,12 +1275,13 @@ function CodeSurface({
|
|
|
1126
1275
|
}) {
|
|
1127
1276
|
const [wrap, setWrap] = useState(false);
|
|
1128
1277
|
const toast = useToast();
|
|
1278
|
+
const { t } = useTranslation(messages);
|
|
1129
1279
|
const background = sheetBackground(theme);
|
|
1130
1280
|
const copy = useCallback(() => {
|
|
1131
1281
|
void copyText(text)
|
|
1132
|
-
.then(() => toast.show("
|
|
1133
|
-
.catch(() => toast.error("
|
|
1134
|
-
}, [text, toast]);
|
|
1282
|
+
.then(() => toast.show(t("timeline.row.copied")))
|
|
1283
|
+
.catch(() => toast.error(t("timeline.row.copyFailed")));
|
|
1284
|
+
}, [text, toast, t]);
|
|
1135
1285
|
return (
|
|
1136
1286
|
<View
|
|
1137
1287
|
style={[
|
|
@@ -1144,12 +1294,16 @@ function CodeSurface({
|
|
|
1144
1294
|
]}
|
|
1145
1295
|
>
|
|
1146
1296
|
<View style={[styles.codeToolbar, { borderBottomColor: theme.colors.border }]}>
|
|
1147
|
-
<Pressable
|
|
1297
|
+
<Pressable
|
|
1298
|
+
onPress={() => setWrap((value) => !value)}
|
|
1299
|
+
accessibilityLabel={wrap ? t("timeline.row.noWrap") : t("timeline.row.wrap")}
|
|
1300
|
+
hitSlop={6}
|
|
1301
|
+
>
|
|
1148
1302
|
<Text style={[styles.codeToolbarText, { color: theme.colors.foregroundMuted }]}>
|
|
1149
|
-
{wrap ? "
|
|
1303
|
+
{wrap ? t("timeline.row.noWrap") : t("timeline.row.wrap")}
|
|
1150
1304
|
</Text>
|
|
1151
1305
|
</Pressable>
|
|
1152
|
-
<Pressable onPress={copy} accessibilityLabel="
|
|
1306
|
+
<Pressable onPress={copy} accessibilityLabel={t("timeline.row.copy")} hitSlop={6}>
|
|
1153
1307
|
<Icon name="Copy" size={13} color={theme.colors.foregroundMuted} />
|
|
1154
1308
|
</Pressable>
|
|
1155
1309
|
</View>
|
|
@@ -1175,7 +1329,9 @@ function ToolRow({ item, theme, layout, agentId }: PluginTimelineItemProps<ToolD
|
|
|
1175
1329
|
const inline = layout.platform === "web";
|
|
1176
1330
|
const window = useWindowDimensions();
|
|
1177
1331
|
const data = item.data;
|
|
1332
|
+
const { t } = useTranslation(messages);
|
|
1178
1333
|
const look = useMemo(() => toolLook(data), [data]);
|
|
1334
|
+
const verb = typeof look.verb === "string" ? t(look.verb) : look.verb.text;
|
|
1179
1335
|
const content = useMemo(() => toolContent(data), [data]);
|
|
1180
1336
|
const language = useMemo(() => toolLanguage(data), [data]);
|
|
1181
1337
|
const subject = useMemo(() => toolSubject(data, look), [data, look]);
|
|
@@ -1203,7 +1359,7 @@ function ToolRow({ item, theme, layout, agentId }: PluginTimelineItemProps<ToolD
|
|
|
1203
1359
|
<View>
|
|
1204
1360
|
<Pressable
|
|
1205
1361
|
accessibilityRole="button"
|
|
1206
|
-
accessibilityLabel={`${
|
|
1362
|
+
accessibilityLabel={`${verb}${look.target === "" ? "" : ` ${look.target}`}`}
|
|
1207
1363
|
onPress={openSheet}
|
|
1208
1364
|
hitSlop={6}
|
|
1209
1365
|
style={({ pressed }: { pressed: boolean }) => [
|
|
@@ -1223,14 +1379,14 @@ function ToolRow({ item, theme, layout, agentId }: PluginTimelineItemProps<ToolD
|
|
|
1223
1379
|
)}
|
|
1224
1380
|
</View>
|
|
1225
1381
|
<Text style={[styles.verb, { color: failed ? theme.colors.statusDanger : theme.colors.foregroundMuted }]}>
|
|
1226
|
-
{
|
|
1382
|
+
{verb}
|
|
1227
1383
|
</Text>
|
|
1228
1384
|
<Text numberOfLines={1} style={[styles.target, { color: theme.colors.foregroundMuted }]}>
|
|
1229
1385
|
{look.target}
|
|
1230
1386
|
</Text>
|
|
1231
1387
|
{data.status === "running" || data.status === "completed" ? null : (
|
|
1232
1388
|
<Text style={[styles.meta, { color: statusColor(data.status, theme) }]}>
|
|
1233
|
-
{
|
|
1389
|
+
{t(statusKey(data.status))}
|
|
1234
1390
|
</Text>
|
|
1235
1391
|
)}
|
|
1236
1392
|
{content === undefined ? null : (
|
|
@@ -1267,7 +1423,7 @@ function ToolRow({ item, theme, layout, agentId }: PluginTimelineItemProps<ToolD
|
|
|
1267
1423
|
<DetailSheet
|
|
1268
1424
|
open={open}
|
|
1269
1425
|
onClose={() => setOpen(false)}
|
|
1270
|
-
title={
|
|
1426
|
+
title={verb}
|
|
1271
1427
|
subject={subject}
|
|
1272
1428
|
subjectWrap={wrapSubject}
|
|
1273
1429
|
icon={look.icon}
|
|
@@ -1289,6 +1445,81 @@ function ToolRow({ item, theme, layout, agentId }: PluginTimelineItemProps<ToolD
|
|
|
1289
1445
|
);
|
|
1290
1446
|
}
|
|
1291
1447
|
|
|
1448
|
+
/**
|
|
1449
|
+
* The checklist Paseo would draw itself, in the plugin's compact row shape.
|
|
1450
|
+
*
|
|
1451
|
+
* One `todo_write` call yields one of these, so the tool row that produced it is
|
|
1452
|
+
* dropped once it completes and the list never appears twice.
|
|
1453
|
+
*/
|
|
1454
|
+
function TodoRow({ item, theme, layout }: PluginTimelineItemProps<TodoData>) {
|
|
1455
|
+
const { t } = useTranslation(messages);
|
|
1456
|
+
const [open, setOpen] = useState(false);
|
|
1457
|
+
const inline = layout.platform === "web";
|
|
1458
|
+
const window = useWindowDimensions();
|
|
1459
|
+
const spacing = useTimelineStyle();
|
|
1460
|
+
const items = item.data.items;
|
|
1461
|
+
const total = items.length;
|
|
1462
|
+
const done = items.filter((entry) => entry.status === "completed").length;
|
|
1463
|
+
const content = checklist(items);
|
|
1464
|
+
const verb = t("timeline.tool.tasks");
|
|
1465
|
+
const row = {
|
|
1466
|
+
...styles.row,
|
|
1467
|
+
marginTop: spacing.toolRowMarginY,
|
|
1468
|
+
marginBottom: 0,
|
|
1469
|
+
paddingVertical: spacing.toolRowPaddingY,
|
|
1470
|
+
minHeight: spacing.toolRowMinHeight,
|
|
1471
|
+
gap: spacing.toolRowGap,
|
|
1472
|
+
};
|
|
1473
|
+
return (
|
|
1474
|
+
<View>
|
|
1475
|
+
<Pressable
|
|
1476
|
+
accessibilityRole="button"
|
|
1477
|
+
accessibilityLabel={`${verb} ${done}/${total}`}
|
|
1478
|
+
onPress={() => (inline ? setOpen((value) => !value) : setOpen(true))}
|
|
1479
|
+
hitSlop={6}
|
|
1480
|
+
style={({ pressed }: { pressed: boolean }) => [
|
|
1481
|
+
row,
|
|
1482
|
+
pressed ? { backgroundColor: theme.colors.surface1, borderRadius: 6 } : null,
|
|
1483
|
+
]}
|
|
1484
|
+
>
|
|
1485
|
+
<View style={styles.lead}>
|
|
1486
|
+
<Icon name="ListChecks" size={14} color={theme.colors.foregroundMuted} />
|
|
1487
|
+
</View>
|
|
1488
|
+
<Text style={[styles.verb, { color: theme.colors.foregroundMuted }]}>{verb}</Text>
|
|
1489
|
+
<Text numberOfLines={1} style={[styles.target, { color: theme.colors.foregroundMuted }]}>
|
|
1490
|
+
{`${done}/${total}`}
|
|
1491
|
+
</Text>
|
|
1492
|
+
<View style={{ transform: [{ rotate: inline && open ? "90deg" : "0deg" }] }}>
|
|
1493
|
+
<Icon name="ChevronRight" size={12} color={theme.colors.foregroundMuted} />
|
|
1494
|
+
</View>
|
|
1495
|
+
</Pressable>
|
|
1496
|
+
{inline && open ? (
|
|
1497
|
+
<View style={styles.inlineTool}>
|
|
1498
|
+
<ScrollView
|
|
1499
|
+
style={{ maxHeight: Math.max(160, Math.round(window.height * 0.35)) }}
|
|
1500
|
+
contentContainerStyle={styles.inlineReasoningContent}
|
|
1501
|
+
showsVerticalScrollIndicator
|
|
1502
|
+
>
|
|
1503
|
+
<Text selectable style={[styles.bodyText, { color: theme.colors.foreground }]}>{content}</Text>
|
|
1504
|
+
</ScrollView>
|
|
1505
|
+
</View>
|
|
1506
|
+
) : null}
|
|
1507
|
+
{inline ? null : (
|
|
1508
|
+
<DetailSheet
|
|
1509
|
+
open={open}
|
|
1510
|
+
onClose={() => setOpen(false)}
|
|
1511
|
+
title={verb}
|
|
1512
|
+
icon="ListChecks"
|
|
1513
|
+
theme={theme}
|
|
1514
|
+
copyValue={content}
|
|
1515
|
+
>
|
|
1516
|
+
<Text selectable style={[styles.bodyText, { color: theme.colors.foreground }]}>{content}</Text>
|
|
1517
|
+
</DetailSheet>
|
|
1518
|
+
)}
|
|
1519
|
+
</View>
|
|
1520
|
+
);
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1292
1523
|
export function contributeTimeline(client: PluginClientContext): () => void {
|
|
1293
1524
|
const cleanups = [
|
|
1294
1525
|
client.addTimelineTransformer({
|
|
@@ -1312,6 +1543,42 @@ export function contributeTimeline(client: PluginClientContext): () => void {
|
|
|
1312
1543
|
schema: reasoningSchema,
|
|
1313
1544
|
Component: ReasoningRow,
|
|
1314
1545
|
}),
|
|
1546
|
+
client.addTimelineTransformer({
|
|
1547
|
+
id: "dsh-todo-row",
|
|
1548
|
+
query: { itemType: "todo" },
|
|
1549
|
+
transform({ item }) {
|
|
1550
|
+
if (item.type !== "todo") return undefined;
|
|
1551
|
+
const items = item.items.flatMap((entry) => {
|
|
1552
|
+
const text = typeof entry.text === "string" ? entry.text : "";
|
|
1553
|
+
if (text === "") return [];
|
|
1554
|
+
const status = typeof entry.status === "string"
|
|
1555
|
+
? entry.status
|
|
1556
|
+
: entry.completed
|
|
1557
|
+
? "completed"
|
|
1558
|
+
: "pending";
|
|
1559
|
+
return [{
|
|
1560
|
+
text,
|
|
1561
|
+
status,
|
|
1562
|
+
...(typeof entry.activeForm === "string" ? { activeForm: entry.activeForm } : {}),
|
|
1563
|
+
}];
|
|
1564
|
+
});
|
|
1565
|
+
if (items.length === 0) return undefined;
|
|
1566
|
+
return {
|
|
1567
|
+
items: [{
|
|
1568
|
+
type: "plugin" as const,
|
|
1569
|
+
kind: "dsh-todo",
|
|
1570
|
+
version: 1,
|
|
1571
|
+
data: { items },
|
|
1572
|
+
}],
|
|
1573
|
+
};
|
|
1574
|
+
},
|
|
1575
|
+
}),
|
|
1576
|
+
client.addTimelineRenderer({
|
|
1577
|
+
kind: "dsh-todo",
|
|
1578
|
+
version: 1,
|
|
1579
|
+
schema: todoSchema,
|
|
1580
|
+
Component: TodoRow,
|
|
1581
|
+
}),
|
|
1315
1582
|
client.addTimelineTransformer({
|
|
1316
1583
|
id: "dsh-tool-row",
|
|
1317
1584
|
query: { itemType: "tool_call" },
|
|
@@ -1319,11 +1586,21 @@ export function contributeTimeline(client: PluginClientContext): () => void {
|
|
|
1319
1586
|
if (item.type !== "tool_call") return undefined;
|
|
1320
1587
|
const detail = isRecord(item.detail) ? item.detail : undefined;
|
|
1321
1588
|
const type = stringField(detail, "type");
|
|
1589
|
+
// A finished `todo_write` is drawn by the checklist row above; keeping
|
|
1590
|
+
// its tool row too would show one call twice.
|
|
1591
|
+
if (
|
|
1592
|
+
item.name === "todo_write"
|
|
1593
|
+
&& item.status === "completed"
|
|
1594
|
+
&& todoEntries(detailInput(detail)).length > 0
|
|
1595
|
+
) {
|
|
1596
|
+
return { items: [] };
|
|
1597
|
+
}
|
|
1322
1598
|
// Keep Paseo's richer cards for semantic helpers; every other tool gets
|
|
1323
|
-
// the shared row so a provider-specific name never shows up bare
|
|
1599
|
+
// the shared row so a provider-specific name never shows up bare, and an
|
|
1600
|
+
// unfamiliar tool falls back to the generic wrench row instead of the
|
|
1601
|
+
// host's own styling.
|
|
1324
1602
|
const nativeCard = type === "sub_agent"
|
|
1325
1603
|
|| type === "worktree_setup"
|
|
1326
|
-
|| type === "plain_text"
|
|
1327
1604
|
|| type === "plan";
|
|
1328
1605
|
if (nativeCard) return undefined;
|
|
1329
1606
|
const error = item.error === null || item.error === undefined ? undefined : String(
|