@acryldev/workspace 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +61 -2
- package/cordis.patch.yml +3 -0
- package/lib/agents/argument-text.d.ts +9 -0
- package/lib/agents/catalog.d.ts +32 -0
- package/lib/agents/contract.d.ts +50 -0
- package/lib/agents/definition.d.ts +38 -0
- package/lib/agents/file-store.d.ts +7 -0
- package/lib/agents/known-agents.d.ts +52 -0
- package/lib/agents/launch.d.ts +26 -0
- package/lib/agents/preferences.d.ts +40 -0
- package/lib/agents/route.d.ts +10 -0
- package/lib/agents/settings.d.ts +28 -0
- package/lib/agents/status/agent-status.d.ts +38 -0
- package/lib/agents/status/claude-hooks.d.ts +18 -0
- package/lib/agents/status/route.d.ts +10 -0
- package/lib/capabilities/contract.d.ts +17 -0
- package/lib/capabilities/route.d.ts +8 -0
- package/lib/client.js +91109 -0
- package/lib/client.js.map +1 -0
- package/lib/files/contract.d.ts +74 -0
- package/lib/files/route.d.ts +9 -0
- package/lib/files/service.d.ts +48 -0
- package/lib/folder-picker/contract.d.ts +9 -0
- package/lib/folder-picker/picker.d.ts +23 -0
- package/lib/folder-picker/route.d.ts +5 -0
- package/lib/git/changes.d.ts +29 -0
- package/lib/git/checks.d.ts +8 -0
- package/lib/git/commits.d.ts +14 -0
- package/lib/git/contract.d.ts +136 -0
- package/lib/git/errors.d.ts +9 -0
- package/lib/git/guards.d.ts +9 -0
- package/lib/git/ignored.d.ts +9 -0
- package/lib/git/parsing.d.ts +13 -0
- package/lib/git/route.d.ts +9 -0
- package/lib/git/runner.d.ts +29 -0
- package/lib/git/search.d.ts +14 -0
- package/lib/git/service.d.ts +52 -0
- package/lib/git/worktrees.d.ts +26 -0
- package/lib/index.d.ts +39 -0
- package/lib/index.js +3799 -0
- package/lib/index.js.map +1 -0
- package/lib/private-route.d.ts +15 -0
- package/lib/projects/contract.d.ts +82 -0
- package/lib/projects/registry.d.ts +73 -0
- package/lib/projects/route.d.ts +16 -0
- package/lib/projects/tools.d.ts +24 -0
- package/lib/pty/contract.d.ts +52 -0
- package/lib/pty/node-pty-spawn.d.ts +3 -0
- package/lib/pty/route.d.ts +9 -0
- package/lib/pty/screen-model.d.ts +25 -0
- package/lib/pty/scrollback.d.ts +26 -0
- package/lib/pty/service.d.ts +156 -0
- package/lib/pty/stream.d.ts +19 -0
- package/lib/shared-context/chat.d.ts +34 -0
- package/lib/shared-context/launch.d.ts +24 -0
- package/lib/shared-context/render.d.ts +29 -0
- package/lib/shared-context/route.d.ts +13 -0
- package/lib/shared-context/service.d.ts +65 -0
- package/lib/shared-context/tool.d.ts +20 -0
- package/lib/types/agents/argument-text.d.ts +9 -0
- package/lib/types/agents/contract.d.ts +50 -0
- package/lib/types/agents/definition.d.ts +38 -0
- package/lib/types/agents/known-agents.d.ts +52 -0
- package/lib/types/agents/launch.d.ts +26 -0
- package/lib/types/agents/preferences.d.ts +40 -0
- package/lib/types/agents/status/agent-status.d.ts +38 -0
- package/lib/types/capabilities/contract.d.ts +17 -0
- package/lib/types/client/agents/AddAgentForm.d.ts +10 -0
- package/lib/types/client/agents/AgentRow.d.ts +11 -0
- package/lib/types/client/agents/AgentsSection.d.ts +14 -0
- package/lib/types/client/agents/acryl-logo-data.d.ts +3 -0
- package/lib/types/client/agents/agent-draft.d.ts +24 -0
- package/lib/types/client/agents/agents-api.d.ts +18 -0
- package/lib/types/client/agents/agents-section-model.d.ts +45 -0
- package/lib/types/client/agents/agents-settings-plugin.d.ts +8 -0
- package/lib/types/client/agents/agents-state.d.ts +26 -0
- package/lib/types/client/agents/controls.d.ts +40 -0
- package/lib/types/client/board/NoteColumn.d.ts +17 -0
- package/lib/types/client/board/SessionBoardPane.d.ts +16 -0
- package/lib/types/client/board/board-model.d.ts +36 -0
- package/lib/types/client/browser/BrowserPane.d.ts +28 -0
- package/lib/types/client/canvas/SplitDivider.d.ts +9 -0
- package/lib/types/client/canvas/WorkspaceCanvas.d.ts +78 -0
- package/lib/types/client/canvas/groups.d.ts +47 -0
- package/lib/types/client/canvas/persist.d.ts +17 -0
- package/lib/types/client/canvas/persistence.d.ts +78 -0
- package/lib/types/client/canvas/shell-requests.d.ts +16 -0
- package/lib/types/client/canvas/split-ratio.d.ts +12 -0
- package/lib/types/client/canvas/state.d.ts +181 -0
- package/lib/types/client/canvas/tab-title.d.ts +7 -0
- package/lib/types/client/capabilities/capabilities-api.d.ts +8 -0
- package/lib/types/client/changes/ChangesBody.d.ts +14 -0
- package/lib/types/client/changes/changes-tab.d.ts +20 -0
- package/lib/types/client/chat/chat-selection.d.ts +70 -0
- package/lib/types/client/chat/composer-focus.d.ts +16 -0
- package/lib/types/client/checks/ChecksBody.d.ts +9 -0
- package/lib/types/client/checks/checks-tab.d.ts +12 -0
- package/lib/types/client/chrome/StatusLine.d.ts +11 -0
- package/lib/types/client/chrome/panel-icons.d.ts +16 -0
- package/lib/types/client/chrome/status-line.d.ts +19 -0
- package/lib/types/client/chrome/worktree-agents.d.ts +13 -0
- package/lib/types/client/comments/CommentsBody.d.ts +24 -0
- package/lib/types/client/comments/comment-store.d.ts +38 -0
- package/lib/types/client/comments/comments-tab.d.ts +14 -0
- package/lib/types/client/comments/editor-comments.d.ts +6 -0
- package/lib/types/client/comments/terminal-targets.d.ts +35 -0
- package/lib/types/client/comments/use-comments.d.ts +27 -0
- package/lib/types/client/connection/session-banner.d.ts +51 -0
- package/lib/types/client/diff/GitDiffPane.d.ts +27 -0
- package/lib/types/client/diff/TextDiffPane.d.ts +6 -0
- package/lib/types/client/diff/comment-message.d.ts +29 -0
- package/lib/types/client/diff/diff-layout.d.ts +4 -0
- package/lib/types/client/diff/line-diff.d.ts +14 -0
- package/lib/types/client/diff/unified-diff.d.ts +31 -0
- package/lib/types/client/dock/DockButtons.d.ts +19 -0
- package/lib/types/client/dock/DockColumns.d.ts +21 -0
- package/lib/types/client/dock/DockDivider.d.ts +13 -0
- package/lib/types/client/dock/TerminalDockPanel.d.ts +13 -0
- package/lib/types/client/dock/dock-controller.d.ts +55 -0
- package/lib/types/client/dock/dock-hooks.d.ts +6 -0
- package/lib/types/client/dock/dock-host.d.ts +14 -0
- package/lib/types/client/dock/dock-icons.d.ts +10 -0
- package/lib/types/client/dock/dock-model.d.ts +35 -0
- package/lib/types/client/dock/dock-tabs.d.ts +72 -0
- package/lib/types/client/dock/terminal-stack.d.ts +19 -0
- package/lib/types/client/docs/DocFilePane.d.ts +12 -0
- package/lib/types/client/docs/DocPane.d.ts +6 -0
- package/lib/types/client/docs/DocView.d.ts +5 -0
- package/lib/types/client/docs/doc-format.d.ts +46 -0
- package/lib/types/client/dom/find-by-name.d.ts +18 -0
- package/lib/types/client/files/CodeEditor.d.ts +19 -0
- package/lib/types/client/files/FileBreadcrumbs.d.ts +15 -0
- package/lib/types/client/files/FileEditorPane.d.ts +12 -0
- package/lib/types/client/files/FileTree.d.ts +25 -0
- package/lib/types/client/files/FilesBody.d.ts +14 -0
- package/lib/types/client/files/ScratchFilePane.d.ts +6 -0
- package/lib/types/client/files/breadcrumbs.d.ts +18 -0
- package/lib/types/client/files/file-edit.d.ts +20 -0
- package/lib/types/client/files/file-icons.d.ts +17 -0
- package/lib/types/client/files/files-api.d.ts +26 -0
- package/lib/types/client/files/files-tab.d.ts +25 -0
- package/lib/types/client/files/line-comment.d.ts +26 -0
- package/lib/types/client/files/line-comments.d.ts +48 -0
- package/lib/types/client/files/tree-model.d.ts +60 -0
- package/lib/types/client/git/git-api.d.ts +35 -0
- package/lib/types/client/index.d.ts +28 -0
- package/lib/types/client/models/ModelConnect.d.ts +13 -0
- package/lib/types/client/models/model-connect.d.ts +145 -0
- package/lib/types/client/notifications/Toasts.d.ts +6 -0
- package/lib/types/client/notifications/system-notice.d.ts +19 -0
- package/lib/types/client/notifications/toast-state.d.ts +29 -0
- package/lib/types/client/palette/CommandPalette.d.ts +9 -0
- package/lib/types/client/palette/PalettePanel.d.ts +10 -0
- package/lib/types/client/palette/file-search.d.ts +9 -0
- package/lib/types/client/palette/fuzzy.d.ts +15 -0
- package/lib/types/client/palette/palette-commands.d.ts +64 -0
- package/lib/types/client/palette/palette-config.d.ts +21 -0
- package/lib/types/client/palette/palette-items.d.ts +40 -0
- package/lib/types/client/palette/palette-settings-plugin.d.ts +8 -0
- package/lib/types/client/palette/palette-shortcut.d.ts +10 -0
- package/lib/types/client/palette/palette-state.d.ts +68 -0
- package/lib/types/client/palette/use-workspace-palette.d.ts +39 -0
- package/lib/types/client/projects/NewWorkspaceDialog.d.ts +21 -0
- package/lib/types/client/projects/ProjectsSidebar.d.ts +39 -0
- package/lib/types/client/projects/RepoSection.d.ts +29 -0
- package/lib/types/client/projects/WorkspaceStrip.d.ts +14 -0
- package/lib/types/client/projects/projects-control.d.ts +119 -0
- package/lib/types/client/projects/registry-api.d.ts +22 -0
- package/lib/types/client/projects/registry-state.d.ts +67 -0
- package/lib/types/client/projects/shown-workspace.d.ts +19 -0
- package/lib/types/client/projects/sidebar-model.d.ts +113 -0
- package/lib/types/client/projects/upstream-panels.d.ts +54 -0
- package/lib/types/client/projects/web-folder-picker.d.ts +13 -0
- package/lib/types/client/review/ReviewBody.d.ts +9 -0
- package/lib/types/client/review/review-store.d.ts +46 -0
- package/lib/types/client/review/review-tab.d.ts +15 -0
- package/lib/types/client/sessions/agent-bridge.d.ts +20 -0
- package/lib/types/client/sessions/main-session.d.ts +24 -0
- package/lib/types/client/sessions/running-agents.d.ts +9 -0
- package/lib/types/client/sessions/session-client.d.ts +22 -0
- package/lib/types/client/sessions/session-navigation.d.ts +63 -0
- package/lib/types/client/sessions/session-pick.d.ts +15 -0
- package/lib/types/client/settings/locales.d.ts +5 -0
- package/lib/types/client/settings/open-settings.d.ts +37 -0
- package/lib/types/client/settings/section-plugin.d.ts +39 -0
- package/lib/types/client/settings/styles.d.ts +3 -0
- package/lib/types/client/shared-context/BriefTab.d.ts +21 -0
- package/lib/types/client/shared-context/brief-api.d.ts +9 -0
- package/lib/types/client/status/agent-status-api.d.ts +10 -0
- package/lib/types/client/status/agent-status-state.d.ts +27 -0
- package/lib/types/client/status/attention-model.d.ts +20 -0
- package/lib/types/client/styles.d.ts +2 -0
- package/lib/types/client/tabs/AgentIcon.d.ts +12 -0
- package/lib/types/client/tabs/NewTabMenu.d.ts +42 -0
- package/lib/types/client/tabs/TabActivity.d.ts +7 -0
- package/lib/types/client/tabs/TabStrip.d.ts +53 -0
- package/lib/types/client/tabs/TabsPanel.d.ts +14 -0
- package/lib/types/client/tabs/agent-marks.d.ts +9 -0
- package/lib/types/client/tabs/agent-visibility.d.ts +11 -0
- package/lib/types/client/tabs/last-tab.d.ts +15 -0
- package/lib/types/client/tabs/registry/CustomTabPane.d.ts +13 -0
- package/lib/types/client/tabs/registry/provide.d.ts +11 -0
- package/lib/types/client/tabs/registry/tab-registry.d.ts +52 -0
- package/lib/types/client/tabs/tab-close.d.ts +4 -0
- package/lib/types/client/tabs/tab-scroll.d.ts +19 -0
- package/lib/types/client/tabs/tab-types-state.d.ts +24 -0
- package/lib/types/client/tabs/tabs-settings-plugin.d.ts +9 -0
- package/lib/types/client/terminal/PtyPane.d.ts +8 -0
- package/lib/types/client/terminal/TerminalSearchBar.d.ts +7 -0
- package/lib/types/client/terminal/agent-commands.d.ts +15 -0
- package/lib/types/client/terminal/gpu-renderer.d.ts +10 -0
- package/lib/types/client/terminal/pty-api.d.ts +21 -0
- package/lib/types/client/terminal/pty-stream.d.ts +46 -0
- package/lib/types/client/terminal/terminal-links.d.ts +9 -0
- package/lib/types/client/terminal/terminal-search.d.ts +18 -0
- package/lib/types/client/terminal/terminal-session.d.ts +105 -0
- package/lib/types/client/terminal/terminal-size.d.ts +7 -0
- package/lib/types/client/ui.d.ts +18 -0
- package/lib/types/client/worktrees/shell-polling.d.ts +10 -0
- package/lib/types/client/worktrees/shell-state.d.ts +200 -0
- package/lib/types/files/contract.d.ts +74 -0
- package/lib/types/folder-picker/contract.d.ts +9 -0
- package/lib/types/git/contract.d.ts +136 -0
- package/lib/types/projects/contract.d.ts +82 -0
- package/lib/types/pty/contract.d.ts +52 -0
- package/lib/ui.js +12735 -0
- package/lib/ui.js.map +1 -0
- package/package.json +145 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** A terminal or agent tab: shows the session's live terminal and its status. */
|
|
2
|
+
import type { WorkspaceTile } from '../canvas/state.ts';
|
|
3
|
+
import type { TerminalRegistry } from './terminal-session.ts';
|
|
4
|
+
export declare function PtyPane({ tile, terminals, compact }: {
|
|
5
|
+
readonly tile: WorkspaceTile;
|
|
6
|
+
readonly terminals: TerminalRegistry; /** Hide the name and status line (the dock's tab strip already names the terminal). */
|
|
7
|
+
readonly compact?: boolean;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The search box over a terminal: type to find, Enter for the next match, Shift+Enter for the previous, Escape to close. */
|
|
2
|
+
import type { TerminalSession } from './terminal-session.ts';
|
|
3
|
+
export interface TerminalSearchBarProps {
|
|
4
|
+
readonly session: TerminalSession;
|
|
5
|
+
onClose(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function TerminalSearchBar({ session, onClose }: TerminalSearchBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Labels for allowlisted Terminal / agent tabs. */
|
|
2
|
+
import type { WorkspacePtyCommandId } from '../../pty/contract.ts';
|
|
3
|
+
export interface WorkspaceAgentCommand {
|
|
4
|
+
readonly id: WorkspacePtyCommandId;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
}
|
|
7
|
+
export interface WorkspaceSurfaceAction {
|
|
8
|
+
readonly kind: 'pty' | 'file' | 'browser' | 'diff' | 'kanban' | 'doc';
|
|
9
|
+
readonly commandId?: WorkspacePtyCommandId;
|
|
10
|
+
readonly label: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const WORKSPACE_SURFACE_ACTIONS: readonly WorkspaceSurfaceAction[];
|
|
13
|
+
export declare const WORKSPACE_AGENT_COMMANDS: readonly WorkspaceAgentCommand[];
|
|
14
|
+
/** The name of an agent id; a custom agent's own name is used by the caller that knows it. */
|
|
15
|
+
export declare function labelForCommand(id: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The GPU (WebGL) renderer for a terminal, with the DOM renderer as the fallback.
|
|
3
|
+
*
|
|
4
|
+
* WebGL draws box-drawing and block characters pixel-exact and stays smooth under heavy output, which the
|
|
5
|
+
* DOM renderer does not. It is used only where a WebGL2 context is really available, and a lost context
|
|
6
|
+
* (a sleeping GPU, too many contexts) drops back to the DOM renderer instead of leaving a blank terminal.
|
|
7
|
+
*/
|
|
8
|
+
import type { Terminal } from '@xterm/xterm';
|
|
9
|
+
/** @returns true when the GPU renderer is now active. Call after `terminal.open`. */
|
|
10
|
+
export declare function enableGpuRenderer(terminal: Terminal): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Same-origin client for Host workspace PTY sessions. */
|
|
2
|
+
import { type AgentId, type WorkspacePtyView } from '../../pty/contract.ts';
|
|
3
|
+
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
4
|
+
export interface TerminalSize {
|
|
5
|
+
readonly cols: number;
|
|
6
|
+
readonly rows: number;
|
|
7
|
+
}
|
|
8
|
+
export interface WorkspacePtyApi {
|
|
9
|
+
/**
|
|
10
|
+
* @param cwd - optional worktree directory to start in.
|
|
11
|
+
* @param size - the size the terminal will be shown at, so the first frame already fits.
|
|
12
|
+
*/
|
|
13
|
+
start(commandId: AgentId, cwd?: string, size?: TerminalSize): Promise<WorkspacePtyView>;
|
|
14
|
+
read(id: string): Promise<WorkspacePtyView>;
|
|
15
|
+
write(id: string, data: string): Promise<void>;
|
|
16
|
+
resize(id: string, cols: number, rows: number): Promise<void>;
|
|
17
|
+
close(id: string): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** @param fetcher - injected for tests; defaults to window.fetch. */
|
|
20
|
+
export declare function createWorkspacePtyApi(fetcher?: FetchLike): WorkspacePtyApi;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser end of one terminal's live stream (see `src/pty/stream.ts`).
|
|
3
|
+
*
|
|
4
|
+
* It remembers how far the terminal has been shown (the cursor), so when the connection drops it
|
|
5
|
+
* reconnects and asks only for what it missed. Input and resizes made while offline wait in order and go
|
|
6
|
+
* out first once the connection is back. It never guesses: a closed session or an exit ends it.
|
|
7
|
+
*/
|
|
8
|
+
export type PtyStreamState = 'connecting' | 'live' | 'reconnecting' | 'exited' | 'lost';
|
|
9
|
+
export interface PtyStreamHandlers {
|
|
10
|
+
/** New output. `replace` means clear the terminal first (more was missed than the Host kept). */
|
|
11
|
+
output(data: string, replace: boolean): void;
|
|
12
|
+
state(state: PtyStreamState): void;
|
|
13
|
+
exit(exitCode: number | null, error: string | null): void;
|
|
14
|
+
}
|
|
15
|
+
/** The slice of the browser WebSocket the stream uses, so tests can supply their own. */
|
|
16
|
+
export interface StreamSocket {
|
|
17
|
+
send(data: string): void;
|
|
18
|
+
close(): void;
|
|
19
|
+
onopen: ((event: Event) => void) | null;
|
|
20
|
+
onmessage: ((event: MessageEvent) => void) | null;
|
|
21
|
+
onclose: ((event: CloseEvent) => void) | null;
|
|
22
|
+
onerror: ((event: Event) => void) | null;
|
|
23
|
+
readonly readyState: number;
|
|
24
|
+
}
|
|
25
|
+
export type StreamSocketFactory = (url: string) => StreamSocket;
|
|
26
|
+
export declare function browserStreamUrl(id: string, cursor: number): string;
|
|
27
|
+
export declare class PtyStream {
|
|
28
|
+
private readonly id;
|
|
29
|
+
private readonly handlers;
|
|
30
|
+
private readonly createSocket;
|
|
31
|
+
private readonly urlFor;
|
|
32
|
+
private socket;
|
|
33
|
+
private cursor;
|
|
34
|
+
private ended;
|
|
35
|
+
private timer;
|
|
36
|
+
private backoff;
|
|
37
|
+
private queuedInput;
|
|
38
|
+
private size;
|
|
39
|
+
constructor(id: string, handlers: PtyStreamHandlers, createSocket?: StreamSocketFactory, urlFor?: (id: string, cursor: number) => string);
|
|
40
|
+
connect(): void;
|
|
41
|
+
/** Keystrokes and pasted text, delivered in order (held back while offline, up to a cap). */
|
|
42
|
+
input(data: string): void;
|
|
43
|
+
resize(cols: number, rows: number): void;
|
|
44
|
+
dispose(): void;
|
|
45
|
+
private transmit;
|
|
46
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Finding web addresses in a line of terminal output, so they can be clicked. Pure text rules. */
|
|
2
|
+
export interface TerminalLink {
|
|
3
|
+
/** Zero-based start (inclusive) and end (exclusive) columns in the line. */
|
|
4
|
+
readonly start: number;
|
|
5
|
+
readonly end: number;
|
|
6
|
+
readonly url: string;
|
|
7
|
+
}
|
|
8
|
+
/** @returns the http and https addresses in `line`, without trailing punctuation, in order. */
|
|
9
|
+
export declare function findLinks(line: string): TerminalLink[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Searching a terminal's scrollback: pure rules over the lines the terminal holds. */
|
|
2
|
+
export interface TerminalMatch {
|
|
3
|
+
/** Absolute row in the buffer (scrollback included) and the column where the match starts. */
|
|
4
|
+
readonly row: number;
|
|
5
|
+
readonly col: number;
|
|
6
|
+
readonly length: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const MAX_MATCHES = 2000;
|
|
9
|
+
/** @returns every case-insensitive occurrence of `query` in `lines`, top to bottom, at most {@link MAX_MATCHES}. */
|
|
10
|
+
export declare function findMatches(lines: readonly string[], query: string): TerminalMatch[];
|
|
11
|
+
/**
|
|
12
|
+
* @param count - number of matches.
|
|
13
|
+
* @param current - index of the match now selected, or -1 when none is.
|
|
14
|
+
* @returns the index to move to, wrapping around at both ends; -1 when there are no matches.
|
|
15
|
+
*/
|
|
16
|
+
export declare function stepMatch(count: number, current: number, direction: 1 | -1): number;
|
|
17
|
+
/** Cmd+F on macOS, Ctrl+Shift+F elsewhere (plain Ctrl+F belongs to the shell). */
|
|
18
|
+
export declare function isSearchShortcut(event: Pick<KeyboardEvent, 'key' | 'metaKey' | 'ctrlKey' | 'shiftKey' | 'altKey'>, mac: boolean): boolean;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One terminal that outlives its tab.
|
|
3
|
+
*
|
|
4
|
+
* The xterm instance and its live stream belong to the session, not to the pane that shows it. Switching
|
|
5
|
+
* tabs only moves the terminal's element out of and back into the page, so the screen is exactly as the
|
|
6
|
+
* process left it: no replayed history, no redraw glitches. The session ends when its tab is closed.
|
|
7
|
+
*/
|
|
8
|
+
import { type PtyStreamState, type StreamSocketFactory } from './pty-stream.ts';
|
|
9
|
+
export type TerminalStatus = PtyStreamState;
|
|
10
|
+
export interface TerminalSessionSnapshot {
|
|
11
|
+
readonly status: TerminalStatus;
|
|
12
|
+
readonly exitCode: number | null;
|
|
13
|
+
readonly error: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface TerminalSessionOptions {
|
|
16
|
+
/** Called once when the process behind a session ends. */
|
|
17
|
+
readonly onExit?: (terminalId: string, exitCode: number | null) => void;
|
|
18
|
+
/** Called once when the Host no longer knows the terminal (it restarted, or the terminal was closed elsewhere). */
|
|
19
|
+
readonly onLost?: (terminalId: string) => void;
|
|
20
|
+
/** Called when the program sets the terminal's title (`ESC ] 0 ; title BEL`). */
|
|
21
|
+
readonly onTitle?: (terminalId: string, title: string) => void;
|
|
22
|
+
readonly createSocket?: StreamSocketFactory;
|
|
23
|
+
readonly urlFor?: (id: string, cursor: number) => string;
|
|
24
|
+
/** The screen's colours and type size, for a root owner with its own palette; the workspace's when left out. */
|
|
25
|
+
readonly appearance?: TerminalAppearance;
|
|
26
|
+
}
|
|
27
|
+
export interface TerminalAppearance {
|
|
28
|
+
readonly background: string;
|
|
29
|
+
readonly foreground: string;
|
|
30
|
+
readonly fontSize?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare class TerminalSession {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
private readonly terminal;
|
|
35
|
+
private readonly fit;
|
|
36
|
+
private readonly stream;
|
|
37
|
+
private readonly element;
|
|
38
|
+
private readonly listeners;
|
|
39
|
+
private snapshot;
|
|
40
|
+
private opened;
|
|
41
|
+
private host;
|
|
42
|
+
private observer;
|
|
43
|
+
private frame;
|
|
44
|
+
private dims;
|
|
45
|
+
private disposed;
|
|
46
|
+
private matches;
|
|
47
|
+
private matchIndex;
|
|
48
|
+
private searchQuery;
|
|
49
|
+
private readonly searchListeners;
|
|
50
|
+
constructor(id: string, options?: TerminalSessionOptions);
|
|
51
|
+
getSnapshot: () => TerminalSessionSnapshot;
|
|
52
|
+
subscribe: (listener: () => void) => (() => void);
|
|
53
|
+
/** Show this terminal in `host` (a pane), replacing whatever showed it before. */
|
|
54
|
+
attach(host: HTMLElement): void;
|
|
55
|
+
/** Take the terminal out of the page; it keeps running and keeps its screen. */
|
|
56
|
+
detach(): void;
|
|
57
|
+
focus(): void;
|
|
58
|
+
/** The process is still there to type into. */
|
|
59
|
+
isLive(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The program has turned on bracketed paste, so pasted text arrives as one paste and its line breaks do not press Enter (agent CLIs,
|
|
62
|
+
* modern shells). Without it, every line break of a paste would run what came before it.
|
|
63
|
+
*/
|
|
64
|
+
takesMultilinePaste(): boolean;
|
|
65
|
+
/** Type `text` into the program as a paste, as if the user pasted it; nothing is submitted unless the text itself ends a line. */
|
|
66
|
+
paste(text: string): void;
|
|
67
|
+
/** Be told when the user asks to search this terminal (the search shortcut). @returns disposer. */
|
|
68
|
+
onSearchRequest(listener: () => void): () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Select the next (or previous) occurrence of `query` in the scrollback and scroll it into view.
|
|
71
|
+
* A new query starts from the top of what is on screen's nearest match after the current one.
|
|
72
|
+
* @returns the position (1-based) and the number of matches; position 0 when there is none.
|
|
73
|
+
*/
|
|
74
|
+
search(query: string, direction?: 1 | -1): {
|
|
75
|
+
readonly position: number;
|
|
76
|
+
readonly total: number;
|
|
77
|
+
};
|
|
78
|
+
/** Forget the search (the bar closed): the selection goes and the next search starts fresh. */
|
|
79
|
+
clearSearch(): void;
|
|
80
|
+
/** End the session's view of the process (the tab was closed); closing the process itself is the caller's. */
|
|
81
|
+
dispose(): void;
|
|
82
|
+
private scheduleFit;
|
|
83
|
+
private update;
|
|
84
|
+
}
|
|
85
|
+
/** The live terminals of one workspace canvas, by Host session id. */
|
|
86
|
+
export declare class TerminalRegistry {
|
|
87
|
+
private readonly options;
|
|
88
|
+
private readonly sessions;
|
|
89
|
+
private readonly lostListeners;
|
|
90
|
+
private readonly exitListeners;
|
|
91
|
+
private readonly titleListeners;
|
|
92
|
+
constructor(options?: TerminalSessionOptions);
|
|
93
|
+
/** The session of a terminal this canvas shows, if it has one. */
|
|
94
|
+
get(id: string): TerminalSession | undefined;
|
|
95
|
+
/** Be told when the Host no longer knows a terminal. @returns disposer. */
|
|
96
|
+
onLost(listener: (terminalId: string) => void): () => void;
|
|
97
|
+
/** Be told when any session's process ends. @returns disposer. */
|
|
98
|
+
onExit(listener: (terminalId: string, exitCode: number | null) => void): () => void;
|
|
99
|
+
/** Be told when a program sets its terminal's title. @returns disposer. */
|
|
100
|
+
onTitle(listener: (terminalId: string, title: string) => void): () => void;
|
|
101
|
+
ensure(id: string): TerminalSession;
|
|
102
|
+
/** The tab was closed: end the session's view. */
|
|
103
|
+
release(id: string): void;
|
|
104
|
+
disposeAll(): void;
|
|
105
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** A first guess at how many columns and rows a pane will hold, before the terminal is on screen to measure. */
|
|
2
|
+
import type { TerminalSize } from './pty-api.ts';
|
|
3
|
+
/**
|
|
4
|
+
* @returns the estimated size, or undefined when the area is unknown or too small to be a real pane.
|
|
5
|
+
* The real size is sent as soon as the terminal is measured; this only makes the first frame close.
|
|
6
|
+
*/
|
|
7
|
+
export declare function estimateTerminalSize(widthPx: number, heightPx: number): TerminalSize | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace's reusable client layers, for another root owner (the Blends frame) that shows terminals, files and git without the workbench:
|
|
3
|
+
* the live terminal sessions, the PTY, files and git route clients, the agents a PTY can run, and xterm's stylesheet as text. Nothing here
|
|
4
|
+
* registers a slot or a service; the importer owns placement and lifecycle. Settings > Agents comes as the plugins that register it.
|
|
5
|
+
*/
|
|
6
|
+
export { TerminalRegistry, TerminalSession, type TerminalAppearance, type TerminalSessionSnapshot, type TerminalStatus } from './terminal/terminal-session.ts';
|
|
7
|
+
export { createWorkspacePtyApi, type WorkspacePtyApi, type TerminalSize } from './terminal/pty-api.ts';
|
|
8
|
+
export { createWorkspaceFilesApi, type WorkspaceFilesApi } from './files/files-api.ts';
|
|
9
|
+
export { createWorkspaceGitApi, type WorkspaceGitApi } from './git/git-api.ts';
|
|
10
|
+
export { KNOWN_AGENTS, knownAgent, type KnownAgentId } from '../agents/known-agents.ts';
|
|
11
|
+
export type { FileEntry, FilesTreeView, FileContentView } from '../files/contract.ts';
|
|
12
|
+
export type { GitChange, GitStatusView } from '../git/contract.ts';
|
|
13
|
+
export { AgentsState } from './agents/agents-state.ts';
|
|
14
|
+
export { createWorkspaceAgentsApi } from './agents/agents-api.ts';
|
|
15
|
+
export { agentsSettingsPlugin } from './agents/agents-settings-plugin.ts';
|
|
16
|
+
export { settingsSharedPlugin } from './settings/section-plugin.ts';
|
|
17
|
+
/** xterm's own stylesheet; the importer injects it once, beside the `.xterm` rules a terminal needs. */
|
|
18
|
+
export declare const XTERM_CSS: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Keep the shell's git state fresh while the window is visible. */
|
|
2
|
+
import type { WorkspaceShellState } from './shell-state.ts';
|
|
3
|
+
/** Milliseconds between refreshes of every known worktree's status. */
|
|
4
|
+
export declare const SHELL_POLL_INTERVAL_MS = 5000;
|
|
5
|
+
/**
|
|
6
|
+
* Start refreshing on an interval, on window focus, and when the page becomes visible.
|
|
7
|
+
* Hidden pages do no work. Owned by one `ctx.effect`; the returned disposer stops it and
|
|
8
|
+
* disposes the shell.
|
|
9
|
+
*/
|
|
10
|
+
export declare function startShellPolling(shell: WorkspaceShellState): () => void;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observable state for the Workspace's left and right panes: which repositories and worktrees are
|
|
3
|
+
* known, their changed files, and which worktree is selected. Pure TypeScript with an injected git
|
|
4
|
+
* API, so it is unit-testable without a browser.
|
|
5
|
+
*/
|
|
6
|
+
import type { GitChange, GitRepoView } from '../../git/contract.ts';
|
|
7
|
+
import type { WorkspaceGitApi } from '../git/git-api.ts';
|
|
8
|
+
export type ShellMode = 'chats' | 'projects';
|
|
9
|
+
export type LoadPhase = 'idle' | 'loading' | 'ready' | 'error';
|
|
10
|
+
export interface WorktreeState {
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly branch: string | null;
|
|
13
|
+
readonly main: boolean;
|
|
14
|
+
readonly phase: LoadPhase;
|
|
15
|
+
readonly changes: readonly GitChange[];
|
|
16
|
+
/** Sum of added lines across changes that report counts. */
|
|
17
|
+
readonly added: number;
|
|
18
|
+
/** Sum of removed lines across changes that report counts. */
|
|
19
|
+
readonly removed: number;
|
|
20
|
+
readonly truncated: boolean;
|
|
21
|
+
readonly error?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RepoState {
|
|
24
|
+
readonly root: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/** false for a plain folder registered as a workspace that is not a git repository. It has exactly one synthetic worktree (itself), no
|
|
27
|
+
* branches, and never polls git status - it always reports zero changes. */
|
|
28
|
+
readonly git: boolean;
|
|
29
|
+
readonly worktrees: readonly WorktreeState[];
|
|
30
|
+
}
|
|
31
|
+
export interface ShellSnapshot {
|
|
32
|
+
readonly mode: ShellMode;
|
|
33
|
+
readonly repos: readonly RepoState[];
|
|
34
|
+
/** Worktree whose tab group and changes are shown. */
|
|
35
|
+
readonly selectedPath: string | undefined;
|
|
36
|
+
/** Chat session ids the user closed from the tree or the tab strip; closing in one place hides the chat in both. This hides the session
|
|
37
|
+
* from this view only: the injected `ISessions` face cannot delete a session, so the session itself is kept. */
|
|
38
|
+
readonly dismissedChats: ReadonlySet<string>;
|
|
39
|
+
}
|
|
40
|
+
/** A request to run one check (a package script) in a terminal tab of a worktree. */
|
|
41
|
+
export interface RunCheckRequest {
|
|
42
|
+
readonly worktree: string;
|
|
43
|
+
/** Title for the terminal tab, for example `pnpm run check`. */
|
|
44
|
+
readonly title: string;
|
|
45
|
+
/** The command line to type into the shell. Built from a validated script name only. */
|
|
46
|
+
readonly commandLine: string;
|
|
47
|
+
}
|
|
48
|
+
/** A request to open one file of a worktree in an editor tab. */
|
|
49
|
+
export interface OpenFileRequest {
|
|
50
|
+
readonly worktree: string;
|
|
51
|
+
/** Path relative to the worktree. */
|
|
52
|
+
readonly file: string;
|
|
53
|
+
/** The user asked for it beside the tab in front (a split); otherwise it opens as the current tab. */
|
|
54
|
+
readonly beside?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** A request to preview one markdown file of a worktree in a Doc tab. */
|
|
57
|
+
export type OpenDocRequest = OpenFileRequest;
|
|
58
|
+
export interface OpenDiffRequest {
|
|
59
|
+
readonly worktree: string;
|
|
60
|
+
readonly file: string;
|
|
61
|
+
/** The user asked for it beside the tab in front (a split); otherwise it opens as the current tab. */
|
|
62
|
+
readonly beside?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** A request to close one canvas tile (the tree's hover "x" on an agent or terminal entry). Handled by `routeShellRequests`, not
|
|
65
|
+
* `WorkspaceState.closeTile` directly, so a terminal tile's process is released too - the tree has no access to that itself. */
|
|
66
|
+
export interface CloseTileRequest {
|
|
67
|
+
readonly worktree: string;
|
|
68
|
+
readonly tileId: string;
|
|
69
|
+
}
|
|
70
|
+
export declare class WorkspaceShellState {
|
|
71
|
+
private readonly api;
|
|
72
|
+
private snapshot;
|
|
73
|
+
private readonly listeners;
|
|
74
|
+
private readonly diffListeners;
|
|
75
|
+
private readonly runListeners;
|
|
76
|
+
private readonly fileListeners;
|
|
77
|
+
private readonly docListeners;
|
|
78
|
+
private readonly closeTileListeners;
|
|
79
|
+
private readonly probes;
|
|
80
|
+
/** Repos removed by `forgetRepo`. Passive discovery (every chat's folder, every registered workspace) would otherwise add a removed
|
|
81
|
+
* repo straight back while a chat or the Host's list still points at it. Checked by `discover()` on every path; cleared only by an
|
|
82
|
+
* explicit re-add (`clearForgotten: true`), never by passive discovery, whose sources can lag a delete. */
|
|
83
|
+
private readonly forgottenRepos;
|
|
84
|
+
private readonly forgottenListeners;
|
|
85
|
+
private readonly statusInflight;
|
|
86
|
+
private pinned;
|
|
87
|
+
private reveal;
|
|
88
|
+
private disposed;
|
|
89
|
+
/** The chat folder a restore is discovering a worktree for right now (see `follow`); undefined when no restore is in flight. */
|
|
90
|
+
private following;
|
|
91
|
+
/** Callers waiting for the next selection (`waitForSelection`), settled together when one lands. */
|
|
92
|
+
private readonly selectionWaiters;
|
|
93
|
+
/**
|
|
94
|
+
* @param initialForgotten - a previous run's removed roots (`forgetRepo`), so a removal survives a reload.
|
|
95
|
+
* @param initialDismissed - a previous run's dismissed chats (`dismissChat`), so a dismissal survives a reload.
|
|
96
|
+
*/
|
|
97
|
+
constructor(api: WorkspaceGitApi, initialForgotten?: readonly string[], initialDismissed?: readonly string[]);
|
|
98
|
+
getSnapshot(): ShellSnapshot;
|
|
99
|
+
/** Repository roots currently removed (`forgetRepo`), for persistence. */
|
|
100
|
+
forgottenRoots(): readonly string[];
|
|
101
|
+
/** Notified whenever the forgotten-roots set changes (a removal, or an explicit re-add lifting one). */
|
|
102
|
+
onForgottenChange(listener: () => void): () => void;
|
|
103
|
+
private notifyForgottenChange;
|
|
104
|
+
subscribe(listener: () => void): () => void;
|
|
105
|
+
/** The selected worktree, when it is known. */
|
|
106
|
+
selectedWorktree(): WorktreeState | undefined;
|
|
107
|
+
/** Hide a chat from the tree and the tab strip. Idempotent. */
|
|
108
|
+
dismissChat(id: string): void;
|
|
109
|
+
/** Undo a dismissal - a session explicitly reopened elsewhere (the classic "All chats" view, search) is
|
|
110
|
+
* no longer hidden. A no-op when it was never dismissed. */
|
|
111
|
+
restoreChat(id: string): void;
|
|
112
|
+
/** Drop a repository or plain folder from the tree entirely, and remember it as removed: `discover()` refuses to merge a forgotten root
|
|
113
|
+
* again (passive discovery would re-add it while a chat or the Host's list still points there); only an explicit re-add
|
|
114
|
+
* (`clearForgotten: true`) lifts it. Its probe cache entries are cleared too, so a later fresh discovery does not reuse a stale result. */
|
|
115
|
+
forgetRepo(root: string): void;
|
|
116
|
+
setMode(mode: ShellMode): void;
|
|
117
|
+
/**
|
|
118
|
+
* Learn about the repository that contains `cwd`.
|
|
119
|
+
* @param options.registerFolder - when true, and `cwd` is not a git repository, register it as its own plain folder workspace instead
|
|
120
|
+
* of reporting it unknown. Only for an explicit "add this folder" (`ProjectsControl.addProjectByPath`, and re-syncing already
|
|
121
|
+
* registered project paths); never for passive discovery of a chat's folder, which would turn every folder a chat ran in into a
|
|
122
|
+
* project. Bypasses the probe cache: an explicit add is not deduplicated against an earlier passive discovery of the same path.
|
|
123
|
+
* @param options.clearForgotten - when true, lifts an earlier `forgetRepo(cwd)` for this exact path. Only for a deliberate re-add by the
|
|
124
|
+
* user (`ProjectsControl.addProjectByPath`); never for re-syncing registered paths, whose source can still list a path for a moment
|
|
125
|
+
* after it was removed.
|
|
126
|
+
* @returns the path of the worktree (or plain folder) that owns `cwd` - undefined when `cwd` is not a
|
|
127
|
+
* git repository and `registerFolder` was not requested, when the api call itself failed, or when the
|
|
128
|
+
* owning root was explicitly removed (`forgetRepo`) and not since re-added.
|
|
129
|
+
*/
|
|
130
|
+
discover(cwd: string, options?: {
|
|
131
|
+
readonly registerFolder?: boolean;
|
|
132
|
+
readonly clearForgotten?: boolean;
|
|
133
|
+
}): Promise<string | undefined>;
|
|
134
|
+
/** Take a repository view the caller already has (for example the answer to creating a worktree). */
|
|
135
|
+
applyRepo(view: GitRepoView): void;
|
|
136
|
+
/**
|
|
137
|
+
* Select the worktree that contains `cwd` unless the user has picked one by hand.
|
|
138
|
+
* Used to follow the current chat session.
|
|
139
|
+
*/
|
|
140
|
+
follow(cwd: string): Promise<void>;
|
|
141
|
+
/** Whether a chat folder is being discovered for the selection right now (a reload restoring the shown chat's worktree). */
|
|
142
|
+
restoring(): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* The worktree a new chat should use, waiting out a reload's restore: resolved at once when one is selected, otherwise with the path the next
|
|
145
|
+
* selection resolves to within `timeoutMs`, and undefined when none does. A new chat asked while the shown chat's worktree is still being restored
|
|
146
|
+
* targets it once it lands instead of opening with no worktree.
|
|
147
|
+
*/
|
|
148
|
+
waitForSelection(timeoutMs?: number): Promise<string | undefined>;
|
|
149
|
+
private settleSelectionWaiters;
|
|
150
|
+
/** Release a manual pick (for example when opening its chat failed) so the selection follows the chat again. */
|
|
151
|
+
unpin(): void;
|
|
152
|
+
/** The user picked a worktree: keep it selected even when the chat session changes, and reveal its changes. */
|
|
153
|
+
select(path: string): void;
|
|
154
|
+
/**
|
|
155
|
+
* Select no worktree, and keep it so while the chat changes: a workspace without projects shows none (spec 043), even though the
|
|
156
|
+
* chat on screen runs in a folder of another workspace.
|
|
157
|
+
*/
|
|
158
|
+
clearSelection(): void;
|
|
159
|
+
/** Register (or clear) how to bring the Changes tab into view. Owned by the Changes tab plugin. */
|
|
160
|
+
setReveal(reveal: (() => void) | undefined): void;
|
|
161
|
+
/** Reload the worktree list of every known git repository and the status of every worktree. Never
|
|
162
|
+
* polls a plain, non-git folder - it has no git state to refresh. */
|
|
163
|
+
refreshAll(): Promise<void>;
|
|
164
|
+
/** Reload one worktree's changed files. Concurrent calls for the same path share one request. A no-op
|
|
165
|
+
* for a plain, non-git folder - it always reports zero changes. */
|
|
166
|
+
refreshStatus(path: string): Promise<void>;
|
|
167
|
+
/** Ask the canvas to close a tile (the tree's hover "x" on an agent or terminal entry). */
|
|
168
|
+
requestCloseTile(request: CloseTileRequest): void;
|
|
169
|
+
/** @returns disposer. */
|
|
170
|
+
onCloseTileRequest(listener: (request: CloseTileRequest) => void): () => void;
|
|
171
|
+
/** Ask the canvas to open (or focus) a diff tile for one changed file. */
|
|
172
|
+
openDiff(request: OpenDiffRequest): void;
|
|
173
|
+
/** @returns disposer. */
|
|
174
|
+
onOpenDiff(listener: (request: OpenDiffRequest) => void): () => void;
|
|
175
|
+
/** Ask the canvas to open (or focus) an editor tab for one file. */
|
|
176
|
+
openFile(request: OpenFileRequest): void;
|
|
177
|
+
/** @returns disposer. */
|
|
178
|
+
onOpenFile(listener: (request: OpenFileRequest) => void): () => void;
|
|
179
|
+
/** Ask the canvas to open (or focus) a read-only Doc tab for one markdown file. */
|
|
180
|
+
openDoc(request: OpenDocRequest): void;
|
|
181
|
+
/** @returns disposer. */
|
|
182
|
+
onOpenDoc(listener: (request: OpenDocRequest) => void): () => void;
|
|
183
|
+
/** Ask the canvas to run a check in a terminal tab of that worktree. */
|
|
184
|
+
runCheck(request: RunCheckRequest): void;
|
|
185
|
+
/** @returns disposer. */
|
|
186
|
+
onRunCheck(listener: (request: RunCheckRequest) => void): () => void;
|
|
187
|
+
dispose(): void;
|
|
188
|
+
private selectInternal;
|
|
189
|
+
private findWorktree;
|
|
190
|
+
/** false only for a path known to belong to a plain, non-git folder repo; true for everything else,
|
|
191
|
+
* including a path not seen yet (the old, safe default: assume git until proven otherwise). */
|
|
192
|
+
private isGitWorktree;
|
|
193
|
+
private mergeRepo;
|
|
194
|
+
/** Register `cwd` itself as a plain, non-git folder workspace - one synthetic worktree, no branches,
|
|
195
|
+
* never polled for git status. A no-op once `cwd` is already known (as a repo or as a folder). */
|
|
196
|
+
private mergeFolder;
|
|
197
|
+
private applyRepoState;
|
|
198
|
+
private patchWorktree;
|
|
199
|
+
private replace;
|
|
200
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Loopback routes and JSON shapes for browsing, reading and saving files inside a git worktree. */
|
|
2
|
+
export declare const WORKSPACE_FILES_TREE_PATH = "/api/acryl-workspace/files/tree";
|
|
3
|
+
export declare const WORKSPACE_FILES_READ_PATH = "/api/acryl-workspace/files/read";
|
|
4
|
+
export declare const WORKSPACE_FILES_WRITE_PATH = "/api/acryl-workspace/files/write";
|
|
5
|
+
export declare const WORKSPACE_FILES_ENTRY_PATH = "/api/acryl-workspace/files/entry";
|
|
6
|
+
/** The largest file the editor opens or saves. */
|
|
7
|
+
export declare const MAX_EDITABLE_BYTES: number;
|
|
8
|
+
export type FileEntryKind = 'file' | 'dir';
|
|
9
|
+
export interface FileEntry {
|
|
10
|
+
/** Base name, without any directory part. */
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly kind: FileEntryKind;
|
|
13
|
+
/** Git ignores it (build output, dependencies, local settings); the tree shows it dimmed. */
|
|
14
|
+
readonly ignored?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** One directory of a worktree. */
|
|
17
|
+
export interface FilesTreeView {
|
|
18
|
+
/** Absolute worktree path. */
|
|
19
|
+
readonly path: string;
|
|
20
|
+
/** Directory relative to the worktree, `''` for its root. */
|
|
21
|
+
readonly dir: string;
|
|
22
|
+
/** Directories first, then files, each alphabetical. */
|
|
23
|
+
readonly entries: readonly FileEntry[];
|
|
24
|
+
/** True when the directory had more entries than the cap. */
|
|
25
|
+
readonly truncated: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface FileContentView {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly file: string;
|
|
30
|
+
/** UTF-8 text; empty when `binary`. */
|
|
31
|
+
readonly content: string;
|
|
32
|
+
readonly binary: boolean;
|
|
33
|
+
readonly size: number;
|
|
34
|
+
/** Modification time on disk, sent back when saving to detect an outside change. */
|
|
35
|
+
readonly mtimeMs: number;
|
|
36
|
+
}
|
|
37
|
+
export interface FileSavedView {
|
|
38
|
+
readonly path: string;
|
|
39
|
+
readonly file: string;
|
|
40
|
+
readonly size: number;
|
|
41
|
+
readonly mtimeMs: number;
|
|
42
|
+
}
|
|
43
|
+
/** @param value - unknown JSON from the tree route. */
|
|
44
|
+
export declare function parseFilesTreeView(value: unknown): FilesTreeView;
|
|
45
|
+
/** @param value - unknown JSON from the read route. */
|
|
46
|
+
export declare function parseFileContentView(value: unknown): FileContentView;
|
|
47
|
+
/** @param value - unknown JSON from the write route. */
|
|
48
|
+
export declare function parseFileSavedView(value: unknown): FileSavedView;
|
|
49
|
+
/**
|
|
50
|
+
* One structural change to a worktree's files. Deliberately small: create a file or an empty folder,
|
|
51
|
+
* rename or move an entry, delete a file or an empty folder. Nothing overwrites, nothing recurses.
|
|
52
|
+
*/
|
|
53
|
+
export type FileEntryChange = {
|
|
54
|
+
readonly op: 'create';
|
|
55
|
+
readonly kind: FileEntryKind;
|
|
56
|
+
readonly file: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly op: 'rename';
|
|
59
|
+
readonly file: string;
|
|
60
|
+
readonly to: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly op: 'delete';
|
|
63
|
+
readonly file: string;
|
|
64
|
+
};
|
|
65
|
+
/** The result of a structural change: what now exists (null after a delete). */
|
|
66
|
+
export interface FileEntryChangedView {
|
|
67
|
+
readonly path: string;
|
|
68
|
+
readonly op: FileEntryChange['op'];
|
|
69
|
+
readonly file: string | null;
|
|
70
|
+
}
|
|
71
|
+
/** @param value - unknown JSON from the entry route. */
|
|
72
|
+
export declare function parseFileEntryChangedView(value: unknown): FileEntryChangedView;
|
|
73
|
+
/** Validate an untrusted request body into a change, or null when it is not one. */
|
|
74
|
+
export declare function parseFileEntryChange(value: unknown): FileEntryChange | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Same-origin route that opens the operating system's own folder chooser on the machine running the Host. */
|
|
2
|
+
export declare const WORKSPACE_PICK_FOLDER_PATH = "/api/acryl-workspace/pick-folder";
|
|
3
|
+
/** What the chooser answered: the picked absolute path, or null when it was cancelled. */
|
|
4
|
+
export interface PickFolderView {
|
|
5
|
+
readonly path: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** HTTP status the route uses when this machine has no native chooser (a headless Linux box, say). */
|
|
8
|
+
export declare const PICK_FOLDER_UNAVAILABLE_STATUS = 501;
|
|
9
|
+
export declare function parsePickFolderView(value: unknown): PickFolderView;
|