dsh-harness-reflex 0.1.0 → 0.3.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.md +20 -6
- package/client.js +3511 -185
- package/dist/attribution.d.ts +266 -0
- package/dist/attribution.js +238 -0
- package/dist/attribution.js.map +1 -0
- package/dist/bridge.d.ts +311 -13
- package/dist/bridge.js +714 -42
- package/dist/bridge.js.map +1 -1
- package/dist/client-bundle.js +4 -1
- package/dist/client-bundle.js.map +1 -1
- package/dist/command.js +10 -0
- package/dist/command.js.map +1 -1
- package/dist/config.d.ts +530 -22
- package/dist/config.js +808 -27
- package/dist/config.js.map +1 -1
- package/dist/delegation-dispatch.d.ts +132 -0
- package/dist/delegation-dispatch.js +186 -0
- package/dist/delegation-dispatch.js.map +1 -0
- package/dist/delegation-health.d.ts +131 -0
- package/dist/delegation-health.js +97 -0
- package/dist/delegation-health.js.map +1 -0
- package/dist/delegation.d.ts +148 -0
- package/dist/delegation.js +186 -0
- package/dist/delegation.js.map +1 -0
- package/dist/effort-delegation.d.ts +144 -0
- package/dist/effort-delegation.js +280 -0
- package/dist/effort-delegation.js.map +1 -0
- package/dist/effort.d.ts +141 -0
- package/dist/effort.js +251 -9
- package/dist/effort.js.map +1 -1
- package/dist/host-patch.d.ts +156 -0
- package/dist/host-patch.js +534 -0
- package/dist/host-patch.js.map +1 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.js +99 -7
- package/dist/index.js.map +1 -1
- package/dist/interventions.d.ts +98 -373
- package/dist/interventions.js +442 -1702
- package/dist/interventions.js.map +1 -1
- package/dist/panel-api.d.ts +328 -4
- package/dist/panel-api.js +322 -15
- package/dist/panel-api.js.map +1 -1
- package/dist/panel-mount.d.ts +81 -22
- package/dist/panel-mount.js +228 -7
- package/dist/panel-mount.js.map +1 -1
- package/dist/routing.d.ts +23 -18
- package/dist/routing.js +471 -153
- package/dist/routing.js.map +1 -1
- package/dist/session-audit.d.ts +70 -0
- package/dist/session-audit.js +73 -0
- package/dist/session-audit.js.map +1 -1
- package/dist/systemone-probe.d.ts +114 -0
- package/dist/systemone-probe.js +383 -0
- package/dist/systemone-probe.js.map +1 -0
- package/dist/testing.d.ts +212 -7
- package/dist/testing.js +333 -27
- package/dist/testing.js.map +1 -1
- package/dist/tools.d.ts +109 -3
- package/dist/tools.js +103 -4
- package/dist/tools.js.map +1 -1
- package/dist/unconfigured-backend.d.ts +72 -0
- package/dist/unconfigured-backend.js +94 -0
- package/dist/unconfigured-backend.js.map +1 -0
- package/dist/vendor/harness-reflex/backend/factory.d.ts +31 -1
- package/dist/vendor/harness-reflex/backend/factory.js +18 -3
- package/dist/vendor/harness-reflex/backend/factory.js.map +1 -1
- package/dist/vendor/harness-reflex/backend/jev.d.ts +20 -0
- package/dist/vendor/harness-reflex/backend/jev.js +11 -4
- package/dist/vendor/harness-reflex/backend/jev.js.map +1 -1
- package/dist/vendor/harness-reflex/backend/simple-jev.d.ts +16 -0
- package/dist/vendor/harness-reflex/backend/simple-jev.js +17 -6
- package/dist/vendor/harness-reflex/backend/simple-jev.js.map +1 -1
- package/dist/vendor/harness-reflex/core/closing.d.ts +90 -0
- package/dist/vendor/harness-reflex/core/closing.js +111 -0
- package/dist/vendor/harness-reflex/core/closing.js.map +1 -0
- package/dist/vendor/harness-reflex/core/evidence.d.ts +119 -0
- package/dist/vendor/harness-reflex/core/evidence.js +209 -0
- package/dist/vendor/harness-reflex/core/evidence.js.map +1 -0
- package/dist/vendor/harness-reflex/core/judge.d.ts +221 -0
- package/dist/vendor/harness-reflex/core/judge.js +251 -0
- package/dist/vendor/harness-reflex/core/judge.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate-closing.d.ts +237 -0
- package/dist/vendor/harness-reflex/core/orchestrate-closing.js +250 -0
- package/dist/vendor/harness-reflex/core/orchestrate-closing.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate-correction.d.ts +209 -0
- package/dist/vendor/harness-reflex/core/orchestrate-correction.js +141 -0
- package/dist/vendor/harness-reflex/core/orchestrate-correction.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate-host.d.ts +225 -0
- package/dist/vendor/harness-reflex/core/orchestrate-host.js +80 -0
- package/dist/vendor/harness-reflex/core/orchestrate-host.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate-stagnation.d.ts +259 -0
- package/dist/vendor/harness-reflex/core/orchestrate-stagnation.js +270 -0
- package/dist/vendor/harness-reflex/core/orchestrate-stagnation.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate.d.ts +357 -0
- package/dist/vendor/harness-reflex/core/orchestrate.js +418 -0
- package/dist/vendor/harness-reflex/core/orchestrate.js.map +1 -0
- package/dist/vendor/harness-reflex/core/policy.d.ts +122 -0
- package/dist/vendor/harness-reflex/core/policy.js +102 -0
- package/dist/vendor/harness-reflex/core/policy.js.map +1 -0
- package/dist/vendor/harness-reflex/core/prune-plan.d.ts +141 -0
- package/dist/vendor/harness-reflex/core/prune-plan.js +390 -0
- package/dist/vendor/harness-reflex/core/prune-plan.js.map +1 -0
- package/dist/vendor/harness-reflex/core/text.d.ts +36 -0
- package/dist/vendor/harness-reflex/core/text.js +66 -0
- package/dist/vendor/harness-reflex/core/text.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/audit.d.ts +18 -0
- package/dist/vendor/harness-reflex/ports/audit.js +11 -0
- package/dist/vendor/harness-reflex/ports/audit.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/clock.d.ts +14 -0
- package/dist/vendor/harness-reflex/ports/clock.js +11 -0
- package/dist/vendor/harness-reflex/ports/clock.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/decision.d.ts +75 -0
- package/dist/vendor/harness-reflex/ports/decision.js +2 -0
- package/dist/vendor/harness-reflex/ports/decision.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/index.d.ts +14 -0
- package/dist/vendor/harness-reflex/ports/index.js +2 -0
- package/dist/vendor/harness-reflex/ports/index.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/log.d.ts +22 -0
- package/dist/vendor/harness-reflex/ports/log.js +12 -0
- package/dist/vendor/harness-reflex/ports/log.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/state.d.ts +46 -0
- package/dist/vendor/harness-reflex/ports/state.js +13 -0
- package/dist/vendor/harness-reflex/ports/state.js.map +1 -0
- package/package.json +25 -13
package/dist/panel-api.d.ts
CHANGED
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
import type { IncomingMessage } from 'node:http';
|
|
27
27
|
import type { DecisionLedger } from './vendor/harness-reflex/index.js';
|
|
28
28
|
import type { WebRoute } from '@deepseek-ai/dsh-host-webserver';
|
|
29
|
-
import type
|
|
29
|
+
import { type ResolvedReflexConfig } from './config.js';
|
|
30
30
|
import type { ReflexEffortStatus } from './effort.js';
|
|
31
|
+
import type { DelegationHealthState } from './delegation-health.js';
|
|
31
32
|
/** Version reported by the panel; kept in step with `package.json` by a test. */
|
|
32
|
-
export declare const REFLEX_PLUGIN_VERSION = "0.
|
|
33
|
+
export declare const REFLEX_PLUGIN_VERSION = "0.3.0";
|
|
33
34
|
/** Namespace every panel route lives under. */
|
|
34
35
|
export declare const PANEL_BASE = "/dsh-reflex/api";
|
|
35
36
|
/** The route family, as the panel's phases address it. */
|
|
@@ -37,6 +38,21 @@ export declare const PANEL_ROUTES: {
|
|
|
37
38
|
readonly snapshot: "/dsh-reflex/api/panel";
|
|
38
39
|
readonly health: "/dsh-reflex/api/health";
|
|
39
40
|
readonly clearLedger: "/dsh-reflex/api/ledger/clear";
|
|
41
|
+
/**
|
|
42
|
+
* Writes the host `modelSelection` switch into the profile patch.
|
|
43
|
+
*
|
|
44
|
+
* A route of its own, and a `POST`, because it is the only request in this
|
|
45
|
+
* family that changes a file outside this plugin's own settings section.
|
|
46
|
+
*/
|
|
47
|
+
readonly delegation: "/dsh-reflex/api/delegation";
|
|
48
|
+
/**
|
|
49
|
+
* Probes one System One profile from the server.
|
|
50
|
+
*
|
|
51
|
+
* A `POST` with a JSON body naming the profile, and not a `GET`: it performs
|
|
52
|
+
* outbound work on the user's behalf, and a cached or prefetched GET must never
|
|
53
|
+
* be able to trigger a connection attempt.
|
|
54
|
+
*/
|
|
55
|
+
readonly systemOneTest: "/dsh-reflex/api/systemone/test";
|
|
40
56
|
};
|
|
41
57
|
/** How many recent ledger entries one snapshot carries. Default 25, cap 200. */
|
|
42
58
|
export declare const PANEL_LEDGER_WINDOW = 25;
|
|
@@ -97,6 +113,37 @@ export interface PanelInterventionsView {
|
|
|
97
113
|
/** Capability → effective mode, with `inherit` already resolved. */
|
|
98
114
|
capabilities: Record<string, string>;
|
|
99
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Delegation block of the snapshot.
|
|
118
|
+
*
|
|
119
|
+
* Deliberately not folded into {@link PanelToolsView}: those switches decide
|
|
120
|
+
* which tools *this plugin* registers, while this one decides whether the *Host*
|
|
121
|
+
* is asked for a capability (`modelSelection`). The panel shows them apart so the
|
|
122
|
+
* one switch that edits a file outside this plugin cannot look like the others.
|
|
123
|
+
*/
|
|
124
|
+
export interface PanelDelegationView {
|
|
125
|
+
/** The authored consent (`delegation.enabled`); off by default. */
|
|
126
|
+
enabled: boolean;
|
|
127
|
+
/** Whether `reflex_delegate` is registered in the live registry right now. */
|
|
128
|
+
registered: boolean;
|
|
129
|
+
/** What the live Host registry says, or `unknown` when no fact was supplied. */
|
|
130
|
+
state: DelegationHealthState | 'unknown';
|
|
131
|
+
/** The host profile patch this switch edits, when one could be resolved. */
|
|
132
|
+
patchPath?: string;
|
|
133
|
+
/** Which fact resolved {@link patchPath}. */
|
|
134
|
+
patchPathSource?: string;
|
|
135
|
+
/** Whether the host patch currently asks for the field (read from the file). */
|
|
136
|
+
patchEnabled: boolean;
|
|
137
|
+
/** Why the capability is not usable, or why the patch could not be read. */
|
|
138
|
+
reason?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Whether a write has happened that only a restart can apply.
|
|
141
|
+
*
|
|
142
|
+
* Computed from facts, never guessed: the switch is on, the file asks for the
|
|
143
|
+
* field, and the host tool still does not declare `reasoning_effort`.
|
|
144
|
+
*/
|
|
145
|
+
restartRequired: boolean;
|
|
146
|
+
}
|
|
100
147
|
/** Per-tool switch block of the snapshot. */
|
|
101
148
|
export interface PanelToolsView {
|
|
102
149
|
/** Suffix → switch, every suffix of the vocabulary answered. */
|
|
@@ -166,6 +213,26 @@ export interface PanelLedgerRow {
|
|
|
166
213
|
switched?: boolean;
|
|
167
214
|
/** `details.contextTokens`, the context size the routing decision reasoned about. */
|
|
168
215
|
contextTokens?: number;
|
|
216
|
+
/**
|
|
217
|
+
* `details.systemOneConnection` — the System One connection in force when the
|
|
218
|
+
* call was dispatched (g-068). Absent on an entry that predates the change,
|
|
219
|
+
* and never invented for it.
|
|
220
|
+
*/
|
|
221
|
+
systemOneConnection?: string;
|
|
222
|
+
/**
|
|
223
|
+
* `details.systemOneModel` — the model id the call **requested**. A request,
|
|
224
|
+
* never an observation: whether an upstream served or rewrote it is unknown
|
|
225
|
+
* to this plugin, which is why every renderer marks it as requested.
|
|
226
|
+
*/
|
|
227
|
+
systemOneModel?: string | null;
|
|
228
|
+
/**
|
|
229
|
+
* `details.systemOneSource` — `remote`, `local`, `local-fallback`, `rejected`
|
|
230
|
+
* or `unknown`. Anything but `remote` means the answer was not a System One
|
|
231
|
+
* answer, and the panel must never show it as one.
|
|
232
|
+
*/
|
|
233
|
+
systemOneSource?: string;
|
|
234
|
+
/** `details.systemOneDetail` — why the source is not `remote`. */
|
|
235
|
+
systemOneDetail?: string;
|
|
169
236
|
}
|
|
170
237
|
/** Ledger block of the snapshot. */
|
|
171
238
|
export interface PanelLedgerView {
|
|
@@ -187,6 +254,55 @@ export interface PanelSystemOneHealth {
|
|
|
187
254
|
/** Consecutive failed requests; a single success resets it. */
|
|
188
255
|
consecutiveFailures: number;
|
|
189
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* One connection profile, as the panel renders it.
|
|
259
|
+
*
|
|
260
|
+
* Every field here is a *non-secret* one. The key never appears: the panel learns
|
|
261
|
+
* only {@link apiKeyPresent}, which is what lets it draw a write-only input with
|
|
262
|
+
* a placeholder without ever holding the value.
|
|
263
|
+
*/
|
|
264
|
+
export interface PanelSystemOneProfileView {
|
|
265
|
+
/** Profile name; also the row id and the settings path segment. */
|
|
266
|
+
name: string;
|
|
267
|
+
baseUrl?: string;
|
|
268
|
+
model?: string;
|
|
269
|
+
/** Environment variable this profile names, when it names one. */
|
|
270
|
+
apiKeyEnv?: string;
|
|
271
|
+
/**
|
|
272
|
+
* Whether this profile currently resolves a key — from its own secret slot or
|
|
273
|
+
* from the variable the chain names. Never which value.
|
|
274
|
+
*/
|
|
275
|
+
apiKeyPresent: boolean;
|
|
276
|
+
/** Whether the key this profile resolves is its own secret slot (not a variable). */
|
|
277
|
+
apiKeyFromProfile: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* The variable that supplied this profile's key, or the one it named and
|
|
280
|
+
* found empty. A name, never a value.
|
|
281
|
+
*/
|
|
282
|
+
apiKeyVariable?: string;
|
|
283
|
+
/**
|
|
284
|
+
* This profile names a variable that is empty, and the lookup locked onto it
|
|
285
|
+
* (g-059): no fallback variable was consulted. Rendered as "named, but empty"
|
|
286
|
+
* rather than as "no key configured".
|
|
287
|
+
*/
|
|
288
|
+
apiKeyLocked?: boolean;
|
|
289
|
+
timeoutMs?: number;
|
|
290
|
+
backend?: string;
|
|
291
|
+
/** Every model id this connection offers, in authored order (g-066). */
|
|
292
|
+
modelIds?: string[];
|
|
293
|
+
/** The one model id in force for this connection: what the runtime and the probe use. */
|
|
294
|
+
selectedModel?: string;
|
|
295
|
+
/**
|
|
296
|
+
* `selectedModel` is not in {@link modelIds}.
|
|
297
|
+
*
|
|
298
|
+
* The row must say so: the runtime then sends no model at all rather than
|
|
299
|
+
* quietly running a different one, and a probe would test a request nobody
|
|
300
|
+
* selected. Absent when the selection is valid (or when none is named).
|
|
301
|
+
*/
|
|
302
|
+
modelMissing?: boolean;
|
|
303
|
+
/** Whether this is the profile in force. */
|
|
304
|
+
active: boolean;
|
|
305
|
+
}
|
|
190
306
|
/** System One backend block of the snapshot. */
|
|
191
307
|
export interface PanelSystemOneView {
|
|
192
308
|
/** Selected implementation; `auto` resolves through the environment. */
|
|
@@ -196,9 +312,60 @@ export interface PanelSystemOneView {
|
|
|
196
312
|
baseUrl?: string;
|
|
197
313
|
model?: string;
|
|
198
314
|
apiKeyEnv?: string;
|
|
199
|
-
/**
|
|
315
|
+
/**
|
|
316
|
+
* Whether the key chain currently resolves a key — from the settings
|
|
317
|
+
* document, from `apiKeyEnv`, or from one of the fallback variables. Never
|
|
318
|
+
* which value.
|
|
319
|
+
*/
|
|
200
320
|
apiKeyPresent: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Where that key came from, so the page can say "from the configuration",
|
|
323
|
+
* "from JEV_API_KEY", or "from JEV_API_KEY (fallback)" instead of guessing
|
|
324
|
+
* from `apiKeyEnv`. Absent when no key resolves at all.
|
|
325
|
+
*
|
|
326
|
+
* `fallback` is an environment read reached through the documented variable
|
|
327
|
+
* list because the block named *no* variable (g-059) — marked as such so a
|
|
328
|
+
* deployment that meant to name one can tell it named nothing.
|
|
329
|
+
*/
|
|
330
|
+
apiKeySource?: 'profile' | 'env' | 'fallback';
|
|
331
|
+
/**
|
|
332
|
+
* The environment variable that supplied the key (present when
|
|
333
|
+
* {@link apiKeySource} is `env` or `fallback`), or — when nothing resolved —
|
|
334
|
+
* the variable the block named and found empty. A *name*; no value travels.
|
|
335
|
+
*/
|
|
336
|
+
apiKeyVariable?: string;
|
|
337
|
+
/**
|
|
338
|
+
* The block named a variable that is empty, and the lookup stopped there on
|
|
339
|
+
* purpose (g-059): no fallback variable was consulted. Distinct from a plain
|
|
340
|
+
* `apiKeyPresent: false`, which means nothing was named and nothing was found.
|
|
341
|
+
*/
|
|
342
|
+
apiKeyLocked?: boolean;
|
|
343
|
+
/** Whether the resolved configuration carries a literal key. Never the key. */
|
|
344
|
+
apiKeyFromProfile: boolean;
|
|
201
345
|
timeoutMs?: number;
|
|
346
|
+
/** Every authored profile, in authored order. Empty when none is authored. */
|
|
347
|
+
profiles: PanelSystemOneProfileView[];
|
|
348
|
+
/** The authored `active` name, when one was authored. */
|
|
349
|
+
activeProfile?: string;
|
|
350
|
+
/**
|
|
351
|
+
* The authored `active` name matches no profile. Surfaced as a warning rather
|
|
352
|
+
* than hidden: a typo must not look like a working configuration — and since
|
|
353
|
+
* g-066 it also means nothing connects.
|
|
354
|
+
*/
|
|
355
|
+
activeProfileMissing: boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Why nothing connects, when nothing does (g-066): no profiles, none
|
|
358
|
+
* activated, the active name missing, only the pre-g-066 flat fields, or an
|
|
359
|
+
* active profile whose model cannot be sent.
|
|
360
|
+
*
|
|
361
|
+
* Absent exactly when a connection resolved, so the page renders its
|
|
362
|
+
* "unconfigured" state from this and never from a guess about the fields.
|
|
363
|
+
*/
|
|
364
|
+
unconfigured?: 'no-active-profile' | 'no-profiles' | 'active-profile-missing' | 'legacy-config-required' | 'model-selection-unusable' | 'model-selection-invalid';
|
|
365
|
+
/** The active profile's selected model is not in its list; nothing runs. */
|
|
366
|
+
activeProfileModelMissing?: boolean;
|
|
367
|
+
/** The active profile's model cannot be sent, so nothing connects (g-066 att-002). */
|
|
368
|
+
activeProfileModelUnusable?: boolean;
|
|
202
369
|
/**
|
|
203
370
|
* Live gateway health, when the backend keeps any. Backends that answer every
|
|
204
371
|
* call in-process (mock) omit it; the absence is not an outage.
|
|
@@ -232,6 +399,7 @@ export interface PanelSnapshot {
|
|
|
232
399
|
systemOne: PanelSystemOneView;
|
|
233
400
|
interventions: PanelInterventionsView;
|
|
234
401
|
tools: PanelToolsView;
|
|
402
|
+
delegation: PanelDelegationView;
|
|
235
403
|
ledger: PanelLedgerView;
|
|
236
404
|
modelCatalog?: PanelModelGroup[];
|
|
237
405
|
}
|
|
@@ -272,12 +440,60 @@ export interface PanelRuntimeFacts {
|
|
|
272
440
|
ledger: Pick<DecisionLedger, 'getSummary' | 'getEntries' | 'getLogPath'>;
|
|
273
441
|
/** Latest adaptive decision of this activation. */
|
|
274
442
|
effort: ReflexEffortStatus | undefined;
|
|
275
|
-
/** Whether an API key is currently reachable through the
|
|
443
|
+
/** Whether an API key is currently reachable through the resolved key chain. */
|
|
276
444
|
apiKeyPresent: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Where that key came from: a literal in the settings document (`profile`), an
|
|
447
|
+
* environment variable the block named (`env`), or a documented fallback
|
|
448
|
+
* variable (`fallback`). Absent when no key resolves.
|
|
449
|
+
*/
|
|
450
|
+
apiKeySource?: 'profile' | 'env' | 'fallback';
|
|
451
|
+
/**
|
|
452
|
+
* The variable that supplied the key, or the named-but-empty one. A name,
|
|
453
|
+
* never a value.
|
|
454
|
+
*/
|
|
455
|
+
apiKeyVariable?: string;
|
|
456
|
+
/** The block named a variable that is empty, so no fallback was consulted. */
|
|
457
|
+
apiKeyLocked?: boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Key *presence* per profile name — the only key fact the panel may receive.
|
|
460
|
+
*
|
|
461
|
+
* A map of booleans and variable names, never of values: the projection cannot
|
|
462
|
+
* leak what it is not handed, and a test asserts the serialized snapshot
|
|
463
|
+
* contains no key substring.
|
|
464
|
+
*/
|
|
465
|
+
profileKeys?: Record<string, {
|
|
466
|
+
present: boolean;
|
|
467
|
+
fromProfile: boolean;
|
|
468
|
+
variable?: string;
|
|
469
|
+
locked?: boolean;
|
|
470
|
+
}>;
|
|
277
471
|
/** Health of the backend's gateway conversation, when it tracks one. */
|
|
278
472
|
systemOneHealth?: PanelSystemOneHealth;
|
|
279
473
|
/** Available physical model catalog from ctx.llm. */
|
|
280
474
|
modelCatalog?: PanelModelGroup[];
|
|
475
|
+
/**
|
|
476
|
+
* The live delegation-capability reading.
|
|
477
|
+
*
|
|
478
|
+
* `undefined` when the caller could not read the registry at all, which the
|
|
479
|
+
* projection reports as `unknown` rather than inventing a state.
|
|
480
|
+
*/
|
|
481
|
+
delegationHealth?: {
|
|
482
|
+
state: DelegationHealthState;
|
|
483
|
+
reason?: string;
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* The host profile patch, as read from disk by the caller.
|
|
487
|
+
*
|
|
488
|
+
* Supplied rather than read here so the projection stays pure: the mount layer
|
|
489
|
+
* owns the file access, and a test drives it with a scratch path.
|
|
490
|
+
*/
|
|
491
|
+
hostPatch?: {
|
|
492
|
+
path?: string;
|
|
493
|
+
source?: string;
|
|
494
|
+
enabled: boolean;
|
|
495
|
+
reason?: string;
|
|
496
|
+
};
|
|
281
497
|
/** Timestamp of the snapshot; defaults to now. */
|
|
282
498
|
now?: number;
|
|
283
499
|
}
|
|
@@ -297,6 +513,39 @@ export declare function projectEffortDecision(status: ReflexEffortStatus): Panel
|
|
|
297
513
|
* @returns the serializable snapshot.
|
|
298
514
|
*/
|
|
299
515
|
export declare function buildPanelSnapshot(facts: PanelRuntimeFacts, limit?: number): PanelSnapshot;
|
|
516
|
+
/**
|
|
517
|
+
* Project the System One connection block, including every profile.
|
|
518
|
+
*
|
|
519
|
+
* The one rule this function exists to keep: **no key value may reach the
|
|
520
|
+
* payload**. It reads {@link PanelRuntimeFacts.profileKeys} — presence flags the
|
|
521
|
+
* caller gathered — and never `config.systemOne.profiles[*].apiKey`, which does
|
|
522
|
+
* exist in the resolved config because the backend needs it.
|
|
523
|
+
*
|
|
524
|
+
* @param config - the configuration in force.
|
|
525
|
+
* @param facts - gathered runtime facts.
|
|
526
|
+
* @returns the wire projection of the connection block.
|
|
527
|
+
*/
|
|
528
|
+
export declare function projectSystemOne(config: ResolvedReflexConfig, facts: PanelRuntimeFacts): PanelSystemOneView;
|
|
529
|
+
/**
|
|
530
|
+
* Project the delegation switch, the host patch it edits, and the live capability.
|
|
531
|
+
*
|
|
532
|
+
* The "not working" reasons are kept apart on purpose, because the fix differs:
|
|
533
|
+
* `model-selection-off` is a tool that does not publish the level (tick the
|
|
534
|
+
* switch, restart), while `missing-tool` is a host without a delegation tool at
|
|
535
|
+
* all (nothing this plugin can do). `unknown` is neither: it means the capability
|
|
536
|
+
* was not probed, and it must never be rendered as "off".
|
|
537
|
+
*
|
|
538
|
+
* `registered` now follows **configuration** (g-054), so the one contradiction
|
|
539
|
+
* this view exists to prevent — "the switch is ticked, the tool is never
|
|
540
|
+
* registered" — can no longer be produced by the plugin. `restartRequired` is
|
|
541
|
+
* the remaining explanation for "I ticked it and the level still does not take
|
|
542
|
+
* effect": the file asks, but the running host still does not publish the
|
|
543
|
+
* parameter.
|
|
544
|
+
* @param config - the configuration in force.
|
|
545
|
+
* @param facts - gathered runtime facts.
|
|
546
|
+
* @returns the wire projection of the delegation block.
|
|
547
|
+
*/
|
|
548
|
+
export declare function projectDelegation(config: ResolvedReflexConfig, facts: PanelRuntimeFacts): PanelDelegationView;
|
|
300
549
|
/**
|
|
301
550
|
* Clamp a requested ledger window onto the accepted range.
|
|
302
551
|
* @param limit - requested count; non-finite values fall back to the default.
|
|
@@ -361,6 +610,57 @@ export interface PanelSource {
|
|
|
361
610
|
clearLedger(): number;
|
|
362
611
|
/** Whether the loopback/pairing fence admitted this request. */
|
|
363
612
|
allows(request: IncomingMessage): boolean;
|
|
613
|
+
/**
|
|
614
|
+
* Turn the host `modelSelection` switch on in the profile patch.
|
|
615
|
+
*
|
|
616
|
+
* Omitted by a host that cannot write the file; the route then answers 501
|
|
617
|
+
* rather than pretending, which is what tells the panel to say "do it by hand".
|
|
618
|
+
* @returns the outcome the panel renders.
|
|
619
|
+
*/
|
|
620
|
+
enableDelegation?: () => PanelDelegationWrite;
|
|
621
|
+
/**
|
|
622
|
+
* Probe one System One profile; absent means the host cannot, and the route
|
|
623
|
+
* answers 501 rather than pretending the connection was fine.
|
|
624
|
+
* @param profile - profile name, or `undefined` for the active one.
|
|
625
|
+
* @param signal - cancelled when the client goes away.
|
|
626
|
+
* @returns the classified probe result.
|
|
627
|
+
*/
|
|
628
|
+
testSystemOne?: (profile: string | undefined, signal: AbortSignal) => Promise<PanelProbeAnswer>;
|
|
629
|
+
}
|
|
630
|
+
/** The answer of one connection probe. */
|
|
631
|
+
export interface PanelProbeAnswer {
|
|
632
|
+
ok: boolean;
|
|
633
|
+
/** `ok` | `auth-failed` | `unreachable` | `timeout` | `bad-response` | `misconfigured`. */
|
|
634
|
+
status: string;
|
|
635
|
+
/** Real round trip, in milliseconds. */
|
|
636
|
+
latencyMs: number;
|
|
637
|
+
/** Profile that was probed, or `null` when the flat block was. */
|
|
638
|
+
profile: string | null;
|
|
639
|
+
httpStatus?: number;
|
|
640
|
+
/** Redacted, single-line explanation. */
|
|
641
|
+
detail?: string;
|
|
642
|
+
model?: string;
|
|
643
|
+
endpoint?: string;
|
|
644
|
+
}
|
|
645
|
+
/** The answer of one delegation write. */
|
|
646
|
+
export interface PanelDelegationWrite {
|
|
647
|
+
/** What happened, in the vocabulary {@link HostPatchResult} uses. */
|
|
648
|
+
outcome: string;
|
|
649
|
+
/** Absolute path edited, when one was. */
|
|
650
|
+
path?: string;
|
|
651
|
+
/** Which fact resolved that path. */
|
|
652
|
+
source?: string;
|
|
653
|
+
/** Why nothing was written, when nothing was. */
|
|
654
|
+
reason?: string;
|
|
655
|
+
/** Backup written before the edit, when one was. */
|
|
656
|
+
backupPath?: string;
|
|
657
|
+
/**
|
|
658
|
+
* Whether the change needs a DSH restart to take effect.
|
|
659
|
+
*
|
|
660
|
+
* Always `true` for an actual write: the host reads `tool-subagent`'s config
|
|
661
|
+
* at boot, and only this plugin's own fiber hot-updates.
|
|
662
|
+
*/
|
|
663
|
+
restartRequired: boolean;
|
|
364
664
|
}
|
|
365
665
|
/**
|
|
366
666
|
* Resolve one panel request into a status and a JSON body.
|
|
@@ -372,6 +672,21 @@ export interface PanelSource {
|
|
|
372
672
|
* @returns the answer to serialize.
|
|
373
673
|
*/
|
|
374
674
|
export declare function answerPanelRequest(source: PanelSource, request: IncomingMessage): PanelAnswer;
|
|
675
|
+
/** Largest body the probe route will read, so a request cannot make it buffer the world. */
|
|
676
|
+
export declare const PANEL_PROBE_BODY_MAX = 4096;
|
|
677
|
+
/**
|
|
678
|
+
* Resolve one panel request that may need to read a body or probe a connection.
|
|
679
|
+
*
|
|
680
|
+
* The synchronous {@link answerPanelRequest} stays the entry point for every
|
|
681
|
+
* route that needs neither, which is what keeps its existing callers (and their
|
|
682
|
+
* assertions) unchanged. This one handles the probe route, whose body names the
|
|
683
|
+
* profile and whose answer takes a real network round trip.
|
|
684
|
+
*
|
|
685
|
+
* @param source - the live facts.
|
|
686
|
+
* @param request - the incoming request.
|
|
687
|
+
* @returns the answer to serialize.
|
|
688
|
+
*/
|
|
689
|
+
export declare function answerPanelRequestAsync(source: PanelSource, request: IncomingMessage): Promise<PanelAnswer>;
|
|
375
690
|
/**
|
|
376
691
|
* Serve one resolved answer over a `node:http` response.
|
|
377
692
|
*
|
|
@@ -389,6 +704,15 @@ export declare function sendPanelAnswer(request: IncomingMessage, response: Pane
|
|
|
389
704
|
* One handler owns every path in the family, so the method/path decision lives
|
|
390
705
|
* in {@link answerPanelRequest} and cannot drift between routes; the
|
|
391
706
|
* `kind: 'exact'` paths mean the server never routes an unrelated URL here.
|
|
707
|
+
*
|
|
708
|
+
* ## Why the handler catches
|
|
709
|
+
*
|
|
710
|
+
* The Host maps a throw out of a route handler onto a bare `400` with an empty
|
|
711
|
+
* body, which erases the stack — the one thing needed to diagnose it. A panel
|
|
712
|
+
* route that fails must therefore answer for itself: `500` plus the real detail.
|
|
713
|
+
* This is not a substitute for handling a known failure where it happens (a
|
|
714
|
+
* missing service is read defensively, not caught here); it guarantees that an
|
|
715
|
+
* *unknown* one is still visible instead of silently becoming "bad request".
|
|
392
716
|
* @param source - the live facts.
|
|
393
717
|
* @returns the routes to register.
|
|
394
718
|
*/
|