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.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-api.js","sourceRoot":"","sources":["../src/panel-api.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGxD,iFAAiF;AACjF,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE7C,+CAA+C;AAC/C,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAE5C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,GAAG,UAAU,QAAQ;IAC/B,MAAM,EAAE,GAAG,UAAU,SAAS;IAC9B,WAAW,EAAE,GAAG,UAAU,eAAe;CACjC,CAAC;AAEX,gFAAgF;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,iFAAiF;AACjF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AA8P3C;;;;GAIG;AACH,SAAS,UAAU,CAAC,KAAwB;IAC1C,IAAI,KAAK,CAAC,eAAe,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACrD,IAAI,KAAK,CAAC,eAAe,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,eAAe,CAAC;IACtE,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/C,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,IAAI,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ings panel.\n *\n * The browser half of this plugin (`./client`) renders the settings page, but a\n * client bundle may not value-import another plugin and the plugin's own live\n * facts — decision throughput, saved tokens, the last adaptive decision — only\n * exist in the Host process. The two halves therefore meet on the one channel a\n * third-party plugin can own without a generated Remote namespace: a small,\n * explicitly projected JSON route family served by `ctx.webServer`.\n *\n * Design rules this module keeps:\n *\n * - **Explicit projection.** Every payload field is projected from the runtime\n * by hand. `LedgerEntry.details` is an open record written by several code\n * paths, so it is narrowed to five known scalar fields instead of serialized\n * whole — the panel shows what it declares, and nothing else rides the wire.\n * - **Secrets stay home.** The connection block carries the *name* of the API\n * key's environment variable; the key's value is never read here, so no\n * response can leak it.\n * - **Loopback by default.** The route family answers the local GUI only, plus\n * whatever the optional `remoteWebUiPairing` service recognises as a paired\n * device, so a LAN-exposed Host does not publish its ledger to strangers.\n *\n * @module dsh-reflex/panel-api\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nimport type { DecisionLedger, LedgerEntry } from './vendor/harness-reflex/index.js';\nimport type { WebRoute } from '@deepseek-ai/dsh-host-webserver';\n\nimport type { ResolvedReflexConfig } from './config.js';\nimport { INTERVENTION_CAPABILITIES } from './config.js';\nimport type { ReflexEffortStatus } from './effort.js';\n\n/** Version reported by the panel; kept in step with `package.json` by a test. */\nexport const REFLEX_PLUGIN_VERSION = '0.1.0';\n\n/** Namespace every panel route lives under. */\nexport const PANEL_BASE = '/dsh-reflex/api';\n\n/** The route family, as the panel's phases address it. */\nexport const PANEL_ROUTES = {\n snapshot: `${PANEL_BASE}/panel`,\n health: `${PANEL_BASE}/health`,\n clearLedger: `${PANEL_BASE}/ledger/clear`\n} as const;\n\n/** How many recent ledger entries one snapshot carries. Default 25, cap 200. */\nexport const PANEL_LEDGER_WINDOW = 25;\n\n/** Largest accepted `?limit=` value, so one request cannot ask for the world. */\nexport const PANEL_LEDGER_WINDOW_MAX = 200;\n\n/**\n * One candidate of a virtual model pool, as the panel renders it.\n *\n * Mirrors the authored `ReflexModelPoolEntry` rather than the resolved router\n * entry: the panel edits authored configuration, so it shows exactly the keys\n * the settings document can carry.\n */\nexport interface PanelPoolEntry {\n provider: string;\n model: string;\n description?: string;\n tags?: string[];\n}\n\n/** One virtual model and its ordered physical candidate pool. */\nexport interface PanelPoolView {\n /** Virtual model id the deployment selects (`reflex:<id>`). */\n model: string;\n entries: PanelPoolEntry[];\n}\n\n/** Routing block of the snapshot. */\nexport interface PanelRoutingView {\n enabled: boolean;\n /** Whether an activation actually registered the virtual provider. */\n active: boolean;\n virtualProvider: string;\n fallback?: string;\n maxTaskChars: number;\n /** Total candidates across every pool. */\n candidates: number;\n pools: PanelPoolView[];\n}\n\n/** Effort block of the snapshot. */\nexport interface PanelEffortView {\n /** `reflex`/`auto` (per-turn adaptive), one pinned level, or `null` when unset. */\n setting: string | null;\n fallback: string;\n minConfidence: number;\n /** Whether adaptive effort may decide anything; `false` turns the adaptive half off. */\n enabled: boolean;\n /** Most recent adaptive decision of this activation, if any. */\n latest: PanelEffortDecision | null;\n /** How many adaptive decisions the ledger has recorded. */\n decisions: number;\n}\n\n/** Automatic-intervention block of the snapshot. */\nexport interface PanelInterventionsView {\n /** Authored master mode. */\n mode: string;\n /** Whether any capability is enabled at all. */\n enabled: boolean;\n /** Whether any capability resolves to `active` rather than merely observing. */\n acting: boolean;\n /** Capability → effective mode, with `inherit` already resolved. */\n capabilities: Record<string, string>;\n}\n\n/** Per-tool switch block of the snapshot. */\nexport interface PanelToolsView {\n /** Suffix → switch, every suffix of the vocabulary answered. */\n enabled: Record<string, boolean>;\n /** Registered tool names as the runtime surface reports them, in registration order. */\n active: string[];\n}\n\n/** One projected adaptive-effort decision (`effort-decision` ledger entries and the live feed agree on these). */\nexport interface PanelEffortDecision {\n level: string;\n applied: string | null;\n outcome: string;\n trigger: string;\n source: string;\n confidence: number;\n latencyMs: number;\n provider: string;\n model: string;\n line: string;\n at: number;\n agentId?: string;\n role?: string;\n turn?: number;\n step?: number;\n basis?: string[];\n degradedReason?: string;\n}\n\n/** Ledger totals, projected from `DecisionLedger.getSummary`. */\nexport interface PanelLedgerSummary {\n totalCalls: number;\n callsByType: Record<string, number>;\n totalTokensSaved: number;\n avgLatencyMs: number;\n estimatedCostSavedUsd: number;\n stagnationAlerts: number;\n gatePassedCount: number;\n gateFailedCount: number;\n}\n\n/** One projected ledger entry. */\nexport interface PanelLedgerRow {\n id: string;\n at: string;\n type: string;\n backend: string;\n latencyMs: number;\n tokensSaved: number;\n passed?: boolean;\n isStuck?: boolean;\n shadow?: boolean;\n skipReason?: string;\n /** `details.action`, when the recording code path declared one. */\n action?: string;\n /** `details.target`, the physical `provider:model` a routing decision chose. */\n target?: string;\n /** `details.level`, the level an effort decision chose. */\n level?: string;\n /** `details.applied`, the effort actually dispatched; `null` when cleared. */\n applied?: string | null;\n /** `details.reason`, why the decision landed where it did. */\n reason?: string;\n /**\n * `details.currentModel`, the `provider:model` the session held before a\n * routing decision; absent on a session's first decision.\n */\n currentModel?: string;\n /** `details.switched`, whether the decision moved the session's model. */\n switched?: boolean;\n /** `details.contextTokens`, the context size the routing decision reasoned about. */\n contextTokens?: number;\n}\n\n/** Ledger block of the snapshot. */\nexport interface PanelLedgerView {\n summary: PanelLedgerSummary;\n recent: PanelLedgerRow[];\n /** JSONL sink, or `null` for an in-memory ledger. */\n logPath: string | null;\n /** Whether the Host will accept a clear request for this ledger. */\n clearable: boolean;\n}\n\n/** Health of the System One gateway conversation, as the panel renders it. */\nexport interface PanelSystemOneHealth {\n /** Whether the most recent request succeeded; `false` shows the degraded banner. */\n available: boolean;\n /** Why the most recent request failed, if it did. */\n lastFailureReason?: string;\n /** ISO timestamp of the most recent failure. */\n lastFailureAt?: string;\n /** Consecutive failed requests; a single success resets it. */\n consecutiveFailures: number;\n}\n\n/** System One backend block of the snapshot. */\nexport interface PanelSystemOneView {\n /** Selected implementation; `auto` resolves through the environment. */\n backend: string;\n /** Name of the backend implementation the activation actually built. */\n active: string;\n baseUrl?: string;\n model?: string;\n apiKeyEnv?: string;\n /** Whether `apiKeyEnv` currently holds a non-empty value. Never the value. */\n apiKeyPresent: boolean;\n timeoutMs?: number;\n /**\n * Live gateway health, when the backend keeps any. Backends that answer every\n * call in-process (mock) omit it; the absence is not an outage.\n */\n health?: PanelSystemOneHealth;\n}\n\n/** Plugin identity block of the snapshot. */\nexport interface PanelPluginView {\n name: string;\n version: string;\n toolPrefix: string;\n ledgerPath?: string;\n pruneThreshold: number;\n calibrationPath?: string;\n}\n\n/** The whole panel payload. */\nexport interface PanelModelGroup {\n id: string;\n name: string;\n models: Array<{ id: string; name?: string }>;\n}\n\nexport interface PanelSnapshot {\n ok: true;\n at: number;\n plugin: PanelPluginView;\n routing: PanelRoutingView;\n effort: PanelEffortView;\n systemOne: PanelSystemOneView;\n interventions: PanelInterventionsView;\n tools: PanelToolsView;\n ledger: PanelLedgerView;\n modelCatalog?: PanelModelGroup[];\n}\n\n/**\n * Everything {@link buildPanelSnapshot} needs, gathered by the caller.\n *\n * Passing facts in (instead of reaching into a live runtime) keeps the\n * projection a pure function of its inputs, which is what the unit tests pin.\n */\nexport interface PanelRuntimeFacts {\n config: ResolvedReflexConfig;\n /** `DecisionBackend.name` of the activation. */\n backendName: string;\n /** Ordered pools as the deployment authored them. */\n pools: PanelPoolView[];\n /**\n * The physical fallback currently in force, `provider:model`.\n *\n * Read from the live router, not from the resolved config: a settings edit is\n * committed into the running activation without a remount, so the config the\n * activation resolved at startup is exactly the stale value the panel must not\n * report as effective. `null` means the live policy has no fallback (fail\n * closed); `undefined` means the caller did not supply a live fact and the\n * activation's resolved config is the best available answer.\n */\n routingFallback?: string | null;\n /** Whether the virtual provider route is installed. */\n routingActive: boolean;\n /**\n * Registered tool names of this activation, as\n * {@link ReflexRuntime.toolSurface} reports them.\n *\n * Required, not derived from the switches: the panel's promise is to show the\n * *effective* surface, and a derived guess would keep agreeing with the config\n * while the registry disagreed with both.\n */\n toolSurface: readonly string[];\n ledger: Pick<DecisionLedger, 'getSummary' | 'getEntries' | 'getLogPath'>;\n /** Latest adaptive decision of this activation. */\n effort: ReflexEffortStatus | undefined;\n /** Whether an API key is currently reachable through the declared variable. */\n apiKeyPresent: boolean;\n /** Health of the backend's gateway conversation, when it tracks one. */\n systemOneHealth?: PanelSystemOneHealth;\n /** Available physical model catalog from ctx.llm. */\n modelCatalog?: PanelModelGroup[];\n /** Timestamp of the snapshot; defaults to now. */\n now?: number;\n}\n\n/**\n * The fallback the panel must report.\n * @param facts - gathered runtime facts.\n * @returns the live fallback when one was supplied, else the activation's.\n */\nfunction fallbackOf(facts: PanelRuntimeFacts): string | undefined {\n if (facts.routingFallback === null) return undefined;\n if (facts.routingFallback !== undefined) return facts.routingFallback;\n const fallback = facts.config.routing.fallback;\n return fallback === undefined ? undefined : `${fallback.provider}:${fallback.model}`;\n}\n\n/** Narrow one open `details` value to projected scalar fields. */\nfunction projectRow(entry: LedgerEntry): PanelLedgerRow {\n const details = entry.details;\n const text = (key: string): string | undefined => {\n const value = details?.[key];\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n };\n const action = text('action');\n const target = text('target');\n const level = text('level');\n const reason = text('reason');\n const rawApplied = details?.applied;\n const applied = typeof rawApplied === 'string' ? rawApplied : rawApplied === null ? null : undefined;\n const currentModel = text('currentModel');\n const rawSwitched = details?.switched;\n const switched = typeof rawSwitched === 'boolean' ? rawSwitched : undefined;\n const rawContextTokens = details?.contextTokens;\n const contextTokens =\n typeof rawContextTokens === 'number' && Number.isFinite(rawContextTokens) ? rawContextTokens : undefined;\n return {\n id: entry.id,\n at: entry.timestamp,\n type: entry.type,\n backend: entry.backend,\n latencyMs: entry.latencyMs,\n tokensSaved: entry.tokensSaved ?? 0,\n ...(entry.passed === undefined ? {} : { passed: entry.passed }),\n ...(entry.isStuck === undefined ? {} : { isStuck: entry.isStuck }),\n ...(entry.shadow === undefined ? {} : { shadow: entry.shadow }),\n ...(entry.skipReason === undefined ? {} : { skipReason: entry.skipReason }),\n ...(action === undefined ? {} : { action }),\n ...(target === undefined ? {} : { target }),\n ...(level === undefined ? {} : { level }),\n ...(applied === undefined ? {} : { applied }),\n ...(reason === undefined ? {} : { reason }),\n ...(currentModel === undefined ? {} : { currentModel }),\n ...(switched === undefined ? {} : { switched }),\n ...(contextTokens === undefined ? {} : { contextTokens })\n };\n}\n\n/**\n * Project one adaptive-effort status onto the wire shape.\n * @param status - the published status.\n * @returns the projected decision; basis entries that are not strings are dropped.\n */\nexport function projectEffortDecision(status: ReflexEffortStatus): PanelEffortDecision {\n const basis = Array.isArray(status.basis) ? status.basis.filter((item): item is string => typeof item === 'string') : undefined;\n return {\n level: status.level,\n applied: status.applied ?? null,\n outcome: status.outcome,\n trigger: status.trigger,\n source: status.source,\n confidence: status.confidence,\n latencyMs: status.latencyMs,\n provider: status.provider,\n model: status.model,\n line: status.line,\n at: status.at,\n ...(status.agentId === undefined ? {} : { agentId: status.agentId }),\n ...(status.role === undefined ? {} : { role: status.role }),\n ...(status.turn === undefined ? {} : { turn: status.turn }),\n ...(status.step === undefined ? {} : { step: status.step }),\n ...(basis === undefined ? {} : { basis }),\n ...(status.degradedReason === undefined ? {} : { degradedReason: status.degradedReason })\n };\n}\n\n/**\n * Build the panel payload from one activation's facts.\n *\n * Pure: the same facts always produce the same payload, except for the `at`\n * timestamp the caller may pin.\n * @param facts - gathered runtime facts.\n * @param limit - how many recent entries to carry; clamped to the accepted window.\n * @returns the serializable snapshot.\n */\nexport function buildPanelSnapshot(facts: PanelRuntimeFacts, limit: number = PANEL_LEDGER_WINDOW): PanelSnapshot {\n const window = clampLimit(limit);\n const { config } = facts;\n const entries = facts.ledger.getEntries();\n const recent = entries.slice(Math.max(0, entries.length - window)).map(projectRow);\n const decisions = entries.filter((entry) => entry.type === 'effort-decision').length;\n\n return {\n ok: true,\n at: facts.now ?? Date.now(),\n plugin: {\n name: 'dsh-reflex',\n version: REFLEX_PLUGIN_VERSION,\n toolPrefix: config.toolPrefix,\n pruneThreshold: config.pruneThreshold,\n ...(config.ledgerPath === undefined ? {} : { ledgerPath: config.ledgerPath }),\n ...(config.calibrationPath === undefined ? {} : { calibrationPath: config.calibrationPath })\n },\n routing: {\n enabled: config.routing.enabled,\n active: facts.routingActive,\n virtualProvider: config.routing.virtualProvider,\n maxTaskChars: config.routing.maxTaskChars,\n candidates: facts.pools.reduce((total, pool) => total + pool.entries.length, 0),\n pools: facts.pools.map((pool) => ({ model: pool.model, entries: pool.entries.map(clonePoolEntry) })),\n ...(fallbackOf(facts) === undefined ? {} : { fallback: fallbackOf(facts) })\n },\n effort: {\n setting: config.effort.setting ?? null,\n fallback: config.effort.fallback,\n minConfidence: config.effort.minConfidence,\n enabled: config.effort.enabled,\n decisions,\n latest: facts.effort === undefined ? null : projectEffortDecision(facts.effort)\n },\n interventions: {\n mode: config.interventions.mode,\n enabled: config.interventions.enabled,\n acting: INTERVENTION_CAPABILITIES.some((capability) => config.interventions.capabilities[capability] === 'active'),\n capabilities: { ...config.interventions.capabilities }\n },\n tools: {\n enabled: { ...config.tools.enabled },\n active: [...facts.toolSurface]\n },\n systemOne: {\n backend: config.systemOne.backend,\n active: facts.backendName,\n apiKeyPresent: facts.apiKeyPresent,\n ...(facts.systemOneHealth === undefined ? {} : { health: { ...facts.systemOneHealth } }),\n ...(config.systemOne.baseUrl === undefined ? {} : { baseUrl: config.systemOne.baseUrl }),\n ...(config.systemOne.model === undefined ? {} : { model: config.systemOne.model }),\n ...(config.systemOne.apiKeyEnv === undefined ? {} : { apiKeyEnv: config.systemOne.apiKeyEnv }),\n ...(config.systemOne.timeoutMs === undefined ? {} : { timeoutMs: config.systemOne.timeoutMs })\n },\n ledger: {\n summary: facts.ledger.getSummary(),\n recent,\n logPath: facts.ledger.getLogPath(),\n // Clearing drops the in-memory entries and, when this activation owns a\n // JSONL sink, deletes that file; the panel confirms before asking.\n clearable: true\n },\n ...(facts.modelCatalog === undefined ? {} : { modelCatalog: facts.modelCatalog })\n };\n}\n\n/** Detached copy of one pool entry, so a caller cannot mutate the payload later. */\nfunction clonePoolEntry(entry: PanelPoolEntry): PanelPoolEntry {\n return {\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 * Clamp a requested ledger window onto the accepted range.\n * @param limit - requested count; non-finite values fall back to the default.\n * @returns a count in `[1, PANEL_LEDGER_WINDOW_MAX]`.\n */\nexport function clampLimit(limit: number): number {\n if (!Number.isFinite(limit)) return PANEL_LEDGER_WINDOW;\n return Math.min(PANEL_LEDGER_WINDOW_MAX, Math.max(1, Math.floor(limit)));\n}\n\n/**\n * Read one query parameter of a panel request.\n * @param url - raw request URL, path and query.\n * @param name - parameter name.\n * @returns the value, or `null` when absent.\n */\nexport function readQuery(url: string | undefined, name: string): string | null {\n const query = url === undefined ? '' : (url.split('?')[1] ?? '');\n return new URLSearchParams(query).get(name);\n}\n\n/**\n * Read the `limit` query parameter of a panel request.\n * @param url - raw request URL, path and query.\n * @returns the parsed count, or the default when absent or unusable.\n */\nexport function readLimit(url: string | undefined): number {\n const raw = readQuery(url, 'limit');\n if (raw === null || raw.trim().length === 0) return PANEL_LEDGER_WINDOW;\n const parsed = Number(raw);\n return Number.isFinite(parsed) ? clampLimit(parsed) : PANEL_LEDGER_WINDOW;\n}\n\n/** Whether an IPv4 literal names the loopback range `127/8`. */\nexport function isLoopbackIPv4(address: string): boolean {\n const parts = address.split('.');\n if (parts.length !== 4) return false;\n if (parts[0] !== '127') return false;\n return parts.every((part) => /^\\d{1,3}$/.test(part) && Number(part) <= 255);\n}\n\n/**\n * Whether a socket remote address names loopback (`127/8`, `::1`, or a mapped form).\n *\n * The socket address is authoritative: a `Host` header or `X-Forwarded-For` can\n * be forged by the caller, so neither decides this.\n * @param address - `request.socket.remoteAddress`.\n * @returns whether the peer is on this machine.\n */\nexport function isLoopbackAddress(address: string | undefined): boolean {\n if (address === undefined) return false;\n const normalized = address.toLowerCase();\n if (normalized === '::1') return true;\n if (normalized.startsWith('::ffff:')) return isLoopbackIPv4(normalized.slice(7));\n return isLoopbackIPv4(normalized);\n}\n\n/** Extra allow rules a Host may install beside the loopback fence. */\nexport interface PanelAccessOptions {\n /**\n * Whether an optional pairing service recognises this request as a paired\n * device. Absent means \"loopback only\".\n */\n isPaired?: ((request: IncomingMessage) => boolean) | undefined;\n}\n\n/**\n * Whether one request may reach the panel routes.\n * @param request - the incoming request.\n * @param options - optional pairing check.\n * @returns whether the request is allowed.\n */\nexport function isPanelRequestAllowed(request: IncomingMessage, options: PanelAccessOptions = {}): boolean {\n if (isLoopbackAddress(request.socket?.remoteAddress)) return true;\n const isPaired = options.isPaired;\n if (typeof isPaired !== 'function') return false;\n try {\n return isPaired(request) === true;\n } catch {\n return false;\n }\n}\n\n/** Narrow response face the panel handlers need; `ServerResponse` satisfies it. */\nexport interface PanelResponse {\n writeHead(status: number, headers?: Record<string, string>): unknown;\n end(chunk?: string): unknown;\n}\n\n/** What one panel request resolves to, before it is serialized. */\nexport interface PanelAnswer {\n status: number;\n body: unknown;\n headers?: Record<string, string>;\n}\n\n/** The live facts one panel route family answers from. */\nexport interface PanelSource {\n /** Build the current snapshot. */\n snapshot(limit: number): PanelSnapshot;\n /** Clear the ledger. @returns how many entries were dropped. */\n clearLedger(): number;\n /** Whether the loopback/pairing fence admitted this request. */\n allows(request: IncomingMessage): boolean;\n}\n\n/** JSON headers every panel answer carries. */\nfunction jsonHeaders(extra: Record<string, string> = {}): Record<string, string> {\n return { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store', ...extra };\n}\n\n/**\n * Resolve one panel request into a status and a JSON body.\n *\n * Kept separate from the socket so the whole route family is testable without a\n * server: {@link makePanelRoutes} only adapts this to `node:http`.\n * @param source - the live facts.\n * @param request - the incoming request.\n * @returns the answer to serialize.\n */\nexport function answerPanelRequest(source: PanelSource, request: IncomingMessage): PanelAnswer {\n const method = (request.method ?? 'GET').toUpperCase();\n const path = (request.url ?? '/').split('?')[0] ?? '/';\n\n if (!source.allows(request)) {\n return { status: 403, body: { ok: false, error: 'forbidden', detail: 'the reflex panel answers loopback clients and paired devices only' } };\n }\n\n switch (path) {\n case PANEL_ROUTES.snapshot:\n if (method !== 'GET' && method !== 'HEAD') return methodNotAllowed('GET, HEAD');\n return { status: 200, body: source.snapshot(readLimit(request.url)) };\n case PANEL_ROUTES.health:\n if (method !== 'GET' && method !== 'HEAD') return methodNotAllowed('GET, HEAD');\n return { status: 200, body: { ok: true, name: 'dsh-reflex', version: REFLEX_PLUGIN_VERSION } };\n case PANEL_ROUTES.clearLedger:\n if (method !== 'POST') return methodNotAllowed('POST');\n // Clearing deletes the owned JSONL sink as well as the in-memory entries,\n // so an accidental (or cross-site) POST must not be enough on its own.\n if (readQuery(request.url, 'confirm') !== 'clear') {\n return {\n status: 400,\n body: {\n ok: false,\n error: 'confirmation-required',\n detail: 'clearing the ledger deletes its JSONL sink; repeat the POST with ?confirm=clear'\n }\n };\n }\n return { status: 200, body: { ok: true, cleared: source.clearLedger() } };\n default:\n return { status: 404, body: { ok: false, error: 'not-found', detail: `unknown reflex panel route \"${path}\"` } };\n }\n}\n\n/** Standard 405 answer. */\nfunction methodNotAllowed(allow: string): PanelAnswer {\n return { status: 405, body: { ok: false, error: 'method-not-allowed', detail: `use ${allow}` }, headers: { allow } };\n}\n\n/**\n * Serve one resolved answer over a `node:http` response.\n *\n * `HEAD` carries the same headers and no body, which is what a probe needs — so\n * the length is measured from the body the matching `GET` would send rather than\n * left for the server to guess from an empty chunk.\n * @param request - the incoming request.\n * @param response - the response to own.\n * @param answer - the resolved answer.\n */\nexport function sendPanelAnswer(request: IncomingMessage, response: PanelResponse, answer: PanelAnswer): void {\n const suppressed = answer.status === 204;\n const payload = suppressed ? '' : JSON.stringify(answer.body);\n const headers = jsonHeaders({\n ...(suppressed ? {} : { 'content-length': String(Buffer.byteLength(payload, 'utf8')) }),\n ...answer.headers\n });\n response.writeHead(answer.status, headers);\n if (suppressed || (request.method ?? 'GET').toUpperCase() === 'HEAD') {\n response.end();\n return;\n }\n response.end(payload);\n}\n\n/**\n * Build the `/api/dsh-reflex/*` route family.\n *\n * One handler owns every path in the family, so the method/path decision lives\n * in {@link answerPanelRequest} and cannot drift between routes; the\n * `kind: 'exact'` paths mean the server never routes an unrelated URL here.\n * @param source - the live facts.\n * @returns the routes to register.\n */\nexport function makePanelRoutes(source: PanelSource): WebRoute[] {\n const handler = (request: IncomingMessage, response: ServerResponse): void => {\n sendPanelAnswer(request, response, answerPanelRequest(source, request));\n };\n return [\n { kind: 'exact', path: PANEL_ROUTES.snapshot, handler },\n { kind: 'exact', path: PANEL_ROUTES.health, handler },\n { kind: 'exact', path: PANEL_ROUTES.clearLedger, handler }\n ];\n}\n\n/** Every path this family owns, for diagnostics and tests. */\nexport const PANEL_PATHS: readonly string[] = Object.values(PANEL_ROUTES);\n"]}
|
|
1
|
+
{"version":3,"file":"panel-api.js","sourceRoot":"","sources":["../src/panel-api.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,gBAAgB,EAA6B,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAIxD,iFAAiF;AACjF,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE7C,+CAA+C;AAC/C,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAE5C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,GAAG,UAAU,QAAQ;IAC/B,MAAM,EAAE,GAAG,UAAU,SAAS;IAC9B,WAAW,EAAE,GAAG,UAAU,eAAe;IACzC;;;;;OAKG;IACH,UAAU,EAAE,GAAG,UAAU,aAAa;IACtC;;;;;;OAMG;IACH,aAAa,EAAE,GAAG,UAAU,iBAAiB;CACrC,CAAC;AAEX,gFAAgF;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,iFAAiF;AACjF,MAAM,CAAC,MAAM,uBAAuB,GAA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,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC","sourcesContent":["/**\n * Read-only HTTP surface behind the Reflex settings panel.\n *\n * The browser half of this plugin (`./client`) renders the settings page, but a\n * client bundle may not value-import another plugin and the plugin's own live\n * facts — decision throughput, saved tokens, the last adaptive decision — only\n * exist in the Host process. The two halves therefore meet on the one channel a\n * third-party plugin can own without a generated Remote namespace: a small,\n * explicitly projected JSON route family served by `ctx.webServer`.\n *\n * Design rules this module keeps:\n *\n * - **Explicit projection.** Every payload field is projected from the runtime\n * by hand. `LedgerEntry.details` is an open record written by several code\n * paths, so it is narrowed to five known scalar fields instead of serialized\n * whole — the panel shows what it declares, and nothing else rides the wire.\n * - **Secrets stay home.** The connection block carries the *name* of the API\n * key's environment variable; the key's value is never read here, so no\n * response can leak it.\n * - **Loopback by default.** The route family answers the local GUI only, plus\n * whatever the optional `remoteWebUiPairing` service recognises as a paired\n * device, so a LAN-exposed Host does not publish its ledger to strangers.\n *\n * @module dsh-reflex/panel-api\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nimport type { DecisionLedger, LedgerEntry } from './vendor/harness-reflex/index.js';\nimport type { WebRoute } from '@deepseek-ai/dsh-host-webserver';\n\nimport { connectionTarget, type ResolvedReflexConfig } from './config.js';\nimport { INTERVENTION_CAPABILITIES } from './config.js';\nimport type { ReflexEffortStatus } from './effort.js';\nimport type { DelegationHealthState } from './delegation-health.js';\n\n/** Version reported by the panel; kept in step with `package.json` by a test. */\nexport const REFLEX_PLUGIN_VERSION = '0.3.0';\n\n/** Namespace every panel route lives under. */\nexport const PANEL_BASE = '/dsh-reflex/api';\n\n/** The route family, as the panel's phases address it. */\nexport const PANEL_ROUTES = {\n snapshot: `${PANEL_BASE}/panel`,\n health: `${PANEL_BASE}/health`,\n clearLedger: `${PANEL_BASE}/ledger/clear`,\n /**\n * Writes the host `modelSelection` switch into the profile patch.\n *\n * A route of its own, and a `POST`, because it is the only request in this\n * family that changes a file outside this plugin's own settings section.\n */\n delegation: `${PANEL_BASE}/delegation`,\n /**\n * Probes one System One profile from the server.\n *\n * A `POST` with a JSON body naming the profile, and not a `GET`: it performs\n * outbound work on the user's behalf, and a cached or prefetched GET must never\n * be able to trigger a connection attempt.\n */\n systemOneTest: `${PANEL_BASE}/systemone/test`\n} as const;\n\n/** How many recent ledger entries one snapshot carries. Default 25, cap 200. */\nexport const PANEL_LEDGER_WINDOW = 25;\n\n/** Largest accepted `?limit=` value, so one request cannot ask for the world. */\nexport const PANEL_LEDGER_WINDOW_MAX = 200;\n\n/**\n * One candidate of a virtual model pool, as the panel renders it.\n *\n * Mirrors the authored `ReflexModelPoolEntry` rather than the resolved router\n * entry: the panel edits authored configuration, so it shows exactly the keys\n * the settings document can carry.\n */\nexport interface PanelPoolEntry {\n provider: string;\n model: string;\n description?: string;\n tags?: string[];\n}\n\n/** One virtual model and its ordered physical candidate pool. */\nexport interface PanelPoolView {\n /** Virtual model id the deployment selects (`reflex:<id>`). */\n model: string;\n entries: PanelPoolEntry[];\n}\n\n/** Routing block of the snapshot. */\nexport interface PanelRoutingView {\n enabled: boolean;\n /** Whether an activation actually registered the virtual provider. */\n active: boolean;\n virtualProvider: string;\n fallback?: string;\n maxTaskChars: number;\n /** Total candidates across every pool. */\n candidates: number;\n pools: PanelPoolView[];\n}\n\n/** Effort block of the snapshot. */\nexport interface PanelEffortView {\n /** `reflex`/`auto` (per-turn adaptive), one pinned level, or `null` when unset. */\n setting: string | null;\n fallback: string;\n minConfidence: number;\n /** Whether adaptive effort may decide anything; `false` turns the adaptive half off. */\n enabled: boolean;\n /** Most recent adaptive decision of this activation, if any. */\n latest: PanelEffortDecision | null;\n /** How many adaptive decisions the ledger has recorded. */\n decisions: number;\n}\n\n/** Automatic-intervention block of the snapshot. */\nexport interface PanelInterventionsView {\n /** Authored master mode. */\n mode: string;\n /** Whether any capability is enabled at all. */\n enabled: boolean;\n /** Whether any capability resolves to `active` rather than merely observing. */\n acting: boolean;\n /** Capability → effective mode, with `inherit` already resolved. */\n capabilities: Record<string, string>;\n}\n\n/**\n * Delegation block of the snapshot.\n *\n * Deliberately not folded into {@link PanelToolsView}: those switches decide\n * which tools *this plugin* registers, while this one decides whether the *Host*\n * is asked for a capability (`modelSelection`). The panel shows them apart so the\n * one switch that edits a file outside this plugin cannot look like the others.\n */\nexport interface PanelDelegationView {\n /** The authored consent (`delegation.enabled`); off by default. */\n enabled: boolean;\n /** Whether `reflex_delegate` is registered in the live registry right now. */\n registered: boolean;\n /** What the live Host registry says, or `unknown` when no fact was supplied. */\n state: DelegationHealthState | 'unknown';\n /** The host profile patch this switch edits, when one could be resolved. */\n patchPath?: string;\n /** Which fact resolved {@link patchPath}. */\n patchPathSource?: string;\n /** Whether the host patch currently asks for the field (read from the file). */\n patchEnabled: boolean;\n /** Why the capability is not usable, or why the patch could not be read. */\n reason?: string;\n /**\n * Whether a write has happened that only a restart can apply.\n *\n * Computed from facts, never guessed: the switch is on, the file asks for the\n * field, and the host tool still does not declare `reasoning_effort`.\n */\n restartRequired: boolean;\n}\n\n/** Per-tool switch block of the snapshot. */\nexport interface PanelToolsView {\n /** Suffix → switch, every suffix of the vocabulary answered. */\n enabled: Record<string, boolean>;\n /** Registered tool names as the runtime surface reports them, in registration order. */\n active: string[];\n}\n\n/** One projected adaptive-effort decision (`effort-decision` ledger entries and the live feed agree on these). */\nexport interface PanelEffortDecision {\n level: string;\n applied: string | null;\n outcome: string;\n trigger: string;\n source: string;\n confidence: number;\n latencyMs: number;\n provider: string;\n model: string;\n line: string;\n at: number;\n agentId?: string;\n role?: string;\n turn?: number;\n step?: number;\n basis?: string[];\n degradedReason?: string;\n}\n\n/** Ledger totals, projected from `DecisionLedger.getSummary`. */\nexport interface PanelLedgerSummary {\n totalCalls: number;\n callsByType: Record<string, number>;\n totalTokensSaved: number;\n avgLatencyMs: number;\n estimatedCostSavedUsd: number;\n stagnationAlerts: number;\n gatePassedCount: number;\n gateFailedCount: number;\n}\n\n/** One projected ledger entry. */\nexport interface PanelLedgerRow {\n id: string;\n at: string;\n type: string;\n backend: string;\n latencyMs: number;\n tokensSaved: number;\n passed?: boolean;\n isStuck?: boolean;\n shadow?: boolean;\n skipReason?: string;\n /** `details.action`, when the recording code path declared one. */\n action?: string;\n /** `details.target`, the physical `provider:model` a routing decision chose. */\n target?: string;\n /** `details.level`, the level an effort decision chose. */\n level?: string;\n /** `details.applied`, the effort actually dispatched; `null` when cleared. */\n applied?: string | null;\n /** `details.reason`, why the decision landed where it did. */\n reason?: string;\n /**\n * `details.currentModel`, the `provider:model` the session held before a\n * routing decision; absent on a session's first decision.\n */\n currentModel?: string;\n /** `details.switched`, whether the decision moved the session's model. */\n switched?: boolean;\n /** `details.contextTokens`, the context size the routing decision reasoned about. */\n contextTokens?: number;\n /**\n * `details.systemOneConnection` — the System One connection in force when the\n * call was dispatched (g-068). Absent on an entry that predates the change,\n * and never invented for it.\n */\n systemOneConnection?: string;\n /**\n * `details.systemOneModel` — the model id the call **requested**. A request,\n * never an observation: whether an upstream served or rewrote it is unknown\n * to this plugin, which is why every renderer marks it as requested.\n */\n systemOneModel?: string | null;\n /**\n * `details.systemOneSource` — `remote`, `local`, `local-fallback`, `rejected`\n * or `unknown`. Anything but `remote` means the answer was not a System One\n * answer, and the panel must never show it as one.\n */\n systemOneSource?: string;\n /** `details.systemOneDetail` — why the source is not `remote`. */\n systemOneDetail?: string;\n}\n\n/** Ledger block of the snapshot. */\nexport interface PanelLedgerView {\n summary: PanelLedgerSummary;\n recent: PanelLedgerRow[];\n /** JSONL sink, or `null` for an in-memory ledger. */\n logPath: string | null;\n /** Whether the Host will accept a clear request for this ledger. */\n clearable: boolean;\n}\n\n/** Health of the System One gateway conversation, as the panel renders it. */\nexport interface PanelSystemOneHealth {\n /** Whether the most recent request succeeded; `false` shows the degraded banner. */\n available: boolean;\n /** Why the most recent request failed, if it did. */\n lastFailureReason?: string;\n /** ISO timestamp of the most recent failure. */\n lastFailureAt?: string;\n /** Consecutive failed requests; a single success resets it. */\n consecutiveFailures: number;\n}\n\n/**\n * One connection profile, as the panel renders it.\n *\n * Every field here is a *non-secret* one. The key never appears: the panel learns\n * only {@link apiKeyPresent}, which is what lets it draw a write-only input with\n * a placeholder without ever holding the value.\n */\nexport interface PanelSystemOneProfileView {\n /** Profile name; also the row id and the settings path segment. */\n name: string;\n baseUrl?: string;\n model?: string;\n /** Environment variable this profile names, when it names one. */\n apiKeyEnv?: string;\n /**\n * Whether this profile currently resolves a key — from its own secret slot or\n * from the variable the chain names. Never which value.\n */\n apiKeyPresent: boolean;\n /** Whether the key this profile resolves is its own secret slot (not a variable). */\n apiKeyFromProfile: boolean;\n /**\n * The variable that supplied this profile's key, or the one it named and\n * found empty. A name, never a value.\n */\n apiKeyVariable?: string;\n /**\n * This profile names a variable that is empty, and the lookup locked onto it\n * (g-059): no fallback variable was consulted. Rendered as \"named, but empty\"\n * rather than as \"no key configured\".\n */\n apiKeyLocked?: boolean;\n timeoutMs?: number;\n backend?: string;\n /** Every model id this connection offers, in authored order (g-066). */\n modelIds?: string[];\n /** The one model id in force for this connection: what the runtime and the probe use. */\n selectedModel?: string;\n /**\n * `selectedModel` is not in {@link modelIds}.\n *\n * The row must say so: the runtime then sends no model at all rather than\n * quietly running a different one, and a probe would test a request nobody\n * selected. Absent when the selection is valid (or when none is named).\n */\n modelMissing?: boolean;\n /** Whether this is the profile in force. */\n active: boolean;\n}\n\n/** System One backend block of the snapshot. */\nexport interface PanelSystemOneView {\n /** Selected implementation; `auto` resolves through the environment. */\n backend: string;\n /** Name of the backend implementation the activation actually built. */\n active: string;\n baseUrl?: string;\n model?: string;\n apiKeyEnv?: string;\n /**\n * Whether the key chain currently resolves a key — from the settings\n * document, from `apiKeyEnv`, or from one of the fallback variables. Never\n * which value.\n */\n apiKeyPresent: boolean;\n /**\n * Where that key came from, so the page can say \"from the configuration\",\n * \"from JEV_API_KEY\", or \"from JEV_API_KEY (fallback)\" instead of guessing\n * from `apiKeyEnv`. Absent when no key resolves at all.\n *\n * `fallback` is an environment read reached through the documented variable\n * list because the block named *no* variable (g-059) — marked as such so a\n * deployment that meant to name one can tell it named nothing.\n */\n apiKeySource?: 'profile' | 'env' | 'fallback';\n /**\n * The environment variable that supplied the key (present when\n * {@link apiKeySource} is `env` or `fallback`), or — when nothing resolved —\n * the variable the block named and found empty. A *name*; no value travels.\n */\n apiKeyVariable?: string;\n /**\n * The block named a variable that is empty, and the lookup stopped there on\n * purpose (g-059): no fallback variable was consulted. Distinct from a plain\n * `apiKeyPresent: false`, which means nothing was named and nothing was found.\n */\n apiKeyLocked?: boolean;\n /** Whether the resolved configuration carries a literal key. Never the key. */\n apiKeyFromProfile: boolean;\n timeoutMs?: number;\n /** Every authored profile, in authored order. Empty when none is authored. */\n profiles: PanelSystemOneProfileView[];\n /** The authored `active` name, when one was authored. */\n activeProfile?: string;\n /**\n * The authored `active` name matches no profile. Surfaced as a warning rather\n * than hidden: a typo must not look like a working configuration — and since\n * g-066 it also means nothing connects.\n */\n activeProfileMissing: boolean;\n /**\n * Why nothing connects, when nothing does (g-066): no profiles, none\n * activated, the active name missing, only the pre-g-066 flat fields, or an\n * active profile whose model cannot be sent.\n *\n * Absent exactly when a connection resolved, so the page renders its\n * \"unconfigured\" state from this and never from a guess about the fields.\n */\n unconfigured?:\n | 'no-active-profile'\n | 'no-profiles'\n | 'active-profile-missing'\n | 'legacy-config-required'\n | 'model-selection-unusable'\n | 'model-selection-invalid';\n /** The active profile's selected model is not in its list; nothing runs. */\n activeProfileModelMissing?: boolean;\n /** The active profile's model cannot be sent, so nothing connects (g-066 att-002). */\n activeProfileModelUnusable?: boolean;\n /**\n * Live gateway health, when the backend keeps any. Backends that answer every\n * call in-process (mock) omit it; the absence is not an outage.\n */\n health?: PanelSystemOneHealth;\n}\n\n/** Plugin identity block of the snapshot. */\nexport interface PanelPluginView {\n name: string;\n version: string;\n toolPrefix: string;\n ledgerPath?: string;\n pruneThreshold: number;\n calibrationPath?: string;\n}\n\n/** The whole panel payload. */\nexport interface PanelModelGroup {\n id: string;\n name: string;\n models: Array<{ id: string; name?: string }>;\n}\n\nexport interface PanelSnapshot {\n ok: true;\n at: number;\n plugin: PanelPluginView;\n routing: PanelRoutingView;\n effort: PanelEffortView;\n systemOne: PanelSystemOneView;\n interventions: PanelInterventionsView;\n tools: PanelToolsView;\n delegation: PanelDelegationView;\n ledger: PanelLedgerView;\n modelCatalog?: PanelModelGroup[];\n}\n\n/**\n * Everything {@link buildPanelSnapshot} needs, gathered by the caller.\n *\n * Passing facts in (instead of reaching into a live runtime) keeps the\n * projection a pure function of its inputs, which is what the unit tests pin.\n */\nexport interface PanelRuntimeFacts {\n config: ResolvedReflexConfig;\n /** `DecisionBackend.name` of the activation. */\n backendName: string;\n /** Ordered pools as the deployment authored them. */\n pools: PanelPoolView[];\n /**\n * The physical fallback currently in force, `provider:model`.\n *\n * Read from the live router, not from the resolved config: a settings edit is\n * committed into the running activation without a remount, so the config the\n * activation resolved at startup is exactly the stale value the panel must not\n * report as effective. `null` means the live policy has no fallback (fail\n * closed); `undefined` means the caller did not supply a live fact and the\n * activation's resolved config is the best available answer.\n */\n routingFallback?: string | null;\n /** Whether the virtual provider route is installed. */\n routingActive: boolean;\n /**\n * Registered tool names of this activation, as\n * {@link ReflexRuntime.toolSurface} reports them.\n *\n * Required, not derived from the switches: the panel's promise is to show the\n * *effective* surface, and a derived guess would keep agreeing with the config\n * while the registry disagreed with both.\n */\n toolSurface: readonly string[];\n ledger: Pick<DecisionLedger, 'getSummary' | 'getEntries' | 'getLogPath'>;\n /** Latest adaptive decision of this activation. */\n effort: ReflexEffortStatus | undefined;\n /** Whether an API key is currently reachable through the resolved key chain. */\n apiKeyPresent: boolean;\n /**\n * Where that key came from: a literal in the settings document (`profile`), an\n * environment variable the block named (`env`), or a documented fallback\n * variable (`fallback`). Absent when no key resolves.\n */\n apiKeySource?: 'profile' | 'env' | 'fallback';\n /**\n * The variable that supplied the key, or the named-but-empty one. A name,\n * never a value.\n */\n apiKeyVariable?: string;\n /** The block named a variable that is empty, so no fallback was consulted. */\n apiKeyLocked?: boolean;\n /**\n * Key *presence* per profile name — the only key fact the panel may receive.\n *\n * A map of booleans and variable names, never of values: the projection cannot\n * leak what it is not handed, and a test asserts the serialized snapshot\n * contains no key substring.\n */\n profileKeys?: Record<string, { present: boolean; fromProfile: boolean; variable?: string; locked?: boolean }>;\n /** Health of the backend's gateway conversation, when it tracks one. */\n systemOneHealth?: PanelSystemOneHealth;\n /** Available physical model catalog from ctx.llm. */\n modelCatalog?: PanelModelGroup[];\n /**\n * The live delegation-capability reading.\n *\n * `undefined` when the caller could not read the registry at all, which the\n * projection reports as `unknown` rather than inventing a state.\n */\n delegationHealth?: { state: DelegationHealthState; reason?: string };\n /**\n * The host profile patch, as read from disk by the caller.\n *\n * Supplied rather than read here so the projection stays pure: the mount layer\n * owns the file access, and a test drives it with a scratch path.\n */\n hostPatch?: { path?: string; source?: string; enabled: boolean; reason?: string };\n /** Timestamp of the snapshot; defaults to now. */\n now?: number;\n}\n\n/**\n * The fallback the panel must report.\n * @param facts - gathered runtime facts.\n * @returns the live fallback when one was supplied, else the activation's.\n */\nfunction fallbackOf(facts: PanelRuntimeFacts): string | undefined {\n if (facts.routingFallback === null) return undefined;\n if (facts.routingFallback !== undefined) return facts.routingFallback;\n const fallback = facts.config.routing.fallback;\n return fallback === undefined ? undefined : `${fallback.provider}:${fallback.model}`;\n}\n\n/** Narrow one open `details` value to projected scalar fields. */\nfunction projectRow(entry: LedgerEntry): PanelLedgerRow {\n const details = entry.details;\n const text = (key: string): string | undefined => {\n const value = details?.[key];\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n };\n const action = text('action');\n const target = text('target');\n const level = text('level');\n const reason = text('reason');\n const rawApplied = details?.applied;\n const applied = typeof rawApplied === 'string' ? rawApplied : rawApplied === null ? null : undefined;\n const currentModel = text('currentModel');\n const rawSwitched = details?.switched;\n const switched = typeof rawSwitched === 'boolean' ? rawSwitched : undefined;\n const rawContextTokens = details?.contextTokens;\n const contextTokens =\n typeof rawContextTokens === 'number' && Number.isFinite(rawContextTokens) ? rawContextTokens : undefined;\n // Provenance is projected exactly as recorded: an entry without it (written\n // before g-068) gets nothing, and `null` is kept distinct from absent because\n // \"the connection names no model\" is a fact, not a missing value.\n const systemOneConnection = text('systemOneConnection');\n const rawSystemOneModel = details?.systemOneModel;\n const systemOneModel =\n typeof rawSystemOneModel === 'string' || rawSystemOneModel === null ? (rawSystemOneModel as string | null) : undefined;\n const systemOneSource = text('systemOneSource');\n const systemOneDetail = text('systemOneDetail');\n return {\n id: entry.id,\n at: entry.timestamp,\n type: entry.type,\n backend: entry.backend,\n latencyMs: entry.latencyMs,\n tokensSaved: entry.tokensSaved ?? 0,\n ...(entry.passed === undefined ? {} : { passed: entry.passed }),\n ...(entry.isStuck === undefined ? {} : { isStuck: entry.isStuck }),\n ...(entry.shadow === undefined ? {} : { shadow: entry.shadow }),\n ...(entry.skipReason === undefined ? {} : { skipReason: entry.skipReason }),\n ...(action === undefined ? {} : { action }),\n ...(target === undefined ? {} : { target }),\n ...(level === undefined ? {} : { level }),\n ...(applied === undefined ? {} : { applied }),\n ...(reason === undefined ? {} : { reason }),\n ...(currentModel === undefined ? {} : { currentModel }),\n ...(switched === undefined ? {} : { switched }),\n ...(contextTokens === undefined ? {} : { contextTokens }),\n ...(systemOneConnection === undefined ? {} : { systemOneConnection }),\n ...(systemOneModel === undefined ? {} : { systemOneModel }),\n ...(systemOneSource === undefined ? {} : { systemOneSource }),\n ...(systemOneDetail === undefined ? {} : { systemOneDetail })\n };\n}\n\n/**\n * Project one adaptive-effort status onto the wire shape.\n * @param status - the published status.\n * @returns the projected decision; basis entries that are not strings are dropped.\n */\nexport function projectEffortDecision(status: ReflexEffortStatus): PanelEffortDecision {\n const basis = Array.isArray(status.basis) ? status.basis.filter((item): item is string => typeof item === 'string') : undefined;\n return {\n level: status.level,\n applied: status.applied ?? null,\n outcome: status.outcome,\n trigger: status.trigger,\n source: status.source,\n confidence: status.confidence,\n latencyMs: status.latencyMs,\n provider: status.provider,\n model: status.model,\n line: status.line,\n at: status.at,\n ...(status.agentId === undefined ? {} : { agentId: status.agentId }),\n ...(status.role === undefined ? {} : { role: status.role }),\n ...(status.turn === undefined ? {} : { turn: status.turn }),\n ...(status.step === undefined ? {} : { step: status.step }),\n ...(basis === undefined ? {} : { basis }),\n ...(status.degradedReason === undefined ? {} : { degradedReason: status.degradedReason })\n };\n}\n\n/**\n * Build the panel payload from one activation's facts.\n *\n * Pure: the same facts always produce the same payload, except for the `at`\n * timestamp the caller may pin.\n * @param facts - gathered runtime facts.\n * @param limit - how many recent entries to carry; clamped to the accepted window.\n * @returns the serializable snapshot.\n */\nexport function buildPanelSnapshot(facts: PanelRuntimeFacts, limit: number = PANEL_LEDGER_WINDOW): PanelSnapshot {\n const window = clampLimit(limit);\n const { config } = facts;\n const entries = facts.ledger.getEntries();\n const recent = entries.slice(Math.max(0, entries.length - window)).map(projectRow);\n const decisions = entries.filter((entry) => entry.type === 'effort-decision').length;\n\n return {\n ok: true,\n at: facts.now ?? Date.now(),\n plugin: {\n name: 'dsh-reflex',\n version: REFLEX_PLUGIN_VERSION,\n toolPrefix: config.toolPrefix,\n pruneThreshold: config.pruneThreshold,\n ...(config.ledgerPath === undefined ? {} : { ledgerPath: config.ledgerPath }),\n ...(config.calibrationPath === undefined ? {} : { calibrationPath: config.calibrationPath })\n },\n routing: {\n enabled: config.routing.enabled,\n active: facts.routingActive,\n virtualProvider: config.routing.virtualProvider,\n maxTaskChars: config.routing.maxTaskChars,\n candidates: facts.pools.reduce((total, pool) => total + pool.entries.length, 0),\n pools: facts.pools.map((pool) => ({ model: pool.model, entries: pool.entries.map(clonePoolEntry) })),\n ...(fallbackOf(facts) === undefined ? {} : { fallback: fallbackOf(facts) })\n },\n effort: {\n setting: config.effort.setting ?? null,\n fallback: config.effort.fallback,\n minConfidence: config.effort.minConfidence,\n enabled: config.effort.enabled,\n decisions,\n latest: facts.effort === undefined ? null : projectEffortDecision(facts.effort)\n },\n interventions: {\n mode: config.interventions.mode,\n enabled: config.interventions.enabled,\n acting: INTERVENTION_CAPABILITIES.some((capability) => config.interventions.capabilities[capability] === 'active'),\n capabilities: { ...config.interventions.capabilities }\n },\n tools: {\n enabled: { ...config.tools.enabled },\n active: [...facts.toolSurface]\n },\n delegation: projectDelegation(config, facts),\n systemOne: projectSystemOne(config, facts),\n ledger: {\n summary: facts.ledger.getSummary(),\n recent,\n logPath: facts.ledger.getLogPath(),\n // Clearing drops the in-memory entries and, when this activation owns a\n // JSONL sink, deletes that file; the panel confirms before asking.\n clearable: true\n },\n ...(facts.modelCatalog === undefined ? {} : { modelCatalog: facts.modelCatalog })\n };\n}\n\n/**\n * Project the System One connection block, including every profile.\n *\n * The one rule this function exists to keep: **no key value may reach the\n * payload**. It reads {@link PanelRuntimeFacts.profileKeys} — presence flags the\n * caller gathered — and never `config.systemOne.profiles[*].apiKey`, which does\n * exist in the resolved config because the backend needs it.\n *\n * @param config - the configuration in force.\n * @param facts - gathered runtime facts.\n * @returns the wire projection of the connection block.\n */\nexport function projectSystemOne(config: ResolvedReflexConfig, facts: PanelRuntimeFacts): PanelSystemOneView {\n const { systemOne } = config;\n // Presence, never value: a profile \"has\" a key when its own secret slot is set,\n // else when one of the variables the chain names holds a non-empty value.\n const keyFacts = (\n name: string,\n profile: { apiKey?: string; apiKeyEnv?: string }\n ): { present: boolean; fromProfile: boolean; variable?: string; locked?: boolean } => {\n const supplied = facts.profileKeys?.[name];\n if (supplied !== undefined) return supplied;\n const own = typeof profile.apiKey === 'string' && profile.apiKey.length > 0;\n return { present: own, fromProfile: own };\n };\n // A row shows the connection it would *actually use*. Since g-066 that is the\n // profile's own fields and nothing else — there is no block beneath it to\n // inherit from — and the model shown is the *selected* one, the same value the\n // runtime sends and the probe tests. A selection pointing outside `modelIds`\n // projects no model plus `modelMissing`, so the row can say why.\n const profiles: PanelSystemOneProfileView[] = Object.entries(systemOne.profiles ?? {}).map(([name, profile]) => {\n const keys = keyFacts(name, profile);\n const projected = connectionTarget(systemOne, name, profile);\n const selectedOutsideList = profile.selectedModel !== undefined && !(profile.modelIds ?? []).includes(profile.selectedModel);\n return {\n name,\n active: systemOne.active === name,\n apiKeyPresent: keys.present,\n apiKeyFromProfile: keys.fromProfile,\n ...(keys.variable === undefined ? {} : { apiKeyVariable: keys.variable }),\n ...(keys.locked === true ? { apiKeyLocked: true } : {}),\n ...(projected.baseUrl === undefined ? {} : { baseUrl: projected.baseUrl }),\n ...(projected.model === undefined ? {} : { model: projected.model }),\n ...(projected.apiKeyEnv === undefined ? {} : { apiKeyEnv: projected.apiKeyEnv }),\n ...(projected.timeoutMs === undefined ? {} : { timeoutMs: projected.timeoutMs }),\n ...(projected.backend === undefined ? {} : { backend: projected.backend }),\n ...(profile.modelIds === undefined ? {} : { modelIds: [...profile.modelIds] }),\n // The *effective* selection, including the implicit \"first listed id\", so\n // the page can show which model runs instead of rendering an empty choice.\n // A broken selection projects no model at all (see `modelMissing`).\n ...(projected.model === undefined ? {} : { selectedModel: projected.model }),\n ...(selectedOutsideList ? { modelMissing: true } : {})\n };\n });\n const resolvedCarriesKey = typeof systemOne.apiKey === 'string' && systemOne.apiKey.length > 0;\n return {\n backend: systemOne.backend,\n active: facts.backendName,\n apiKeyPresent: facts.apiKeyPresent,\n apiKeyFromProfile: resolvedCarriesKey,\n // Provenance travels as a source tag and a variable *name* — the caller\n // resolved them through the one key chain and dropped the value there.\n ...(facts.apiKeySource === undefined ? {} : { apiKeySource: facts.apiKeySource }),\n ...(facts.apiKeyVariable === undefined ? {} : { apiKeyVariable: facts.apiKeyVariable }),\n ...(facts.apiKeyLocked === true ? { apiKeyLocked: true } : {}),\n profiles,\n activeProfileMissing: systemOne.activeProfileMissing === true,\n ...(systemOne.unconfigured === undefined ? {} : { unconfigured: systemOne.unconfigured }),\n ...(systemOne.activeProfileModelMissing === true ? { activeProfileModelMissing: true } : {}),\n ...(systemOne.unconfigured === 'model-selection-unusable' ? { activeProfileModelUnusable: true } : {}),\n ...(facts.systemOneHealth === undefined ? {} : { health: { ...facts.systemOneHealth } }),\n ...(systemOne.active === undefined ? {} : { activeProfile: systemOne.active }),\n ...(systemOne.baseUrl === undefined ? {} : { baseUrl: systemOne.baseUrl }),\n ...(systemOne.model === undefined ? {} : { model: systemOne.model }),\n ...(systemOne.apiKeyEnv === undefined ? {} : { apiKeyEnv: systemOne.apiKeyEnv }),\n ...(systemOne.timeoutMs === undefined ? {} : { timeoutMs: systemOne.timeoutMs })\n };\n}\n\n/**\n * Project the delegation switch, the host patch it edits, and the live capability.\n *\n * The \"not working\" reasons are kept apart on purpose, because the fix differs:\n * `model-selection-off` is a tool that does not publish the level (tick the\n * switch, restart), while `missing-tool` is a host without a delegation tool at\n * all (nothing this plugin can do). `unknown` is neither: it means the capability\n * was not probed, and it must never be rendered as \"off\".\n *\n * `registered` now follows **configuration** (g-054), so the one contradiction\n * this view exists to prevent — \"the switch is ticked, the tool is never\n * registered\" — can no longer be produced by the plugin. `restartRequired` is\n * the remaining explanation for \"I ticked it and the level still does not take\n * effect\": the file asks, but the running host still does not publish the\n * parameter.\n * @param config - the configuration in force.\n * @param facts - gathered runtime facts.\n * @returns the wire projection of the delegation block.\n */\nexport function projectDelegation(config: ResolvedReflexConfig, facts: PanelRuntimeFacts): PanelDelegationView {\n const state = facts.delegationHealth?.state ?? 'unknown';\n const enabled = config.delegation.enabled;\n const registered = [...facts.toolSurface].some((name) => name.endsWith('delegate'));\n const patchEnabled = facts.hostPatch?.enabled ?? false;\n // The runtime's own reading wins over the file's: a stale file that asks for\n // the field while the tool still refuses is precisely the restart case.\n const broken = state === 'model-selection-off' || state === 'missing-tool';\n const reason =\n enabled && broken\n ? facts.delegationHealth?.reason\n : // An unprobed capability explains itself: without this the panel would\n // fall back to the patch's reason and imply the patch was the problem.\n enabled && state === 'unknown' && registered\n ? facts.delegationHealth?.reason\n : facts.hostPatch?.reason;\n return {\n enabled,\n registered,\n state,\n patchEnabled,\n restartRequired: enabled && patchEnabled && state === 'model-selection-off',\n ...(facts.hostPatch?.path === undefined ? {} : { patchPath: facts.hostPatch.path }),\n ...(facts.hostPatch?.source === undefined ? {} : { patchPathSource: facts.hostPatch.source }),\n ...(reason === undefined ? {} : { reason })\n };\n}\n\n/** Detached copy of one pool entry, so a caller cannot mutate the payload later. */\nfunction clonePoolEntry(entry: PanelPoolEntry): PanelPoolEntry {\n return {\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 * Clamp a requested ledger window onto the accepted range.\n * @param limit - requested count; non-finite values fall back to the default.\n * @returns a count in `[1, PANEL_LEDGER_WINDOW_MAX]`.\n */\nexport function clampLimit(limit: number): number {\n if (!Number.isFinite(limit)) return PANEL_LEDGER_WINDOW;\n return Math.min(PANEL_LEDGER_WINDOW_MAX, Math.max(1, Math.floor(limit)));\n}\n\n/**\n * Read one query parameter of a panel request.\n * @param url - raw request URL, path and query.\n * @param name - parameter name.\n * @returns the value, or `null` when absent.\n */\nexport function readQuery(url: string | undefined, name: string): string | null {\n const query = url === undefined ? '' : (url.split('?')[1] ?? '');\n return new URLSearchParams(query).get(name);\n}\n\n/**\n * Read the `limit` query parameter of a panel request.\n * @param url - raw request URL, path and query.\n * @returns the parsed count, or the default when absent or unusable.\n */\nexport function readLimit(url: string | undefined): number {\n const raw = readQuery(url, 'limit');\n if (raw === null || raw.trim().length === 0) return PANEL_LEDGER_WINDOW;\n const parsed = Number(raw);\n return Number.isFinite(parsed) ? clampLimit(parsed) : PANEL_LEDGER_WINDOW;\n}\n\n/** Whether an IPv4 literal names the loopback range `127/8`. */\nexport function isLoopbackIPv4(address: string): boolean {\n const parts = address.split('.');\n if (parts.length !== 4) return false;\n if (parts[0] !== '127') return false;\n return parts.every((part) => /^\\d{1,3}$/.test(part) && Number(part) <= 255);\n}\n\n/**\n * Whether a socket remote address names loopback (`127/8`, `::1`, or a mapped form).\n *\n * The socket address is authoritative: a `Host` header or `X-Forwarded-For` can\n * be forged by the caller, so neither decides this.\n * @param address - `request.socket.remoteAddress`.\n * @returns whether the peer is on this machine.\n */\nexport function isLoopbackAddress(address: string | undefined): boolean {\n if (address === undefined) return false;\n const normalized = address.toLowerCase();\n if (normalized === '::1') return true;\n if (normalized.startsWith('::ffff:')) return isLoopbackIPv4(normalized.slice(7));\n return isLoopbackIPv4(normalized);\n}\n\n/** Extra allow rules a Host may install beside the loopback fence. */\nexport interface PanelAccessOptions {\n /**\n * Whether an optional pairing service recognises this request as a paired\n * device. Absent means \"loopback only\".\n */\n isPaired?: ((request: IncomingMessage) => boolean) | undefined;\n}\n\n/**\n * Whether one request may reach the panel routes.\n * @param request - the incoming request.\n * @param options - optional pairing check.\n * @returns whether the request is allowed.\n */\nexport function isPanelRequestAllowed(request: IncomingMessage, options: PanelAccessOptions = {}): boolean {\n if (isLoopbackAddress(request.socket?.remoteAddress)) return true;\n const isPaired = options.isPaired;\n if (typeof isPaired !== 'function') return false;\n try {\n return isPaired(request) === true;\n } catch {\n return false;\n }\n}\n\n/** Narrow response face the panel handlers need; `ServerResponse` satisfies it. */\nexport interface PanelResponse {\n writeHead(status: number, headers?: Record<string, string>): unknown;\n end(chunk?: string): unknown;\n}\n\n/** What one panel request resolves to, before it is serialized. */\nexport interface PanelAnswer {\n status: number;\n body: unknown;\n headers?: Record<string, string>;\n}\n\n/** The live facts one panel route family answers from. */\nexport interface PanelSource {\n /** Build the current snapshot. */\n snapshot(limit: number): PanelSnapshot;\n /** Clear the ledger. @returns how many entries were dropped. */\n clearLedger(): number;\n /** Whether the loopback/pairing fence admitted this request. */\n allows(request: IncomingMessage): boolean;\n /**\n * Turn the host `modelSelection` switch on in the profile patch.\n *\n * Omitted by a host that cannot write the file; the route then answers 501\n * rather than pretending, which is what tells the panel to say \"do it by hand\".\n * @returns the outcome the panel renders.\n */\n enableDelegation?: () => PanelDelegationWrite;\n /**\n * Probe one System One profile; absent means the host cannot, and the route\n * answers 501 rather than pretending the connection was fine.\n * @param profile - profile name, or `undefined` for the active one.\n * @param signal - cancelled when the client goes away.\n * @returns the classified probe result.\n */\n testSystemOne?: (profile: string | undefined, signal: AbortSignal) => Promise<PanelProbeAnswer>;\n}\n\n/** The answer of one connection probe. */\nexport interface PanelProbeAnswer {\n ok: boolean;\n /** `ok` | `auth-failed` | `unreachable` | `timeout` | `bad-response` | `misconfigured`. */\n status: string;\n /** Real round trip, in milliseconds. */\n latencyMs: number;\n /** Profile that was probed, or `null` when the flat block was. */\n profile: string | null;\n httpStatus?: number;\n /** Redacted, single-line explanation. */\n detail?: string;\n model?: string;\n endpoint?: string;\n}\n\n/** The answer of one delegation write. */\nexport interface PanelDelegationWrite {\n /** What happened, in the vocabulary {@link HostPatchResult} uses. */\n outcome: string;\n /** Absolute path edited, when one was. */\n path?: string;\n /** Which fact resolved that path. */\n source?: string;\n /** Why nothing was written, when nothing was. */\n reason?: string;\n /** Backup written before the edit, when one was. */\n backupPath?: string;\n /**\n * Whether the change needs a DSH restart to take effect.\n *\n * Always `true` for an actual write: the host reads `tool-subagent`'s config\n * at boot, and only this plugin's own fiber hot-updates.\n */\n restartRequired: boolean;\n}\n\n/** JSON headers every panel answer carries. */\nfunction jsonHeaders(extra: Record<string, string> = {}): Record<string, string> {\n return { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store', ...extra };\n}\n\n/**\n * Resolve one panel request into a status and a JSON body.\n *\n * Kept separate from the socket so the whole route family is testable without a\n * server: {@link makePanelRoutes} only adapts this to `node:http`.\n * @param source - the live facts.\n * @param request - the incoming request.\n * @returns the answer to serialize.\n */\nexport function answerPanelRequest(source: PanelSource, request: IncomingMessage): PanelAnswer {\n const method = (request.method ?? 'GET').toUpperCase();\n const path = (request.url ?? '/').split('?')[0] ?? '/';\n\n if (!source.allows(request)) {\n return { status: 403, body: { ok: false, error: 'forbidden', detail: 'the reflex panel answers loopback clients and paired devices only' } };\n }\n\n switch (path) {\n case PANEL_ROUTES.snapshot:\n if (method !== 'GET' && method !== 'HEAD') return methodNotAllowed('GET, HEAD');\n return { status: 200, body: source.snapshot(readLimit(request.url)) };\n case PANEL_ROUTES.health:\n if (method !== 'GET' && method !== 'HEAD') return methodNotAllowed('GET, HEAD');\n return { status: 200, body: { ok: true, name: 'dsh-reflex', version: REFLEX_PLUGIN_VERSION } };\n case PANEL_ROUTES.delegation:\n if (method !== 'POST') return methodNotAllowed('POST');\n // The write edits a file the user owns, outside this plugin's settings\n // section. Same fence as the ledger clear: an accidental or cross-site\n // GET/POST must not be enough, so the caller has to name the intent.\n if (readQuery(request.url, 'confirm') !== 'delegation') {\n return {\n status: 400,\n body: {\n ok: false,\n error: 'confirmation-required',\n detail: 'this writes tool-subagent.modelSelection into the profile patch; repeat the POST with ?confirm=delegation'\n }\n };\n }\n if (source.enableDelegation === undefined) {\n return {\n status: 501,\n body: { ok: false, error: 'not-writable', detail: 'this host cannot write the profile patch; add the row by hand' }\n };\n }\n return { status: 200, body: { ok: true, ...source.enableDelegation() } };\n case PANEL_ROUTES.clearLedger:\n if (method !== 'POST') return methodNotAllowed('POST');\n // Clearing deletes the owned JSONL sink as well as the in-memory entries,\n // so an accidental (or cross-site) POST must not be enough on its own.\n if (readQuery(request.url, 'confirm') !== 'clear') {\n return {\n status: 400,\n body: {\n ok: false,\n error: 'confirmation-required',\n detail: 'clearing the ledger deletes its JSONL sink; repeat the POST with ?confirm=clear'\n }\n };\n }\n return { status: 200, body: { ok: true, cleared: source.clearLedger() } };\n default:\n return { status: 404, body: { ok: false, error: 'not-found', detail: `unknown reflex panel route \"${path}\"` } };\n }\n}\n\n/** Largest body the probe route will read, so a request cannot make it buffer the world. */\nexport const PANEL_PROBE_BODY_MAX = 4_096;\n\n/**\n * Read one request body, bounded.\n *\n * @param request - the incoming request.\n * @param max - largest accepted length in bytes.\n * @returns the body text, or `undefined` when it exceeded the bound.\n */\nasync function readBoundedBody(request: IncomingMessage, max: number = PANEL_PROBE_BODY_MAX): Promise<string | undefined> {\n const stream = request as IncomingMessage & AsyncIterable<Buffer | string>;\n let size = 0;\n const chunks: string[] = [];\n for await (const chunk of stream) {\n const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n size += Buffer.byteLength(text, 'utf8');\n if (size > max) return undefined;\n chunks.push(text);\n }\n return chunks.join('');\n}\n\n/**\n * Resolve one panel request that may need to read a body or probe a connection.\n *\n * The synchronous {@link answerPanelRequest} stays the entry point for every\n * route that needs neither, which is what keeps its existing callers (and their\n * assertions) unchanged. This one handles the probe route, whose body names the\n * profile and whose answer takes a real network round trip.\n *\n * @param source - the live facts.\n * @param request - the incoming request.\n * @returns the answer to serialize.\n */\nexport async function answerPanelRequestAsync(source: PanelSource, request: IncomingMessage): Promise<PanelAnswer> {\n const path = (request.url ?? '/').split('?')[0] ?? '/';\n if (path !== PANEL_ROUTES.systemOneTest) return answerPanelRequest(source, request);\n\n const method = (request.method ?? 'GET').toUpperCase();\n if (!source.allows(request)) {\n return { status: 403, body: { ok: false, error: 'forbidden', detail: 'the reflex panel answers loopback clients and paired devices only' } };\n }\n if (method !== 'POST') return methodNotAllowed('POST');\n if (source.testSystemOne === undefined) {\n return {\n status: 501,\n body: { ok: false, error: 'not-probeable', detail: 'this host cannot reach a System One endpoint from the server' }\n };\n }\n\n // An absent body means \"the active profile\"; anything else must be JSON naming\n // one. A malformed body is refused here rather than guessed at.\n const raw = await readBoundedBody(request);\n if (raw === undefined) {\n return { status: 413, body: { ok: false, error: 'body-too-large', detail: `the request body must stay under ${String(PANEL_PROBE_BODY_MAX)} bytes` } };\n }\n let requested: string | undefined;\n const trimmed = raw.trim();\n if (trimmed.length > 0) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(trimmed);\n } catch {\n return { status: 400, body: { ok: false, error: 'bad-json', detail: 'the request body must be JSON like {\"profile\":\"name\"}' } };\n }\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {\n return { status: 400, body: { ok: false, error: 'bad-body', detail: 'the request body must be a JSON object' } };\n }\n const value = (parsed as { profile?: unknown }).profile;\n if (value !== undefined && typeof value !== 'string') {\n return { status: 400, body: { ok: false, error: 'bad-profile', detail: '\"profile\" must be a string when present' } };\n }\n requested = typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;\n }\n\n // The client may go away mid-probe (panel closed, route unmounted); the probe\n // then stops instead of completing into a destroyed socket.\n const controller = new AbortController();\n request.once?.('close', () => controller.abort());\n try {\n const result = await source.testSystemOne(requested, controller.signal);\n // `result` already carries `ok`, so the spread is the whole payload.\n return { status: 200, body: result };\n } catch (error) {\n // A probe is supposed to classify its own failures; reaching here means a bug.\n // Report it as a failed probe rather than a 500, so the row still renders.\n return {\n status: 200,\n body: {\n ok: false,\n status: 'bad-response',\n latencyMs: 0,\n profile: requested ?? null,\n detail: error instanceof Error ? redactProbeText(error.message) : 'the probe failed'\n }\n };\n }\n}\n\n/**\n * Scrub one probe detail before it is put on the wire.\n *\n * The probe already redacts; this is the second gate, at the boundary the payload\n * actually leaves through, so a bug in the first cannot become a leak.\n * @param text - raw detail.\n * @returns a single-line string with credential shapes removed.\n */\nfunction redactProbeText(text: string): string {\n return String(text ?? '')\n .replace(/Bearer\\s+[^\\s\"',;}]+/gi, 'Bearer ***')\n .replace(/\\b(sk|pk|key)-[A-Za-z0-9._-]{6,}/g, '$1-***')\n .replace(/\\s+/g, ' ')\n .trim()\n .slice(0, 240);\n}\n\n/** Standard 405 answer. */\nfunction methodNotAllowed(allow: string): PanelAnswer {\n return { status: 405, body: { ok: false, error: 'method-not-allowed', detail: `use ${allow}` }, headers: { allow } };\n}\n\n/**\n * Serve one resolved answer over a `node:http` response.\n *\n * `HEAD` carries the same headers and no body, which is what a probe needs — so\n * the length is measured from the body the matching `GET` would send rather than\n * left for the server to guess from an empty chunk.\n * @param request - the incoming request.\n * @param response - the response to own.\n * @param answer - the resolved answer.\n */\nexport function sendPanelAnswer(request: IncomingMessage, response: PanelResponse, answer: PanelAnswer): void {\n const suppressed = answer.status === 204;\n const payload = suppressed ? '' : JSON.stringify(answer.body);\n const headers = jsonHeaders({\n ...(suppressed ? {} : { 'content-length': String(Buffer.byteLength(payload, 'utf8')) }),\n ...answer.headers\n });\n response.writeHead(answer.status, headers);\n if (suppressed || (request.method ?? 'GET').toUpperCase() === 'HEAD') {\n response.end();\n return;\n }\n response.end(payload);\n}\n\n/**\n * Build the `/api/dsh-reflex/*` route family.\n *\n * One handler owns every path in the family, so the method/path decision lives\n * in {@link answerPanelRequest} and cannot drift between routes; the\n * `kind: 'exact'` paths mean the server never routes an unrelated URL here.\n *\n * ## Why the handler catches\n *\n * The Host maps a throw out of a route handler onto a bare `400` with an empty\n * body, which erases the stack — the one thing needed to diagnose it. A panel\n * route that fails must therefore answer for itself: `500` plus the real detail.\n * This is not a substitute for handling a known failure where it happens (a\n * missing service is read defensively, not caught here); it guarantees that an\n * *unknown* one is still visible instead of silently becoming \"bad request\".\n * @param source - the live facts.\n * @returns the routes to register.\n */\nexport function makePanelRoutes(source: PanelSource): WebRoute[] {\n const handler = (request: IncomingMessage, response: ServerResponse): void => {\n void answerPanelRequestAsync(source, request)\n .then((answer) => sendPanelAnswer(request, response, answer))\n .catch((error: unknown) => {\n reportHandlerError(response, error);\n });\n };\n\n const reportHandlerError = (response: ServerResponse, error: unknown): void => {\n const detail = error instanceof Error ? (error.stack ?? error.message) : String(error);\n try {\n response.writeHead(500, {\n 'content-type': 'application/json; charset=utf-8',\n 'cache-control': 'no-store'\n });\n response.end(JSON.stringify({ ok: false, error: 'panel-handler-threw', detail }));\n } catch {\n // The socket is already gone: there is nobody left to report to.\n }\n };\n return [\n { kind: 'exact', path: PANEL_ROUTES.snapshot, handler },\n { kind: 'exact', path: PANEL_ROUTES.health, handler },\n { kind: 'exact', path: PANEL_ROUTES.clearLedger, handler },\n { kind: 'exact', path: PANEL_ROUTES.delegation, handler },\n { kind: 'exact', path: PANEL_ROUTES.systemOneTest, handler }\n ];\n}\n\n/** Every path this family owns, for diagnostics and tests. */\nexport const PANEL_PATHS: readonly string[] = Object.values(PANEL_ROUTES);\n"]}
|
package/dist/panel-mount.d.ts
CHANGED
|
@@ -1,31 +1,88 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host-side mounting of the Reflex settings panel routes.
|
|
3
|
-
*
|
|
4
|
-
* Kept apart from {@link applyReflex} for one reason: the panel is the only
|
|
5
|
-
* part of this plugin that needs a Web server, and the plugin must stay fully
|
|
6
|
-
* functional without one (stdio MCP hosts, tests, headless embeds). So the
|
|
7
|
-
* routes are mounted through a *scoped* cordis injection — `ctx.inject(
|
|
8
|
-
* ['webServer'], …)` — which simply never activates when the service is absent,
|
|
9
|
-
* instead of adding `webServer` to the plugin's own `inject` list and stalling
|
|
10
|
-
* every activation on a service a headless host will never provide.
|
|
11
|
-
*
|
|
12
|
-
* One panel per registrant context: a deployment may activate this plugin more
|
|
13
|
-
* than once (different tool prefixes), but two families on the same paths would
|
|
14
|
-
* fight over the same URLs, so the first activation owns the panel and later
|
|
15
|
-
* ones are reported and ignored.
|
|
16
|
-
*
|
|
17
|
-
* @module dsh-reflex/panel-mount
|
|
18
|
-
*/
|
|
19
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import { type ResolvedSystemOneConfig } from './config.js';
|
|
3
|
+
import { type HostPatchOptions } from './host-patch.js';
|
|
20
4
|
import type { ReflexRuntime } from './bridge.js';
|
|
21
|
-
import { type PanelPoolView, type PanelRuntimeFacts, type PanelSource } from './panel-api.js';
|
|
5
|
+
import { type PanelPoolView, type PanelProbeAnswer, type PanelRuntimeFacts, type PanelSource } from './panel-api.js';
|
|
22
6
|
/**
|
|
23
7
|
* Project this activation's model pools onto the panel view.
|
|
24
8
|
* @param runtime - the activation's runtime.
|
|
25
9
|
* @returns one row per configured virtual model, in authored order.
|
|
26
10
|
*/
|
|
27
11
|
export declare function panelPools(runtime: ReflexRuntime): PanelPoolView[];
|
|
28
|
-
export declare function panelFacts(runtime: ReflexRuntime, env?: Record<string, string | undefined>, ctx?: Context): PanelRuntimeFacts;
|
|
12
|
+
export declare function panelFacts(runtime: ReflexRuntime, env?: Record<string, string | undefined>, ctx?: Context, hostPatch?: HostPatchOptions): PanelRuntimeFacts;
|
|
13
|
+
/**
|
|
14
|
+
* Key readiness as the panel needs it: presence, provenance, and the *reason*
|
|
15
|
+
* for an absence.
|
|
16
|
+
*
|
|
17
|
+
* `apiKeyLocked` is the fact g-059 added: the block **named** a variable and that
|
|
18
|
+
* variable is empty. It is deliberately separate from plain
|
|
19
|
+
* `apiKeyPresent === false`, which now means "nothing was named and nothing was
|
|
20
|
+
* exported" — the two need different copy, and "the name I typed is empty" must
|
|
21
|
+
* not read as "no key anywhere".
|
|
22
|
+
*
|
|
23
|
+
* The value is never part of this type: the facts are booleans, a source tag,
|
|
24
|
+
* and a variable *name*.
|
|
25
|
+
*/
|
|
26
|
+
export interface ApiKeyFacts {
|
|
27
|
+
/** Whether a key resolved. */
|
|
28
|
+
apiKeyPresent: boolean;
|
|
29
|
+
/** Where the key came from when {@link apiKeyPresent}. */
|
|
30
|
+
apiKeySource?: 'profile' | 'env' | 'fallback';
|
|
31
|
+
/**
|
|
32
|
+
* The variable behind the key (when present), or the named-but-empty variable
|
|
33
|
+
* (when locked). Absent only when nothing was named and nothing resolved.
|
|
34
|
+
*/
|
|
35
|
+
apiKeyVariable?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The block named a variable, that variable is empty, and the lookup stopped
|
|
38
|
+
* there on purpose: no fallback was consulted and none will be.
|
|
39
|
+
*/
|
|
40
|
+
apiKeyLocked?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The readiness facts the snapshot reports about the key in force.
|
|
44
|
+
*
|
|
45
|
+
* Presence and provenance are read from {@link resolveApiKeyWithSource} — the
|
|
46
|
+
* one chain — so the panel can say *where* the key came from instead of guessing
|
|
47
|
+
* from `apiKeyEnv`.
|
|
48
|
+
*
|
|
49
|
+
* @param systemOne - the connection block in force.
|
|
50
|
+
* @param env - environment the chain reads.
|
|
51
|
+
* @returns the presence/provenance facts for the snapshot.
|
|
52
|
+
*/
|
|
53
|
+
export declare function apiKeyFacts(systemOne: Pick<ResolvedSystemOneConfig, 'apiKey' | 'apiKeyEnv'>, env?: Record<string, string | undefined>): ApiKeyFacts;
|
|
54
|
+
/**
|
|
55
|
+
* Gather key *presence* and provenance for every authored profile.
|
|
56
|
+
*
|
|
57
|
+
* Returns facts and nothing else: the panel renders a placeholder from
|
|
58
|
+
* `present` and never needs the value. `fromProfile` distinguishes a key stored in
|
|
59
|
+
* the settings document from one read out of the environment, and `variable`
|
|
60
|
+
* names the variable that supplied it — still without the value. Each row goes
|
|
61
|
+
* through {@link resolveApiKeyWithSource}, so a profile inheriting a fallback
|
|
62
|
+
* variable is reported the same way the backend would resolve it.
|
|
63
|
+
*
|
|
64
|
+
* @param systemOne - the connection block in force.
|
|
65
|
+
* @param env - environment the chain reads.
|
|
66
|
+
* @returns one presence record per profile name.
|
|
67
|
+
*/
|
|
68
|
+
export declare function profileKeyPresence(systemOne: Pick<ResolvedSystemOneConfig, 'profiles'>, env?: Record<string, string | undefined>): Record<string, {
|
|
69
|
+
present: boolean;
|
|
70
|
+
fromProfile: boolean;
|
|
71
|
+
variable?: string;
|
|
72
|
+
locked?: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Build the probe the test route calls for one profile name.
|
|
76
|
+
*
|
|
77
|
+
* Reads the profile out of the *live* configuration on every call, so a test
|
|
78
|
+
* started right after a save probes what was just saved. The key is handed to
|
|
79
|
+
* {@link probeSystemOne} and never leaves this process.
|
|
80
|
+
*
|
|
81
|
+
* @param runtime - the activation's runtime.
|
|
82
|
+
* @param env - environment the `apiKeyEnv` indirection reads.
|
|
83
|
+
* @returns the probe callback the panel source exposes.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createSystemOneProbe(runtime: ReflexRuntime, env?: Record<string, string | undefined>, fetchImpl?: typeof fetch): (profile: string | undefined, signal: AbortSignal) => Promise<PanelProbeAnswer>;
|
|
29
86
|
/**
|
|
30
87
|
* Build the live source the panel routes answer from.
|
|
31
88
|
* @param ctx - the registrant context, used only for the optional pairing check.
|
|
@@ -33,7 +90,7 @@ export declare function panelFacts(runtime: ReflexRuntime, env?: Record<string,
|
|
|
33
90
|
* @param env - environment the API-key indirection reads.
|
|
34
91
|
* @returns the source {@link makePanelRoutes} serves.
|
|
35
92
|
*/
|
|
36
|
-
export declare function createPanelSource(ctx: Context, runtime: ReflexRuntime, env?: Record<string, string | undefined
|
|
93
|
+
export declare function createPanelSource(ctx: Context, runtime: ReflexRuntime, env?: Record<string, string | undefined>, hostPatch?: HostPatchOptions): PanelSource;
|
|
37
94
|
/**
|
|
38
95
|
* Mount the panel routes for one activation, if this Host serves HTTP.
|
|
39
96
|
*
|
|
@@ -41,4 +98,6 @@ export declare function createPanelSource(ctx: Context, runtime: ReflexRuntime,
|
|
|
41
98
|
* @param runtime - the activation's runtime.
|
|
42
99
|
* @returns a disposer that releases this activation's panel ownership.
|
|
43
100
|
*/
|
|
44
|
-
export declare function mountReflexPanel(ctx: Context, runtime: ReflexRuntime
|
|
101
|
+
export declare function mountReflexPanel(ctx: Context, runtime: ReflexRuntime, options?: {
|
|
102
|
+
hostPatch?: HostPatchOptions;
|
|
103
|
+
}): () => void;
|