@keith9681/dsh-sidebar 0.15.2

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.
Files changed (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/README_EN.md +0 -0
  4. package/cordis.patch.yml +49 -0
  5. package/lib/client-editor.js +34651 -0
  6. package/lib/client-mermaid.js +200629 -0
  7. package/lib/client-registry.js +13388 -0
  8. package/lib/client-terminal.js +8904 -0
  9. package/lib/client.js +13388 -0
  10. package/lib/index.js +3959 -0
  11. package/lib/invariant.js +22 -0
  12. package/lib/types/agent-pty.d.ts +226 -0
  13. package/lib/types/browser-probe.d.ts +15 -0
  14. package/lib/types/bundle-route.d.ts +12 -0
  15. package/lib/types/client/BrowserView.d.ts +22 -0
  16. package/lib/types/client/DiffTab.d.ts +6 -0
  17. package/lib/types/client/DiffView.d.ts +51 -0
  18. package/lib/types/client/EditorHost.d.ts +12 -0
  19. package/lib/types/client/FileTree.d.ts +36 -0
  20. package/lib/types/client/GitView.d.ts +8 -0
  21. package/lib/types/client/OrphanedTab.d.ts +11 -0
  22. package/lib/types/client/PdfView.d.ts +6 -0
  23. package/lib/types/client/RenderBoundary.d.ts +32 -0
  24. package/lib/types/client/SandboxStatusBar.d.ts +10 -0
  25. package/lib/types/client/SideCardSection.d.ts +74 -0
  26. package/lib/types/client/SideChatView.d.ts +16 -0
  27. package/lib/types/client/Sidebar.d.ts +6 -0
  28. package/lib/types/client/SubagentView.d.ts +16 -0
  29. package/lib/types/client/TabBar.d.ts +43 -0
  30. package/lib/types/client/TerminalView.d.ts +24 -0
  31. package/lib/types/client/TextEditor.d.ts +10 -0
  32. package/lib/types/client/TreePanel.d.ts +23 -0
  33. package/lib/types/client/UploadOverlay.d.ts +20 -0
  34. package/lib/types/client/add-plugin-modal.d.ts +15 -0
  35. package/lib/types/client/api.d.ts +268 -0
  36. package/lib/types/client/binary-download.d.ts +12 -0
  37. package/lib/types/client/breakpoints.d.ts +12 -0
  38. package/lib/types/client/browser.d.ts +50 -0
  39. package/lib/types/client/builtins/index.d.ts +18 -0
  40. package/lib/types/client/builtins/tabs.d.ts +11 -0
  41. package/lib/types/client/builtins/viewers.d.ts +3 -0
  42. package/lib/types/client/chunk-loader.d.ts +124 -0
  43. package/lib/types/client/chunks/editor.d.ts +9 -0
  44. package/lib/types/client/chunks/mermaid.d.ts +10 -0
  45. package/lib/types/client/chunks/terminal.d.ts +9 -0
  46. package/lib/types/client/cm-themes.d.ts +24 -0
  47. package/lib/types/client/conversation-draft.d.ts +14 -0
  48. package/lib/types/client/desktop-env.d.ts +35 -0
  49. package/lib/types/client/editable-state.d.ts +27 -0
  50. package/lib/types/client/editor-load.d.ts +66 -0
  51. package/lib/types/client/frame-batcher.d.ts +24 -0
  52. package/lib/types/client/icons.d.ts +57 -0
  53. package/lib/types/client/image-types.d.ts +3 -0
  54. package/lib/types/client/ime-guard.d.ts +36 -0
  55. package/lib/types/client/index.d.ts +19 -0
  56. package/lib/types/client/intercept.d.ts +33 -0
  57. package/lib/types/client/lang.d.ts +12 -0
  58. package/lib/types/client/lazy-chunk.d.ts +25 -0
  59. package/lib/types/client/link-intercept.d.ts +42 -0
  60. package/lib/types/client/locales.d.ts +366 -0
  61. package/lib/types/client/mermaid-blocks.d.ts +41 -0
  62. package/lib/types/client/mermaid-sanitize.d.ts +2 -0
  63. package/lib/types/client/mermaid.d.ts +12 -0
  64. package/lib/types/client/open-when-sized.d.ts +20 -0
  65. package/lib/types/client/open-with-settings.d.ts +4 -0
  66. package/lib/types/client/open-with.d.ts +87 -0
  67. package/lib/types/client/openpath-intercept.d.ts +41 -0
  68. package/lib/types/client/paths.d.ts +35 -0
  69. package/lib/types/client/pdf-types.d.ts +2 -0
  70. package/lib/types/client/plugin-settings.d.ts +8 -0
  71. package/lib/types/client/plugins-shared.d.ts +27 -0
  72. package/lib/types/client/plugins-tabs.d.ts +3 -0
  73. package/lib/types/client/plugins-viewers.d.ts +3 -0
  74. package/lib/types/client/prefs.d.ts +41 -0
  75. package/lib/types/client/produced-files.d.ts +23 -0
  76. package/lib/types/client/selection-payload.d.ts +27 -0
  77. package/lib/types/client/service.d.ts +440 -0
  78. package/lib/types/client/settings-nav-icon.d.ts +19 -0
  79. package/lib/types/client/shell-presets.d.ts +48 -0
  80. package/lib/types/client/sidechat-transcript.d.ts +103 -0
  81. package/lib/types/client/split-pane.d.ts +30 -0
  82. package/lib/types/client/state.d.ts +359 -0
  83. package/lib/types/client/subagent-detect.d.ts +54 -0
  84. package/lib/types/client/subagent-jobs.d.ts +63 -0
  85. package/lib/types/client/tab-content-memo.d.ts +33 -0
  86. package/lib/types/client/terminal-font.d.ts +20 -0
  87. package/lib/types/client/theme.d.ts +45 -0
  88. package/lib/types/client/titlebar-strip.d.ts +23 -0
  89. package/lib/types/client/upload.d.ts +69 -0
  90. package/lib/types/client/wco.d.ts +47 -0
  91. package/lib/types/config.d.ts +64 -0
  92. package/lib/types/context-types.d.ts +603 -0
  93. package/lib/types/fs-operations.d.ts +28 -0
  94. package/lib/types/fs-search.d.ts +24 -0
  95. package/lib/types/fs-tree.d.ts +51 -0
  96. package/lib/types/git.d.ts +82 -0
  97. package/lib/types/html-route.d.ts +59 -0
  98. package/lib/types/index.d.ts +47 -0
  99. package/lib/types/invariant.d.ts +15 -0
  100. package/lib/types/jobs-routes.d.ts +45 -0
  101. package/lib/types/open-external.d.ts +24 -0
  102. package/lib/types/prefs-shared.d.ts +225 -0
  103. package/lib/types/pty-deps.d.ts +78 -0
  104. package/lib/types/pty-manager.d.ts +168 -0
  105. package/lib/types/sidechat-core.d.ts +172 -0
  106. package/lib/types/sidechat-routes.d.ts +30 -0
  107. package/lib/types/subagent-activity.d.ts +44 -0
  108. package/lib/types/subagent-live-route.d.ts +44 -0
  109. package/lib/types/tools.d.ts +31 -0
  110. package/lib/types/trust-fence.d.ts +24 -0
  111. package/lib/types/wire.d.ts +38 -0
  112. package/package.json +173 -0
  113. package/scripts/install.ps1 +289 -0
  114. package/scripts/install.sh +287 -0
  115. package/src/agent-pty.ts +527 -0
  116. package/src/browser-probe.ts +26 -0
  117. package/src/bundle-route.ts +129 -0
  118. package/src/client/BrowserView.tsx +253 -0
  119. package/src/client/DiffTab.tsx +110 -0
  120. package/src/client/DiffView.tsx +305 -0
  121. package/src/client/EditorHost.tsx +525 -0
  122. package/src/client/FileTree.tsx +653 -0
  123. package/src/client/GitView.tsx +558 -0
  124. package/src/client/OrphanedTab.tsx +27 -0
  125. package/src/client/PdfView.tsx +110 -0
  126. package/src/client/RenderBoundary.tsx +49 -0
  127. package/src/client/SandboxStatusBar.tsx +60 -0
  128. package/src/client/SideCardSection.module.css +960 -0
  129. package/src/client/SideCardSection.tsx +1152 -0
  130. package/src/client/SideChatView.module.css +437 -0
  131. package/src/client/SideChatView.tsx +644 -0
  132. package/src/client/Sidebar.tsx +1148 -0
  133. package/src/client/SubagentView.module.css +547 -0
  134. package/src/client/SubagentView.tsx +883 -0
  135. package/src/client/TabBar.tsx +305 -0
  136. package/src/client/TerminalView.tsx +383 -0
  137. package/src/client/TextEditor.tsx +500 -0
  138. package/src/client/TreePanel.tsx +273 -0
  139. package/src/client/UploadOverlay.tsx +62 -0
  140. package/src/client/add-plugin-modal.tsx +199 -0
  141. package/src/client/api.ts +335 -0
  142. package/src/client/binary-download.tsx +23 -0
  143. package/src/client/breakpoints.ts +51 -0
  144. package/src/client/browser.ts +119 -0
  145. package/src/client/builtins/index.ts +37 -0
  146. package/src/client/builtins/tabs.tsx +331 -0
  147. package/src/client/builtins/viewers.tsx +125 -0
  148. package/src/client/chunk-loader.ts +351 -0
  149. package/src/client/chunks/editor.tsx +9 -0
  150. package/src/client/chunks/mermaid.tsx +10 -0
  151. package/src/client/chunks/terminal.tsx +9 -0
  152. package/src/client/cm-themes.ts +129 -0
  153. package/src/client/conversation-draft.ts +29 -0
  154. package/src/client/css-modules.d.ts +5 -0
  155. package/src/client/desktop-env.ts +72 -0
  156. package/src/client/editable-state.ts +70 -0
  157. package/src/client/editor-load.ts +92 -0
  158. package/src/client/frame-batcher.ts +56 -0
  159. package/src/client/icons.tsx +161 -0
  160. package/src/client/image-types.ts +8 -0
  161. package/src/client/ime-guard.ts +47 -0
  162. package/src/client/index.tsx +369 -0
  163. package/src/client/intercept.tsx +110 -0
  164. package/src/client/lang.ts +103 -0
  165. package/src/client/layout.css +94 -0
  166. package/src/client/lazy-chunk.tsx +89 -0
  167. package/src/client/link-intercept.ts +73 -0
  168. package/src/client/locales.ts +734 -0
  169. package/src/client/mermaid-blocks.ts +110 -0
  170. package/src/client/mermaid-sanitize.ts +93 -0
  171. package/src/client/mermaid.tsx +401 -0
  172. package/src/client/open-when-sized.ts +43 -0
  173. package/src/client/open-with-settings.tsx +135 -0
  174. package/src/client/open-with.ts +221 -0
  175. package/src/client/openpath-intercept.ts +62 -0
  176. package/src/client/paths.ts +47 -0
  177. package/src/client/pdf-types.ts +4 -0
  178. package/src/client/plugin-settings.ts +43 -0
  179. package/src/client/plugins-shared.ts +29 -0
  180. package/src/client/plugins-tabs.ts +87 -0
  181. package/src/client/plugins-viewers.ts +30 -0
  182. package/src/client/prefs.ts +207 -0
  183. package/src/client/produced-files.ts +91 -0
  184. package/src/client/selection-payload.ts +86 -0
  185. package/src/client/service.ts +838 -0
  186. package/src/client/settings-nav-icon.ts +45 -0
  187. package/src/client/shell-presets.ts +83 -0
  188. package/src/client/sidebar.module.css +2577 -0
  189. package/src/client/sidechat-transcript.ts +321 -0
  190. package/src/client/split-pane.tsx +322 -0
  191. package/src/client/state.ts +1175 -0
  192. package/src/client/subagent-detect.ts +137 -0
  193. package/src/client/subagent-jobs.ts +161 -0
  194. package/src/client/tab-content-memo.ts +46 -0
  195. package/src/client/terminal-font.ts +28 -0
  196. package/src/client/theme.ts +110 -0
  197. package/src/client/titlebar-strip.ts +37 -0
  198. package/src/client/upload.ts +187 -0
  199. package/src/client/wco.ts +120 -0
  200. package/src/config.ts +155 -0
  201. package/src/context-types.ts +610 -0
  202. package/src/fs-operations.ts +99 -0
  203. package/src/fs-search.ts +86 -0
  204. package/src/fs-tree.ts +158 -0
  205. package/src/git.ts +244 -0
  206. package/src/html-route.ts +106 -0
  207. package/src/index.ts +1132 -0
  208. package/src/invariant.ts +32 -0
  209. package/src/jobs-routes.ts +257 -0
  210. package/src/open-external.ts +90 -0
  211. package/src/prefs-shared.ts +268 -0
  212. package/src/pty-deps.ts +240 -0
  213. package/src/pty-manager.ts +376 -0
  214. package/src/sidechat-core.ts +468 -0
  215. package/src/sidechat-routes.ts +344 -0
  216. package/src/subagent-activity.ts +91 -0
  217. package/src/subagent-live-route.ts +93 -0
  218. package/src/tools.ts +479 -0
  219. package/src/trust-fence.ts +77 -0
  220. package/src/wire.ts +100 -0
@@ -0,0 +1,24 @@
1
+ import '@xterm/xterm/css/xterm.css';
2
+ import { type SessionScope, type TerminalDepsStatus } from './api.ts';
3
+ import { type SidebarStore } from './state.ts';
4
+ /** The degraded-mode payload rendered by {@link TerminalDepsBanner}. */
5
+ type TerminalDepsInfo = Extract<TerminalDepsStatus, {
6
+ ok: false;
7
+ }>;
8
+ export declare function TerminalView(props: {
9
+ scope: SessionScope;
10
+ tabId: string;
11
+ store: SidebarStore;
12
+ }): import("react").JSX.Element;
13
+ /**
14
+ * The node-pty dependency failure banner (issue #140): explains that the
15
+ * terminal's native dependency failed to load and shows the PASTEABLE repair
16
+ * command (bash / cmd / PowerShell) with a copy button — the user pastes it
17
+ * into a terminal where their DSH profile lives and runs it, then retries.
18
+ * Extracted as a standalone component for direct testing.
19
+ */
20
+ export declare function TerminalDepsBanner(props: {
21
+ deps: TerminalDepsInfo;
22
+ onRetry: () => void;
23
+ }): import("react").JSX.Element;
24
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { FileViewerProps } from './service.ts';
2
+ /**
3
+ * The sandbox tokens of the HTML preview iframe. NO allow-same-origin (the
4
+ * preview must stay in an opaque origin — with the route's own origin it
5
+ * could read session data) and NO allow-top-navigation (a previewed page
6
+ * must not hijack the GUI). The user can disable the sandbox per-feature
7
+ * in the side card settings (warned); the toggle below reflects it.
8
+ */
9
+ export declare const HTML_IFRAME_SANDBOX = "allow-scripts allow-popups allow-downloads allow-modals";
10
+ export declare function TextEditor(props: FileViewerProps): import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import type { OpenWithTarget } from './open-with.ts';
2
+ export declare function TreePanel(props: {
3
+ sessionId: string;
4
+ cwd: string | undefined;
5
+ expanded: string[];
6
+ onToggle: (path: string) => void;
7
+ onOpenFile: (path: string) => void;
8
+ /** File context-menu "open in a new tab" (passed through to FileTree). */
9
+ onOpenFileNewTab?: (path: string) => void;
10
+ /** File context-menu "open to the side" (passed through to FileTree). */
11
+ onOpenFileSide?: (path: string) => void;
12
+ /** The "open with" menu surface (passed through to FileTree; absent →
13
+ * the whole section is hidden). */
14
+ openWithTargets?: OpenWithTarget[];
15
+ openWithPinned?: string[];
16
+ openWithSsh?: boolean;
17
+ onOpenWith?: (targetId: string, path: string) => void;
18
+ onToggleOpenWithPin?: (targetId: string) => void;
19
+ onReferenceFile: (path: string) => void;
20
+ /** Full-window presentation: the panel fills its host instead of docking
21
+ * at a fixed width. */
22
+ full?: boolean;
23
+ }): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Full-window upload progress over the files tree: a blurred scrim (same mask
3
+ * token as the repo's Modal primitive) with a card showing the target
4
+ * directory, file-level progress, and a cancel button. Esc cancels too —
5
+ * clicking the scrim does not, so a stray click can never abort an upload.
6
+ * Rendered inside TreePanel (absolute inset-0), so it covers only the file
7
+ * window and never the conversation column.
8
+ */
9
+ import { type ReactNode } from 'react';
10
+ export declare function UploadOverlay(props: {
11
+ /** Absolute upload directory (the session workspace or a tree directory). */
12
+ dir: string;
13
+ done: number;
14
+ total: number;
15
+ /** Relative path of the file being uploaded ('' when none is in flight). */
16
+ current: string;
17
+ onCancel: () => void;
18
+ /** True while cancellation is in flight (disables the cancel button). */
19
+ cancelling?: boolean;
20
+ }): ReactNode;
@@ -0,0 +1,15 @@
1
+ import type { BetterSidebarService } from './service.ts';
2
+ /** Which extension point the modal is adding a plugin for. */
3
+ export type PluginKind = 'tab' | 'viewer';
4
+ /** The modal body: the GitHub topic button + the recommended plugin list
5
+ * with per-entry jump/copy buttons (extracted for direct testing). */
6
+ export declare function PluginListBody(props: {
7
+ service: BetterSidebarService;
8
+ kind: PluginKind;
9
+ }): import("react").JSX.Element;
10
+ /** The modal itself (mounted only while open — see the module comment). */
11
+ export declare function AddPluginModal(props: {
12
+ service: BetterSidebarService;
13
+ onClose: () => void;
14
+ kind: PluginKind;
15
+ }): import("react").JSX.Element;
@@ -0,0 +1,268 @@
1
+ import type { LastActivity } from '../subagent-activity.ts';
2
+ import type { SidechatThreadInfo } from '../sidechat-core.ts';
3
+ import type { BrowserProbeResult } from './browser.ts';
4
+ /** One wire failure. */
5
+ export declare class SidebarApiError extends Error {
6
+ readonly code: string;
7
+ constructor(code: string, message: string);
8
+ }
9
+ /** Explorer row (host fs-tree shape). */
10
+ export interface FsEntry {
11
+ name: string;
12
+ path: string;
13
+ isDir: boolean;
14
+ hidden: boolean;
15
+ /** Whether the row is a symlink; `isDir` then describes the link's target. */
16
+ isSymlink: boolean;
17
+ /** For symlinks: the target is missing or unreadable (stat failed). */
18
+ broken: boolean;
19
+ }
20
+ /** Git status entry (host git shape). */
21
+ export interface GitStatusEntry {
22
+ path: string;
23
+ xy: string;
24
+ }
25
+ /** Git status snapshot. */
26
+ export interface GitStatusResult {
27
+ isRepo: boolean;
28
+ branch?: string;
29
+ entries: GitStatusEntry[];
30
+ }
31
+ /** One git log row. */
32
+ export interface GitLogEntry {
33
+ /** Short hash (7+ chars, display). */
34
+ hash: string;
35
+ /** Full 40-char hash (advanced operations). */
36
+ hashFull: string;
37
+ subject: string;
38
+ author: string;
39
+ /** ISO 8601 author date (`%ai`). */
40
+ date: string;
41
+ /** Ref decorations (--decorate=short), e.g. `HEAD -> main, origin/main`; '' when none. */
42
+ refs: string;
43
+ }
44
+ /** Text read result. */
45
+ export interface FsTextResult {
46
+ kind: 'text';
47
+ content: string;
48
+ truncated: boolean;
49
+ }
50
+ /** Binary read result (no content; images load through the media route).
51
+ * `head` carries the first bytes (base64) for viewer detect sniffing. */
52
+ export interface FsBinaryResult {
53
+ kind: 'binary';
54
+ size: number;
55
+ truncated: boolean;
56
+ head: string;
57
+ }
58
+ /**
59
+ * One jobs.output response: the output the MODEL has read so far for the
60
+ * job (replayed from the owner session's event log — the model's
61
+ * job_output cursor is never touched, so the pane can never steal the
62
+ * agent's bytes). `read` is false until the model actually called
63
+ * job_output for the job.
64
+ */
65
+ export interface JobOutputResult {
66
+ text: string;
67
+ /** True when the host capped the text at its output limit. */
68
+ truncated: boolean;
69
+ /** Whether the model has read the job at least once. */
70
+ read: boolean;
71
+ }
72
+ /** The `subagents.live` response: running child id → latest activity. */
73
+ export type SubagentLiveResult = {
74
+ live: Record<string, LastActivity>;
75
+ };
76
+ /** Terminal dependency status (mirror of the host's depsStatus; issue #140). */
77
+ export type TerminalDepsStatus = {
78
+ ok: true;
79
+ } | {
80
+ ok: false;
81
+ /** The require-time error message (module missing, native binding broken…). */
82
+ cause: string;
83
+ /** The pasteable repair command (terminal/cmd). */
84
+ command: string;
85
+ /** The detected profile name (null when undetected → the command defaults to web). */
86
+ profile: string | null;
87
+ /** Optional supplementary hint (fallback command only). */
88
+ note?: string;
89
+ };
90
+ /** One request's session scope: the conversation id plus its cwd when known. */
91
+ export interface SessionScope {
92
+ sessionId: string;
93
+ /** The session's working directory from the client list summary (optional). */
94
+ cwd?: string;
95
+ }
96
+ /** The sidebar API surface (session scope threaded through every call). */
97
+ export declare const api: {
98
+ sessionCwd: (scope: SessionScope, signal?: AbortSignal) => Promise<{
99
+ sessionId: string;
100
+ cwd: string;
101
+ root: string;
102
+ parent: string | null;
103
+ }>;
104
+ fsTree: (scope: SessionScope, path: string, signal?: AbortSignal) => Promise<{
105
+ path: string;
106
+ entries: FsEntry[];
107
+ truncated: boolean;
108
+ }>;
109
+ /** Global recursive file-name search rooted at the session cwd (the editor
110
+ * side panel's search box); matches are cwd-relative '/'-separated paths. */
111
+ fsSearch: (scope: SessionScope, query: string, signal?: AbortSignal) => Promise<{
112
+ matches: string[];
113
+ truncated: boolean;
114
+ }>;
115
+ fsRead: (scope: SessionScope, path: string, signal?: AbortSignal) => Promise<FsTextResult | FsBinaryResult>;
116
+ fsWrite: (scope: SessionScope, path: string, content: string) => Promise<{
117
+ ok: true;
118
+ }>;
119
+ /** Upload one file's raw bytes into `dir` (keeps the folder tree via
120
+ * `relativePath`); the host streams it under the session workspace. */
121
+ uploadFile: (scope: SessionScope, dir: string, relativePath: string, body: Blob, signal?: AbortSignal) => Promise<{
122
+ path: string;
123
+ size: number;
124
+ }>;
125
+ gitStatus: (scope: SessionScope, signal?: AbortSignal) => Promise<GitStatusResult>;
126
+ gitDiff: (scope: SessionScope, path: string | undefined, staged: boolean, signal?: AbortSignal) => Promise<{
127
+ diff: string;
128
+ }>;
129
+ gitStage: (scope: SessionScope, path?: string) => Promise<{
130
+ ok: true;
131
+ }>;
132
+ gitUnstage: (scope: SessionScope, path?: string) => Promise<{
133
+ ok: true;
134
+ }>;
135
+ gitCommit: (scope: SessionScope, message: string) => Promise<{
136
+ ok: true;
137
+ }>;
138
+ gitBranch: (scope: SessionScope, signal?: AbortSignal) => Promise<{
139
+ current: string;
140
+ names: string[];
141
+ }>;
142
+ gitCheckout: (scope: SessionScope, branch: string) => Promise<{
143
+ ok: true;
144
+ }>;
145
+ /** Recent commit history, lazily pageable (skip/count; defaults 0/30). */
146
+ gitLog: (scope: SessionScope, count?: number, skip?: number, signal?: AbortSignal) => Promise<GitLogEntry[]>;
147
+ /** Full patch text of one commit (diff display for the history rows). */
148
+ gitCommitDiff: (scope: SessionScope, hash: string, signal?: AbortSignal) => Promise<{
149
+ diff: string;
150
+ }>;
151
+ /** Discard the worktree changes of one file (the index is untouched). */
152
+ gitDiscard: (scope: SessionScope, path: string) => Promise<{
153
+ ok: true;
154
+ }>;
155
+ /** Revert one commit onto the current branch. */
156
+ gitRevert: (scope: SessionScope, hash: string) => Promise<{
157
+ ok: true;
158
+ }>;
159
+ /** Cherry-pick one commit onto the current branch. */
160
+ gitCherryPick: (scope: SessionScope, hash: string) => Promise<{
161
+ ok: true;
162
+ }>;
163
+ /** Release a terminal's process immediately (tab closed; the WS close frame
164
+ * may be unreachable while the socket is down, so the host also accepts
165
+ * this explicit route). */
166
+ ptyClose: (scope: SessionScope, tab: string) => Promise<{
167
+ ok: true;
168
+ }>;
169
+ /** Release an agent terminal by uuid (tab closed while WS was down). */
170
+ agentPtyClose: (uuid: string) => Promise<{
171
+ ok: true;
172
+ }>;
173
+ /** Terminal dependency status (issue #140): after a WS close 1011 with
174
+ * reason `pty-deps-missing` the view fetches the full repair details here
175
+ * (the close reason itself is capped at 123 bytes). */
176
+ terminalDeps: () => Promise<TerminalDepsStatus>;
177
+ /**
178
+ * The output the model has read so far for one background job (replayed
179
+ * from the owner session's event log — never the model's job_output
180
+ * cursor). The scope MUST be the job's OWNER session.
181
+ */
182
+ jobOutput: (scope: SessionScope, id: string, signal?: AbortSignal) => Promise<JobOutputResult>;
183
+ /** Request cancellation of one background job (live jobs flip to stopping). */
184
+ jobKill: (scope: SessionScope, id: string, reason?: string) => Promise<{
185
+ ok: true;
186
+ outcome: "requested" | "already-finished";
187
+ }>;
188
+ /**
189
+ * One batch live-preview fetch for the whole Subagent tree. The payload is
190
+ * the already-resolved topology ROOT (not a session scope); the host
191
+ * enumerates descendants once and folds running children's activity.
192
+ */
193
+ subagentsLive: (rootSessionId: string, signal?: AbortSignal) => Promise<SubagentLiveResult>;
194
+ /** Create a Side Chat thread: a child session seeded with the parent's
195
+ * full log up to now. Empty question = immediate create (Codex-style):
196
+ * the thread opens empty, the first prompt carries the boundary. */
197
+ sidechatStart: (sessionId: string, question?: string) => Promise<{
198
+ childId: string;
199
+ }>;
200
+ /** Deliver one follow-up message to a Side Chat thread. */
201
+ sidechatPrompt: (childId: string, text: string) => Promise<{
202
+ accepted: true;
203
+ }>;
204
+ /** Abort a Side Chat thread's running turn (queued work is preserved). */
205
+ sidechatCancel: (childId: string) => Promise<{
206
+ accepted: true;
207
+ }>;
208
+ /** Release a Side Chat thread's live agent (history stays persisted). */
209
+ sidechatDispose: (childId: string) => Promise<{
210
+ accepted: true;
211
+ }>;
212
+ /** Live state + agent identity (provider/model/preset) of a thread. */
213
+ sidechatInfo: (childId: string) => Promise<SidechatThreadInfo>;
214
+ /** The effective terminal shell and its display name (plugin-global). */
215
+ shellGet: () => Promise<{
216
+ shell: string;
217
+ name: string;
218
+ }>;
219
+ /** Whether the session may write files (host truth; default false = read-only). */
220
+ configGet: (scope: SessionScope) => Promise<{
221
+ editable: boolean;
222
+ }>;
223
+ /** Switch the session's write permission (the editor toolbar toggle). */
224
+ configSetEditable: (scope: SessionScope, editable: boolean) => Promise<{
225
+ ok: true;
226
+ }>;
227
+ /** Read the side card preferences (plugin-global, no session scope). */
228
+ settingsGet: () => Promise<{
229
+ value?: unknown;
230
+ revision?: number;
231
+ externalDisable?: boolean;
232
+ }>;
233
+ /** Merge a patch into the side card preferences (revision-guarded). */
234
+ settingsUpdate: (patch: Record<string, unknown>, expectedRevision?: number) => Promise<{
235
+ value?: unknown;
236
+ revision?: number;
237
+ }>;
238
+ /** Probe a URL's response headers (the sidebar browser's embeddability
239
+ * check; see the host's browser.probe route). */
240
+ browserProbe: (url: string, signal?: AbortSignal) => Promise<BrowserProbeResult>;
241
+ /** External open for the file tree's "open with" menu: reveal a path in
242
+ * the OS file manager, or hand a custom-scheme URL (vscode://, cursor://,
243
+ * zed://, custom editors) to its registered handler. The host launches
244
+ * the platform opener (argv, no shell). */
245
+ openExternal: (payload: {
246
+ action: "reveal";
247
+ path: string;
248
+ } | {
249
+ action: "url";
250
+ url: string;
251
+ }) => Promise<{
252
+ started: boolean;
253
+ }>;
254
+ };
255
+ /** Absolute URL of the media route for one path (images only). */
256
+ export declare function mediaUrl(scope: SessionScope, path: string): string;
257
+ /** Absolute URL of the download route: serves raw bytes (binary-safe) with
258
+ * `Content-Disposition: attachment`, so the browser saves the file. */
259
+ export declare function downloadUrl(scope: SessionScope, path: string): string;
260
+ /**
261
+ * Absolute URL of the HTML preview route (see html-route.ts): the path is
262
+ * fully encoded so the previewed page's relative assets resolve back into
263
+ * the same route with the session scope intact. The UNC marker is
264
+ * platform-neutral — the host's requireAbsolute resolves the decoded
265
+ * forward-slash `//server/share/...` form on both win32 and POSIX — so no
266
+ * client-side platform signal is needed.
267
+ */
268
+ export declare function htmlUrl(scope: SessionScope, path: string): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The "no preview — download instead" pane: shown by the editor host when no
3
+ * viewer can render a file (binary without a registered renderer, or the
4
+ * `binary-download` strategy) and registered as the `binary-download` viewer
5
+ * component so the declarative route and the host fallback share one UI.
6
+ */
7
+ import type { ReactNode } from 'react';
8
+ import type { SessionScope } from './api.ts';
9
+ export declare function BinaryDownload(props: {
10
+ scope: SessionScope;
11
+ path: string;
12
+ }): ReactNode;
@@ -0,0 +1,12 @@
1
+ /** Viewport widths strictly below this are "mobile" (paired CSS: max-width: 767px). */
2
+ export declare const NARROW_MAX_WIDTH = 768;
3
+ /** Whether a viewport width is narrow (mobile). */
4
+ export declare function isNarrowWidth(width: number): boolean;
5
+ /**
6
+ * Live narrow-viewport flag for components. Reads `window.innerWidth` and
7
+ * re-measures on resize (rAF-throttled, the repo's existing drag pattern).
8
+ * Deliberately avoids `matchMedia` (jsdom does not implement it) — the
9
+ * resize listener is equally exact for a breakpoint that never changes
10
+ * while the page is open.
11
+ */
12
+ export declare function useNarrowViewport(): boolean;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Pure URL policy for the built-in browser tab: normalize user input into
3
+ * an http(s) URL, and refuse destinations that would be dangerous to embed
4
+ * in the sidebar iframe. Kept dependency-free so it is unit-testable.
5
+ *
6
+ * The iframe sandbox (opaque origin, no allow-same-origin / top-navigation)
7
+ * is the primary security boundary; this module is the address-bar gate on
8
+ * top of it: only http/https may be navigated, and loopback addresses are
9
+ * refused so a browsed page cannot probe local services by user action.
10
+ * The GUI's OWN origin is explicitly ALLOWED — the user may open the GUI
11
+ * itself in the sidebar (debugging, mirroring); the sandbox still renders
12
+ * it in an opaque origin with no same-origin privileges, exactly like any
13
+ * other site.
14
+ */
15
+ /** Why a navigation attempt was refused. */
16
+ export type BrowserBlockReason = 'scheme' | 'loopback';
17
+ /** Result of normalizing one address-bar input. */
18
+ export type BrowserNavigateResult = {
19
+ kind: 'ok';
20
+ url: string;
21
+ } | {
22
+ kind: 'blocked';
23
+ reason: BrowserBlockReason;
24
+ } | {
25
+ kind: 'invalid';
26
+ };
27
+ /** One browser.probe wire result (host fetch of the target's headers). */
28
+ export interface BrowserProbeResult {
29
+ reachable: boolean;
30
+ /** The final (post-redirect) URL; present when reachable. */
31
+ url?: string;
32
+ status?: number;
33
+ xFrameOptions?: string;
34
+ /** The CSP frame-ancestors source list; present when the directive exists. */
35
+ frameAncestors?: string[];
36
+ }
37
+ /** Embeddability verdict of one probe. */
38
+ export type Embeddability = 'embeddable' | 'blocked' | 'unknown';
39
+ /**
40
+ * Decide whether a site can render inside the sidebar iframe. The signals
41
+ * are exactly the ones the BROWSER enforces when it refuses an iframe load:
42
+ * X-Frame-Options DENY/SAMEORIGIN, or a frame-ancestors directive that does
43
+ * not allow `*` ('self' here means the SITE's own origin — never ours, so
44
+ * it also blocks the sidebar). A site we could not reach yields 'unknown'
45
+ * and the plain iframe stays.
46
+ */
47
+ export declare function embeddabilityOf(probe: BrowserProbeResult): Embeddability;
48
+ /** A loopback hostname (localhost, IPv6 ::1, 127.0.0.0/8, 0.0.0.0). */
49
+ export declare function isLoopbackHostname(hostname: string): boolean;
50
+ export declare function normalizeBrowserUrl(input: string, selfOrigin: string): BrowserNavigateResult;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Built-in registration: the plugin registers its own tab pages and file
3
+ * previewers through the same {@link BetterSidebarService} external plugins
4
+ * use — eating its own dogfood. The descriptors live next to their feature
5
+ * modules (tabs.tsx / viewers.tsx); this module only aggregates them and
6
+ * owns the disposer lifecycle (cordis auto-invokes it on fiber disposal,
7
+ * HMR-safe).
8
+ */
9
+ import type { Context } from '../../context-types.ts';
10
+ import type { BetterSidebarService } from '../service.ts';
11
+ import { type BuiltinTabOptions } from './tabs.tsx';
12
+ /**
13
+ * Register all built-in tabs and viewers with the service. Returns a
14
+ * disposer that unregisters everything (cordis auto-invokes it on fiber
15
+ * disposal). The `ctx` is threaded into tab descriptors that need it
16
+ * (EditorHost reads `ctx.betterSidebar` for file-viewer matching).
17
+ */
18
+ export declare function registerBuiltins(ctx: Context, service: BetterSidebarService, options?: BuiltinTabOptions): () => void;
@@ -0,0 +1,11 @@
1
+ import type { Context } from '../../context-types.ts';
2
+ import type { TabDescriptor } from '../service.ts';
3
+ /** How many UI-owned terminals may be open at once (agent-owned ones are uncapped). */
4
+ export declare const TERMINAL_LIMIT = 3;
5
+ /** Optional per-registration builtin behavior (currently terminal title). */
6
+ export interface BuiltinTabOptions {
7
+ /** Returns the display title for newly opened terminal tabs. */
8
+ terminalTitle?: () => string;
9
+ }
10
+ /** The 6 built-in tab descriptors. */
11
+ export declare function builtinTabs(ctx: Context, options?: BuiltinTabOptions): readonly TabDescriptor[];
@@ -0,0 +1,3 @@
1
+ import type { FileViewerDescriptor } from '../service.ts';
2
+ /** The 6 built-in file viewer descriptors. */
3
+ export declare function builtinViewers(): readonly FileViewerDescriptor[];
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Lazy chunk loader for the client bundle. The heavy preview/terminal
3
+ * libraries (CodeMirror, xterm — the editor/terminal stacks, several MB)
4
+ * live in separate build-time bundles (`lib/client-<name>.js`) fetched only
5
+ * on first use of the feature that needs them, so startup downloads/parses
6
+ * only the ~1MB core bundle. (The office stack — Univer / docx-preview /
7
+ * pptx-renderer — is no longer bundled here: Office previews moved to the
8
+ * recommended office plugin, see plugins-viewers.ts.)
9
+ *
10
+ * How a chunk script works (see tsdown.config.ts chunkBundle):
11
+ *
12
+ * globalThis.__dshChunks__ = globalThis.__dshChunks__ || {};
13
+ * globalThis.__dshChunks__["terminal"] = (require) => { ...exports };
14
+ *
15
+ * The script registers its factory on a plugin-owned global registry (NOT
16
+ * through window.__ModuleLoader__.load — the module loader's import() only
17
+ * resolves seed words, shell-own modules, registered factories, and boot
18
+ * graph rows; a chunk id is none of those, so resolution would be version-
19
+ * dependent). Materialization is plugin-owned:
20
+ *
21
+ * 1. inject <script src="/sidebar/bundle/<name>.js"> (classic same-origin
22
+ * script; the official /plugins/<id>/client.js route cannot serve
23
+ * arbitrary file names, so the plugin's own host route serves the chunks),
24
+ * 2. read the factory from the global registry,
25
+ * 3. call it with a require that resolves the platform externals through
26
+ * `__DSH_MODULES__.import(spec)` — the seed-word branch, the one part of
27
+ * the module system that is stable across versions.
28
+ *
29
+ * Caching contract (three layers, each with a failure path):
30
+ * - In-memory: one in-flight promise per chunk, memoized until
31
+ * {@link resetChunks}; a failed load removes its entry so the next call
32
+ * retries from scratch. HMR re-activation keeps the resolved exports of
33
+ * unchanged chunks (ETag revalidation via
34
+ * {@link revalidateChunksOnReactivate}) — the next lazy open skips the
35
+ * re-inject / re-execute.
36
+ * - Script execution: each re-execution overwrites the global registry slot
37
+ * (assignment, never registration) — no "duplicate factory registration"
38
+ * class of errors; a failed materialization clears the cache so the retry
39
+ * re-injects and re-executes.
40
+ * - HTTP: the bundle route revalidates every request (`cache-control:
41
+ * no-cache` + ETag, 304 when unchanged), so page refreshes and HMR
42
+ * re-activations never re-download a multi-MB chunk that did not change.
43
+ *
44
+ * HMR: each plugin activation calls {@link revalidateChunksOnReactivate},
45
+ * which HEADs every loaded chunk against the bundle route and keeps the
46
+ * in-memory cache for the ones whose ETag is unchanged (a hot-reloaded core
47
+ * bundle therefore does not re-execute multi-MB chunk scripts). Chunk-only
48
+ * source edits still need a manual page refresh (the HMR poll watches only
49
+ * client.js); an edit that does land while a core HMR happens is caught by
50
+ * the ETag comparison on the next activation.
51
+ */
52
+ export type ChunkName = 'terminal' | 'editor' | 'mermaid';
53
+ /** The module exports a chunk factory provides (namespace-ish record). */
54
+ export type ChunkExports = Record<string, unknown>;
55
+ /**
56
+ * The platform externals a chunk bundle may require (mirror of
57
+ * CLIENT_EXTERNALS in tsdown.config.ts — the chunk builds keep these
58
+ * external and the loader resolves them here). A superset is safe: the
59
+ * require only answers what the chunk actually asks for. The shell's static
60
+ * module table seeds React, Cordis, and the UI libraries (primitives/slots);
61
+ * `dsh-client-runtime/client` normalizes onto the runtime package row
62
+ * (stripClientSuffix). dsh-client-web-react / dsh-client-schema-form were
63
+ * dropped in DSH 0.1.0-rc.8 (no rc.8 publish, nothing requires them) — the
64
+ * chunks never asked for them, so they no longer belong here.
65
+ */
66
+ export declare const CHUNK_EXTERNALS: readonly string[];
67
+ /**
68
+ * The client module system surface this loader needs to resolve externals.
69
+ * DSH 0.1.0-rc.8 provides it as the `ctx.modules` service (no page global
70
+ * anymore); the plugin injects it at activation via
71
+ * {@link setChunkModuleSystem}. The rc.7-era `window.__DSH_MODULES__` global
72
+ * remains as a fallback so older hosts and the test harness keep working.
73
+ */
74
+ export interface ChunkModuleSystem {
75
+ import(specifier: string): Promise<unknown>;
76
+ }
77
+ /**
78
+ * Inject the client module system the chunk externals resolve through.
79
+ * Called by the client half's apply() with `ctx.modules` (rc.8+); pass
80
+ * undefined to clear (tests). Survives {@link resetChunks} — the module
81
+ * system is shell state, not chunk state, and stays live across HMR.
82
+ */
83
+ export declare function setChunkModuleSystem(system: ChunkModuleSystem | undefined): void;
84
+ /** Script-load hook; tests replace it with a stub (the default needs a real DOM + network). */
85
+ export type ChunkScriptLoader = (src: string) => Promise<void>;
86
+ /** Test hook: replace the chunk-script loader (pass null to restore the default). */
87
+ export declare function setChunkScriptLoaderForTests(loader: ChunkScriptLoader | null): void;
88
+ export declare function registerChunkForTests(name: ChunkName, loader: () => Promise<ChunkExports>): void;
89
+ /**
90
+ * Load (once) and materialize a lazy chunk, returning its module exports.
91
+ * Concurrent callers share one in-flight load; a failure clears the cache
92
+ * entry so the next call retries (the script re-executes and overwrites its
93
+ * global registry slot — assignments are idempotent).
94
+ * @param name - the chunk to load.
95
+ */
96
+ export declare function loadChunk(name: ChunkName): Promise<ChunkExports>;
97
+ /**
98
+ * Drop all chunk state for a fresh plugin activation (HMR-safe): clear the
99
+ * in-memory cache and any test-registry entries, so the next lazy open
100
+ * re-fetches and re-executes the current chunk scripts (the registry slots
101
+ * are overwritten by the re-execution — no cleanup needed). A pending
102
+ * revalidation barrier is cleared too: it was only guarding the cache reads
103
+ * of the state being dropped, so the next load must not wait on it (the
104
+ * orphaned task still settles and its identity-guarded `finally` no-ops).
105
+ */
106
+ export declare function resetChunks(): void;
107
+ /**
108
+ * HMR-safe re-activation hook (index.tsx calls this instead of a full
109
+ * reset): keep the resolved exports of every loaded chunk and drop only the
110
+ * ones whose script changed on disk — the bundle route revalidates every
111
+ * request (cache-control: no-cache + ETag), so an unchanged chunk keeps its
112
+ * memory cache and the next lazy open skips the re-inject / re-execute.
113
+ * Fail-open: an unreachable, ETag-less, or timed-out chunk is dropped
114
+ * (re-fetch on next open). Test-registry entries are always cleared
115
+ * (per-test fixtures).
116
+ * A page refresh remains the authoritative reset (the HMR poll watches only
117
+ * client.js; chunk-only edits surface here on the next core re-activation).
118
+ *
119
+ * The returned promise is also a BARRIER for {@link loadChunk}: while a
120
+ * revalidation is pending, every chunk load awaits it before serving cache,
121
+ * so a lazy tab opening mid-revalidation can never render stale exports
122
+ * that the sweep is about to invalidate (CR #232 P1).
123
+ */
124
+ export declare function revalidateChunksOnReactivate(): Promise<void>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Lazy chunk entry: the code/markdown/html text editor (CodeMirror 6 + the
3
+ * language packages). Built as `lib/client-editor.js` and registered under
4
+ * `dsh-better-sidebar/editor` — fetched only when a text file is first
5
+ * opened (see chunk-loader.ts and docs/plans/2026-08-12-lazy-chunks-design.md).
6
+ * Never import this module from the core bundle: it pulls CodeMirror into
7
+ * the startup path.
8
+ */
9
+ export { TextEditor } from '../TextEditor.tsx';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Lazy chunk entry: the mermaid diagram renderer for the markdown preview
3
+ * (mermaid + its d3/dagre/cytoscape graph deps). Built as
4
+ * lib/client-mermaid.js and registered under the `mermaid` global chunk
5
+ * slot — fetched only when a previewed markdown file contains a mermaid
6
+ * fence (see chunk-loader.ts and the mermaid markdown preview design doc).
7
+ * Never import this module from the core bundle: it pulls mermaid into the
8
+ * startup path.
9
+ */
10
+ export { MermaidMarkdown } from '../mermaid.tsx';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Lazy chunk entry: the interactive terminal (xterm + fit addon). Built as
3
+ * `lib/client-terminal.js` and registered under
4
+ * `dsh-better-sidebar/terminal` — fetched only when a terminal tab is first
5
+ * opened (see chunk-loader.ts and docs/plans/2026-08-12-lazy-chunks-design.md).
6
+ * Never import this module from the core bundle: it pulls xterm (and its
7
+ * stylesheet) into the startup path.
8
+ */
9
+ export { TerminalView } from '../TerminalView.tsx';