@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,51 @@
1
+ /** One explorer row. */
2
+ export interface SidebarFsEntry {
3
+ name: string;
4
+ path: string;
5
+ isDir: boolean;
6
+ hidden: boolean;
7
+ /** Whether the row is a symlink; `isDir` then describes the link's target. */
8
+ isSymlink: boolean;
9
+ /** For symlinks: the target is missing or unreadable (stat failed). */
10
+ broken: boolean;
11
+ }
12
+ /** One listed level. */
13
+ export interface SidebarFsListing {
14
+ path: string;
15
+ entries: SidebarFsEntry[];
16
+ truncated: boolean;
17
+ }
18
+ /** Directory-first, case-insensitive name ordering (VSCode explorer order). */
19
+ export declare function compareEntries(a: SidebarFsEntry, b: SidebarFsEntry): number;
20
+ /**
21
+ * List one directory level.
22
+ * @param path - absolute directory path.
23
+ * @param maxEntries - row bound of one level (extra rows flag `truncated`).
24
+ * @returns the sorted listing.
25
+ * @throws {SidebarError} fs-error when the level is unreadable or not a directory.
26
+ */
27
+ export declare function listDirectory(path: string, maxEntries?: number): Promise<SidebarFsListing>;
28
+ /** The root row label of a listing: the last path segment (or the full path at the filesystem root). */
29
+ export declare function rootLabel(path: string): string;
30
+ /** Parent of a path, or undefined at the filesystem root (the explorer's "up" target). */
31
+ export declare function parentOf(path: string): string | undefined;
32
+ /**
33
+ * Normalize a caller-supplied path to an absolute, resolved path or throw
34
+ * fs-error. `path.isAbsolute()` is the OS's own notion of absolute: POSIX
35
+ * roots (`/...`), Windows drive letters (`C:\...`) and — on win32 — UNC
36
+ * network shares (`\\server\share\...`); drive-relative forms (`C:foo`)
37
+ * stay rejected.
38
+ */
39
+ export declare function requireAbsolute(path: string): string;
40
+ /**
41
+ * Whether `target` lies under `base` (or equals it), tolerant of separator
42
+ * style and — on Windows, where the filesystem is case-insensitive — of
43
+ * letter case. The media route uses this instead of a raw `startsWith` so a
44
+ * case-mismatched or mixed-separator path can never be misclassified
45
+ * (e.g. `C:\Users\Me` vs `c:/users/me/file.png`).
46
+ * @param platform - filesystem semantics; injectable so both branches are
47
+ * unit-testable on any host.
48
+ */
49
+ export declare function isWithin(base: string, target: string, platform?: NodeJS.Platform): boolean;
50
+ /** Message text of an unknown thrown value. */
51
+ export declare function messageOf(error: unknown): string;
@@ -0,0 +1,82 @@
1
+ /** A parsed `git status --porcelain=v1 -z` entry. */
2
+ export interface GitStatusEntry {
3
+ path: string;
4
+ /** Two-letter index/worktree status (X Y), e.g. 'M ', ' M', 'A ', '??'. */
5
+ xy: string;
6
+ }
7
+ /** The source-control panel snapshot. */
8
+ export interface GitStatusResult {
9
+ isRepo: boolean;
10
+ branch?: string;
11
+ entries: GitStatusEntry[];
12
+ }
13
+ /** One `git log` row. */
14
+ export interface GitLogEntry {
15
+ /** Short hash (7+ chars, display). */
16
+ hash: string;
17
+ /** Full 40-char hash (advanced operations: revert / cherry-pick). */
18
+ hashFull: string;
19
+ subject: string;
20
+ author: string;
21
+ /** ISO 8601 author date (`%ai`), e.g. `2024-01-01 10:00:00 +0800`. */
22
+ date: string;
23
+ /** Ref decorations (`%D` with --decorate=short), e.g. `HEAD -> main, origin/main`; '' when none. */
24
+ refs: string;
25
+ }
26
+ /** One git failure (stderr text as the message). */
27
+ export declare class GitCommandError extends Error {
28
+ readonly code: string;
29
+ readonly command: string;
30
+ constructor(message: string, code: string | undefined, command: string);
31
+ }
32
+ /** Parse porcelain v1 -z output into entries (rename/copy pairs collapse to one row). */
33
+ export declare function parsePorcelainZ(output: string): GitStatusEntry[];
34
+ /** Parse `git log --pretty=format:%h%x1f%s%x1f%an%x1f%ai%x1f%H%x1f%D` rows. */
35
+ export declare function parseLogLines(output: string): GitLogEntry[];
36
+ /** Whether the directory is inside a git work tree (exit-0 `git rev-parse`). */
37
+ export declare function isGitRepo(cwd: string): Promise<boolean>;
38
+ /** The repository top level containing `cwd` (`git rev-parse --show-toplevel`). */
39
+ export declare function repoRoot(cwd: string): Promise<string>;
40
+ /** The current branch name (`git rev-parse --abbrev-ref HEAD`; 'HEAD' when detached). */
41
+ export declare function currentBranch(cwd: string): Promise<string>;
42
+ /**
43
+ * Working-tree status (untracked included). `--untracked-files=all` lists
44
+ * the CONTENTS of new directories as individual entries (`?? newdir/a.ts`
45
+ * rather than a collapsed `?? newdir/`), so every row in the source-control
46
+ * panel is a real file whose diff tab can load. With `=normal`, git folds a
47
+ * new folder into one trailing-slash entry that has no diff output and
48
+ * cannot be read as a file.
49
+ */
50
+ export declare function status(cwd: string): Promise<GitStatusResult>;
51
+ /** Diff text of the worktree (unstaged) or the index (staged). */
52
+ export declare function diff(cwd: string, path: string | undefined, staged: boolean): Promise<string>;
53
+ /** Stage paths (all when path is undefined). */
54
+ export declare function stage(cwd: string, path: string | undefined): Promise<void>;
55
+ /** Unstage paths (all when path is undefined). */
56
+ export declare function unstage(cwd: string, path: string | undefined): Promise<void>;
57
+ /** Commit the staged changes with a message (global identity untouched). */
58
+ export declare function commit(cwd: string, message: string): Promise<void>;
59
+ /** Branch names (current first). */
60
+ export declare function branches(cwd: string): Promise<{
61
+ current: string;
62
+ names: string[];
63
+ }>;
64
+ /** Switch to an existing branch. */
65
+ export declare function checkout(cwd: string, branch: string): Promise<void>;
66
+ /** Recent commit history (newest first), lazily pageable via skip/count. */
67
+ export declare function log(cwd: string, count?: number, skip?: number): Promise<GitLogEntry[]>;
68
+ /**
69
+ * Content of a file at a revision (`git show <rev>:<path>`), or null when the
70
+ * revision has no such path (a new/untracked file has no HEAD side).
71
+ */
72
+ export declare function show(cwd: string, rev: string, path: string): Promise<string | null>;
73
+ /** Full patch text of one commit (`git show` with the commit header suppressed).
74
+ * Merge commits show their diff against the first parent (`-m --first-parent`
75
+ * is a no-op for regular commits), so a history click always has content. */
76
+ export declare function commitDiff(cwd: string, hash: string): Promise<string>;
77
+ /** Discard the worktree changes of one path (`git checkout -- <path>`; the index is untouched). */
78
+ export declare function discard(cwd: string, path: string): Promise<void>;
79
+ /** Revert one commit onto the current branch with an auto-generated message. */
80
+ export declare function revert(cwd: string, hash: string): Promise<void>;
81
+ /** Cherry-pick one commit onto the current branch. */
82
+ export declare function cherryPick(cwd: string, hash: string): Promise<void>;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Pure URL vocabulary of the /sidebar/html route (HTML previewer).
3
+ *
4
+ * Why path-encoded parameters instead of a query string: the previewed
5
+ * page resolves its relative assets (./style.css, img/x.png) against the
6
+ * document URL, and the WHATWG URL algorithm DROPS the query of a
7
+ * path-relative reference — `/sidebar/html?a=1&path=/a/b/` + `./style.css`
8
+ * would lose the session scope and the route would reject the asset.
9
+ * Encoding everything into the URL path keeps relative resolution inside
10
+ * the same route with every request self-contained:
11
+ *
12
+ * /sidebar/html/<sessionId>/<absolute-path segments, encodeURIComponent'd>
13
+ * /sidebar/html/S/Users/me/proj/index.html
14
+ * + ./style.css → /sidebar/html/S/Users/me/proj/style.css
15
+ * Windows: C:\Users\me\a.html → /sidebar/html/S/C%3A/Users/me/a.html
16
+ * UNC (\\server\share\... or //server/share/...):
17
+ * → /sidebar/html/S//server/share/proj/a.html ('//' right after the
18
+ * sessionId marks the UNC prefix; the WHATWG URL keeps '//' intact so
19
+ * relative assets still resolve inside the same route)
20
+ *
21
+ * The decoder rebuilds the marker as a forward-slash `//server/share/...`
22
+ * path. That form is intentionally platform-neutral: `node:path` resolves it
23
+ * to `\\server\share\...` on win32 and `/server/share/...` on POSIX, so the
24
+ * host's existing requireAbsolute + isWithin fence needs no platform signal
25
+ * (a leading `//` is a legal POSIX absolute path, so no data is lost on
26
+ * either platform).
27
+ *
28
+ * This module is intentionally dependency-free (no node imports, no wire
29
+ * helpers) so the client bundle can import `encodeHtmlUrl` without tripping
30
+ * the build-time purity gate; the host converts decode failures into
31
+ * SidebarError responses at the route boundary.
32
+ */
33
+ /** One decoded route reference. */
34
+ export interface HtmlRouteRef {
35
+ sessionId: string;
36
+ /** Absolute file path (leading slash; Windows drives keep their colon). */
37
+ path: string;
38
+ }
39
+ /** Decode outcome: the reference, or a client-error description. */
40
+ export type HtmlDecodeResult = {
41
+ ok: true;
42
+ ref: HtmlRouteRef;
43
+ } | {
44
+ ok: false;
45
+ status: 400 | 404;
46
+ message: string;
47
+ };
48
+ /** The route prefix both encoders/decoders agree on. */
49
+ export declare const HTML_ROUTE_PREFIX = "/sidebar/html/";
50
+ /** Build the route URL for one absolute file path (client + tests). */
51
+ export declare function encodeHtmlUrl(sessionId: string, path: string): string;
52
+ /**
53
+ * Decode a route pathname into the session + absolute file path. Rejects
54
+ * a wrong prefix (404), an empty path, malformed percent encoding, and a
55
+ * missing sessionId or file path (400). The caller still must bound the
56
+ * decoded path with requireAbsolute + isWithin(cwd) — a decoded `..`
57
+ * segment resolves outside the cwd and is refused there.
58
+ */
59
+ export declare function decodeHtmlUrl(pathname: string): HtmlDecodeResult;
@@ -0,0 +1,47 @@
1
+ import type { Context } from './context-types.ts';
2
+ import { Config, type ResolvedSidebarConfig, type SidebarConfig } from './config.ts';
3
+ export { Config };
4
+ export type { SidebarConfig, ResolvedSidebarConfig };
5
+ export type { Context } from './context-types.ts';
6
+ export type { BetterSidebarService, TabDescriptor, TabComponentProps, FileViewerDescriptor, FileViewerProps, FileFetchStrategy, } from './client/service.ts';
7
+ /** Plugin identity for cordis.yml rows. */
8
+ export declare const name = "dsh-better-sidebar";
9
+ /** Services required before mounting: the webserver routes, the session store, the web runtime's trusted hosts, and the tool registry. */
10
+ export declare const inject: string[];
11
+ /** Content type served by /sidebar/file (binary-safe fallback for unknowns). */
12
+ export declare function mediaTypeForPath(path: string): string;
13
+ /**
14
+ * The live face of the side card settings namespace, bound to the settings
15
+ * service when it is mounted. The DSH settings RPC domain only serves
16
+ * allowlisted namespaces (api-proxy exposedNamespaces), so the client reads
17
+ * and writes THIS namespace through the plugin's own fenced /sidebar routes,
18
+ * which call the seam in-process — no configuration-client gate involved.
19
+ */
20
+ export interface SidebarSettingsFace {
21
+ /** The current resolved value + revision (undefined while the settings service is absent). */
22
+ get(): {
23
+ value?: unknown;
24
+ revision?: number;
25
+ };
26
+ /**
27
+ * Whether the dsh-web-ui family's aionui-panel has been selected as the
28
+ * right-panel provider (the `aionui-panel` settings namespace resolves
29
+ * `rightPanel: 'aionui-panel'`). While true the sidebar must not mount —
30
+ * the two right panels are mutually exclusive. False when the namespace is
31
+ * absent (no aionui installed) or the provider is anything else.
32
+ */
33
+ externalDisable(): boolean;
34
+ /** Merge a patch (revision-guarded) and return the fresh resolved view. */
35
+ update(patch: Record<string, unknown>, expectedRevision?: number): Promise<{
36
+ value?: unknown;
37
+ revision?: number;
38
+ }>;
39
+ }
40
+ /**
41
+ * Plugin body: mount the fenced routes and the pty lifecycle.
42
+ * @param ctx - host plugin context (webServer, sessions, webRuntime).
43
+ * @param config - deployment-provided limits; the Loader validates against
44
+ * {@link Config} and fills defaults, direct callers get them from
45
+ * {@link resolveSidebarConfig}.
46
+ */
47
+ export declare function apply(ctx: Context, config?: SidebarConfig): void;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Package-owned invariant companion for `dsh-better-sidebar`.
3
+ * @module dsh-better-sidebar/invariant
4
+ */
5
+ import type { Context } from './context-types.ts';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "dsh-better-sidebar-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Background-job routes of the /sidebar JSON API ('jobs.output' /
3
+ * 'jobs.kill'). The job LIST needs no route: it arrives through the
4
+ * harness's `session/jobs` push mirror (`jobsBySession` in the sessions
5
+ * list feed). The routes:
6
+ *
7
+ * - 'jobs.output' — REPLAYS the output the MODEL has read so far for one
8
+ * job. The source is the owner session's own event log: `tool/call` rows
9
+ * of `job_output` name the job via `arguments.job_id`, and the paired
10
+ * `tool/result` rows carry the finalized content the model received.
11
+ * Because the session store's in-memory log can lag the live append feed
12
+ * after a host restart (the store session stays frozen at its
13
+ * rehydration boundary), the plugin ALSO mirrors job_output events from
14
+ * the live `session/event` feed and merges both sources (deduped by seq).
15
+ * This touches NO DSH source: the model's `job_output` cursor is never
16
+ * consumed, and the pane stays empty until the agent reads the job.
17
+ * - 'jobs.kill' — the registry's stock `kill` (a pristine DSH API),
18
+ * fenced by the owning session via the live agent caller. Absent registry
19
+ * → 503, mirroring the settings routes' optional-service downgrade.
20
+ */
21
+ import type { Context } from './context-types.ts';
22
+ /** The two background-job routes of the sidebar API. */
23
+ export interface SidebarJobsRoutes {
24
+ /** The output the model has read so far for one job (event replay, capped). */
25
+ output(payload: unknown): {
26
+ text: string;
27
+ truncated: boolean;
28
+ read: boolean;
29
+ };
30
+ /** Request cancellation of one job (live jobs flip to stopping). */
31
+ kill(payload: unknown): {
32
+ ok: true;
33
+ outcome: 'requested' | 'already-finished';
34
+ };
35
+ }
36
+ /**
37
+ * Build the jobs routes bound to the plugin context. `output` merges the
38
+ * owner session's own event log with the live job_output mirror; `kill`
39
+ * reads the jobs/agents services lazily and degrades to a 503 when the
40
+ * deployment lacks the registry.
41
+ * @param ctx - host plugin context.
42
+ * @param outputLimit - response cap for one output replay in bytes; longer
43
+ * texts are sliced and flagged `truncated` (mirrors the fs.read cap).
44
+ */
45
+ export declare function buildJobsApi(ctx: Context, outputLimit: number): SidebarJobsRoutes;
@@ -0,0 +1,24 @@
1
+ /** The two external open actions the route accepts. */
2
+ export type OpenExternalAction = 'reveal' | 'url';
3
+ /** One platform opener invocation (argv array — never a shell string). */
4
+ export interface ExternalCommand {
5
+ command: string;
6
+ args: string[];
7
+ }
8
+ /** Reveal/select a path in the OS file manager. On Linux there is no common
9
+ * select protocol — the containing directory is opened instead (KISS). */
10
+ export declare function revealCommand(path: string, platform?: NodeJS.Platform): ExternalCommand;
11
+ /** Hand a custom-scheme URL to the OS protocol handler. */
12
+ export declare function urlCommand(url: string, platform?: NodeJS.Platform): ExternalCommand;
13
+ /** Validate a URL-scheme open target: a parseable custom-scheme URL (never
14
+ * http/https — those would only dump the URL into a browser tab). */
15
+ export declare function validateExternalUrl(raw: string): string;
16
+ /**
17
+ * Launch one external open action and return immediately (detached, no
18
+ * stdio). Spawn failures are reported through the child's 'error' event —
19
+ * by then the route already returned, so the event is swallowed (the OS
20
+ * dialog about a missing handler is the user-visible outcome either way).
21
+ */
22
+ export declare function launchExternal(action: OpenExternalAction, value: string): {
23
+ started: true;
24
+ };
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Shared "Side card" preference vocabulary (types + constants), consumed by
3
+ * BOTH halves: the host registers the schemastery schema over these values
4
+ * (config.ts) and the client reads/writes them through the settings RPC
5
+ * (client/prefs.ts, client/SideCardSection.tsx). Kept free of schemastery so
6
+ * the browser bundle never pulls the schema runtime in.
7
+ */
8
+ /** The user-settings namespace holding the side card preferences. */
9
+ export declare const SIDEBAR_PREFS_NS = "dsh-better-sidebar";
10
+ /** User-facing side card preferences (new-conversation defaults). */
11
+ export interface SidebarPrefs {
12
+ /** Whether a brand-new conversation opens the side card by default. */
13
+ openByDefault: boolean;
14
+ /** Default panel width as a percent of the window width (20–60). */
15
+ defaultWidthPercent: number;
16
+ /**
17
+ * Whether the sidebar auto-activates (opens the panel) and expands the
18
+ * Subagent page when the current conversation spawns a new subagent.
19
+ */
20
+ autoOpenSubagent: boolean;
21
+ /**
22
+ * Whether the sidebar auto-activates (opens the panel) and expands the
23
+ * Jobs page when a NEW background job appears for the current
24
+ * conversation (any new job id, not just the first one).
25
+ */
26
+ autoOpenJobs: boolean;
27
+ /**
28
+ * Whether the model-facing agent terminal tools (terminal_create / list /
29
+ * send / read / wait_for / resize / signal / close) are injected into the
30
+ * model's toolset. Off by default: the feature stays dormant until the
31
+ * user explicitly enables it in the side card settings.
32
+ */
33
+ agentTerminalTools: boolean;
34
+ /**
35
+ * Custom terminal font-family stack (a CSS font-family value, e.g.
36
+ * `'JetBrains Mono', monospace`). Empty string follows the app's theme
37
+ * monospace font (`--ds-font-family-code`). Applied live to every
38
+ * terminal tab; configured under the terminal card's secondary settings.
39
+ */
40
+ terminalFontFamily: string;
41
+ /**
42
+ * Custom terminal font size in px (9–32). Applied live to every terminal
43
+ * tab; configured under the terminal card's secondary settings.
44
+ */
45
+ terminalFontSize: number;
46
+ /**
47
+ * Whether expanding the bottom panel for the FIRST time in a session tries
48
+ * to open a fresh terminal tab there (the terminal quota/type still gates
49
+ * the attempt). On by default; the switch lives under the terminal tab's
50
+ * row in the Side card settings.
51
+ */
52
+ bottomPanelAutoTerminal: boolean;
53
+ /**
54
+ * Whether chat-side file opens (tool-row path links, the produced-files
55
+ * row, prose file mentions — every path that funnels through the client
56
+ * runtime's `ctx.workspaces.openPath`) open in the sidebar editor instead
57
+ * of the Host OS's default application. On by default; the editor tab's
58
+ * own enable switch gates it too (both must be on for the takeover).
59
+ */
60
+ interceptOpenPath: boolean;
61
+ /**
62
+ * Whether the editor tab runs in merged mode: a path input replaces the
63
+ * plain header and a toggleable file-tree panel (with a global name
64
+ * search) docks at the tab's right edge. On by default; also makes brand
65
+ * new sessions seed an empty editor tab (tree panel open) instead of the
66
+ * explorer tab. The switch lives under the editor card's gear in the
67
+ * Side card settings; off restores the pre-merge editor exactly.
68
+ */
69
+ editorExplorer: boolean;
70
+ /**
71
+ * The shell the UI and agent terminals spawn (absolute path or bare
72
+ * executable name). Empty (default) keeps the legacy resolution order:
73
+ * `cordis.patch.yml` `config.shell`, then `$SHELL` / login shell /
74
+ * `powershell.exe` on Windows. Set it from the terminal card's gear in
75
+ * the Side card settings (or the yaml) to pin a specific shell — takes
76
+ * effect for terminals opened afterwards.
77
+ */
78
+ terminalShell: string;
79
+ /**
80
+ * Explicit arguments for `terminalShell`, space-separated (empty keeps
81
+ * the platform defaults; when set, they fully replace them — same
82
+ * contract as the yaml `shellArgs`).
83
+ */
84
+ terminalShellArgs: string;
85
+ /**
86
+ * Title-bar / shell compatibility scheme (the "位置兼容模式" setting):
87
+ * - `auto` (default): CONSERVATIVE — only the standard Window Controls
88
+ * Overlay API (present in frameless Chromium shells that draw the
89
+ * native caption buttons over web content) contributes real geometry;
90
+ * without it nothing is modified, so plain-browser (web) behavior is
91
+ * untouched.
92
+ * - `web`: EXPLICIT "DSH official web" — never adapt, not even WCO
93
+ * geometry (the user declares they run the plain web UI).
94
+ * - `preset`: apply the built-in shell preset named by
95
+ * `titleBarPresetId` (data-driven, opt-in — see shell-presets.ts).
96
+ * - `custom`: apply the free-form `customCss` (and the legacy
97
+ * `titleBarStripPx` strip).
98
+ */
99
+ titleBarScheme: TitleBarScheme;
100
+ /**
101
+ * The built-in shell preset id applied while `titleBarScheme` is
102
+ * `preset` ('' = no preset — nothing extra is applied).
103
+ */
104
+ titleBarPresetId: string;
105
+ /**
106
+ * Free-form CSS injected into the page (last in the cascade, so it can
107
+ * override the plugin's styles; use `!important` to override JS-written
108
+ * inline CSS variables). Applied while `titleBarScheme` is `custom`.
109
+ */
110
+ customCss: string;
111
+ /**
112
+ * LEGACY (kept for read-migration and downgrade mirroring only): position
113
+ * compatibility mode flag. The UI writes `titleBarScheme` instead; a
114
+ * stored `true` without a scheme migrates to the `custom` scheme (with
115
+ * `titleBarStripPx` preserved).
116
+ */
117
+ titleBarCompat: boolean;
118
+ /**
119
+ * LEGACY (kept for read-migration and downgrade mirroring only): the
120
+ * reserved top strip height in px used by the `custom` scheme (0–120,
121
+ * default 40). Drives the `--dsh-title-bar-strip` CSS variable: the
122
+ * toggle cluster drops `strip + 3px` and the right panel's content
123
+ * starts `strip` px below its top edge.
124
+ */
125
+ titleBarStripPx: number;
126
+ /**
127
+ * Whether the HTML previewer drops its sandboxed iframe. Sandbox ON (the
128
+ * default) renders previewed HTML in an opaque-origin iframe that cannot
129
+ * touch the GUI; turning it OFF runs the previewed page with the GUI's
130
+ * own origin — full read/write access to session files and internal
131
+ * APIs. Only for trusted local content; the setting copy warns.
132
+ */
133
+ htmlViewerNoSandbox: boolean;
134
+ /**
135
+ * Whether a newly opened HTML preview starts UNSANDBOXED (the per-surface
136
+ * temporary unlock pre-applied). Off by default: previews open sandboxed
137
+ * and the status row offers the one-tap unlock; when on, previews open
138
+ * in the red unsandboxed state and the status row offers a one-tap
139
+ * restore for the current file.
140
+ */
141
+ htmlViewerDefaultUnsafe: boolean;
142
+ /**
143
+ * Whether the browser tab drops its sandboxed iframe. Sandbox ON (the
144
+ * default) keeps browsed sites in an opaque origin with no GUI access;
145
+ * turning it OFF runs any visited site with the GUI's own origin — it
146
+ * can read session data and act as the logged-in GUI. Only for trusted
147
+ * sites; the setting copy warns.
148
+ */
149
+ browserNoSandbox: boolean;
150
+ /**
151
+ * MASTER switch: whether clicking an EXTERNAL link in the GUI (chat
152
+ * messages, tool rows, prose mentions) is taken over into the sidebar at
153
+ * all. On by default; the per-protocol granularity lives in
154
+ * `browserInterceptHttp` / `browserInterceptHttps` (the protocol flag
155
+ * must also be on), and the target tab's own enable switch gates it too.
156
+ * Ctrl/Cmd+click always bypasses the takeover. Kept as the master so old
157
+ * documents keep their meaning with no migration (an explicit `false`
158
+ * stays "never take over").
159
+ */
160
+ browserInterceptLinks: boolean;
161
+ /**
162
+ * Whether clicking an http EXTERNAL link in the GUI opens the sidebar
163
+ * (the built-in browser tab, or a plugin tab that declares `urlTarget`)
164
+ * instead of a new browser tab. On by default; gated on the
165
+ * `browserInterceptLinks` master and the target tab's own enable switch.
166
+ */
167
+ browserInterceptHttp: boolean;
168
+ /**
169
+ * Whether clicking an https EXTERNAL link in the GUI opens the sidebar
170
+ * instead of a new browser tab. OFF by default — most https sites (e.g.
171
+ * GitHub) refuse iframe embedding, so the system browser is the smoother
172
+ * default; gated on the `browserInterceptLinks` master and the target
173
+ * tab's own enable switch.
174
+ */
175
+ browserInterceptHttps: boolean;
176
+ /**
177
+ * Per-tab enable switches, keyed by tab descriptor id (`'explorer'`,
178
+ * `'my-plugin:db'`). An ABSENT key means enabled — only an explicit
179
+ * `false` disables a tab type (hidden from the + menu, `openTab` refuses,
180
+ * and derived flows like subagent auto-open / agent-terminal tabs stop).
181
+ * Already-open tabs of a disabled type keep rendering (closing one
182
+ * prevents reopening), matching the "existing conversations keep their
183
+ * own layouts" rule.
184
+ */
185
+ tabsEnabled: Record<string, boolean>;
186
+ /**
187
+ * Per-viewer enable switches, keyed by file viewer descriptor id
188
+ * (`'image'`, `'my-plugin:csv'`). An ABSENT key means enabled; a disabled
189
+ * viewer is skipped by `matchFileViewer` so files fall through to the
190
+ * next matching viewer (or the download button when none match).
191
+ */
192
+ viewersEnabled: Record<string, boolean>;
193
+ /**
194
+ * Plugin-owned settings blobs (v0.12.0+), keyed by descriptor id: each
195
+ * registered tab/viewer that declares `settings.pluginToggles` (or writes
196
+ * through `settings.render`'s `updatePluginSetting`) persists its values
197
+ * here — an open map, so third-party keys need no host PrefsSchema field.
198
+ * Values are JSON-serializable (the row controls produce strings /
199
+ * numbers / booleans; custom panels are responsible for their own).
200
+ */
201
+ pluginSettings: Record<string, Record<string, unknown>>;
202
+ }
203
+ /** Range contract of {@link SidebarPrefs.defaultWidthPercent}. */
204
+ export declare const WIDTH_PERCENT_MIN = 20;
205
+ export declare const WIDTH_PERCENT_MAX = 60;
206
+ export declare const WIDTH_PERCENT_DEFAULT = 35;
207
+ /** Range contract of {@link SidebarPrefs.terminalFontSize}. */
208
+ export declare const TERMINAL_FONT_SIZE_MIN = 9;
209
+ export declare const TERMINAL_FONT_SIZE_MAX = 32;
210
+ export declare const TERMINAL_FONT_SIZE_DEFAULT = 13;
211
+ /** Range contract of {@link SidebarPrefs.titleBarStripPx}. */
212
+ export declare const TITLE_BAR_STRIP_MIN = 0;
213
+ export declare const TITLE_BAR_STRIP_MAX = 120;
214
+ export declare const TITLE_BAR_STRIP_DEFAULT = 40;
215
+ /** The title-bar / shell compatibility schemes (see {@link SidebarPrefs.titleBarScheme}). */
216
+ export declare const TITLE_BAR_SCHEMES: readonly ["auto", "web", "preset", "custom"];
217
+ export type TitleBarScheme = typeof TITLE_BAR_SCHEMES[number];
218
+ /** Fallback prefs used whenever the settings document is unreachable or malformed. */
219
+ export declare const SIDEBAR_PREFS_DEFAULTS: SidebarPrefs;
220
+ /** Clamp one width percent into the contract range (shared by schema and client reads). */
221
+ export declare function clampWidthPercent(value: number): number;
222
+ /** Clamp one terminal font size into the contract range (shared by schema and client reads). */
223
+ export declare function clampTerminalFontSize(value: number): number;
224
+ /** Clamp one title-bar strip height into the contract range (shared by schema and client reads). */
225
+ export declare function clampTitleBarStrip(value: number): number;
@@ -0,0 +1,78 @@
1
+ import type * as nodePtyNs from 'node-pty';
2
+ /** The node-pty module surface the registries consume (spawn/kill/resize/…). */
3
+ export type NodePtyModule = typeof nodePtyNs;
4
+ /**
5
+ * The node-pty version range this plugin ships. MUST stay identical to the
6
+ * range DSH core declares (`@deepseek-ai/dsh-subprocess-local`): the same
7
+ * range keeps pnpm resolving both to one physical package.
8
+ */
9
+ export declare const DSH_NODE_PTY_RANGE = "^1.1.0";
10
+ /**
11
+ * The WebSocket close-code-1011 reason the host sends when node-pty is
12
+ * unavailable. The client recognizes this exact marker and fetches the full
13
+ * repair details from `/sidebar/api/terminal.deps` (a WS close reason is
14
+ * capped at 123 bytes, so the command itself cannot ride the close frame).
15
+ */
16
+ export declare const PTY_DEPS_MISSING = "pty-deps-missing";
17
+ /** A require-compatible loader, injectable for tests. */
18
+ export type NodePtyRequire = (id: string) => unknown;
19
+ /**
20
+ * Load node-pty once (synchronously) and cache the outcome. Returns null
21
+ * when the package or its native binding cannot be loaded; the cause stays
22
+ * queryable through {@link nodePtyLoadCause}. Never throws.
23
+ */
24
+ export declare function loadNodePty(requireImpl?: NodePtyRequire): NodePtyModule | null;
25
+ /** The recorded load failure (undefined when the load succeeded or never ran). */
26
+ export declare function nodePtyLoadCause(): unknown;
27
+ /** Forget the cached outcome (tests only — a real reload is otherwise one-shot). */
28
+ export declare function resetNodePtyCache(): void;
29
+ /** Load node-pty or throw the canonical degraded-mode error (class-constructor default). */
30
+ export declare function loadRequiredNodePty(): NodePtyModule;
31
+ /**
32
+ * Detect the DSH profile directory this plugin is installed into: the
33
+ * nearest ancestor of the plugin module that carries both `package.json`
34
+ * and `pnpm-workspace.yaml` (the profile root; the plugin resolves from the
35
+ * profile's node_modules). Falls back to `$DSH_HOME/profiles/web` (the
36
+ * standard web profile), then null.
37
+ */
38
+ export declare function findProfileDir(fromFile?: string): string | null;
39
+ /** The plugin package root (walk-up from the module; works for lib/ and src/ layouts). */
40
+ export declare function findPluginRoot(fromFile?: string): string | null;
41
+ /** Options for {@link buildRepairCommand}. */
42
+ export interface RepairCommandOptions {
43
+ /** The plugin package root (where scripts/install.sh / install.ps1 live). */
44
+ pluginRoot: string | null;
45
+ /** The detected profile directory (null → the standard `web` profile). */
46
+ profileDir: string | null;
47
+ /** Platform override for tests; defaults to the live process. */
48
+ platform?: NodeJS.Platform;
49
+ }
50
+ /**
51
+ * The pasteable repair command for a broken node-pty install: rerun the
52
+ * plugin's own installer in `--repair` mode (idempotent: it re-writes the
53
+ * profile's `allowBuilds: node-pty: true` and re-installs/rebuilds the
54
+ * dependency). Falls back to DSH's plugin command when the scripts are not
55
+ * shipped (exotic layouts).
56
+ */
57
+ export declare function buildRepairCommand(options: RepairCommandOptions): {
58
+ command: string;
59
+ note?: string;
60
+ };
61
+ /** Structured status served by the `/sidebar/api/terminal.deps` endpoint. */
62
+ export type NodePtyDepsStatus = {
63
+ ok: true;
64
+ } | {
65
+ ok: false;
66
+ /** The require-time error message (module missing, native binding broken…). */
67
+ cause: string;
68
+ /** The pasteable repair command (terminal/cmd). */
69
+ command: string;
70
+ /** The detected profile name (null when undetected → the command defaults to web). */
71
+ profile: string | null;
72
+ /** Optional supplementary hint (fallback command only). */
73
+ note?: string;
74
+ };
75
+ /** Current node-pty dependency status (loaded vs degraded + repair info). */
76
+ export declare function depsStatus(options?: {
77
+ fromFile?: string;
78
+ }): NodePtyDepsStatus;