@lingxi-ai-cn/dsh-tui-runtime 0.1.0-rc.8
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 +109 -0
- package/README.zh.md +109 -0
- package/lib/index.js +10552 -0
- package/lib/invariant.js +9 -0
- package/lib/types/agent-view.d.ts +40 -0
- package/lib/types/app.d.ts +121 -0
- package/lib/types/composer.d.ts +188 -0
- package/lib/types/detail.d.ts +24 -0
- package/lib/types/footer.d.ts +85 -0
- package/lib/types/history-search.d.ts +58 -0
- package/lib/types/host.d.ts +210 -0
- package/lib/types/index.d.ts +60 -0
- package/lib/types/invariant.d.ts +6 -0
- package/lib/types/keybindings.d.ts +165 -0
- package/lib/types/markdown.d.ts +9 -0
- package/lib/types/open-url.d.ts +9 -0
- package/lib/types/plugin-hub.d.ts +158 -0
- package/lib/types/resume.d.ts +66 -0
- package/lib/types/rewind.d.ts +37 -0
- package/lib/types/sanitize.d.ts +9 -0
- package/lib/types/session-export.d.ts +29 -0
- package/lib/types/session-lifecycle.d.ts +20 -0
- package/lib/types/startup-logo.d.ts +45 -0
- package/lib/types/store.d.ts +88 -0
- package/lib/types/suggestion.d.ts +99 -0
- package/lib/types/terminal-input.d.ts +69 -0
- package/lib/types/terminal-session.d.ts +129 -0
- package/lib/types/theme.d.ts +76 -0
- package/lib/types/todo-panel.d.ts +12 -0
- package/lib/types/tool-card.d.ts +24 -0
- package/lib/types/tool-group.d.ts +10 -0
- package/lib/types/transcript-search.d.ts +67 -0
- package/lib/types/transcript-view.d.ts +32 -0
- package/lib/types/transcript.d.ts +159 -0
- package/lib/types/viewport.d.ts +211 -0
- package/lib/types/work-panel.d.ts +28 -0
- package/lib/types/work.d.ts +100 -0
- package/package.json +104 -0
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
/** Package-owned invariant companion for `@lingxi-ai-cn/dsh-tui-runtime`. */
|
|
3
|
+
const PACKAGE_NAME = "@lingxi-ai-cn/dsh-tui-runtime";
|
|
4
|
+
const name = "tui-invariant";
|
|
5
|
+
const inject = ["invariants"];
|
|
6
|
+
const install = () => {};
|
|
7
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
8
|
+
//#endregion
|
|
9
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Process-local single-view Agent navigation state for the native TUI. */
|
|
2
|
+
import type { SessionIdType as SessionId } from './host.ts';
|
|
3
|
+
/** Exact Agent transcript and input target rendered by the native TUI. */
|
|
4
|
+
export interface TuiAgentViewDescriptor {
|
|
5
|
+
/** Whether the view is the owned root or one borrowed local child. */
|
|
6
|
+
readonly kind: 'root' | 'child';
|
|
7
|
+
/** Session and Agent identity whose durable transcript is rendered. */
|
|
8
|
+
readonly id: SessionId;
|
|
9
|
+
/** Concise source-owned label shown in the header. */
|
|
10
|
+
readonly label: string;
|
|
11
|
+
/** Durable direct parent required to authorize child input. */
|
|
12
|
+
readonly parentSession?: SessionId | undefined;
|
|
13
|
+
/** Whether the current view accepts composer input. */
|
|
14
|
+
readonly acceptsInput: boolean;
|
|
15
|
+
/** Exact reason input is unavailable. */
|
|
16
|
+
readonly readOnlyReason?: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Process-local state slots keyed by Agent Session id.
|
|
20
|
+
* @typeParam T - complete disposable UI state owned by one transcript view.
|
|
21
|
+
*/
|
|
22
|
+
export declare class TuiAgentViewStateCache<T> {
|
|
23
|
+
private readonly states;
|
|
24
|
+
/**
|
|
25
|
+
* Save the complete local state of one view.
|
|
26
|
+
* @param id - view Session id.
|
|
27
|
+
* @param state - disposable state to restore on the next visit.
|
|
28
|
+
*/
|
|
29
|
+
set(id: SessionId, state: T): void;
|
|
30
|
+
/**
|
|
31
|
+
* Restore one view or create its initial local state.
|
|
32
|
+
* @param id - view Session id.
|
|
33
|
+
* @param create - initializer used only on the first visit.
|
|
34
|
+
* @returns the cached or newly initialized state.
|
|
35
|
+
*/
|
|
36
|
+
get(id: SessionId, create: () => T): T;
|
|
37
|
+
/** Drop every saved view after the owning TUI lifecycle ends. */
|
|
38
|
+
clear(): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=agent-view.d.ts.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/** Ink component tree for transcript, interactions, composer, and status. */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { Agent, CommandDescriptor, ContextPressureProjection, FsPathCompletionResult, ModelSelection, PermissionSelect } from './host.ts';
|
|
4
|
+
import { AgentStatusStore, InteractionStore, SessionEventStore, ValueStore } from './store.ts';
|
|
5
|
+
import type { InputCursorTarget } from './terminal-session.ts';
|
|
6
|
+
import { type ComposerLayout } from './composer.ts';
|
|
7
|
+
import { type TuiInteractionDescriptor } from './keybindings.ts';
|
|
8
|
+
import { type TuiFooterItemId } from './footer.ts';
|
|
9
|
+
import { type TuiResumeCandidate, type TuiResumeDialogSnapshot } from './resume.ts';
|
|
10
|
+
import type { TuiFreshSessionDialogSnapshot } from './session-lifecycle.ts';
|
|
11
|
+
import type { TuiSessionExportDialogSnapshot } from './session-export.ts';
|
|
12
|
+
import type { TuiRewindCandidate, TuiRewindDialogSnapshot } from './rewind.ts';
|
|
13
|
+
import type { TuiWorkItemView, TuiWorkSnapshot } from './work.ts';
|
|
14
|
+
import { type TuiPluginHubDetailLine, type TuiPluginHubDialogSnapshot } from './plugin-hub.ts';
|
|
15
|
+
import type { PluginId } from '@lingxi-ai-cn/dsh-plugin-hub';
|
|
16
|
+
import { type TuiAgentViewDescriptor } from './agent-view.ts';
|
|
17
|
+
import { type TuiTerminalInputEvent } from './terminal-input.ts';
|
|
18
|
+
import { type TuiTheme } from './theme.tsx';
|
|
19
|
+
import { type TuiStartupLogoVariant } from './startup-logo.tsx';
|
|
20
|
+
export interface TuiAppProps {
|
|
21
|
+
agent: Agent;
|
|
22
|
+
view: TuiAgentViewDescriptor;
|
|
23
|
+
events: SessionEventStore;
|
|
24
|
+
status: AgentStatusStore;
|
|
25
|
+
interactions: InteractionStore;
|
|
26
|
+
externalNotice: ValueStore<string>;
|
|
27
|
+
modelSelection: ValueStore<ModelSelection | undefined>;
|
|
28
|
+
helpOpen: ValueStore<boolean>;
|
|
29
|
+
permissions: ValueStore<PermissionSelect | undefined>;
|
|
30
|
+
contextPressure: ValueStore<ContextPressureProjection | undefined>;
|
|
31
|
+
resumeDialog: ValueStore<TuiResumeDialogSnapshot | undefined>;
|
|
32
|
+
freshSessionDialog: ValueStore<TuiFreshSessionDialogSnapshot | undefined>;
|
|
33
|
+
rewindDialog: ValueStore<TuiRewindDialogSnapshot | undefined>;
|
|
34
|
+
sessionExportDialog: ValueStore<TuiSessionExportDialogSnapshot | undefined>;
|
|
35
|
+
pluginHubDialog: ValueStore<TuiPluginHubDialogSnapshot | undefined>;
|
|
36
|
+
work: ValueStore<TuiWorkSnapshot>;
|
|
37
|
+
maxResumeOptions: number;
|
|
38
|
+
commands: readonly CommandDescriptor[];
|
|
39
|
+
interactionRegistry: readonly TuiInteractionDescriptor[];
|
|
40
|
+
completePaths(query: string, signal: AbortSignal): Promise<FsPathCompletionResult>;
|
|
41
|
+
onInputCursor(target: InputCursorTarget | undefined): void;
|
|
42
|
+
onSubmit(text: string): Promise<void>;
|
|
43
|
+
/** Copy non-secret UI text through the negotiated terminal clipboard path. */
|
|
44
|
+
onCopy(text: string): {
|
|
45
|
+
readonly ok: boolean;
|
|
46
|
+
readonly message?: string;
|
|
47
|
+
};
|
|
48
|
+
onActivateFooter(itemId: TuiFooterItemId): Promise<void>;
|
|
49
|
+
onResume(candidate: TuiResumeCandidate): Promise<void>;
|
|
50
|
+
onCloseResume(): void;
|
|
51
|
+
onConfirmFreshSession(): Promise<void>;
|
|
52
|
+
onCloseFreshSession(): void;
|
|
53
|
+
onRewind(candidate: TuiRewindCandidate): Promise<void>;
|
|
54
|
+
onCloseRewind(): void;
|
|
55
|
+
onExportSession(directory: string, includeDescendants: boolean): Promise<void>;
|
|
56
|
+
onCloseSessionExport(): void;
|
|
57
|
+
onClosePluginHub(): void;
|
|
58
|
+
onPluginHubToggleView(): Promise<void>;
|
|
59
|
+
onPluginHubSearch(query: string): Promise<void>;
|
|
60
|
+
onPluginHubDetail(pluginId: PluginId): Promise<void>;
|
|
61
|
+
onPluginHubInstall(): Promise<void>;
|
|
62
|
+
onPluginHubRemove(packageName: string): Promise<void>;
|
|
63
|
+
onPluginHubConfirm(): Promise<void>;
|
|
64
|
+
onPluginHubRefresh(): Promise<void>;
|
|
65
|
+
onPluginHubLoadMore(): Promise<void>;
|
|
66
|
+
onPluginHubSort(): Promise<void>;
|
|
67
|
+
onPluginHubCategory(): Promise<void>;
|
|
68
|
+
onMounted: () => void;
|
|
69
|
+
onOpenHelp(): void;
|
|
70
|
+
onCloseHelp(): void;
|
|
71
|
+
onCancelWork(item: TuiWorkItemView): Promise<void>;
|
|
72
|
+
onOpenWork(item: TuiWorkItemView): Promise<void>;
|
|
73
|
+
onReturnRoot(): void;
|
|
74
|
+
onCancel(): void;
|
|
75
|
+
onExit(): void;
|
|
76
|
+
/** Input events buffered while terminal capabilities were negotiated. */
|
|
77
|
+
initialTerminalInput?: readonly TuiTerminalInputEvent[] | undefined;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolve readable semantic color for one Plugin Hub detail or confirmation line.
|
|
81
|
+
* @param theme - active terminal theme.
|
|
82
|
+
* @param line - projected Plugin Hub line.
|
|
83
|
+
* @returns text style without ANSI dim, which would compound muted palette colors.
|
|
84
|
+
*/
|
|
85
|
+
export declare function tuiPluginHubDetailTextStyle(theme: TuiTheme, line: TuiPluginHubDetailLine): Readonly<{
|
|
86
|
+
color?: string;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Resolve the real terminal cursor cell used by CJK IME preedit rendering.
|
|
90
|
+
* @param stdout - terminal dimensions used by the active Ink frame.
|
|
91
|
+
* @param prefix - first-line composer label rendered before the editable text.
|
|
92
|
+
* @param layout - visible Unicode-aware composer layout.
|
|
93
|
+
* @param placement - optional centered-composer origin; omission selects the bottom workspace.
|
|
94
|
+
* @returns one-based terminal row and column for the insertion point.
|
|
95
|
+
*/
|
|
96
|
+
export declare function inputCursorTarget(stdout: Pick<NodeJS.WriteStream, 'rows' | 'columns'>, prefix: string, layout: ComposerLayout, placement?: {
|
|
97
|
+
readonly firstInputRow: number;
|
|
98
|
+
readonly leftColumn: number;
|
|
99
|
+
}): InputCursorTarget;
|
|
100
|
+
/**
|
|
101
|
+
* Resolve the bounded startup composer frame and its first editable terminal row.
|
|
102
|
+
* @param stdout - terminal dimensions used by the active Ink frame.
|
|
103
|
+
* @param composerRows - mounted editor rows inside the bordered composer.
|
|
104
|
+
* @param supplementalRows - suggestion rows mounted between the brand and composer.
|
|
105
|
+
* @returns centered width, zero-based horizontal origin, one-based first input row, and selected mark.
|
|
106
|
+
*/
|
|
107
|
+
export declare function tuiStartupComposerFrame(stdout: Pick<NodeJS.WriteStream, 'rows' | 'columns'>, composerRows: number, supplementalRows?: number): {
|
|
108
|
+
readonly width: number;
|
|
109
|
+
readonly leftColumn: number;
|
|
110
|
+
readonly firstInputRow: number;
|
|
111
|
+
readonly logo: TuiStartupLogoVariant;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Select one stable-width frame for the running-Agent activity indicator.
|
|
115
|
+
* @param tick - monotonically increasing process-local animation tick.
|
|
116
|
+
* @returns a three-cell ASCII frame.
|
|
117
|
+
*/
|
|
118
|
+
export declare function tuiWorkingFrame(tick: number): string;
|
|
119
|
+
/** Render the native single-view Agent TUI. */
|
|
120
|
+
export declare function TuiApp(props: TuiAppProps): React.ReactElement;
|
|
121
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/** Pure Unicode-aware editor state and layout for the native TUI composer. */
|
|
2
|
+
/** Process-local large-paste payload represented by one bounded editor placeholder. */
|
|
3
|
+
export interface TuiComposerPasteReference {
|
|
4
|
+
/** Stable placeholder embedded in this draft's visible text. */
|
|
5
|
+
readonly placeholder: string;
|
|
6
|
+
/** Terminal-safe original text expanded only when the prompt is submitted. */
|
|
7
|
+
readonly text: string;
|
|
8
|
+
/** UTF-8 payload size used in the bounded placeholder. */
|
|
9
|
+
readonly bytes: number;
|
|
10
|
+
/** Physical source-line count used in the bounded placeholder. */
|
|
11
|
+
readonly lines: number;
|
|
12
|
+
}
|
|
13
|
+
/** Text and insertion point restored by one composer undo or redo action. */
|
|
14
|
+
export interface TuiComposerSnapshot {
|
|
15
|
+
/** Complete editor text. */
|
|
16
|
+
text: string;
|
|
17
|
+
/** UTF-16 insertion offset at a grapheme boundary. */
|
|
18
|
+
cursor: number;
|
|
19
|
+
/** Large-paste payloads still referenced by the visible text. */
|
|
20
|
+
references?: readonly TuiComposerPasteReference[] | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** Edit category used to define composer undo units. */
|
|
23
|
+
export type TuiComposerEditKind = 'typing' | 'delete-backward' | 'delete-forward' | 'delete-word-backward' | 'delete-word-forward' | 'paste' | 'multiline' | 'suggestion' | 'history';
|
|
24
|
+
/** Bounded process-local undo and redo stacks for one active draft. */
|
|
25
|
+
export interface TuiComposerEditHistory {
|
|
26
|
+
/** Oldest-first snapshots available to undo. */
|
|
27
|
+
past: readonly TuiComposerSnapshot[];
|
|
28
|
+
/** Oldest-first snapshots available to redo, with the next value last. */
|
|
29
|
+
future: readonly TuiComposerSnapshot[];
|
|
30
|
+
/** Most recent mergeable edit and its timestamp. */
|
|
31
|
+
coalescing?: {
|
|
32
|
+
kind: TuiComposerEditKind;
|
|
33
|
+
at: number;
|
|
34
|
+
} | undefined;
|
|
35
|
+
}
|
|
36
|
+
/** Process-local editor value, insertion point, and history traversal state. */
|
|
37
|
+
export interface ComposerState {
|
|
38
|
+
/** Complete draft text. */
|
|
39
|
+
text: string;
|
|
40
|
+
/** UTF-16 insertion offset at a grapheme boundary. */
|
|
41
|
+
cursor: number;
|
|
42
|
+
/** Newest-first submitted-history offset, or `-1` outside history traversal. */
|
|
43
|
+
historyIndex: number;
|
|
44
|
+
/** Draft retained while submitted history is being inspected. */
|
|
45
|
+
historyScratch?: TuiComposerDraft | undefined;
|
|
46
|
+
/** Large-paste payloads referenced by bounded placeholders in {@link text}. */
|
|
47
|
+
references?: readonly TuiComposerPasteReference[] | undefined;
|
|
48
|
+
/** Process-local bounded edit history, created after the first text change. */
|
|
49
|
+
editHistory?: TuiComposerEditHistory | undefined;
|
|
50
|
+
}
|
|
51
|
+
/** Process-local draft value retained outside the active editor. */
|
|
52
|
+
export interface TuiComposerDraft {
|
|
53
|
+
/** Complete retained text. */
|
|
54
|
+
text: string;
|
|
55
|
+
/** UTF-16 insertion offset at a grapheme boundary. */
|
|
56
|
+
cursor: number;
|
|
57
|
+
/** Edit history retained with this draft while it is stashed or searched. */
|
|
58
|
+
editHistory?: TuiComposerEditHistory | undefined;
|
|
59
|
+
/** Large-paste payloads retained with this process-local draft. */
|
|
60
|
+
references?: readonly TuiComposerPasteReference[] | undefined;
|
|
61
|
+
}
|
|
62
|
+
/** Result of one stash, restore, or swap action. */
|
|
63
|
+
export interface TuiComposerStashTransition {
|
|
64
|
+
/** Active editor after the action. */
|
|
65
|
+
composer: ComposerState;
|
|
66
|
+
/** Draft retained outside the editor, absent after restoration. */
|
|
67
|
+
stash?: TuiComposerDraft | undefined;
|
|
68
|
+
/** Observable action taken for status rendering. */
|
|
69
|
+
action: 'unchanged' | 'stashed' | 'restored' | 'swapped';
|
|
70
|
+
}
|
|
71
|
+
/** Visible composer rows and insertion cell relative to the editor content. */
|
|
72
|
+
export interface ComposerLayout {
|
|
73
|
+
/** Bounded physical rows mounted by Ink. */
|
|
74
|
+
lines: readonly string[];
|
|
75
|
+
/** Zero-based visible row containing the insertion point. */
|
|
76
|
+
cursorRow: number;
|
|
77
|
+
/** Zero-based display cell within `cursorRow`. */
|
|
78
|
+
cursorColumn: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create a composer editor at the end of an optional initial value.
|
|
82
|
+
* @param text - initial editor text.
|
|
83
|
+
* @returns initialized editor state.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createComposerState(text?: string): ComposerState;
|
|
86
|
+
/**
|
|
87
|
+
* Stash a non-empty draft, restore into an empty editor, or swap two non-empty drafts.
|
|
88
|
+
* @param composer - active editor value and cursor.
|
|
89
|
+
* @param stash - currently retained process-local draft.
|
|
90
|
+
* @returns the new editor, retained draft, and action name.
|
|
91
|
+
*/
|
|
92
|
+
export declare function toggleTuiComposerStash(composer: ComposerState, stash: TuiComposerDraft | undefined): TuiComposerStashTransition;
|
|
93
|
+
/**
|
|
94
|
+
* Replace the complete editor value as one explicit undo unit.
|
|
95
|
+
* @param state - current editor state.
|
|
96
|
+
* @param text - complete replacement text.
|
|
97
|
+
* @param cursor - insertion point in the replacement text.
|
|
98
|
+
* @param kind - edit category controlling coalescing.
|
|
99
|
+
* @param now - edit timestamp used for bounded typing and deletion coalescing.
|
|
100
|
+
* @param references - paste references retained by placeholders in the replacement text.
|
|
101
|
+
* @returns updated editor with redo cleared.
|
|
102
|
+
*/
|
|
103
|
+
export declare function replaceComposerText(state: ComposerState, text: string, cursor: number, kind: TuiComposerEditKind, now?: number, references?: readonly TuiComposerPasteReference[] | undefined): ComposerState;
|
|
104
|
+
/**
|
|
105
|
+
* Restore the preceding composer snapshot.
|
|
106
|
+
* @param state - current editor state.
|
|
107
|
+
* @returns preceding value, or the unchanged state when no undo is available.
|
|
108
|
+
*/
|
|
109
|
+
export declare function undoComposerEdit(state: ComposerState): ComposerState;
|
|
110
|
+
/**
|
|
111
|
+
* Restore the next composer snapshot after an undo.
|
|
112
|
+
* @param state - current editor state.
|
|
113
|
+
* @returns next value, or the unchanged state when no redo is available.
|
|
114
|
+
*/
|
|
115
|
+
export declare function redoComposerEdit(state: ComposerState): ComposerState;
|
|
116
|
+
/**
|
|
117
|
+
* Insert terminal-safe text at the active insertion point.
|
|
118
|
+
* @param state - current editor state.
|
|
119
|
+
* @param input - typed or pasted text.
|
|
120
|
+
* @param now - edit timestamp used for coalescing.
|
|
121
|
+
* @returns updated editor state.
|
|
122
|
+
*/
|
|
123
|
+
export declare function insertComposerText(state: ComposerState, input: string, now?: number): ComposerState;
|
|
124
|
+
/**
|
|
125
|
+
* Decide whether one bracketed paste should be represented by a bounded placeholder.
|
|
126
|
+
* @param input - committed terminal paste text.
|
|
127
|
+
* @returns true when its byte or line count exceeds the direct-editor threshold.
|
|
128
|
+
*/
|
|
129
|
+
export declare function isLargeComposerPaste(input: string): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Insert one large terminal paste as an undoable process-local reference.
|
|
132
|
+
* @param state - current editor state.
|
|
133
|
+
* @param input - committed bracketed-paste payload.
|
|
134
|
+
* @param now - edit timestamp retained with the independent paste unit.
|
|
135
|
+
* @returns editor state containing one bounded visible placeholder.
|
|
136
|
+
*/
|
|
137
|
+
export declare function insertComposerPasteReference(state: ComposerState, input: string, now?: number): ComposerState;
|
|
138
|
+
/**
|
|
139
|
+
* Expand process-local paste references into the model-visible prompt.
|
|
140
|
+
* @param state - complete editor state at submission.
|
|
141
|
+
* @returns terminal-safe prompt text with every intact placeholder expanded.
|
|
142
|
+
*/
|
|
143
|
+
export declare function materializeComposerText(state: ComposerState): string;
|
|
144
|
+
/**
|
|
145
|
+
* Detach one draft for stash, submitted history, or view-local retention.
|
|
146
|
+
* @param state - active editor state.
|
|
147
|
+
* @returns process-local draft preserving cursor, edits, and paste references.
|
|
148
|
+
*/
|
|
149
|
+
export declare function tuiComposerDraft(state: ComposerState): TuiComposerDraft;
|
|
150
|
+
/**
|
|
151
|
+
* Restore a detached process-local draft as an active editor.
|
|
152
|
+
* @param draft - retained draft value.
|
|
153
|
+
* @returns editor state preserving paste references and edit history.
|
|
154
|
+
*/
|
|
155
|
+
export declare function restoreTuiComposerDraft(draft: TuiComposerDraft): ComposerState;
|
|
156
|
+
/**
|
|
157
|
+
* Move the insertion point without changing text.
|
|
158
|
+
* @param state - current editor state.
|
|
159
|
+
* @param movement - grapheme, word, line, or buffer movement.
|
|
160
|
+
* @returns state with the updated insertion point.
|
|
161
|
+
*/
|
|
162
|
+
export declare function moveComposerCursor(state: ComposerState, movement: 'left' | 'right' | 'home' | 'end' | 'buffer-home' | 'buffer-end' | 'word-left' | 'word-right'): ComposerState;
|
|
163
|
+
/**
|
|
164
|
+
* Delete one grapheme or one adjacent word around the insertion point.
|
|
165
|
+
* @param state - current editor state.
|
|
166
|
+
* @param deletion - deletion direction and unit.
|
|
167
|
+
* @param now - edit timestamp used for coalescing.
|
|
168
|
+
* @returns updated editor state.
|
|
169
|
+
*/
|
|
170
|
+
export declare function deleteComposerText(state: ComposerState, deletion: 'backward' | 'forward' | 'word-backward' | 'word-forward', now?: number): ComposerState;
|
|
171
|
+
/**
|
|
172
|
+
* Traverse submitted history while preserving the unsent draft.
|
|
173
|
+
* @param state - current editor state.
|
|
174
|
+
* @param history - oldest-first submitted values.
|
|
175
|
+
* @param direction - history traversal direction.
|
|
176
|
+
* @param now - edit timestamp retained with the independent history unit.
|
|
177
|
+
* @returns recalled value or restored scratch draft.
|
|
178
|
+
*/
|
|
179
|
+
export declare function traverseComposerHistory(state: ComposerState, history: readonly (string | TuiComposerDraft)[], direction: 'older' | 'newer', now?: number): ComposerState;
|
|
180
|
+
/**
|
|
181
|
+
* Wrap and vertically window the draft while retaining the insertion row.
|
|
182
|
+
* @param state - current editor state.
|
|
183
|
+
* @param width - available terminal display cells.
|
|
184
|
+
* @param maxRows - maximum visible physical rows.
|
|
185
|
+
* @returns bounded visible lines and insertion geometry.
|
|
186
|
+
*/
|
|
187
|
+
export declare function layoutComposer(state: ComposerState, width: number, maxRows?: number): ComposerLayout;
|
|
188
|
+
//# sourceMappingURL=composer.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Cached logical and physical rows for one focused transcript detail. */
|
|
2
|
+
import type { TranscriptNode, TranscriptToolNode } from './transcript.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Project complete unwrapped transcript detail for clipboard transfer.
|
|
5
|
+
* @param node - current semantic parent block.
|
|
6
|
+
* @param child - focused retained tool child, when applicable.
|
|
7
|
+
* @returns terminal-safe logical rows joined without viewport-introduced wrapping.
|
|
8
|
+
*/
|
|
9
|
+
export declare function tuiTranscriptDetailText(node: TranscriptNode, child?: TranscriptToolNode): string;
|
|
10
|
+
/** Process-local detail projection keyed by stable block identity and current node reference. */
|
|
11
|
+
export declare class TuiTranscriptDetailCache {
|
|
12
|
+
private readonly entries;
|
|
13
|
+
/** Drop all cached logical and width-dependent physical rows. */
|
|
14
|
+
reset(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve wrapped physical rows for one transcript block or retained child.
|
|
17
|
+
* @param node - current semantic parent block.
|
|
18
|
+
* @param width - available terminal cells.
|
|
19
|
+
* @param child - focused retained tool child, when applicable.
|
|
20
|
+
* @returns immutable physical detail rows.
|
|
21
|
+
*/
|
|
22
|
+
lines(node: TranscriptNode, width: number, child?: TranscriptToolNode): readonly string[];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=detail.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** Pure actionable-footer descriptors and width-bounded projections. */
|
|
2
|
+
import type { ContextPressureProjection, ModelSelection, PermissionSelect } from './host.ts';
|
|
3
|
+
import type { TuiWorkSummary } from './work.ts';
|
|
4
|
+
/** Stable action targets exposed by the native TUI footer. */
|
|
5
|
+
export type TuiFooterItemId = 'model' | 'permission' | 'work' | 'context' | 'workspace' | 'transcript';
|
|
6
|
+
/** One actionable status item derived from authoritative runtime state. */
|
|
7
|
+
export interface TuiFooterItemDescriptor {
|
|
8
|
+
/** Stable package-owned item identity. */
|
|
9
|
+
readonly id: TuiFooterItemId;
|
|
10
|
+
/** Short label retained when the footer is narrow. */
|
|
11
|
+
readonly label: string;
|
|
12
|
+
/** Compact current value shown in the status row. */
|
|
13
|
+
readonly value: string;
|
|
14
|
+
/** Enter behavior for this item. */
|
|
15
|
+
readonly action: 'models' | 'permissions' | 'work' | 'detail';
|
|
16
|
+
/** Complete read-only detail shown for local status items. */
|
|
17
|
+
readonly detailLines: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
/** Current viewport position needed by the transcript footer item. */
|
|
20
|
+
export interface TuiFooterTranscriptPosition {
|
|
21
|
+
/** Zero-based first mounted transcript node, or -1 when empty. */
|
|
22
|
+
readonly startIndex: number;
|
|
23
|
+
/** Zero-based last mounted transcript node, or -1 when empty. */
|
|
24
|
+
readonly endIndex: number;
|
|
25
|
+
/** Complete projected transcript node count. */
|
|
26
|
+
readonly total: number;
|
|
27
|
+
/** Whether content exists above the mounted page. */
|
|
28
|
+
readonly hasOlder: boolean;
|
|
29
|
+
/** Whether content exists below the mounted page. */
|
|
30
|
+
readonly hasNewer: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Authoritative values from which the current footer is projected. */
|
|
33
|
+
export interface TuiFooterSources {
|
|
34
|
+
/** Selection used by the active request or the next request. */
|
|
35
|
+
readonly modelSelection?: ModelSelection | undefined;
|
|
36
|
+
/** Whether the selection describes a captured running request. */
|
|
37
|
+
readonly modelSelectionKind: 'running request' | 'next request';
|
|
38
|
+
/** Effective permission select, absent when the capability is not composed. */
|
|
39
|
+
readonly permissions?: PermissionSelect | undefined;
|
|
40
|
+
/** Provider-anchored approximate context occupancy. */
|
|
41
|
+
readonly context?: ContextPressureProjection | undefined;
|
|
42
|
+
/** Authoritative background-work counters. */
|
|
43
|
+
readonly work?: TuiWorkSummary | undefined;
|
|
44
|
+
/** Full Session workspace path. */
|
|
45
|
+
readonly workspace?: string | undefined;
|
|
46
|
+
/** Current mounted transcript page. */
|
|
47
|
+
readonly transcript: TuiFooterTranscriptPosition;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Project current authoritative state into stable actionable footer items.
|
|
51
|
+
* @param sources - model, permission, context, workspace, and viewport facts.
|
|
52
|
+
* @returns immutable items in navigation order; unavailable context is omitted.
|
|
53
|
+
*/
|
|
54
|
+
export declare function tuiFooterItems(sources: TuiFooterSources): readonly TuiFooterItemDescriptor[];
|
|
55
|
+
/**
|
|
56
|
+
* Hide lower-priority items at narrow widths while preserving model and permission.
|
|
57
|
+
* @param items - complete current footer item list.
|
|
58
|
+
* @param columns - physical cells available to the footer row.
|
|
59
|
+
* @returns the navigable items mounted at this width.
|
|
60
|
+
*/
|
|
61
|
+
export declare function visibleTuiFooterItems(items: readonly TuiFooterItemDescriptor[], columns: number): readonly TuiFooterItemDescriptor[];
|
|
62
|
+
/**
|
|
63
|
+
* Move a footer selection without depending on React state.
|
|
64
|
+
* @param items - current visible footer items.
|
|
65
|
+
* @param selected - current item id, possibly stale after capability changes.
|
|
66
|
+
* @param direction - previous or next navigation.
|
|
67
|
+
* @returns the selected id after cyclic movement, or undefined for no items.
|
|
68
|
+
*/
|
|
69
|
+
export declare function moveTuiFooterSelection(items: readonly TuiFooterItemDescriptor[], selected: TuiFooterItemId | undefined, direction: 'previous' | 'next'): TuiFooterItemId | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Format every mounted item into one physical row.
|
|
72
|
+
* @param items - visible footer items.
|
|
73
|
+
* @param columns - complete row budget in terminal cells.
|
|
74
|
+
* @returns one row no wider than the supplied budget.
|
|
75
|
+
*/
|
|
76
|
+
export declare function tuiFooterStatusLine(items: readonly TuiFooterItemDescriptor[], columns: number): string;
|
|
77
|
+
/**
|
|
78
|
+
* Format one selected item with its navigation position.
|
|
79
|
+
* @param items - visible footer items.
|
|
80
|
+
* @param selected - current item id, possibly stale after a width change.
|
|
81
|
+
* @param columns - complete row budget in terminal cells.
|
|
82
|
+
* @returns one selected-item row no wider than the supplied budget.
|
|
83
|
+
*/
|
|
84
|
+
export declare function tuiSelectedFooterLine(items: readonly TuiFooterItemDescriptor[], selected: TuiFooterItemId | undefined, columns: number): string;
|
|
85
|
+
//# sourceMappingURL=footer.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Pure process-local search state over submitted TUI prompt history. */
|
|
2
|
+
import { type ComposerState, type TuiComposerDraft } from './composer.ts';
|
|
3
|
+
/** Active reverse-history query and the draft restored when search is cancelled. */
|
|
4
|
+
export interface TuiHistorySearchState {
|
|
5
|
+
/** Text matched case-insensitively against submitted prompts. */
|
|
6
|
+
query: string;
|
|
7
|
+
/** Zero-based position in newest-first matching prompts, or `-1` with no match. */
|
|
8
|
+
matchIndex: number;
|
|
9
|
+
/** Exact editor value retained while search owns keyboard input. */
|
|
10
|
+
originalDraft: TuiComposerDraft;
|
|
11
|
+
}
|
|
12
|
+
/** Current match and count derived from one history-search state. */
|
|
13
|
+
export interface TuiHistorySearchResult {
|
|
14
|
+
/** Selected submitted prompt, absent when the query has no match. */
|
|
15
|
+
match?: string | undefined;
|
|
16
|
+
/** Exact submitted draft, including process-local paste references. */
|
|
17
|
+
draft?: TuiComposerDraft | undefined;
|
|
18
|
+
/** One-based selected position, or zero when no prompt matches. */
|
|
19
|
+
position: number;
|
|
20
|
+
/** Number of unique matching submitted prompts. */
|
|
21
|
+
count: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Start reverse search using the current draft as both the query and cancel target.
|
|
25
|
+
* @param composer - editor state before search takes keyboard ownership.
|
|
26
|
+
* @param history - oldest-first submitted prompts.
|
|
27
|
+
* @returns initialized search state selecting the newest match when one exists.
|
|
28
|
+
*/
|
|
29
|
+
export declare function startTuiHistorySearch(composer: ComposerState, history: readonly (string | TuiComposerDraft)[]): TuiHistorySearchState;
|
|
30
|
+
/**
|
|
31
|
+
* Restore the exact editor value retained when reverse search started.
|
|
32
|
+
* @param state - active history-search state.
|
|
33
|
+
* @returns editor state with the original text and insertion point.
|
|
34
|
+
*/
|
|
35
|
+
export declare function cancelTuiHistorySearch(state: TuiHistorySearchState): ComposerState;
|
|
36
|
+
/**
|
|
37
|
+
* Replace the active query and restart matching from the newest prompt.
|
|
38
|
+
* @param state - active history-search state.
|
|
39
|
+
* @param query - complete replacement query.
|
|
40
|
+
* @param history - oldest-first submitted prompts.
|
|
41
|
+
* @returns search state positioned at the newest match.
|
|
42
|
+
*/
|
|
43
|
+
export declare function updateTuiHistorySearchQuery(state: TuiHistorySearchState, query: string, history: readonly (string | TuiComposerDraft)[]): TuiHistorySearchState;
|
|
44
|
+
/**
|
|
45
|
+
* Select the next older match without wrapping to the newest prompt.
|
|
46
|
+
* @param state - active history-search state.
|
|
47
|
+
* @param history - oldest-first submitted prompts.
|
|
48
|
+
* @returns search state with a bounded selected index.
|
|
49
|
+
*/
|
|
50
|
+
export declare function nextTuiHistorySearchMatch(state: TuiHistorySearchState, history: readonly (string | TuiComposerDraft)[]): TuiHistorySearchState;
|
|
51
|
+
/**
|
|
52
|
+
* Resolve the selected prompt and display position from current submitted history.
|
|
53
|
+
* @param state - active history-search state.
|
|
54
|
+
* @param history - oldest-first submitted prompts.
|
|
55
|
+
* @returns selected match and newest-first position metadata.
|
|
56
|
+
*/
|
|
57
|
+
export declare function tuiHistorySearchResult(state: TuiHistorySearchState, history: readonly (string | TuiComposerDraft)[]): TuiHistorySearchResult;
|
|
58
|
+
//# sourceMappingURL=history-search.d.ts.map
|