@aiwayds/dsh-tui-pi 0.5.2 → 0.7.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/lib/settings.d.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  * settings surface (schema-form driven there, pi-tui overlays here).
4
4
  *
5
5
  * Walks `ctx.settings.describe()` (registered namespaces → serialized
6
- * schemastery schemas → resolved values) and renders it as nested
7
- * SettingsList overlays, one level per schema depth:
6
+ * schemastery schemas → resolved values) and renders it as nested FW list
7
+ * panels (src/panels.ts SettingsListPanel), one level per schema depth:
8
8
  *
9
9
  * level 0 category list (searchable): general / models / plugins / agent,
10
10
  * then `other` for unmapped namespaces. Namespace→category comes
@@ -37,6 +37,7 @@ import type { Context } from '@deepseek-ai/cordis';
37
37
  import { type SchemaNode } from '@deepseek-ai/dsh-client-schema-form';
38
38
  import { type Component, type TUI } from '@earendil-works/pi-tui';
39
39
  import { type TuiTheme } from './theme/index.ts';
40
+ import { type ProviderCatalogEntry } from './provider-catalog.ts';
40
41
  export interface SettingsCategory {
41
42
  id: string;
42
43
  label: string;
@@ -138,6 +139,7 @@ export interface EditOptions {
138
139
  /** Inline value editor: title, current-value line, error/notice line, Input. */
139
140
  export declare class EditField implements Component {
140
141
  private readonly tui;
142
+ private readonly theme;
141
143
  private readonly options;
142
144
  private readonly input;
143
145
  private error;
@@ -147,11 +149,7 @@ export declare class EditField implements Component {
147
149
  private pending;
148
150
  /** Guards onDone: exactly one terminal transition (submit success/keep/escape). */
149
151
  private done;
150
- private readonly fg;
151
- private readonly fgMuted;
152
152
  private readonly fgDanger;
153
- /** Popup-surface background for the secret mask line. */
154
- private readonly maskBg;
155
153
  constructor(tui: TUI, options: EditOptions, theme: TuiTheme);
156
154
  /** Terminal transition — runs the caller's onDone exactly once. */
157
155
  private finish;
@@ -161,11 +159,69 @@ export declare class EditField implements Component {
161
159
  * Masked input line for secret fields: a dot row (one dot per visible
162
160
  * column of the value, capped to the popup width) with a `▎` marker at the
163
161
  * cursor position. The real cursor is not rendered — the marker only hints
164
- * at the editing position; input semantics live in the internal Input.
162
+ * at the editing position; input semantics live in the internal Input. The
163
+ * row needs no background of its own — FramedOverlay fills the canvasSubtle
164
+ * backdrop.
165
165
  */
166
166
  private maskLine;
167
167
  handleInput(data: string): void;
168
168
  }
169
+ /** Commit a provider (profile + key); resolves with an outcome or none. */
170
+ export interface AddProviderOptions {
171
+ /** Catalog entries the picker offers, in directory order. */
172
+ entries: readonly ProviderCatalogEntry[];
173
+ /**
174
+ * When set, skip the picker and open the key editor for this entry
175
+ * directly — the `/login <provider>` fast path. Esc in the editor pops the
176
+ * whole flow.
177
+ */
178
+ initialEntry?: ProviderCatalogEntry;
179
+ /** Commit the provider: write the profile, then store the key. */
180
+ onCommit: (entry: ProviderCatalogEntry, key: string) => Promise<CommitResult | undefined>;
181
+ /** Pop the whole flow (Esc, or right after a successful commit). */
182
+ onExit: () => void;
183
+ /** Error sink for writes that fail after the editor already closed. */
184
+ onError: (message: string) => void;
185
+ }
186
+ /**
187
+ * Add-provider flow for the Models category — the terminal counterpart of
188
+ * pi-agent's /login, trimmed to the information a user actually needs: pick
189
+ * a provider from the built-in directory (searchable FW list panel, accent
190
+ * BOLD title), enter exactly one API key, done. The key editor reuses
191
+ * EditField (pending guard, late-error sink); the picker is a searchable
192
+ * SettingsListPanel of the directory entries. `/login <provider>` reuses this
193
+ * flow through `initialEntry`, which swaps the picker for a direct key
194
+ * editor. Exported because /login instantiates it as a top-level overlay.
195
+ */
196
+ export declare class AddProviderFlow implements Component {
197
+ private readonly tui;
198
+ private readonly theme;
199
+ private readonly list;
200
+ /** Direct-launch key editor (`initialEntry` set); replaces the picker list. */
201
+ private readonly direct;
202
+ private readonly empty;
203
+ private readonly onExit;
204
+ constructor(tui: TUI, theme: TuiTheme, options: AddProviderOptions);
205
+ /** Key editor for one directory entry; commits through the write chain. */
206
+ private keyEditor;
207
+ invalidate(): void;
208
+ render(width: number): string[];
209
+ handleInput(data: string): void;
210
+ }
211
+ /**
212
+ * Commit a provider (profile + key) through the settings + credentials seams —
213
+ * the same two writes the web Models page performs. Shared by the Models
214
+ * category's add flow and the /login command; the caller supplies the profile
215
+ * write (each surface keeps its own serialized settings chain). A missing
216
+ * credentials service still commits the profile (it names the derived ref; the
217
+ * key then has to come from the environment).
218
+ *
219
+ * Outcome surface: a write failure is an `error`; a committed profile whose
220
+ * key could not be stored is an `error` with the manual fallback spelled out
221
+ * (B3); a committed profile with no credentials service at all is a `notice`
222
+ * (success + hint, no ✘ — C11). Resolves `undefined` on a full success.
223
+ */
224
+ export declare function commitProvider(ctx: Context, writeProfile: () => Promise<string | undefined>, entry: ProviderCatalogEntry, key: string): Promise<CommitResult | undefined>;
169
225
  export interface OpenSettingsBrowserOptions {
170
226
  ctx: Context;
171
227
  tui: TUI;