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.
Files changed (124) hide show
  1. package/README.md +20 -6
  2. package/client.js +3511 -185
  3. package/dist/attribution.d.ts +266 -0
  4. package/dist/attribution.js +238 -0
  5. package/dist/attribution.js.map +1 -0
  6. package/dist/bridge.d.ts +311 -13
  7. package/dist/bridge.js +714 -42
  8. package/dist/bridge.js.map +1 -1
  9. package/dist/client-bundle.js +4 -1
  10. package/dist/client-bundle.js.map +1 -1
  11. package/dist/command.js +10 -0
  12. package/dist/command.js.map +1 -1
  13. package/dist/config.d.ts +530 -22
  14. package/dist/config.js +808 -27
  15. package/dist/config.js.map +1 -1
  16. package/dist/delegation-dispatch.d.ts +132 -0
  17. package/dist/delegation-dispatch.js +186 -0
  18. package/dist/delegation-dispatch.js.map +1 -0
  19. package/dist/delegation-health.d.ts +131 -0
  20. package/dist/delegation-health.js +97 -0
  21. package/dist/delegation-health.js.map +1 -0
  22. package/dist/delegation.d.ts +148 -0
  23. package/dist/delegation.js +186 -0
  24. package/dist/delegation.js.map +1 -0
  25. package/dist/effort-delegation.d.ts +144 -0
  26. package/dist/effort-delegation.js +280 -0
  27. package/dist/effort-delegation.js.map +1 -0
  28. package/dist/effort.d.ts +141 -0
  29. package/dist/effort.js +251 -9
  30. package/dist/effort.js.map +1 -1
  31. package/dist/host-patch.d.ts +156 -0
  32. package/dist/host-patch.js +534 -0
  33. package/dist/host-patch.js.map +1 -0
  34. package/dist/index.d.ts +12 -3
  35. package/dist/index.js +99 -7
  36. package/dist/index.js.map +1 -1
  37. package/dist/interventions.d.ts +98 -373
  38. package/dist/interventions.js +442 -1702
  39. package/dist/interventions.js.map +1 -1
  40. package/dist/panel-api.d.ts +328 -4
  41. package/dist/panel-api.js +322 -15
  42. package/dist/panel-api.js.map +1 -1
  43. package/dist/panel-mount.d.ts +81 -22
  44. package/dist/panel-mount.js +228 -7
  45. package/dist/panel-mount.js.map +1 -1
  46. package/dist/routing.d.ts +23 -18
  47. package/dist/routing.js +471 -153
  48. package/dist/routing.js.map +1 -1
  49. package/dist/session-audit.d.ts +70 -0
  50. package/dist/session-audit.js +73 -0
  51. package/dist/session-audit.js.map +1 -1
  52. package/dist/systemone-probe.d.ts +114 -0
  53. package/dist/systemone-probe.js +383 -0
  54. package/dist/systemone-probe.js.map +1 -0
  55. package/dist/testing.d.ts +212 -7
  56. package/dist/testing.js +333 -27
  57. package/dist/testing.js.map +1 -1
  58. package/dist/tools.d.ts +109 -3
  59. package/dist/tools.js +103 -4
  60. package/dist/tools.js.map +1 -1
  61. package/dist/unconfigured-backend.d.ts +72 -0
  62. package/dist/unconfigured-backend.js +94 -0
  63. package/dist/unconfigured-backend.js.map +1 -0
  64. package/dist/vendor/harness-reflex/backend/factory.d.ts +31 -1
  65. package/dist/vendor/harness-reflex/backend/factory.js +18 -3
  66. package/dist/vendor/harness-reflex/backend/factory.js.map +1 -1
  67. package/dist/vendor/harness-reflex/backend/jev.d.ts +20 -0
  68. package/dist/vendor/harness-reflex/backend/jev.js +11 -4
  69. package/dist/vendor/harness-reflex/backend/jev.js.map +1 -1
  70. package/dist/vendor/harness-reflex/backend/simple-jev.d.ts +16 -0
  71. package/dist/vendor/harness-reflex/backend/simple-jev.js +17 -6
  72. package/dist/vendor/harness-reflex/backend/simple-jev.js.map +1 -1
  73. package/dist/vendor/harness-reflex/core/closing.d.ts +90 -0
  74. package/dist/vendor/harness-reflex/core/closing.js +111 -0
  75. package/dist/vendor/harness-reflex/core/closing.js.map +1 -0
  76. package/dist/vendor/harness-reflex/core/evidence.d.ts +119 -0
  77. package/dist/vendor/harness-reflex/core/evidence.js +209 -0
  78. package/dist/vendor/harness-reflex/core/evidence.js.map +1 -0
  79. package/dist/vendor/harness-reflex/core/judge.d.ts +221 -0
  80. package/dist/vendor/harness-reflex/core/judge.js +251 -0
  81. package/dist/vendor/harness-reflex/core/judge.js.map +1 -0
  82. package/dist/vendor/harness-reflex/core/orchestrate-closing.d.ts +237 -0
  83. package/dist/vendor/harness-reflex/core/orchestrate-closing.js +250 -0
  84. package/dist/vendor/harness-reflex/core/orchestrate-closing.js.map +1 -0
  85. package/dist/vendor/harness-reflex/core/orchestrate-correction.d.ts +209 -0
  86. package/dist/vendor/harness-reflex/core/orchestrate-correction.js +141 -0
  87. package/dist/vendor/harness-reflex/core/orchestrate-correction.js.map +1 -0
  88. package/dist/vendor/harness-reflex/core/orchestrate-host.d.ts +225 -0
  89. package/dist/vendor/harness-reflex/core/orchestrate-host.js +80 -0
  90. package/dist/vendor/harness-reflex/core/orchestrate-host.js.map +1 -0
  91. package/dist/vendor/harness-reflex/core/orchestrate-stagnation.d.ts +259 -0
  92. package/dist/vendor/harness-reflex/core/orchestrate-stagnation.js +270 -0
  93. package/dist/vendor/harness-reflex/core/orchestrate-stagnation.js.map +1 -0
  94. package/dist/vendor/harness-reflex/core/orchestrate.d.ts +357 -0
  95. package/dist/vendor/harness-reflex/core/orchestrate.js +418 -0
  96. package/dist/vendor/harness-reflex/core/orchestrate.js.map +1 -0
  97. package/dist/vendor/harness-reflex/core/policy.d.ts +122 -0
  98. package/dist/vendor/harness-reflex/core/policy.js +102 -0
  99. package/dist/vendor/harness-reflex/core/policy.js.map +1 -0
  100. package/dist/vendor/harness-reflex/core/prune-plan.d.ts +141 -0
  101. package/dist/vendor/harness-reflex/core/prune-plan.js +390 -0
  102. package/dist/vendor/harness-reflex/core/prune-plan.js.map +1 -0
  103. package/dist/vendor/harness-reflex/core/text.d.ts +36 -0
  104. package/dist/vendor/harness-reflex/core/text.js +66 -0
  105. package/dist/vendor/harness-reflex/core/text.js.map +1 -0
  106. package/dist/vendor/harness-reflex/ports/audit.d.ts +18 -0
  107. package/dist/vendor/harness-reflex/ports/audit.js +11 -0
  108. package/dist/vendor/harness-reflex/ports/audit.js.map +1 -0
  109. package/dist/vendor/harness-reflex/ports/clock.d.ts +14 -0
  110. package/dist/vendor/harness-reflex/ports/clock.js +11 -0
  111. package/dist/vendor/harness-reflex/ports/clock.js.map +1 -0
  112. package/dist/vendor/harness-reflex/ports/decision.d.ts +75 -0
  113. package/dist/vendor/harness-reflex/ports/decision.js +2 -0
  114. package/dist/vendor/harness-reflex/ports/decision.js.map +1 -0
  115. package/dist/vendor/harness-reflex/ports/index.d.ts +14 -0
  116. package/dist/vendor/harness-reflex/ports/index.js +2 -0
  117. package/dist/vendor/harness-reflex/ports/index.js.map +1 -0
  118. package/dist/vendor/harness-reflex/ports/log.d.ts +22 -0
  119. package/dist/vendor/harness-reflex/ports/log.js +12 -0
  120. package/dist/vendor/harness-reflex/ports/log.js.map +1 -0
  121. package/dist/vendor/harness-reflex/ports/state.d.ts +46 -0
  122. package/dist/vendor/harness-reflex/ports/state.js +13 -0
  123. package/dist/vendor/harness-reflex/ports/state.js.map +1 -0
  124. package/package.json +25 -13
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAyD,MAAM,aAAa,CAAC;AAC7H,OAAO,EAAE,aAAa,EAA6D,MAAM,aAAa,CAAC;AACvG,2EAA2E;AAC3E,+EAA+E;AAC/E,2EAA2E;AAC3E,qDAAqD;AACrD,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAyB,MAAM,YAAY,CAAC;AAuEtG;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC;AAKxE;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAG,kBAAkB,EAAE,SAAS,CAAU,CAAC;AAKjF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAA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OAAO,SAAS,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,IAAK,eAAqC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7D,OAAO,OAAiC,CAAC;IAC3C,CAAC;IACD,MAAM,IAAI,KAAK,CACb,6EAA6E,MAAM,CAAC,KAAK,CAAC,IAAI,CAC/F,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAA4B;IACxD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import z from '@deepseek-ai/schemastery';\n\nimport { ADAPTIVE_EFFORT_LEVELS, EFFORT_TRIGGERS, type AdaptiveEffortLevel, type ReasoningEffortSetting } from './effort.js';\nimport { parseFallback, type ModelPoolEntry, type ModelPools, type PhysicalTarget } from './router.js';\n// Runtime import, not a type-only one: the tool vocabulary is owned by the\n// registry module, and validating `tools.enabled` against a second copy of the\n// list is exactly the drift this import removes. `./tools.js` imports this\n// module for types only, so no runtime cycle exists.\nimport { REFLEX_TOOL_DEFAULT_ENABLED, REFLEX_TOOL_SUFFIXES, type ReflexToolSuffix } from './tools.js';\n\n/**\n * Deployment configuration for the reflex plugin.\n *\n * Every field is optional in the authored form: schemastery supplies the\n * documented defaults, and {@link resolveConfig} normalizes whatever the loader\n * resolved into the fully-populated {@link ResolvedReflexConfig}.\n *\n * @module dsh-reflex/config\n */\n\n/** One authored candidate of a virtual model's pool. */\nexport interface ReflexModelPoolEntry {\n /** Physical provider route. */\n provider: string;\n /** Physical model id. */\n model: string;\n /** Capability note fed to the System 1 decision. */\n description?: string;\n /** Extra matching keywords fed to the System 1 decision. */\n tags?: string[];\n}\n\n/** Authored virtual-provider routing configuration. */\nexport interface ReflexRoutingConfig {\n /** Install the virtual provider and its request interception. Default `true`. */\n enabled?: boolean;\n /** Virtual provider route name. Default `reflex`. */\n virtualProvider?: string;\n /**\n * Physical `provider:model` used when a pool cannot answer (unknown model,\n * empty pool, unrankable candidates). Absent = fail closed: the request is\n * refused with a `ReflexRoutingError` instead of silently dispatching into a\n * route the user never configured.\n */\n fallback?: string;\n /** Virtual model id → ordered physical candidate pool. */\n models?: Record<string, ReflexModelPoolEntry[]>;\n /** Task-text budget handed to the System 1 decision (characters). */\n maxTaskChars?: number;\n}\n\n/**\n * Authored connection settings of the System One decision backend.\n *\n * The Settings panel edits this block, so it is deliberately secret-free: the\n * API key never enters the settings document. `apiKeyEnv` names the environment\n * variable that holds the key, which keeps the credential in the deployment's\n * own environment (and out of every `settings.describe` answer, whose redaction\n * only covers schema-declared secret slots).\n *\n * Every field is optional and *overrides* the environment for this plugin\n * instance only. An omitted field keeps the environment/environment-default\n * behaviour of the backend implementation, so an existing env-configured\n * deployment is unaffected by adding the block.\n */\nexport interface ReflexSystemOneConfig {\n /** Base URL of the Jev gateway or the OpenAI-compatible logits endpoint. */\n baseUrl?: string;\n /** Model id the backend asks for. */\n model?: string;\n /**\n * Name of the environment variable holding the API key (`SYSTEM_ONE_API_KEY`\n * by default). Never the key itself.\n */\n apiKeyEnv?: string;\n /** Per-request timeout in milliseconds. */\n timeoutMs?: number;\n}\n\n/**\n * The three-state vocabulary every automatic capability shares.\n *\n * `off` is the capability absent; `observe` runs the complete detection and\n * action *planning* path while changing nothing the model can see; `active`\n * executes the planned intervention. The shared vocabulary is what keeps one\n * switch — not three subtly different \"disabled\" flags — behind every gate.\n */\nexport const INTERVENTION_MODES = ['off', 'observe', 'active'] as const;\n\n/** One resolved three-state mode. */\nexport type InterventionMode = (typeof INTERVENTION_MODES)[number];\n\n/**\n * A capability-level setting: one of the three modes, or `inherit` to follow\n * {@link ReflexInterventionsConfig.mode}. Inheritance is deliberately not\n * available at the top level, where there is nothing to inherit from.\n */\nexport const INTERVENTION_SETTINGS = [...INTERVENTION_MODES, 'inherit'] as const;\n\n/** One authored capability-level setting. */\nexport type InterventionSetting = (typeof INTERVENTION_SETTINGS)[number];\n\n/**\n * The automatic capabilities, each with its own three-state setting.\n *\n * - `stagnation`: the tool-call gate (`tools/pre-execute`) that denies a call\n * the run is repeating after System 1 confirmed stagnation, plus the\n * corrective context appended at `agent/pre-step`.\n * - `prune`: the result projection (`tools/post-execute`) that shrinks an\n * oversized successful payload below its deterministic floors.\n * - `gate`: corrective feedback (`tools/post-execute`) that turns a repeated\n * failing result into an error carrying the System 1 recommendation.\n * - `closing`: the turn-stop check (`agent/turn-stopping`) that objects to a\n * turn closing on self-contradictory verification evidence.\n */\nexport const INTERVENTION_CAPABILITIES = ['stagnation', 'prune', 'gate', 'closing'] as const;\n\n/** One automatic capability name. */\nexport type InterventionCapability = (typeof INTERVENTION_CAPABILITIES)[number];\n\n/**\n * Authored automatic-intervention configuration.\n *\n * Key names are this plugin's contract with the settings surface: the block is\n * edited through the very same schemastery schema the Settings panel writes, so\n * there is no second write channel and no second source of truth.\n */\nexport interface ReflexInterventionsConfig {\n /**\n * Master mode of every automatic capability. `observe` (the default) runs the\n * full detection path and records what it *would* do without touching the\n * tool call, its result, the message list, or the turn boundary.\n */\n mode?: InterventionSetting;\n /** Per-capability override; an omitted capability inherits {@link mode}. */\n capabilities?: Partial<Record<InterventionCapability, InterventionSetting>>;\n /**\n * Ceiling on applied interventions per turn, so an intervention can never\n * become the loop it was meant to break. Default `3`.\n */\n maxInterventionsPerTurn?: number;\n /**\n * Ceiling on *judgments* per turn — the expensive half of a detection. A\n * pathological turn presenting many similar results is bounded by this rather\n * than by the payload count. Default `3`.\n */\n maxJudgmentsPerTurn?: number;\n /** Ceiling on judgments per agent session. Default `20`. */\n maxJudgmentsPerSession?: number;\n /**\n * Identical consecutive tool calls required before the deterministic\n * pre-trigger spends a System 1 judgment. Default `3`.\n */\n repeatThreshold?: number;\n /** Consecutive failing results required before the same. Default `3`. */\n failureThreshold?: number;\n /** Minimum System 1 confidence for a stagnation verdict to act. Default `0.6`. */\n minConfidence?: number;\n /** Steps of one agent's history a deterministic pre-trigger looks at. Default `6`. */\n windowSize?: number;\n /**\n * Lowest share of a payload's characters a prune may keep. The deterministic\n * floor: a candidate that cuts deeper is replaced by the head/tail form.\n * Default `0.5`.\n */\n pruneFloorRatio?: number;\n /** Characters always kept from the head of a pruned payload. Default `400`. */\n pruneHeadChars?: number;\n /** Characters always kept from the tail of a pruned payload. Default `400`. */\n pruneTailChars?: number;\n /**\n * Character count at/above which pruning judges the payload segment by\n * segment through System One. Below it the deterministic local candidates run\n * and no judgment is spent. Effective value is `max(this, pruneThreshold)`,\n * so raising `pruneThreshold` alone never makes a save invalid. Default `10000`.\n */\n pruneJudgeMinChars?: number;\n /**\n * Probability at/above which a sentence System One classified as a completion\n * claim is submitted to verification. A deterministic floor on a semantic\n * decision, never a word list. Default `0.5`.\n */\n claimMinConfidence?: number;\n /**\n * Character budget of the evidence handed to one closing judgment. Overflow\n * is truncated by priority — diagnostic lines, then tail summaries, then the\n * rest — and the dropped amount is reported. Minimum `200`, default `2400`.\n */\n closingEvidenceChars?: number;\n /** Lookup intent handed to the pruning judgment. */\n intent?: string;\n}\n\n/** Automatic-intervention configuration after defaults and resolution. */\nexport interface ResolvedInterventionsConfig {\n /** The master mode, always one of the three (never `inherit`). */\n mode: InterventionMode;\n /** Effective mode of every capability: the override, else the master mode. */\n capabilities: Record<InterventionCapability, InterventionMode>;\n /** Whether any capability is allowed to act. */\n enabled: boolean;\n maxInterventionsPerTurn: number;\n maxJudgmentsPerTurn: number;\n maxJudgmentsPerSession: number;\n repeatThreshold: number;\n failureThreshold: number;\n minConfidence: number;\n windowSize: number;\n pruneFloorRatio: number;\n pruneHeadChars: number;\n pruneTailChars: number;\n /** At/above this character count pruning judges segments through System One. */\n pruneJudgeMinChars: number;\n /** Confidence floor for a classified completion claim. */\n claimMinConfidence: number;\n /** Character budget of the closing evidence. */\n closingEvidenceChars: number;\n intent: string;\n}\n\n/** Authored adaptive reasoning-effort configuration. */\nexport interface ReflexEffortConfig {\n /**\n * Whether adaptive reasoning effort may run at all. Default `true`, which is\n * the pre-existing behaviour: `reflex`/`auto` and the virtual-route default\n * keep deciding per turn. `false` stops every adaptive decision and withdraws\n * the plugin-injected `reflex` level, leaving concrete levels untouched.\n */\n enabled?: boolean;\n /**\n * `'reflex'`/`'auto'` makes every turn decide its own effort through System 1.\n * Omitted = the plugin never touches `reasoningEffort`, exactly as if this\n * feature were not installed. A concrete level is rejected: fixed depth is a\n * model-selector choice, not a deployment setting.\n */\n reasoningEffort?: ReasoningEffortSetting;\n /** Level used when no cue matches and System 1 cannot decide. Default `medium`. */\n fallback?: AdaptiveEffortLevel;\n /** Minimum System 1 confidence for its answer to be trusted. Default `0.3`. */\n minConfidence?: number;\n}\n\n/**\n * Authored per-tool switches, indexed by tool *suffix* rather than tool name.\n *\n * The suffix is what a user writes (`choice`, `route`, …); the registered name\n * is `toolPrefix` + suffix, so a switch keyed by name would break the moment a\n * deployment renames its prefix. An omitted suffix takes\n * {@link REFLEX_TOOL_DEFAULT_ENABLED} — on for every suffix except `route` —\n * and every suffix can be turned either way explicitly.\n */\nexport interface ReflexToolsConfig {\n /**\n * Suffix → enabled. Omitted entries take the documented default (`route` is\n * the one suffix that starts off); unknown keys are rejected.\n */\n enabled?: Partial<Record<ReflexToolSuffix, boolean>>;\n}\n\n/** Deployment configuration for the reflex tool bundle. */\nexport interface ReflexConfig {\n /**\n * System One decision backend. `auto` honors `SYSTEM_ONE_BACKEND` and the\n * API-key/base-url environment variables; the explicit values force one\n * implementation for this plugin only, without touching the environment.\n */\n backend?: 'auto' | 'mock' | 'jev' | 'vllm';\n /** Prefix for every registered tool name (`reflex_choice`, …). */\n toolPrefix?: string;\n /**\n * JSONL audit sink for the decision ledger. Omitted (the default) keeps the\n * ledger in process memory so a Host never writes into the user's project\n * unless persistence was asked for explicitly.\n */\n ledgerPath?: string;\n /** Character count above which `prune` activates for one payload. */\n pruneThreshold?: number;\n /** Optional calibration curve JSON; falls back to `SYSTEM_ONE_CALIBRATION_FILE`. */\n calibrationPath?: string;\n /** Connection settings of the System One decision backend. */\n systemOne?: ReflexSystemOneConfig;\n /** Virtual provider + System 1 model routing. */\n routing?: ReflexRoutingConfig;\n /** Per-turn adaptive reasoning effort. */\n effort?: ReflexEffortConfig;\n /** Per-tool switches of the eight reflex tools. */\n tools?: ReflexToolsConfig;\n /** Automatic interventions on the Host's tool and agent lifecycle hooks. */\n interventions?: ReflexInterventionsConfig;\n}\n\n/** Routing configuration after defaults and validation have been applied. */\nexport interface ResolvedRoutingConfig {\n enabled: boolean;\n virtualProvider: string;\n fallback?: PhysicalTarget;\n models: ModelPools;\n maxTaskChars: number;\n}\n\n/** System One backend configuration after defaults and validation. */\nexport interface ResolvedSystemOneConfig {\n /** Selected implementation; `auto` keeps the environment heuristics. */\n backend: 'auto' | 'mock' | 'jev' | 'vllm';\n /** Base URL override, absent when the environment decides. */\n baseUrl?: string;\n /** Model id override, absent when the environment decides. */\n model?: string;\n /** Environment variable that holds the API key; never the key itself. */\n apiKeyEnv?: string;\n /** Per-request timeout override in milliseconds. */\n timeoutMs?: number;\n}\n\n/** Effort configuration after defaults and validation have been applied. */\nexport interface ResolvedEffortConfig {\n /** Whether adaptive effort may decide anything; `true` unless authored otherwise. */\n enabled: boolean;\n /**\n * The adaptive trigger marker; `undefined` (the default) leaves\n * `reasoningEffort` entirely to the caller.\n */\n setting?: ReasoningEffortSetting;\n /** Level used when neither System 1 nor the cue classifier has evidence. */\n fallback: AdaptiveEffortLevel;\n /** Minimum System 1 confidence for its answer to be trusted. */\n minConfidence: number;\n}\n\n/** Per-tool switches after defaults: every suffix of the vocabulary is answered. */\nexport interface ResolvedToolsConfig {\n /** Suffix → whether the tool is registered. Every suffix has an entry. */\n enabled: Record<ReflexToolSuffix, boolean>;\n}\n\n/** Configuration after defaults and validation have been applied. */\nexport interface ResolvedReflexConfig {\n backend: 'auto' | 'mock' | 'jev' | 'vllm';\n toolPrefix: string;\n ledgerPath?: string;\n pruneThreshold: number;\n calibrationPath?: string;\n systemOne: ResolvedSystemOneConfig;\n routing: ResolvedRoutingConfig;\n effort: ResolvedEffortConfig;\n tools: ResolvedToolsConfig;\n interventions: ResolvedInterventionsConfig;\n}\n\n/** Schemastery schema for one automatic-intervention block. */\nconst InterventionsSchema = z\n .object({\n mode: z\n .union([...INTERVENTION_MODES])\n .default('observe')\n .description('off = absent, observe = detect and record only (default), active = execute the planned intervention.'),\n capabilities: z\n .object({\n stagnation: z.union([...INTERVENTION_SETTINGS]).description('Tool-call gate and pre-step correction; omit to inherit mode.'),\n prune: z.union([...INTERVENTION_SETTINGS]).description('Oversized result projection; omit to inherit mode.'),\n gate: z.union([...INTERVENTION_SETTINGS]).description('Repeated-failure corrective feedback; omit to inherit mode.'),\n closing: z.union([...INTERVENTION_SETTINGS]).description('Turn-stop objection; omit to inherit mode.')\n })\n .default({}),\n maxInterventionsPerTurn: z.natural().default(3),\n maxJudgmentsPerTurn: z.natural().default(3),\n maxJudgmentsPerSession: z.natural().default(20),\n repeatThreshold: z.natural().min(2).default(3),\n failureThreshold: z.natural().min(2).default(3),\n minConfidence: z.number().min(0).max(1).default(0.6),\n windowSize: z.natural().min(3).default(6),\n pruneFloorRatio: z.number().min(0).max(1).default(0.5),\n pruneHeadChars: z.natural().default(400),\n pruneTailChars: z.natural().default(400),\n pruneJudgeMinChars: z\n .natural()\n .default(10000)\n .description('At or above this many characters, pruning judges the output segment by segment through System One.'),\n claimMinConfidence: z\n .number()\n .min(0)\n .max(1)\n .default(0.5)\n .description('Probability at/above which a sentence classified as a completion claim is submitted to verification.'),\n closingEvidenceChars: z\n .natural()\n .min(200)\n .default(2400)\n .description('Character budget of the evidence handed to one closing judgment; overflow is truncated by priority.'),\n intent: z.string().description('Lookup intent handed to the pruning judgment.')\n })\n .volatile();\n\n/** Schemastery schema for one candidate pool entry. */\nconst ModelPoolEntrySchema = z.object({\n provider: z.string().description('Physical provider route (must not be the virtual provider itself).'),\n model: z.string().description('Physical model id as the provider adapter knows it.'),\n description: z.string().description('Capability note the System 1 decision reasons about.'),\n tags: z.array(z.string()).description('Extra matching keywords for the System 1 decision.')\n});\n\n/** Schemastery schema for the virtual-provider routing block. */\nconst RoutingSchema = z.object({\n enabled: z.boolean().default(true),\n virtualProvider: z.string().default('reflex'),\n fallback: z.string().description('Physical \"provider:model\" used when a pool cannot answer; omit to fail closed.'),\n models: z.dict(z.array(ModelPoolEntrySchema)).default({}),\n maxTaskChars: z.natural().default(400)\n}).volatile();\n\n/** Schemastery schema for the adaptive reasoning-effort block. */\nconst EffortSchema = z.object({\n enabled: z\n .boolean()\n .default(true)\n .description('Whether adaptive reasoning effort may run. Default true; false withdraws the plugin-injected adaptive level.'),\n reasoningEffort: z\n .union([...EFFORT_TRIGGERS])\n .description(\n 'Per-turn adaptive marker (\"reflex\", alias \"auto\"). Omit to leave reasoningEffort to the caller; a concrete level belongs in the model selector.'\n ),\n fallback: z\n .union([...ADAPTIVE_EFFORT_LEVELS])\n .default('medium')\n .description('Level used when System 1 and the cue classifier both have no evidence.'),\n minConfidence: z\n .number()\n .min(0)\n .max(1)\n .default(0.3)\n .description('Minimum System 1 confidence for its answer to be trusted over the cue classifier.')\n}).volatile();\n\n/** Schemastery schema for the System One backend connection block. */\nconst SystemOneSchema = z.object({\n baseUrl: z.string().description('Jev gateway or OpenAI-compatible logits endpoint; omit to use the environment.'),\n model: z.string().description('Model id the backend asks for; omit to use the environment default.'),\n apiKeyEnv: z\n .string()\n .description('Name of the environment variable holding the API key — never the key itself.'),\n timeoutMs: z.natural().description('Per-request timeout in milliseconds; omit for the backend default.')\n}).volatile();\n\n/**\n * Schemastery schema for the per-tool switch block.\n *\n * Deliberately an open dictionary rather than an object with eight declared\n * keys: schemastery drops what an object does not declare, and a dropped typo\n * would read as \"the tool stayed on\" instead of failing. {@link resolveToolsConfig}\n * therefore owns the rejection of unknown suffixes.\n */\nconst ToolsSchema = z\n .object({\n enabled: z\n .dict(z.boolean())\n .default({})\n .description(\n `Suffix → enabled (${REFLEX_TOOL_SUFFIXES.join(', ')}). Omitted suffixes keep their documented default (${REFLEX_TOOL_SUFFIXES.filter((suffix) => !REFLEX_TOOL_DEFAULT_ENABLED[suffix]).join(', ') || 'none'} off, the rest on).`\n )\n })\n .volatile();\n\n/**\n * Schemastery schema the Cordis loader validates the deployment config with.\n *\n * The explicit `Schemastery<ReflexConfig>` annotation is deliberate: the\n * inferred type of a schema containing `z.dict(z.array(...))` names a\n * `cosmokit` helper that is not portably resolvable from this package's\n * emitted declarations, so the public shape is stated instead of inferred.\n */\n/**\n * Schemastery schema of the plugin's configuration.\n */\nexport const Config: Schemastery<any> = z.object({\n backend: z.union(['auto', 'mock', 'jev', 'vllm']).default('auto').volatile(),\n toolPrefix: z.string().default('reflex_').volatile(),\n ledgerPath: z.string().description('JSONL audit sink; omit to keep the ledger in memory.').volatile(),\n pruneThreshold: z.natural().default(500).volatile(),\n calibrationPath: z.string().description('Calibration curve JSON applied to choice confidences.').volatile(),\n systemOne: SystemOneSchema.default({}),\n routing: RoutingSchema.default({}),\n effort: EffortSchema.default({}),\n tools: ToolsSchema.default({}),\n interventions: InterventionsSchema.default({})\n});\n\n/**\n * Validate one authored three-state setting.\n *\n * The loader restricts the value to the schema's union; this repeats the check\n * because {@link resolveConfig} is also the entry point for a programmatic\n * caller, and a typo there must fail loudly instead of silently disabling (or\n * silently enabling) an intervention.\n *\n * @param value - authored setting.\n * @param allowInherit - whether `inherit` is a legal value at this position.\n * @param label - dotted path used in the error.\n * @returns the normalized setting, or `undefined` when nothing was authored.\n * @throws Error when the value is not a legal setting.\n */\nexport function resolveInterventionSetting(\n value: string | undefined,\n allowInherit: boolean,\n label: string\n): InterventionSetting | undefined {\n if (value === undefined) return undefined;\n const setting = typeof value === 'string' ? value.trim().toLowerCase() : '';\n if ((INTERVENTION_SETTINGS as readonly string[]).includes(setting)) {\n if (setting === 'inherit' && !allowInherit) {\n throw new Error(`${label} must be one of ${INTERVENTION_MODES.join(', ')} (got \"inherit\": there is nothing to inherit from)`);\n }\n return setting as InterventionSetting;\n }\n const legal = allowInherit ? INTERVENTION_SETTINGS : INTERVENTION_MODES;\n throw new Error(`${label} must be one of ${legal.join(', ')} (got \"${String(value)}\")`);\n}\n\n/**\n * Validate the automatic-intervention block and fill in every default.\n *\n * Capability entries resolve to an effective three-state mode here, once, so\n * every consumer — listeners, the panel projection, the audit — reads the same\n * answer instead of re-deriving inheritance.\n *\n * @param authored - the authored `interventions` block.\n * @param pruneThreshold - the runtime prune threshold, the lower bound of the\n * segment-judging threshold.\n * @returns the resolved master mode, effective capability modes, and limits.\n * @throws Error when a field is present but unusable.\n */\nexport function resolveInterventionsConfig(\n authored: ReflexInterventionsConfig | undefined,\n pruneThreshold = 500\n): ResolvedInterventionsConfig {\n const block = authored ?? {};\n const mode = (resolveInterventionSetting(block.mode, false, 'interventions.mode') ?? 'observe') as InterventionMode;\n\n const capabilities = {} as Record<InterventionCapability, InterventionMode>;\n for (const capability of INTERVENTION_CAPABILITIES) {\n const setting = resolveInterventionSetting(\n block.capabilities?.[capability],\n true,\n `interventions.capabilities.${capability}`\n );\n capabilities[capability] = setting === undefined || setting === 'inherit' ? mode : setting;\n }\n\n const counts: Array<[number | undefined, string, number, number]> = [\n [block.maxInterventionsPerTurn, 'maxInterventionsPerTurn', 3, 0],\n [block.maxJudgmentsPerTurn, 'maxJudgmentsPerTurn', 3, 0],\n [block.maxJudgmentsPerSession, 'maxJudgmentsPerSession', 20, 0],\n [block.repeatThreshold, 'repeatThreshold', 3, 2],\n [block.failureThreshold, 'failureThreshold', 3, 2],\n [block.windowSize, 'windowSize', 6, 3],\n [block.pruneHeadChars, 'pruneHeadChars', 400, 0],\n [block.pruneTailChars, 'pruneTailChars', 400, 0],\n [block.pruneJudgeMinChars, 'pruneJudgeMinChars', 10000, 0],\n [block.closingEvidenceChars, 'closingEvidenceChars', 2400, 200]\n ];\n const resolved: Record<string, number> = {};\n for (const [value, name, fallback, minimum] of counts) {\n if (value === undefined) {\n resolved[name] = fallback;\n continue;\n }\n if (!Number.isInteger(value) || value < minimum) {\n throw new Error(`interventions.${name} must be an integer >= ${minimum} (got \"${String(value)}\")`);\n }\n resolved[name] = value;\n }\n\n const minConfidence = block.minConfidence ?? 0.6;\n if (!Number.isFinite(minConfidence) || minConfidence < 0 || minConfidence > 1) {\n throw new Error(`interventions.minConfidence must be a number in [0, 1] (got \"${String(block.minConfidence)}\")`);\n }\n const pruneFloorRatio = block.pruneFloorRatio ?? 0.5;\n if (!Number.isFinite(pruneFloorRatio) || pruneFloorRatio < 0 || pruneFloorRatio > 1) {\n throw new Error(`interventions.pruneFloorRatio must be a number in [0, 1] (got \"${String(block.pruneFloorRatio)}\")`);\n }\n const claimMinConfidence = block.claimMinConfidence ?? 0.5;\n if (!Number.isFinite(claimMinConfidence) || claimMinConfidence < 0 || claimMinConfidence > 1) {\n throw new Error(\n `interventions.claimMinConfidence must be a number in [0, 1] (got \"${String(block.claimMinConfidence)}\")`\n );\n }\n // The segment-judging floor is layered on the prune threshold: judging below\n // the size at which pruning even runs is meaningless. Rather than refusing a\n // save that raises `pruneThreshold` alone (the panel exposes it independently,\n // and the user should not have to raise a second field to keep their edit),\n // the effective floor is lifted to the prune threshold. The panel reports the\n // lifted value, which is the one the runtime actually uses.\n const pruneJudgeMinChars = Math.max(resolved.pruneJudgeMinChars!, pruneThreshold);\n\n return {\n mode,\n capabilities,\n // One capability may be enabled by its own override while the master mode is\n // `off`, so the switch that decides whether anything is installed reads the\n // effective modes rather than the master alone.\n enabled: INTERVENTION_CAPABILITIES.some((capability) => capabilities[capability] !== 'off'),\n maxInterventionsPerTurn: resolved.maxInterventionsPerTurn!,\n maxJudgmentsPerTurn: resolved.maxJudgmentsPerTurn!,\n maxJudgmentsPerSession: resolved.maxJudgmentsPerSession!,\n repeatThreshold: resolved.repeatThreshold!,\n failureThreshold: resolved.failureThreshold!,\n minConfidence,\n windowSize: resolved.windowSize!,\n pruneFloorRatio,\n pruneHeadChars: resolved.pruneHeadChars!,\n pruneTailChars: resolved.pruneTailChars!,\n pruneJudgeMinChars,\n claimMinConfidence,\n closingEvidenceChars: resolved.closingEvidenceChars!,\n intent: optionalText(block.intent) ?? 'extract diagnostics, relevant results and errors'\n };\n}\n\n/**\n * Trim one optional authored string, treating blank text as absent.\n * @param value - authored value.\n * @returns the trimmed text, or `undefined` when nothing usable was authored.\n */\nfunction optionalText(value: string | undefined): string | undefined {\n if (typeof value !== 'string') return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Validate the System One connection block and fill in every default.\n * @param backend - the top-level backend selector.\n * @param authored - the authored `systemOne` block.\n * @returns the resolved connection settings.\n * @throws Error when a field is present but unusable.\n */\nexport function resolveSystemOneConfig(\n backend: 'auto' | 'mock' | 'jev' | 'vllm' | undefined,\n authored: ReflexSystemOneConfig | undefined\n): ResolvedSystemOneConfig {\n const selected = backend ?? 'auto';\n if (!(['auto', 'mock', 'jev', 'vllm'] as const).includes(selected)) {\n throw new Error(`backend must be one of auto, mock, jev, vllm (got \"${String(backend)}\")`);\n }\n const baseUrl = optionalText(authored?.baseUrl);\n const model = optionalText(authored?.model);\n const apiKeyEnv = optionalText(authored?.apiKeyEnv);\n const timeoutMs = authored?.timeoutMs;\n if (timeoutMs !== undefined && (!Number.isInteger(timeoutMs) || timeoutMs <= 0)) {\n throw new Error(`systemOne.timeoutMs must be a positive integer (got \"${String(timeoutMs)}\")`);\n }\n return {\n backend: selected,\n ...(baseUrl === undefined ? {} : { baseUrl }),\n ...(model === undefined ? {} : { model }),\n ...(apiKeyEnv === undefined ? {} : { apiKeyEnv }),\n ...(timeoutMs === undefined ? {} : { timeoutMs })\n };\n}\n\n/**\n * Read the API key a resolved connection block points at.\n *\n * The indirection is the point: the settings document carries the variable's\n * *name*, so a panel write can never leak the credential into a file the Host\n * then renders back to every client.\n * @param config - resolved System One connection settings.\n * @param env - environment to read; defaults to `process.env`.\n * @returns the key, or `undefined` when the variable is unset or empty.\n */\nexport function resolveApiKey(\n config: Pick<ResolvedSystemOneConfig, 'apiKeyEnv'>,\n env: Record<string, string | undefined> = process.env\n): string | undefined {\n if (config.apiKeyEnv === undefined) return undefined;\n const value = env[config.apiKeyEnv];\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\n/**\n * Normalize one authored pool into detached `{ provider, model, description, tags }` entries,\n * rejecting candidates that would route back into the virtual provider.\n * @param model - virtual model id owning the pool.\n * @param entries - authored candidates.\n * @param virtualProvider - the virtual provider route.\n * @returns the normalized pool.\n * @throws Error when an entry is unusable or self-referential.\n */\nfunction resolvePool(model: string, entries: ReflexModelPoolEntry[], virtualProvider: string): ModelPoolEntry[] {\n if (!Array.isArray(entries)) throw new Error(`routing.models.${model} must be a list of { provider, model } candidates`);\n\n return entries.map((entry, index) => {\n const provider = typeof entry?.provider === 'string' ? entry.provider.trim() : '';\n const target = typeof entry?.model === 'string' ? entry.model.trim() : '';\n if (provider.length === 0 || target.length === 0) {\n throw new Error(`routing.models.${model}[${index}] needs a non-empty provider and model`);\n }\n if (provider.includes(':')) {\n throw new Error(`routing.models.${model}[${index}].provider must not contain \":\" (got \"${provider}\")`);\n }\n if (provider === virtualProvider) {\n throw new Error(\n `routing.models.${model}[${index}] routes back into the virtual provider \"${virtualProvider}\"; a pool must name physical routes only`\n );\n }\n const tags = Array.isArray(entry.tags) ? entry.tags.filter((tag) => typeof tag === 'string' && tag.trim().length > 0) : [];\n return {\n provider,\n model: target,\n ...(entry.description?.trim() ? { description: entry.description.trim() } : {}),\n ...(tags.length > 0 ? { tags } : {})\n };\n });\n}\n\n/**\n * Read a resolved config value out of its volatile marker.\n */\nexport function plainConfig(value: any): any {\n if (value !== null && typeof value === 'object' && typeof value.get === 'function') {\n return plainConfig(value.get());\n }\n if (Array.isArray(value)) {\n return value.map(item => plainConfig(item));\n }\n if (value !== null && typeof value === 'object') {\n return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, plainConfig(child)]));\n }\n return value;\n}\n\n/**\n * Collect the snapshot of every volatile config reference reachable from one\n * loader-resolved config.\n *\n * A config-only update in the Cordis loader never remounts the plugin: the\n * schemastery `volatile` marks tell the loader to commit the new values into the\n * running fiber's references and dispatch `loader/volatile-update`. Every\n * reference hands out a fresh snapshot object from `get()` when it is committed,\n * so comparing these snapshots by identity answers \"did the live config change?\"\n * without re-validating the whole document, and without the loader itself.\n *\n * @param value - a resolved config, raw config, or one of its blocks.\n * @param out - collector for the snapshot identities.\n * @returns the snapshots, in a stable traversal order; empty for a plain config.\n */\nexport function volatileSnapshots(value: unknown, out: unknown[] = []): unknown[] {\n if (value === null || typeof value !== 'object') return out;\n const reference = value as { get?: unknown };\n if (typeof reference.get === 'function') {\n out.push((reference.get as () => unknown)());\n return out;\n }\n if (Array.isArray(value)) {\n for (const item of value) volatileSnapshots(item, out);\n return out;\n }\n for (const child of Object.values(value as Record<string, unknown>)) volatileSnapshots(child, out);\n return out;\n}\n\n/**\n * Validate an authored config and fill in every default.\n * @param config - deployment config (already resolved by the loader, or raw).\n * @returns the fully-populated configuration.\n * @throws Error when the routing block names an unusable virtual provider or fallback.\n */\nexport function resolveConfig(config?: ReflexConfig): ResolvedReflexConfig {\n const unwrapped = plainConfig(config ?? {});\n const authoredEffort = (unwrapped as { effort?: { reasoningEffort?: unknown } } | null | undefined)?.effort;\n const authoredReasoning =\n authoredEffort !== null && typeof authoredEffort === 'object'\n ? (authoredEffort as { reasoningEffort?: unknown }).reasoningEffort\n : undefined;\n // Check the authored policy *before* the schema: a legacy concrete level then\n // gets the migration hint below instead of the schema's generic union error.\n if (typeof authoredReasoning === 'string') resolveEffortSetting(authoredReasoning);\n const validated = plainConfig(Config(unwrapped)) as ReflexConfig;\n const routing = validated.routing ?? {};\n const effort = validated.effort ?? {};\n\n const virtualProvider = (routing.virtualProvider ?? 'reflex').trim();\n if (virtualProvider.length === 0) throw new Error('routing.virtualProvider must be non-empty');\n if (virtualProvider.includes(':')) {\n throw new Error(`routing.virtualProvider must not contain \":\" (got \"${virtualProvider}\")`);\n }\n\n const setting = resolveEffortSetting(effort.reasoningEffort);\n\n const authored = routing.models ?? {};\n const models: Record<string, ModelPoolEntry[]> = {};\n for (const [model, entries] of Object.entries(authored)) {\n if (model.trim().length === 0) throw new Error('routing.models keys must be non-empty virtual model ids');\n models[model] = resolvePool(model, Array.isArray(entries) ? entries : [], virtualProvider);\n }\n\n const fallback =\n typeof routing.fallback === 'string' && routing.fallback.trim().length > 0 ? parseFallback(routing.fallback) : undefined;\n if (fallback?.provider === virtualProvider) {\n throw new Error(`routing.fallback must not point back into the virtual provider \"${virtualProvider}\"`);\n }\n\n const effortFallback = effort.fallback ?? 'medium';\n if (!(ADAPTIVE_EFFORT_LEVELS as readonly string[]).includes(effortFallback)) {\n throw new Error(`effort.fallback must be one of ${ADAPTIVE_EFFORT_LEVELS.join(', ')} (got \"${String(effortFallback)}\")`);\n }\n const minConfidence = effort.minConfidence ?? 0.3;\n if (!Number.isFinite(minConfidence) || minConfidence < 0 || minConfidence > 1) {\n throw new Error(`effort.minConfidence must be a number in [0, 1] (got \"${String(effort.minConfidence)}\")`);\n }\n const effortEnabled = effort.enabled ?? true;\n if (typeof effortEnabled !== 'boolean') {\n throw new Error(`effort.enabled must be a boolean (got \"${String(effort.enabled)}\")`);\n }\n\n return {\n backend: validated.backend ?? 'auto',\n toolPrefix: validated.toolPrefix ?? 'reflex_',\n ledgerPath: validated.ledgerPath,\n pruneThreshold: validated.pruneThreshold ?? 500,\n calibrationPath: validated.calibrationPath,\n systemOne: resolveSystemOneConfig(validated.backend, validated.systemOne),\n routing: {\n enabled: routing.enabled ?? true,\n virtualProvider,\n models,\n maxTaskChars: routing.maxTaskChars ?? 400,\n ...(fallback ? { fallback } : {})\n },\n effort: {\n enabled: effortEnabled,\n ...(setting === undefined ? {} : { setting }),\n fallback: effortFallback,\n minConfidence\n },\n tools: resolveToolsConfig(validated.tools),\n interventions: resolveInterventionsConfig(validated.interventions, validated.pruneThreshold ?? 500)\n };\n}\n\n/**\n * Validate the per-tool switch block and fill in every omitted suffix.\n *\n * Both failure modes are answered here, not by the schema: an unknown suffix\n * (a typo, or a tool this build does not ship) and a non-boolean value. A\n * deployment that cannot be honoured fails at resolution time rather than\n * half-registering its tools. The suffix vocabulary is this build's, so a\n * switch for a capability that is no longer a tool — `prune`,\n * `detect_stagnation`, `status_ledger` — is refused here instead of being\n * carried as a key that reads as \"on\" and registers nothing.\n *\n * A programmatic caller that passes the switch map itself (instead of wrapping\n * it in `enabled`) is rejected too: silently reading it as \"nothing authored\"\n * would turn that typo into a deployment where everything stays registered.\n *\n * @param authored - the authored `tools` block.\n * @returns every suffix of the vocabulary mapped to its effective switch.\n * @throws Error when the block, a key, or a value cannot be honoured.\n */\nexport function resolveToolsConfig(authored: ReflexToolsConfig | undefined): ResolvedToolsConfig {\n if (authored !== undefined && (authored === null || typeof authored !== 'object' || Array.isArray(authored))) {\n throw new Error(`tools must be an object mapping tool suffixes to booleans (got \"${String(authored)}\")`);\n }\n const block = authored ?? {};\n const extraKeys = Object.keys(block).filter((key) => key !== 'enabled');\n if (extraKeys.length > 0) {\n const rendered = extraKeys.map((key) => JSON.stringify(key)).join(', ');\n throw new Error(\n `tools has unknown key${extraKeys.length === 1 ? '' : 's'} ${rendered}; only \"enabled\" is supported`\n );\n }\n const switches = block.enabled;\n if (switches !== undefined && (switches === null || typeof switches !== 'object' || Array.isArray(switches))) {\n throw new Error(`tools.enabled must be an object mapping tool suffixes to booleans (got \"${String(switches)}\")`);\n }\n const authoredSwitches = switches ?? {};\n const unknown = Object.keys(authoredSwitches).filter((key) => !(REFLEX_TOOL_SUFFIXES as readonly string[]).includes(key));\n if (unknown.length > 0) {\n const rendered = unknown.map((key) => JSON.stringify(key)).join(', ');\n throw new Error(\n `tools.enabled has unknown tool ${unknown.length === 1 ? 'switch' : 'switches'} ${rendered}; legal suffixes are ${REFLEX_TOOL_SUFFIXES.join(', ')}`\n );\n }\n const enabled = {} as Record<ReflexToolSuffix, boolean>;\n for (const suffix of REFLEX_TOOL_SUFFIXES) {\n const value = authoredSwitches[suffix];\n if (value !== undefined && typeof value !== 'boolean') {\n throw new Error(`tools.enabled.${suffix} must be a boolean (got \"${String(value)}\")`);\n }\n // Omitted entries take the per-suffix default instead of an unconditional\n // \"on\": `route` is off unless the deployment asks for it, and the panel,\n // the registry, and this resolver must all agree on that one table.\n enabled[suffix] = value ?? REFLEX_TOOL_DEFAULT_ENABLED[suffix];\n }\n return { enabled };\n}\n\n/**\n * Validate one authored `reasoningEffort` value.\n *\n * Configuration only answers \"should adaptive effort run at all?\": the loader\n * restricts it to the trigger markers, and this repeats the check because\n * {@link resolveConfig} is also the entry point for a programmatic caller. A\n * concrete level is not a typo to ignore — it is an obsolete setting, so the\n * error says where that choice moved instead of silently dropping it.\n *\n * @param value - authored setting.\n * @returns the normalized trigger, or `undefined` when nothing was configured.\n * @throws Error when the value is not `reflex`/`auto` (including a concrete level).\n */\nexport function resolveEffortSetting(value: string | undefined): ReasoningEffortSetting | undefined {\n if (value === undefined) return undefined;\n const setting = typeof value === 'string' ? value.trim().toLowerCase() : '';\n if ((EFFORT_TRIGGERS as readonly string[]).includes(setting)) {\n return setting as ReasoningEffortSetting;\n }\n throw new Error(\n `effort.reasoningEffort 只支持留空或 reflex(别名 auto);要固定思考深度请在模型选择器里选择具体档位 (got \"${String(value)}\")`\n );\n}\n\n/**\n * Whether this configuration can actually route: enabled with at least one\n * non-empty pool. Without a pool the plugin registers no virtual provider at\n * all, so a misconfigured `reflex` selection can never masquerade as working.\n * @param config - resolved configuration.\n * @returns whether routing should be installed.\n */\nexport function routingActive(config: ResolvedReflexConfig): boolean {\n if (!config.routing.enabled) return false;\n return Object.values(config.routing.models).some((pool) => pool.length > 0);\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAyD,MAAM,aAAa,CAAC;AAC7H,OAAO,EAAE,aAAa,EAA6D,MAAM,aAAa,CAAC;AACvG,2EAA2E;AAC3E,+EAA+E;AAC/E,2EAA2E;AAC3E,qDAAqD;AACrD,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAyB,MAAM,YAAY,CAAC;AACtG,+EAA+E;AAC/E,+EAA+E;AAC/E,iFAAiF;AACjF,gEAAgE;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AA+GpF,iEAAiE;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAEnD,kFAAkF;AAClF,MAAM,CAAC,MAAM,2BAA2B,GAAG,aAAa,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrD,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,YAAY;IACnB,SAAS,EAAE,2BAA2B;IACtC,OAAO,EAAE,KAAK;CACf,CAA4C,CAAC;AAE9C;;;;;;;GAOG;AACH,SAAS,qBAAqB;IAC5B,OAAO;QACL,QAAQ,EAAE,EAAE,CAAC,oBAAoB,CAAC,EAAE,EAAE,GAAG,yBAAyB,EAAE,EAAE;QACtE,MAAM,EAAE,oBAAoB;KAC7B,CAAC;AACJ,CAAC;AA4DD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC;AAKxE;;;;GAI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C,CAAC;IAC7H,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,8CAA8C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAyB;IAC5D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,IAAK,eAAqC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7D,OAAO,OAAiC,CAAC;IAC3C,CAAC;IACD,MAAM,IAAI,KAAK,CACb,6EAA6E,MAAM,CAAC,KAAK,CAAC,IAAI,CAC/F,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAA4B;IACxD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import z from '@deepseek-ai/schemastery';\n\nimport { ADAPTIVE_EFFORT_LEVELS, EFFORT_TRIGGERS, type AdaptiveEffortLevel, type ReasoningEffortSetting } from './effort.js';\nimport { parseFallback, type ModelPoolEntry, type ModelPools, type PhysicalTarget } from './router.js';\n// Runtime import, not a type-only one: the tool vocabulary is owned by the\n// registry module, and validating `tools.enabled` against a second copy of the\n// list is exactly the drift this import removes. `./tools.js` imports this\n// module for types only, so no runtime cycle exists.\nimport { REFLEX_TOOL_DEFAULT_ENABLED, REFLEX_TOOL_SUFFIXES, type ReflexToolSuffix } from './tools.js';\n// The factory connection re-states the *project's* official endpoint and model\n// rather than a second copy of the strings: `api.typesafe.ai/v1/systemone` and\n// `jev-latest` are owned by the backend implementation, and a literal here would\n// be a drift waiting to happen the next time the gateway moves.\nimport { DEFAULT_SYSTEMONE_ENDPOINT } from './vendor/harness-reflex/backend/jev.js';\n\n/**\n * Deployment configuration for the reflex plugin.\n *\n * Every field is optional in the authored form: schemastery supplies the\n * documented defaults, and {@link resolveConfig} normalizes whatever the loader\n * resolved into the fully-populated {@link ResolvedReflexConfig}.\n *\n * @module dsh-reflex/config\n */\n\n/** One authored candidate of a virtual model's pool. */\nexport interface ReflexModelPoolEntry {\n /** Physical provider route. */\n provider: string;\n /** Physical model id. */\n model: string;\n /** Capability note fed to the System 1 decision. */\n description?: string;\n /** Extra matching keywords fed to the System 1 decision. */\n tags?: string[];\n}\n\n/** Authored virtual-provider routing configuration. */\nexport interface ReflexRoutingConfig {\n /** Install the virtual provider and its request interception. Default `true`. */\n enabled?: boolean;\n /** Virtual provider route name. Default `reflex`. */\n virtualProvider?: string;\n /**\n * Physical `provider:model` used when a pool cannot answer (unknown model,\n * empty pool, unrankable candidates). Absent = fail closed: the request is\n * refused with a `ReflexRoutingError` instead of silently dispatching into a\n * route the user never configured.\n */\n fallback?: string;\n /** Virtual model id → ordered physical candidate pool. */\n models?: Record<string, ReflexModelPoolEntry[]>;\n /** Task-text budget handed to the System 1 decision (characters). */\n maxTaskChars?: number;\n}\n\n/**\n * One named System One connection profile.\n *\n * A profile **is** the connection (g-066): there is no block of last resort\n * beside it, so every field the runtime needs is either stated here or read out\n * of the environment by the backend. The panel lists profiles, picks one as\n * active, and tests each connection without ever receiving the key: `apiKey` is\n * a schema-declared `role('secret')` slot, so DSH's structural redaction removes\n * it from every wire-boundary value and reports its *presence* through a\n * sidecar instead.\n *\n * Legality: a profile name is a key of `systemOne.profiles`, so it may not be\n * empty, may not contain `.` (the settings-route path separator), and may not\n * collide after case folding — the panel shows these names as identifiers.\n */\nexport interface ReflexSystemOneProfile {\n /** Base URL of the Jev gateway or the OpenAI-compatible logits endpoint. */\n baseUrl?: string;\n /**\n * The one legacy model id (pre-g-066 shape).\n *\n * A connection that authors this and nothing else keeps working untouched:\n * {@link resolveSystemOneProfiles} treats it as a one-entry\n * {@link modelIds} list. Authors spelling both is refused rather than guessed\n * at, because the two say different things about which models exist.\n */\n model?: string;\n /**\n * Every model id this connection may ask for (g-066).\n *\n * A list, not a single id, because one gateway serves several models behind\n * one URL and key. {@link selectedModel} is the one the *runtime* and the\n * *probe* use — the two read the same field, so testing a connection tests\n * what the next decision actually sends.\n */\n modelIds?: string[];\n /**\n * Which of {@link modelIds} is in force.\n *\n * Absent means \"the first one\", which is what a one-model connection always\n * resolves to. A name outside the list is *reported*\n * ({@link ResolvedSystemOneConfig.activeProfileModelMissing}) and resolves to\n * nothing instead of silently running a model nobody selected: quietly\n * picking the first entry is exactly the \"switched behind my back\" behaviour\n * this goal removes.\n */\n selectedModel?: string;\n /**\n * The API key itself.\n *\n * Write-only: schemastery declares it `role('secret')`, so it never crosses a\n * wire boundary and no response can echo it. Absent means \"no key stated by\n * this profile\" — the resolution chain then falls through to `apiKeyEnv`.\n */\n apiKey?: string;\n /**\n * Name of the environment variable holding the API key. Never the key itself.\n *\n * Kept beside {@link apiKey} on purpose: a profile may name an environment\n * variable instead of carrying a secret.\n */\n apiKeyEnv?: string;\n /** Per-request timeout in milliseconds. */\n timeoutMs?: number;\n /** Backend override for this profile (`auto`/`mock`/`jev`/`vllm`). */\n backend?: string;\n}\n\n/** Row name of the factory connection, as the panel shows it. */\nexport const FACTORY_PROFILE_NAME = 'JEV official';\n\n/** The environment variable the factory connection locks onto — never another. */\nexport const FACTORY_PROFILE_API_KEY_ENV = 'JEV_API_KEY';\n\n/**\n * The factory connection (g-067): the project's own Jev gateway, switched on.\n *\n * A deployment whose settings document declares **no** `systemOne` block is a\n * **fresh document**, and it should not open on \"no connection, nothing works\":\n * the plugin ships with one working remote connection already named, already\n * active, pointing at the official endpoint and model, and locked onto\n * {@link FACTORY_PROFILE_API_KEY_ENV}.\n *\n * It is deliberately a normal profile — an entry of `systemOne.profiles` with\n * nothing special about it — and it is supplied by the **schema default**\n * (`Config.systemOne`), which schemastery applies only to an *absent* key. That\n * single rule is the whole distinction between \"fresh\" and \"the owner said\n * something\":\n *\n * - **deactivate** — the page writes `systemOne.active: ''`; the section is\n * stated, resolves as `no-active-profile`, and **no** factory row is filled\n * back in (the row stays listed, switched off);\n * - **delete** — the page unsets the row *and* states the empty activation, so\n * the section is `{profiles: {}, active: ''}` → `no-profiles`, and nothing is\n * filled back in;\n * - **rename / replace** — any authored `systemOne` block wins outright; the\n * factory row is only ever materialized into a document that has none.\n *\n * The one write that would blur the line is a cleared path whose parent is then\n * rebuilt from nothing (`{}`, which schemastery does not default): that is why\n * the page never unsets `systemOne.active` or the last profile row on its own —\n * it states an explicit empty activation instead.\n *\n * The lock matters as much as the row. `apiKeyEnv` **names** the variable, and\n * naming locks (g-059): with no `JEV_API_KEY` exported the connection reports\n * \"named but empty\" and sends no key — it never reaches for\n * `SYSTEM_ONE_API_KEY`, `VLLM_API_KEY` or `OPENAI_API_KEY` behind the owner's\n * back. Only the variable *name* is ever authored; the secret itself is never\n * written into a settings document by this row.\n *\n * ## The implementation is bound, not left to `auto` (g-067 att-002)\n *\n * The row pins `backend: 'jev'` rather than inheriting the top-level selector.\n * An independent review blocked the first attempt for exactly this: with no\n * `backend` on the row, a fresh deployment (top-level `backend: 'auto'`) had its\n * implementation chosen from the *environment* on every build — `auto` delegates\n * to the vendored factory, which reads `SYSTEM_ONE_BACKEND`/`REFLEX_BACKEND` and\n * `VLLM_BASE_URL`/`OPENAI_BASE_URL`. Exporting two variables therefore took the\n * already-resolved `JEV_API_KEY` and sent it as `Authorization` to a vLLM\n * endpoint nobody configured, while the panel's connection test — which treats\n * `auto` as Jev — still probed the official URL and reported green.\n *\n * So the factory row states all three of the facts a connection has: where\n * (official URL), what model, and **which implementation speaks it**. The\n * implementation is no longer something the environment can change underneath a\n * connection the plugin shipped. This is a row-level binding, which is the\n * documented precedence for every profile — not a top-level override: an\n * authored row, and a deployment's own `backend` selector for authored rows,\n * are untouched.\n *\n * An **explicit** top-level `mock` still answers in-process: a mock never opens\n * a socket, so it cannot send the key anywhere, and `createBackend` honours it\n * before any transport is built (see its mock branch). What the binding removes\n * is the *implicit* `auto` route, which is the one the environment decided.\n */\nexport const FACTORY_SYSTEMONE_PROFILE = Object.freeze({\n baseUrl: DEFAULT_SYSTEMONE_ENDPOINT,\n model: 'jev-latest',\n apiKeyEnv: FACTORY_PROFILE_API_KEY_ENV,\n backend: 'jev'\n}) satisfies Readonly<ReflexSystemOneProfile>;\n\n/**\n * `systemOne` block a settings document starts from.\n *\n * Returned fresh on every call, because schemastery stores the default it is\n * given: a shared object would let one caller's edit leak into the next\n * resolution.\n * @returns a new factory block.\n */\nfunction factorySystemOneBlock() {\n return {\n profiles: { [FACTORY_PROFILE_NAME]: { ...FACTORY_SYSTEMONE_PROFILE } },\n active: FACTORY_PROFILE_NAME\n };\n}\n\n/**\n * Authored connection settings of the System One decision backend.\n *\n * **Only named profiles connect** (g-066). The flat `baseUrl` / `model` /\n * `apiKeyEnv` / `timeoutMs` fields this block used to carry beside\n * `profiles` are gone, together with the \"profile over flat over environment\"\n * merge they made possible: with no valid active profile the plugin is\n * *unconfigured* and sends no external request at all. Silently running some\n * other block — or picking whatever environment variable happened to be\n * exported — is the behaviour the goal removes.\n *\n * The fields are deliberately **not declared on the schema** any more, for two\n * reasons:\n *\n * 1. Schemastery drops what an object does not declare, so a settings document\n * that still carries them (written by an earlier release) keeps them on disk\n * untouched instead of having them rewritten under the page's feet. g-066\n * converts nothing: migration is the owner's decision, not a side effect of\n * opening a panel.\n * 2. A deployment authored in `cordis.patch.yml` with the old flat shape still\n * hands those keys to {@link resolveSystemOneConfig} — read below under\n * `legacy*` — and they can *only* describe a connection that this plugin\n * would previously have used implicitly. Reading them is what turns \"your\n * working deployment now fails closed with no explanation\" into a precise\n * message telling the owner to name a profile.\n *\n * An omitted profile field keeps the environment/default behaviour of the\n * backend implementation.\n */\nexport interface ReflexSystemOneConfig {\n /** Named connection profiles, keyed by the name the panel shows. */\n profiles?: Record<string, ReflexSystemOneProfile>;\n /**\n * Name of the profile in force.\n *\n * A name that matches no authored profile is *not* silently ignored: the\n * resolution reports `activeProfileMissing` and resolves **nothing**, which\n * the panel shows as a warning and the runtime treats as unconfigured.\n * Failing the whole activation was the alternative and was rejected: a single\n * mistyped name would take every reflex tool down, and the tools still have\n * their deterministic local fallbacks.\n */\n active?: string;\n /**\n * Pre-g-066 flat connection fields, read for the *diagnosis* only.\n *\n * Never used to connect: see {@link ReflexSystemOneConfig}. Kept out of the\n * authoring schema; listed here so the resolution can name them.\n */\n baseUrl?: string;\n /** Pre-g-066 flat model id; diagnosis only. */\n model?: string;\n /** Pre-g-066 flat key-variable name; diagnosis only. */\n apiKeyEnv?: string;\n /** Pre-g-066 flat timeout; diagnosis only. */\n timeoutMs?: number;\n}\n\n/**\n * The three-state vocabulary every automatic capability shares.\n *\n * `off` is the capability absent; `observe` runs the complete detection and\n * action *planning* path while changing nothing the model can see; `active`\n * executes the planned intervention. The shared vocabulary is what keeps one\n * switch — not three subtly different \"disabled\" flags — behind every gate.\n */\nexport const INTERVENTION_MODES = ['off', 'observe', 'active'] as const;\n\n/** One resolved three-state mode. */\nexport type InterventionMode = (typeof INTERVENTION_MODES)[number];\n\n/**\n * A capability-level setting: one of the three modes, or `inherit` to follow\n * {@link ReflexInterventionsConfig.mode}. Inheritance is deliberately not\n * available at the top level, where there is nothing to inherit from.\n */\nexport const INTERVENTION_SETTINGS = [...INTERVENTION_MODES, 'inherit'] as const;\n\n/** One authored capability-level setting. */\nexport type InterventionSetting = (typeof INTERVENTION_SETTINGS)[number];\n\n/**\n * The automatic capabilities, each with its own three-state setting.\n *\n * - `stagnation`: the tool-call gate (`tools/pre-execute`) that denies a call\n * the run is repeating after System 1 confirmed stagnation, plus the\n * corrective context appended at `agent/pre-step`.\n * - `prune`: the result projection (`tools/post-execute`) that shrinks an\n * oversized successful payload below its deterministic floors.\n * - `gate`: corrective feedback (`tools/post-execute`) that turns a repeated\n * failing result into an error carrying the System 1 recommendation.\n * - `closing`: the turn-stop check (`agent/turn-stopping`) that objects to a\n * turn closing on self-contradictory verification evidence.\n */\nexport const INTERVENTION_CAPABILITIES = ['stagnation', 'prune', 'gate', 'closing'] as const;\n\n/** One automatic capability name. */\nexport type InterventionCapability = (typeof INTERVENTION_CAPABILITIES)[number];\n\n/**\n * Authored automatic-intervention configuration.\n *\n * Key names are this plugin's contract with the settings surface: the block is\n * edited through the very same schemastery schema the Settings panel writes, so\n * there is no second write channel and no second source of truth.\n */\nexport interface ReflexInterventionsConfig {\n /**\n * Master mode of every automatic capability. `observe` (the default) runs the\n * full detection path and records what it *would* do without touching the\n * tool call, its result, the message list, or the turn boundary.\n */\n mode?: InterventionSetting;\n /** Per-capability override; an omitted capability inherits {@link mode}. */\n capabilities?: Partial<Record<InterventionCapability, InterventionSetting>>;\n /**\n * Ceiling on applied interventions per turn, so an intervention can never\n * become the loop it was meant to break. Default `3`.\n */\n maxInterventionsPerTurn?: number;\n /**\n * Ceiling on *judgments* per turn — the expensive half of a detection. A\n * pathological turn presenting many similar results is bounded by this rather\n * than by the payload count. Default `3`.\n */\n maxJudgmentsPerTurn?: number;\n /** Ceiling on judgments per agent session. Default `20`. */\n maxJudgmentsPerSession?: number;\n /**\n * Identical consecutive tool calls required before the deterministic\n * pre-trigger spends a System 1 judgment. Default `3`.\n */\n repeatThreshold?: number;\n /** Consecutive failing results required before the same. Default `3`. */\n failureThreshold?: number;\n /** Minimum System 1 confidence for a stagnation verdict to act. Default `0.6`. */\n minConfidence?: number;\n /** Steps of one agent's history a deterministic pre-trigger looks at. Default `6`. */\n windowSize?: number;\n /**\n * Lowest share of a payload's characters a prune may keep. The deterministic\n * floor: a candidate that cuts deeper is replaced by the head/tail form.\n * Default `0.5`.\n */\n pruneFloorRatio?: number;\n /** Characters always kept from the head of a pruned payload. Default `400`. */\n pruneHeadChars?: number;\n /** Characters always kept from the tail of a pruned payload. Default `400`. */\n pruneTailChars?: number;\n /**\n * Character count at/above which pruning judges the payload segment by\n * segment through System One. Below it the deterministic local candidates run\n * and no judgment is spent. Effective value is `max(this, pruneThreshold)`,\n * so raising `pruneThreshold` alone never makes a save invalid. Default `10000`.\n */\n pruneJudgeMinChars?: number;\n /**\n * Probability at/above which a sentence System One classified as a completion\n * claim is submitted to verification. A deterministic floor on a semantic\n * decision, never a word list. Default `0.5`.\n */\n claimMinConfidence?: number;\n /**\n * Character budget of the evidence handed to one closing judgment. Overflow\n * is truncated by priority — diagnostic lines, then tail summaries, then the\n * rest — and the dropped amount is reported. Minimum `200`, default `2400`.\n */\n closingEvidenceChars?: number;\n /** Lookup intent handed to the pruning judgment. */\n intent?: string;\n}\n\n/** Automatic-intervention configuration after defaults and resolution. */\nexport interface ResolvedInterventionsConfig {\n /** The master mode, always one of the three (never `inherit`). */\n mode: InterventionMode;\n /** Effective mode of every capability: the override, else the master mode. */\n capabilities: Record<InterventionCapability, InterventionMode>;\n /** Whether any capability is allowed to act. */\n enabled: boolean;\n maxInterventionsPerTurn: number;\n maxJudgmentsPerTurn: number;\n maxJudgmentsPerSession: number;\n repeatThreshold: number;\n failureThreshold: number;\n minConfidence: number;\n windowSize: number;\n pruneFloorRatio: number;\n pruneHeadChars: number;\n pruneTailChars: number;\n /** At/above this character count pruning judges segments through System One. */\n pruneJudgeMinChars: number;\n /** Confidence floor for a classified completion claim. */\n claimMinConfidence: number;\n /** Character budget of the closing evidence. */\n closingEvidenceChars: number;\n intent: string;\n}\n\n/** Authored adaptive reasoning-effort configuration. */\nexport interface ReflexEffortConfig {\n /**\n * Whether adaptive reasoning effort may run at all. Default `true`, which is\n * the pre-existing behaviour: `reflex`/`auto` and the virtual-route default\n * keep deciding per turn. `false` stops every adaptive decision and withdraws\n * the plugin-injected `reflex` level, leaving concrete levels untouched.\n */\n enabled?: boolean;\n /**\n * `'reflex'`/`'auto'` makes every turn decide its own effort through System 1.\n * Omitted = the plugin never touches `reasoningEffort`, exactly as if this\n * feature were not installed. A concrete level is rejected: fixed depth is a\n * model-selector choice, not a deployment setting.\n */\n reasoningEffort?: ReasoningEffortSetting;\n /** Level used when no cue matches and System 1 cannot decide. Default `medium`. */\n fallback?: AdaptiveEffortLevel;\n /** Minimum System 1 confidence for its answer to be trusted. Default `0.3`. */\n minConfidence?: number;\n}\n\n/**\n * Authored per-tool switches, indexed by tool *suffix* rather than tool name.\n *\n * The suffix is what a user writes (`choice`, `route`, …); the registered name\n * is `toolPrefix` + suffix, so a switch keyed by name would break the moment a\n * deployment renames its prefix. An omitted suffix takes\n * {@link REFLEX_TOOL_DEFAULT_ENABLED} — on for every suffix except `route` —\n * and every suffix can be turned either way explicitly.\n */\nexport interface ReflexToolsConfig {\n /**\n * Suffix → enabled. Omitted entries take the documented default (`route` is\n * the one suffix that starts off); unknown keys are rejected.\n */\n enabled?: Partial<Record<ReflexToolSuffix, boolean>>;\n}\n\n/**\n * Authored switch of the *host capability* the delegation tool needs.\n *\n * Deliberately not part of {@link ReflexToolsConfig}: `tools.enabled.<suffix>`\n * decides whether this plugin registers a tool it can serve on its own, while\n * this flag decides whether the Host is asked to publish the model-selection\n * surface `reflex_delegate` needs. Ticking it is a consent to edit the host\n * profile patch (`tool-subagent.config.modelSelection: true`) — a file this\n * plugin otherwise never touches, and whose change only applies after a DSH\n * restart.\n */\nexport interface ReflexDelegationConfig {\n /**\n * Whether the delegation capability is asked for. Default `false`: the tool\n * does not work until the Host's `tool-subagent` publishes `reasoning_effort`,\n * so the switch starts off rather than advertising a tool that cannot carry a\n * level. `true` means \"I want it, and I agree to the host switch it needs\".\n */\n enabled?: boolean;\n}\n\n/** Deployment configuration for the reflex tool bundle. */\nexport interface ReflexConfig {\n /**\n * System One decision backend. `auto` honors `SYSTEM_ONE_BACKEND` and the\n * API-key/base-url environment variables; the explicit values force one\n * implementation for this plugin only, without touching the environment.\n */\n backend?: 'auto' | 'mock' | 'jev' | 'vllm';\n /** Prefix for every registered tool name (`reflex_choice`, …). */\n toolPrefix?: string;\n /**\n * JSONL audit sink for the decision ledger. Omitted (the default) keeps the\n * ledger in process memory so a Host never writes into the user's project\n * unless persistence was asked for explicitly.\n */\n ledgerPath?: string;\n /** Character count above which `prune` activates for one payload. */\n pruneThreshold?: number;\n /** Optional calibration curve JSON; falls back to `SYSTEM_ONE_CALIBRATION_FILE`. */\n calibrationPath?: string;\n /** Connection settings of the System One decision backend. */\n systemOne?: ReflexSystemOneConfig;\n /** Virtual provider + System 1 model routing. */\n routing?: ReflexRoutingConfig;\n /** Per-turn adaptive reasoning effort. */\n effort?: ReflexEffortConfig;\n /** Per-tool switches of the eight reflex tools. */\n tools?: ReflexToolsConfig;\n /** The host capability `reflex_delegate` depends on. */\n delegation?: ReflexDelegationConfig;\n /** Automatic interventions on the Host's tool and agent lifecycle hooks. */\n interventions?: ReflexInterventionsConfig;\n}\n\n/** Routing configuration after defaults and validation have been applied. */\nexport interface ResolvedRoutingConfig {\n enabled: boolean;\n virtualProvider: string;\n fallback?: PhysicalTarget;\n models: ModelPools;\n maxTaskChars: number;\n}\n\n/** System One backend configuration after defaults and validation. */\nexport interface ResolvedSystemOneConfig {\n /** Selected implementation; `auto` keeps the environment heuristics. */\n backend: 'auto' | 'mock' | 'jev' | 'vllm';\n /**\n * Base URL of the connection in force, absent when nothing selected one.\n *\n * Since g-066 this is *the active profile's* address (or, for a profile that\n * states none, nothing at all — the backend then reads the environment). It\n * is never inherited from a block beside the profile, because no such block\n * exists any more.\n */\n baseUrl?: string;\n /** Model id the runtime asks for: the active profile's selected model. */\n model?: string;\n /** Environment variable that holds the API key; never the key itself. */\n apiKeyEnv?: string;\n /** Per-request timeout override in milliseconds. */\n timeoutMs?: number;\n /**\n * The API key of the *resolved* profile, when the chain found one.\n *\n * Never serialized to a panel or route: {@link ResolvedSystemOneConfig} is only\n * handed to {@link createBackend} and to the connection probe.\n */\n apiKey?: string;\n /** Active profile name as authored, when one was. */\n active?: string;\n /**\n * Every profile, normalized, in authored order. Keys are the panel's row ids.\n *\n * Absent when the document authors no `profiles` at all.\n */\n profiles?: Record<string, ResolvedSystemOneProfile>;\n /**\n * The authored `active` name matched no profile.\n *\n * The panel shows this as a warning and the runtime is **unconfigured**: it\n * makes no connection of its own accord. Nothing is resolved from anywhere\n * else, so a typo cannot silently run a connection the user did not select.\n */\n activeProfileMissing?: boolean;\n /**\n * Why nothing can be connected, when nothing can (g-066).\n *\n * - `no-active-profile`: profiles exist but none is activated;\n * - `no-profiles`: the document authors no profile at all;\n * - `active-profile-missing`: `active` names no authored profile;\n * - `legacy-config-required`: the document carries only the pre-g-066 flat\n * fields, which no longer connect anything;\n * - `model-selection-unusable`: the active profile resolved, but the model its\n * configuration puts in force cannot be sent (owner-authored refusal);\n * - `model-selection-invalid`: the active profile's *selected* model is not in\n * its list, so nothing runs (see {@link activeProfileModelMissing}).\n *\n * Absent exactly when an active profile resolved **and** its model is\n * sendable. The panel renders it as the \"unconfigured\" state and the backend\n * refuses to build, so an unusable model never becomes a request to some other\n * model (g-066 att-002).\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 /**\n * The active profile names a `selectedModel` that is not in its `modelIds`.\n *\n * Reported, and the resolved {@link model} is left absent rather than falling\n * back to the first id: a connection whose *selected* model does not exist is\n * a broken selection, not an invitation to run a different model. Since\n * g-066 att-002 it is also *final*: {@link unconfigured} is set with\n * `model-selection-invalid` and {@link createBackend} builds no transport, so\n * the backend's own `|| DEFAULT_MODEL` fallback can never turn \"nothing was\n * selected\" into a request for a model nobody picked.\n */\n activeProfileModelMissing?: boolean;\n}\n\n/** One profile after defaults and validation. */\nexport interface ResolvedSystemOneProfile {\n baseUrl?: string;\n /**\n * Every model id the connection offers, in authored order.\n *\n * Derived from `modelIds`, or from a legacy single `model` as a one-entry\n * list — so every connection has the same shape downstream.\n */\n modelIds?: string[];\n /** The model in force for this connection (see {@link ReflexSystemOneProfile.selectedModel}). */\n selectedModel?: string;\n /** The key this profile carries. Write-only; see {@link ReflexSystemOneProfile}. */\n apiKey?: string;\n apiKeyEnv?: string;\n timeoutMs?: number;\n backend?: 'auto' | 'mock' | 'jev' | 'vllm';\n}\n\n/** Effort configuration after defaults and validation have been applied. */\nexport interface ResolvedEffortConfig {\n /** Whether adaptive effort may decide anything; `true` unless authored otherwise. */\n enabled: boolean;\n /**\n * The adaptive trigger marker; `undefined` (the default) leaves\n * `reasoningEffort` entirely to the caller.\n */\n setting?: ReasoningEffortSetting;\n /** Level used when neither System 1 nor the cue classifier has evidence. */\n fallback: AdaptiveEffortLevel;\n /** Minimum System 1 confidence for its answer to be trusted. */\n minConfidence: number;\n}\n\n/** Per-tool switches after defaults: every suffix of the vocabulary is answered. */\nexport interface ResolvedToolsConfig {\n /** Suffix → whether the tool is registered. Every suffix has an entry. */\n enabled: Record<ReflexToolSuffix, boolean>;\n}\n\n/** Delegation switch after defaults have been applied. */\nexport interface ResolvedDelegationConfig {\n /**\n * Whether the user has consented to the host `modelSelection` switch this\n * activation's `reflex_delegate` needs. Default `false`.\n */\n enabled: boolean;\n}\n\n/** Configuration after defaults and validation have been applied. */\nexport interface ResolvedReflexConfig {\n backend: 'auto' | 'mock' | 'jev' | 'vllm';\n toolPrefix: string;\n ledgerPath?: string;\n pruneThreshold: number;\n calibrationPath?: string;\n systemOne: ResolvedSystemOneConfig;\n routing: ResolvedRoutingConfig;\n effort: ResolvedEffortConfig;\n tools: ResolvedToolsConfig;\n delegation: ResolvedDelegationConfig;\n interventions: ResolvedInterventionsConfig;\n}\n\n/** Schemastery schema for one automatic-intervention block. */\nconst InterventionsSchema = z\n .object({\n mode: z\n .union([...INTERVENTION_MODES])\n .default('observe')\n .description('off = absent, observe = detect and record only (default), active = execute the planned intervention.'),\n capabilities: z\n .object({\n stagnation: z.union([...INTERVENTION_SETTINGS]).description('Tool-call gate and pre-step correction; omit to inherit mode.'),\n prune: z.union([...INTERVENTION_SETTINGS]).description('Oversized result projection; omit to inherit mode.'),\n gate: z.union([...INTERVENTION_SETTINGS]).description('Repeated-failure corrective feedback; omit to inherit mode.'),\n closing: z.union([...INTERVENTION_SETTINGS]).description('Turn-stop objection; omit to inherit mode.')\n })\n .default({}),\n maxInterventionsPerTurn: z.natural().default(3),\n maxJudgmentsPerTurn: z.natural().default(3),\n maxJudgmentsPerSession: z.natural().default(20),\n repeatThreshold: z.natural().min(2).default(3),\n failureThreshold: z.natural().min(2).default(3),\n minConfidence: z.number().min(0).max(1).default(0.6),\n windowSize: z.natural().min(3).default(6),\n pruneFloorRatio: z.number().min(0).max(1).default(0.5),\n pruneHeadChars: z.natural().default(400),\n pruneTailChars: z.natural().default(400),\n pruneJudgeMinChars: z\n .natural()\n .default(10000)\n .description('At or above this many characters, pruning judges the output segment by segment through System One.'),\n claimMinConfidence: z\n .number()\n .min(0)\n .max(1)\n .default(0.5)\n .description('Probability at/above which a sentence classified as a completion claim is submitted to verification.'),\n closingEvidenceChars: z\n .natural()\n .min(200)\n .default(2400)\n .description('Character budget of the evidence handed to one closing judgment; overflow is truncated by priority.'),\n intent: z.string().description('Lookup intent handed to the pruning judgment.')\n })\n .volatile();\n\n/** Schemastery schema for one candidate pool entry. */\nconst ModelPoolEntrySchema = z.object({\n provider: z.string().description('Physical provider route (must not be the virtual provider itself).'),\n model: z.string().description('Physical model id as the provider adapter knows it.'),\n description: z.string().description('Capability note the System 1 decision reasons about.'),\n tags: z.array(z.string()).description('Extra matching keywords for the System 1 decision.')\n});\n\n/** Schemastery schema for the virtual-provider routing block. */\nconst RoutingSchema = z.object({\n enabled: z.boolean().default(true),\n virtualProvider: z.string().default('reflex'),\n fallback: z.string().description('Physical \"provider:model\" used when a pool cannot answer; omit to fail closed.'),\n models: z.dict(z.array(ModelPoolEntrySchema)).default({}),\n maxTaskChars: z.natural().default(400)\n}).volatile();\n\n/** Schemastery schema for the adaptive reasoning-effort block. */\nconst EffortSchema = z.object({\n enabled: z\n .boolean()\n .default(true)\n .description('Whether adaptive reasoning effort may run. Default true; false withdraws the plugin-injected adaptive level.'),\n reasoningEffort: z\n .union([...EFFORT_TRIGGERS])\n .description(\n 'Per-turn adaptive marker (\"reflex\", alias \"auto\"). Omit to leave reasoningEffort to the caller; a concrete level belongs in the model selector.'\n ),\n fallback: z\n .union([...ADAPTIVE_EFFORT_LEVELS])\n .default('medium')\n .description('Level used when System 1 and the cue classifier both have no evidence.'),\n minConfidence: z\n .number()\n .min(0)\n .max(1)\n .default(0.3)\n .description('Minimum System 1 confidence for its answer to be trusted over the cue classifier.')\n}).volatile();\n\n/**\n * Schemastery schema for one System One connection profile.\n *\n * `apiKey` is the one field of this plugin declared `role('secret')`. That role\n * is the whole mechanism behind the panel's write-only input: DSH's structural\n * redaction (`dsh-settings` `redactSecrets`) walks the schema — through\n * `z.dict()` entries, by `node.inner` — drops every secret slot from a value\n * before it crosses a wire boundary, and records `{path, set}` in a sidecar so a\n * configuration surface can render a placeholder without ever holding the value.\n *\n * Deliberately no `default`: a secret slot with a default would materialize a\n * value nobody typed, and `plainSchema` strips `default`/`required` from secret\n * slots anyway.\n */\nconst SystemOneProfileSchema = z.object({\n baseUrl: z.string().description('Jev gateway or OpenAI-compatible logits endpoint.'),\n model: z\n .string()\n .description('Legacy single model id. Same as modelIds: [id]; it is kept as written and is never rewritten into the list form.'),\n modelIds: z\n .array(z.string())\n .description('Every model id this connection may ask for. Omit to keep the legacy single model.'),\n selectedModel: z\n .string()\n .description('The one model in force for this connection: the runtime and the connection test both use it. Omit = the first modelIds entry.'),\n apiKey: z\n .string()\n .role('secret')\n .description(\n 'API key of this profile, write-only: stored on save, never returned by any read. Empty = leave unchanged; clear it with the explicit Clear action.'\n ),\n apiKeyEnv: z.string().description('Name of the environment variable holding this profile’s API key — never the key itself.'),\n timeoutMs: z.natural().description('Per-request timeout in milliseconds.'),\n backend: z\n .union(['auto', 'mock', 'jev', 'vllm'])\n .description('Backend implementation serving this connection; omit to use the top-level backend.')\n});\n\n/** Schemastery schema for the System One backend connection block. */\nconst SystemOneSchema = z.object({\n /**\n * Only profiles connect (g-066). The pre-g-066 flat `baseUrl` / `model` /\n * `apiKeyEnv` / `timeoutMs` keys are deliberately **not** declared: schemastery\n * drops undeclared keys, and an object write re-states only what it declares,\n * so a document still carrying them keeps them byte for byte instead of having\n * them converted (or deleted) as a side effect of a panel save.\n */\n profiles: z\n .dict(SystemOneProfileSchema)\n .default({})\n .description('Named connection profiles; each may carry its own write-only apiKey and its own model list.'),\n active: z.string().description('Name of the profile in force; a name no profile declares is reported, and nothing connects.')\n}).volatile();\n\n/**\n * Schemastery schema for the per-tool switch block.\n *\n * Deliberately an open dictionary rather than an object with eight declared\n * keys: schemastery drops what an object does not declare, and a dropped typo\n * would read as \"the tool stayed on\" instead of failing. {@link resolveToolsConfig}\n * therefore owns the rejection of unknown suffixes.\n */\nconst ToolsSchema = z\n .object({\n enabled: z\n .dict(z.boolean())\n .default({})\n .description(\n `Suffix → enabled (${REFLEX_TOOL_SUFFIXES.join(', ')}). Omitted suffixes keep their documented default (${REFLEX_TOOL_SUFFIXES.filter((suffix) => !REFLEX_TOOL_DEFAULT_ENABLED[suffix]).join(', ') || 'none'} off, the rest on).`\n )\n })\n .volatile();\n\n/**\n * Schemastery schema for the delegation block.\n *\n * One boolean, defaulting to `false`. It is authored, never written by the\n * plugin: the panel's toggle writes this field, the runtime detector refuses to\n * write it, and the only other file this plugin edits is the host patch the\n * consent box names explicitly.\n */\nconst DelegationSchema = z\n .object({\n enabled: z\n .boolean()\n .default(false)\n .description(\n 'Consent to the host capability reflex_delegate needs: on = the host tool-subagent publishes reasoning_effort (modelSelection: true), which is written into the profile patch and applies after a DSH restart. Default false.'\n )\n })\n .volatile();\n\n/**\n * Schemastery schema the Cordis loader validates the deployment config with.\n *\n * The explicit `Schemastery<ReflexConfig>` annotation is deliberate: the\n * inferred type of a schema containing `z.dict(z.array(...))` names a\n * `cosmokit` helper that is not portably resolvable from this package's\n * emitted declarations, so the public shape is stated instead of inferred.\n */\n/**\n * Schemastery schema of the plugin's configuration.\n */\nexport const Config: Schemastery<any> = z.object({\n backend: z.union(['auto', 'mock', 'jev', 'vllm']).default('auto').volatile(),\n toolPrefix: z.string().default('reflex_').volatile(),\n ledgerPath: z.string().description('JSONL audit sink; omit to keep the ledger in memory.').volatile(),\n pruneThreshold: z.natural().default(500).volatile(),\n calibrationPath: z.string().description('Calibration curve JSON applied to choice confidences.').volatile(),\n // The factory connection lives here, on the real schema default, rather than in\n // `resolveSystemOneConfig` (g-067). Schemastery applies a default to a\n // top-level key the document omits, and a fresh profile omits it: its patch\n // file starts as `[]`, so the loader entry's config is `{}` and this key never\n // appears. That is the only shape that gets the factory row from here: a\n // document that *states* a `systemOne` block keeps it, which is what makes\n // deactivation and deletion stick.\n //\n // It also puts the row where the Host settings form can see it: the form\n // projects the *resolved* config, so a default the schema never produces would\n // be a connection the panel shows and the settings page does not.\n systemOne: SystemOneSchema.default(factorySystemOneBlock()),\n routing: RoutingSchema.default({}),\n effort: EffortSchema.default({}),\n tools: ToolsSchema.default({}),\n delegation: DelegationSchema.default({}),\n interventions: InterventionsSchema.default({})\n});\n\n/**\n * Validate one authored three-state setting.\n *\n * The loader restricts the value to the schema's union; this repeats the check\n * because {@link resolveConfig} is also the entry point for a programmatic\n * caller, and a typo there must fail loudly instead of silently disabling (or\n * silently enabling) an intervention.\n *\n * @param value - authored setting.\n * @param allowInherit - whether `inherit` is a legal value at this position.\n * @param label - dotted path used in the error.\n * @returns the normalized setting, or `undefined` when nothing was authored.\n * @throws Error when the value is not a legal setting.\n */\nexport function resolveInterventionSetting(\n value: string | undefined,\n allowInherit: boolean,\n label: string\n): InterventionSetting | undefined {\n if (value === undefined) return undefined;\n const setting = typeof value === 'string' ? value.trim().toLowerCase() : '';\n if ((INTERVENTION_SETTINGS as readonly string[]).includes(setting)) {\n if (setting === 'inherit' && !allowInherit) {\n throw new Error(`${label} must be one of ${INTERVENTION_MODES.join(', ')} (got \"inherit\": there is nothing to inherit from)`);\n }\n return setting as InterventionSetting;\n }\n const legal = allowInherit ? INTERVENTION_SETTINGS : INTERVENTION_MODES;\n throw new Error(`${label} must be one of ${legal.join(', ')} (got \"${String(value)}\")`);\n}\n\n/**\n * Validate the automatic-intervention block and fill in every default.\n *\n * Capability entries resolve to an effective three-state mode here, once, so\n * every consumer — listeners, the panel projection, the audit — reads the same\n * answer instead of re-deriving inheritance.\n *\n * @param authored - the authored `interventions` block.\n * @param pruneThreshold - the runtime prune threshold, the lower bound of the\n * segment-judging threshold.\n * @returns the resolved master mode, effective capability modes, and limits.\n * @throws Error when a field is present but unusable.\n */\nexport function resolveInterventionsConfig(\n authored: ReflexInterventionsConfig | undefined,\n pruneThreshold = 500\n): ResolvedInterventionsConfig {\n const block = authored ?? {};\n const mode = (resolveInterventionSetting(block.mode, false, 'interventions.mode') ?? 'observe') as InterventionMode;\n\n const capabilities = {} as Record<InterventionCapability, InterventionMode>;\n for (const capability of INTERVENTION_CAPABILITIES) {\n const setting = resolveInterventionSetting(\n block.capabilities?.[capability],\n true,\n `interventions.capabilities.${capability}`\n );\n capabilities[capability] = setting === undefined || setting === 'inherit' ? mode : setting;\n }\n\n const counts: Array<[number | undefined, string, number, number]> = [\n [block.maxInterventionsPerTurn, 'maxInterventionsPerTurn', 3, 0],\n [block.maxJudgmentsPerTurn, 'maxJudgmentsPerTurn', 3, 0],\n [block.maxJudgmentsPerSession, 'maxJudgmentsPerSession', 20, 0],\n [block.repeatThreshold, 'repeatThreshold', 3, 2],\n [block.failureThreshold, 'failureThreshold', 3, 2],\n [block.windowSize, 'windowSize', 6, 3],\n [block.pruneHeadChars, 'pruneHeadChars', 400, 0],\n [block.pruneTailChars, 'pruneTailChars', 400, 0],\n [block.pruneJudgeMinChars, 'pruneJudgeMinChars', 10000, 0],\n [block.closingEvidenceChars, 'closingEvidenceChars', 2400, 200]\n ];\n const resolved: Record<string, number> = {};\n for (const [value, name, fallback, minimum] of counts) {\n if (value === undefined) {\n resolved[name] = fallback;\n continue;\n }\n if (!Number.isInteger(value) || value < minimum) {\n throw new Error(`interventions.${name} must be an integer >= ${minimum} (got \"${String(value)}\")`);\n }\n resolved[name] = value;\n }\n\n const minConfidence = block.minConfidence ?? 0.6;\n if (!Number.isFinite(minConfidence) || minConfidence < 0 || minConfidence > 1) {\n throw new Error(`interventions.minConfidence must be a number in [0, 1] (got \"${String(block.minConfidence)}\")`);\n }\n const pruneFloorRatio = block.pruneFloorRatio ?? 0.5;\n if (!Number.isFinite(pruneFloorRatio) || pruneFloorRatio < 0 || pruneFloorRatio > 1) {\n throw new Error(`interventions.pruneFloorRatio must be a number in [0, 1] (got \"${String(block.pruneFloorRatio)}\")`);\n }\n const claimMinConfidence = block.claimMinConfidence ?? 0.5;\n if (!Number.isFinite(claimMinConfidence) || claimMinConfidence < 0 || claimMinConfidence > 1) {\n throw new Error(\n `interventions.claimMinConfidence must be a number in [0, 1] (got \"${String(block.claimMinConfidence)}\")`\n );\n }\n // The segment-judging floor is layered on the prune threshold: judging below\n // the size at which pruning even runs is meaningless. Rather than refusing a\n // save that raises `pruneThreshold` alone (the panel exposes it independently,\n // and the user should not have to raise a second field to keep their edit),\n // the effective floor is lifted to the prune threshold. The panel reports the\n // lifted value, which is the one the runtime actually uses.\n const pruneJudgeMinChars = Math.max(resolved.pruneJudgeMinChars!, pruneThreshold);\n\n return {\n mode,\n capabilities,\n // One capability may be enabled by its own override while the master mode is\n // `off`, so the switch that decides whether anything is installed reads the\n // effective modes rather than the master alone.\n enabled: INTERVENTION_CAPABILITIES.some((capability) => capabilities[capability] !== 'off'),\n maxInterventionsPerTurn: resolved.maxInterventionsPerTurn!,\n maxJudgmentsPerTurn: resolved.maxJudgmentsPerTurn!,\n maxJudgmentsPerSession: resolved.maxJudgmentsPerSession!,\n repeatThreshold: resolved.repeatThreshold!,\n failureThreshold: resolved.failureThreshold!,\n minConfidence,\n windowSize: resolved.windowSize!,\n pruneFloorRatio,\n pruneHeadChars: resolved.pruneHeadChars!,\n pruneTailChars: resolved.pruneTailChars!,\n pruneJudgeMinChars,\n claimMinConfidence,\n closingEvidenceChars: resolved.closingEvidenceChars!,\n intent: optionalText(block.intent) ?? 'extract diagnostics, relevant results and errors'\n };\n}\n\n/**\n * Normalize one profile's model list and its single selected entry.\n *\n * Two authored shapes are accepted, and they mean the same thing:\n *\n * - `modelIds: [a, b, c]` + `selectedModel: b` — the g-066 shape, any number of\n * ids with one in force;\n * - `model: a` — the pre-g-066 shape, which is exactly `modelIds: [a]` selected.\n * Accepted so an existing connection keeps working untouched; **no migration\n * is written back**, so opening the panel changes nothing on disk.\n *\n * Both at once is refused rather than merged: they are two different statements\n * about which models exist, and picking one would silently drop the other.\n * A `selectedModel` outside the list is *not* an error here — resolution reports\n * it (`activeProfileModelMissing`) so the panel can point at the field.\n *\n * @param name - profile name, for the message.\n * @param entry - the authored profile.\n * @returns the normalized list and the selected id (when the profile names one).\n * @throws Error when `modelIds` is not a list of non-empty strings, or when both\n * shapes are authored.\n */\nfunction resolveProfileModels(\n name: string,\n entry: ReflexSystemOneProfile\n): { modelIds: string[]; selectedModel?: string } {\n const legacy = optionalText(entry.model);\n const authored = entry.modelIds;\n const selectedModel = optionalText(entry.selectedModel);\n // An **empty** list is not an authoring: schemastery materializes `modelIds: []`\n // for every profile that declares the field's schema but no value, so a legacy\n // `model: x` arrives beside an empty list rather than alone. Treating that as\n // \"both shapes authored\" would reject every pre-g-066 connection the moment it\n // passes through the schema — the exact compatibility this rule protects.\n if (Array.isArray(authored) && authored.length === 0 && legacy !== undefined) {\n return checkedSelection(name, [legacy], selectedModel);\n }\n if (authored !== undefined && authored !== null) {\n if (!Array.isArray(authored)) {\n throw new Error(`systemOne.profiles[\"${name}\"].modelIds must be a list of model ids`);\n }\n if (legacy !== undefined) {\n throw new Error(\n `systemOne.profiles[\"${name}\"] authors both model and modelIds; keep modelIds and selectedModel, or keep the single model`\n );\n }\n const modelIds: string[] = [];\n for (const [index, raw] of authored.entries()) {\n const id = optionalText(typeof raw === 'string' ? raw : undefined);\n if (id === undefined) {\n throw new Error(`systemOne.profiles[\"${name}\"].modelIds[${String(index)}] must be a non-empty model id`);\n }\n // Duplicates are collapsed: the list is a set of choices, and two rows for\n // one id would let the page show a selection that is not a selection.\n if (!modelIds.includes(id)) modelIds.push(id);\n }\n return checkedSelection(name, modelIds, selectedModel);\n }\n return checkedSelection(name, legacy === undefined ? [] : [legacy], selectedModel);\n}\n\n/**\n * Refuse the one authored selection that can never run.\n *\n * A `selectedModel` **outside** `modelIds` is not a preference to be re-resolved\n * later: it names a model this connection does not offer, and every consumer —\n * runtime, connection test, panel — would have to invent an answer. g-066\n * att-002 closes it here, at the write, so it cannot be saved in the first\n * place. A selection beside an **empty** list is the same mistake with nothing\n * to select: it is refused rather than silently kept as \"select nothing\".\n *\n * (The resolution still reports such a document — {@link\n * ResolvedSystemOneConfig.activeProfileModelMissing} — because a file edited by\n * hand reaches it without passing through here, and the runtime then refuses to\n * connect instead of running another model.)\n *\n * @param name - profile name, for the message.\n * @param modelIds - the normalized list.\n * @param selectedModel - the authored selection, when one was.\n * @returns the normalized list and selection.\n * @throws Error when the selection names nothing in the list.\n */\nfunction checkedSelection(\n name: string,\n modelIds: string[],\n selectedModel: string | undefined\n): { modelIds: string[]; selectedModel?: string } {\n if (selectedModel !== undefined && !modelIds.includes(selectedModel)) {\n throw new Error(\n `systemOne.profiles[\"${name}\"].selectedModel \"${selectedModel}\" is not one of its modelIds (${\n modelIds.length === 0 ? 'the list is empty' : modelIds.join(', ')\n }); select a listed model instead`\n );\n }\n return { modelIds, ...(selectedModel === undefined ? {} : { selectedModel }) };\n}\n\n/**\n * Trim one optional authored string, treating blank text as absent.\n * @param value - authored value.\n * @returns the trimmed text, or `undefined` when nothing usable was authored.\n */\nfunction optionalText(value: string | undefined): string | undefined {\n if (typeof value !== 'string') return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Validate the System One connection block and fill in every default.\n *\n * ## The resolution rule (g-066: one connection, the active profile)\n *\n * **Only the active profile connects.** Every connection field — `baseUrl`,\n * `model`, `apiKey`, `apiKeyEnv`, `timeoutMs`, `backend` — comes from the\n * profile `active` names, or stays `undefined` and is then decided by the\n * backend's own environment read and documented default.\n *\n * There is no block of last resort. A document with no valid active profile\n * resolves to {@link ResolvedSystemOneConfig.unconfigured} with **no** connection\n * fields at all, so nothing downstream can invent one:\n *\n * | document | `unconfigured` |\n * | ----------------------------------------- | ------------------------- |\n * | no profiles at all | `no-profiles` |\n * | profiles, none activated | `no-active-profile` |\n * | `active` naming a profile that is not there | `active-profile-missing` |\n * | only the pre-g-066 flat fields | `legacy-config-required` |\n *\n * The pre-g-066 merge (\"active profile over flat block over environment\") was\n * removed because the *fallback* was the bug: a mistyped or missing activation\n * ran a connection the user never selected. The legacy fields are still *read*,\n * but only to name the problem in `legacy-config-required` — converting them into\n * a profile would be a silent configuration change (and, for `apiKeyEnv`, a\n * silent choice between a literal key and a variable), so this function never\n * does it.\n *\n * `apiKey` and `apiKeyEnv` stay independent, so a profile may carry a literal key\n * while naming no variable, or name a variable and carry no key;\n * {@link resolveApiKeyWithSource} decides which the transport presents.\n *\n * @param backend - the top-level backend selector (the fallback implementation\n * choice for a profile that states none).\n * @param authored - the authored `systemOne` block.\n * @returns the resolved connection settings.\n * @throws Error when a field is present but unusable.\n */\nexport function resolveSystemOneConfig(\n backend: 'auto' | 'mock' | 'jev' | 'vllm' | undefined,\n authored: ReflexSystemOneConfig | undefined\n): ResolvedSystemOneConfig {\n const selected = backend ?? 'auto';\n if (!(['auto', 'mock', 'jev', 'vllm'] as const).includes(selected)) {\n throw new Error(`backend must be one of auto, mock, jev, vllm (got \"${String(backend)}\")`);\n }\n const profiles = resolveSystemOneProfiles(authored?.profiles);\n const hasProfiles = Object.keys(profiles).length > 0;\n const active = optionalText(authored?.active);\n const activeProfile = active === undefined ? undefined : profiles[active];\n const activeProfileMissing = active !== undefined && activeProfile === undefined;\n\n // The shared half of the resolved shape: what the document authors, and\n // nothing that could be mistaken for a connection.\n const authoredShape: ResolvedSystemOneConfig = {\n backend: selected,\n ...(hasProfiles ? { profiles } : {}),\n ...(active === undefined ? {} : { active }),\n ...(activeProfileMissing ? { activeProfileMissing: true } : {})\n };\n\n if (activeProfile === undefined) {\n // Nothing was activated. Which of the four absence reasons applies decides\n // the copy the panel shows and the message the runtime logs, so the facts are\n // kept apart rather than collapsed into \"not configured\".\n const legacy = legacyConnectionAuthored(authored);\n const unconfigured = activeProfileMissing\n ? ('active-profile-missing' as const)\n : hasProfiles\n ? ('no-active-profile' as const)\n : legacy\n ? ('legacy-config-required' as const)\n : ('no-profiles' as const);\n return { ...authoredShape, unconfigured };\n }\n\n // The profile's *selected* model: the one the runtime sends and the probe\n // tests. A selection outside the list is reported — never resolved to \"the\n // first one\", which would run a model nobody picked.\n const modelIds = activeProfile.modelIds ?? [];\n const selectedModel = modelForProfile(activeProfile, modelIds);\n const modelSelectionBroken = selectedModel?.missing === true;\n // The implementation this connection really runs (g-067 att-002), resolved by\n // the precedence {@link connectionTarget} applies, so the runtime and the\n // connection test cannot describe two different transports.\n const implementationSelector = effectiveImplementation(selected, activeProfile.backend, activeProfile);\n // The timeout is already validated per profile (`resolveProfileEntry` runs on\n // every entry, the active one included), so this is a read, not a re-check: a\n // second copy of the predicate here would be a check nothing can reach, and\n // the mutation control proved it — disabling *this* line left every test green.\n const timeoutMs = activeProfile.timeoutMs;\n // Which model the transport would *really* send (g-066 att-002), decided by\n // the one function the connection test reads as well.\n const planned = plannedModel(modelIds, implementationSelector, selectedModel);\n const connection = {\n ...authoredShape,\n // The selector this connection really runs under, *after* the spread so the\n // authored top-level value cannot re-assert itself over the row's choice.\n backend: implementationSelector,\n ...(activeProfile.baseUrl === undefined ? {} : { baseUrl: activeProfile.baseUrl }),\n ...(modelSelectionBroken || selectedModel?.model === undefined ? {} : { model: selectedModel.model }),\n ...(activeProfile.apiKeyEnv === undefined ? {} : { apiKeyEnv: activeProfile.apiKeyEnv }),\n ...(activeProfile.apiKey === undefined ? {} : { apiKey: activeProfile.apiKey }),\n ...(timeoutMs === undefined ? {} : { timeoutMs }),\n ...(modelSelectionBroken ? { activeProfileModelMissing: true } : {})\n };\n // A model the configuration puts in force but the runtime cannot honour is a\n // refusal, not a connection: `unconfigured` means \"build no transport\", which\n // is the only way the backend's default can never stand in for it.\n if (planned.unusable !== undefined) return { ...connection, unconfigured: planned.unusable };\n // Spread conditionally: `model: undefined` would still be a *present* key, and\n // \"absent\" is what the panel and the probe read as \"names no model\".\n return planned.model === undefined ? connection : { ...connection, model: planned.model };\n}\n\n/**\n * The model a connection would actually send, or why it can send none.\n *\n * The single implementation of the rule the runtime and the connection test both\n * obey (g-066 att-002). It exists because `model === undefined` did *not* mean\n * \"no model\": every remote backend fills an absent `model` with `|| DEFAULT`, and\n * `auto` may additionally take a `SYSTEM_ONE_MODEL` from the environment. Left\n * to the backend, a broken selection became a live request for a model nobody\n * chose, while the probe — which has no such default — sent nothing. Both ends\n * now ask this one function, in the same process, so they cannot disagree.\n *\n * - the profile lists ids and selects one: that id;\n * - its selection is outside the list: **unusable** (`model-selection-invalid`),\n * never the first id and never an implementation default;\n * - it lists no id: the default of the implementation that would be built, read\n * from the same environment the backend reads — unless that implementation is\n * not determinable, in which case it is **unusable**\n * (`model-selection-unusable`) rather than a guess between two defaults;\n * - `mock` connects nowhere and names no model.\n *\n * @param modelIds - the profile's model list.\n * @param backend - the effective implementation selector.\n * @param selected - what {@link modelForProfile} answered for the profile.\n * @param env - the environment the backend would read.\n * @returns the model to send, or the refusal tag.\n */\nfunction plannedModel(\n modelIds: readonly string[],\n backend: 'auto' | 'mock' | 'jev' | 'vllm',\n selected: { model?: string; missing?: boolean },\n env: Record<string, string | undefined> = process.env\n): { model?: string; unusable?: 'model-selection-invalid' | 'model-selection-unusable' } {\n if (selected.missing === true) return { unusable: 'model-selection-invalid' };\n if (selected.model !== undefined) return { model: selected.model };\n const fallback = defaultModelAnswer(backend, env);\n if (fallback.unusable === true) return { unusable: 'model-selection-unusable' };\n return fallback.model === undefined ? {} : { model: fallback.model };\n}\n\n/**\n * The model a backend would fall back to, for a connection that names none.\n *\n * Only the *defaults* of the two remote implementations are modelled, under the\n * same environment precedence as the backend classes (explicit option, then\n * `SYSTEM_ONE_MODEL`, then the per-implementation variable, then the constant).\n * The in-process mock is not configured by any of this and has never touched an\n * endpoint, so it names no model.\n *\n * `unusable` is the \"there is a model, but no backend here could send it\"\n * answer: an `auto` provider chosen from the environment by a URL rather than an\n * explicit provider.\n *\n * @param backend - the effective implementation selector.\n * @param env - the environment the backend would read; the process environment by\n * default, so the runtime and the probe (in that same process) agree.\n * @returns the model that would be sent, and whether it is unusable.\n */\nfunction defaultModelAnswer(\n backend: 'auto' | 'mock' | 'jev' | 'vllm',\n env: Record<string, string | undefined> = process.env\n): { model?: string; unusable?: true } {\n const named = optionalText(env.SYSTEM_ONE_MODEL);\n if (backend === 'mock') return {};\n if (backend === 'jev') return { model: named ?? optionalText(env.JEV_MODEL) ?? 'jev-latest' };\n if (backend === 'vllm') {\n return { model: named ?? optionalText(env.VLLM_MODEL) ?? 'Qwen/Qwen2.5-7B-Instruct' };\n }\n // `auto`: the vendored factory picks the implementation from the environment.\n // It is modelled exactly as far as it is deterministic — an explicit provider\n // variable selects one — and anything else is refused rather than guessed.\n const provider = (env.SYSTEM_ONE_BACKEND ?? env.REFLEX_BACKEND ?? '').trim().toLowerCase();\n if (provider === 'jev') return { model: named ?? optionalText(env.JEV_MODEL) ?? 'jev-latest' };\n if (provider === 'vllm' || provider === 'simple-jev' || provider === 'logits') {\n return { model: named ?? optionalText(env.VLLM_MODEL) ?? 'Qwen/Qwen2.5-7B-Instruct' };\n }\n if (provider.length === 0) {\n if (!named && (env.SYSTEM_ONE_API_KEY || env.JEV_API_KEY)) {\n return { model: optionalText(env.JEV_MODEL) ?? 'jev-latest' };\n }\n if (!named && (env.VLLM_BASE_URL || env.OPENAI_BASE_URL)) {\n return { model: optionalText(env.VLLM_MODEL) ?? 'Qwen/Qwen2.5-7B-Instruct' };\n }\n // Neither credential nor endpoint: the factory would build the in-process\n // mock. That is still *not* \"no model\" — the runtime would answer from\n // heuristics while the panel showed a configured connection — so it is\n // refused like any other undeterminable implementation. A deployment that\n // wants the in-process answer asks for it (`backend: mock`).\n }\n // A model was named but no implementation can be determined to send it.\n return { unusable: true };\n}\n\n/**\n * The model one profile puts in force, and whether the selection is broken.\n *\n * A legacy single `model` is a one-entry list, so the two authored shapes answer\n * the same way: `selectedModel` if it names an entry, else the first entry, else\n * absent (a connection may name no model at all and let the backend default it).\n * @param profile - the normalized profile.\n * @param modelIds - its model list.\n * @returns the resolved choice; `missing` marks a selected id outside the list.\n */\nfunction modelForProfile(\n profile: ResolvedSystemOneProfile,\n modelIds: readonly string[]\n): { model?: string; missing?: boolean } {\n const chosen = profile.selectedModel;\n if (chosen === undefined) return modelIds.length === 0 ? {} : { model: modelIds[0] };\n // The list is what decides: an id outside it cannot be run, even when it is the\n // only text the document carries.\n return modelIds.includes(chosen) ? { model: chosen } : { missing: true };\n}\n\n/**\n * Whether the document carries the pre-g-066 flat connection fields.\n *\n * Read purely to *name* the problem: a deployment authored that way used to\n * connect implicitly, and \"no profile configured\" would be a confusing answer\n * for a document that plainly holds an address. Never a connection itself.\n * @param authored - the authored `systemOne` block.\n * @returns true when any legacy connection field is non-blank.\n */\nfunction legacyConnectionAuthored(authored: ReflexSystemOneConfig | undefined): boolean {\n return [authored?.baseUrl, authored?.model, authored?.apiKeyEnv].some((value) => optionalText(value) !== undefined);\n}\n\n/**\n * Normalize every authored profile, rejecting names the panel cannot address.\n *\n * A name becomes both a `z.dict` key and a segment of a settings `set` path, so\n * the rules are the ones those two consumers impose: non-blank, no `.` (the path\n * separator) and unique after case folding (the panel shows names as identifiers\n * and two rows differing only in case would be indistinguishable).\n *\n * @param authored - the authored `profiles` dictionary.\n * @returns the normalized profiles, in authored order.\n * @throws Error when a name or a field is unusable.\n */\nfunction resolveSystemOneProfiles(\n authored: Record<string, ReflexSystemOneProfile> | undefined\n): Record<string, ResolvedSystemOneProfile> {\n if (authored === undefined) return {};\n if (authored === null || typeof authored !== 'object' || Array.isArray(authored)) {\n throw new Error('systemOne.profiles must be a dictionary of profile name → connection settings');\n }\n const profiles: Record<string, ResolvedSystemOneProfile> = {};\n const seen = new Map<string, string>();\n for (const [rawName, entry] of Object.entries(authored)) {\n const name = optionalText(rawName);\n if (name === undefined) throw new Error('systemOne.profiles keys must be non-empty profile names');\n if (name.includes('.')) {\n throw new Error(`systemOne.profiles name must not contain \".\" (got \"${name}\"): it is the settings path separator`);\n }\n const folded = name.toLowerCase();\n const clash = seen.get(folded);\n if (clash !== undefined) {\n throw new Error(`systemOne.profiles has two names differing only in case (\"${clash}\" and \"${name}\")`);\n }\n seen.set(folded, name);\n if (entry === null || typeof entry !== 'object' || Array.isArray(entry)) {\n throw new Error(`systemOne.profiles[\"${name}\"] must be an object of connection settings`);\n }\n const profileBackend = optionalText(entry.backend);\n if (profileBackend !== undefined && !(['auto', 'mock', 'jev', 'vllm'] as const).includes(profileBackend as never)) {\n throw new Error(`systemOne.profiles[\"${name}\"].backend must be one of auto, mock, jev, vllm (got \"${profileBackend}\")`);\n }\n const timeoutMs = entry.timeoutMs;\n // The one place a timeout is validated: every profile goes through here, so\n // the active profile is covered without a second check of its own.\n if (timeoutMs !== undefined && (!Number.isInteger(timeoutMs) || timeoutMs <= 0)) {\n throw new Error(`systemOne.profiles[\"${name}\"].timeoutMs must be a positive integer (got \"${String(timeoutMs)}\")`);\n }\n const baseUrl = optionalText(entry.baseUrl);\n const { modelIds, selectedModel } = resolveProfileModels(name, entry);\n const apiKey = optionalText(entry.apiKey);\n const apiKeyEnv = optionalText(entry.apiKeyEnv);\n profiles[name] = {\n ...(baseUrl === undefined ? {} : { baseUrl }),\n ...(modelIds.length === 0 ? {} : { modelIds }),\n ...(selectedModel === undefined ? {} : { selectedModel }),\n ...(apiKey === undefined ? {} : { apiKey }),\n ...(apiKeyEnv === undefined ? {} : { apiKeyEnv }),\n ...(timeoutMs === undefined ? {} : { timeoutMs }),\n ...(profileBackend === undefined ? {} : { backend: profileBackend as 'auto' | 'mock' | 'jev' | 'vllm' })\n };\n }\n return profiles;\n}\n\n/**\n * The environment variables the key chain falls back to, in order.\n *\n * This list is the *whole* fallback, exported so callers that want to name the\n * candidates (the panel's \"nothing configured\" copy) read it from here instead of\n * restating it. Changing the order here changes it for the backend, the panel,\n * and the connection probe at once — which is the point.\n */\nexport const API_KEY_ENV_FALLBACKS = ['SYSTEM_ONE_API_KEY', 'JEV_API_KEY', 'VLLM_API_KEY', 'OPENAI_API_KEY'] as const;\n\n/**\n * The outcome of resolving one connection's key.\n *\n * A discriminated union rather than `{ key } | undefined` (g-059): \"the block\n * named a variable and that variable is empty\" is a *different fact* from \"the\n * block named nothing and nothing was exported\", and the panel has to say which.\n * Collapsing both into `undefined` is exactly what let the two be conflated.\n *\n * - `{ key }` — a key was found; {@link source} says where.\n * - `{ missing: 'named', variable }` — the block **named** `variable` and it holds\n * nothing. Naming is a lock: no fallback variable was consulted, and none may be.\n * - `undefined` — the block named nothing and no fallback variable holds a key.\n */\nexport type ApiKeyResolution = ResolvedApiKey | ApiKeyNotFound;\n\n/** Where a resolved key came from. */\nexport interface ResolvedApiKey {\n /** The key itself. Stays in the host process; no projection serializes it. */\n key: string;\n /**\n * `profile` for a literal key from the settings document; `env` for the\n * variable the block named; `fallback` for a {@link API_KEY_ENV_FALLBACKS}\n * variable reached because the block named none. `fallback` is a separate tag\n * so the panel can print \"(回退)\" — a deployment that *meant* to name a\n * variable can then see that it in fact named nothing.\n */\n source: 'profile' | 'env' | 'fallback';\n /** The variable that supplied the key when {@link source} is `env` or `fallback`. */\n variable?: string;\n}\n\n/** The variable the block named holds nothing, and the lookup stopped there. */\nexport interface ApiKeyNotFound {\n /** Why nothing resolved. */\n missing: 'named';\n /** The variable the block named — the empty one, never a fallback. */\n variable: string;\n}\n\n/**\n * Resolve the API key for a connection, and say where it came from.\n *\n * This is the **single source of truth** for the key chain. The backend\n * constructors, the panel's readiness projection, and the `/systemone/test`\n * probe all call it, so the panel can never again report a different reality\n * from the one the runtime acts on.\n *\n * The chain, in order:\n *\n * 1. **`config.apiKey`** — a literal key from the settings document, where it is\n * a declared `role('secret')` slot. It outranks every variable and makes\n * `apiKeyEnv` irrelevant: a deployment that stores the secret outright has no\n * use for a variable *name*.\n * 2. **`config.apiKeyEnv`** — the variable the connection *names*. **Naming\n * locks**: this is the only variable consulted, and if it is empty the result\n * is {@link ApiKeyNotFound} — never a fallback to step 3. The settings\n * document carries only the name, so a panel write cannot leak the value.\n * 3. **{@link API_KEY_ENV_FALLBACKS}** — only when step 2 named nothing:\n * `SYSTEM_ONE_API_KEY`, `JEV_API_KEY`, `VLLM_API_KEY`, `OPENAI_API_KEY`,\n * first non-empty wins.\n *\n * Step 2 no longer falls through to step 3 (g-059). The earlier choice — \"naming\n * a variable is not a request to lock onto it\" — was reversed by the owner: a\n * deployment that names `SYSTEM_ONE_API_KEY` while only `JEV_API_KEY` is\n * exported must read as *missing*, not silently work from a variable nobody\n * named. Locking is now implied by naming, so an empty value cannot be mistaken\n * for \"nobody named anything\".\n *\n * An empty string counts as absent at every step, so an exported-but-empty\n * variable is never a credential.\n *\n * A **blank** `apiKeyEnv` (spaces only) is not a naming:\n * {@link resolveSystemOneConfig} trims it away before this function sees it, so\n * a stray space in the name field keeps the historical fallback instead of\n * locking onto a variable whose name is a space.\n *\n * @param config - resolved System One connection settings (a profile's, or the flat block's).\n * @param env - environment to read; defaults to `process.env`.\n * @returns the key and its provenance; the locked-but-empty fact; or `undefined`\n * when nothing was named and nothing was exported.\n */\nexport function resolveApiKeyWithSource(\n config: Pick<ResolvedSystemOneConfig, 'apiKeyEnv' | 'apiKey'>,\n env: Record<string, string | undefined> = process.env\n): ApiKeyResolution | undefined {\n if (typeof config.apiKey === 'string' && config.apiKey.length > 0) return { key: config.apiKey, source: 'profile' };\n if (typeof config.apiKeyEnv === 'string' && config.apiKeyEnv.length > 0) {\n const named = env[config.apiKeyEnv];\n if (typeof named === 'string' && named.length > 0) return { key: named, source: 'env', variable: config.apiKeyEnv };\n // Naming locks (g-059): a named-but-empty variable ends the lookup here. It\n // must not reach the fallback loop, or the panel would report a lock the\n // runtime never honoured.\n return { missing: 'named', variable: config.apiKeyEnv };\n }\n for (const variable of API_KEY_ENV_FALLBACKS) {\n const value = env[variable];\n if (typeof value === 'string' && value.length > 0) return { key: value, source: 'fallback', variable };\n }\n return undefined;\n}\n\n/**\n * The key a resolution carries, or `undefined` for both kinds of absence.\n *\n * The one place the union is flattened: a transport only needs to know *whether*\n * there is a key, never *why* there is none. Panel copy must not use this —\n * telling \"named but empty\" from \"nothing configured\" is the point of the union.\n * @param resolution - a {@link resolveApiKeyWithSource} result.\n * @returns the key, when one resolved.\n */\nexport function resolvedKeyOf(resolution: ApiKeyResolution | undefined): string | undefined {\n return resolution === undefined || !('key' in resolution) ? undefined : resolution.key;\n}\n\n/**\n * Read the API key a resolved connection block points at.\n *\n * A thin wrapper over {@link resolveApiKeyWithSource}: callers that need only the\n * value use this one, and callers that must report *where* it came from use that\n * one. Deliberately kept as the only spelling of the chain — a second\n * implementation here is exactly the drift (`panel says empty, backend works`)\n * this pair exists to prevent.\n *\n * @param config - resolved System One connection settings.\n * @param env - environment to read; defaults to `process.env`.\n * @returns the key, or `undefined` when no source holds one.\n */\nexport function resolveApiKey(\n config: Pick<ResolvedSystemOneConfig, 'apiKeyEnv' | 'apiKey'>,\n env: Record<string, string | undefined> = process.env\n): string | undefined {\n return resolvedKeyOf(resolveApiKeyWithSource(config, env));\n}\n\n/** The connection facts one probe target carries (never a value it can echo). */\nexport interface ConnectionTarget {\n /** Profile name this target was projected from. */\n name: string;\n /** Backend that would serve this target. */\n backend: 'auto' | 'mock' | 'jev' | 'vllm';\n baseUrl?: string;\n model?: string;\n apiKeyEnv?: string;\n /** The key to present. Stays in this process; never serialized. */\n apiKey?: string;\n timeoutMs?: number;\n /**\n * This connection's model cannot be sent (g-066 att-002): its `selectedModel`\n * is not in its list, or no implementation could be sure which model to ask\n * for when it names none. A probe reports this instead of guessing a model.\n */\n modelUnusable?: boolean;\n}\n\n/**\n * Project one profile's connection facts for the connection test.\n *\n * The probe must send exactly the request the runtime would send, so both read\n * the *same* profile fields: base URL, the **selected** model\n * ({@link modelForProfile}), the key and its variable, the timeout, and the\n * backend. Since g-066 there is nothing to merge — a profile that states no\n * `baseUrl` inherits from **nobody**, and the backend's own environment read is\n * the only thing left below it, exactly as for the runtime.\n *\n * The model is derived rather than read from {@link ConnectionTarget.model}, so a\n * probe can never test a model the runtime does not run: one `selectedModel`\n * outside `modelIds` makes both of them **absent** (and the panel says why,\n * while {@link resolveSystemOneConfig} refuses to connect at all). A profile that\n * lists no model is the one case where the answer is the implementation default\n * — the same {@link plannedModel} the resolved connection uses, so the two can\n * never disagree about which model a connection asks for.\n *\n * `modelUnusable` is the probe's whole answer for a connection whose model\n * cannot be sent: it must not guess one instead.\n *\n * @param flat - the resolved block, supplying the backend fallback only.\n * @param name - profile name (the probe's label).\n * @param profile - the profile to project.\n * @returns the target's connection facts.\n */\nexport function connectionTarget(\n flat: Pick<ResolvedSystemOneConfig, 'backend'>,\n name: string,\n profile: ResolvedSystemOneProfile\n): ConnectionTarget {\n const baseUrl = optionalText(profile.baseUrl);\n // The same rule {@link resolveSystemOneConfig} applies (g-067 att-002): one\n // function, so the test button cannot describe a transport the runtime does\n // not run — the divergence that got the first attempt blocked.\n const backend = effectiveImplementation(flat.backend ?? 'auto', profile.backend, profile);\n const modelIds = profile.modelIds ?? [];\n const resolved = plannedModel(modelIds, backend, modelForProfile(profile, modelIds));\n const model = resolved.model === undefined ? undefined : optionalText(resolved.model);\n const apiKeyEnv = optionalText(profile.apiKeyEnv);\n const apiKey = optionalText(profile.apiKey);\n const timeoutMs = profile.timeoutMs;\n return {\n name,\n backend,\n ...(baseUrl === undefined ? {} : { baseUrl }),\n ...(model === undefined ? {} : { model }),\n ...(resolved.unusable === undefined ? {} : { modelUnusable: true }),\n ...(apiKeyEnv === undefined ? {} : { apiKeyEnv }),\n ...(apiKey === undefined ? {} : { apiKey }),\n ...(timeoutMs === undefined ? {} : { timeoutMs })\n };\n}\n\n/** The transport a connection resolves to: the three the plugin can build. */\nexport type ConnectionImplementation = 'mock' | 'jev' | 'vllm';\n\n/**\n * Which backend selector one active connection really runs under (g-067 att-002).\n *\n * One rule, asked by the resolved connection and by {@link connectionTarget}, so\n * the runtime and the connection test cannot disagree about the transport.\n *\n * The long-standing precedence stands: **a row that names an implementation\n * decides for itself**, and an unnamed row follows the top-level selector. What\n * g-067 adds is a single, narrow exception — see {@link isShippedFactoryRow}.\n *\n * @param selected - the top-level selector.\n * @param rowBackend - the profile's own `backend`, when it states one.\n * @param profile - the profile, so the shipped factory row can be recognised.\n * @returns the selector to resolve an implementation from.\n */\nfunction effectiveImplementation(\n selected: 'auto' | 'mock' | 'jev' | 'vllm',\n rowBackend: 'auto' | 'mock' | 'jev' | 'vllm' | undefined,\n profile: ResolvedSystemOneProfile\n): 'auto' | 'mock' | 'jev' | 'vllm' {\n // The shipped factory row binds `jev` so the *environment* cannot redirect it —\n // but that binding must not silently overrule a deployment that stated its own\n // implementation. Two explicit top-level settings therefore still win over the\n // shipped row, and only over it: an authored row keeps the usual precedence.\n //\n // - `mock` answers in-process and opens no socket, so honouring it cannot send\n // the connection's credential anywhere. Without this, `backend: mock` — the\n // setting every fixture in this package runs on — would dial the official\n // gateway with whatever key the chain resolved.\n // - `vllm` asks the runtime to speak the logits protocol; leaving it on the\n // row's bound `jev` would answer in a protocol the deployment did not choose.\n // Its own endpoint is the row's, so nothing is reached that the connection\n // does not name.\n //\n // `jev` needs no exception (it is what the row already binds), and `auto` is\n // precisely the case the binding exists to override.\n if ((selected === 'mock' || selected === 'vllm') && rowBackend === 'jev' && isShippedFactoryRow(profile)) {\n return selected;\n }\n return rowBackend ?? selected;\n}\n\n/**\n * Whether one profile is the **unedited** shipped factory connection.\n *\n * The exception above must not leak to an authored row that merely resembles the\n * factory one: a user who edited the address, the model or the key variable has\n * stated their own connection, and the usual precedence must apply to it. Value\n * equality is the only stable handle — schemastery materializes the default into\n * a fresh object on every resolution.\n *\n * The model is read through {@link modelForProfile}, the rule every consumer of\n * a profile's model uses, so the schema's legacy `model` beside an empty\n * `modelIds` is recognised exactly like an explicit one-entry list.\n *\n * @param profile - a resolved profile.\n * @returns true for the shipped factory row, unedited.\n */\nfunction isShippedFactoryRow(profile: ResolvedSystemOneProfile): boolean {\n const modelIds = profile.modelIds ?? [];\n return (\n profile.baseUrl === FACTORY_SYSTEMONE_PROFILE.baseUrl &&\n profile.apiKeyEnv === FACTORY_SYSTEMONE_PROFILE.apiKeyEnv &&\n profile.backend === FACTORY_SYSTEMONE_PROFILE.backend &&\n modelForProfile(profile, modelIds).model === FACTORY_SYSTEMONE_PROFILE.model\n );\n}\n\n/**\n * The implementation a connection's backend selector really builds (g-067 att-002).\n *\n * The one place `auto` is turned into a concrete transport, asked by both ends\n * of the same connection: {@link createBackend} builds from it, and the\n * connection test probes with it. Any second derivation is a divergence waiting\n * to happen — and one already happened: the probe hard-coded `auto → jev` while\n * `auto` in the runtime delegated to the vendored factory, which reads the\n * environment. Under `SYSTEM_ONE_BACKEND=vllm` the test button probed the\n * official Jev URL and reported green while the runtime dialled a vLLM endpoint\n * with the same key.\n *\n * `auto` is modelled exactly as far as it is deterministic: the vendored\n * factory's own precedence, read from the environment —\n *\n * 1. an explicit `SYSTEM_ONE_BACKEND` / `REFLEX_BACKEND` selects that provider\n * (`jev`, or `vllm`/`simple-jev`/`logits` as the logits backend);\n * 2. with no selector, a Jev credential (`SYSTEM_ONE_API_KEY` / `JEV_API_KEY`)\n * selects Jev, then a vLLM endpoint selects the logits backend;\n * 3. anything else is the in-process mock.\n *\n * Note what this function does **not** do: it does not make `auto` safe. It\n * makes the two halves honest about the same answer. A connection that must not\n * follow the environment pins its own `backend` instead — which is what the\n * factory row does ({@link FACTORY_SYSTEMONE_PROFILE}).\n *\n * The one deviation from the factory is deliberate: with a selector naming a\n * provider, the factory's \"any other name falls through to the mock\" is kept,\n * because that is what the runtime really builds — guessing Jev there would\n * reintroduce the false green from the other side.\n *\n * @param selector - the connection's effective backend selector.\n * @param env - the environment the `auto` factory would read.\n * @returns the transport that would be built.\n */\nexport function connectionImplementation(\n selector: string,\n env: Record<string, string | undefined> = process.env\n): ConnectionImplementation {\n if (selector === 'mock') return 'mock';\n if (selector === 'jev') return 'jev';\n if (selector === 'vllm') return 'vllm';\n // `auto` (and anything unexpected reaching here): the factory's own order.\n const provider = (env.SYSTEM_ONE_BACKEND ?? env.REFLEX_BACKEND ?? '').trim().toLowerCase();\n if (provider === 'jev') return 'jev';\n if (provider === 'vllm' || provider === 'simple-jev' || provider === 'logits') return 'vllm';\n if (provider.length > 0) return 'mock';\n if (env.SYSTEM_ONE_API_KEY || env.JEV_API_KEY) return 'jev';\n if (env.VLLM_BASE_URL || env.OPENAI_BASE_URL) return 'vllm';\n return 'mock';\n}\n\n/**\n * Normalize one authored pool into detached `{ provider, model, description, tags }` entries,\n * rejecting candidates that would route back into the virtual provider.\n * @param model - virtual model id owning the pool.\n * @param entries - authored candidates.\n * @param virtualProvider - the virtual provider route.\n * @returns the normalized pool.\n * @throws Error when an entry is unusable or self-referential.\n */\nfunction resolvePool(model: string, entries: ReflexModelPoolEntry[], virtualProvider: string): ModelPoolEntry[] {\n if (!Array.isArray(entries)) throw new Error(`routing.models.${model} must be a list of { provider, model } candidates`);\n\n return entries.map((entry, index) => {\n const provider = typeof entry?.provider === 'string' ? entry.provider.trim() : '';\n const target = typeof entry?.model === 'string' ? entry.model.trim() : '';\n if (provider.length === 0 || target.length === 0) {\n throw new Error(`routing.models.${model}[${index}] needs a non-empty provider and model`);\n }\n if (provider.includes(':')) {\n throw new Error(`routing.models.${model}[${index}].provider must not contain \":\" (got \"${provider}\")`);\n }\n if (provider === virtualProvider) {\n throw new Error(\n `routing.models.${model}[${index}] routes back into the virtual provider \"${virtualProvider}\"; a pool must name physical routes only`\n );\n }\n const tags = Array.isArray(entry.tags) ? entry.tags.filter((tag) => typeof tag === 'string' && tag.trim().length > 0) : [];\n return {\n provider,\n model: target,\n ...(entry.description?.trim() ? { description: entry.description.trim() } : {}),\n ...(tags.length > 0 ? { tags } : {})\n };\n });\n}\n\n/**\n * Read a resolved config value out of its volatile marker.\n */\nexport function plainConfig(value: any): any {\n if (value !== null && typeof value === 'object' && typeof value.get === 'function') {\n return plainConfig(value.get());\n }\n if (Array.isArray(value)) {\n return value.map(item => plainConfig(item));\n }\n if (value !== null && typeof value === 'object') {\n return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, plainConfig(child)]));\n }\n return value;\n}\n\n/**\n * Collect the snapshot of every volatile config reference reachable from one\n * loader-resolved config.\n *\n * A config-only update in the Cordis loader never remounts the plugin: the\n * schemastery `volatile` marks tell the loader to commit the new values into the\n * running fiber's references and dispatch `loader/volatile-update`. Every\n * reference hands out a fresh snapshot object from `get()` when it is committed,\n * so comparing these snapshots by identity answers \"did the live config change?\"\n * without re-validating the whole document, and without the loader itself.\n *\n * @param value - a resolved config, raw config, or one of its blocks.\n * @param out - collector for the snapshot identities.\n * @returns the snapshots, in a stable traversal order; empty for a plain config.\n */\nexport function volatileSnapshots(value: unknown, out: unknown[] = []): unknown[] {\n if (value === null || typeof value !== 'object') return out;\n const reference = value as { get?: unknown };\n if (typeof reference.get === 'function') {\n out.push((reference.get as () => unknown)());\n return out;\n }\n if (Array.isArray(value)) {\n for (const item of value) volatileSnapshots(item, out);\n return out;\n }\n for (const child of Object.values(value as Record<string, unknown>)) volatileSnapshots(child, out);\n return out;\n}\n\n/**\n * Validate an authored config and fill in every default.\n * @param config - deployment config (already resolved by the loader, or raw).\n * @returns the fully-populated configuration.\n * @throws Error when the routing block names an unusable virtual provider or fallback.\n */\nexport function resolveConfig(config?: ReflexConfig): ResolvedReflexConfig {\n const unwrapped = plainConfig(config ?? {});\n const authoredEffort = (unwrapped as { effort?: { reasoningEffort?: unknown } } | null | undefined)?.effort;\n const authoredReasoning =\n authoredEffort !== null && typeof authoredEffort === 'object'\n ? (authoredEffort as { reasoningEffort?: unknown }).reasoningEffort\n : undefined;\n // Check the authored policy *before* the schema: a legacy concrete level then\n // gets the migration hint below instead of the schema's generic union error.\n if (typeof authoredReasoning === 'string') resolveEffortSetting(authoredReasoning);\n const validated = plainConfig(Config(unwrapped)) as ReflexConfig;\n const routing = validated.routing ?? {};\n const effort = validated.effort ?? {};\n\n const virtualProvider = (routing.virtualProvider ?? 'reflex').trim();\n if (virtualProvider.length === 0) throw new Error('routing.virtualProvider must be non-empty');\n if (virtualProvider.includes(':')) {\n throw new Error(`routing.virtualProvider must not contain \":\" (got \"${virtualProvider}\")`);\n }\n\n const setting = resolveEffortSetting(effort.reasoningEffort);\n\n const authored = routing.models ?? {};\n const models: Record<string, ModelPoolEntry[]> = {};\n for (const [model, entries] of Object.entries(authored)) {\n if (model.trim().length === 0) throw new Error('routing.models keys must be non-empty virtual model ids');\n models[model] = resolvePool(model, Array.isArray(entries) ? entries : [], virtualProvider);\n }\n\n const fallback =\n typeof routing.fallback === 'string' && routing.fallback.trim().length > 0 ? parseFallback(routing.fallback) : undefined;\n if (fallback?.provider === virtualProvider) {\n throw new Error(`routing.fallback must not point back into the virtual provider \"${virtualProvider}\"`);\n }\n\n const effortFallback = effort.fallback ?? 'medium';\n if (!(ADAPTIVE_EFFORT_LEVELS as readonly string[]).includes(effortFallback)) {\n throw new Error(`effort.fallback must be one of ${ADAPTIVE_EFFORT_LEVELS.join(', ')} (got \"${String(effortFallback)}\")`);\n }\n const minConfidence = effort.minConfidence ?? 0.3;\n if (!Number.isFinite(minConfidence) || minConfidence < 0 || minConfidence > 1) {\n throw new Error(`effort.minConfidence must be a number in [0, 1] (got \"${String(effort.minConfidence)}\")`);\n }\n const effortEnabled = effort.enabled ?? true;\n if (typeof effortEnabled !== 'boolean') {\n throw new Error(`effort.enabled must be a boolean (got \"${String(effort.enabled)}\")`);\n }\n\n return {\n backend: validated.backend ?? 'auto',\n toolPrefix: validated.toolPrefix ?? 'reflex_',\n ledgerPath: validated.ledgerPath,\n pruneThreshold: validated.pruneThreshold ?? 500,\n calibrationPath: validated.calibrationPath,\n systemOne: resolveSystemOneConfig(validated.backend, validated.systemOne),\n routing: {\n enabled: routing.enabled ?? true,\n virtualProvider,\n models,\n maxTaskChars: routing.maxTaskChars ?? 400,\n ...(fallback ? { fallback } : {})\n },\n effort: {\n enabled: effortEnabled,\n ...(setting === undefined ? {} : { setting }),\n fallback: effortFallback,\n minConfidence\n },\n tools: resolveToolsConfig(validated.tools),\n delegation: resolveDelegationConfig(validated.delegation),\n interventions: resolveInterventionsConfig(validated.interventions, validated.pruneThreshold ?? 500)\n };\n}\n\n/**\n * Validate the per-tool switch block and fill in every omitted suffix.\n *\n * Both failure modes are answered here, not by the schema: an unknown suffix\n * (a typo, or a tool this build does not ship) and a non-boolean value. A\n * deployment that cannot be honoured fails at resolution time rather than\n * half-registering its tools. The suffix vocabulary is this build's, so a\n * switch for a capability that is no longer a tool — `prune`,\n * `detect_stagnation`, `status_ledger` — is refused here instead of being\n * carried as a key that reads as \"on\" and registers nothing.\n *\n * A programmatic caller that passes the switch map itself (instead of wrapping\n * it in `enabled`) is rejected too: silently reading it as \"nothing authored\"\n * would turn that typo into a deployment where everything stays registered.\n *\n * @param authored - the authored `tools` block.\n * @returns every suffix of the vocabulary mapped to its effective switch.\n * @throws Error when the block, a key, or a value cannot be honoured.\n */\nexport function resolveToolsConfig(authored: ReflexToolsConfig | undefined): ResolvedToolsConfig {\n if (authored !== undefined && (authored === null || typeof authored !== 'object' || Array.isArray(authored))) {\n throw new Error(`tools must be an object mapping tool suffixes to booleans (got \"${String(authored)}\")`);\n }\n const block = authored ?? {};\n const extraKeys = Object.keys(block).filter((key) => key !== 'enabled');\n if (extraKeys.length > 0) {\n const rendered = extraKeys.map((key) => JSON.stringify(key)).join(', ');\n throw new Error(\n `tools has unknown key${extraKeys.length === 1 ? '' : 's'} ${rendered}; only \"enabled\" is supported`\n );\n }\n const switches = block.enabled;\n if (switches !== undefined && (switches === null || typeof switches !== 'object' || Array.isArray(switches))) {\n throw new Error(`tools.enabled must be an object mapping tool suffixes to booleans (got \"${String(switches)}\")`);\n }\n const authoredSwitches = switches ?? {};\n const unknown = Object.keys(authoredSwitches).filter((key) => !(REFLEX_TOOL_SUFFIXES as readonly string[]).includes(key));\n if (unknown.length > 0) {\n const rendered = unknown.map((key) => JSON.stringify(key)).join(', ');\n throw new Error(\n `tools.enabled has unknown tool ${unknown.length === 1 ? 'switch' : 'switches'} ${rendered}; legal suffixes are ${REFLEX_TOOL_SUFFIXES.join(', ')}`\n );\n }\n const enabled = {} as Record<ReflexToolSuffix, boolean>;\n for (const suffix of REFLEX_TOOL_SUFFIXES) {\n const value = authoredSwitches[suffix];\n if (value !== undefined && typeof value !== 'boolean') {\n throw new Error(`tools.enabled.${suffix} must be a boolean (got \"${String(value)}\")`);\n }\n // Omitted entries take the per-suffix default instead of an unconditional\n // \"on\": `route` is off unless the deployment asks for it, and the panel,\n // the registry, and this resolver must all agree on that one table.\n enabled[suffix] = value ?? REFLEX_TOOL_DEFAULT_ENABLED[suffix];\n }\n return { enabled };\n}\n\n/**\n * Validate the delegation block and fill in its default.\n *\n * The default is `false` and it is load-bearing: with the switch on, the tool\n * is offered; with it off, `reflex_delegate` is not registered at all, because a\n * wrapper whose level cannot be delivered would be a capability that only looks\n * like one. A non-boolean is refused rather than coerced, for the same reason\n * every other block refuses one.\n * @param authored - the authored `delegation` block.\n * @returns the resolved switch.\n * @throws Error when the value is present but not a boolean.\n */\nexport function resolveDelegationConfig(authored: ReflexDelegationConfig | undefined): ResolvedDelegationConfig {\n if (authored !== undefined && (authored === null || typeof authored !== 'object' || Array.isArray(authored))) {\n throw new Error(`delegation must be an object (got \"${String(authored)}\")`);\n }\n const block = authored ?? {};\n const extraKeys = Object.keys(block).filter((key) => key !== 'enabled');\n if (extraKeys.length > 0) {\n const rendered = extraKeys.map((key) => JSON.stringify(key)).join(', ');\n throw new Error(`delegation has unknown key${extraKeys.length === 1 ? '' : 's'} ${rendered}; only \"enabled\" is supported`);\n }\n const value = block.enabled;\n if (value !== undefined && typeof value !== 'boolean') {\n throw new Error(`delegation.enabled must be a boolean (got \"${String(value)}\")`);\n }\n return { enabled: value ?? false };\n}\n\n/**\n * Validate one authored `reasoningEffort` value.\n *\n * Configuration only answers \"should adaptive effort run at all?\": the loader\n * restricts it to the trigger markers, and this repeats the check because\n * {@link resolveConfig} is also the entry point for a programmatic caller. A\n * concrete level is not a typo to ignore — it is an obsolete setting, so the\n * error says where that choice moved instead of silently dropping it.\n *\n * @param value - authored setting.\n * @returns the normalized trigger, or `undefined` when nothing was configured.\n * @throws Error when the value is not `reflex`/`auto` (including a concrete level).\n */\nexport function resolveEffortSetting(value: string | undefined): ReasoningEffortSetting | undefined {\n if (value === undefined) return undefined;\n const setting = typeof value === 'string' ? value.trim().toLowerCase() : '';\n if ((EFFORT_TRIGGERS as readonly string[]).includes(setting)) {\n return setting as ReasoningEffortSetting;\n }\n throw new Error(\n `effort.reasoningEffort 只支持留空或 reflex(别名 auto);要固定思考深度请在模型选择器里选择具体档位 (got \"${String(value)}\")`\n );\n}\n\n/**\n * Whether this configuration can actually route: enabled with at least one\n * non-empty pool. Without a pool the plugin registers no virtual provider at\n * all, so a misconfigured `reflex` selection can never masquerade as working.\n * @param config - resolved configuration.\n * @returns whether routing should be installed.\n */\nexport function routingActive(config: ResolvedReflexConfig): boolean {\n if (!config.routing.enabled) return false;\n return Object.values(config.routing.models).some((pool) => pool.length > 0);\n}\n"]}
@@ -0,0 +1,132 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { Agent } from '@deepseek-ai/dsh-agent';
3
+ import type { ChoiceRequest, ChoiceResponse } from './vendor/harness-reflex/backend/types.js';
4
+ import type { DecisionLedger } from './vendor/harness-reflex/core/ledger.js';
5
+ import { type DelegationParentFacts } from './delegation.js';
6
+ import type { ReflexDelegationSeam } from './tools.js';
7
+ /**
8
+ * Bind `reflex_delegate` to the Host's own delegation tool.
9
+ *
10
+ * The whole point of this adapter is that it *adds no authority of its own*. It
11
+ * decides one reasoning level, and then hands the call to the registry through
12
+ * `ctx.tools.execute()` — the same public pipeline a model-issued call takes, so
13
+ * the pre-execute policy, approvals, guards, the Host tool's own route policy
14
+ * (`assertAllowedModelSelection`), its route preflight, and its recursion limit
15
+ * all run exactly as they would for a direct call. When the Host refuses, its
16
+ * refusal is rethrown verbatim; this layer never turns "not allowed" into a
17
+ * different answer, and never checks a route itself.
18
+ *
19
+ * @module dsh-reflex/delegation-dispatch
20
+ */
21
+ /** Facts one activation needs to expose `reflex_delegate`, so a single descriptor covers them all. */
22
+ export interface ReflexDelegationOptions {
23
+ /** The registry the delegation tool is registered in. */
24
+ readonly ctx: Context;
25
+ /** The activation's audit ledger. */
26
+ readonly ledger: DecisionLedger;
27
+ /** System One choice execution; the runtime's backend. */
28
+ readonly decide: (request: ChoiceRequest) => Promise<ChoiceResponse>;
29
+ /** Minimum System One confidence for its answer to be trusted. */
30
+ readonly minConfidence: number;
31
+ /** Agent the delegated call is attributed to; resolved per call when possible. */
32
+ readonly agent?: () => Agent | undefined;
33
+ /** Sink for the one deployment warning this module can raise. */
34
+ readonly warn?: (message: string) => void;
35
+ }
36
+ /**
37
+ * Find the Host's delegation tool in the registry, when it can carry a level.
38
+ *
39
+ * Two facts have to hold, and both are read from the live registry rather than
40
+ * assumed:
41
+ *
42
+ * 1. the tool is registered — the Host owns its name as configuration
43
+ * (`toolName`, default `subagent`), so candidate names are tried in order;
44
+ * 2. the tool *declares* `reasoning_effort`. The Host only adds that parameter
45
+ * to its schema when the deployment sets `modelSelection: true`; with the
46
+ * switch off the tool accepts no level at all.
47
+ *
48
+ * The parameter list is the model-facing schema the Host publishes, so this is
49
+ * an observable contract, not internals.
50
+ *
51
+ * ## Why the scope argument is not optional decoration
52
+ *
53
+ * `dsh-tools` is a *scoped* registry: `get(name)` with no scope reads the
54
+ * **global** view, and a tool mounted inside an **agent preset** — which is
55
+ * where a real deployment attaches `tool-subagent` — is not in that view at
56
+ * all. Reading the global view to decide whether this Host can delegate
57
+ * therefore answers "no tool" on every preset-hosted deployment, however
58
+ * correctly `modelSelection` is configured. Passing the calling agent reads the
59
+ * view that deployment actually serves, and is the only reading that can tell
60
+ * "the capability is off" from "this scope does not show it".
61
+ * @param ctx - context whose `tools` service is live.
62
+ * @param agent - the scope to read as; omitted selects the global view.
63
+ * @returns the registered name and whether it accepts a level, or `undefined`
64
+ * when that scope exposes no delegation tool at all.
65
+ */
66
+ export declare function inspectDelegationTool(ctx: Context, agent?: Agent): DelegationTarget | undefined;
67
+ /**
68
+ * The name the seam dispatches to when no scope is available to confirm it.
69
+ *
70
+ * This is the Host tool's documented default (`toolName`, default `subagent`).
71
+ * Naming it here rather than reading it at mount is the whole point of the
72
+ * registration fix: at mount there is no agent scope, so the registry cannot
73
+ * answer, and "cannot answer" must not read as "cannot delegate".
74
+ */
75
+ export declare const DELEGATION_TOOL_NAME: string;
76
+ /**
77
+ * The Host delegation tool as this activation can use it.
78
+ *
79
+ * Separates "there is no such tool" from "there is one, but it cannot carry a
80
+ * reasoning level", because the two need different answers: the first is silent,
81
+ * the second is a loud deployment problem the operator has to hear about.
82
+ */
83
+ export interface DelegationTarget {
84
+ /** Registered tool name. */
85
+ readonly toolName: string;
86
+ /** Whether the tool declares `reasoning_effort` (Host `modelSelection: true`). */
87
+ readonly acceptsReasoningEffort: boolean;
88
+ }
89
+ /** The log line emitted when the Host tool exists but cannot carry a level. */
90
+ export declare const DELEGATION_MODEL_SELECTION_DISABLED: string;
91
+ /**
92
+ * Read the parent's own effort and model from its composed options.
93
+ *
94
+ * Read live on every call rather than captured at mount: a session's selection
95
+ * changes between steps, and the fallback must inherit what the parent is using
96
+ * *now*.
97
+ * @param agent - the calling agent, when one is known.
98
+ * @returns the parent facts, with unknown fields omitted.
99
+ */
100
+ export declare function parentDelegationFacts(agent: Agent | undefined): DelegationParentFacts;
101
+ /**
102
+ * Build the seam `reflex_delegate` dispatches through.
103
+ *
104
+ * ## Why this does not inspect the registry
105
+ *
106
+ * It used to refuse to build unless the live registry showed a delegation tool
107
+ * that *declares* `reasoning_effort`. That probe ran during `apply()`, where the
108
+ * plugin has no agent scope — and `dsh-tools` is scoped, so the probe read the
109
+ * **global** view. A real deployment attaches `tool-subagent` inside an **agent
110
+ * preset**, which the global view does not contain. The consequence was the bug
111
+ * this seam now avoids: a correctly configured Host (patch written,
112
+ * `modelSelection: true` dumped from the running config, the panel switch on)
113
+ * still got no `reflex_delegate`, because the one place the plugin looked for
114
+ * the capability is the one place a preset can never appear.
115
+ *
116
+ * So the capability question is not answered here at all. What this Host can
117
+ * serve is judged at **call time**, in the caller's own scope, by the Host's own
118
+ * argument validation: a `subagent` that does not accept `reasoning_effort`
119
+ * rejects the call, and {@link delegationFailure} rethrows that refusal verbatim.
120
+ * That refusal is strictly better evidence than a schema probe taken at mount —
121
+ * it comes from the very scope that would serve the call.
122
+ *
123
+ * Whether the *user* consented is a separate question, and it is not answered
124
+ * here either: `delegationExecutables` withholds the target unless
125
+ * `delegation.enabled` is true, so the registry only ever asks for a seam that
126
+ * configuration already asked for.
127
+ *
128
+ * @param options - the registry, the ledger, System One, and the confidence floor.
129
+ * @returns the seam. Never `undefined` for a capability reason: registration is
130
+ * decided by configuration, not by a registry view taken at mount.
131
+ */
132
+ export declare function createReflexDelegation(options: ReflexDelegationOptions): ReflexDelegationSeam | undefined;