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-mount.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { connectionTarget, resolveApiKeyWithSource, routingActive } from './config.js';
|
|
2
|
+
import { enableHostModelSelection, inspectHostModelSelection } from './host-patch.js';
|
|
2
3
|
import { formatTargetName } from './router.js';
|
|
3
4
|
import { buildPanelSnapshot, isPanelRequestAllowed, makePanelRoutes } from './panel-api.js';
|
|
5
|
+
import { probeSystemOne } from './systemone-probe.js';
|
|
4
6
|
/** Contexts that already mounted a panel; released when the activation disposes. */
|
|
5
7
|
const mounted = new WeakSet();
|
|
6
8
|
/**
|
|
@@ -31,7 +33,15 @@ export function panelPools(runtime) {
|
|
|
31
33
|
*/
|
|
32
34
|
// In-memory cache for models populated asynchronously
|
|
33
35
|
const catalogCache = new Map();
|
|
34
|
-
export function panelFacts(runtime, env = process.env, ctx) {
|
|
36
|
+
export function panelFacts(runtime, env = process.env, ctx, hostPatch) {
|
|
37
|
+
// Tell the lifecycle which scope to read the delegation capability in. A
|
|
38
|
+
// preset-hosted `subagent` is invisible from the registry's global view, so a
|
|
39
|
+
// panel that probes without a scope reports "unknown" forever on a host whose
|
|
40
|
+
// delegation is perfectly configured. A live agent (or, before any exists, a
|
|
41
|
+
// live preset) is the scope a session would actually be served from.
|
|
42
|
+
const scope = delegationScopeOf(ctx);
|
|
43
|
+
if (scope !== undefined)
|
|
44
|
+
runtime.noteDelegationScope(scope);
|
|
35
45
|
const cached = ctx ? catalogCache.get(ctx) : undefined;
|
|
36
46
|
if (ctx && (!cached || cached.length === 0 || cached.every(g => g.models.length === 0))) {
|
|
37
47
|
// Background async fetch so panelFacts remains synchronous
|
|
@@ -92,11 +102,205 @@ export function panelFacts(runtime, env = process.env, ctx) {
|
|
|
92
102
|
toolSurface: [...runtime.toolSurface],
|
|
93
103
|
ledger: runtime.ledger,
|
|
94
104
|
effort: runtime.effortStatusFeed.latest(),
|
|
95
|
-
|
|
105
|
+
// Resolved through the same function the backend construction and the probe
|
|
106
|
+
// use, so "the panel says the env var is empty" can no longer contradict a
|
|
107
|
+
// working backend: presence *and* provenance come from one chain.
|
|
108
|
+
...apiKeyFacts(effective.systemOne, env),
|
|
109
|
+
// Presence only, per profile. Gathered here (and not by the projection) so
|
|
110
|
+
// the one place that reads the environment is this file, and so the wire
|
|
111
|
+
// projection is handed booleans rather than anything it could leak.
|
|
112
|
+
profileKeys: profileKeyPresence(effective.systemOne, env),
|
|
113
|
+
// Both are read on every poll: the registry can change under a running host,
|
|
114
|
+
// and the patch file can be edited by a person while the panel is open. A
|
|
115
|
+
// cached copy of either would be exactly the stale fact the panel must not
|
|
116
|
+
// show.
|
|
117
|
+
delegationHealth: delegationHealthOf(runtime),
|
|
118
|
+
hostPatch: inspectHostModelSelection(hostPatch ?? { env }),
|
|
96
119
|
...(systemOneHealth === undefined ? {} : { systemOneHealth }),
|
|
97
120
|
...(modelCatalog === undefined ? {} : { modelCatalog })
|
|
98
121
|
};
|
|
99
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* The readiness facts the snapshot reports about the key in force.
|
|
125
|
+
*
|
|
126
|
+
* Presence and provenance are read from {@link resolveApiKeyWithSource} — the
|
|
127
|
+
* one chain — so the panel can say *where* the key came from instead of guessing
|
|
128
|
+
* from `apiKeyEnv`.
|
|
129
|
+
*
|
|
130
|
+
* @param systemOne - the connection block in force.
|
|
131
|
+
* @param env - environment the chain reads.
|
|
132
|
+
* @returns the presence/provenance facts for the snapshot.
|
|
133
|
+
*/
|
|
134
|
+
export function apiKeyFacts(systemOne, env = process.env) {
|
|
135
|
+
const resolved = resolveApiKeyWithSource(systemOne, env);
|
|
136
|
+
if (resolved === undefined)
|
|
137
|
+
return { apiKeyPresent: false };
|
|
138
|
+
if (!('key' in resolved)) {
|
|
139
|
+
return { apiKeyPresent: false, apiKeyLocked: true, apiKeyVariable: resolved.variable };
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
apiKeyPresent: true,
|
|
143
|
+
apiKeySource: resolved.source,
|
|
144
|
+
...(resolved.variable === undefined ? {} : { apiKeyVariable: resolved.variable })
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Gather key *presence* and provenance for every authored profile.
|
|
149
|
+
*
|
|
150
|
+
* Returns facts and nothing else: the panel renders a placeholder from
|
|
151
|
+
* `present` and never needs the value. `fromProfile` distinguishes a key stored in
|
|
152
|
+
* the settings document from one read out of the environment, and `variable`
|
|
153
|
+
* names the variable that supplied it — still without the value. Each row goes
|
|
154
|
+
* through {@link resolveApiKeyWithSource}, so a profile inheriting a fallback
|
|
155
|
+
* variable is reported the same way the backend would resolve it.
|
|
156
|
+
*
|
|
157
|
+
* @param systemOne - the connection block in force.
|
|
158
|
+
* @param env - environment the chain reads.
|
|
159
|
+
* @returns one presence record per profile name.
|
|
160
|
+
*/
|
|
161
|
+
export function profileKeyPresence(systemOne, env = process.env) {
|
|
162
|
+
const out = {};
|
|
163
|
+
for (const [name, profile] of Object.entries(systemOne.profiles ?? {})) {
|
|
164
|
+
// The profile's own fields, with no flat block folded in: a row reports what
|
|
165
|
+
// *it* supplies, and the panel already shows the flat block's own status.
|
|
166
|
+
const resolved = resolveApiKeyWithSource(profile, env);
|
|
167
|
+
// `locked` mirrors {@link ApiKeyFacts.apiKeyLocked}: the row named a variable
|
|
168
|
+
// that is empty, so the row says so instead of "no key anywhere".
|
|
169
|
+
const present = resolved !== undefined && 'key' in resolved;
|
|
170
|
+
out[name] = {
|
|
171
|
+
present,
|
|
172
|
+
fromProfile: present && resolved.source === 'profile',
|
|
173
|
+
...(resolved?.variable === undefined ? {} : { variable: resolved.variable }),
|
|
174
|
+
...(present ? {} : { locked: resolved !== undefined })
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return out;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Build the probe the test route calls for one profile name.
|
|
181
|
+
*
|
|
182
|
+
* Reads the profile out of the *live* configuration on every call, so a test
|
|
183
|
+
* started right after a save probes what was just saved. The key is handed to
|
|
184
|
+
* {@link probeSystemOne} and never leaves this process.
|
|
185
|
+
*
|
|
186
|
+
* @param runtime - the activation's runtime.
|
|
187
|
+
* @param env - environment the `apiKeyEnv` indirection reads.
|
|
188
|
+
* @returns the probe callback the panel source exposes.
|
|
189
|
+
*/
|
|
190
|
+
export function createSystemOneProbe(runtime, env = process.env, fetchImpl) {
|
|
191
|
+
return async (profile, signal) => {
|
|
192
|
+
const effective = runtime.effectiveConfig.systemOne;
|
|
193
|
+
// Only a profile names a connection (g-066). There is no block to fold in
|
|
194
|
+
// and, crucially, no "probe the active one" for an invocation that names
|
|
195
|
+
// nothing: `active` is what the runtime uses, so it is what the test has to
|
|
196
|
+
// use too, and when there is no active profile there is nothing to test.
|
|
197
|
+
const name = profile ?? effective.active;
|
|
198
|
+
if (name === undefined || name.length === 0) {
|
|
199
|
+
// An unnamed probe used to test whatever the flat block said, which is the
|
|
200
|
+
// implicit connection this goal removes. Say why nothing was tested.
|
|
201
|
+
return {
|
|
202
|
+
ok: false,
|
|
203
|
+
status: 'misconfigured',
|
|
204
|
+
latencyMs: 0,
|
|
205
|
+
profile: null,
|
|
206
|
+
detail: `no active profile is selected (${effective.unconfigured ?? 'unconfigured'}); activate a connection first`
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const targetProfile = effective.profiles?.[name];
|
|
210
|
+
if (targetProfile === undefined) {
|
|
211
|
+
// Naming a profile that does not exist is a caller error, not a connection
|
|
212
|
+
// failure: say so instead of probing something else under a wrong label.
|
|
213
|
+
return { ok: false, status: 'misconfigured', latencyMs: 0, profile: name, detail: `no profile named "${name}" is configured` };
|
|
214
|
+
}
|
|
215
|
+
// The same projection the runtime uses, including the profile's *selected*
|
|
216
|
+
// model: testing a connection tests the request the next decision sends.
|
|
217
|
+
const target = connectionTarget(effective, name, targetProfile);
|
|
218
|
+
// A row whose model cannot be sent is reported from its own projection — the
|
|
219
|
+
// runtime builds no transport for it either — but the probe still runs so
|
|
220
|
+
// the answer carries the same shape as every other one (g-066 att-002).
|
|
221
|
+
const result = await probeSystemOne(target, { env, signal, ...(fetchImpl === undefined ? {} : { fetch: fetchImpl }) });
|
|
222
|
+
return {
|
|
223
|
+
ok: result.ok,
|
|
224
|
+
status: result.status,
|
|
225
|
+
latencyMs: result.latencyMs,
|
|
226
|
+
profile: name ?? null,
|
|
227
|
+
...(result.httpStatus === undefined ? {} : { httpStatus: result.httpStatus }),
|
|
228
|
+
...(result.detail === undefined ? {} : { detail: result.detail }),
|
|
229
|
+
...(result.model === undefined ? {} : { model: result.model }),
|
|
230
|
+
...(result.endpoint === undefined ? {} : { endpoint: result.endpoint })
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* The scope a delegation-capability read should use, when one is available.
|
|
236
|
+
*
|
|
237
|
+
* Prefers a live agent: that is the scope whose view actually serves a session's
|
|
238
|
+
* tool calls. Falls back to the root agent, then to a live preset (the scope a
|
|
239
|
+
* fresh session would be composed from). `undefined` when the host exposes
|
|
240
|
+
* neither — the reading is then `unknown`, which is honest, rather than a global
|
|
241
|
+
* view that a preset-hosted tool can never appear in.
|
|
242
|
+
*
|
|
243
|
+
* ## Why the whole read sits inside one `try` (and why `get` comes first)
|
|
244
|
+
*
|
|
245
|
+
* On a real cordis context a missing `inject` entry does not read as
|
|
246
|
+
* `undefined`: the context proxy *throws* `cannot get property "agents" without
|
|
247
|
+
* inject`. This plugin deliberately does not inject `agents` (a host without
|
|
248
|
+
* that service must still activate the panel), so `ctx.agents` is precisely the
|
|
249
|
+
* read that throws here — and a `try` wrapped around only the *calls* leaves the
|
|
250
|
+
* failing read outside it. Optional chaining is no defence either: it guards
|
|
251
|
+
* against `null`/`undefined`, not against a getter that throws.
|
|
252
|
+
*
|
|
253
|
+
* `ctx.get(name)` is the reflection form: it reads the service store without the
|
|
254
|
+
* inject requirement and answers `undefined` when the service is absent. The
|
|
255
|
+
* property form stays as a fallback for hosts that expose no `get` (and for the
|
|
256
|
+
* plain-object contexts tests build) — inside the same `try`, because on cordis
|
|
257
|
+
* it is the throwing form.
|
|
258
|
+
*
|
|
259
|
+
* @param ctx - any context carrying the agent registry, when the host has one.
|
|
260
|
+
* @returns a readable scope, or `undefined` when nothing can be read as.
|
|
261
|
+
*/
|
|
262
|
+
function delegationScopeOf(ctx) {
|
|
263
|
+
try {
|
|
264
|
+
const holder = ctx;
|
|
265
|
+
if (holder === undefined || holder === null)
|
|
266
|
+
return undefined;
|
|
267
|
+
// `get` first: it cannot throw for an uninjected service. `??` then falls
|
|
268
|
+
// back to the property form for hosts that do not expose `get` — that read
|
|
269
|
+
// is the throwing one, which is why it stays inside this `try`.
|
|
270
|
+
const registry = (holder.get?.('agents') ?? holder.agents);
|
|
271
|
+
if (registry === undefined || registry === null)
|
|
272
|
+
return undefined;
|
|
273
|
+
const live = typeof registry.list === 'function' ? registry.list() : [];
|
|
274
|
+
if (Array.isArray(live) && live.length > 0)
|
|
275
|
+
return live[0];
|
|
276
|
+
const roots = typeof registry.roots === 'function' ? registry.roots() : [];
|
|
277
|
+
if (Array.isArray(roots) && roots.length > 0)
|
|
278
|
+
return roots[0];
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// Either the service is not injected (cordis throws on the property read) or
|
|
282
|
+
// the registry is closing mid-read. Neither is a capability fault: report no
|
|
283
|
+
// scope, which the panel shows as `unknown`, rather than pretend the host
|
|
284
|
+
// turned the capability off.
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
return undefined;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* The live delegation reading, reduced to what the projection carries.
|
|
291
|
+
*
|
|
292
|
+
* `undefined` — not a fabricated `missing-tool` — when this activation has no
|
|
293
|
+
* reading attached: a runtime built without the plugin lifecycle (a test, an
|
|
294
|
+
* embedder) must not be reported as a broken deployment.
|
|
295
|
+
* @param runtime - the activation's runtime.
|
|
296
|
+
* @returns the state and its reason, when one is known.
|
|
297
|
+
*/
|
|
298
|
+
function delegationHealthOf(runtime) {
|
|
299
|
+
const health = runtime.delegationHealth;
|
|
300
|
+
if (health === undefined)
|
|
301
|
+
return undefined;
|
|
302
|
+
return { state: health.state, ...(health.reason === undefined ? {} : { reason: health.reason }) };
|
|
303
|
+
}
|
|
100
304
|
/**
|
|
101
305
|
* Read the optional `remoteWebUiPairing` service.
|
|
102
306
|
* @param ctx - any context in the registrant's tree.
|
|
@@ -125,17 +329,34 @@ function pairingOf(ctx) {
|
|
|
125
329
|
* @param env - environment the API-key indirection reads.
|
|
126
330
|
* @returns the source {@link makePanelRoutes} serves.
|
|
127
331
|
*/
|
|
128
|
-
export function createPanelSource(ctx, runtime, env = process.env) {
|
|
332
|
+
export function createPanelSource(ctx, runtime, env = process.env, hostPatch) {
|
|
129
333
|
const pairing = pairingOf(ctx);
|
|
130
334
|
return {
|
|
131
335
|
allows: (request) => isPanelRequestAllowed(request, {
|
|
132
336
|
isPaired: pairing === undefined ? undefined : (candidate) => pairing.isPairedDevice(candidate)
|
|
133
337
|
}),
|
|
134
|
-
snapshot: (limit) => buildPanelSnapshot(panelFacts(runtime, env, ctx), limit),
|
|
338
|
+
snapshot: (limit) => buildPanelSnapshot(panelFacts(runtime, env, ctx, hostPatch), limit),
|
|
339
|
+
testSystemOne: createSystemOneProbe(runtime, env),
|
|
135
340
|
clearLedger: () => {
|
|
136
341
|
const cleared = runtime.ledger.getEntries().length;
|
|
137
342
|
runtime.ledger.clear();
|
|
138
343
|
return cleared;
|
|
344
|
+
},
|
|
345
|
+
// The one write outside this plugin's settings section. It is *not* a
|
|
346
|
+
// reaction to a broken capability — it is the user's explicit consent, sent
|
|
347
|
+
// from the toggle — and it never retries or repairs on its own.
|
|
348
|
+
enableDelegation: () => {
|
|
349
|
+
const result = enableHostModelSelection(hostPatch ?? { env });
|
|
350
|
+
const wrote = result.outcome === 'added-field' || result.outcome === 'added-row' || result.outcome === 'added-field-after-name';
|
|
351
|
+
return {
|
|
352
|
+
outcome: result.outcome,
|
|
353
|
+
...(result.path === undefined ? {} : { path: result.path }),
|
|
354
|
+
...(result.source === undefined ? {} : { source: result.source }),
|
|
355
|
+
...(result.reason === undefined ? {} : { reason: result.reason }),
|
|
356
|
+
...(result.backupPath === undefined ? {} : { backupPath: result.backupPath }),
|
|
357
|
+
// Only a real edit needs a restart; "already enabled" needs nothing.
|
|
358
|
+
restartRequired: wrote
|
|
359
|
+
};
|
|
139
360
|
}
|
|
140
361
|
};
|
|
141
362
|
}
|
|
@@ -146,7 +367,7 @@ export function createPanelSource(ctx, runtime, env = process.env) {
|
|
|
146
367
|
* @param runtime - the activation's runtime.
|
|
147
368
|
* @returns a disposer that releases this activation's panel ownership.
|
|
148
369
|
*/
|
|
149
|
-
export function mountReflexPanel(ctx, runtime) {
|
|
370
|
+
export function mountReflexPanel(ctx, runtime, options = {}) {
|
|
150
371
|
const inject = ctx.inject;
|
|
151
372
|
if (typeof inject !== 'function')
|
|
152
373
|
return () => { };
|
|
@@ -157,7 +378,7 @@ export function mountReflexPanel(ctx, runtime) {
|
|
|
157
378
|
mounted.add(ctx);
|
|
158
379
|
ctx.inject(['webServer'], (scope) => {
|
|
159
380
|
scope.effect(() => {
|
|
160
|
-
const source = createPanelSource(scope, runtime);
|
|
381
|
+
const source = createPanelSource(scope, runtime, process.env, options.hostPatch);
|
|
161
382
|
const disposers = makePanelRoutes(source).map((route) => scope.webServer.register(route));
|
|
162
383
|
return () => {
|
|
163
384
|
for (const dispose of disposers)
|
package/dist/panel-mount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
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G,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,KAAU,EAAE,EAAE;QACvC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE;YAChB,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACjD,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1F,OAAO,GAAG,EAAE;gBACV,KAAK,MAAM,OAAO,IAAI,SAAS;oBAAE,OAAO,EAAE,CAAC;YAC7C,CAAC,CAAC;QACJ,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Host-side mounting of the Reflex settings panel routes.\n *\n * Kept apart from {@link applyReflex} for one reason: the panel is the only\n * part of this plugin that needs a Web server, and the plugin must stay fully\n * functional without one (stdio MCP hosts, tests, headless embeds). So the\n * routes are mounted through a *scoped* cordis injection — `ctx.inject(\n * ['webServer'], …)` — which simply never activates when the service is absent,\n * instead of adding `webServer` to the plugin's own `inject` list and stalling\n * every activation on a service a headless host will never provide.\n *\n * One panel per registrant context: a deployment may activate this plugin more\n * than once (different tool prefixes), but two families on the same paths would\n * fight over the same URLs, so the first activation owns the panel and later\n * ones are reported and ignored.\n *\n * @module dsh-reflex/panel-mount\n */\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { IncomingMessage } from 'node:http';\n\nimport { resolveApiKey, routingActive } from './config.js';\nimport { formatTargetName } from './router.js';\nimport type { ReflexRuntime } from './bridge.js';\nimport {\n buildPanelSnapshot,\n isPanelRequestAllowed,\n makePanelRoutes,\n type PanelPoolView,\n type PanelRuntimeFacts,\n type PanelSource\n} from './panel-api.js';\n\n/** Contexts that already mounted a panel; released when the activation disposes. */\nconst mounted = new WeakSet<object>();\n\n/**\n * Project this activation's model pools onto the panel view.\n * @param runtime - the activation's runtime.\n * @returns one row per configured virtual model, in authored order.\n */\nexport function panelPools(runtime: ReflexRuntime): PanelPoolView[] {\n return runtime.modelRouter.modelIds.map((model) => ({\n model,\n entries: (runtime.modelRouter.poolFor(model) ?? []).map((entry) => ({\n provider: entry.provider,\n model: entry.model,\n ...(entry.description === undefined ? {} : { description: entry.description }),\n ...(entry.tags === undefined ? {} : { tags: [...entry.tags] })\n }))\n }));\n}\n\n/**\n * Gather one activation's live facts.\n *\n * Read fresh on every request rather than cached: the ledger grows between\n * polls, and a settings write re-resolves the config, so a cached snapshot would\n * be the one thing the panel must never show.\n * @param runtime - the activation's runtime.\n * @param env - environment the API-key indirection reads.\n * @returns the facts {@link buildPanelSnapshot} projects.\n */\n// In-memory cache for models populated asynchronously\nconst catalogCache = new Map<object, PanelRuntimeFacts['modelCatalog']>();\n\nexport function panelFacts(\n runtime: ReflexRuntime,\n env: Record<string, string | undefined> = process.env,\n ctx?: Context\n): PanelRuntimeFacts {\n const cached = ctx ? catalogCache.get(ctx) : undefined;\n if (ctx && (!cached || cached.length === 0 || cached.every(g => g.models.length === 0))) {\n // Background async fetch so panelFacts remains synchronous\n (async () => {\n try {\n const llm = (ctx as any).get?.('llm');\n if (llm?.listProviders) {\n const providers = (await llm.listProviders()) ?? [];\n const list = (\n await Promise.all(\n providers.map(async (p: any) => {\n const pid = typeof p === 'string' ? p : (p?.id ?? p);\n const pname = typeof p === 'string' ? p : (p?.name ?? pid);\n if (pid === effective.routing.virtualProvider) return null;\n let models: any[] = [];\n try {\n models = (await llm.listModels?.(pid)) ?? [];\n } catch {}\n return {\n id: pid,\n name: pname,\n models: models.map((m: any) => ({\n id: typeof m === 'string' ? m : m.id,\n name: typeof m === 'string' ? m : (m.name ?? m.id)\n }))\n };\n })\n )\n ).filter(Boolean);\n if (list.length > 0) catalogCache.set(ctx, list);\n }\n } catch (err: any) {}\n })();\n }\n\n const modelCatalog = ctx ? catalogCache.get(ctx) : undefined;\n\n // One read of the live projection: it also lazily applies a committed\n // config-only save, so a poll right after the panel's own write already shows\n // the new values instead of the previous activation snapshot.\n const effective = runtime.effectiveConfig;\n const systemOneHealth = runtime.systemOneHealth();\n // `panelPools` and the fallback read the router, whose policy is live: the\n // loader commits a routing edit without remounting the plugin, so what the\n // panel reports is the value the next request will actually use.\n const pools = panelPools(runtime);\n const fallback = runtime.modelRouter.fallback;\n\n return {\n // `effectiveConfig` reports the values currently in force for every block a\n // config-only save can change (effort, interventions, tools, backend,\n // ledger sink, routing lifecycle): the startup snapshot would be exactly\n // the stale value the panel must not show.\n config: effective,\n backendName: runtime.backendName,\n pools,\n routingFallback: fallback === undefined ? null : formatTargetName(fallback),\n routingActive: routingActive(effective),\n // Copied, not aliased: the runtime republishes its surface on every\n // `tools/change`, and a snapshot must not follow it after the fact.\n toolSurface: [...runtime.toolSurface],\n ledger: runtime.ledger,\n effort: runtime.effortStatusFeed.latest(),\n apiKeyPresent: resolveApiKey(effective.systemOne, env) !== undefined,\n ...(systemOneHealth === undefined ? {} : { systemOneHealth }),\n ...(modelCatalog === undefined ? {} : { modelCatalog })\n };\n}\n\n/** Shape of the optional pairing service, as far as this plugin depends on it. */\ninterface PairingService {\n isPairedDevice(request: IncomingMessage): boolean;\n}\n\n/**\n * Read the optional `remoteWebUiPairing` service.\n * @param ctx - any context in the registrant's tree.\n * @returns the service, or `undefined` when the deployment has no pairing.\n */\nfunction pairingOf(ctx: Context): PairingService | undefined {\n const get = (ctx as { get?: (name: string, strict?: boolean) => unknown }).get;\n if (typeof get !== 'function') return undefined;\n let value: unknown;\n try {\n value = get.call(ctx, 'remoteWebUiPairing', false);\n } catch {\n return undefined;\n }\n if (value === null || typeof value !== 'object') return undefined;\n const candidate = value as Partial<PairingService>;\n return typeof candidate.isPairedDevice === 'function' ? (candidate as PairingService) : undefined;\n}\n\n/**\n * Build the live source the panel routes answer from.\n * @param ctx - the registrant context, used only for the optional pairing check.\n * @param runtime - the activation's runtime.\n * @param env - environment the API-key indirection reads.\n * @returns the source {@link makePanelRoutes} serves.\n */\nexport function createPanelSource(\n ctx: Context,\n runtime: ReflexRuntime,\n env: Record<string, string | undefined> = process.env\n): PanelSource {\n const pairing = pairingOf(ctx);\n return {\n allows: (request) =>\n isPanelRequestAllowed(request, {\n isPaired: pairing === undefined ? undefined : (candidate) => pairing.isPairedDevice(candidate)\n }),\n snapshot: (limit) => buildPanelSnapshot(panelFacts(runtime, env, ctx), limit),\n clearLedger: () => {\n const cleared = runtime.ledger.getEntries().length;\n runtime.ledger.clear();\n return cleared;\n }\n };\n}\n\n/**\n * Mount the panel routes for one activation, if this Host serves HTTP.\n *\n * @param ctx - the registrant context.\n * @param runtime - the activation's runtime.\n * @returns a disposer that releases this activation's panel ownership.\n */\nexport function mountReflexPanel(ctx: Context, runtime: ReflexRuntime): () => void {\n const inject = (ctx as { inject?: unknown }).inject;\n if (typeof inject !== 'function') return () => {};\n if (mounted.has(ctx)) {\n ctx.logger?.('dsh-reflex')?.warn('the reflex settings panel is already mounted on this context; the first activation owns it');\n return () => {};\n }\n mounted.add(ctx);\n\n ctx.inject(['webServer'], (scope: any) => {\n scope.effect(() => {\n const source = createPanelSource(scope, runtime);\n const disposers = makePanelRoutes(source).map((route) => scope.webServer.register(route));\n return () => {\n for (const dispose of disposers) dispose();\n };\n }, 'reflex panel routes');\n });\n\n return () => {\n mounted.delete(ctx);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"panel-mount.js","sourceRoot":"","sources":["../src/panel-mount.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EAEd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAyB,MAAM,iBAAiB,CAAC;AAC7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,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J,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAY,EACZ,OAAsB,EACtB,UAA4C,EAAE;IAE9C,MAAM,MAAM,GAAI,GAA4B,CAAC,MAAM,CAAC;IACpD,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClD,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,GAAG,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,4FAA4F,CAAC,CAAC;QAC/H,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEjB,GAAG,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,KAAU,EAAE,EAAE;QACvC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE;YAChB,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;YACjF,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1F,OAAO,GAAG,EAAE;gBACV,KAAK,MAAM,OAAO,IAAI,SAAS;oBAAE,OAAO,EAAE,CAAC;YAC7C,CAAC,CAAC;QACJ,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Host-side mounting of the Reflex settings panel routes.\n *\n * Kept apart from {@link applyReflex} for one reason: the panel is the only\n * part of this plugin that needs a Web server, and the plugin must stay fully\n * functional without one (stdio MCP hosts, tests, headless embeds). So the\n * routes are mounted through a *scoped* cordis injection — `ctx.inject(\n * ['webServer'], …)` — which simply never activates when the service is absent,\n * instead of adding `webServer` to the plugin's own `inject` list and stalling\n * every activation on a service a headless host will never provide.\n *\n * One panel per registrant context: a deployment may activate this plugin more\n * than once (different tool prefixes), but two families on the same paths would\n * fight over the same URLs, so the first activation owns the panel and later\n * ones are reported and ignored.\n *\n * @module dsh-reflex/panel-mount\n */\nimport type { Agent } from '@deepseek-ai/dsh-agent';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { IncomingMessage } from 'node:http';\n\nimport {\n connectionTarget,\n resolveApiKeyWithSource,\n routingActive,\n type ResolvedSystemOneConfig\n} from './config.js';\nimport { enableHostModelSelection, inspectHostModelSelection, type HostPatchOptions } from './host-patch.js';\nimport { formatTargetName } from './router.js';\nimport type { ReflexRuntime } from './bridge.js';\nimport {\n buildPanelSnapshot,\n isPanelRequestAllowed,\n makePanelRoutes,\n type PanelPoolView,\n type PanelProbeAnswer,\n type PanelRuntimeFacts,\n type PanelSource\n} from './panel-api.js';\nimport { probeSystemOne } from './systemone-probe.js';\nimport type { DelegationHealthState } from './delegation-health.js';\n\n/** Contexts that already mounted a panel; released when the activation disposes. */\nconst mounted = new WeakSet<object>();\n\n/**\n * Project this activation's model pools onto the panel view.\n * @param runtime - the activation's runtime.\n * @returns one row per configured virtual model, in authored order.\n */\nexport function panelPools(runtime: ReflexRuntime): PanelPoolView[] {\n return runtime.modelRouter.modelIds.map((model) => ({\n model,\n entries: (runtime.modelRouter.poolFor(model) ?? []).map((entry) => ({\n provider: entry.provider,\n model: entry.model,\n ...(entry.description === undefined ? {} : { description: entry.description }),\n ...(entry.tags === undefined ? {} : { tags: [...entry.tags] })\n }))\n }));\n}\n\n/**\n * Gather one activation's live facts.\n *\n * Read fresh on every request rather than cached: the ledger grows between\n * polls, and a settings write re-resolves the config, so a cached snapshot would\n * be the one thing the panel must never show.\n * @param runtime - the activation's runtime.\n * @param env - environment the API-key indirection reads.\n * @returns the facts {@link buildPanelSnapshot} projects.\n */\n// In-memory cache for models populated asynchronously\nconst catalogCache = new Map<object, PanelRuntimeFacts['modelCatalog']>();\n\nexport function panelFacts(\n runtime: ReflexRuntime,\n env: Record<string, string | undefined> = process.env,\n ctx?: Context,\n hostPatch?: HostPatchOptions\n): PanelRuntimeFacts {\n // Tell the lifecycle which scope to read the delegation capability in. A\n // preset-hosted `subagent` is invisible from the registry's global view, so a\n // panel that probes without a scope reports \"unknown\" forever on a host whose\n // delegation is perfectly configured. A live agent (or, before any exists, a\n // live preset) is the scope a session would actually be served from.\n const scope = delegationScopeOf(ctx);\n if (scope !== undefined) runtime.noteDelegationScope(scope);\n\n const cached = ctx ? catalogCache.get(ctx) : undefined;\n if (ctx && (!cached || cached.length === 0 || cached.every(g => g.models.length === 0))) {\n // Background async fetch so panelFacts remains synchronous\n (async () => {\n try {\n const llm = (ctx as any).get?.('llm');\n if (llm?.listProviders) {\n const providers = (await llm.listProviders()) ?? [];\n const list = (\n await Promise.all(\n providers.map(async (p: any) => {\n const pid = typeof p === 'string' ? p : (p?.id ?? p);\n const pname = typeof p === 'string' ? p : (p?.name ?? pid);\n if (pid === effective.routing.virtualProvider) return null;\n let models: any[] = [];\n try {\n models = (await llm.listModels?.(pid)) ?? [];\n } catch {}\n return {\n id: pid,\n name: pname,\n models: models.map((m: any) => ({\n id: typeof m === 'string' ? m : m.id,\n name: typeof m === 'string' ? m : (m.name ?? m.id)\n }))\n };\n })\n )\n ).filter(Boolean);\n if (list.length > 0) catalogCache.set(ctx, list);\n }\n } catch (err: any) {}\n })();\n }\n\n const modelCatalog = ctx ? catalogCache.get(ctx) : undefined;\n\n // One read of the live projection: it also lazily applies a committed\n // config-only save, so a poll right after the panel's own write already shows\n // the new values instead of the previous activation snapshot.\n const effective = runtime.effectiveConfig;\n const systemOneHealth = runtime.systemOneHealth();\n // `panelPools` and the fallback read the router, whose policy is live: the\n // loader commits a routing edit without remounting the plugin, so what the\n // panel reports is the value the next request will actually use.\n const pools = panelPools(runtime);\n const fallback = runtime.modelRouter.fallback;\n\n return {\n // `effectiveConfig` reports the values currently in force for every block a\n // config-only save can change (effort, interventions, tools, backend,\n // ledger sink, routing lifecycle): the startup snapshot would be exactly\n // the stale value the panel must not show.\n config: effective,\n backendName: runtime.backendName,\n pools,\n routingFallback: fallback === undefined ? null : formatTargetName(fallback),\n routingActive: routingActive(effective),\n // Copied, not aliased: the runtime republishes its surface on every\n // `tools/change`, and a snapshot must not follow it after the fact.\n toolSurface: [...runtime.toolSurface],\n ledger: runtime.ledger,\n effort: runtime.effortStatusFeed.latest(),\n // Resolved through the same function the backend construction and the probe\n // use, so \"the panel says the env var is empty\" can no longer contradict a\n // working backend: presence *and* provenance come from one chain.\n ...apiKeyFacts(effective.systemOne, env),\n // Presence only, per profile. Gathered here (and not by the projection) so\n // the one place that reads the environment is this file, and so the wire\n // projection is handed booleans rather than anything it could leak.\n profileKeys: profileKeyPresence(effective.systemOne, env),\n // Both are read on every poll: the registry can change under a running host,\n // and the patch file can be edited by a person while the panel is open. A\n // cached copy of either would be exactly the stale fact the panel must not\n // show.\n delegationHealth: delegationHealthOf(runtime),\n hostPatch: inspectHostModelSelection(hostPatch ?? { env }),\n ...(systemOneHealth === undefined ? {} : { systemOneHealth }),\n ...(modelCatalog === undefined ? {} : { modelCatalog })\n };\n}\n\n/**\n * Key readiness as the panel needs it: presence, provenance, and the *reason*\n * for an absence.\n *\n * `apiKeyLocked` is the fact g-059 added: the block **named** a variable and that\n * variable is empty. It is deliberately separate from plain\n * `apiKeyPresent === false`, which now means \"nothing was named and nothing was\n * exported\" — the two need different copy, and \"the name I typed is empty\" must\n * not read as \"no key anywhere\".\n *\n * The value is never part of this type: the facts are booleans, a source tag,\n * and a variable *name*.\n */\nexport interface ApiKeyFacts {\n /** Whether a key resolved. */\n apiKeyPresent: boolean;\n /** Where the key came from when {@link apiKeyPresent}. */\n apiKeySource?: 'profile' | 'env' | 'fallback';\n /**\n * The variable behind the key (when present), or the named-but-empty variable\n * (when locked). Absent only when nothing was named and nothing resolved.\n */\n apiKeyVariable?: string;\n /**\n * The block named a variable, that variable is empty, and the lookup stopped\n * there on purpose: no fallback was consulted and none will be.\n */\n apiKeyLocked?: boolean;\n}\n\n/**\n * The readiness facts the snapshot reports about the key in force.\n *\n * Presence and provenance are read from {@link resolveApiKeyWithSource} — the\n * one chain — so the panel can say *where* the key came from instead of guessing\n * from `apiKeyEnv`.\n *\n * @param systemOne - the connection block in force.\n * @param env - environment the chain reads.\n * @returns the presence/provenance facts for the snapshot.\n */\nexport function apiKeyFacts(\n systemOne: Pick<ResolvedSystemOneConfig, 'apiKey' | 'apiKeyEnv'>,\n env: Record<string, string | undefined> = process.env\n): ApiKeyFacts {\n const resolved = resolveApiKeyWithSource(systemOne, env);\n if (resolved === undefined) return { apiKeyPresent: false };\n if (!('key' in resolved)) {\n return { apiKeyPresent: false, apiKeyLocked: true, apiKeyVariable: resolved.variable };\n }\n return {\n apiKeyPresent: true,\n apiKeySource: resolved.source,\n ...(resolved.variable === undefined ? {} : { apiKeyVariable: resolved.variable })\n };\n}\n\n/**\n * Gather key *presence* and provenance for every authored profile.\n *\n * Returns facts and nothing else: the panel renders a placeholder from\n * `present` and never needs the value. `fromProfile` distinguishes a key stored in\n * the settings document from one read out of the environment, and `variable`\n * names the variable that supplied it — still without the value. Each row goes\n * through {@link resolveApiKeyWithSource}, so a profile inheriting a fallback\n * variable is reported the same way the backend would resolve it.\n *\n * @param systemOne - the connection block in force.\n * @param env - environment the chain reads.\n * @returns one presence record per profile name.\n */\nexport function profileKeyPresence(\n systemOne: Pick<ResolvedSystemOneConfig, 'profiles'>,\n env: Record<string, string | undefined> = process.env\n): Record<string, { present: boolean; fromProfile: boolean; variable?: string; locked?: boolean }> {\n const out: Record<string, { present: boolean; fromProfile: boolean; variable?: string; locked?: boolean }> = {};\n for (const [name, profile] of Object.entries(systemOne.profiles ?? {})) {\n // The profile's own fields, with no flat block folded in: a row reports what\n // *it* supplies, and the panel already shows the flat block's own status.\n const resolved = resolveApiKeyWithSource(profile, env);\n // `locked` mirrors {@link ApiKeyFacts.apiKeyLocked}: the row named a variable\n // that is empty, so the row says so instead of \"no key anywhere\".\n const present = resolved !== undefined && 'key' in resolved;\n out[name] = {\n present,\n fromProfile: present && resolved.source === 'profile',\n ...(resolved?.variable === undefined ? {} : { variable: resolved.variable }),\n ...(present ? {} : { locked: resolved !== undefined })\n };\n }\n return out;\n}\n\n/**\n * Build the probe the test route calls for one profile name.\n *\n * Reads the profile out of the *live* configuration on every call, so a test\n * started right after a save probes what was just saved. The key is handed to\n * {@link probeSystemOne} and never leaves this process.\n *\n * @param runtime - the activation's runtime.\n * @param env - environment the `apiKeyEnv` indirection reads.\n * @returns the probe callback the panel source exposes.\n */\nexport function createSystemOneProbe(\n runtime: ReflexRuntime,\n env: Record<string, string | undefined> = process.env,\n fetchImpl?: typeof fetch\n): (profile: string | undefined, signal: AbortSignal) => Promise<PanelProbeAnswer> {\n return async (profile, signal) => {\n const effective = runtime.effectiveConfig.systemOne;\n // Only a profile names a connection (g-066). There is no block to fold in\n // and, crucially, no \"probe the active one\" for an invocation that names\n // nothing: `active` is what the runtime uses, so it is what the test has to\n // use too, and when there is no active profile there is nothing to test.\n const name = profile ?? effective.active;\n if (name === undefined || name.length === 0) {\n // An unnamed probe used to test whatever the flat block said, which is the\n // implicit connection this goal removes. Say why nothing was tested.\n return {\n ok: false,\n status: 'misconfigured',\n latencyMs: 0,\n profile: null,\n detail: `no active profile is selected (${effective.unconfigured ?? 'unconfigured'}); activate a connection first`\n };\n }\n const targetProfile = effective.profiles?.[name];\n if (targetProfile === undefined) {\n // Naming a profile that does not exist is a caller error, not a connection\n // failure: say so instead of probing something else under a wrong label.\n return { ok: false, status: 'misconfigured', latencyMs: 0, profile: name, detail: `no profile named \"${name}\" is configured` };\n }\n // The same projection the runtime uses, including the profile's *selected*\n // model: testing a connection tests the request the next decision sends.\n const target = connectionTarget(effective, name, targetProfile);\n // A row whose model cannot be sent is reported from its own projection — the\n // runtime builds no transport for it either — but the probe still runs so\n // the answer carries the same shape as every other one (g-066 att-002).\n const result = await probeSystemOne(target, { env, signal, ...(fetchImpl === undefined ? {} : { fetch: fetchImpl }) });\n return {\n ok: result.ok,\n status: result.status,\n latencyMs: result.latencyMs,\n profile: name ?? null,\n ...(result.httpStatus === undefined ? {} : { httpStatus: result.httpStatus }),\n ...(result.detail === undefined ? {} : { detail: result.detail }),\n ...(result.model === undefined ? {} : { model: result.model }),\n ...(result.endpoint === undefined ? {} : { endpoint: result.endpoint })\n };\n };\n}\n\n/**\n * The scope a delegation-capability read should use, when one is available.\n *\n * Prefers a live agent: that is the scope whose view actually serves a session's\n * tool calls. Falls back to the root agent, then to a live preset (the scope a\n * fresh session would be composed from). `undefined` when the host exposes\n * neither — the reading is then `unknown`, which is honest, rather than a global\n * view that a preset-hosted tool can never appear in.\n *\n * ## Why the whole read sits inside one `try` (and why `get` comes first)\n *\n * On a real cordis context a missing `inject` entry does not read as\n * `undefined`: the context proxy *throws* `cannot get property \"agents\" without\n * inject`. This plugin deliberately does not inject `agents` (a host without\n * that service must still activate the panel), so `ctx.agents` is precisely the\n * read that throws here — and a `try` wrapped around only the *calls* leaves the\n * failing read outside it. Optional chaining is no defence either: it guards\n * against `null`/`undefined`, not against a getter that throws.\n *\n * `ctx.get(name)` is the reflection form: it reads the service store without the\n * inject requirement and answers `undefined` when the service is absent. The\n * property form stays as a fallback for hosts that expose no `get` (and for the\n * plain-object contexts tests build) — inside the same `try`, because on cordis\n * it is the throwing form.\n *\n * @param ctx - any context carrying the agent registry, when the host has one.\n * @returns a readable scope, or `undefined` when nothing can be read as.\n */\nfunction delegationScopeOf(ctx: Context | undefined): Agent | undefined {\n try {\n const holder = ctx as { get?: (name: string) => unknown; agents?: unknown } | undefined;\n if (holder === undefined || holder === null) return undefined;\n // `get` first: it cannot throw for an uninjected service. `??` then falls\n // back to the property form for hosts that do not expose `get` — that read\n // is the throwing one, which is why it stays inside this `try`.\n const registry = (holder.get?.('agents') ?? holder.agents) as\n | { list?: () => Agent[]; roots?: () => Agent[] }\n | undefined;\n if (registry === undefined || registry === null) return undefined;\n const live = typeof registry.list === 'function' ? registry.list() : [];\n if (Array.isArray(live) && live.length > 0) return live[0];\n const roots = typeof registry.roots === 'function' ? registry.roots() : [];\n if (Array.isArray(roots) && roots.length > 0) return roots[0];\n } catch {\n // Either the service is not injected (cordis throws on the property read) or\n // the registry is closing mid-read. Neither is a capability fault: report no\n // scope, which the panel shows as `unknown`, rather than pretend the host\n // turned the capability off.\n return undefined;\n }\n return undefined;\n}\n\n/**\n * The live delegation reading, reduced to what the projection carries.\n *\n * `undefined` — not a fabricated `missing-tool` — when this activation has no\n * reading attached: a runtime built without the plugin lifecycle (a test, an\n * embedder) must not be reported as a broken deployment.\n * @param runtime - the activation's runtime.\n * @returns the state and its reason, when one is known.\n */\nfunction delegationHealthOf(runtime: ReflexRuntime): { state: DelegationHealthState; reason?: string } | undefined {\n const health = runtime.delegationHealth;\n if (health === undefined) return undefined;\n return { state: health.state, ...(health.reason === undefined ? {} : { reason: health.reason }) };\n}\n\n/** Shape of the optional pairing service, as far as this plugin depends on it. */\ninterface PairingService {\n isPairedDevice(request: IncomingMessage): boolean;\n}\n\n/**\n * Read the optional `remoteWebUiPairing` service.\n * @param ctx - any context in the registrant's tree.\n * @returns the service, or `undefined` when the deployment has no pairing.\n */\nfunction pairingOf(ctx: Context): PairingService | undefined {\n const get = (ctx as { get?: (name: string, strict?: boolean) => unknown }).get;\n if (typeof get !== 'function') return undefined;\n let value: unknown;\n try {\n value = get.call(ctx, 'remoteWebUiPairing', false);\n } catch {\n return undefined;\n }\n if (value === null || typeof value !== 'object') return undefined;\n const candidate = value as Partial<PairingService>;\n return typeof candidate.isPairedDevice === 'function' ? (candidate as PairingService) : undefined;\n}\n\n/**\n * Build the live source the panel routes answer from.\n * @param ctx - the registrant context, used only for the optional pairing check.\n * @param runtime - the activation's runtime.\n * @param env - environment the API-key indirection reads.\n * @returns the source {@link makePanelRoutes} serves.\n */\nexport function createPanelSource(\n ctx: Context,\n runtime: ReflexRuntime,\n env: Record<string, string | undefined> = process.env,\n hostPatch?: HostPatchOptions\n): PanelSource {\n const pairing = pairingOf(ctx);\n return {\n allows: (request) =>\n isPanelRequestAllowed(request, {\n isPaired: pairing === undefined ? undefined : (candidate) => pairing.isPairedDevice(candidate)\n }),\n snapshot: (limit) => buildPanelSnapshot(panelFacts(runtime, env, ctx, hostPatch), limit),\n testSystemOne: createSystemOneProbe(runtime, env),\n clearLedger: () => {\n const cleared = runtime.ledger.getEntries().length;\n runtime.ledger.clear();\n return cleared;\n },\n // The one write outside this plugin's settings section. It is *not* a\n // reaction to a broken capability — it is the user's explicit consent, sent\n // from the toggle — and it never retries or repairs on its own.\n enableDelegation: () => {\n const result = enableHostModelSelection(hostPatch ?? { env });\n const wrote = result.outcome === 'added-field' || result.outcome === 'added-row' || result.outcome === 'added-field-after-name';\n return {\n outcome: result.outcome,\n ...(result.path === undefined ? {} : { path: result.path }),\n ...(result.source === undefined ? {} : { source: result.source }),\n ...(result.reason === undefined ? {} : { reason: result.reason }),\n ...(result.backupPath === undefined ? {} : { backupPath: result.backupPath }),\n // Only a real edit needs a restart; \"already enabled\" needs nothing.\n restartRequired: wrote\n };\n }\n };\n}\n\n/**\n * Mount the panel routes for one activation, if this Host serves HTTP.\n *\n * @param ctx - the registrant context.\n * @param runtime - the activation's runtime.\n * @returns a disposer that releases this activation's panel ownership.\n */\nexport function mountReflexPanel(\n ctx: Context,\n runtime: ReflexRuntime,\n options: { hostPatch?: HostPatchOptions } = {}\n): () => void {\n const inject = (ctx as { inject?: unknown }).inject;\n if (typeof inject !== 'function') return () => {};\n if (mounted.has(ctx)) {\n ctx.logger?.('dsh-reflex')?.warn('the reflex settings panel is already mounted on this context; the first activation owns it');\n return () => {};\n }\n mounted.add(ctx);\n\n ctx.inject(['webServer'], (scope: any) => {\n scope.effect(() => {\n const source = createPanelSource(scope, runtime, process.env, options.hostPatch);\n const disposers = makePanelRoutes(source).map((route) => scope.webServer.register(route));\n return () => {\n for (const dispose of disposers) dispose();\n };\n }, 'reflex panel routes');\n });\n\n return () => {\n mounted.delete(ctx);\n };\n}\n"]}
|
package/dist/routing.d.ts
CHANGED
|
@@ -7,38 +7,43 @@ import { ReflexVirtualAdapter } from './virtual-adapter.js';
|
|
|
7
7
|
* Install the virtual provider route and the interception layers that route its
|
|
8
8
|
* requests through System 1.
|
|
9
9
|
*
|
|
10
|
-
* Layer 1 — `agent/
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
10
|
+
* Layer 1 — `agent/pre-step` (waterfall): the loop fixes the step's route and
|
|
11
|
+
* reasoning effort from `this.model.current()` *before* it dispatches anything,
|
|
12
|
+
* and `agent/request` may no longer propose a different one (DSH 0.2.2 rejects
|
|
13
|
+
* it: "a replacement may adjust controls but must keep the provider, model, and
|
|
14
|
+
* reasoning effort selection"). So the decision is taken here instead, and
|
|
15
|
+
* written into `payload.modelSelection` — the same object `dsh-agent-loop`
|
|
16
|
+
* keeps as its local `selection`, which is what `prepareRequest` compares the
|
|
17
|
+
* request against. See {@link installModelRouting} for why that write is safe.
|
|
18
|
+
*
|
|
19
|
+
* Layer 2 — the same decision chooses the turn's reasoning effort. A selection
|
|
19
20
|
* carrying the `reflex`/`auto` marker (or a deployment that configured the
|
|
20
21
|
* marker) has no physical effort id yet; {@link EffortInterceptor} turns it into
|
|
21
22
|
* one, projects it onto the routed model's vocabulary, audits it in the session
|
|
22
|
-
* log, and publishes it to the status feed. A
|
|
23
|
-
* effort is
|
|
23
|
+
* log, and publishes it to the status feed. A selection that named a concrete
|
|
24
|
+
* effort is only re-worded to fit the routed model — never adapted.
|
|
24
25
|
*
|
|
25
26
|
* Layer 3 — the virtual adapter's `stream()`: anything that does not pass
|
|
26
27
|
* through layer 1 (hand-built one-shot calls, `prepareCall()` consumers) is
|
|
27
28
|
* routed at dispatch time and delegated to the physical adapter through
|
|
28
29
|
* `ctx.llm.stream`.
|
|
29
30
|
*
|
|
30
|
-
* The task text each decision reasons about
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* rather than inheriting its parent's decision. That is also the input the
|
|
34
|
-
* effort decision reads, because the request waterfall only sees a frozen config.
|
|
31
|
+
* The task text each decision reasons about is the step's own user messages: a
|
|
32
|
+
* subagent's first step carries its delegated task, so a delegated agent routes
|
|
33
|
+
* on *its own* task rather than inheriting its parent's decision.
|
|
35
34
|
*
|
|
36
|
-
* The
|
|
37
|
-
* input seen so far), and every routed
|
|
35
|
+
* The listener also accumulates each agent's *session size* (characters of step
|
|
36
|
+
* input seen so far), and every routed step remembers the physical model it
|
|
38
37
|
* landed on. Both ride into the next decision as cache-affinity facts, so a
|
|
39
38
|
* session that already holds a warm prompt prefix is not moved onto another
|
|
40
39
|
* physical model for a marginal score difference.
|
|
41
40
|
*
|
|
41
|
+
* `agent/request` is still listened to, but strictly read-only: it awaits the
|
|
42
|
+
* rest of the waterfall and hands the configuration back untouched. It is kept
|
|
43
|
+
* because the listener is the only place that can *observe* the configuration
|
|
44
|
+
* the loop really uses, and a future audit may want it — it must never write a
|
|
45
|
+
* field again.
|
|
46
|
+
*
|
|
42
47
|
* @module dsh-reflex/routing
|
|
43
48
|
*/
|
|
44
49
|
/** Dependencies of {@link installModelRouting}. */
|