dsh-advisor 0.4.0 → 0.5.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/README.i18n.yaml +2 -2
- package/README.md +31 -22
- package/README.zh.md +31 -22
- package/lib/advisor-runtime.js +1 -1
- package/lib/client/advisor-card.d.ts +18 -14
- package/lib/client/advisor-session.d.ts +75 -0
- package/lib/client/advisor-store.d.ts +131 -0
- package/lib/client/index.d.ts +18 -13
- package/lib/client/locales.d.ts +15 -0
- package/lib/client.js +375 -14
- package/lib/commands.d.ts +220 -27
- package/lib/commands.js +260 -34
- package/lib/commands.js.map +1 -1
- package/lib/config.d.ts +74 -20
- package/lib/config.js +74 -20
- package/lib/config.js.map +1 -1
- package/lib/delivery.d.ts +9 -9
- package/lib/delivery.js +10 -12
- package/lib/delivery.js.map +1 -1
- package/lib/gateway.d.ts +139 -24
- package/lib/gateway.js +138 -27
- package/lib/gateway.js.map +1 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.js +483 -82
- package/lib/index.js.map +1 -1
- package/lib/kinds.d.ts +79 -51
- package/lib/kinds.js +60 -43
- package/lib/kinds.js.map +1 -1
- package/lib/settings.d.ts +56 -86
- package/lib/settings.js +48 -91
- package/lib/settings.js.map +1 -1
- package/lib/transcript.d.ts +11 -9
- package/lib/transcript.js +25 -16
- package/lib/transcript.js.map +1 -1
- package/lib/tui-settings.d.ts +10 -10
- package/lib/tui-settings.js +10 -10
- package/lib/tui-settings.js.map +1 -1
- package/lib/tui.js +39 -5
- package/lib/tui.js.map +1 -1
- package/package.json +24 -23
package/lib/commands.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* T7 — slash commands (spec §2 S5, §6 status surface, §8.5 KD-5 seed-on-enable
|
|
2
|
+
* T7 — slash commands (spec §2 S5, §6 status surface, §8.5 KD-5 seed-on-enable,
|
|
3
|
+
* §5.3 session model override).
|
|
3
4
|
*
|
|
4
5
|
* One `/advisor` command is registered (through {@link registerAdvisorCommands})
|
|
5
|
-
* with
|
|
6
|
+
* with these forms:
|
|
6
7
|
*
|
|
7
8
|
* - `/advisor` — toggle the per-session override (on ↔ off);
|
|
8
9
|
* - `/advisor on` — enable the advisor for this session;
|
|
9
10
|
* - `/advisor off` — disable the advisor for this session;
|
|
10
11
|
* - `/advisor status` — report the per-session status surface;
|
|
11
|
-
* - `/advisor config` — show the composed advisor config (
|
|
12
|
+
* - `/advisor config` — show the composed advisor config (global defaults);
|
|
13
|
+
* - `/advisor model` — show the effective reviewer route + source;
|
|
14
|
+
* - `/advisor model set <provider> <model>` — pin an atomic pair for the
|
|
15
|
+
* invoking session only (validated via `resolveModelInfo`, 60 s, no retry);
|
|
16
|
+
* - `/advisor model reset` — re-inherit the current global defaults;
|
|
12
17
|
* - anything else — usage text.
|
|
13
18
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* the
|
|
19
|
+
* All forms are **session-scoped and ephemeral**: they drive per-session
|
|
20
|
+
* overrides ({@link AdvisorSessionOverrides} — the enable flag and the
|
|
21
|
+
* runtime-only atomic model pair, fenced by per-session generations) that the
|
|
22
|
+
* runtime gate and the effective resolver consult, so no command ever touches
|
|
23
|
+
* the persisted config (spec §4 mapping, §5.3 — matches omp `/advisor`
|
|
24
|
+
* semantics). Enabling a session whose effective route has no complete pair
|
|
25
|
+
* starts no model call: the S4 explicit gate (spec §5.2) applies AFTER session
|
|
26
|
+
* resolution, and the status/on text explains the disabled-with-reason.
|
|
21
27
|
*
|
|
22
28
|
* The module is cordis-free (pure parse + render + registration contract), so
|
|
23
29
|
* it is unit-testable with a fake command registry and a fake controller;
|
|
@@ -27,6 +33,68 @@
|
|
|
27
33
|
*
|
|
28
34
|
* @module dsh-advisor/commands
|
|
29
35
|
*/
|
|
36
|
+
/**
|
|
37
|
+
* Parse the text following `/advisor model`. `set` keeps its RAW remainder —
|
|
38
|
+
* the atomic-pair validation ({@link parseModelSetArgs}) owns it, because the
|
|
39
|
+
* set flow reports a precise rejection reason in the command reply.
|
|
40
|
+
*/
|
|
41
|
+
export function parseAdvisorModelCommand(rawInput) {
|
|
42
|
+
const argument = rawInput.trim();
|
|
43
|
+
if (argument === '')
|
|
44
|
+
return { kind: 'show' };
|
|
45
|
+
if (argument === 'reset')
|
|
46
|
+
return { kind: 'reset' };
|
|
47
|
+
if (argument === 'set' || argument.startsWith('set ') || argument.startsWith('set\t')) {
|
|
48
|
+
return { kind: 'set', args: argument.slice('set'.length).trim() };
|
|
49
|
+
}
|
|
50
|
+
return { kind: 'usage' };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Validate one structured `{provider, model}` pair (spec §5.3 pair validation):
|
|
54
|
+
* both values must be strings that are non-empty after outer trim, with no
|
|
55
|
+
* whitespace INSIDE either identifier (the same rules `parseModelSetArgs`
|
|
56
|
+
* enforces for the CLI form — one validation source shared by the command face
|
|
57
|
+
* and the web gateway face, so the two surfaces can never diverge). Outer
|
|
58
|
+
* whitespace is trimmed; case is retained; model ids containing `/` are fine
|
|
59
|
+
* (`/` is not whitespace). Never throws — every rejection carries a
|
|
60
|
+
* user-facing reason.
|
|
61
|
+
*/
|
|
62
|
+
export function parseModelPair(provider, model) {
|
|
63
|
+
if (typeof provider !== 'string' || typeof model !== 'string') {
|
|
64
|
+
return { ok: false, reason: 'incomplete pair — provider and model are both required' };
|
|
65
|
+
}
|
|
66
|
+
const trimmedProvider = provider.trim();
|
|
67
|
+
const trimmedModel = model.trim();
|
|
68
|
+
if (trimmedProvider === '' || trimmedModel === '') {
|
|
69
|
+
return { ok: false, reason: 'incomplete pair — provider and model are both required' };
|
|
70
|
+
}
|
|
71
|
+
if (/\s/.test(trimmedProvider) || /\s/.test(trimmedModel)) {
|
|
72
|
+
return { ok: false, reason: 'invalid pair — provider and model must not contain whitespace' };
|
|
73
|
+
}
|
|
74
|
+
return { ok: true, provider: trimmedProvider, model: trimmedModel };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validate `/advisor model set <provider> <model>` arguments (spec §5.3):
|
|
78
|
+
* exactly two arguments; outer whitespace trimmed; case retained; blank or
|
|
79
|
+
* partial pairs, extra fields (a third argument), and whitespace-containing
|
|
80
|
+
* identifiers rejected. Separate args are what allow model ids containing
|
|
81
|
+
* `/`. Never throws — every rejection carries a user-facing reason.
|
|
82
|
+
*/
|
|
83
|
+
export function parseModelSetArgs(rawArgs) {
|
|
84
|
+
const args = rawArgs.trim().split(/\s+/).filter((arg) => arg.length > 0);
|
|
85
|
+
if (args.length === 0) {
|
|
86
|
+
return { ok: false, reason: 'usage: /advisor model set <provider> <model>' };
|
|
87
|
+
}
|
|
88
|
+
if (args.length === 1) {
|
|
89
|
+
return { ok: false, reason: `incomplete pair — provider and model are both required (got only "${args[0]}")` };
|
|
90
|
+
}
|
|
91
|
+
if (args.length > 2) {
|
|
92
|
+
return { ok: false, reason: `too many arguments — the pair is exactly <provider> <model> (got ${args.length})` };
|
|
93
|
+
}
|
|
94
|
+
// The split cannot leave whitespace inside a token; the shared validator is
|
|
95
|
+
// still the single authority for the pair shape (B2 web face parity).
|
|
96
|
+
return parseModelPair(args[0], args[1]);
|
|
97
|
+
}
|
|
30
98
|
/**
|
|
31
99
|
* Parse the text following `/advisor` (the dsh `parseCommand` split already
|
|
32
100
|
* yields `rawInput` including the separator whitespace, e.g. `' on'` for
|
|
@@ -45,27 +113,40 @@ export function parseAdvisorCommand(rawInput) {
|
|
|
45
113
|
return { kind: 'status' };
|
|
46
114
|
if (argument === 'config')
|
|
47
115
|
return { kind: 'config' };
|
|
116
|
+
if (argument === 'model' || argument.startsWith('model ') || argument.startsWith('model\t')) {
|
|
117
|
+
return { kind: 'model', sub: parseAdvisorModelCommand(argument.slice('model'.length)) };
|
|
118
|
+
}
|
|
48
119
|
return { kind: 'usage' };
|
|
49
120
|
}
|
|
50
|
-
// ---------------------------------------------------------------------------
|
|
51
|
-
// Per-session override mechanism (session-scoped, ephemeral)
|
|
52
|
-
// ---------------------------------------------------------------------------
|
|
53
121
|
/**
|
|
54
|
-
* The per-session
|
|
55
|
-
* `
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
122
|
+
* The per-session overrides consulted by the runtime gate and the effective
|
|
123
|
+
* resolver (`src/index.ts`):
|
|
124
|
+
*
|
|
125
|
+
* - enable: `override ?? config.enabled` (`/advisor on|off|toggle`);
|
|
126
|
+
* - model: the complete session pair ?? the composed global pair — the pair
|
|
127
|
+
* is atomic, so the two levels are never merged (spec §5.3);
|
|
128
|
+
* - generation: a per-session counter that fences async model work — a newer
|
|
129
|
+
* set/reset supersedes unresolved older work, and dispose/owner teardown
|
|
130
|
+
* (which wipe the counter) can never be undone by a delayed completion.
|
|
131
|
+
*
|
|
132
|
+
* Nothing here touches the persisted config. All maps are keyed by session id
|
|
133
|
+
* and hold only LIVE sessions' state: `clear` runs on `agent/disposed` /
|
|
134
|
+
* `session/disposed`, `clearModel` runs on reset (an emptied entry is
|
|
135
|
+
* removed), and `disposeAll` runs on owner teardown — state stays
|
|
136
|
+
* O(live overrides), with no historical SessionId accumulation and no
|
|
137
|
+
* TTL/GC job.
|
|
59
138
|
*/
|
|
60
139
|
export class AdvisorSessionOverrides {
|
|
61
140
|
configEnabled;
|
|
62
|
-
|
|
141
|
+
enables = new Map();
|
|
142
|
+
models = new Map();
|
|
143
|
+
generations = new Map();
|
|
63
144
|
constructor(configEnabled) {
|
|
64
145
|
this.configEnabled = configEnabled;
|
|
65
146
|
}
|
|
66
147
|
/** Effective switch for one session: `override ?? config.enabled`. */
|
|
67
148
|
effective(sessionId) {
|
|
68
|
-
return this.
|
|
149
|
+
return this.enables.get(sessionId) ?? this.configEnabled;
|
|
69
150
|
}
|
|
70
151
|
/**
|
|
71
152
|
* Update the config-level fallback switch (live config — settings onChange,
|
|
@@ -76,13 +157,64 @@ export class AdvisorSessionOverrides {
|
|
|
76
157
|
setConfigEnabled(enabled) {
|
|
77
158
|
this.configEnabled = enabled;
|
|
78
159
|
}
|
|
79
|
-
/** Set the override for one session. */
|
|
160
|
+
/** Set the enable override for one session. */
|
|
80
161
|
set(sessionId, enabled) {
|
|
81
|
-
this.
|
|
162
|
+
this.enables.set(sessionId, enabled);
|
|
163
|
+
}
|
|
164
|
+
/** The session's pinned model pair, or `undefined` when it inherits. */
|
|
165
|
+
model(sessionId) {
|
|
166
|
+
return this.models.get(sessionId);
|
|
167
|
+
}
|
|
168
|
+
/** Commit the (already validated) atomic pair for one session. */
|
|
169
|
+
setModel(sessionId, pair) {
|
|
170
|
+
this.models.set(sessionId, pair);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Remove a session's model pin (reset-to-inherit). @returns `true` when a
|
|
174
|
+
* pin was actually removed — `false` means the session was already
|
|
175
|
+
* inheriting (a reset no-op).
|
|
176
|
+
*/
|
|
177
|
+
clearModel(sessionId) {
|
|
178
|
+
return this.models.delete(sessionId);
|
|
82
179
|
}
|
|
83
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* Bump and return the session's model-work generation — the fence token an
|
|
182
|
+
* async validation captures; any later `beginModelGeneration` (a newer
|
|
183
|
+
* set/reset) or any state wipe makes the captured value stale.
|
|
184
|
+
*/
|
|
185
|
+
beginModelGeneration(sessionId) {
|
|
186
|
+
const next = (this.generations.get(sessionId) ?? 0) + 1;
|
|
187
|
+
this.generations.set(sessionId, next);
|
|
188
|
+
return next;
|
|
189
|
+
}
|
|
190
|
+
/** The session's current model-work generation (0 before the first). */
|
|
191
|
+
modelGeneration(sessionId) {
|
|
192
|
+
return this.generations.get(sessionId) ?? 0;
|
|
193
|
+
}
|
|
194
|
+
/** Sessions holding ANY per-session override state (enable and/or pair). */
|
|
195
|
+
overrideSessionIds() {
|
|
196
|
+
return new Set([...this.enables.keys(), ...this.models.keys()]).keys();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Drop ALL per-session state for one session (enable + pair + generation) —
|
|
200
|
+
* the `agent/disposed` / `session/disposed` cleanup. Wiping the generation
|
|
201
|
+
* invalidates any in-flight validation for the session (captured values are
|
|
202
|
+
* ≥ 1 and can never again match the post-clear default 0).
|
|
203
|
+
*/
|
|
84
204
|
clear(sessionId) {
|
|
85
|
-
this.
|
|
205
|
+
this.enables.delete(sessionId);
|
|
206
|
+
this.models.delete(sessionId);
|
|
207
|
+
this.generations.delete(sessionId);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Owner teardown: wipe every session's state. Pending validations for any
|
|
211
|
+
* session become stale exactly like a per-session `clear` — a delayed
|
|
212
|
+
* completion can never commit after the owner is gone.
|
|
213
|
+
*/
|
|
214
|
+
disposeAll() {
|
|
215
|
+
this.enables.clear();
|
|
216
|
+
this.models.clear();
|
|
217
|
+
this.generations.clear();
|
|
86
218
|
}
|
|
87
219
|
}
|
|
88
220
|
/**
|
|
@@ -96,13 +228,67 @@ export function advisorStatusText(status) {
|
|
|
96
228
|
if (status.disabledReason !== undefined)
|
|
97
229
|
lines.push(`Reason: ${status.disabledReason}`);
|
|
98
230
|
if (status.provider && status.model) {
|
|
99
|
-
|
|
231
|
+
// Spec §5.3: the status reports the EFFECTIVE route, labeled by source.
|
|
232
|
+
const source = status.modelSource === 'session' ? 'session override' : 'global default';
|
|
233
|
+
lines.push(`Model: ${status.provider}/${status.model} (${source})`);
|
|
100
234
|
}
|
|
101
235
|
const pending = status.pendingCount > 0 ? ` (${status.pendingCount} pending)` : '';
|
|
102
236
|
lines.push(`Runtime: ${status.runtimeStatus}${pending}`);
|
|
103
237
|
lines.push(`Last activity: ${status.lastActivityAt === undefined ? 'never' : new Date(status.lastActivityAt).toISOString()}`);
|
|
104
238
|
return lines.join('\n');
|
|
105
239
|
}
|
|
240
|
+
// ---------------------------------------------------------------------------
|
|
241
|
+
// Model surface (`/advisor model` — spec §5.3, the B1 command face)
|
|
242
|
+
// ---------------------------------------------------------------------------
|
|
243
|
+
/** Validation deadline for one `/advisor model set` lookup (60 s — matches
|
|
244
|
+
* the runtime's whole-call deadline default, `src/advisor-runtime.ts`). */
|
|
245
|
+
export const ADVISOR_MODEL_VALIDATION_TIMEOUT_MS = 60_000;
|
|
246
|
+
/**
|
|
247
|
+
* Render the `/advisor model` surface: the effective pair, its source, and
|
|
248
|
+
* the live-session lifetime (spec §5.3 — the reply must name the lifetime).
|
|
249
|
+
*/
|
|
250
|
+
export function advisorModelText(route) {
|
|
251
|
+
const lines = [];
|
|
252
|
+
if (route.provider && route.model) {
|
|
253
|
+
lines.push(`Model: ${route.provider}/${route.model}`);
|
|
254
|
+
lines.push(route.source === 'session'
|
|
255
|
+
? 'Source: session override — lives for this session; cleared by /advisor model reset, dispose, or restart'
|
|
256
|
+
: 'Source: global default — pin a different route with /advisor model set <provider> <model>');
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
lines.push('Model: none — the global default has no provider/model');
|
|
260
|
+
lines.push('Set both globally (the /advisor config edit paths) or pin a session pair:');
|
|
261
|
+
lines.push(' /advisor model set <provider> <model>');
|
|
262
|
+
}
|
|
263
|
+
lines.push('Lifetime: this session only — never persisted; a new/forked session inherits the global defaults.');
|
|
264
|
+
return lines.join('\n');
|
|
265
|
+
}
|
|
266
|
+
/** Render one `/advisor model set` outcome. */
|
|
267
|
+
export function modelSetText(outcome) {
|
|
268
|
+
switch (outcome.kind) {
|
|
269
|
+
case 'committed':
|
|
270
|
+
return `Session model pinned: ${outcome.status.provider}/${outcome.status.model} (session override).\n${advisorStatusText(outcome.status)}`;
|
|
271
|
+
case 'unchanged':
|
|
272
|
+
return `Session model pinned: ${outcome.status.provider}/${outcome.status.model} — same effective route, runtime untouched.`;
|
|
273
|
+
case 'rejected':
|
|
274
|
+
return `Not set: ${outcome.reason}`;
|
|
275
|
+
case 'failed':
|
|
276
|
+
return `Model not set — validation failed, previous selection untouched: ${outcome.reason}`;
|
|
277
|
+
case 'cancelled':
|
|
278
|
+
return 'Model not set — the command was cancelled; previous selection untouched.';
|
|
279
|
+
case 'superseded':
|
|
280
|
+
return 'Model not set — superseded by a newer /advisor model command.';
|
|
281
|
+
case 'gone':
|
|
282
|
+
return 'Model not set — this session is no longer live.';
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/** Render one `/advisor model reset` outcome. */
|
|
286
|
+
export function modelResetText(outcome) {
|
|
287
|
+
if (outcome.kind === 'noop') {
|
|
288
|
+
return 'No session model pin to reset — this session already inherits the global defaults.';
|
|
289
|
+
}
|
|
290
|
+
return `Session model pin removed — inheriting the global defaults.\n${advisorStatusText(outcome.status)}`;
|
|
291
|
+
}
|
|
106
292
|
/**
|
|
107
293
|
* First line of a system prompt, truncated to ≤ 80 chars with a trailing
|
|
108
294
|
* ellipsis when the first line is longer — the TUI one-liner readback, never
|
|
@@ -121,9 +307,9 @@ export function summarizeSystemPrompt(prompt) {
|
|
|
121
307
|
* Render the composed config surface. Mirrors the status renderer's minimal
|
|
122
308
|
* line style; the edit hint points at the operator edit paths — when the TUI
|
|
123
309
|
* `tuiSettingsSections` seam is mounted (dsh-tui ≥ v0.8.0) the TUI `/settings`
|
|
124
|
-
* Advisor section is listed FIRST, followed by the profile patch layer
|
|
125
|
-
*
|
|
126
|
-
* otherwise only the
|
|
310
|
+
* Advisor section is listed FIRST, followed by the profile patch layer
|
|
311
|
+
* (`cordis.patch.yml`, whose `advisor` plugin row carries the volatile live
|
|
312
|
+
* fields); otherwise only the file path.
|
|
127
313
|
*/
|
|
128
314
|
export function advisorConfigText(config) {
|
|
129
315
|
const lines = [];
|
|
@@ -150,18 +336,30 @@ export function advisorConfigText(config) {
|
|
|
150
336
|
// `tuiSettingsAvailable` input the wiring supplies at render time; the
|
|
151
337
|
// absent-seam text is the n8 line, byte-identical.
|
|
152
338
|
lines.push(config.tuiSettingsAvailable
|
|
153
|
-
? 'Edit: TUI /settings screen (Advisor section, dsh-tui ≥ v0.8.0) or ~/.dsh/profiles/<profile>/cordis.patch.yml (plugin row)
|
|
154
|
-
: 'Edit: ~/.dsh/profiles/<profile>/cordis.patch.yml (plugin row)
|
|
339
|
+
? 'Edit: TUI /settings screen (Advisor section, dsh-tui ≥ v0.8.0) or ~/.dsh/profiles/<profile>/cordis.patch.yml (advisor plugin row)'
|
|
340
|
+
: 'Edit: ~/.dsh/profiles/<profile>/cordis.patch.yml (advisor plugin row)');
|
|
155
341
|
return lines.join('\n');
|
|
156
342
|
}
|
|
157
343
|
/** Usage text for an unknown `/advisor` subcommand. */
|
|
158
344
|
export const USAGE = [
|
|
159
|
-
'Usage: /advisor [on|off|status|config]',
|
|
345
|
+
'Usage: /advisor [on|off|status|config|model]',
|
|
160
346
|
' /advisor toggle the advisor for this session',
|
|
161
347
|
' /advisor on enable the advisor for this session',
|
|
162
348
|
' /advisor off disable the advisor for this session',
|
|
163
349
|
' /advisor status show per-session advisor status (state, model, runtime, pending, last activity)',
|
|
164
|
-
' /advisor config show the composed advisor config (
|
|
350
|
+
' /advisor config show the composed advisor config (global defaults readback)',
|
|
351
|
+
' /advisor model show the effective model, its source (session override or global default), and the live-session lifetime',
|
|
352
|
+
' /advisor model set <provider> <model>',
|
|
353
|
+
' pin the reviewer model for this session only (separate args; ids may contain /)',
|
|
354
|
+
' /advisor model reset',
|
|
355
|
+
' drop the session pin and re-inherit the current global defaults',
|
|
356
|
+
].join('\n');
|
|
357
|
+
/** Usage text for an unknown `/advisor model` subcommand. */
|
|
358
|
+
export const MODEL_USAGE = [
|
|
359
|
+
'Usage: /advisor model [set <provider> <model>|reset]',
|
|
360
|
+
' /advisor model show the effective model and its source',
|
|
361
|
+
' /advisor model set <p> <m> pin the reviewer model for this session only',
|
|
362
|
+
' /advisor model reset re-inherit the current global defaults',
|
|
165
363
|
].join('\n');
|
|
166
364
|
/**
|
|
167
365
|
* "Enabled" outcome text — mentions the S4 gate when it blocks model calls.
|
|
@@ -220,11 +418,39 @@ function createAdvisorCommandHandler(controller) {
|
|
|
220
418
|
case 'config':
|
|
221
419
|
// Session-less readback: the composed config, never the session state.
|
|
222
420
|
return { kind: 'success', text: advisorConfigText(controller.getConfig()) };
|
|
421
|
+
case 'model':
|
|
422
|
+
return handleModelCommand(controller, sessionId, invocation);
|
|
223
423
|
case 'usage':
|
|
224
424
|
return { kind: 'success', text: USAGE };
|
|
225
425
|
}
|
|
226
426
|
};
|
|
227
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* `/advisor model` dispatch (spec §5.3). Only the `set` form is async — it
|
|
430
|
+
* awaits the 60 s `resolveModelInfo` validation before replying with the
|
|
431
|
+
* outcome; show/reset are synchronous.
|
|
432
|
+
*/
|
|
433
|
+
function handleModelCommand(controller, sessionId, invocation) {
|
|
434
|
+
const command = parseAdvisorCommand(invocation.rawInput);
|
|
435
|
+
if (command.kind !== 'model')
|
|
436
|
+
return { kind: 'success', text: MODEL_USAGE };
|
|
437
|
+
switch (command.sub.kind) {
|
|
438
|
+
case 'show':
|
|
439
|
+
return { kind: 'success', text: advisorModelText(controller.getModelRoute(sessionId)) };
|
|
440
|
+
case 'reset':
|
|
441
|
+
return { kind: 'success', text: modelResetText(controller.resetModel(sessionId, invocation.agent.session.seq)) };
|
|
442
|
+
case 'set': {
|
|
443
|
+
const args = parseModelSetArgs(command.sub.args);
|
|
444
|
+
if (!args.ok)
|
|
445
|
+
return { kind: 'success', text: modelSetText({ kind: 'rejected', reason: args.reason }) };
|
|
446
|
+
return controller
|
|
447
|
+
.setModel(sessionId, args.provider, args.model, invocation.agent, invocation.signal)
|
|
448
|
+
.then((outcome) => ({ kind: 'success', text: modelSetText(outcome) }));
|
|
449
|
+
}
|
|
450
|
+
case 'usage':
|
|
451
|
+
return { kind: 'success', text: MODEL_USAGE };
|
|
452
|
+
}
|
|
453
|
+
}
|
|
228
454
|
/**
|
|
229
455
|
* Register the `/advisor` command with a command registry (the dsh
|
|
230
456
|
* `CommandService`, or a fake in tests). Called from the plugin's conditional
|
|
@@ -235,8 +461,8 @@ function createAdvisorCommandHandler(controller) {
|
|
|
235
461
|
export function registerAdvisorCommands(registry, controller) {
|
|
236
462
|
return registry.register({
|
|
237
463
|
name: 'advisor',
|
|
238
|
-
description: 'Toggle, enable, disable, or
|
|
239
|
-
input: { hint: '[on|off|status|config]' },
|
|
464
|
+
description: 'Toggle, enable, disable, inspect, or re-route the per-session advisor',
|
|
465
|
+
input: { hint: '[on|off|status|config|model]' },
|
|
240
466
|
handler: createAdvisorCommandHandler(controller),
|
|
241
467
|
});
|
|
242
468
|
}
|
package/lib/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAkBH;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAA;IAChC,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;IAC9C,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAC5C,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IAC9C,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;IACpD,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;IACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC;AAED,8EAA8E;AAC9E,6DAA6D;AAC7D,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,OAAO,uBAAuB;IAGd;IAFH,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAA;IAEvD,YAAoB,aAAsB;QAAtB,kBAAa,GAAb,aAAa,CAAS;IAAG,CAA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AAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YAChD,IAAI,CAAC,IAAI,CAAC,EAAE;gBAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAA;YACvG,OAAO,UAAU;iBACd,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC;iBACnF,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAkB,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;QACnF,CAAC;QACD,KAAK,OAAO;YACV,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;IACjD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAgC,EAChC,UAAoC;IAEpC,OAAO,QAAQ,CAAC,QAAQ,CAAC;QACvB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,uEAAuE;QACpF,KAAK,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE;QAC/C,OAAO,EAAE,2BAA2B,CAAC,UAAU,CAAC;KACjD,CAAC,CAAA;AACJ,CAAC"}
|
package/lib/config.d.ts
CHANGED
|
@@ -4,10 +4,19 @@
|
|
|
4
4
|
* The exported schemastery `Config` schema is what the cordis Loader uses to
|
|
5
5
|
* validate the plugin row config: it applies defaults (`enabled` false,
|
|
6
6
|
* `immuneTurns` 3, `maxDeltaMessages` 60, `systemPrompt` "") and enforces
|
|
7
|
-
* types/bounds (integers ≥ 0).
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* types/bounds (integers ≥ 0). All six live fields are declared `.volatile()`:
|
|
8
|
+
* the Loader commits edits to them into the running fiber's references WITHOUT
|
|
9
|
+
* a remount (dsh 0.1.7-rc.1 — the settings.yaml user layer is gone), so
|
|
10
|
+
* `apply` receives each field as a `{ get() }` reference and every read must
|
|
11
|
+
* unwrap it first — {@link unwrapAdvisorConfig}, which tolerates plain values
|
|
12
|
+
* too (integration harnesses pass plain objects).
|
|
13
|
+
*
|
|
14
|
+
* `resolveAdvisorConfig(raw)` additionally enforces the explicit model gate:
|
|
15
|
+
* when `enabled` is true but `provider` or `model` is missing or empty, it
|
|
16
|
+
* resolves to a disabled-with-reason config — the advisor never starts a model
|
|
17
|
+
* call (hard gate, not a warning). The volatile unwrap happens BEFORE the gate:
|
|
18
|
+
* an unwrapped reference object is truthy, so the enabled/provider/model reads
|
|
19
|
+
* would silently pass the gate on the reference objects themselves.
|
|
11
20
|
*
|
|
12
21
|
* @module dsh-advisor/config
|
|
13
22
|
*/
|
|
@@ -44,25 +53,66 @@ export interface ResolvedAdvisorConfig {
|
|
|
44
53
|
* stay optional so an enabled-without-pair config validates and then resolves
|
|
45
54
|
* to disabled-with-reason instead of failing to load.
|
|
46
55
|
*
|
|
56
|
+
* Volatile (dsh 0.1.7-rc.1): every field is a LIVE field. The Loader commits
|
|
57
|
+
* edits into the running fiber's references without remounting the plugin
|
|
58
|
+
* (same pattern as dsh `agent-default-model`), so flat, always-present fields
|
|
59
|
+
* are exactly what the settings forms surface. `.volatile()` requires a fixed
|
|
60
|
+
* object path with no enclosing volatile field — this flat schema qualifies.
|
|
61
|
+
*
|
|
47
62
|
* Type note: left to inference (`Schema<ObjectS, ObjectT>`), so calling the
|
|
48
63
|
* schema accepts partial input (each key optional, `| null`) and yields the
|
|
49
|
-
* fully-defaulted output — matching schemastery's runtime semantics.
|
|
64
|
+
* fully-defaulted output — matching schemastery's runtime semantics. With
|
|
65
|
+
* `.volatile()` the output type of each field is the reference shape; the
|
|
66
|
+
* resolver reads through {@link unwrapAdvisorConfig}, keeping this module's
|
|
67
|
+
* exported contracts plain-valued.
|
|
50
68
|
*/
|
|
51
|
-
export declare const Config: z<Schemastery.ObjectS<{
|
|
52
|
-
enabled: z<boolean, boolean>;
|
|
53
|
-
provider: z<string, string>;
|
|
54
|
-
model: z<string, string>;
|
|
55
|
-
systemPrompt: z<string, string>;
|
|
56
|
-
immuneTurns: z<number, number>;
|
|
57
|
-
maxDeltaMessages: z<number, number>;
|
|
58
|
-
}
|
|
59
|
-
enabled: z<boolean, boolean>;
|
|
60
|
-
provider: z<string, string>;
|
|
61
|
-
model: z<string, string>;
|
|
62
|
-
systemPrompt: z<string, string>;
|
|
63
|
-
immuneTurns: z<number, number>;
|
|
64
|
-
maxDeltaMessages: z<number, number>;
|
|
65
|
-
}
|
|
69
|
+
export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
70
|
+
enabled: z<boolean, boolean, "volatile-defined">;
|
|
71
|
+
provider: z<string, string, "volatile">;
|
|
72
|
+
model: z<string, string, "volatile">;
|
|
73
|
+
systemPrompt: z<string, string, "volatile-defined">;
|
|
74
|
+
immuneTurns: z<number, number, "volatile-defined">;
|
|
75
|
+
maxDeltaMessages: z<number, number, "volatile-defined">;
|
|
76
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
77
|
+
enabled: z<boolean, boolean, "volatile-defined">;
|
|
78
|
+
provider: z<string, string, "volatile">;
|
|
79
|
+
model: z<string, string, "volatile">;
|
|
80
|
+
systemPrompt: z<string, string, "volatile-defined">;
|
|
81
|
+
immuneTurns: z<number, number, "volatile-defined">;
|
|
82
|
+
maxDeltaMessages: z<number, number, "volatile-defined">;
|
|
83
|
+
}>>, "plain">;
|
|
84
|
+
/**
|
|
85
|
+
* The entry config as the runtime hands it to `apply` (dsh 0.1.7-rc.1): every
|
|
86
|
+
* field declared `.volatile()` arrives as a cosmokit `Volatile` reference —
|
|
87
|
+
* a `{ get() }` object the Loader commits live edits into — instead of the
|
|
88
|
+
* bare value. Deliberately loose (`unknown` value side): the reference vs.
|
|
89
|
+
* plain distinction is a runtime duck-type, not a static one, and plain
|
|
90
|
+
* values remain legal input (integration harnesses never resolve through the
|
|
91
|
+
* Loader).
|
|
92
|
+
*/
|
|
93
|
+
export interface VolatileAdvisorConfig {
|
|
94
|
+
readonly enabled: unknown;
|
|
95
|
+
readonly provider?: unknown;
|
|
96
|
+
readonly model?: unknown;
|
|
97
|
+
readonly systemPrompt: unknown;
|
|
98
|
+
readonly immuneTurns: unknown;
|
|
99
|
+
readonly maxDeltaMessages: unknown;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Snapshot the live entry config into a plain {@link AdvisorConfig}: every
|
|
103
|
+
* schema-declared field is read through its volatile reference (or taken as
|
|
104
|
+
* the plain value it is on non-Loader paths), and `null` — which schemastery
|
|
105
|
+
* passes through for fields without a default — is normalized to `undefined`
|
|
106
|
+
* so the resolved contract is null-free and the gate treats null exactly like
|
|
107
|
+
* a missing value. Keys outside the schema ride along untouched (the
|
|
108
|
+
* schemastery object resolver merges unknown keys through; they are never
|
|
109
|
+
* volatile-declared, so they are never references) — the hard gate's
|
|
110
|
+
* unknown-key rejection must keep seeing them.
|
|
111
|
+
*
|
|
112
|
+
* This is a snapshot read, NOT a validation: the result is the RAW composed
|
|
113
|
+
* config `resolveAdvisorConfig` consumes.
|
|
114
|
+
*/
|
|
115
|
+
export declare function unwrapAdvisorConfig(raw: VolatileAdvisorConfig): AdvisorConfig;
|
|
66
116
|
/**
|
|
67
117
|
* Resolve the raw config into the runtime contract.
|
|
68
118
|
*
|
|
@@ -70,5 +120,9 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
70
120
|
* - Applies the explicit model gate (S4): `enabled: true` with `provider` or
|
|
71
121
|
* `model` missing/empty → disabled-with-reason, never throws, no model call.
|
|
72
122
|
* - `provider`/`model` are ignored while disabled.
|
|
123
|
+
*
|
|
124
|
+
* The volatile unwrap happens FIRST (before any gate read): a reference
|
|
125
|
+
* object is truthy regardless of the value behind it, so gating on the raw
|
|
126
|
+
* volatile fields would silently enable the advisor on `{ get() }` objects.
|
|
73
127
|
*/
|
|
74
128
|
export declare function resolveAdvisorConfig(raw: unknown): ResolvedAdvisorConfig;
|