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.
@@ -14,7 +14,9 @@ import type {
14
14
  PluginClientContext,
15
15
  PluginTimelineItemProps,
16
16
  } from "@getpaseo/plugin/client";
17
- import { useAgent, useRpc, useSettings, useTranslation } from "@getpaseo/plugin/client";
17
+ import { useAgent, useRpc, useSettings } from "@getpaseo/plugin/client";
18
+ import { translateForLabel, useTranslation } from "./i18n";
19
+ import { FailedRow, guard, guardAsync, report, withPluginBoundary } from "./guard";
18
20
  import { Icon, copyText, useToast } from "@getpaseo/plugin/client/react-native";
19
21
  import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
20
22
  import * as ReactNative from "react-native";
@@ -46,7 +48,7 @@ const ImageView = (ReactNative as unknown as {
46
48
  import { z } from "zod";
47
49
  import { imagePreviewRpc, type ImageErrorCode } from "../shared/image-preview";
48
50
  import { TIMELINE_STYLE_DEFAULTS, timelineStyleSettings, type TimelineStyleValues } from "../shared/settings";
49
- import { messages, type BrowserVerbKey, type ToolVerb, type ToolVerbKey } from "./messages";
51
+ import type { BrowserVerbKey, ToolVerb, ToolVerbKey } from "./messages";
50
52
 
51
53
  type Phase = "streaming" | "complete";
52
54
  type Theme = PluginTimelineItemProps<unknown>["theme"];
@@ -245,22 +247,27 @@ const runningDotPulse = Platform.OS === "web"
245
247
 
246
248
  /** The breathing accent dot that stands in for a running tool's glyph. */
247
249
  function RunningDot({ color }: { color: string }) {
248
- const { t } = useTranslation(messages);
250
+ const { t } = useTranslation();
249
251
  const pulseRef = useRef<{ interpolate(config: { inputRange: number[]; outputRange: number[] }): unknown } | null>(null);
250
252
  if (pulseRef.current === null) pulseRef.current = new RNAnimated.Animated.Value(0);
251
253
  const pulse = pulseRef.current;
252
254
  useEffect(() => {
253
255
  if (Platform.OS === "web") return;
254
- const loop = RNAnimated.Animated.loop(
255
- RNAnimated.Animated.timing(pulse, {
256
- toValue: 1,
257
- duration: RUNNING_DOT.periodMs,
258
- easing: RNAnimated.Easing.inOut(RNAnimated.Easing.ease),
259
- useNativeDriver: true,
260
- }),
261
- );
262
- loop.start();
263
- return () => loop.stop();
256
+ try {
257
+ const loop = RNAnimated.Animated.loop(
258
+ RNAnimated.Animated.timing(pulse, {
259
+ toValue: 1,
260
+ duration: RUNNING_DOT.periodMs,
261
+ easing: RNAnimated.Easing.inOut(RNAnimated.Easing.ease),
262
+ useNativeDriver: true,
263
+ }),
264
+ );
265
+ loop.start();
266
+ return () => loop.stop();
267
+ } catch (error) {
268
+ report("running dot animation", error);
269
+ return;
270
+ }
264
271
  }, [pulse]);
265
272
  const opacity = pulse.interpolate({ inputRange: [0, 0.5, 1], outputRange: [1, RUNNING_DOT.minOpacity, 1] });
266
273
  const shape = {
@@ -307,7 +314,7 @@ function CommandBlock({ text, theme, maxHeight }: { text: string; theme: Theme;
307
314
 
308
315
  /** Image preview for a read_image tool call; bytes come from the daemon RPC. */
309
316
  function ImagePreview({ agentId, path, theme }: { agentId: string; path: string; theme: Theme }) {
310
- const { t } = useTranslation(messages);
317
+ const { t } = useTranslation();
311
318
  const cwd = useAgent(agentId, (agent) => agent.cwd) ?? "";
312
319
  const readImage = useRpc(imagePreviewRpc);
313
320
  const window = useWindowDimensions();
@@ -321,23 +328,35 @@ function ImagePreview({ agentId, path, theme }: { agentId: string; path: string;
321
328
  const load = useCallback(
322
329
  (allowLarge: boolean) => {
323
330
  setState({ status: "loading" });
324
- void readImage({ cwd, path, allowLarge })
325
- .then((result) => {
326
- if (result.dataUri !== null) {
327
- setState({ status: "ready", uri: result.dataUri });
328
- } else if (result.tooLarge) {
329
- setState({ status: "tooLarge", bytes: result.bytes ?? 0, limit: result.limit ?? 0 });
330
- } else {
331
- setState({ status: "error", code: result.errorCode ?? "unreadable", detail: result.errorDetail });
332
- }
333
- })
334
- .catch((error: unknown) => {
335
- setState({
336
- status: "error",
337
- code: "unreadable",
338
- detail: error instanceof Error ? error.message : String(error),
339
- });
331
+ const failed = (error: unknown) => {
332
+ setState({
333
+ status: "error",
334
+ code: "unreadable",
335
+ detail: error instanceof Error ? error.message : String(error),
340
336
  });
337
+ };
338
+ // `readImage` can throw before it returns a promise (the host may not
339
+ // have the RPC ready yet); that throw would escape the effect and become
340
+ // a fatal error, so both shapes are absorbed here.
341
+ try {
342
+ void readImage({ cwd, path, allowLarge })
343
+ .then((result) => {
344
+ if (result.dataUri !== null) {
345
+ setState({ status: "ready", uri: result.dataUri });
346
+ } else if (result.tooLarge) {
347
+ setState({ status: "tooLarge", bytes: result.bytes ?? 0, limit: result.limit ?? 0 });
348
+ } else {
349
+ setState({ status: "error", code: result.errorCode ?? "unreadable", detail: result.errorDetail });
350
+ }
351
+ })
352
+ .catch((error: unknown) => {
353
+ report("image preview", error);
354
+ failed(error);
355
+ });
356
+ } catch (error) {
357
+ report("image preview", error);
358
+ failed(error);
359
+ }
341
360
  },
342
361
  [cwd, path, readImage],
343
362
  );
@@ -423,12 +442,17 @@ function SheetPanel({
423
442
  children: ReactNode;
424
443
  }) {
425
444
  const toast = useToast();
426
- const { t } = useTranslation(messages);
445
+ const { t } = useTranslation();
427
446
  const copy = useCallback(() => {
428
447
  if (copyValue === undefined) return;
429
- void copyText(copyValue)
430
- .then(() => toast.show(t("timeline.row.copied")))
431
- .catch(() => toast.error(t("timeline.row.copyFailed")));
448
+ guardAsync("copy text", async () => {
449
+ try {
450
+ await copyText(copyValue);
451
+ toast.show(t("timeline.row.copied"));
452
+ } catch {
453
+ toast.error(t("timeline.row.copyFailed"));
454
+ }
455
+ });
432
456
  }, [copyValue, toast, t]);
433
457
  const window = useWindowDimensions();
434
458
  const style = useTimelineStyle();
@@ -506,7 +530,7 @@ function DetailSheet({
506
530
  children: ReactNode;
507
531
  }) {
508
532
  const [full, setFull] = useState(false);
509
- const { t } = useTranslation(messages);
533
+ const { t } = useTranslation();
510
534
  const backdropLabel = t("timeline.row.close");
511
535
  useEffect(() => {
512
536
  if (!open) setFull(false);
@@ -546,7 +570,7 @@ function DetailSheet({
546
570
  }
547
571
 
548
572
  function ReasoningRow({ item, theme, layout }: PluginTimelineItemProps<ReasoningData>) {
549
- const { t } = useTranslation(messages);
573
+ const { t } = useTranslation();
550
574
  const streaming = item.data.phase === "streaming";
551
575
  const inline = layout.platform === "web";
552
576
  const [open, setOpen] = useState(false);
@@ -1275,7 +1299,7 @@ function CodeSurface({
1275
1299
  }) {
1276
1300
  const [wrap, setWrap] = useState(false);
1277
1301
  const toast = useToast();
1278
- const { t } = useTranslation(messages);
1302
+ const { t } = useTranslation();
1279
1303
  const background = sheetBackground(theme);
1280
1304
  const copy = useCallback(() => {
1281
1305
  void copyText(text)
@@ -1329,7 +1353,7 @@ function ToolRow({ item, theme, layout, agentId }: PluginTimelineItemProps<ToolD
1329
1353
  const inline = layout.platform === "web";
1330
1354
  const window = useWindowDimensions();
1331
1355
  const data = item.data;
1332
- const { t } = useTranslation(messages);
1356
+ const { t } = useTranslation();
1333
1357
  const look = useMemo(() => toolLook(data), [data]);
1334
1358
  const verb = typeof look.verb === "string" ? t(look.verb) : look.verb.text;
1335
1359
  const content = useMemo(() => toolContent(data), [data]);
@@ -1452,7 +1476,7 @@ function ToolRow({ item, theme, layout, agentId }: PluginTimelineItemProps<ToolD
1452
1476
  * dropped once it completes and the list never appears twice.
1453
1477
  */
1454
1478
  function TodoRow({ item, theme, layout }: PluginTimelineItemProps<TodoData>) {
1455
- const { t } = useTranslation(messages);
1479
+ const { t } = useTranslation();
1456
1480
  const [open, setOpen] = useState(false);
1457
1481
  const inline = layout.platform === "web";
1458
1482
  const window = useWindowDimensions();
@@ -1526,108 +1550,126 @@ export function contributeTimeline(client: PluginClientContext): () => void {
1526
1550
  id: "dsh-reasoning-row",
1527
1551
  query: { itemType: "reasoning" },
1528
1552
  transform({ item, phase }) {
1529
- if (item.type !== "reasoning" || item.text.trim() === "") return undefined;
1530
- return {
1531
- items: [{
1532
- type: "plugin" as const,
1533
- kind: "dsh-reasoning",
1534
- version: 1,
1535
- data: { text: item.text, phase },
1536
- }],
1537
- };
1553
+ return guard("timeline transformer dsh-reasoning", () => {
1554
+ if (item.type !== "reasoning" || item.text.trim() === "") return undefined;
1555
+ return {
1556
+ items: [{
1557
+ type: "plugin" as const,
1558
+ kind: "dsh-reasoning",
1559
+ version: 1,
1560
+ data: { text: item.text, phase },
1561
+ }],
1562
+ };
1563
+ }, undefined);
1538
1564
  },
1539
1565
  }),
1540
1566
  client.addTimelineRenderer({
1541
1567
  kind: "dsh-reasoning",
1542
1568
  version: 1,
1543
1569
  schema: reasoningSchema,
1544
- Component: ReasoningRow,
1570
+ Component: withPluginBoundary<PluginTimelineItemProps<ReasoningData>>(
1571
+ "dsh-reasoning",
1572
+ ReasoningRow,
1573
+ (props) => <FailedRow theme={props.theme} message={translateForLabel("timeline.row.renderFailed")} />,
1574
+ ),
1545
1575
  }),
1546
1576
  client.addTimelineTransformer({
1547
1577
  id: "dsh-todo-row",
1548
1578
  query: { itemType: "todo" },
1549
1579
  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
- };
1580
+ return guard("timeline transformer dsh-todo", () => {
1581
+ if (item.type !== "todo") return undefined;
1582
+ const items = item.items.flatMap((entry) => {
1583
+ const text = typeof entry.text === "string" ? entry.text : "";
1584
+ if (text === "") return [];
1585
+ const status = typeof entry.status === "string"
1586
+ ? entry.status
1587
+ : entry.completed
1588
+ ? "completed"
1589
+ : "pending";
1590
+ return [{
1591
+ text,
1592
+ status,
1593
+ ...(typeof entry.activeForm === "string" ? { activeForm: entry.activeForm } : {}),
1594
+ }];
1595
+ });
1596
+ if (items.length === 0) return undefined;
1597
+ return {
1598
+ items: [{
1599
+ type: "plugin" as const,
1600
+ kind: "dsh-todo",
1601
+ version: 1,
1602
+ data: { items },
1603
+ }],
1604
+ };
1605
+ }, undefined);
1574
1606
  },
1575
1607
  }),
1576
1608
  client.addTimelineRenderer({
1577
1609
  kind: "dsh-todo",
1578
1610
  version: 1,
1579
1611
  schema: todoSchema,
1580
- Component: TodoRow,
1612
+ Component: withPluginBoundary<PluginTimelineItemProps<TodoData>>(
1613
+ "dsh-todo",
1614
+ TodoRow,
1615
+ (props) => <FailedRow theme={props.theme} message={translateForLabel("timeline.row.renderFailed")} />,
1616
+ ),
1581
1617
  }),
1582
1618
  client.addTimelineTransformer({
1583
1619
  id: "dsh-tool-row",
1584
1620
  query: { itemType: "tool_call" },
1585
1621
  transform({ item, phase }) {
1586
- if (item.type !== "tool_call") return undefined;
1587
- const detail = isRecord(item.detail) ? item.detail : undefined;
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
- }
1598
- // Keep Paseo's richer cards for semantic helpers; every other tool gets
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.
1602
- const nativeCard = type === "sub_agent"
1603
- || type === "worktree_setup"
1604
- || type === "plan";
1605
- if (nativeCard) return undefined;
1606
- const error = item.error === null || item.error === undefined ? undefined : String(
1607
- isRecord(item.error) && typeof item.error.message === "string" ? item.error.message : item.error,
1608
- );
1609
- return {
1610
- items: [{
1611
- type: "plugin" as const,
1612
- kind: "dsh-tool",
1613
- version: 1,
1614
- data: {
1615
- name: item.name,
1616
- status: item.status,
1617
- ...(detail === undefined ? {} : { detail: toJson(detail) }),
1618
- ...(item.callId === undefined ? {} : { callId: item.callId }),
1619
- ...(error === undefined ? {} : { error }),
1620
- phase,
1621
- },
1622
- }],
1623
- };
1622
+ return guard("timeline transformer dsh-tool", () => {
1623
+ if (item.type !== "tool_call") return undefined;
1624
+ const detail = isRecord(item.detail) ? item.detail : undefined;
1625
+ const type = stringField(detail, "type");
1626
+ // A finished `todo_write` is drawn by the checklist row above; keeping
1627
+ // its tool row too would show one call twice.
1628
+ if (
1629
+ item.name === "todo_write"
1630
+ && item.status === "completed"
1631
+ && todoEntries(detailInput(detail)).length > 0
1632
+ ) {
1633
+ return { items: [] };
1634
+ }
1635
+ // Keep Paseo's richer cards for semantic helpers; every other tool gets
1636
+ // the shared row so a provider-specific name never shows up bare, and an
1637
+ // unfamiliar tool falls back to the generic wrench row instead of the
1638
+ // host's own styling.
1639
+ const nativeCard = type === "sub_agent"
1640
+ || type === "worktree_setup"
1641
+ || type === "plan";
1642
+ if (nativeCard) return undefined;
1643
+ const error = item.error === null || item.error === undefined ? undefined : String(
1644
+ isRecord(item.error) && typeof item.error.message === "string" ? item.error.message : item.error,
1645
+ );
1646
+ return {
1647
+ items: [{
1648
+ type: "plugin" as const,
1649
+ kind: "dsh-tool",
1650
+ version: 1,
1651
+ data: {
1652
+ name: item.name,
1653
+ status: item.status,
1654
+ ...(detail === undefined ? {} : { detail: toJson(detail) }),
1655
+ ...(item.callId === undefined ? {} : { callId: item.callId }),
1656
+ ...(error === undefined ? {} : { error }),
1657
+ phase,
1658
+ },
1659
+ }],
1660
+ };
1661
+ }, undefined);
1624
1662
  },
1625
1663
  }),
1626
1664
  client.addTimelineRenderer({
1627
1665
  kind: "dsh-tool",
1628
1666
  version: 1,
1629
1667
  schema: toolSchema,
1630
- Component: ToolRow,
1668
+ Component: withPluginBoundary<PluginTimelineItemProps<ToolData>>(
1669
+ "dsh-tool",
1670
+ ToolRow,
1671
+ (props) => <FailedRow theme={props.theme} message={translateForLabel("timeline.row.renderFailed")} />,
1672
+ ),
1631
1673
  }),
1632
1674
  ];
1633
1675
  return () => {
package/index.client.tsx CHANGED
@@ -1,15 +1,53 @@
1
1
  import type { PluginClientContext } from "@getpaseo/plugin/client";
2
+ import { guardCleanup, report } from "./client/guard";
3
+ import { DshPluginsPage } from "./client/dsh-plugins-page";
4
+ import { persistentLabel } from "./client/labels";
2
5
  import { contributeStreamStats } from "./client/stream-stats";
3
6
  import { contributeTimelineSettings } from "./client/settings-screen";
4
7
  import { contributeTimeline } from "./client/timeline";
5
8
 
6
- export default function contribute(client: PluginClientContext) {
9
+ /**
10
+ * The icon travels as inline SVG rather than a Lucide name: the app ships a
11
+ * pruned icon set, and a name it does not know is rejected while the host
12
+ * registers the sidebar row.
13
+ */
14
+ const PLUGIN_ICON = {
15
+ svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="7" height="7" x="14" y="3" rx="1"/><path d="M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3"/></svg>',
16
+ };
17
+
18
+ function buildContributions(client: PluginClientContext) {
19
+ const title = persistentLabel("plugins.page.title");
7
20
  const cleanups = [
8
- contributeStreamStats(client),
9
- contributeTimeline(client),
10
- contributeTimelineSettings(client),
21
+ guardCleanup("stream stats", () => contributeStreamStats(client)),
22
+ guardCleanup("timeline", () => contributeTimeline(client)),
23
+ guardCleanup("timeline settings", () => contributeTimelineSettings(client)),
24
+ guardCleanup("plugins screen", () => client.addScreen({
25
+ id: "dsh-plugins",
26
+ title,
27
+ Component: DshPluginsPage,
28
+ })),
29
+ guardCleanup("plugins sidebar", () => client.addSidebarItem({
30
+ id: "dsh-plugins",
31
+ title,
32
+ icon: PLUGIN_ICON,
33
+ surface: "dsh-plugins",
34
+ })),
11
35
  ];
12
36
  return () => {
13
37
  for (const cleanup of cleanups) cleanup();
14
38
  };
15
39
  }
40
+
41
+ /**
42
+ * Nothing this entry point does may reach the host as an exception: release
43
+ * Hermes reports an uncaught plugin error as fatal and closes the whole app,
44
+ * including for users who never opened a DSH screen.
45
+ */
46
+ export default function contribute(client: PluginClientContext) {
47
+ try {
48
+ return buildContributions(client);
49
+ } catch (error) {
50
+ report("plugin client entry", error);
51
+ return () => {};
52
+ }
53
+ }
package/index.server.ts CHANGED
@@ -4,6 +4,8 @@ import type { PluginServerContext } from "@getpaseo/plugin/server";
4
4
  import { imagePreviewRpc } from "./shared/image-preview";
5
5
  import { timelineStyleSettings } from "./shared/settings";
6
6
  import { ensurePaseoProfile } from "./server/bootstrap";
7
+ import { DshPlugins } from "./server/dsh-plugins";
8
+ import { registerDshPluginsRpc } from "./server/dsh-plugins-rpc";
7
9
  import { createDshProvider } from "./server/provider";
8
10
 
9
11
  /**
@@ -14,6 +16,9 @@ import { createDshProvider } from "./server/provider";
14
16
  * bundle it carries (see server/bootstrap.ts). Provisioning is best-effort —
15
17
  * a filesystem failure is logged and the provider still registers, so the
16
18
  * failure surfaces as an honest error when a session tries to start `dsh`.
19
+ *
20
+ * The DSH Plugins page is registered even when provisioning fails: it opens on
21
+ * the profile path and shows the real error, instead of disappearing.
17
22
  */
18
23
  const MAX_IMAGE_BYTES = 12 * 1024 * 1024;
19
24
  const HARD_MAX_IMAGE_BYTES = 64 * 1024 * 1024;
@@ -93,6 +98,12 @@ export default function contribute(server: PluginServerContext) {
93
98
  };
94
99
  }
95
100
  });
101
+
102
+ const manager = new DshPlugins();
103
+ const disposePlugins = registerDshPluginsRpc(server, manager);
96
104
  server.registerProvider(createDshProvider());
97
- return () => {};
105
+
106
+ return () => {
107
+ disposePlugins();
108
+ };
98
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-dsh",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "description": "DeepSeek Harness (dsh) as a native Paseo provider: question cards, plan mode, thinking levels, steering, images, a slash menu, permissions and presets.",
5
5
  "keywords": [
6
6
  "paseo",
@@ -47,7 +47,7 @@
47
47
  "check:locales": "node scripts/check-locales.mjs"
48
48
  },
49
49
  "peerDependencies": {
50
- "@getpaseo/plugin": ">=0.13.0"
50
+ "@getpaseo/plugin": ">=0.16.0"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "@getpaseo/plugin": {
package/paseo-plugin.json CHANGED
@@ -8,6 +8,6 @@
8
8
  }
9
9
  },
10
10
  "requirements": {
11
- "paseo": ">=0.13.0"
11
+ "paseo": ">=0.16.0"
12
12
  }
13
13
  }
@@ -36,10 +36,16 @@ export function profileName(): string {
36
36
  return process.env.DSH_PASEO_PROFILE ?? "paseo";
37
37
  }
38
38
 
39
- function dshHome(): string {
39
+ /** Root that holds every DSH profile; `DSH_HOME` overrides `~/.dsh`. */
40
+ export function dshHomeDir(): string {
40
41
  return process.env.DSH_HOME ?? join(homedir(), ".dsh");
41
42
  }
42
43
 
44
+ /** Directory of one profile, without creating or reading it. */
45
+ export function profileDir(profile: string = profileName(), home: string = dshHomeDir()): string {
46
+ return join(home, "profiles", profile);
47
+ }
48
+
43
49
  function profilePackageJson(profile: string): string {
44
50
  return `${JSON.stringify(
45
51
  {
@@ -74,7 +80,7 @@ export interface ProvisionResult {
74
80
  */
75
81
  export function ensurePaseoProfile(): ProvisionResult {
76
82
  const profile = profileName();
77
- const dir = join(dshHome(), "profiles", profile);
83
+ const dir = profileDir(profile);
78
84
  mkdirSync(join(dir, "node_modules"), { recursive: true });
79
85
 
80
86
  // The profile's own files belong to the user: create a missing one, but never