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