@acrylblends/blends-frame 0.0.0-stage → 0.1.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 +105 -2
- package/cordis.patch.yml +3 -0
- package/lib/app-generation.d.ts +38 -0
- package/lib/app-generation.js +102 -0
- package/lib/app-generation.js.map +1 -0
- package/lib/app-plugins.d.ts +118 -0
- package/lib/app-reload.d.ts +73 -0
- package/lib/app-snapshot.d.ts +40 -0
- package/lib/app-urls.d.ts +17 -0
- package/lib/auto-save.d.ts +63 -0
- package/lib/branch-chats.d.ts +37 -0
- package/lib/client.js +18899 -0
- package/lib/client.js.map +1 -0
- package/lib/contract.d.ts +293 -0
- package/lib/git-sync.d.ts +52 -0
- package/lib/index.d.ts +169 -0
- package/lib/index.js +2923 -0
- package/lib/index.js.map +1 -0
- package/lib/outward-guard.d.ts +45 -0
- package/lib/real-chats.d.ts +42 -0
- package/lib/selection-context.d.ts +118 -0
- package/lib/tool-call-guard.d.ts +104 -0
- package/lib/types/client/BlendsFrame.d.ts +46 -0
- package/lib/types/client/FileView.d.ts +8 -0
- package/lib/types/client/FilesView.d.ts +17 -0
- package/lib/types/client/GitView.d.ts +18 -0
- package/lib/types/client/LeftPanel.d.ts +71 -0
- package/lib/types/client/PluginsSection.d.ts +7 -0
- package/lib/types/client/RemoteSync.d.ts +17 -0
- package/lib/types/client/RightPanel.d.ts +45 -0
- package/lib/types/client/SelectionChip.d.ts +59 -0
- package/lib/types/client/SettingsLauncher.d.ts +9 -0
- package/lib/types/client/ShortcutsRow.d.ts +15 -0
- package/lib/types/client/TerminalView.d.ts +7 -0
- package/lib/types/client/TurnSaveFooter.d.ts +18 -0
- package/lib/types/client/app-reload.d.ts +28 -0
- package/lib/types/client/branch-chats.d.ts +71 -0
- package/lib/types/client/branches.d.ts +23 -0
- package/lib/types/client/canvas/AppCanvas.d.ts +25 -0
- package/lib/types/client/canvas/app-canvas.d.ts +59 -0
- package/lib/types/client/canvas/picker.d.ts +27 -0
- package/lib/types/client/chat-draft.d.ts +15 -0
- package/lib/types/client/chat-saves.d.ts +28 -0
- package/lib/types/client/chats.d.ts +182 -0
- package/lib/types/client/feedback.d.ts +21 -0
- package/lib/types/client/frame-state.d.ts +34 -0
- package/lib/types/client/frame-view.d.ts +35 -0
- package/lib/types/client/fuzzy.d.ts +23 -0
- package/lib/types/client/git-sync.d.ts +39 -0
- package/lib/types/client/highlight.d.ts +15 -0
- package/lib/types/client/index.d.ts +23 -0
- package/lib/types/client/panel-resize.d.ts +29 -0
- package/lib/types/client/plugins-navigator.d.ts +51 -0
- package/lib/types/client/selection.d.ts +56 -0
- package/lib/types/client/sidebar-opens.d.ts +36 -0
- package/lib/types/client/snapshot.d.ts +11 -0
- package/lib/types/client/styles.d.ts +3 -0
- package/lib/types/client/switch-request.d.ts +18 -0
- package/lib/types/client/tab-sizing.d.ts +31 -0
- package/lib/types/client/tabs.d.ts +139 -0
- package/lib/types/client/tools.d.ts +15 -0
- package/lib/types/client/versions.d.ts +34 -0
- package/lib/types/client/view-state.d.ts +42 -0
- package/lib/types/contract.d.ts +293 -0
- package/package.json +122 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** A terminal or PTY agent tab's screen: the live session moved into the panel while the tab is shown, moved out (not ended) when it is not. */
|
|
2
|
+
import type { TerminalRegistry } from '@acrylblends/workspace/ui';
|
|
3
|
+
export interface TerminalViewProps {
|
|
4
|
+
readonly terminals: TerminalRegistry;
|
|
5
|
+
readonly terminalId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function TerminalView({ terminals, terminalId }: TerminalViewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The line under a chat answer that changed the app: "edited src/routes.ts, src/board.ts · saved as v7" (docs/design/blends-frame-mockup.html,
|
|
3
|
+
* scenario 2). DSH draws it in the `conversation.chat.turnTail` slot, before the answer's action row, once per completed turn.
|
|
4
|
+
*/
|
|
5
|
+
import { ChatSavesStore } from './chat-saves.ts';
|
|
6
|
+
/** The turn as the slot hands it over: the number the Host saved it under, and whether it has ended. */
|
|
7
|
+
export interface TurnSaveFooterProps {
|
|
8
|
+
readonly sessionId: string;
|
|
9
|
+
readonly turn: {
|
|
10
|
+
readonly turn: number;
|
|
11
|
+
readonly status: 'open' | 'closed' | 'unknown';
|
|
12
|
+
readonly end?: {
|
|
13
|
+
readonly time?: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
readonly chatSaves: ChatSavesStore;
|
|
17
|
+
}
|
|
18
|
+
export declare function TurnSaveFooter({ sessionId, turn, chatSaves }: TurnSaveFooterProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's code, as the Host runs it (`../app-reload.ts`): the page asks the Host to answer when it changes and reloads the canvas when a new
|
|
3
|
+
* generation of the app is up, so a version gone back to, a file the chat wrote or a line typed in an editor shows without a click. The ask is held by the
|
|
4
|
+
* Host until something changes (a long poll), so there is no timer to wait on. A load the Host refused (a syntax error) leaves the canvas as it is and
|
|
5
|
+
* is kept here for the bar to say.
|
|
6
|
+
*/
|
|
7
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
8
|
+
/** What the bar shows: why the app was not loaded again, or nothing. */
|
|
9
|
+
export interface AppReloadSnapshot {
|
|
10
|
+
readonly error: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare class AppReloadStore {
|
|
13
|
+
/** Called when the app's code was loaded again: the canvas reloads. */
|
|
14
|
+
private readonly onReloaded;
|
|
15
|
+
private readonly fetchImpl;
|
|
16
|
+
private readonly delay;
|
|
17
|
+
private snapshot;
|
|
18
|
+
private readonly listeners;
|
|
19
|
+
constructor(
|
|
20
|
+
/** Called when the app's code was loaded again: the canvas reloads. */
|
|
21
|
+
onReloaded: () => void, fetchImpl?: FetchLike, delay?: (ms: number, signal: AbortSignal) => Promise<void>);
|
|
22
|
+
getSnapshot(): AppReloadSnapshot;
|
|
23
|
+
subscribe(listener: () => void): () => void;
|
|
24
|
+
/** Follow the Host until `signal` aborts: the first answer says where the app is, each later one is a change. */
|
|
25
|
+
run(signal: AbortSignal): Promise<void>;
|
|
26
|
+
private setError;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which branch each chat belongs to, and which chats are open, as the Host remembers them, and the frame's copy: the one source of truth for both.
|
|
3
|
+
* DSH knows no branches. A chat is recorded once - when the frame makes it, or when it is first seen with a turn - and never moved by a later switch.
|
|
4
|
+
* A chat is open while it has a tab or is on screen; the left panel lists only the open ones and the rest wait in the chat's History.
|
|
5
|
+
*/
|
|
6
|
+
import { type BranchChatsView } from '../contract.ts';
|
|
7
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
8
|
+
export interface BranchChatsApi {
|
|
9
|
+
/** The recorded map and open chats. @throws when the Host does not answer it. */
|
|
10
|
+
read(): Promise<BranchChatsView>;
|
|
11
|
+
/** Record a chat's branch. @throws when the Host refuses it (the caller tries again later). */
|
|
12
|
+
assign(id: string, branch: string): Promise<void>;
|
|
13
|
+
/** Open or close one chat. @throws when the Host refuses it. */
|
|
14
|
+
setOpen(id: string, open: boolean): Promise<void>;
|
|
15
|
+
/** Decide which chats are open, when the Host has no decision yet. @throws when the Host refuses it. */
|
|
16
|
+
initOpen(ids: readonly string[]): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createBranchChatsApi(fetcher?: FetchLike): BranchChatsApi;
|
|
19
|
+
/** The map as the panels read it: a chat id to the branch it was opened on, and the chats that are open. */
|
|
20
|
+
export interface BranchChatsPort {
|
|
21
|
+
getSnapshot(): Readonly<Record<string, string>>;
|
|
22
|
+
/** The chats that are open; empty until the Host's decision is known (`isOpenKnown`). */
|
|
23
|
+
getOpen(): ReadonlySet<string>;
|
|
24
|
+
/** Whether the open chats are decided; until then every chat counts as open. */
|
|
25
|
+
isOpenKnown(): boolean;
|
|
26
|
+
subscribe(listener: () => void): () => void;
|
|
27
|
+
}
|
|
28
|
+
export declare class BranchChatsStore implements BranchChatsPort {
|
|
29
|
+
private readonly api;
|
|
30
|
+
private chats;
|
|
31
|
+
/** The open chats; undefined until the Host's list is read, and while the Host has none (nobody decided yet). */
|
|
32
|
+
private open;
|
|
33
|
+
private readonly pending;
|
|
34
|
+
private readonly listeners;
|
|
35
|
+
private loaded;
|
|
36
|
+
constructor(api: BranchChatsApi);
|
|
37
|
+
getSnapshot(): Readonly<Record<string, string>>;
|
|
38
|
+
getOpen(): ReadonlySet<string>;
|
|
39
|
+
/** Whether the open chats are decided (by the Host's record, or by `initOpen`): until then the frame lists and opens nothing by it. */
|
|
40
|
+
isOpenKnown(): boolean;
|
|
41
|
+
isOpen(id: string): boolean;
|
|
42
|
+
subscribe(listener: () => void): () => void;
|
|
43
|
+
/** Whether the Host's map has been read: until then a chat that looks unrecorded may only be one the frame has not heard about. */
|
|
44
|
+
isLoaded(): boolean;
|
|
45
|
+
/** Read what the Host remembers; a failed read keeps the map the frame has and is tried again by the next call. */
|
|
46
|
+
load(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Put every chat that is not recorded yet on `branch`, the checked-out one when it was first seen. The map shows the assignment at once (the
|
|
49
|
+
* panel lists the chat under its branch while the Host write runs); a refused write is dropped so the next look tries again.
|
|
50
|
+
*/
|
|
51
|
+
adopt(ids: readonly string[], branch: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Decide which chats are open, when the Host has no decision (and this page none): the set shows at once and is written once. A set already
|
|
54
|
+
* known is kept, so a second page or a second call changes nothing.
|
|
55
|
+
*/
|
|
56
|
+
initOpen(ids: readonly string[]): void;
|
|
57
|
+
/** Open or close one chat: shown at once, written to the Host; a write the Host refuses puts the chat back as it was. */
|
|
58
|
+
setOpen(id: string, open: boolean): void;
|
|
59
|
+
private publish;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Chat history as the History list shows it (mockup scenario 5): one group per branch, the checked-out branch first and the others by name,
|
|
63
|
+
* each keeping the rows' own order; a chat no branch was recorded for yet comes last, under no name.
|
|
64
|
+
*/
|
|
65
|
+
export declare function historyGroups<Row extends {
|
|
66
|
+
readonly id: string;
|
|
67
|
+
}>(rows: readonly Row[], assignments: Readonly<Record<string, string>>, checkedOut: string | undefined): {
|
|
68
|
+
readonly branch: string | undefined;
|
|
69
|
+
readonly rows: readonly Row[];
|
|
70
|
+
}[];
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The left panel's branch calls to the Host - a new branch ("New"), and moving to an existing one - and what a click on a branch row means.
|
|
3
|
+
* A switch never throws the person's work away: with unsaved files the panel asks first and offers a save point.
|
|
4
|
+
*/
|
|
5
|
+
import { type FrameBranch } from '../contract.ts';
|
|
6
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
7
|
+
export interface BranchesApi {
|
|
8
|
+
/** Rejects with the Host's reason (a taken name, a name git refuses). */
|
|
9
|
+
create(name: string): Promise<void>;
|
|
10
|
+
/** Move the app's folder to an existing local branch. Rejects with the Host's reason (git's own line). */
|
|
11
|
+
switchTo(name: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** What a click on a branch row does. */
|
|
14
|
+
export type BranchClick = 'toggle' | 'switch' | 'ask';
|
|
15
|
+
/**
|
|
16
|
+
* The current branch opens or closes what is running on it; another branch is switched to, and with unsaved files the person is asked first
|
|
17
|
+
* (save a point, or cancel). Only a state that says zero unsaved files switches at once: a state that could not count them asks.
|
|
18
|
+
*/
|
|
19
|
+
export declare function branchClick(branch: FrameBranch, unsaved: number | undefined): BranchClick;
|
|
20
|
+
/** The version's subject when a switch saves the person's work first. */
|
|
21
|
+
export declare function saveBeforeSwitchMessage(name: string): string;
|
|
22
|
+
export declare function createBranchesApi(fetcher?: FetchLike): BranchesApi;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The centre: the app's own page in one frame. A navigation or a reload mounts a NEW frame; a frame is never re-pointed (section 30). */
|
|
2
|
+
import type { SelectedElement } from '../selection.ts';
|
|
3
|
+
import type { AppCanvasState } from './app-canvas.ts';
|
|
4
|
+
export interface AppCanvasProps {
|
|
5
|
+
readonly canvas: AppCanvasState;
|
|
6
|
+
/** The frame's select control is on: clicks in the app pick an element instead of acting on the app. */
|
|
7
|
+
readonly picking?: boolean;
|
|
8
|
+
/** One element was picked. */
|
|
9
|
+
readonly onPick?: (element: SelectedElement) => void;
|
|
10
|
+
/** Escape left the picker. */
|
|
11
|
+
readonly onCancel?: () => void;
|
|
12
|
+
/** The pick belongs to a page the canvas no longer shows: the frame lets the selection go with it. */
|
|
13
|
+
readonly onStaleSelection?: () => void;
|
|
14
|
+
/** The element the chat has selected: outlined while it is on the page shown. */
|
|
15
|
+
readonly selected?: SelectedElement | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** The page a loaded app document shows; undefined while the frame is still the browser's initial about:blank. */
|
|
18
|
+
export declare function appPage(doc: {
|
|
19
|
+
readonly location: {
|
|
20
|
+
readonly href: string;
|
|
21
|
+
readonly pathname: string;
|
|
22
|
+
readonly search: string;
|
|
23
|
+
};
|
|
24
|
+
}): string | undefined;
|
|
25
|
+
export declare function AppCanvas({ canvas, picking, onPick, onCancel, onStaleSelection, selected }: AppCanvasProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app page the canvas shows, and the calls a person or the agent may make on it (docs/plans/ide-host-inversion.md section 31, boundary A).
|
|
3
|
+
*
|
|
4
|
+
* The canvas is a value, not a surface: the React component renders whatever this state says, and a navigation or a reload is a new address or a
|
|
5
|
+
* new attempt, which makes a NEW frame. A frame is never re-pointed at another address - that is what let a late load from an earlier address pass
|
|
6
|
+
* for this one's answer and replace a live app page (section 30) - and nothing here reloads on its own: only `navigate` and `reload`, which only a
|
|
7
|
+
* person or the door calls.
|
|
8
|
+
*/
|
|
9
|
+
/** The key the door publishes `{ windowId }` on the page's window (plugins/acryl-door/src/page/index.ts, `PAGE_KEY`). */
|
|
10
|
+
export declare const DOOR_PAGE_KEY: symbol;
|
|
11
|
+
export interface AppCanvasView {
|
|
12
|
+
/** The absolute address of the app's own page, or undefined when the Host serves none. */
|
|
13
|
+
readonly address: string | undefined;
|
|
14
|
+
/** How many reloads were asked for; each mounts a fresh frame at the same address. */
|
|
15
|
+
readonly attempt: number;
|
|
16
|
+
/** The last load the component saw, with whether the document was readable (a same-origin app page always is). */
|
|
17
|
+
readonly loaded: {
|
|
18
|
+
readonly address: string;
|
|
19
|
+
readonly readable: boolean;
|
|
20
|
+
} | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface AppCanvas {
|
|
23
|
+
/** The address the canvas shows, absolute; undefined when the Host serves no app. */
|
|
24
|
+
address(): string | undefined;
|
|
25
|
+
/** Point the canvas at a path on the frame's origin. Called by a person or the door, never by the frame itself. */
|
|
26
|
+
navigate(path: string): void;
|
|
27
|
+
/** Reload the app page. Called by a person or the door. */
|
|
28
|
+
reload(): void;
|
|
29
|
+
/** Called after every change of address, attempt or load. */
|
|
30
|
+
subscribe(listener: () => void): () => void;
|
|
31
|
+
/** The door's page window id of the canvas page, when its script has published one. */
|
|
32
|
+
pageWindow(): string | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** The canvas as the frame renders it; one instance per client plugin lifetime. */
|
|
35
|
+
export declare class AppCanvasState implements AppCanvas {
|
|
36
|
+
private addressValue;
|
|
37
|
+
private attemptValue;
|
|
38
|
+
private loadedValue;
|
|
39
|
+
private frame;
|
|
40
|
+
private snapshot;
|
|
41
|
+
private readonly listeners;
|
|
42
|
+
/** Set once, from the Host's answer: the app's own page. */
|
|
43
|
+
setAddress(address: string | undefined): void;
|
|
44
|
+
address(): string | undefined;
|
|
45
|
+
navigate(path: string): void;
|
|
46
|
+
reload(): void;
|
|
47
|
+
attempt(): number;
|
|
48
|
+
/** The component hands its frame over, so `pageWindow` reads the live page. */
|
|
49
|
+
attach(frame: HTMLIFrameElement | null): void;
|
|
50
|
+
/** The component reports a load; subscribers see the address it was for. */
|
|
51
|
+
reportLoad(address: string, readable: boolean): void;
|
|
52
|
+
pageWindow(): string | undefined;
|
|
53
|
+
/** The live app page's window, when the canvas has one: the frame's view contract reaches the page through it. */
|
|
54
|
+
contentWindow(): Window | undefined;
|
|
55
|
+
/** The identity `useSyncExternalStore` compares. */
|
|
56
|
+
getSnapshot(): AppCanvasView;
|
|
57
|
+
subscribe(listener: () => void): () => void;
|
|
58
|
+
private emit;
|
|
59
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frame's element picker over the app canvas (docs/design/blends-frame-mockup.html, scenario 2). The app's page is same-origin under
|
|
3
|
+
* `/app`, so the frame reads and decorates the app's own document: the element under the pointer is outlined, a click picks it and does
|
|
4
|
+
* nothing else, and Escape leaves the picker.
|
|
5
|
+
*/
|
|
6
|
+
import { type SelectedElement } from '../selection.ts';
|
|
7
|
+
export interface CanvasPickerHandlers {
|
|
8
|
+
/** One element was clicked while picking. */
|
|
9
|
+
onPick(element: SelectedElement): void;
|
|
10
|
+
/** Escape left the picker; the frame turns its select control off. */
|
|
11
|
+
onCancel(): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Attach the picker to one app document.
|
|
15
|
+
* @param doc - the app page's document, same-origin with the frame.
|
|
16
|
+
* @param handlers - what a click and Escape mean to the frame.
|
|
17
|
+
* @returns a disposer that removes every listener and the outline, and restores the app's cursor.
|
|
18
|
+
*/
|
|
19
|
+
export declare function attachPicker(doc: Document, handlers: CanvasPickerHandlers): () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Mark the element the chat has selected (scenario 2: the picked card stays outlined while it is the selection). The mark follows the element as the
|
|
22
|
+
* page scrolls or resizes, and is gone when the element is.
|
|
23
|
+
* @param doc - the app page's document.
|
|
24
|
+
* @param selector - the selection's selector ({@link SelectedElement.selector}).
|
|
25
|
+
* @returns a disposer that removes the mark and its listeners.
|
|
26
|
+
*/
|
|
27
|
+
export declare function markSelected(doc: Document, selector: string): () => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writing into the chat's composer: DSH's conversation input for a session (`conversation.input.for(scope).setDraft`), the same seam
|
|
3
|
+
* `@acryl/ui`'s `acrylChat.notice` uses. The services are read at the call and checked, so a page without a chat answers false.
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
/** Put `text` in the composer of chat `sessionId` and focus it. @returns false when this page holds no composer for that chat. */
|
|
7
|
+
export declare function draftInChat(ctx: Context, sessionId: string, text: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Attach one browser file to a chat's composer as DSH's own draft attachment, so the composer shows it and sending includes it.
|
|
10
|
+
* @param ctx - the frame's client context.
|
|
11
|
+
* @param sessionId - the chat to attach it to.
|
|
12
|
+
* @param file - the browser file (an image keeps its type and bytes for the model).
|
|
13
|
+
* @returns false when the page holds no attachment intake or no composer for that chat.
|
|
14
|
+
*/
|
|
15
|
+
export declare function attachDraft(ctx: Context, sessionId: string, file: File): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each chat turn saved (the Host's auto-save, `../auto-save.ts`): the line under an answer, "edited src/routes.ts, src/board.ts · saved as v7".
|
|
3
|
+
* The Host makes the version a moment after the turn ends, so a turn that has just closed asks again a few times before it concludes there was none.
|
|
4
|
+
*/
|
|
5
|
+
import { type TurnSaveView } from '../contract.ts';
|
|
6
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
7
|
+
export interface ChatSavesApi {
|
|
8
|
+
read(session: string): Promise<readonly TurnSaveView[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createChatSavesApi(fetcher?: FetchLike): ChatSavesApi;
|
|
11
|
+
/** "edited src/routes.ts, src/board.ts · saved as v7". */
|
|
12
|
+
export declare function saveLine(save: Pick<TurnSaveView, 'files' | 'version'>): string;
|
|
13
|
+
/** When a closed turn with no save yet asks again, after these many milliseconds each: the version lands a moment after the turn's last event. */
|
|
14
|
+
export declare const SAVE_RETRY_MS: readonly number[];
|
|
15
|
+
export declare class ChatSavesStore {
|
|
16
|
+
private readonly api;
|
|
17
|
+
private readonly onSaved;
|
|
18
|
+
private readonly saves;
|
|
19
|
+
private readonly asked;
|
|
20
|
+
private readonly listeners;
|
|
21
|
+
/** `onSaved` is told when a read brings a save the page had not seen: the versions and the unsaved count have changed with it. */
|
|
22
|
+
constructor(api: ChatSavesApi, onSaved?: () => void);
|
|
23
|
+
getSnapshot(session: string): readonly TurnSaveView[];
|
|
24
|
+
subscribe(listener: () => void): () => void;
|
|
25
|
+
/** Read the chat's saves; reads that overlap share one request. A failed read keeps what was shown. */
|
|
26
|
+
refresh(session: string): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chats as the frame lists them: DSH's sessions, newest first, the one DSH's main view retains marked current. Opening one asks DSH's own
|
|
3
|
+
* navigation (`uiWorkspace`) when it is composed, so DSH stays the one owner of which session is shown (the reason is in acryl-workspace's
|
|
4
|
+
* `sessions/main-session.ts`); without it, the frame holds the main-view reference itself.
|
|
5
|
+
*
|
|
6
|
+
* Which branch a chat belongs to, and which chats are open, is the branch-chats record (`./branch-chats.ts`), the one source of truth. The rule this
|
|
7
|
+
* store keeps: the chat on screen always belongs to the checked-out branch (docs/design/blends-frame-mockup.html, scenarios 2 and 5). Whatever
|
|
8
|
+
* moves the folder to another branch - the left panel, the New button, the Git tab, a terminal - the chat on screen then becomes that branch's own
|
|
9
|
+
* (`decideChat`). A chat is open while it has a tab or is on screen: the left panel lists only those, and the rest are closed, found in History.
|
|
10
|
+
*/
|
|
11
|
+
import type { ISessions, SessionListState } from '@acrylblends/ui/frame';
|
|
12
|
+
import { type RealChatView } from '../contract.ts';
|
|
13
|
+
import type { BranchChatsStore } from './branch-chats.ts';
|
|
14
|
+
import type { ChatRow, ChatsPort } from './LeftPanel.tsx';
|
|
15
|
+
import { type FrameTabs } from './tabs.ts';
|
|
16
|
+
type SessionId = Parameters<ISessions['retain']>[0];
|
|
17
|
+
/** The options DSH's session creation takes (the workspace it belongs to is one of them). */
|
|
18
|
+
type SessionCreateOptions = NonNullable<Parameters<ISessions['create']>[0]>;
|
|
19
|
+
type WorkspaceId = NonNullable<SessionCreateOptions['workspaceId']>;
|
|
20
|
+
export interface MainViewNavigation {
|
|
21
|
+
openSession(target: SessionId): void;
|
|
22
|
+
}
|
|
23
|
+
/** The share of DSH's `workspaces` service used here: register a folder as a workspace, so a chat made in it is bound to it. */
|
|
24
|
+
export interface WorkspaceRegistration {
|
|
25
|
+
create(input: {
|
|
26
|
+
readonly path: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
readonly workspaceId: WorkspaceId;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
/** A chat's name: its own title once it has one, else "New chat" (DSH's display title falls back to the project folder's name, which names no chat). */
|
|
32
|
+
/** What a chat with no title of its own is called. */
|
|
33
|
+
export declare const NEW_CHAT = "New chat";
|
|
34
|
+
export declare function chatTitle(row: {
|
|
35
|
+
readonly title?: string | null;
|
|
36
|
+
}): string;
|
|
37
|
+
export declare function chatRows(list: SessionListState): ChatRow[];
|
|
38
|
+
/**
|
|
39
|
+
* The rows the left panel lists: a chat with no turn is not a chat, except the one open right now (it is where the next message goes). A chat that is
|
|
40
|
+
* running is real by definition. `real` is the Host's list of chats with a turn; until it has been read, only the open chat shows.
|
|
41
|
+
*/
|
|
42
|
+
export declare function visibleChats(rows: readonly ChatRow[], real: ReadonlyMap<string, string>, running?: ReadonlySet<string>): ChatRow[];
|
|
43
|
+
/** What the store does to make the chat on screen the checked-out branch's. */
|
|
44
|
+
export type ChatDecision = {
|
|
45
|
+
readonly action: 'none';
|
|
46
|
+
}
|
|
47
|
+
/** Show this chat of the branch. */
|
|
48
|
+
| {
|
|
49
|
+
readonly action: 'open';
|
|
50
|
+
readonly id: string;
|
|
51
|
+
}
|
|
52
|
+
/** Record this chat (the one on screen) as the branch's: it was made elsewhere and no branch is recorded for it yet. */
|
|
53
|
+
| {
|
|
54
|
+
readonly action: 'adopt';
|
|
55
|
+
readonly id: string;
|
|
56
|
+
}
|
|
57
|
+
/** The branch has no chat to show: make one. */
|
|
58
|
+
| {
|
|
59
|
+
readonly action: 'create';
|
|
60
|
+
};
|
|
61
|
+
export interface ChatsView {
|
|
62
|
+
/** DSH's sessions, newest first. */
|
|
63
|
+
readonly rows: readonly ChatRow[];
|
|
64
|
+
/** The chats with a turn (the Host's list). */
|
|
65
|
+
readonly real: ReadonlyMap<string, string>;
|
|
66
|
+
readonly running: ReadonlySet<string>;
|
|
67
|
+
/** Chat id to branch: the branch-chats map. */
|
|
68
|
+
readonly assignments: Readonly<Record<string, string>>;
|
|
69
|
+
readonly branch: string;
|
|
70
|
+
/** The chat a tab of the strip asks for on this branch, shown instead of the branch's newest. */
|
|
71
|
+
readonly preferred?: string | undefined;
|
|
72
|
+
/** The chats that are open; a closed chat is never the branch's to show. Undefined: no chat is closed. */
|
|
73
|
+
readonly open?: ReadonlySet<string> | undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The chat the checked-out branch shows: the tab's chat when it is the branch's, else its newest open chat with a turn, else one of its open chats
|
|
77
|
+
* still blank. Undefined when the branch has none open (its closed chats stay in History).
|
|
78
|
+
*/
|
|
79
|
+
export declare function branchChat(view: ChatsView, exclude?: ReadonlySet<string>): ChatRow | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* The chats that are open when nobody decided yet (an app that already has many chats, or one from before chats could be closed): the latest chat with
|
|
82
|
+
* a turn of each branch, the chat on screen, and the chats that already have a tab. Everything else is closed, found in History.
|
|
83
|
+
*/
|
|
84
|
+
export declare function initialOpenChats(view: Pick<ChatsView, 'rows' | 'real' | 'running' | 'assignments'>, tabbed?: ReadonlySet<string>): string[];
|
|
85
|
+
/**
|
|
86
|
+
* The chat on screen against the checked-out branch. One that belongs to the branch stays (unless a tab of the strip asks for another of the
|
|
87
|
+
* branch's). One recorded for another branch gives way to this branch's own chat, or a new one. One no branch is recorded for is the branch's
|
|
88
|
+
* own when it has a turn (it was made before anything was recorded) or when the branch has no chat yet; otherwise it is a stray blank session DSH
|
|
89
|
+
* made on load, and the branch's own chat is shown instead, so a load never piles up another empty chat. Nothing on screen yet: the branch's own
|
|
90
|
+
* chat if it has one, else DSH's choice.
|
|
91
|
+
*/
|
|
92
|
+
export declare function decideChat(view: ChatsView): ChatDecision;
|
|
93
|
+
export interface RealChatsApi {
|
|
94
|
+
read(): Promise<readonly RealChatView[]>;
|
|
95
|
+
}
|
|
96
|
+
export declare function createRealChatsApi(fetcher?: (input: string, init?: RequestInit) => Promise<Response>): RealChatsApi;
|
|
97
|
+
export interface ChatsDeps {
|
|
98
|
+
readonly navigation: () => MainViewNavigation | undefined;
|
|
99
|
+
readonly workspaceFor?: () => WorkspaceRegistration | undefined;
|
|
100
|
+
readonly realChats?: RealChatsApi;
|
|
101
|
+
/** The map of chat to branch: the one source of truth, read here and written once per chat. */
|
|
102
|
+
readonly branchChats?: BranchChatsStore;
|
|
103
|
+
/** The checked-out branch; undefined outside a repository (no branch to keep a chat for). */
|
|
104
|
+
readonly branch?: () => string | undefined;
|
|
105
|
+
/** The app's folder, where a chat made by the frame works. */
|
|
106
|
+
readonly appRoot?: () => string | undefined;
|
|
107
|
+
/** The chat the strip's active tab asks for on the checked-out branch, if it is a tab of one. */
|
|
108
|
+
readonly preferred?: () => string | undefined;
|
|
109
|
+
/** The right panel's strip: a chat opened from a list gets a tab of its own, unless it is the one the base tab shows. */
|
|
110
|
+
readonly tabs?: FrameTabs;
|
|
111
|
+
}
|
|
112
|
+
export declare class ChatsStore implements ChatsPort {
|
|
113
|
+
private readonly deps;
|
|
114
|
+
private rows;
|
|
115
|
+
private sessions;
|
|
116
|
+
private held;
|
|
117
|
+
private readonly listeners;
|
|
118
|
+
private all;
|
|
119
|
+
private real;
|
|
120
|
+
private realLoaded;
|
|
121
|
+
private running;
|
|
122
|
+
private reading;
|
|
123
|
+
private scheduled;
|
|
124
|
+
private again;
|
|
125
|
+
private creating;
|
|
126
|
+
/** The chat `open` last asked DSH for, until DSH shows it (see `reconcile`). */
|
|
127
|
+
private pending;
|
|
128
|
+
constructor(deps: ChatsDeps);
|
|
129
|
+
getSnapshot(): readonly ChatRow[];
|
|
130
|
+
subscribe(listener: () => void): () => void;
|
|
131
|
+
/** Follow `sessions` until the returned disposer runs (the service's fiber ends). */
|
|
132
|
+
watch(sessions: ISessions): () => void;
|
|
133
|
+
open(id: string): void;
|
|
134
|
+
/**
|
|
135
|
+
* Make the chat on screen the checked-out branch's (`decideChat`). Called whenever anything it depends on changes: the branch, the sessions, the
|
|
136
|
+
* chats with a turn, the branch-chats map, the strip's tab. It acts only once the map and the Host's chat list have been read: before that a
|
|
137
|
+
* chat that looks unrecorded may only be one the frame has not heard about, and recording it would put it on the wrong branch.
|
|
138
|
+
*/
|
|
139
|
+
reconcile(): void;
|
|
140
|
+
private decide;
|
|
141
|
+
/**
|
|
142
|
+
* Every open chat of the checked-out branch has a tab of its own, except the one the base tab shows (the newest of those without): the open set is
|
|
143
|
+
* remembered by the Host, the strip by the page, so a page that has not seen a chat open gets its tab here.
|
|
144
|
+
*/
|
|
145
|
+
private tabOpenChats;
|
|
146
|
+
/** The chats that have a tab of their own. */
|
|
147
|
+
private tabbed;
|
|
148
|
+
/**
|
|
149
|
+
* A new chat on the checked-out branch, shown at once: a DSH session made on the Host and recorded for the branch before anything else can see
|
|
150
|
+
* it. Undefined without the sessions service or outside a branch. A second call while one runs gets the same chat.
|
|
151
|
+
*/
|
|
152
|
+
create(): Promise<string | undefined>;
|
|
153
|
+
private make;
|
|
154
|
+
/**
|
|
155
|
+
* "+ then Chat": a chat of its own on the checked-out branch. The chat on screen is reused when it has no turn yet (it is already a new chat), so
|
|
156
|
+
* the strip never fills with empty ones; @returns its id and whether it was made now. Undefined when no chat could be made.
|
|
157
|
+
*/
|
|
158
|
+
startChat(): Promise<{
|
|
159
|
+
readonly id: string;
|
|
160
|
+
readonly made: boolean;
|
|
161
|
+
} | undefined>;
|
|
162
|
+
/**
|
|
163
|
+
* The base tab's chat: the checked-out branch's newest open chat that has no tab of its own, shown; a new chat when the branch has none open.
|
|
164
|
+
*/
|
|
165
|
+
openPrimary(exclude: ReadonlySet<string>): void;
|
|
166
|
+
private openSet;
|
|
167
|
+
/**
|
|
168
|
+
* Open a chat of the checked-out branch from a list (History): a closed chat is open from now on, as a tab of its own; either way it is shown.
|
|
169
|
+
*/
|
|
170
|
+
show(id: string): void;
|
|
171
|
+
/**
|
|
172
|
+
* Close a chat (its tab's x): it leaves the open chats and waits in History. When it is the chat on screen the view moves off it first: to `prefer`
|
|
173
|
+
* (the chat of the tab the strip shows now), else the base tab's chat (the branch's newest open chat that has no tab of its own, among all but
|
|
174
|
+
* `tabbed`), else a new chat.
|
|
175
|
+
*/
|
|
176
|
+
closeChat(id: string, tabbed: ReadonlySet<string>, prefer?: string): void;
|
|
177
|
+
/** Ask the Host which chats have a turn; a read that comes in while one runs asks once more afterwards, and a failed read keeps what was known. */
|
|
178
|
+
private refreshReal;
|
|
179
|
+
private publishVisible;
|
|
180
|
+
private publish;
|
|
181
|
+
}
|
|
182
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feedback from users in the left panel (docs/design/blends-frame-mockup.html, scenario 9): the notes people sent from the app (its `feedback`
|
|
3
|
+
* plugin), read from the frame's Host, and the task a note becomes when the builder hands it to an agent.
|
|
4
|
+
*/
|
|
5
|
+
import { type FeedbackNoteView, type FeedbackView } from '../contract.ts';
|
|
6
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
7
|
+
export interface FeedbackApi {
|
|
8
|
+
read(): Promise<FeedbackView>;
|
|
9
|
+
markSeen(ids: readonly string[]): Promise<void>;
|
|
10
|
+
/** The frame-served screenshot of one note (same origin, so the panel and the hand-off can read it). */
|
|
11
|
+
shotUrl(id: string): string;
|
|
12
|
+
}
|
|
13
|
+
export declare function createFeedbackApi(fetcher?: FetchLike): FeedbackApi;
|
|
14
|
+
/** The page a note came from, as a heading: "Home page" for the app's root, else its last path part. */
|
|
15
|
+
export declare function feedbackPlace(note: Pick<FeedbackNoteView, 'page'>, mount?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* The task an agent gets for a note. The note is what a person typed into the app, so it goes in quoted, as data: the builder reads the task in
|
|
18
|
+
* the composer and sends it, nothing runs on its own.
|
|
19
|
+
*/
|
|
20
|
+
export declare function feedbackTask(note: FeedbackNoteView): string;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the frame shows around the app, from the Host's state route. The frame reads it again while the page is visible, so a version an agent saves
|
|
3
|
+
* or a file it changes shows without a reload; a failed re-read keeps what is shown, and an unchanged answer tells no one.
|
|
4
|
+
*/
|
|
5
|
+
import { type FrameState } from '../contract.ts';
|
|
6
|
+
export type FrameStateView = {
|
|
7
|
+
readonly status: 'loading';
|
|
8
|
+
} | {
|
|
9
|
+
readonly status: 'ready';
|
|
10
|
+
readonly state: FrameState;
|
|
11
|
+
} | {
|
|
12
|
+
readonly status: 'error';
|
|
13
|
+
readonly message: string;
|
|
14
|
+
};
|
|
15
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
16
|
+
export declare class FrameStateStore {
|
|
17
|
+
private readonly fetchImpl;
|
|
18
|
+
private view;
|
|
19
|
+
private readonly listeners;
|
|
20
|
+
private generation;
|
|
21
|
+
constructor(fetchImpl?: FetchLike);
|
|
22
|
+
getSnapshot(): FrameStateView;
|
|
23
|
+
subscribe(listener: () => void): () => void;
|
|
24
|
+
/** Read the state again; an older answer arriving after a newer request is dropped. */
|
|
25
|
+
refresh(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Read the state now and return it: a decision that would act on the unsaved count (switch a branch, go back to a version) reads it here instead
|
|
28
|
+
* of trusting what the last poll showed. Undefined when this read failed, even though the page keeps showing the last good state.
|
|
29
|
+
*/
|
|
30
|
+
current(): Promise<FrameState | undefined>;
|
|
31
|
+
/** One read of the Host's state, published to the page unless a newer read started meanwhile; returns what this read got. */
|
|
32
|
+
private read;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frame's view of the app page, as the app's own client plugins see it (docs/design/blends-frame-mockup.html): Build is the builder's screen, so the
|
|
3
|
+
* app's build-time controls stay out of the canvas; Preview is what production shows, so the app's production controls render there. The frame owns the
|
|
4
|
+
* mode; the page's plugins read it from this handle, and a mode change reaches them without a reload.
|
|
5
|
+
*
|
|
6
|
+
* The app page is same-origin under `/app`, so the frame publishes the handle on its own window and the page reads it through `window.parent`. The page
|
|
7
|
+
* listens for {@link FRAME_MODE_EVENT} on its own window; `mode` is live, so the event is only the notification. A page opened directly has no such
|
|
8
|
+
* parent and keeps its own behavior (plugins/agent-panel/client/main.ts and plugins/feedback/client.js read the same names).
|
|
9
|
+
*/
|
|
10
|
+
export declare const FRAME_VIEW_KEY: symbol;
|
|
11
|
+
export declare const FRAME_MODE_EVENT = "acryl:frame-mode";
|
|
12
|
+
/** Build hides the app's own build-time controls; Preview shows what production shows. */
|
|
13
|
+
export type AppFrameMode = 'build' | 'preview';
|
|
14
|
+
/** What the app's page reads from `window.parent[FRAME_VIEW_KEY]`. */
|
|
15
|
+
export interface AppFrameView {
|
|
16
|
+
readonly mode: AppFrameMode;
|
|
17
|
+
}
|
|
18
|
+
/** The frame's side of the canvas: the live window of the app page it embeds. */
|
|
19
|
+
export interface FrameHost {
|
|
20
|
+
contentWindow(): Window | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** The part of the frame's view state the handle publishes. */
|
|
23
|
+
export interface FrameViewSource {
|
|
24
|
+
getSnapshot(): {
|
|
25
|
+
readonly mode: AppFrameMode;
|
|
26
|
+
};
|
|
27
|
+
subscribe(listener: () => void): () => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Publish the frame's view and tell the app page whenever the mode changes.
|
|
31
|
+
* @param host - the canvas, whose content window is the app page.
|
|
32
|
+
* @param view - the frame's view state; its `mode` is the published value.
|
|
33
|
+
* @returns a disposer that removes the handle and the subscription.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installFrameView(host: FrameHost, view: FrameViewSource): () => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Fuzzy file search for the Files tab (⌘P): the query's letters in order anywhere in the path, ranked like an editor's quick open. */
|
|
2
|
+
export interface FuzzyMatch {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
/** Indexes into `path` of the letters the query matched, ascending. */
|
|
5
|
+
readonly hits: readonly number[];
|
|
6
|
+
readonly score: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Match `query` against one path, case-insensitively, letters in order. Each matched letter scores; one right after the previous match, at the
|
|
10
|
+
* start of a word, or in the file's own name scores more, a long gap or a long stretch from the first letter to the last scores less, and a
|
|
11
|
+
* shorter path wins a tie. @returns undefined when the letters are not all there.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fuzzyMatch(query: string, path: string): FuzzyMatch | undefined;
|
|
14
|
+
/** The best `limit` matches of `query` over `paths`, best first. */
|
|
15
|
+
export declare function fuzzySearch(query: string, paths: readonly string[], limit?: number): FuzzyMatch[];
|
|
16
|
+
/** A match split for display: the label is the path below its top folder, which is shown apart as the meta. */
|
|
17
|
+
export declare function displayMatch(match: FuzzyMatch): {
|
|
18
|
+
readonly folder: string;
|
|
19
|
+
readonly parts: readonly {
|
|
20
|
+
readonly text: string;
|
|
21
|
+
readonly hit: boolean;
|
|
22
|
+
}[];
|
|
23
|
+
};
|