dsh-llm-fallbacks 0.3.1 → 0.3.3

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.
@@ -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): registers
3
- * a `tuiCommandTrees` provider for the `/fallbacks` command so the dsh-tui
4
- * profile's `/` menu shows the command with localized descriptions and
5
- * `config` subcommand completion — with ZERO dsh-TUI changes.
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` +
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "dsh",
6
6
  "dsh-plugin"
7
7
  ],
8
- "version": "0.3.1",
8
+ "version": "0.3.3",
9
9
  "type": "module",
10
10
  "main": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts",
@@ -61,23 +61,23 @@
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@deepseek-ai/cordis": "^4.0.1",
64
- "@deepseek-ai/dsh-agent": "^0.1.0-rc.8",
65
- "@deepseek-ai/dsh-api-gateway": "^0.1.0-rc.8",
66
- "@deepseek-ai/dsh-api-remotes": "^0.1.0-rc.8",
67
- "@deepseek-ai/dsh-client-connection": "^0.1.0-rc.8",
68
- "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.8",
69
- "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.8",
70
- "@deepseek-ai/dsh-client-ui-conversation": "^0.1.0-rc.8",
71
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.8",
72
- "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.8",
73
- "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.0-rc.8",
74
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.8",
75
- "@deepseek-ai/dsh-commands": "^0.1.0-rc.8",
76
- "@deepseek-ai/dsh-llm": "^0.1.0-rc.8",
77
- "@deepseek-ai/dsh-session": "^0.1.0-rc.8",
78
- "@deepseek-ai/dsh-settings": "^0.1.0-rc.8",
79
- "@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.8",
80
- "@deepseek-ai/dsh-typert-registry": "^0.1.0-rc.8",
64
+ "@deepseek-ai/dsh-agent": "^0.1.1-rc.1",
65
+ "@deepseek-ai/dsh-api-gateway": "^0.1.1-rc.1",
66
+ "@deepseek-ai/dsh-api-remotes": "^0.1.1-rc.1",
67
+ "@deepseek-ai/dsh-client-connection": "^0.1.1-rc.1",
68
+ "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.1",
69
+ "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.1",
70
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.1.1-rc.1",
71
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.1-rc.1",
72
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.1",
73
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.1",
74
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.1",
75
+ "@deepseek-ai/dsh-commands": "^0.1.1-rc.1",
76
+ "@deepseek-ai/dsh-llm": "^0.1.1-rc.1",
77
+ "@deepseek-ai/dsh-session": "^0.1.1-rc.1",
78
+ "@deepseek-ai/dsh-settings": "^0.1.1-rc.1",
79
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.1",
80
+ "@deepseek-ai/dsh-typert-registry": "^0.1.1-rc.1",
81
81
  "@deepseek-ai/schemastery": "^3.18.1",
82
82
  "react": "^18.2.0"
83
83
  },