dsh-coding-sidebar 1.0.0

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 (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +524 -0
  3. package/cordis.patch.yml +49 -0
  4. package/lib/client-editor.js +48229 -0
  5. package/lib/client-mermaid.js +200745 -0
  6. package/lib/client-registry.js +21867 -0
  7. package/lib/client-terminal.js +9361 -0
  8. package/lib/client.js +21867 -0
  9. package/lib/index.js +4556 -0
  10. package/lib/invariant.js +22 -0
  11. package/lib/types/agent-opens.d.ts +65 -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 +39 -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 +13 -0
  19. package/lib/types/client/FileTree.d.ts +38 -0
  20. package/lib/types/client/FreeWindow.d.ts +29 -0
  21. package/lib/types/client/GitView.d.ts +10 -0
  22. package/lib/types/client/MarkdownHtml.d.ts +32 -0
  23. package/lib/types/client/OrphanedTab.d.ts +11 -0
  24. package/lib/types/client/PdfView.d.ts +6 -0
  25. package/lib/types/client/RenderBoundary.d.ts +32 -0
  26. package/lib/types/client/SandboxStatusBar.d.ts +10 -0
  27. package/lib/types/client/SideCardSection.d.ts +74 -0
  28. package/lib/types/client/SideChatView.d.ts +16 -0
  29. package/lib/types/client/Sidebar.d.ts +6 -0
  30. package/lib/types/client/SubagentView.d.ts +16 -0
  31. package/lib/types/client/TabBar.d.ts +54 -0
  32. package/lib/types/client/TerminalView.d.ts +24 -0
  33. package/lib/types/client/TextEditor.d.ts +10 -0
  34. package/lib/types/client/TreePanel.d.ts +24 -0
  35. package/lib/types/client/UploadOverlay.d.ts +20 -0
  36. package/lib/types/client/add-plugin-modal.d.ts +15 -0
  37. package/lib/types/client/api.d.ts +275 -0
  38. package/lib/types/client/binary-download.d.ts +12 -0
  39. package/lib/types/client/breakpoints.d.ts +17 -0
  40. package/lib/types/client/browser.d.ts +60 -0
  41. package/lib/types/client/builtins/index.d.ts +18 -0
  42. package/lib/types/client/builtins/tabs.d.ts +11 -0
  43. package/lib/types/client/builtins/viewers.d.ts +3 -0
  44. package/lib/types/client/chunk-loader.d.ts +131 -0
  45. package/lib/types/client/chunks/editor.d.ts +9 -0
  46. package/lib/types/client/chunks/mermaid.d.ts +10 -0
  47. package/lib/types/client/chunks/terminal.d.ts +9 -0
  48. package/lib/types/client/cm-themes.d.ts +24 -0
  49. package/lib/types/client/conversation-draft.d.ts +14 -0
  50. package/lib/types/client/desktop-env.d.ts +35 -0
  51. package/lib/types/client/editor-load.d.ts +66 -0
  52. package/lib/types/client/frame-batcher.d.ts +24 -0
  53. package/lib/types/client/icons.d.ts +59 -0
  54. package/lib/types/client/image-types.d.ts +3 -0
  55. package/lib/types/client/ime-guard.d.ts +36 -0
  56. package/lib/types/client/index.d.ts +25 -0
  57. package/lib/types/client/intercept.d.ts +46 -0
  58. package/lib/types/client/lang.d.ts +14 -0
  59. package/lib/types/client/layout-push.d.ts +15 -0
  60. package/lib/types/client/lazy-chunk.d.ts +25 -0
  61. package/lib/types/client/link-intercept.d.ts +42 -0
  62. package/lib/types/client/locales-ar.d.ts +18 -0
  63. package/lib/types/client/locales-de.d.ts +4 -0
  64. package/lib/types/client/locales-fr.d.ts +10 -0
  65. package/lib/types/client/locales-hi.d.ts +17 -0
  66. package/lib/types/client/locales-id.d.ts +15 -0
  67. package/lib/types/client/locales-it.d.ts +8 -0
  68. package/lib/types/client/locales-ja.d.ts +17 -0
  69. package/lib/types/client/locales-ko.d.ts +9 -0
  70. package/lib/types/client/locales-nl.d.ts +16 -0
  71. package/lib/types/client/locales-pl.d.ts +19 -0
  72. package/lib/types/client/locales-pt.d.ts +1 -0
  73. package/lib/types/client/locales-ru.d.ts +13 -0
  74. package/lib/types/client/locales-sv.d.ts +1 -0
  75. package/lib/types/client/locales-th.d.ts +17 -0
  76. package/lib/types/client/locales-tr.d.ts +17 -0
  77. package/lib/types/client/locales-vi.d.ts +17 -0
  78. package/lib/types/client/locales-zh-HK.d.ts +32 -0
  79. package/lib/types/client/locales-zh-MO.d.ts +32 -0
  80. package/lib/types/client/locales-zh-TW.d.ts +32 -0
  81. package/lib/types/client/locales.d.ts +452 -0
  82. package/lib/types/client/markdown-html.d.ts +96 -0
  83. package/lib/types/client/markdown-images.d.ts +45 -0
  84. package/lib/types/client/markdown-labels.d.ts +38 -0
  85. package/lib/types/client/md-toc.d.ts +4 -0
  86. package/lib/types/client/mermaid-blocks.d.ts +47 -0
  87. package/lib/types/client/mermaid-sanitize.d.ts +2 -0
  88. package/lib/types/client/mermaid.d.ts +12 -0
  89. package/lib/types/client/open-when-sized.d.ts +20 -0
  90. package/lib/types/client/open-with-settings.d.ts +4 -0
  91. package/lib/types/client/open-with.d.ts +87 -0
  92. package/lib/types/client/openpath-intercept.d.ts +85 -0
  93. package/lib/types/client/paths.d.ts +43 -0
  94. package/lib/types/client/pdf-types.d.ts +2 -0
  95. package/lib/types/client/pinned.d.ts +86 -0
  96. package/lib/types/client/plugin-settings.d.ts +8 -0
  97. package/lib/types/client/plugins-shared.d.ts +27 -0
  98. package/lib/types/client/plugins-tabs.d.ts +3 -0
  99. package/lib/types/client/plugins-viewers.d.ts +3 -0
  100. package/lib/types/client/prefs.d.ts +41 -0
  101. package/lib/types/client/produced-files.d.ts +29 -0
  102. package/lib/types/client/selection-payload.d.ts +27 -0
  103. package/lib/types/client/service.d.ts +439 -0
  104. package/lib/types/client/settings-nav-icon.d.ts +19 -0
  105. package/lib/types/client/shell-presets.d.ts +48 -0
  106. package/lib/types/client/sidechat-transcript.d.ts +103 -0
  107. package/lib/types/client/split-pane.d.ts +36 -0
  108. package/lib/types/client/state.d.ts +432 -0
  109. package/lib/types/client/subagent-detect.d.ts +54 -0
  110. package/lib/types/client/subagent-jobs.d.ts +63 -0
  111. package/lib/types/client/tab-content-memo.d.ts +40 -0
  112. package/lib/types/client/terminal-font.d.ts +78 -0
  113. package/lib/types/client/terminal-links.d.ts +119 -0
  114. package/lib/types/client/theme.d.ts +45 -0
  115. package/lib/types/client/titlebar-strip.d.ts +23 -0
  116. package/lib/types/client/upload.d.ts +69 -0
  117. package/lib/types/client/wco.d.ts +47 -0
  118. package/lib/types/config.d.ts +64 -0
  119. package/lib/types/context-types.d.ts +605 -0
  120. package/lib/types/fs-operations.d.ts +28 -0
  121. package/lib/types/fs-search.d.ts +24 -0
  122. package/lib/types/fs-tree.d.ts +51 -0
  123. package/lib/types/git.d.ts +124 -0
  124. package/lib/types/html-route.d.ts +59 -0
  125. package/lib/types/index.d.ts +47 -0
  126. package/lib/types/invariant.d.ts +15 -0
  127. package/lib/types/jobs-routes.d.ts +45 -0
  128. package/lib/types/open-external.d.ts +24 -0
  129. package/lib/types/path-security.d.ts +20 -0
  130. package/lib/types/prefs-shared.d.ts +236 -0
  131. package/lib/types/pty-deps.d.ts +78 -0
  132. package/lib/types/pty-manager.d.ts +168 -0
  133. package/lib/types/sidechat-core.d.ts +172 -0
  134. package/lib/types/sidechat-routes.d.ts +30 -0
  135. package/lib/types/subagent-activity.d.ts +44 -0
  136. package/lib/types/subagent-live-route.d.ts +44 -0
  137. package/lib/types/tools.d.ts +34 -0
  138. package/lib/types/trust-fence.d.ts +24 -0
  139. package/lib/types/wire.d.ts +38 -0
  140. package/package.json +172 -0
  141. package/scripts/install.ps1 +306 -0
  142. package/scripts/install.sh +287 -0
  143. package/src/agent-opens.ts +265 -0
  144. package/src/agent-pty.ts +527 -0
  145. package/src/browser-probe.ts +26 -0
  146. package/src/bundle-route.ts +129 -0
  147. package/src/client/BrowserView.tsx +289 -0
  148. package/src/client/DiffTab.tsx +114 -0
  149. package/src/client/DiffView.tsx +305 -0
  150. package/src/client/EditorHost.tsx +558 -0
  151. package/src/client/FileTree.tsx +669 -0
  152. package/src/client/FreeWindow.tsx +337 -0
  153. package/src/client/GitView.tsx +717 -0
  154. package/src/client/MarkdownHtml.tsx +296 -0
  155. package/src/client/OrphanedTab.tsx +27 -0
  156. package/src/client/PdfView.tsx +110 -0
  157. package/src/client/RenderBoundary.tsx +49 -0
  158. package/src/client/SandboxStatusBar.tsx +60 -0
  159. package/src/client/SideCardSection.module.css +960 -0
  160. package/src/client/SideCardSection.tsx +1163 -0
  161. package/src/client/SideChatView.module.css +437 -0
  162. package/src/client/SideChatView.tsx +645 -0
  163. package/src/client/Sidebar.tsx +1370 -0
  164. package/src/client/SubagentView.module.css +547 -0
  165. package/src/client/SubagentView.tsx +883 -0
  166. package/src/client/TabBar.tsx +365 -0
  167. package/src/client/TerminalView.tsx +424 -0
  168. package/src/client/TextEditor.tsx +468 -0
  169. package/src/client/TreePanel.tsx +275 -0
  170. package/src/client/UploadOverlay.tsx +62 -0
  171. package/src/client/add-plugin-modal.tsx +199 -0
  172. package/src/client/api.ts +357 -0
  173. package/src/client/binary-download.tsx +23 -0
  174. package/src/client/breakpoints.ts +61 -0
  175. package/src/client/browser.ts +167 -0
  176. package/src/client/builtins/index.ts +37 -0
  177. package/src/client/builtins/tabs.tsx +340 -0
  178. package/src/client/builtins/viewers.tsx +125 -0
  179. package/src/client/chunk-loader.ts +358 -0
  180. package/src/client/chunks/editor.tsx +9 -0
  181. package/src/client/chunks/mermaid.tsx +10 -0
  182. package/src/client/chunks/terminal.tsx +9 -0
  183. package/src/client/cm-themes.ts +129 -0
  184. package/src/client/conversation-draft.ts +29 -0
  185. package/src/client/css-modules.d.ts +5 -0
  186. package/src/client/desktop-env.ts +72 -0
  187. package/src/client/editor-load.ts +92 -0
  188. package/src/client/frame-batcher.ts +56 -0
  189. package/src/client/icons.tsx +152 -0
  190. package/src/client/image-types.ts +8 -0
  191. package/src/client/ime-guard.ts +47 -0
  192. package/src/client/index.tsx +427 -0
  193. package/src/client/intercept.tsx +188 -0
  194. package/src/client/lang.ts +225 -0
  195. package/src/client/layout-push.ts +24 -0
  196. package/src/client/layout.css +90 -0
  197. package/src/client/lazy-chunk.tsx +89 -0
  198. package/src/client/link-intercept.ts +73 -0
  199. package/src/client/locales-ar.ts +368 -0
  200. package/src/client/locales-de.ts +353 -0
  201. package/src/client/locales-fr.ts +360 -0
  202. package/src/client/locales-hi.ts +367 -0
  203. package/src/client/locales-id.ts +365 -0
  204. package/src/client/locales-it.ts +358 -0
  205. package/src/client/locales-ja.ts +367 -0
  206. package/src/client/locales-ko.ts +359 -0
  207. package/src/client/locales-nl.ts +365 -0
  208. package/src/client/locales-pl.ts +369 -0
  209. package/src/client/locales-pt.ts +350 -0
  210. package/src/client/locales-ru.ts +365 -0
  211. package/src/client/locales-sv.ts +350 -0
  212. package/src/client/locales-th.ts +367 -0
  213. package/src/client/locales-tr.ts +367 -0
  214. package/src/client/locales-vi.ts +367 -0
  215. package/src/client/locales-zh-HK.ts +382 -0
  216. package/src/client/locales-zh-MO.ts +382 -0
  217. package/src/client/locales-zh-TW.ts +382 -0
  218. package/src/client/locales.ts +894 -0
  219. package/src/client/markdown-html.ts +331 -0
  220. package/src/client/markdown-images.ts +137 -0
  221. package/src/client/markdown-labels.tsx +52 -0
  222. package/src/client/md-toc.tsx +127 -0
  223. package/src/client/mermaid-blocks.ts +110 -0
  224. package/src/client/mermaid-sanitize.ts +93 -0
  225. package/src/client/mermaid.tsx +406 -0
  226. package/src/client/open-when-sized.ts +43 -0
  227. package/src/client/open-with-settings.tsx +135 -0
  228. package/src/client/open-with.ts +221 -0
  229. package/src/client/openpath-intercept.ts +143 -0
  230. package/src/client/paths.ts +63 -0
  231. package/src/client/pdf-types.ts +4 -0
  232. package/src/client/pinned.ts +183 -0
  233. package/src/client/plugin-settings.ts +43 -0
  234. package/src/client/plugins-shared.ts +29 -0
  235. package/src/client/plugins-tabs.ts +96 -0
  236. package/src/client/plugins-viewers.ts +30 -0
  237. package/src/client/prefs.ts +210 -0
  238. package/src/client/produced-files.ts +120 -0
  239. package/src/client/selection-payload.ts +86 -0
  240. package/src/client/service.ts +859 -0
  241. package/src/client/settings-nav-icon.ts +45 -0
  242. package/src/client/shell-presets.ts +83 -0
  243. package/src/client/sidebar.module.css +2788 -0
  244. package/src/client/sidechat-transcript.ts +321 -0
  245. package/src/client/split-pane.tsx +331 -0
  246. package/src/client/state.ts +1497 -0
  247. package/src/client/subagent-detect.ts +137 -0
  248. package/src/client/subagent-jobs.ts +161 -0
  249. package/src/client/tab-content-memo.ts +55 -0
  250. package/src/client/terminal-font.ts +224 -0
  251. package/src/client/terminal-links.ts +194 -0
  252. package/src/client/theme.ts +110 -0
  253. package/src/client/titlebar-strip.ts +37 -0
  254. package/src/client/upload.ts +187 -0
  255. package/src/client/wco.ts +120 -0
  256. package/src/config.ts +154 -0
  257. package/src/context-types.ts +611 -0
  258. package/src/fs-operations.ts +95 -0
  259. package/src/fs-search.ts +113 -0
  260. package/src/fs-tree.ts +158 -0
  261. package/src/git.ts +446 -0
  262. package/src/html-route.ts +106 -0
  263. package/src/index.ts +1291 -0
  264. package/src/invariant.ts +32 -0
  265. package/src/jobs-routes.ts +257 -0
  266. package/src/open-external.ts +90 -0
  267. package/src/path-security.ts +75 -0
  268. package/src/prefs-shared.ts +280 -0
  269. package/src/pty-deps.ts +240 -0
  270. package/src/pty-manager.ts +376 -0
  271. package/src/sidechat-core.ts +468 -0
  272. package/src/sidechat-routes.ts +344 -0
  273. package/src/subagent-activity.ts +91 -0
  274. package/src/subagent-live-route.ts +93 -0
  275. package/src/tools.ts +482 -0
  276. package/src/trust-fence.ts +84 -0
  277. package/src/wire.ts +100 -0
@@ -0,0 +1,605 @@
1
+ /**
2
+ * Structural types for the cordis services this plugin consumes, plus the
3
+ * Context face both halves share.
4
+ *
5
+ * The type base is the vendored `@deepseek-ai/cordis` Context (the runtime
6
+ * DSH actually runs); the service members this plugin touches are restated
7
+ * below as structural mirrors and combined with the base by INTERSECTION.
8
+ * Intersection (not `declare module` augmentation) is deliberate: DSH's own
9
+ * packages already augment `@deepseek-ai/cordis`, and the host and client
10
+ * packages declare *different* types for the same member — host
11
+ * `sessions: SessionStore` vs client runtime `sessions: ISessions` — so a
12
+ * single program that re-declares them would fail interface merging
13
+ * (TS2717). Intersecting keeps every face available and lets each call site
14
+ * resolve against the member it needs without any module-level conflict.
15
+ *
16
+ * `effect`, `get`, `provide`, `inject`, `logger`, `emit`, `isolate` and the
17
+ * event helpers come from the vendored cordis base and are intentionally NOT
18
+ * restated here: their strict shapes are the runtime contract (e.g. an
19
+ * effect body must return a disposer). Only the string-keyed session-feed
20
+ * `on` overload is added, because the cordis `on` is keyed to its own
21
+ * typed `Events` map and the harness session feed is a plain string event.
22
+ *
23
+ * This file must stay FREE of Node.js types (`node:http`, `node:stream`,
24
+ * `Buffer`): it is part of the CLIENT-reachable declaration graph (the
25
+ * `Context` in `TabComponentProps` and the `betterSidebar` augmentation),
26
+ * so a Node import here would leak into browser-only consumer builds. The
27
+ * webServer faces below are therefore structural mirrors with plain
28
+ * interfaces (the host casts to real Node types at the few boundaries that
29
+ * need them — e.g. the `ws` upgrade hook in src/index.ts).
30
+ */
31
+ import type { Context as CordisContext } from '@deepseek-ai/cordis';
32
+ import type { BetterSidebarService } from './client/service.ts';
33
+ /** The request face route handlers see (structural subset of node's
34
+ * IncomingMessage: the URL/method/header reads and the async body
35
+ * iteration `readJsonBody` uses). */
36
+ export interface SidebarHttpRequest {
37
+ url?: string;
38
+ method?: string;
39
+ headers: Record<string, string | string[] | undefined>;
40
+ [Symbol.asyncIterator](): AsyncIterator<string | Uint8Array>;
41
+ }
42
+ /** The response face route handlers write to (structural subset of node's
43
+ * ServerResponse: the status/header/body writes the routes use). */
44
+ export interface SidebarHttpResponse {
45
+ statusCode: number;
46
+ writeHead(status: number, headers?: Record<string, string>): void;
47
+ end(body?: string | Uint8Array): void;
48
+ }
49
+ /** The upgrade socket face (structural subset: the destroy the fences use). */
50
+ export interface SidebarUpgradeSocket {
51
+ destroy(): void;
52
+ }
53
+ /** The upgrade head bytes (Buffer at runtime; typed as bytes so no Node
54
+ * global leaks into the declaration graph). */
55
+ export type SidebarUpgradeHead = Uint8Array;
56
+ /** One named webserver route (mirror of the host-webserver WebRoute). */
57
+ export interface SidebarWebRoute {
58
+ kind: 'exact' | 'prefix';
59
+ path: string;
60
+ handler: (req: SidebarHttpRequest, res: SidebarHttpResponse) => void | Promise<void>;
61
+ }
62
+ /** One exact-path HTTP upgrade registration (mirror of WebUpgradeRoute). */
63
+ export interface SidebarWebUpgradeRoute {
64
+ path: string;
65
+ handler: (req: SidebarHttpRequest, socket: SidebarUpgradeSocket, head: SidebarUpgradeHead) => void | Promise<void>;
66
+ }
67
+ /** The webServer service face this plugin uses. */
68
+ export interface SidebarWebServer {
69
+ register(route: SidebarWebRoute): () => void;
70
+ registerUpgrade(route: SidebarWebUpgradeRoute): () => void;
71
+ }
72
+ /** A published session's header slice the sidebar reads (authoritative cwd). */
73
+ export interface SidebarSessionHeader {
74
+ cwd?: string;
75
+ }
76
+ /** The host session store face (`ctx.sessions.get(id)` returns the live session). */
77
+ export interface SidebarSessionStore {
78
+ get(id: string): {
79
+ header: SidebarSessionHeader;
80
+ /**
81
+ * The live session's append-only event log (immutable snapshot; absent
82
+ * on sessions the runtime has not hydrated). Read-only access — the
83
+ * jobs.output route replays `job_output` tool/result rows from it.
84
+ */
85
+ events?: readonly SidebarSessionEvent[];
86
+ } | undefined;
87
+ }
88
+ /**
89
+ * The web runtime service face (mirror of @deepseek-ai/dsh-web-app's
90
+ * WebRuntimeValues): the bind-derived trust list the /api gateway's fence
91
+ * accepts — LAN IP literals sampled when the server binds all interfaces,
92
+ * plus explicit `--trusted-host` authorities.
93
+ */
94
+ export interface SidebarWebRuntime {
95
+ trustedHosts: readonly string[];
96
+ }
97
+ /** Registration options the sidebar passes to `ctx.slots.register` (subset of the real options). */
98
+ export interface SidebarSlotRegisterOptions {
99
+ name: string;
100
+ key?: string;
101
+ id?: string;
102
+ order?: number;
103
+ label?: string | (() => string);
104
+ /** Chain routing selector (returns the matched value, or null to pass on). */
105
+ select?: (owner: unknown) => unknown;
106
+ priority?: number;
107
+ locale?: string;
108
+ registrant?: string;
109
+ /** Business-face factory; args depend on the slot scope. */
110
+ inject?: (...args: any[]) => Record<string, unknown>;
111
+ children?: Record<string, unknown>;
112
+ }
113
+ /** The client slots service face (register returns the disposer). */
114
+ export interface SidebarSlotsService {
115
+ register(options: SidebarSlotRegisterOptions, component: unknown): () => void;
116
+ /**
117
+ * Run a callback for each declaration lifetime of a slot (the runtime
118
+ * SlotRegistry.inject): a no-op while the slot is undeclared, so the
119
+ * settings section registration waits for the settings shell.
120
+ */
121
+ inject(key: string, callback: () => () => void): () => void;
122
+ }
123
+ /** The client session list row the sidebar reads (cwd for the explorer). */
124
+ export interface SidebarSessionSummary {
125
+ id: string;
126
+ cwd?: string;
127
+ displayTitle: string;
128
+ /** Coarse durable origin for navigation filtering (subagent children). */
129
+ origin?: 'subagent';
130
+ /** Durable direct parent session id (present on subagent children). */
131
+ parentId?: string;
132
+ /** Whether the session's agent is currently running. */
133
+ running?: boolean;
134
+ }
135
+ /** One healthy subagent catalog child row (structural mirror of the runtime). */
136
+ export interface SidebarSubagentChildEntry {
137
+ kind: 'child';
138
+ id: string;
139
+ /** Whether the child Agent driver is running at the Host sampling boundary. */
140
+ activity: 'running' | 'inactive';
141
+ /** Whether a direct descendant has durable `origin: 'subagent'`. */
142
+ hasChildren: boolean;
143
+ mode: 'one-shot' | 'continuable';
144
+ label?: string;
145
+ }
146
+ /** One unreadable catalog row (corrupt / unsupported / unavailable). */
147
+ export interface SidebarSubagentDiagnosticEntry {
148
+ kind: 'diagnostic';
149
+ id: string;
150
+ reason: 'corrupt' | 'unsupported' | 'unavailable';
151
+ }
152
+ /** The per-parent lazy catalog delivered through the sessions list feed. */
153
+ export interface SidebarSubagentCatalog {
154
+ entries: Array<SidebarSubagentChildEntry | SidebarSubagentDiagnosticEntry>;
155
+ parentAvailable: boolean;
156
+ state: 'loading' | 'ready' | 'error';
157
+ error: {
158
+ code?: string;
159
+ message?: string;
160
+ } | null;
161
+ }
162
+ /** Durable parent/child address that selects subagent transport in the client. */
163
+ export interface SidebarSubagentAddress {
164
+ parentSessionId: string;
165
+ childSessionId: string;
166
+ mode: 'one-shot' | 'continuable';
167
+ }
168
+ /** Minimal structural mirror of one session event (the subagent history tail). */
169
+ export interface SidebarSessionEvent {
170
+ type: string;
171
+ seq: number;
172
+ time: number;
173
+ data: Record<string, unknown>;
174
+ }
175
+ /** One history row: the durable event plus an optional tool presentation view. */
176
+ export interface SidebarHistoryEntry {
177
+ event: SidebarSessionEvent;
178
+ view?: unknown;
179
+ }
180
+ /** Lifecycle status set of one background job (closed wire union). */
181
+ export type SidebarJobStatus = 'running' | 'stopping' | 'completed' | 'killed' | 'failed';
182
+ /**
183
+ * One background job as the client mirror sees it (wire `JobView` shape:
184
+ * id/kind/label/status/detail?/startedAt/finishedAt?).
185
+ */
186
+ export interface SidebarJobView {
187
+ /** Registry-issued `<kind>-N` identity, stable for the job's whole life. */
188
+ id: string;
189
+ /** Producer kind (`bash`, `pwsh`, `subagent`, …; open string by design). */
190
+ kind: string;
191
+ /** Producer-supplied one-line label: the command, or the delegation description. */
192
+ label: string;
193
+ /** Current lifecycle state. */
194
+ status: SidebarJobStatus;
195
+ /** Kind-specific status detail ('exit code: 3'), present once supplied. */
196
+ detail?: string;
197
+ /** Epoch ms when the job was registered. */
198
+ startedAt: number;
199
+ /** Epoch ms when the job settled; absent while live. */
200
+ finishedAt?: number;
201
+ }
202
+ /** The host jobs registry face the sidebar routes touch (structural mirror of `JobRegistry`). */
203
+ export interface SidebarJobsService {
204
+ /** Request cancellation; throws for an unknown or foreign job. */
205
+ kill(id: string, caller?: SidebarAgent, reason?: string): 'requested' | 'already-finished';
206
+ }
207
+ /** The host agent registry face (structural mirror of the runtime `ctx.agents`). */
208
+ export interface SidebarAgentsService {
209
+ /** The live agent registered under a session id, or undefined when not live. */
210
+ get(id: string): SidebarAgent | undefined;
211
+ /**
212
+ * Create a session + agent with a custom seed (mirror of the runtime
213
+ * AgentRegistry.create) — the Side Chat thread-creation seam: the SAME
214
+ * public seam api-proxy's session.fork and the subagent fork provider use.
215
+ */
216
+ create?(options: unknown): Promise<{
217
+ agent: SidebarAgent;
218
+ dispose(): Promise<void>;
219
+ }>;
220
+ /**
221
+ * Resume an agent on a persisted session (mirror of the runtime
222
+ * AgentRegistry.resume) — the Side Chat cold-continuation seam after a
223
+ * DSH restart or a closed thread.
224
+ */
225
+ resume?(options: unknown): Promise<{
226
+ agent: SidebarAgent;
227
+ dispose(): Promise<void>;
228
+ }>;
229
+ }
230
+ /** The host subagent runtime face (`ctx.subagents`; optional — the live
231
+ * batch route degrades to a 503 when the deployment lacks it). Only the
232
+ * read-only descendant enumeration this plugin needs is mirrored. */
233
+ export interface SidebarSubagentsService {
234
+ /**
235
+ * Enumerate the root's complete session-backed subagent tree in stable
236
+ * pre-order without loading or resuming an Agent (mirror of
237
+ * `SubagentRuntime.listDescendants`).
238
+ */
239
+ listDescendants(rootSessionId: string, signal?: AbortSignal): Promise<SidebarSubagentDescendantEntry[]>;
240
+ }
241
+ /** One descendant row of `ctx.subagents.listDescendants` (structural mirror). */
242
+ export type SidebarSubagentDescendantEntry = {
243
+ kind: 'child';
244
+ id: string;
245
+ activity: 'running' | 'inactive';
246
+ hasChildren: boolean;
247
+ mode: 'one-shot' | 'continuable';
248
+ label?: string;
249
+ parentId: string;
250
+ depth: number;
251
+ } | {
252
+ kind: 'diagnostic';
253
+ id: string;
254
+ reason: 'corrupt' | 'unsupported' | 'unavailable';
255
+ parentId: string;
256
+ depth: number;
257
+ };
258
+ /** The host agent-presets service face (mirror of the runtime agentPresets
259
+ * service): resolves and mounts the preset composition a session recorded,
260
+ * so a resumed or forked session rebuilds the same tool/prompt world its
261
+ * history was produced under. */
262
+ export interface SidebarAgentPresetsService {
263
+ /** Resolve a preset id; undefined resolves the deployment default. */
264
+ resolve(presetId?: string): Promise<{
265
+ id: string;
266
+ }>;
267
+ /** Mount a preset's composition into an agent scope before publication. */
268
+ mount(agentCtx: unknown, presetId: string): Promise<void>;
269
+ }
270
+ /** The host session-title service face (mirror of the sessionTitle service). */
271
+ export interface SidebarSessionTitleService {
272
+ /** Rename one live session's title (pins it against auto-regeneration). */
273
+ rename(session: unknown, title: string): {
274
+ title: string;
275
+ eventSeq: number;
276
+ };
277
+ }
278
+ /** The host session-persistence face (mirror of the sessionPersistence
279
+ * service): detached inspection of a persisted session, used to compose the
280
+ * recorded preset when a Side Chat thread cold-resumes. */
281
+ export interface SidebarSessionPersistenceService {
282
+ inspect(sessionId: string): Promise<{
283
+ meta: {
284
+ cwd?: string;
285
+ agentPreset?: string;
286
+ };
287
+ events: readonly SidebarSessionEvent[];
288
+ }>;
289
+ }
290
+ /** RPC result slot mirror (`RpcResult<T>` on the wire). */
291
+ export type SidebarRpcResult<T> = {
292
+ ok: true;
293
+ value: T;
294
+ } | {
295
+ ok: false;
296
+ error: {
297
+ code: string;
298
+ message: string;
299
+ };
300
+ };
301
+ /** Unary response mirror (`RpcResponse<T>` on the wire). */
302
+ export interface SidebarRpcResponse<T> {
303
+ rpcId: unknown;
304
+ result: SidebarRpcResult<T>;
305
+ }
306
+ /** The generic session-history RPC face the Side Chat transcript polls
307
+ * (subagent.history verifies subagent-catalog membership, which our custom
308
+ * side-thread children do not have — the generic session.history reads any
309
+ * durable log directly). */
310
+ export interface SidebarSessionHistoryRpc {
311
+ history(payload: {
312
+ sessionId: string;
313
+ beforeSeq?: number;
314
+ maxMessages?: number;
315
+ }, signal?: AbortSignal): Promise<SidebarRpcResponse<{
316
+ events: SidebarHistoryEntry[];
317
+ hasMore: boolean;
318
+ }>>;
319
+ }
320
+ /** The wire face the Subagent activity summary needs (subset of `ctx.connection`). */
321
+ export interface SidebarConnectionHandle {
322
+ api: {
323
+ sessions: SidebarSessionHistoryRpc;
324
+ subagents: {
325
+ history(payload: SidebarSubagentAddress & {
326
+ beforeSeq?: number;
327
+ maxMessages?: number;
328
+ }, signal?: AbortSignal): Promise<SidebarRpcResponse<{
329
+ events: SidebarHistoryEntry[];
330
+ hasMore: boolean;
331
+ }>>;
332
+ };
333
+ };
334
+ }
335
+ /** The client session list snapshot the sidebar subscribes to. */
336
+ export interface SidebarSessionList {
337
+ current: string | undefined;
338
+ byId: Record<string, SidebarSessionSummary>;
339
+ /** Direct durable catalogs keyed by their selected parent address. */
340
+ subagentsByParent?: Readonly<Record<string, SidebarSubagentCatalog>>;
341
+ /**
342
+ * Background jobs per session, last-wins from the harness's `session/jobs`
343
+ * push (a missing key is an empty set). Absent on runtime snapshots older
344
+ * than the jobs mirror — the sidebar simply shows no job rows.
345
+ */
346
+ jobsBySession?: Readonly<Record<string, readonly SidebarJobView[]>>;
347
+ }
348
+ /** The client sessions service face (only the list feed is needed). */
349
+ export interface SidebarSessionsService {
350
+ list: {
351
+ getSnapshot(): SidebarSessionList;
352
+ subscribe(fn: () => void): () => void;
353
+ };
354
+ /**
355
+ * Select a listed session as current (mirror of the runtime ISessions.open)
356
+ * — used to jump back to the main agent from the topology root node.
357
+ */
358
+ open?(id: string): void;
359
+ /**
360
+ * Fork a session from a completed-turn prefix of the source and resolve
361
+ * the child session id (mirror of the runtime ISessions.fork — throws on
362
+ * failure). The Side Chat "save as new session" action uses this to
363
+ * promote a hidden side thread into a top-level session.
364
+ */
365
+ fork?(opts: {
366
+ sessionId: string;
367
+ atSeq?: number;
368
+ increaseTitle?: boolean;
369
+ }): Promise<string>;
370
+ /**
371
+ * Resolve the stable session binding of one listed session (mirror of the
372
+ * runtime ISessions.binding); the saved-session rename uses the face's
373
+ * behavior verbs.
374
+ */
375
+ binding?(id: string): {
376
+ session: {
377
+ rename(title: string): Promise<unknown>;
378
+ };
379
+ } | undefined;
380
+ /**
381
+ * Resolve an Agent-scoped context view for one session (mirror of the
382
+ * runtime ISessions.scope) — the ticket `ctx.conversation.input.for`
383
+ * requires to reach that session's composer.
384
+ */
385
+ scope(id: string): Context | undefined;
386
+ /**
387
+ * Open a healthy catalog child through its exact direct-parent address
388
+ * (mirror of the runtime ISessions.openSubagent).
389
+ */
390
+ openSubagent?(address: SidebarSubagentAddress): void;
391
+ /**
392
+ * Resolve an already discovered direct-parent address without opening it.
393
+ */
394
+ subagentAddress?(id: string): SidebarSubagentAddress | undefined;
395
+ /**
396
+ * Mark whether a catalog surface is consuming live membership updates.
397
+ */
398
+ setSubagentCatalogOpen?(parentSessionId: string, open: boolean): void;
399
+ /**
400
+ * Refresh one direct-child catalog.
401
+ */
402
+ refreshSubagents?(parentSessionId: string): Promise<void>;
403
+ }
404
+ /**
405
+ * The client locale service face (mirror of @deepseek-ai/dsh-client-locale's
406
+ * LocaleRuntime — only the slices the sidebar touches). The sidebar follows
407
+ * the DSH i18n system: the active locale is the Host-backed preference
408
+ * (`locale.preference` in settings.yaml) rather than the raw browser
409
+ * language, and the sidebar's zh/en dictionaries register into the service's
410
+ * namespace registry under `betterSidebar`.
411
+ */
412
+ export interface SidebarLocaleService {
413
+ /** Current immutable locale snapshot (uSES-safe; `active` is 'zh' | 'en' today). */
414
+ getSnapshot(): {
415
+ active: string;
416
+ };
417
+ /** Subscribe to snapshot changes (locale switch or dictionary registration). */
418
+ subscribe(fn: () => void): () => void;
419
+ /** Register one locale's dictionary for a namespace; returns the disposer. */
420
+ register(ns: string, locale: string, dict: Record<string, string>): () => void;
421
+ }
422
+ /** The composer draft face the sidebar reaches through `ctx.conversation.input`. */
423
+ export interface SidebarSessionInput {
424
+ /** The live input store (draft read for append). */
425
+ state: {
426
+ getSnapshot(): {
427
+ draft: string;
428
+ };
429
+ };
430
+ /** Replace the draft text (the input machine's single public write path). */
431
+ setDraft(text: string): void;
432
+ }
433
+ /** The composer draft face the sidebar reaches through `ctx.get('conversation')`. */
434
+ export interface SidebarConversation {
435
+ input: {
436
+ for(actx: Context): SidebarSessionInput;
437
+ };
438
+ }
439
+ /**
440
+ * The client workspaces service face (mirror of the runtime IWorkspaces). Only
441
+ * the chat's file-open funnel is touched: `openPath` hands an absolute path
442
+ * to the Host OS's default application, and every chat-side file open
443
+ * (tool rows, produced-files, prose mentions) funnels through it.
444
+ */
445
+ export interface SidebarWorkspacesService {
446
+ /** Open a filesystem path with the Host operating system's default application. */
447
+ openPath(path: string): Promise<void>;
448
+ }
449
+ /**
450
+ * The client Remote carrier face (mirror of @deepseek-ai/dsh-api-gateway's
451
+ * ClientRemote, session namespace only). The 0.1.2-alpha.1 Remote-namespace
452
+ * migration moved the chat's file-open funnel here
453
+ * (`session.openWorkspacePath`, a direct RPC that no longer touches
454
+ * `workspaces.openPath`); probed as an optional property so baselines
455
+ * without the carrier keep routing through the old door.
456
+ */
457
+ export interface SidebarRemoteService {
458
+ session: {
459
+ /** Open a resolved path through the Host's native opener (the RPC twin of openPath). */
460
+ openWorkspacePath(request: {
461
+ path: string;
462
+ }): Promise<unknown>;
463
+ };
464
+ }
465
+ /**
466
+ * The invariant service face (mirror of @deepseek-ai/dsh-invariants'
467
+ * InvariantRegistry). The upstream augmentation does not reach this Context
468
+ * (dual-cordis-instance resolution), so the register signature is restated
469
+ * structurally, exactly like the other service faces above.
470
+ */
471
+ export interface SidebarInvariantsService {
472
+ /** Reserve one package's checks and install them in the service's child fiber. */
473
+ register(packageName: string, installer: (ctx: Context, fail: (message: string) => never) => void | Promise<void>): () => void;
474
+ }
475
+ /** The settings service face (mirror of @deepseek-ai/dsh-settings' SettingsProvider). */
476
+ export interface SidebarSettingsService {
477
+ /**
478
+ * Register one namespace schema (the resolved value layers schema defaults,
479
+ * then the composition base, then the user document).
480
+ */
481
+ register<T>(ns: string, schema: unknown, options?: {
482
+ base?: Partial<T>;
483
+ applies?: 'live' | 'restart';
484
+ }): {
485
+ get(): T;
486
+ watch(callback: (next: T, prev: T) => void | Promise<void>): () => void;
487
+ update(patch: object): Promise<void>;
488
+ replace(section: object): Promise<void>;
489
+ };
490
+ /** Redacted descriptors of every registered namespace (secrets stripped). */
491
+ describe(options?: {
492
+ redactSecrets?: boolean;
493
+ }): Array<{
494
+ ns: string;
495
+ value?: unknown;
496
+ base?: unknown;
497
+ user?: unknown;
498
+ applies: 'live' | 'restart';
499
+ revision: number;
500
+ }>;
501
+ /** Service-level merge write with the revision guard (a stale writer is refused). */
502
+ update(ns: string, patch: object, expectedRevision?: number): Promise<void>;
503
+ }
504
+ /**
505
+ * The tools service face (mirror of @deepseek-ai/dsh-tools' ToolRuntime).
506
+ * The host half registers model-facing tools here; the registry attaches the
507
+ * returned disposer to the contributing fiber so unloading unregisters them.
508
+ */
509
+ export interface SidebarToolsService {
510
+ /** Register one tool definition (raw JSON-Schema or defineTool-sugar form). */
511
+ register(tool: unknown): () => void;
512
+ }
513
+ /**
514
+ * The agent face a tool sees on `exec.agent` (mirror of @deepseek-ai/dsh-agent's
515
+ * Agent). Only the slices the terminal tools touch are restated: the live
516
+ * session identity and its header cwd, both readonly.
517
+ */
518
+ export interface SidebarAgent {
519
+ /** The live session identity shared with the session log. */
520
+ readonly id: string;
521
+ /** The live session this agent drives. */
522
+ readonly session: {
523
+ /** The session's header (validated cwd, lineage metadata). */
524
+ readonly header: {
525
+ readonly cwd?: string;
526
+ };
527
+ };
528
+ }
529
+ /**
530
+ * The shape this plugin actually consumes, intersected with the vendored
531
+ * cordis `Context` below (see the file header for why intersection is used
532
+ * instead of module augmentation).
533
+ */
534
+ export interface SidebarContextShape {
535
+ /** The webServer service face this plugin uses. */
536
+ webServer: SidebarWebServer;
537
+ /** The session store (host `.get`) and the client list feed (`.list`) faces. */
538
+ sessions: SidebarSessionStore & SidebarSessionsService;
539
+ /** The wire handle the Side Chat transcript polls through. */
540
+ connection: SidebarConnectionHandle;
541
+ /** The web runtime trust list (bind-derived). */
542
+ webRuntime: SidebarWebRuntime;
543
+ /** The client slot registry (register/inject). */
544
+ slots: SidebarSlotsService;
545
+ /** The client workspaces service face (file-open funnel). */
546
+ workspaces: SidebarWorkspacesService;
547
+ /** The client Remote carrier (0.1.2+ file-open funnel; optional legacy probe). */
548
+ remote?: SidebarRemoteService;
549
+ /** The settings service face (prefs persistence + namespace reads). */
550
+ settings: SidebarSettingsService;
551
+ /** The invariant registry face. */
552
+ invariants: SidebarInvariantsService;
553
+ /** The tool registry face. */
554
+ tools: SidebarToolsService;
555
+ /** The client locale service face. */
556
+ locale: SidebarLocaleService;
557
+ /** The client module system (rc.8+ chunk-loader externals). */
558
+ modules: {
559
+ import(specifier: string): Promise<unknown>;
560
+ };
561
+ /** The host background-job registry (optional; routes degrade to 503). */
562
+ jobs: SidebarJobsService;
563
+ /** The host live-agent registry (optional; side chat thread agents). */
564
+ agents: SidebarAgentsService;
565
+ /** The host subagent runtime (optional; live topology batch route). */
566
+ subagents: SidebarSubagentsService;
567
+ /** The host agent-presets service (optional; side chat cold resume). */
568
+ agentPresets: SidebarAgentPresetsService;
569
+ /** The host session-title service (optional; side chat thread label pin). */
570
+ sessionTitle: SidebarSessionTitleService;
571
+ /** The host session-persistence service (optional; side chat cold resume). */
572
+ sessionPersistence: SidebarSessionPersistenceService;
573
+ /** The composer draft face (client ui-conversation, lazy `ctx.get` probe). */
574
+ conversation: SidebarConversation;
575
+ /**
576
+ * The client-side sidebar registry: external plugins register tab types
577
+ * and file previewers here. Provided by the client half (see
578
+ * {@link ./client/index.tsx}); undefined on the host side.
579
+ */
580
+ betterSidebar: BetterSidebarService;
581
+ /**
582
+ * String-keyed session feed subscribe (the vendored cordis `on` is keyed
583
+ * to its typed Events map; the harness session feed is a plain string
584
+ * event). The listener receives every appended session event with the
585
+ * LIVE Session instance that appended it.
586
+ */
587
+ on(event: string, listener: (session: unknown, event: SidebarSessionEvent) => void): () => void;
588
+ }
589
+ /**
590
+ * The Context this plugin sees: the vendored cordis Context intersected with
591
+ * the structural service faces above. Re-exported from the package root so a
592
+ * consumer can `import type { Context } from 'dsh-coding-sidebar'`.
593
+ */
594
+ export type Context = CordisContext & SidebarContextShape;
595
+ /**
596
+ * Consumer-facing augmentation (deliberately the only one kept): a plugin
597
+ * that imports `Context` from `@deepseek-ai/cordis` and does
598
+ * `import type {} from 'dsh-coding-sidebar'` sees `ctx.betterSidebar`
599
+ * without importing this package's own Context type.
600
+ */
601
+ declare module '@deepseek-ai/cordis' {
602
+ interface Context {
603
+ betterSidebar: BetterSidebarService;
604
+ }
605
+ }
@@ -0,0 +1,28 @@
1
+ /** Inputs of one upload: the session scope plus the request body stream. */
2
+ export interface WorkspaceUploadInput {
3
+ /** The session workspace root; target and directory must stay inside it. */
4
+ cwd: string;
5
+ /** Absolute upload directory chosen by the client (inside `cwd`). */
6
+ dir: string;
7
+ /** Relative path below `dir` (absolute paths, '.', '..' and empty segments refused). */
8
+ relativePath: string;
9
+ /** The request body stream (raw bytes). */
10
+ chunks: AsyncIterable<string | Uint8Array>;
11
+ /** Byte cap; an oversized upload is refused without touching the target. */
12
+ limit: number;
13
+ }
14
+ /**
15
+ * Stream `chunks` into `dir/relativePath` atomically: a uniquely named temp
16
+ * sibling receives the bytes, then is renamed over the target. The parent
17
+ * directory is created on demand (recursive), so folder uploads work before
18
+ * any level exists. The unique temp name keeps concurrent uploads to the same
19
+ * target independent (each writes and renames its own file; the last rename
20
+ * wins) and never blocks later uploads after a crashed process.
21
+ *
22
+ * @throws SidebarError with a wire code for containment, shape, and size
23
+ * failures; the temp file is always removed on failure.
24
+ */
25
+ export declare function writeWorkspaceUpload(input: WorkspaceUploadInput): Promise<{
26
+ path: string;
27
+ size: number;
28
+ }>;
@@ -0,0 +1,24 @@
1
+ /** One search: the relative paths of the matching entries (dirs included so
2
+ * the client can hint where matches live) plus the truncation flag. */
3
+ export interface FsSearchResult {
4
+ matches: string[];
5
+ truncated: boolean;
6
+ }
7
+ /** Search budgets (both injectable for tests). */
8
+ export interface FsSearchOptions {
9
+ /** Row cap of the result list (default 200). */
10
+ maxMatches?: number;
11
+ /** Total entries visited before the walk gives up (default 100_000). */
12
+ maxVisited?: number;
13
+ }
14
+ /**
15
+ * Search `root` recursively for entries whose name contains `query`
16
+ * (case-insensitive).
17
+ * @param root - absolute search root.
18
+ * @param query - the name substring; empty matches nothing.
19
+ * @param opts - budget overrides (tests).
20
+ * @returns the matching paths RELATIVE to `root` ('/'-separated), sorted,
21
+ * plus whether a budget cut the walk short. An unreadable level is skipped
22
+ * (permission errors never fail the whole search).
23
+ */
24
+ export declare function searchFiles(root: string, query: string, opts?: FsSearchOptions): Promise<FsSearchResult>;