dsh-llm-fallbacks 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -15
- package/README.zh-CN.md +57 -21
- package/dist/client/index.js +3 -2
- package/dist/commands.d.ts +120 -27
- package/dist/gateway.d.ts +17 -0
- package/dist/index.js +473 -12
- package/dist/selectors.d.ts +6 -3
- package/dist/tui-settings.d.ts +140 -0
- package/dist/tui.d.ts +5 -4
- package/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-tui settings-section surface (plan fallbacks-tui-settings Task 1,
|
|
3
|
+
* AC-1 + AC-2): registers a `tuiSettingsSections` section for the
|
|
4
|
+
* `fallbacks` settings namespace so the dsh-tui profile's `/settings`
|
|
5
|
+
* screen shows every web-card capability as an editable form — with ZERO
|
|
6
|
+
* dsh-TUI changes.
|
|
7
|
+
*
|
|
8
|
+
* The service and its shapes are consumed structurally (read-only reference:
|
|
9
|
+
* dsh-TUI @ 2747b87, `src/dsh-adapter/settings-sections.ts`): the six types
|
|
10
|
+
* below are minimal local copies of the host's `TuiSettingsFieldKind` /
|
|
11
|
+
* `TuiSettingsFieldOption` / `TuiSettingsFieldWrite` / `TuiSettingsField` /
|
|
12
|
+
* `TuiSettingsGroup` / `TuiSettingsSection` (reusing the plugin's existing
|
|
13
|
+
* `TuiLocalizedDescriptions` copy of the host `LocalizedDescriptions`), so
|
|
14
|
+
* no `@deepseek-harness-tui/dsh-tui` peer is needed (plan constraint: zero
|
|
15
|
+
* new peer/dependency).
|
|
16
|
+
*
|
|
17
|
+
* The screen runs `format`/`parse` IN-PROCESS (verified probe against main
|
|
18
|
+
* 2747b87: `settingsEditor.ts` `defaultFormat`/`defaultParse` call
|
|
19
|
+
* `field.format(value)` / `field.parse(text)` directly — no IPC
|
|
20
|
+
* serialization), so custom JSON/trigger-code parsers reach the renderer.
|
|
21
|
+
* Complex web-card structures are carried by `text` fields whose `parse`
|
|
22
|
+
* mirrors the gateway's save rules through the exported
|
|
23
|
+
* {@link validateConfigPatch} — an invalid draft returns `undefined` and
|
|
24
|
+
* blocks the save (never writes partial/corrupt config); a blank draft
|
|
25
|
+
* stages a `clear` (the field re-inherits the composition layer). The `tz`
|
|
26
|
+
* text field validates its IANA id the same way the runtime resolves it.
|
|
27
|
+
*
|
|
28
|
+
* @module dsh-llm-fallbacks/tui-settings
|
|
29
|
+
*/
|
|
30
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
31
|
+
import type { TuiLocalizedDescriptions } from './tui.ts';
|
|
32
|
+
/** Control kinds the TUI settings screen knows how to render (host shape). */
|
|
33
|
+
export type TuiSettingsFieldKind = 'text' | 'number' | 'boolean' | 'select';
|
|
34
|
+
/** One select choice (host `TuiSettingsFieldOption` shape). */
|
|
35
|
+
export interface TuiSettingsFieldOption {
|
|
36
|
+
/** Stored value. */
|
|
37
|
+
value: string;
|
|
38
|
+
/** Display label (English; also the fallback). */
|
|
39
|
+
label: string;
|
|
40
|
+
/** Provider-owned translations for the label. */
|
|
41
|
+
descriptions?: TuiLocalizedDescriptions;
|
|
42
|
+
}
|
|
43
|
+
/** The write one field's draft stages when the section is saved (host shape). */
|
|
44
|
+
export type TuiSettingsFieldWrite = {
|
|
45
|
+
kind: 'set';
|
|
46
|
+
value: unknown;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'clear';
|
|
49
|
+
};
|
|
50
|
+
/** One editable field (host `TuiSettingsField` shape). */
|
|
51
|
+
export interface TuiSettingsField {
|
|
52
|
+
/** Key path from the section root, in the settings service's mutate vocabulary. */
|
|
53
|
+
path: readonly string[];
|
|
54
|
+
/** Short field label (English; also the fallback). */
|
|
55
|
+
label: string;
|
|
56
|
+
/** Provider-owned translations for the label. */
|
|
57
|
+
descriptions?: TuiLocalizedDescriptions;
|
|
58
|
+
/** Optional one-line help rendered under the field. */
|
|
59
|
+
hint?: string;
|
|
60
|
+
/** Provider-owned translations for the hint. */
|
|
61
|
+
hintDescriptions?: TuiLocalizedDescriptions;
|
|
62
|
+
/** Optional group id; grouped fields render on that group's subpage. */
|
|
63
|
+
group?: string;
|
|
64
|
+
kind: TuiSettingsFieldKind;
|
|
65
|
+
/** Choices for `kind: 'select'` (ignored otherwise). */
|
|
66
|
+
options?: readonly TuiSettingsFieldOption[];
|
|
67
|
+
/** Input placeholder for `kind: 'text' | 'number'`. */
|
|
68
|
+
placeholder?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Render a stored value as draft text. Defaults to the kind's conversion.
|
|
71
|
+
* The screen calls this directly with the namespace-view value (which may
|
|
72
|
+
* be `undefined` when the field path is absent), so every custom format
|
|
73
|
+
* must guard `undefined`/`null` → `''`.
|
|
74
|
+
*/
|
|
75
|
+
format?(value: unknown): string;
|
|
76
|
+
/**
|
|
77
|
+
* The write this draft text stages, or `undefined` when the text is not a
|
|
78
|
+
* value this field accepts — an invalid draft blocks the save. A custom
|
|
79
|
+
* parse REPLACES the host's default blank→clear, so it must handle the
|
|
80
|
+
* empty draft itself.
|
|
81
|
+
*/
|
|
82
|
+
parse?(text: string): TuiSettingsFieldWrite | undefined;
|
|
83
|
+
}
|
|
84
|
+
/** One navigation group inside the section (host `TuiSettingsGroup` shape). */
|
|
85
|
+
export interface TuiSettingsGroup {
|
|
86
|
+
/** Stable identifier, unique inside the section. */
|
|
87
|
+
id: string;
|
|
88
|
+
/** Group title (English; also the fallback). */
|
|
89
|
+
title: string;
|
|
90
|
+
/** Provider-owned translations for the title. */
|
|
91
|
+
descriptions?: TuiLocalizedDescriptions;
|
|
92
|
+
}
|
|
93
|
+
/** One plugin's section inside the TUI settings screen (host shape). */
|
|
94
|
+
export interface TuiSettingsSection {
|
|
95
|
+
/** Settings namespace this section edits — matches the plugin's registration. */
|
|
96
|
+
ns: string;
|
|
97
|
+
/** Section title (English; also the fallback). */
|
|
98
|
+
title: string;
|
|
99
|
+
/** Provider-owned translations for the title. */
|
|
100
|
+
descriptions?: TuiLocalizedDescriptions;
|
|
101
|
+
/** Optional navigation groups, in display order. */
|
|
102
|
+
groups?: readonly TuiSettingsGroup[];
|
|
103
|
+
/** Editable fields, in display order. */
|
|
104
|
+
fields: readonly TuiSettingsField[];
|
|
105
|
+
}
|
|
106
|
+
/** The section namespace — must match the `fallbacks` settings namespace. */
|
|
107
|
+
export declare const FALLBACKS_TUI_SECTION_NS = "fallbacks";
|
|
108
|
+
/**
|
|
109
|
+
* Maximum draft size for the JSON-backed text fields (qc2 F-004): past
|
|
110
|
+
* this many UTF-8 bytes the draft is rejected BEFORE `JSON.parse` — a very
|
|
111
|
+
* large paste would otherwise stall the in-process settings editor. The
|
|
112
|
+
* cap is far above any operator-authored config; it bounds local memory
|
|
113
|
+
* pressure, not the config model (the gateway accepts any size).
|
|
114
|
+
*/
|
|
115
|
+
export declare const JSON_FIELD_MAX_DRAFT_BYTES: number;
|
|
116
|
+
/**
|
|
117
|
+
* The `fallbacks` /settings section: 13 fields covering all 15 web-card
|
|
118
|
+
* capabilities (the default-model choice rides `rootChain`'s last entry and
|
|
119
|
+
* the per-role fallback strategy rides `roles.list` JSON). Scalar
|
|
120
|
+
* capabilities use native kinds (boolean/number/select); complex structures
|
|
121
|
+
* use `text` fields with custom `format`/`parse` that mirror the gateway's
|
|
122
|
+
* validation. Built fresh per call — the host deep-freezes whatever it
|
|
123
|
+
* receives, and each registration stays independent.
|
|
124
|
+
*/
|
|
125
|
+
export declare function buildFallbacksTuiSection(): TuiSettingsSection;
|
|
126
|
+
/**
|
|
127
|
+
* Register the `fallbacks` section on the optional `tuiSettingsSections`
|
|
128
|
+
* service. First-fiber-only (`serviceOwned === true` — mirrors
|
|
129
|
+
* `installTuiClient` and the gateway/typert multi-fiber dedupe; the host
|
|
130
|
+
* registry throws on a duplicate namespace, so a deduped later fiber must
|
|
131
|
+
* never register). The service is optional: a composition without
|
|
132
|
+
* `dsh-tui-settings-sections` keeps the plugin working and simply omits the
|
|
133
|
+
* TUI settings surface.
|
|
134
|
+
*
|
|
135
|
+
* The inject child returns the registry disposer so cordis withdraws the
|
|
136
|
+
* registration when this fiber (or the service) goes away.
|
|
137
|
+
*/
|
|
138
|
+
export declare function installTuiSettingsSection(ctx: Context, opts: {
|
|
139
|
+
serviceOwned: boolean;
|
|
140
|
+
}): void;
|
package/dist/tui.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-tui client surface (plan fallbacks-tui-client Task 1, AC-1
|
|
3
|
-
* a `tuiCommandTrees` provider
|
|
4
|
-
* profile's `/` menu shows the
|
|
5
|
-
*
|
|
2
|
+
* dsh-tui client surface (plan fallbacks-tui-client Task 1, AC-1 +
|
|
3
|
+
* fallbacks-tui-settings Task 2): registers a `tuiCommandTrees` provider
|
|
4
|
+
* for the `/fallbacks` command so the dsh-tui profile's `/` menu shows the
|
|
5
|
+
* command with localized descriptions and `config` → `revert-seed`
|
|
6
|
+
* subcommand completion — with ZERO dsh-TUI changes.
|
|
6
7
|
*
|
|
7
8
|
* The service and its shapes are consumed structurally (read-only reference:
|
|
8
9
|
* dsh-TUI @ 557a27a, `src/dsh-adapter/command-trees.ts` +
|