dsh-harness-reflex 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -6
- package/client.js +3511 -185
- package/dist/attribution.d.ts +266 -0
- package/dist/attribution.js +238 -0
- package/dist/attribution.js.map +1 -0
- package/dist/bridge.d.ts +311 -13
- package/dist/bridge.js +714 -42
- package/dist/bridge.js.map +1 -1
- package/dist/client-bundle.js +4 -1
- package/dist/client-bundle.js.map +1 -1
- package/dist/command.js +10 -0
- package/dist/command.js.map +1 -1
- package/dist/config.d.ts +530 -22
- package/dist/config.js +808 -27
- package/dist/config.js.map +1 -1
- package/dist/delegation-dispatch.d.ts +132 -0
- package/dist/delegation-dispatch.js +186 -0
- package/dist/delegation-dispatch.js.map +1 -0
- package/dist/delegation-health.d.ts +131 -0
- package/dist/delegation-health.js +97 -0
- package/dist/delegation-health.js.map +1 -0
- package/dist/delegation.d.ts +148 -0
- package/dist/delegation.js +186 -0
- package/dist/delegation.js.map +1 -0
- package/dist/effort-delegation.d.ts +144 -0
- package/dist/effort-delegation.js +280 -0
- package/dist/effort-delegation.js.map +1 -0
- package/dist/effort.d.ts +141 -0
- package/dist/effort.js +251 -9
- package/dist/effort.js.map +1 -1
- package/dist/host-patch.d.ts +156 -0
- package/dist/host-patch.js +534 -0
- package/dist/host-patch.js.map +1 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.js +99 -7
- package/dist/index.js.map +1 -1
- package/dist/interventions.d.ts +98 -373
- package/dist/interventions.js +442 -1702
- package/dist/interventions.js.map +1 -1
- package/dist/panel-api.d.ts +328 -4
- package/dist/panel-api.js +322 -15
- package/dist/panel-api.js.map +1 -1
- package/dist/panel-mount.d.ts +81 -22
- package/dist/panel-mount.js +228 -7
- package/dist/panel-mount.js.map +1 -1
- package/dist/routing.d.ts +23 -18
- package/dist/routing.js +471 -153
- package/dist/routing.js.map +1 -1
- package/dist/session-audit.d.ts +70 -0
- package/dist/session-audit.js +73 -0
- package/dist/session-audit.js.map +1 -1
- package/dist/systemone-probe.d.ts +114 -0
- package/dist/systemone-probe.js +383 -0
- package/dist/systemone-probe.js.map +1 -0
- package/dist/testing.d.ts +212 -7
- package/dist/testing.js +333 -27
- package/dist/testing.js.map +1 -1
- package/dist/tools.d.ts +109 -3
- package/dist/tools.js +103 -4
- package/dist/tools.js.map +1 -1
- package/dist/unconfigured-backend.d.ts +72 -0
- package/dist/unconfigured-backend.js +94 -0
- package/dist/unconfigured-backend.js.map +1 -0
- package/dist/vendor/harness-reflex/backend/factory.d.ts +31 -1
- package/dist/vendor/harness-reflex/backend/factory.js +18 -3
- package/dist/vendor/harness-reflex/backend/factory.js.map +1 -1
- package/dist/vendor/harness-reflex/backend/jev.d.ts +20 -0
- package/dist/vendor/harness-reflex/backend/jev.js +11 -4
- package/dist/vendor/harness-reflex/backend/jev.js.map +1 -1
- package/dist/vendor/harness-reflex/backend/simple-jev.d.ts +16 -0
- package/dist/vendor/harness-reflex/backend/simple-jev.js +17 -6
- package/dist/vendor/harness-reflex/backend/simple-jev.js.map +1 -1
- package/dist/vendor/harness-reflex/core/closing.d.ts +90 -0
- package/dist/vendor/harness-reflex/core/closing.js +111 -0
- package/dist/vendor/harness-reflex/core/closing.js.map +1 -0
- package/dist/vendor/harness-reflex/core/evidence.d.ts +119 -0
- package/dist/vendor/harness-reflex/core/evidence.js +209 -0
- package/dist/vendor/harness-reflex/core/evidence.js.map +1 -0
- package/dist/vendor/harness-reflex/core/judge.d.ts +221 -0
- package/dist/vendor/harness-reflex/core/judge.js +251 -0
- package/dist/vendor/harness-reflex/core/judge.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate-closing.d.ts +237 -0
- package/dist/vendor/harness-reflex/core/orchestrate-closing.js +250 -0
- package/dist/vendor/harness-reflex/core/orchestrate-closing.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate-correction.d.ts +209 -0
- package/dist/vendor/harness-reflex/core/orchestrate-correction.js +141 -0
- package/dist/vendor/harness-reflex/core/orchestrate-correction.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate-host.d.ts +225 -0
- package/dist/vendor/harness-reflex/core/orchestrate-host.js +80 -0
- package/dist/vendor/harness-reflex/core/orchestrate-host.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate-stagnation.d.ts +259 -0
- package/dist/vendor/harness-reflex/core/orchestrate-stagnation.js +270 -0
- package/dist/vendor/harness-reflex/core/orchestrate-stagnation.js.map +1 -0
- package/dist/vendor/harness-reflex/core/orchestrate.d.ts +357 -0
- package/dist/vendor/harness-reflex/core/orchestrate.js +418 -0
- package/dist/vendor/harness-reflex/core/orchestrate.js.map +1 -0
- package/dist/vendor/harness-reflex/core/policy.d.ts +122 -0
- package/dist/vendor/harness-reflex/core/policy.js +102 -0
- package/dist/vendor/harness-reflex/core/policy.js.map +1 -0
- package/dist/vendor/harness-reflex/core/prune-plan.d.ts +141 -0
- package/dist/vendor/harness-reflex/core/prune-plan.js +390 -0
- package/dist/vendor/harness-reflex/core/prune-plan.js.map +1 -0
- package/dist/vendor/harness-reflex/core/text.d.ts +36 -0
- package/dist/vendor/harness-reflex/core/text.js +66 -0
- package/dist/vendor/harness-reflex/core/text.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/audit.d.ts +18 -0
- package/dist/vendor/harness-reflex/ports/audit.js +11 -0
- package/dist/vendor/harness-reflex/ports/audit.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/clock.d.ts +14 -0
- package/dist/vendor/harness-reflex/ports/clock.js +11 -0
- package/dist/vendor/harness-reflex/ports/clock.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/decision.d.ts +75 -0
- package/dist/vendor/harness-reflex/ports/decision.js +2 -0
- package/dist/vendor/harness-reflex/ports/decision.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/index.d.ts +14 -0
- package/dist/vendor/harness-reflex/ports/index.js +2 -0
- package/dist/vendor/harness-reflex/ports/index.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/log.d.ts +22 -0
- package/dist/vendor/harness-reflex/ports/log.js +12 -0
- package/dist/vendor/harness-reflex/ports/log.js.map +1 -0
- package/dist/vendor/harness-reflex/ports/state.d.ts +46 -0
- package/dist/vendor/harness-reflex/ports/state.js +13 -0
- package/dist/vendor/harness-reflex/ports/state.js.map +1 -0
- package/package.json +25 -13
package/dist/routing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../src/routing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAA4E,MAAM,sBAAsB,CAAC;AAG1J,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAqI5D,uBAAuB;AACvB,MAAM,IAAI,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AA6B5B;;;;;;;;;GASG;AACH,SAAS,UAAU,CAAC,GAAe;IACjC,MAAM,IAAI,GAAI,GAA8C,CAAC,GAAG,EAAE,IAAI,CAAC;IACvE,OAAO,IAAI,IAAK,GAAyB,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,IAAI,OAAO,EAAmC,CAAC;AAEpE,yGAAyG;AACzG,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAkD9B;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,GAAe,EAAE,OAAgF;IAC7H,MAAM,MAAM,GAAG,OAAO,IAAI,CAAC,CAAC,QAAgB,EAAE,KAAa,EAAE,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,Q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;;;GAQG;AACH,SAAS,eAAe,CAAC,QAAgC;IACvD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,OAAO,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;QACrC,KAAK,MAAM,KAAK,IAAI,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAA4B,EAAE,CAAC;YACxE,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;gBAAE,SAAS;YACtE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,KAAY;IAC5B,IAAI,CAAC;QACH,OAAO,OAAO,KAAK,EAAE,EAAE,KAAK,QAAQ,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { Agent } from '@deepseek-ai/dsh-agent';\nimport { isAgentLoopRequest, markAgentLoopRequest, type ContentBlock, type LlmCallConfig, type LlmRuntime, type UserMessage } from '@deepseek-ai/dsh-llm';\n\nimport type { EffortInterceptor, EffortResolution, ReflexEffortStatus } from './effort.js';\nimport { formatEffortStatusLine } from './effort.js';\nimport { appendEffortRecord } from './session-audit.js';\nimport { resolveAdaptiveIntent } from './adaptive-intent.js';\nimport type { PhysicalTarget, ReasoningProbe, RouteContext, VirtualModelRouter } from './router.js';\nimport { alignReasoningEffort, estimateContextTokens } from './router.js';\nimport { ReflexVirtualAdapter } from './virtual-adapter.js';\n\n/**\n * Install the virtual provider route and the interception layers that route its\n * requests through System 1.\n *\n * Layer 1 — `agent/request` (waterfall): the loop hands out the *frozen call\n * configuration* it would use and accepts a replacement. This is the only\n * place a loop request can be re-routed, because the request object the loop\n * later builds is deep-frozen and marked as loop-owned. Rewriting the config\n * here means the logged header, the prepared call and the dispatched request\n * all name the physical route, so the routing decision is auditable from the\n * session log alone.\n *\n * Layer 2 — the same waterfall decides the turn's reasoning effort. A request\n * carrying the `reflex`/`auto` marker (or a deployment that configured the\n * marker) has no physical effort id yet; {@link EffortInterceptor} turns it into\n * one, projects it onto the routed model's vocabulary, audits it in the session\n * log, and publishes it to the status feed. A request that named a concrete\n * effort is passed through untouched.\n *\n * Layer 3 — the virtual adapter's `stream()`: anything that does not pass\n * through layer 1 (hand-built one-shot calls, `prepareCall()` consumers) is\n * routed at dispatch time and delegated to the physical adapter through\n * `ctx.llm.stream`.\n *\n * The task text each decision reasons about comes from `agent/pre-step`, which\n * carries the user messages admitted to the step: a subagent's first step\n * carries its delegated task, so a delegated agent routes on its *own* task\n * rather than inheriting its parent's decision. That is also the input the\n * effort decision reads, because the request waterfall only sees a frozen config.\n *\n * The same listener accumulates each agent's *session size* (characters of step\n * input seen so far), and every routed request remembers the physical model it\n * landed on. Both ride into the next decision as cache-affinity facts, so a\n * session that already holds a warm prompt prefix is not moved onto another\n * physical model for a marginal score difference.\n *\n * @module dsh-reflex/routing\n */\n\n/** Dependencies of {@link installModelRouting}. */\nexport interface ModelRoutingOptions {\n /** LLM runtime to register the virtual route on and dispatch through. */\n llm: LlmRuntime;\n /** Pool policy and System 1 decision seam. */\n router: VirtualModelRouter;\n /** Per-turn adaptive reasoning-effort policy. */\n effort: EffortInterceptor;\n /**\n * Whether this activation should register the virtual provider route. `false`\n * (a deployment with routing disabled, or with no pool) still installs the\n * request listeners, so the adaptive-effort layer keeps working, but never\n * registers a route or rewrites one. Defaults to `true`.\n */\n route?: boolean;\n /**\n * Task-text budget captured from `agent/pre-step` (characters).\n *\n * A getter keeps the budget live: a config-only save may change\n * `routing.maxTaskChars` between steps, and the next step must capture with\n * the new value before the schema is re-resolved.\n */\n maxTaskChars: number | (() => number);\n /**\n * Read the live routing policy for the enable/disable and rename lifecycle.\n * Omitted means the initial {@link route} decision is final.\n */\n liveRouting?: () => LiveRoutingPolicy;\n /**\n * Pull the activation's live config, if the host commits config-only saves.\n *\n * Called once at the start of every `agent/pre-step`: the implementation\n * compares the volatile snapshot identities and re-resolves only when the\n * loader actually committed a change, so an unchanged step pays a handful of\n * identity comparisons and no schema run. This is what makes an effort-only\n * deployment (no route to refresh lazily) pick up a settings edit on its next\n * step even if the event were missed.\n */\n refreshConfig?: () => unknown;\n /** Diagnostic sink for non-fatal degradation (never throws). */\n warn?: (message: string) => void;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Events {\n /**\n * One adaptive reasoning-effort decision was applied to a request. Fired for\n * every decided turn; carries the same payload that is committed to the\n * session log, so a status bar and the audit trail cannot disagree.\n * @param payload - the decided level, the effort dispatched, and the evidence.\n * @mode emit\n */\n 'reflex/effort'(payload: ReflexEffortStatus): void;\n }\n}\n\n/** Routing policy facts the lifecycle reconciler reads. */\nexport interface LiveRoutingPolicy {\n /** Deployment `routing.enabled` switch. */\n enabled: boolean;\n /** Current virtual provider route id. */\n virtualProvider: string;\n /** Task capture budget in characters. */\n maxTaskChars: number;\n /** Pools that decide whether a route can be installed at all. */\n models: import('./router.js').ModelPools;\n}\n\n/** What {@link installModelRouting} installed. */\nexport interface ModelRoutingInstallation {\n /**\n * The router actually in force. With several activations on one runtime the\n * first activation owns the process-wide virtual route and later activations\n * route through the owner's policy, so every path agrees on the pools.\n */\n router: VirtualModelRouter;\n /** The adapter registered for the virtual route, when this activation owns it (live). */\n readonly adapter?: ReflexVirtualAdapter;\n /** Whether this call registered the virtual provider route itself. */\n readonly registered: boolean;\n /** How many `registerAdapter` calls this activation has made in total. */\n readonly registrationEvents: number;\n /**\n * Apply a freshly resolved routing policy: register/unregister the route and\n * rename the virtual provider to match. Idempotent; a same-value refresh\n * touches no registration.\n */\n refresh(policy: LiveRoutingPolicy): void;\n /** Detach the listeners and release the route when this call owned it. */\n dispose: () => void;\n}\n\n/** Nothing to undo. */\nconst NOOP = (): void => {};\n\n/**\n * One process-wide virtual route this plugin has registered.\n *\n * `owners` counts the activations that still route through it. Two activations\n * exist at once when a reload is applied as \"create the new activation, then\n * dispose the old one\" (or with two entries of the same plugin). The provider\n * route must survive the first release in that ordering, and the newest\n * activation's policy must be the one in force — otherwise the new activation\n * routes on the old, about-to-be-released pools and then loses the route\n * entirely once the old activation disposes.\n *\n * There is deliberately one shared {@link ReflexVirtualAdapter} whose router all\n * owners route through: two `agent/request` listeners wrapping the same\n * waterfall cannot hold two different policies, because the outer listener sees\n * an already-rewritten config and must agree with the inner one.\n */\ninterface OwnedRoute {\n /** Provider route this entry is registered under. */\n provider: string;\n /** The registered adapter, shared by every owner. */\n adapter: ReflexVirtualAdapter;\n /** Live activations routing through this adapter. */\n owners: number;\n /** Unregister the provider route, called when the last owner goes away. */\n handle: () => void;\n}\n\n/**\n * Stable process-wide identity of one LLM runtime.\n *\n * The service handle a context hands out (`ctx.llm`) is a fresh tracing wrapper\n * on every read, so it must never be a map key: two activations would each see\n * \"no route yet\" and the second would collide with `DUPLICATE_ADAPTER`. The\n * wrapper's owning root context is stable for every read of the same runtime.\n * @param llm - the runtime handle the activation was given.\n * @returns a key that is the same object for every activation on that runtime.\n */\nfunction routeScope(llm: LlmRuntime): object {\n const root = (llm as unknown as { ctx?: { root?: object } }).ctx?.root;\n return root ?? (llm as unknown as object);\n}\n\n/**\n * Virtual routes already owned in this process, keyed by the root context of\n * the LLM runtime that holds them. A DSH deployment can activate this plugin\n * more than once (one activation per tool prefix); provider routes are\n * process-wide, so the first activation registers and the rest join its route\n * instead of colliding with `DUPLICATE_ADAPTER`.\n */\nconst OWNED_ROUTES = new WeakMap<object, Map<string, OwnedRoute>>();\n\n/** Most agent-scoped tasks retained for routing; bounded so a long session cannot grow without limit. */\nconst MAX_TRACKED_AGENTS = 64;\n\n/**\n * What one activation remembers about one agent between requests.\n *\n * `contextChars` is the running character count of the step input this\n * activation has observed for the agent — a monotone lower bound on the\n * session's real context (assistant and tool text are produced after the step\n * that caused them). It is deliberately an observation, not a session-log\n * read: routing must not depend on the session module's internal event shapes.\n */\ninterface AgentRoutingFacts {\n /** Task text captured on the agent's latest step. */\n task?: string;\n /** Physical model the agent's latest routed request landed on. */\n currentModel?: PhysicalTarget;\n /** Characters of step input observed for this agent so far. */\n contextChars: number;\n /**\n * Whether the most recent `agent/pre-step` carried new user text. A step that\n * carries none is a continuation of the step before it, not a new instruction,\n * so its decision may be reused instead of asking System 1 again.\n */\n stepHasText?: boolean;\n /** The decision this turn already made, reused by its later steps. */\n decided?: TurnDecision;\n /** Adaptive effort this layer dispatched most recently, used to recognise a header echo. */\n lastAdaptiveEffort?: string;\n}\n\n/** One decided turn, kept so a same-turn follow-up step costs nothing. */\ninterface TurnDecision {\n turn: number;\n provider: string;\n model: string;\n /** Effort the rewritten request carried; `undefined` when the key was cleared. */\n effort?: string;\n /** The published status of that decision. */\n status?: ReflexEffortStatus;\n /**\n * Effort policy generation the decision was taken under.\n *\n * A config-only save can land mid-turn; a follow-up step may reuse the cached\n * decision only when no policy change happened between them, otherwise the\n * new `fallback`/`minConfidence`/switch would be shadowed by a decision the\n * user already replaced.\n */\n generation?: number;\n}\n\n/**\n * Read the reasoning-effort vocabulary of one physical route.\n * @param llm - the runtime that owns the adapter for the target.\n * @param resolve - raw model-info lookup; defaults to the runtime's own.\n * @returns a probe that never throws.\n */\nfunction createReasoningProbe(llm: LlmRuntime, resolve?: (provider: string, model: string) => Promise<LlmResolvedModelInfoLike>): ReasoningProbe {\n const lookup = resolve ?? ((provider: string, model: string) => llm.resolveModelInfo(provider, model) as unknown as Promise<LlmResolvedModelInfoLike>);\n return async (target) => {\n let info;\n try {\n info = await lookup(target.provider, target.model);\n } catch {\n return { kind: 'unknown' };\n }\n const reasoning = info?.reasoning;\n if (!reasoning || reasoning.efforts.length === 0) return { kind: 'none' };\n return {\n kind: 'declared',\n efforts: reasoning.efforts.map((effort) => effort.id as unknown as string),\n ...(reasoning.defaultEffort ? { defaultEffort: reasoning.defaultEffort as unknown as string } : {})\n };\n };\n}\n\n/** The slice of a resolved model the reasoning probe reads. */\ninterface LlmResolvedModelInfoLike {\n reasoning?: { efforts: readonly { id: unknown }[]; defaultEffort?: unknown };\n}\n\n/**\n * Agent identity facts the routing decision records.\n * @param agent - the requesting agent (possibly a synthetic test double).\n * @returns the audit attribution, never throwing.\n */\nfunction describeAgent(agent: Agent): Pick<RouteContext, 'agentId' | 'role' | 'delegationDepth'> {\n const facts: Pick<RouteContext, 'agentId' | 'role' | 'delegationDepth'> = {};\n try {\n if (typeof agent?.id === 'string' && agent.id.length > 0) facts.agentId = agent.id;\n const header = (agent as { session?: { header?: { origin?: string; delegationDepth?: number } } })?.session?.header;\n facts.role = header?.origin === 'subagent' ? 'subagent' : 'main';\n if (typeof header?.delegationDepth === 'number') facts.delegationDepth = header.delegationDepth;\n } catch {\n // A synthetic or partially-built agent must never break the request path.\n }\n return facts;\n}\n\n/**\n * Report one effort decision to the two audit surfaces.\n *\n * Both are strictly best-effort: the decision has already been applied to the\n * request, and a full log, a hostile listener, or a detached agent must not turn\n * an audit problem into a failed turn.\n *\n * @param ctx - the plugin context (the emit reaches every subscriber of this host).\n * @param agent - the requesting agent, whose session receives the log record.\n * @param status - the decision payload.\n */\nfunction reportEffort(ctx: Context, agent: Agent, status: ReflexEffortStatus): void {\n appendEffortRecord((agent as { session?: unknown } | undefined)?.session, status);\n try {\n ctx.emit('reflex/effort', status);\n } catch {\n // A status carrier must never be able to veto a turn.\n }\n}\n\n/** Effort id that means \"let System 1 decide the level for this turn\". */\nconst ADAPTIVE_EFFORT_MARKER = 'reflex';\n\n/** Whether one effort value is the adaptive marker (or its accepted alias). */\nfunction isAdaptiveMarker(value: string | undefined): boolean {\n return value === ADAPTIVE_EFFORT_MARKER || value === 'auto';\n}\n\n/** Whether a provider is a virtual route owned by this plugin on this runtime. */\nfunction ownedVirtualProvider(llm: LlmRuntime, provider: string): boolean {\n return OWNED_ROUTES.get(routeScope(llm))?.has(provider) === true;\n}\n\n/**\n * The live policy facts the adaptive-effort surface reads.\n *\n * Kept structural rather than tied to {@link EffortInterceptor}: the surface\n * only needs the two values, and a caller that has them as getters gets the\n * live behaviour for free.\n */\nexport interface AdaptiveEffortPolicySource {\n /** Deployment `reasoningEffort` marker, or `undefined` when none is configured. */\n readonly setting: string | undefined;\n /** Deployment `effort.enabled` switch. */\n readonly enabled: boolean;\n}\n\n/** What {@link installAdaptiveEffortSurface} installed. */\nexport interface AdaptiveEffortSurface {\n /** Whether the deployment defaults virtual routes to the adaptive strategy. */\n readonly adaptive: boolean;\n /** Restore the original runtime methods. */\n dispose: () => void;\n}\n\n/**\n * Teach the LLM runtime that `reflex` is a selectable reasoning effort.\n *\n * This is the S4 fix, and it is deliberately a *runtime* change rather than a\n * plugin-local one: the model selector is built by the Host from\n * `llm.resolveModelInfo(...).reasoning.efforts`, and the selection round trip\n * goes through `llm.resolveCallConfig(...)`. A model therefore \"offers Reflex\n * (Auto)\" exactly when these two calls say so for that exact route.\n *\n * Three surfaces are wrapped:\n *\n * - `resolveModelInfo` gains the `reflex` entry (first, so it reads as the\n * default) for every route that declares at least one real effort. A model\n * that declares none is returned untouched, which is why a non-thinking model\n * shows no effort at all instead of a dead \"Reflex (Auto)\" choice.\n * - `resolveCallConfig` accepts the marker for a thinking model, clears it for a\n * model that cannot think, and injects it only for an owned virtual route\n * when the deployment enables adaptive effort.\n * - `prepareCall` translates any marker that survived to this last gate into\n * something the physical adapter accepts, so no code path can hand\n * `reasoningEffort: \"reflex\"` to a provider that never heard of it.\n *\n * With `effort.enabled` off the surface installs nothing that can be *chosen*:\n * the marker is not appended to any model's effort list, so a selector stops\n * offering \"Reflex (Auto)\", and every path that still carries a marker — a\n * persisted selection, a deployment setting, a hand-built call — has it cleared\n * at the last gate instead of being translated to a level the adapter supports.\n * The runtime is still wrapped rather than left alone, because a marker that\n * survives to `prepareCall` must never reach a physical provider.\n *\n * The two policy facts are read through the live interceptor on every call\n * rather than captured here, so a config-only save (the loader commits new\n * volatile values without remounting the plugin) changes what the selector\n * offers and what an unpinned virtual request inherits on the very next call.\n *\n * @param ctx - plugin context (kept for API compatibility).\n * @param llm - the LLM runtime to extend.\n * @param policy - live effort policy (`setting` + `enabled`) of the activation.\n * @returns the installed surface, whose `dispose()` restores the runtime.\n */\nexport function installAdaptiveEffortSurface(\n _ctx: Context,\n llm: LlmRuntime,\n policy: AdaptiveEffortPolicySource\n): AdaptiveEffortSurface {\n const runtime = llm as unknown as Record<string, unknown>;\n const originalResolveModelInfo = llm.resolveModelInfo.bind(llm);\n const originalResolveCallConfig = llm.resolveCallConfig.bind(llm);\n const originalPrepareCall = llm.prepareCall.bind(llm);\n\n /** Whether one exact route can think at all. */\n const supportsThinking = async (provider: string, model: string, signal?: AbortSignal): Promise<boolean> => {\n try {\n const info = await originalResolveModelInfo(provider, model, signal);\n const efforts = (info as unknown as LlmResolvedModelInfoLike)?.reasoning?.efforts;\n return Array.isArray(efforts) && efforts.length > 0;\n } catch {\n return false;\n }\n };\n\n runtime.resolveModelInfo = async (provider: string, model: string, signal?: AbortSignal) => {\n const info = await originalResolveModelInfo(provider, model, signal);\n // The switch is off: the plugin's own effort option is revoked, so no\n // selector can offer a mode this activation will not honour.\n if (!policy.enabled) return info;\n const reasoning = (info as unknown as LlmResolvedModelInfoLike)?.reasoning;\n if (!reasoning || reasoning.efforts.length === 0) return info;\n const efforts = reasoning.efforts as readonly { id: unknown }[];\n if (efforts.some((effort) => isAdaptiveMarker(String(effort.id)))) return info;\n return {\n ...info,\n reasoning: {\n ...reasoning,\n efforts: [{ id: ADAPTIVE_EFFORT_MARKER, name: 'Reflex (Auto)', description: 'System 1 adaptive reasoning effort, decided per turn' }, ...efforts]\n }\n };\n };\n\n runtime.resolveCallConfig = async (config: LlmCallConfig, signal?: AbortSignal) => {\n const requested = config.reasoningEffort as unknown as string | undefined;\n\n if (!policy.enabled) {\n // Nothing is injected for an owned virtual route, and a marker is stripped\n // instead of accepted: the call resolves with the provider's own default,\n // which is the only \"adaptive effort\" a disabled deployment can have.\n if (!isAdaptiveMarker(requested)) return originalResolveCallConfig(config, signal);\n const cleared = await originalResolveCallConfig(\n { ...config, reasoningEffort: undefined } as LlmCallConfig,\n signal\n );\n return { ...cleared, reasoningEffort: undefined };\n }\n\n if (isAdaptiveMarker(requested)) {\n const resolved = await originalResolveCallConfig(\n { ...config, reasoningEffort: undefined } as LlmCallConfig,\n signal\n );\n // A model that cannot think has no adaptive mode to be in: the marker is\n // dropped rather than forwarded, which is what keeps a non-thinking route\n // from failing with UNSUPPORTED_REASONING_EFFORT.\n if (!(await supportsThinking(resolved.provider, resolved.model, signal))) {\n return { ...resolved, reasoningEffort: undefined };\n }\n return { ...resolved, reasoningEffort: ADAPTIVE_EFFORT_MARKER as LlmCallConfig['reasoningEffort'] };\n }\n\n const resolved = await originalResolveCallConfig(config, signal);\n\n // No session identity is available at this runtime seam. Never infer a\n // physical request's intent from another session's model-selection event.\n // Virtual unpinned requests can inherit the deployment policy; physical\n // adaptive requests must carry their own explicit reflex/auto marker.\n if (requested === undefined && isAdaptiveMarker(policy.setting) &&\n ownedVirtualProvider(llm, resolved.provider)) {\n return { ...resolved, reasoningEffort: ADAPTIVE_EFFORT_MARKER as LlmCallConfig['reasoningEffort'] };\n }\n\n return resolved;\n };\n\n runtime.prepareCall = async (config: LlmCallConfig, signal?: AbortSignal, configure?: unknown) => {\n const requested = config.reasoningEffort as unknown as string | undefined;\n if (!isAdaptiveMarker(requested)) {\n return originalPrepareCall(config, signal, configure as never);\n }\n // Last gate before dispatch: the marker is an intent, never an effort any\n // physical adapter can accept, so it is resolved here for the paths that\n // bypass the `agent/request` interception (hand-built one-shot calls,\n // `prepareCall` consumers). With the switch off there is no policy to\n // resolve it *to*, so it is deleted and the provider default applies.\n if (!policy.enabled) {\n const cleared = { ...config } as LlmCallConfig;\n delete (cleared as { reasoningEffort?: unknown }).reasoningEffort;\n return originalPrepareCall(cleared, signal, configure as never);\n }\n const info = await supportsThinking(config.provider, config.model, signal);\n const aligned = info\n ? await alignReasoningEffort(ADAPTIVE_EFFORT_MARKER, { provider: config.provider, model: config.model }, createReasoningProbe(llm, (provider, model) => originalResolveModelInfo(provider, model, signal)))\n : undefined;\n const next = { ...config } as LlmCallConfig;\n if (aligned === undefined) delete (next as { reasoningEffort?: unknown }).reasoningEffort;\n else next.reasoningEffort = aligned as LlmCallConfig['reasoningEffort'];\n return originalPrepareCall(next, signal, configure as never);\n };\n\n\n try {\n (llm as unknown as { emitAdaptersUpdated?: () => void }).emitAdaptersUpdated?.();\n } catch {\n // A catalog refresh is advisory.\n }\n\n let disposed = false;\n return {\n get adaptive() {\n return policy.enabled && isAdaptiveMarker(policy.setting);\n },\n dispose: () => {\n if (disposed) return;\n disposed = true;\n runtime.resolveModelInfo = originalResolveModelInfo;\n runtime.resolveCallConfig = originalResolveCallConfig;\n runtime.prepareCall = originalPrepareCall;\n try {\n (llm as unknown as { emitAdaptersUpdated?: () => void }).emitAdaptersUpdated?.();\n } catch {\n // Same.\n }\n }\n };\n}\n\n/** The `source` of a DSH message, as far as the notice filter reads it. */\ninterface MessageSourceLike {\n kind?: string;\n form?: string;\n summary?: string;\n}\n\n/** First text block of one message, or `''`. */\nfunction textOfMessage(message: unknown): string {\n const blocks = (message as { content?: readonly ContentBlock[] } | undefined)?.content;\n if (!Array.isArray(blocks)) return '';\n for (const block of blocks) {\n if (block?.type === 'text' && typeof block.text === 'string') return block.text;\n }\n return '';\n}\n\n/**\n * Whether one pre-step message is the model-switch notice for the *virtual* route.\n *\n * Routing a virtual model rewrites the request onto a physical target, so the\n * durable request header records the physical route while the user's selection\n * stays virtual. `installModelSelection` compares exactly those two and — seeing\n * a difference that is not a model change at all — appends \"the session\n * continues with `reflex/…`\" to every step. The notice states something false,\n * it costs context tokens on every single step, and it is not a user action, so\n * it is dropped here.\n *\n * The predicate is deliberately narrow: a genuine physical↔physical switch is\n * left alone, because its notice *is* true and the model needs it to interpret\n * the turns above it.\n *\n * @param message - one admitted pre-step message.\n * @param virtualProvider - the virtual provider route id.\n * @param virtualModels - the virtual model ids.\n * @returns whether the message is the pseudo-switch notice.\n */\nexport function isVirtualModelSwitchNotice(\n message: unknown,\n virtualProvider: string,\n virtualModels: readonly string[]\n): boolean {\n const source = (message as { source?: MessageSourceLike } | undefined)?.source;\n if (source?.kind !== 'model-selection' || source.form !== 'notice') return false;\n\n const summary = typeof source.summary === 'string' ? source.summary : '';\n const text = textOfMessage(message);\n const arrow = summary.lastIndexOf('→');\n const named =\n (arrow >= 0 ? summary.slice(arrow + 1) : '').trim() ||\n (text.match(/continues with ([^\\]]+)\\]/)?.[1] ?? '').trim();\n if (named.length === 0) return false;\n\n if (named.startsWith(`${virtualProvider}/`)) return true;\n if (virtualModels.includes(named)) return true;\n return named.split('/')[0] === virtualProvider;\n}\n\n/**\n * Drop the pseudo-switch notices from one pre-step decision.\n * @param decision - the decision returned by the inner waterfall.\n * @param virtualProvider - the virtual provider route id.\n * @param virtualModels - the virtual model ids.\n * @returns the decision, with the false notices removed when there were any.\n */\nexport function filterVirtualSwitchNotices<T extends { messages?: readonly unknown[] }>(\n decision: T,\n virtualProvider: string,\n virtualModels: readonly string[]\n): T {\n const messages = decision?.messages;\n if (!Array.isArray(messages) || messages.length === 0) return decision;\n const kept = messages.filter((message) => !isVirtualModelSwitchNotice(message, virtualProvider, virtualModels));\n if (kept.length === messages.length) return decision;\n return { ...decision, messages: kept };\n}\n\n/**\n * Install the virtual route and its interception layers.\n * @param ctx - the plugin's context (untagged listeners here observe every agent).\n * @param options - runtime, router, and capture budget.\n * @returns the installation handle; `dispose()` is idempotent.\n */\nexport function installModelRouting(ctx: Context, options: ModelRoutingOptions): ModelRoutingInstallation {\n const { llm } = options;\n const warn = options.warn ?? NOOP;\n const facts = new Map<string, AgentRoutingFacts>();\n\n // The raw lookups are captured before the adaptive-effort surface wraps them:\n // the routing probe must see what a model *declares*, never the `reflex`\n // entry the surface adds for the selector.\n const rawResolveModelInfo = llm.resolveModelInfo.bind(llm);\n const rawProbe = (provider: string, model: string) =>\n rawResolveModelInfo(provider, model) as unknown as Promise<LlmResolvedModelInfoLike>;\n\n const surface = installAdaptiveEffortSurface(ctx, llm, options.effort);\n\n let disposed = false;\n const scope = routeScope(llm);\n const owned = OWNED_ROUTES.get(scope) ?? new Map<string, OwnedRoute>();\n OWNED_ROUTES.set(scope, owned);\n\n /**\n * Whether these listeners may rewrite a request's route. Registering the\n * route and *using* one are different questions: an activation without pools\n * must not fall through to a fails-closed pool it never configured, and it\n * must not steal the policy of the activation that does own the route.\n */\n let routes = false;\n let adapter: ReflexVirtualAdapter | undefined;\n let router = options.router;\n /** The shared route entry this activation holds, when it holds one. */\n let held: OwnedRoute | undefined;\n /** Whether this activation created a provider registration (not merely joined). */\n let created = false;\n /** `registerAdapter` calls made by this activation (diagnostics/idempotence). */\n let registrationEvents = 0;\n\n const readTaskBudget = (): number => {\n const budget = typeof options.maxTaskChars === 'function' ? options.maxTaskChars() : options.maxTaskChars;\n return Number.isFinite(budget) ? Math.max(1, budget) : 400;\n };\n\n const republish = (): void => {\n try { (llm as any).emitAdaptersUpdated?.(); } catch {}\n };\n\n /** Build the adapter for one provider name; the router is shared. */\n const buildAdapter = (provider: string): ReflexVirtualAdapter =>\n new ReflexVirtualAdapter({\n provider,\n router,\n dispatch: (dispatchOptions) => llm.stream(dispatchOptions),\n probeReasoning: createReasoningProbe(llm, rawProbe),\n resolveContextWindow: async (prov, mod) => {\n try {\n const info = await rawResolveModelInfo(prov, mod);\n return (info as any)?.context?.contextWindow;\n } catch {\n return undefined;\n }\n }\n });\n\n /**\n * Register (or join) the route for the router's current provider name.\n *\n * Joining rather than colliding is what lets several activations share the\n * process-wide route: the first registers, the rest increment the owner count\n * and adopt the shared router, whose policy the newest activation replaces.\n */\n const registerRoute = (): void => {\n if (routes || held) return;\n const provider = router.virtualProvider;\n const existing = owned.get(provider);\n if (existing) {\n existing.owners += 1;\n router = existing.adapter.router;\n router.updatePolicy({\n models: options.router.models,\n ...(options.router.fallback ? { fallback: options.router.fallback } : {})\n });\n held = existing;\n routes = true;\n warn(\n `dsh-reflex: virtual route \"${provider}\" is already registered in this process; this activation joins it with its own pool policy`\n );\n republish();\n return;\n }\n if (llm.listProviders().some((entry) => entry.id === provider)) {\n warn(\n `dsh-reflex: provider \"${provider}\" is already registered by another adapter; System 1 model routing stays off for this activation`\n );\n return;\n }\n const nextAdapter = buildAdapter(provider);\n let handle: () => void;\n try {\n // Registered on the *root* context on purpose: the provider route is\n // process-wide, and provider registrations are disposed with the fiber\n // that created them. A registration on this activation's fiber would\n // disappear the moment this activation is released — even while another\n // activation is still routing through the same adapter. The release below\n // is what actually withdraws the route, once the last owner is gone.\n handle = ctx.root.llm.registerAdapter([provider], nextAdapter);\n registrationEvents += 1;\n } catch (error) {\n warn(\n `dsh-reflex: could not register the virtual provider \"${provider}\" (${(error as Error).message}); System 1 model routing stays off`\n );\n return;\n }\n const entry: OwnedRoute = { provider, adapter: nextAdapter, owners: 1, handle };\n owned.set(provider, entry);\n held = entry;\n adapter = nextAdapter;\n created = true;\n routes = true;\n republish();\n };\n\n /**\n * Release this activation's hold on the route.\n *\n * The provider registration is withdrawn only when the last owner goes away;\n * until then the shared adapter and its router stay registered for the other\n * activations.\n */\n const releaseRoute = (): void => {\n const entry = held;\n held = undefined;\n routes = false;\n adapter = undefined;\n if (!entry) return;\n entry.owners -= 1;\n if (entry.owners > 0) return;\n if (owned.get(entry.provider) === entry) owned.delete(entry.provider);\n created = false;\n entry.handle();\n republish();\n };\n\n /**\n * Rename the virtual provider route in place.\n *\n * A rename has to leave no orphan adapter: the new name is registered before\n * the old one is withdrawn (registry names differ, so no duplicate), then the\n * ownership entry moves to the new name. Every activation sharing this route\n * shares the same router object, so mutating its provider name renames the\n * route consistently for all of them; the owner count still decides when the\n * registration is actually withdrawn.\n */\n const renameRoute = (provider: string): void => {\n if (router.virtualProvider === provider) return;\n const entry = held;\n if (!entry) {\n router.setVirtualProvider(provider);\n return;\n }\n const oldProvider = entry.provider;\n const nextAdapter = buildAdapter(provider);\n let handle: () => void;\n try {\n handle = ctx.root.llm.registerAdapter([provider], nextAdapter);\n registrationEvents += 1;\n } catch (error) {\n // Keep routing on the old name rather than leaving the activation with no\n // route at all; the next commit retries.\n warn(\n `dsh-reflex: could not rename the virtual provider to \"${provider}\" (${(error as Error).message}); keeping \"${oldProvider}\"`\n );\n return;\n }\n router.setVirtualProvider(provider);\n entry.handle();\n if (owned.get(oldProvider) === entry) owned.delete(oldProvider);\n entry.provider = provider;\n entry.adapter = nextAdapter;\n entry.handle = handle;\n owned.set(provider, entry);\n adapter = nextAdapter;\n republish();\n };\n\n /**\n * Reconcile the provider lifecycle with one resolved routing policy.\n * @param policy - the policy currently in force.\n */\n const reconcile = (policy: LiveRoutingPolicy): void => {\n if (disposed) return;\n const canRoute = policy.enabled && Object.values(policy.models).some((pool) => pool.length > 0);\n if (!canRoute) {\n releaseRoute();\n router.setVirtualProvider(policy.virtualProvider);\n return;\n }\n if (!held) {\n router.setVirtualProvider(policy.virtualProvider);\n registerRoute();\n return;\n }\n if (router.virtualProvider !== policy.virtualProvider) renameRoute(policy.virtualProvider);\n };\n\n if (options.route === false || !router.hasPools) {\n // Deliberately silent: a deployment that configured no pool asked for the\n // tool surface only, and the effort layer may still be configured.\n } else {\n registerRoute();\n }\n\n const probe = createReasoningProbe(llm, rawProbe);\n const disposers: Array<() => void> = [];\n /** Detachers of the per-agent pseudo-switch filters installed lazily. */\n const agentFilterDisposers: Array<() => void> = [];\n /** Agents that already carry a filter, so a step never installs a second one. */\n const agentFilters = new WeakSet<object>();\n\n disposers.push(\n ctx.on('llm/stream', (options, next) => {\n if (isAgentLoopRequest(options) || (options as any).__reflexLoopOwned === true) {\n markAgentLoopRequest(options);\n }\n return next();\n })\n );\n\n // The pools a virtual model advertises are read from the live router, so a\n // committed routing edit changes what the model picker must show. The runtime\n // refreshes the router first (its listener is registered before this one);\n // this only republishes the catalog. A Host without the loader event simply\n // never calls it.\n disposers.push(\n ctx.on('loader/volatile-update', () => {\n try { (llm as any).emitAdaptersUpdated?.(); } catch {}\n })\n );\n\n disposers.push(\n ctx.on('agent/pre-step', async (payload, next) => {\n try {\n // Cheap liveness: the host that commits config-only saves leaves the\n // resolved config stale until someone asks. The check is a handful of\n // identity comparisons and parses nothing unless the loader committed.\n options.refreshConfig?.();\n ensureVirtualSwitchFilter(payload.agent, router, agentFilterDisposers, agentFilters);\n rememberStep(facts, payload.agent, captureTask(payload.messages, readTaskBudget()), measureMessages(payload.messages));\n } catch {\n // Task capture is advisory: a malformed message must not veto the step.\n }\n return next();\n })\n );\n\n disposers.push(\n ctx.on('agent/request', async (payload, next) => {\n const rawConfig = await next();\n if (!rawConfig || payload.signal?.aborted) return rawConfig;\n const config = resolveAdaptiveIntent(ctx, payload.agent, rawConfig, (provider) => router.owns(provider));\n\n const remembered = recallFacts(facts, payload.agent);\n const requested = config.reasoningEffort as unknown as string | undefined;\n const task = remembered?.task;\n\n // With `effort.enabled` off this layer manages no effort at all: it still\n // routes, but the only edit it is allowed to make to `reasoningEffort` is\n // removing its own marker. That keeps a concrete level byte-identical on\n // its way to the adapter, and it means no decision, no audit entry and no\n // status can be produced for a deployment that switched the layer off.\n const effortOff = options.effort.enabled === false;\n\n // Reflex only automatically adapts reasoning effort when the effort was\n // explicitly chosen as reflex/auto, or when an unpinned request names the\n // virtual provider (which defaults to adaptive effort). If the user selected\n // High, Low, Medium, Off, or Provider Default, reflex does not touch effort.\n const isAdaptive =\n !effortOff &&\n (isAdaptiveMarker(requested) ||\n (requested === undefined && router.owns(config.provider) && isAdaptiveMarker(options.effort.setting)));\n\n // Same-turn follow-up steps (step > 1 without new user text) reuse the turn's\n // decision: no second System 1 call, no second effort event, 0ms latency.\n const isFollowupStep =\n (payload.step ?? 1) > 1 &&\n remembered?.decided !== undefined &&\n remembered.decided.turn === payload.turn &&\n remembered.stepHasText !== true &&\n // A config-only save may replace the policy mid-turn; a decision taken\n // under the previous policy is not this turn's answer any more.\n remembered.decided.generation === options.effort.generation;\n\n if (isAdaptive && isFollowupStep && remembered?.decided) {\n const reuse = remembered.decided;\n const routedReuse =\n routes && router.owns(config.provider)\n ? { ...config, provider: reuse.provider, model: reuse.model }\n : config;\n const effort = reuse.effort;\n if (effort === requested && routedReuse === config) return config;\n const rewritten: LlmCallConfig = { ...routedReuse };\n if (effort === undefined) delete (rewritten as { reasoningEffort?: unknown }).reasoningEffort;\n else rewritten.reasoningEffort = effort as LlmCallConfig['reasoningEffort'];\n return rewritten;\n }\n\n let routed = config;\n let switched: boolean | undefined;\n let heldForCache: boolean | undefined;\n if (routes && router.owns(config.provider)) {\n const decision = await router.routeModel({\n provider: config.provider,\n model: config.model,\n task,\n ...describeAgent(payload.agent),\n turn: payload.turn,\n step: payload.step,\n // Cache-affinity facts: the model this session already holds and how\n // much context it is defending.\n ...(remembered?.currentModel ? { currentModel: remembered.currentModel } : {}),\n ...(remembered === undefined ? {} : { contextChars: remembered.contextChars }),\n contextTokens: estimateContextTokens(remembered?.contextChars ?? 0)\n });\n routed = { ...config, provider: decision.target.provider, model: decision.target.model };\n switched = decision.switched;\n heldForCache = decision.reason === 'sticky-affinity';\n rememberTarget(facts, payload.agent, decision.target);\n }\n\n if (!isAdaptive) {\n if (effortOff) {\n // Transparent pass-through: the request keeps the caller's own level\n // (never aligned, never snapped onto the routed model's vocabulary),\n // and the plugin's marker is deleted instead of being translated — the\n // adapter then applies the provider default, which is the only safe\n // reading of \"reflex\" once the adaptive layer is switched off.\n const kept = isAdaptiveMarker(requested) ? undefined : requested;\n if (routed === config && kept === requested) return config;\n const rewritten: LlmCallConfig = { ...routed };\n if (kept === undefined) delete (rewritten as { reasoningEffort?: unknown }).reasoningEffort;\n else rewritten.reasoningEffort = kept as LlmCallConfig['reasoningEffort'];\n return rewritten;\n }\n // Concrete effort (high, low, off...) or provider default: align if needed, never adapt!\n if (routed === config && requested !== undefined) {\n const aligned = await alignReasoningEffort(requested, { provider: routed.provider, model: routed.model }, probe);\n if (aligned === requested) return config;\n const rewritten: LlmCallConfig = { ...routed };\n if (aligned !== undefined) rewritten.reasoningEffort = aligned as LlmCallConfig['reasoningEffort'];\n else delete (rewritten as { reasoningEffort?: unknown }).reasoningEffort;\n return rewritten;\n }\n if (routed !== config) {\n const aligned = requested ? await alignReasoningEffort(requested, { provider: routed.provider, model: routed.model }, probe) : undefined;\n const rewritten: LlmCallConfig = { ...routed };\n if (aligned !== undefined) rewritten.reasoningEffort = aligned as LlmCallConfig['reasoningEffort'];\n else delete (rewritten as { reasoningEffort?: unknown }).reasoningEffort;\n return rewritten;\n }\n return config;\n }\n\n const resolution = await options.effort.resolve({\n requested,\n target: { provider: routed.provider, model: routed.model },\n probe,\n task,\n agent: describeAgent(payload.agent),\n turn: payload.turn,\n step: payload.step,\n requestedProvider: config.provider,\n requestedModel: config.model,\n ...(switched === undefined ? {} : { switched }),\n ...(heldForCache === undefined ? {} : { heldForCache })\n });\n\n if (resolution.status) {\n reportEffort(ctx, payload.agent, resolution.status);\n rememberDecision(facts, payload.agent, payload.turn, routed, resolution, options.effort.generation);\n }\n if (!resolution.changed && routed === config) return config;\n\n const rewritten: LlmCallConfig = { ...routed };\n // Only requests that carried an effort — or whose effort this layer just\n // decided — get one back. A cleared effort deletes the key instead of\n // leaving an `undefined` one behind: a request that never asked for an\n // effort must look exactly as it did before the interception.\n const effort = resolution.changed ? resolution.effort : requested;\n if (config.reasoningEffort !== undefined || resolution.changed) {\n if (effort === undefined) delete (rewritten as { reasoningEffort?: unknown }).reasoningEffort;\n else rewritten.reasoningEffort = effort as LlmCallConfig['reasoningEffort'];\n }\n\n return rewritten;\n }, { prepend: true })\n );\n\n const dispose = () => {\n if (disposed) return;\n disposed = true;\n for (const detach of disposers.reverse()) detach();\n disposers.length = 0;\n for (const detach of agentFilterDisposers.splice(0)) detach();\n facts.clear();\n surface.dispose();\n releaseRoute();\n };\n\n return {\n get router() {\n return router;\n },\n get adapter() {\n return adapter;\n },\n get registered() {\n return created;\n },\n get registrationEvents() {\n return registrationEvents;\n },\n refresh(policy: LiveRoutingPolicy): void {\n reconcile(policy);\n },\n dispose\n };\n}\n\n/**\n * Join the text blocks of the user messages admitted to one step.\n * @param messages - messages carried by `agent/pre-step`.\n * @param budget - maximum characters to keep.\n * @returns the joined task text, or `undefined` when the step carries no text.\n */\nfunction captureTask(messages: readonly UserMessage[], budget: number): string | undefined {\n const limit = Math.max(1, budget);\n const parts: string[] = [];\n let length = 0;\n\n for (const message of messages ?? []) {\n for (const block of (message?.content ?? []) as readonly ContentBlock[]) {\n if (block.type !== 'text' || typeof block.text !== 'string') continue;\n const text = block.text.trim();\n if (text.length === 0) continue;\n parts.push(text);\n length += text.length;\n if (length >= limit) break;\n }\n if (length >= limit) break;\n }\n\n return parts.length === 0 ? undefined : parts.join('\\n').slice(0, limit);\n}\n\n/**\n * Remember one agent's latest step, keeping the map bounded.\n *\n * A step that carries no text still counts towards the session's size and must\n * not erase the task the agent is working on, so the two facts are updated\n * independently.\n *\n * @param facts - the per-installation facts map.\n * @param agent - the agent proposing the step.\n * @param text - the captured task text, when the step carried any.\n * @param chars - characters of step input observed.\n */\nfunction rememberStep(facts: Map<string, AgentRoutingFacts>, agent: Agent, text: string | undefined, chars: number): void {\n const key = agentKey(agent);\n if (key === undefined) return;\n const previous = facts.get(key);\n const next: AgentRoutingFacts = {\n ...(text ?? previous?.task ? { task: text ?? previous?.task } : {}),\n ...(previous?.currentModel ? { currentModel: previous.currentModel } : {}),\n contextChars: (previous?.contextChars ?? 0) + Math.max(0, Math.round(chars)),\n stepHasText: text !== undefined,\n ...(previous?.decided ? { decided: previous.decided } : {}),\n ...(previous?.lastAdaptiveEffort ? { lastAdaptiveEffort: previous.lastAdaptiveEffort } : {})\n };\n facts.delete(key);\n facts.set(key, next);\n while (facts.size > MAX_TRACKED_AGENTS) {\n const oldest = facts.keys().next();\n if (oldest.done) break;\n facts.delete(oldest.value);\n }\n}\n\n/**\n * Remember one turn's decision so its later steps cost nothing.\n *\n * Only an *adaptive* decision is cached: a request that carries its own\n * concrete level needs no decision at all, and caching it would turn the\n * caller's explicit choice into a per-step replay of a value the request\n * already carries.\n *\n * @param facts - the per-installation facts map.\n * @param agent - the requesting agent.\n * @param turn - the turn the decision belongs to.\n * @param routed - the call configuration the decision was taken for.\n * @param resolution - the effort resolution, carrying the status when decided.\n * @param generation - effort policy version the decision was taken under.\n */\nfunction rememberDecision(\n facts: Map<string, AgentRoutingFacts>,\n agent: Agent,\n turn: number | undefined,\n routed: LlmCallConfig,\n resolution: EffortResolution,\n generation: number\n): void {\n const key = agentKey(agent);\n if (key === undefined) return;\n const status = resolution.status;\n const decision: TurnDecision = {\n turn: turn ?? 0,\n provider: routed.provider,\n model: routed.model,\n ...(resolution.effort === undefined ? {} : { effort: resolution.effort }),\n ...(status === undefined ? {} : { status }),\n generation\n };\n const previous = facts.get(key);\n facts.delete(key);\n facts.set(key, {\n ...(previous?.task ? { task: previous.task } : {}),\n ...(previous?.currentModel ? { currentModel: previous.currentModel } : {}),\n contextChars: previous?.contextChars ?? 0,\n ...(previous?.stepHasText === undefined ? {} : { stepHasText: previous.stepHasText }),\n decided: decision,\n // An echo is only recognisable when this layer, not the user, chose the\n // effort — so the marker is recorded for adaptive decisions alone.\n ...(resolution.decision ? { lastAdaptiveEffort: resolution.effort } : {})\n });\n}\n\n/**\n * Re-publish one reused decision for a later step of the same turn.\n * @param decision - the turn's decision.\n * @param turn - the step's turn.\n * @param step - the step number.\n * @returns a status carrying this step's numbers, or `undefined` when none was published.\n */\nfunction statusForStep(\n decision: TurnDecision,\n turn: number | undefined,\n step: number | undefined\n): ReflexEffortStatus | undefined {\n if (!decision.status) return undefined;\n const status: ReflexEffortStatus = {\n ...decision.status,\n latencyMs: 0,\n at: Date.now(),\n ...(turn === undefined ? {} : { turn }),\n ...(step === undefined ? {} : { step })\n };\n return { ...status, line: formatEffortStatusLine(status) };\n}\n\n/**\n * Install the pseudo-switch filter on one agent's own context, once.\n *\n * Placement is the whole point. `installModelSelection` registers its notice\n * listener with `prepend` on the *agent* context, so it is the outermost\n * `agent/pre-step` wrapper and appends its notice after every other listener\n * returned. Registering this filter later, also with `prepend` but on that same\n * agent context, puts it at the front again, so it becomes the one wrapper that\n * sees the notice and can drop it. The first step of a turn never receives a\n * notice, which is exactly the step on which this filter gets installed.\n *\n * @param agent - the agent proposing the step.\n * @param router - the routing policy, naming the virtual route.\n * @param disposers - collector for the detachers.\n * @param installed - guard so one agent never gets two filters.\n */\nfunction ensureVirtualSwitchFilter(\n agent: Agent,\n router: VirtualModelRouter,\n disposers: Array<() => void>,\n installed: WeakSet<object>\n): void {\n const target = agent as unknown as object;\n if (!target || installed.has(target)) return;\n const agentCtx = (agent as { ctx?: Context }).ctx;\n if (!agentCtx || typeof agentCtx.on !== 'function') return;\n\n installed.add(target);\n try {\n const detach = agentCtx.on(\n 'agent/pre-step',\n (async (_payload: { agent: Agent }, next: () => Promise<unknown>) => {\n const decision = await next();\n return filterVirtualSwitchNotices(\n decision as { messages?: readonly unknown[] },\n router.virtualProvider,\n router.modelIds\n );\n }) as never,\n { prepend: true }\n );\n disposers.push(detach as unknown as () => void);\n } catch {\n // A synthetic or torn-down agent context must never break a step.\n installed.delete(target);\n }\n}\n\n/**\n * Remember the physical model one agent's request was routed onto.\n *\n * This is what the next decision defends: the model whose prompt prefix the\n * session has already paid to cache.\n *\n * @param facts - the per-installation facts map.\n * @param agent - the requesting agent.\n * @param target - the physical route the request was rewritten to.\n */\nfunction rememberTarget(facts: Map<string, AgentRoutingFacts>, agent: Agent, target: PhysicalTarget): void {\n const key = agentKey(agent);\n if (key === undefined) return;\n const previous = facts.get(key);\n facts.delete(key);\n facts.set(key, {\n ...(previous?.task ? { task: previous.task } : {}),\n currentModel: { provider: target.provider, model: target.model },\n contextChars: previous?.contextChars ?? 0,\n ...(previous?.stepHasText === undefined ? {} : { stepHasText: previous.stepHasText }),\n ...(previous?.decided ? { decided: previous.decided } : {}),\n ...(previous?.lastAdaptiveEffort ? { lastAdaptiveEffort: previous.lastAdaptiveEffort } : {})\n });\n}\n\n/**\n * Recall what one activation knows about one agent.\n * @param facts - the per-installation facts map.\n * @param agent - the requesting agent.\n * @returns the remembered task, current model and context size, when any.\n */\nfunction recallFacts(facts: Map<string, AgentRoutingFacts>, agent: Agent): AgentRoutingFacts | undefined {\n const key = agentKey(agent);\n return key === undefined ? undefined : facts.get(key);\n}\n\n/**\n * Count the text carried by one step's messages, without truncation.\n *\n * The task text is capped for the prompt; the session size must not be, or a\n * long session would look as small as the first turn forever.\n *\n * @param messages - messages carried by `agent/pre-step`.\n * @returns the number of characters of text, or `0`.\n */\nfunction measureMessages(messages: readonly UserMessage[]): number {\n let length = 0;\n for (const message of messages ?? []) {\n for (const block of (message?.content ?? []) as readonly ContentBlock[]) {\n if (block.type !== 'text' || typeof block.text !== 'string') continue;\n length += block.text.length;\n }\n }\n return length;\n}\n\n/**\n * Stable key for one agent.\n * @param agent - the agent to key.\n * @returns its id, or `undefined` when it has none.\n */\nfunction agentKey(agent: Agent): string | undefined {\n try {\n return typeof agent?.id === 'string' && agent.id.length > 0 ? agent.id : undefined;\n } catch {\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../src/routing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAA4E,MAAM,sBAAsB,CAAC;AAG1J,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAA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O,IAAI,EAAE,CAA4B,EAAE,CAAC;YACxE,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;gBAAE,SAAS;YACtE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,KAAY;IAC5B,IAAI,CAAC;QACH,OAAO,OAAO,KAAK,EAAE,EAAE,KAAK,QAAQ,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { Agent } from '@deepseek-ai/dsh-agent';\nimport { isAgentLoopRequest, markAgentLoopRequest, type ContentBlock, type LlmCallConfig, type LlmRuntime, type UserMessage } from '@deepseek-ai/dsh-llm';\n\nimport type { EffortInterceptor, EffortResolution, ReflexEffortStatus } from './effort.js';\nimport { formatEffortStatusLine, EFFORT_CONTEXT_TURNS } from './effort.js';\nimport { appendEffortRecord } from './session-audit.js';\nimport { resolveAdaptiveIntent } from './adaptive-intent.js';\nimport type { PhysicalTarget, ReasoningProbe, RouteContext, VirtualModelRouter } from './router.js';\nimport { alignReasoningEffort, estimateContextTokens } from './router.js';\nimport { ReflexVirtualAdapter } from './virtual-adapter.js';\n\n/**\n * Install the virtual provider route and the interception layers that route its\n * requests through System 1.\n *\n * Layer 1 — `agent/pre-step` (waterfall): the loop fixes the step's route and\n * reasoning effort from `this.model.current()` *before* it dispatches anything,\n * and `agent/request` may no longer propose a different one (DSH 0.2.2 rejects\n * it: \"a replacement may adjust controls but must keep the provider, model, and\n * reasoning effort selection\"). So the decision is taken here instead, and\n * written into `payload.modelSelection` — the same object `dsh-agent-loop`\n * keeps as its local `selection`, which is what `prepareRequest` compares the\n * request against. See {@link installModelRouting} for why that write is safe.\n *\n * Layer 2 — the same decision chooses the turn's reasoning effort. A selection\n * carrying the `reflex`/`auto` marker (or a deployment that configured the\n * marker) has no physical effort id yet; {@link EffortInterceptor} turns it into\n * one, projects it onto the routed model's vocabulary, audits it in the session\n * log, and publishes it to the status feed. A selection that named a concrete\n * effort is only re-worded to fit the routed model — never adapted.\n *\n * Layer 3 — the virtual adapter's `stream()`: anything that does not pass\n * through layer 1 (hand-built one-shot calls, `prepareCall()` consumers) is\n * routed at dispatch time and delegated to the physical adapter through\n * `ctx.llm.stream`.\n *\n * The task text each decision reasons about is the step's own user messages: a\n * subagent's first step carries its delegated task, so a delegated agent routes\n * on *its own* task rather than inheriting its parent's decision.\n *\n * The listener also accumulates each agent's *session size* (characters of step\n * input seen so far), and every routed step remembers the physical model it\n * landed on. Both ride into the next decision as cache-affinity facts, so a\n * session that already holds a warm prompt prefix is not moved onto another\n * physical model for a marginal score difference.\n *\n * `agent/request` is still listened to, but strictly read-only: it awaits the\n * rest of the waterfall and hands the configuration back untouched. It is kept\n * because the listener is the only place that can *observe* the configuration\n * the loop really uses, and a future audit may want it — it must never write a\n * field again.\n *\n * @module dsh-reflex/routing\n */\n\n/** Dependencies of {@link installModelRouting}. */\nexport interface ModelRoutingOptions {\n /** LLM runtime to register the virtual route on and dispatch through. */\n llm: LlmRuntime;\n /** Pool policy and System 1 decision seam. */\n router: VirtualModelRouter;\n /** Per-turn adaptive reasoning-effort policy. */\n effort: EffortInterceptor;\n /**\n * Whether this activation should register the virtual provider route. `false`\n * (a deployment with routing disabled, or with no pool) still installs the\n * request listeners, so the adaptive-effort layer keeps working, but never\n * registers a route or rewrites one. Defaults to `true`.\n */\n route?: boolean;\n /**\n * Task-text budget captured from `agent/pre-step` (characters).\n *\n * A getter keeps the budget live: a config-only save may change\n * `routing.maxTaskChars` between steps, and the next step must capture with\n * the new value before the schema is re-resolved.\n */\n maxTaskChars: number | (() => number);\n /**\n * Read the live routing policy for the enable/disable and rename lifecycle.\n * Omitted means the initial {@link route} decision is final.\n */\n liveRouting?: () => LiveRoutingPolicy;\n /**\n * Pull the activation's live config, if the host commits config-only saves.\n *\n * Called once at the start of every `agent/pre-step`: the implementation\n * compares the volatile snapshot identities and re-resolves only when the\n * loader actually committed a change, so an unchanged step pays a handful of\n * identity comparisons and no schema run. This is what makes an effort-only\n * deployment (no route to refresh lazily) pick up a settings edit on its next\n * step even if the event were missed.\n */\n refreshConfig?: () => unknown;\n /** Diagnostic sink for non-fatal degradation (never throws). */\n warn?: (message: string) => void;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Events {\n /**\n * One adaptive reasoning-effort decision was applied to a request. Fired for\n * every decided turn; carries the same payload that is committed to the\n * session log, so a status bar and the audit trail cannot disagree.\n * @param payload - the decided level, the effort dispatched, and the evidence.\n * @mode emit\n */\n 'reflex/effort'(payload: ReflexEffortStatus): void;\n }\n}\n\n/** Routing policy facts the lifecycle reconciler reads. */\nexport interface LiveRoutingPolicy {\n /** Deployment `routing.enabled` switch. */\n enabled: boolean;\n /** Current virtual provider route id. */\n virtualProvider: string;\n /** Task capture budget in characters. */\n maxTaskChars: number;\n /** Pools that decide whether a route can be installed at all. */\n models: import('./router.js').ModelPools;\n}\n\n/** What {@link installModelRouting} installed. */\nexport interface ModelRoutingInstallation {\n /**\n * The router actually in force. With several activations on one runtime the\n * first activation owns the process-wide virtual route and later activations\n * route through the owner's policy, so every path agrees on the pools.\n */\n router: VirtualModelRouter;\n /** The adapter registered for the virtual route, when this activation owns it (live). */\n readonly adapter?: ReflexVirtualAdapter;\n /** Whether this call registered the virtual provider route itself. */\n readonly registered: boolean;\n /** How many `registerAdapter` calls this activation has made in total. */\n readonly registrationEvents: number;\n /**\n * Apply a freshly resolved routing policy: register/unregister the route and\n * rename the virtual provider to match. Idempotent; a same-value refresh\n * touches no registration.\n */\n refresh(policy: LiveRoutingPolicy): void;\n /** Detach the listeners and release the route when this call owned it. */\n dispose: () => void;\n}\n\n/** Nothing to undo. */\nconst NOOP = (): void => {};\n\n/**\n * One process-wide virtual route this plugin has registered.\n *\n * `owners` counts the activations that still route through it. Two activations\n * exist at once when a reload is applied as \"create the new activation, then\n * dispose the old one\" (or with two entries of the same plugin). The provider\n * route must survive the first release in that ordering, and the newest\n * activation's policy must be the one in force — otherwise the new activation\n * routes on the old, about-to-be-released pools and then loses the route\n * entirely once the old activation disposes.\n *\n * There is deliberately one shared {@link ReflexVirtualAdapter} whose router all\n * owners route through: two `agent/pre-step` listeners each deciding a step's\n * route cannot hold two different policies, because the outer one runs after the\n * inner one already wrote its decision into the same selection object.\n */\ninterface OwnedRoute {\n /** Provider route this entry is registered under. */\n provider: string;\n /** The registered adapter, shared by every owner. */\n adapter: ReflexVirtualAdapter;\n /** Live activations routing through this adapter. */\n owners: number;\n /** Unregister the provider route, called when the last owner goes away. */\n handle: () => void;\n}\n\n/**\n * Stable process-wide identity of one LLM runtime.\n *\n * The service handle a context hands out (`ctx.llm`) is a fresh tracing wrapper\n * on every read, so it must never be a map key: two activations would each see\n * \"no route yet\" and the second would collide with `DUPLICATE_ADAPTER`. The\n * wrapper's owning root context is stable for every read of the same runtime.\n * @param llm - the runtime handle the activation was given.\n * @returns a key that is the same object for every activation on that runtime.\n */\nfunction routeScope(llm: LlmRuntime): object {\n const root = (llm as unknown as { ctx?: { root?: object } }).ctx?.root;\n return root ?? (llm as unknown as object);\n}\n\n/**\n * Virtual routes already owned in this process, keyed by the root context of\n * the LLM runtime that holds them. A DSH deployment can activate this plugin\n * more than once (one activation per tool prefix); provider routes are\n * process-wide, so the first activation registers and the rest join its route\n * instead of colliding with `DUPLICATE_ADAPTER`.\n */\nconst OWNED_ROUTES = new WeakMap<object, Map<string, OwnedRoute>>();\n\n/** Most agent-scoped tasks retained for routing; bounded so a long session cannot grow without limit. */\nconst MAX_TRACKED_AGENTS = 64;\n\n/**\n * What one activation remembers about one agent between requests.\n *\n * `contextChars` is the running character count of the step input this\n * activation has observed for the agent — a monotone lower bound on the\n * session's real context (assistant and tool text are produced after the step\n * that caused them). It is deliberately an observation, not a session-log\n * read: routing must not depend on the session module's internal event shapes.\n */\ninterface AgentRoutingFacts {\n /** Task text captured on the agent's latest step. */\n task?: string;\n /** Physical model the agent's latest routed request landed on. */\n currentModel?: PhysicalTarget;\n /** Characters of step input observed for this agent so far. */\n contextChars: number;\n /** The decision this turn already made, reused by its later steps. */\n decided?: TurnDecision;\n /** Adaptive effort this layer dispatched most recently, used to recognise a header echo. */\n lastAdaptiveEffort?: string;\n /**\n * One entry per earlier turn that carried user text, oldest first — the\n * observed turn text the continuation path may grade a short reply against.\n *\n * This is an *observation* like every other fact here, not a session-log read:\n * routing must not depend on the session module's internal event shapes. Only\n * the turn number and the captured text are kept, and the list is bounded by\n * the effort layer's own window, so a long session cannot grow it without limit.\n */\n turns?: TrackedTurn[];\n}\n\n/** One earlier turn's captured task text. */\ninterface TrackedTurn {\n /** Turn the text was observed on. */\n turn: number;\n /** Joined user text of that turn, as captured by `agent/pre-step`. */\n text: string;\n}\n\n/** One decided turn, kept so a same-turn follow-up step costs nothing. */\ninterface TurnDecision {\n turn: number;\n provider: string;\n model: string;\n /**\n * Virtual model the decision was taken for.\n *\n * A later step of the same turn reuses the decision only when it names the\n * same virtual model: a caller that selects a different model mid-turn asked\n * for a different pool, and replaying the old target would ignore that.\n */\n virtualModel?: string;\n /** Effort the rewritten request carried; `undefined` when the key was cleared. */\n effort?: string;\n /** The published status of that decision. */\n status?: ReflexEffortStatus;\n /**\n * Effort policy generation the decision was taken under.\n *\n * A config-only save can land mid-turn; a follow-up step may reuse the cached\n * decision only when no policy change happened between them, otherwise the\n * new `fallback`/`minConfidence`/switch would be shadowed by a decision the\n * user already replaced.\n */\n generation?: number;\n}\n\n/**\n * Read the reasoning-effort vocabulary of one physical route.\n * @param llm - the runtime that owns the adapter for the target.\n * @param resolve - raw model-info lookup; defaults to the runtime's own.\n * @returns a probe that never throws.\n */\nfunction createReasoningProbe(llm: LlmRuntime, resolve?: (provider: string, model: string) => Promise<LlmResolvedModelInfoLike>): ReasoningProbe {\n const lookup = resolve ?? ((provider: string, model: string) => llm.resolveModelInfo(provider, model) as unknown as Promise<LlmResolvedModelInfoLike>);\n return async (target) => {\n let info;\n try {\n info = await lookup(target.provider, target.model);\n } catch {\n return { kind: 'unknown' };\n }\n const reasoning = info?.reasoning;\n if (!reasoning || reasoning.efforts.length === 0) return { kind: 'none' };\n return {\n kind: 'declared',\n efforts: reasoning.efforts.map((effort) => effort.id as unknown as string),\n ...(reasoning.defaultEffort ? { defaultEffort: reasoning.defaultEffort as unknown as string } : {})\n };\n };\n}\n\n/** The slice of a resolved model the reasoning probe reads. */\ninterface LlmResolvedModelInfoLike {\n reasoning?: { efforts: readonly { id: unknown }[]; defaultEffort?: unknown };\n}\n\n/**\n * Agent identity facts the routing decision records.\n * @param agent - the requesting agent (possibly a synthetic test double).\n * @returns the audit attribution, never throwing.\n */\nfunction describeAgent(agent: Agent): Pick<RouteContext, 'agentId' | 'role' | 'delegationDepth'> {\n const facts: Pick<RouteContext, 'agentId' | 'role' | 'delegationDepth'> = {};\n try {\n if (typeof agent?.id === 'string' && agent.id.length > 0) facts.agentId = agent.id;\n const header = (agent as { session?: { header?: { origin?: string; delegationDepth?: number } } })?.session?.header;\n facts.role = header?.origin === 'subagent' ? 'subagent' : 'main';\n if (typeof header?.delegationDepth === 'number') facts.delegationDepth = header.delegationDepth;\n } catch {\n // A synthetic or partially-built agent must never break the request path.\n }\n return facts;\n}\n\n/**\n * Report one effort decision to the two audit surfaces.\n *\n * Both are strictly best-effort: the decision has already been applied to the\n * request, and a full log, a hostile listener, or a detached agent must not turn\n * an audit problem into a failed turn.\n *\n * @param ctx - the plugin context (the emit reaches every subscriber of this host).\n * @param agent - the requesting agent, whose session receives the log record.\n * @param status - the decision payload.\n */\nfunction reportEffort(ctx: Context, agent: Agent, status: ReflexEffortStatus): void {\n appendEffortRecord((agent as { session?: unknown } | undefined)?.session, status);\n try {\n ctx.emit('reflex/effort', status);\n } catch {\n // A status carrier must never be able to veto a turn.\n }\n}\n\n/** Effort id that means \"let System 1 decide the level for this turn\". */\nconst ADAPTIVE_EFFORT_MARKER = 'reflex';\n\n/** Whether one effort value is the adaptive marker (or its accepted alias). */\nfunction isAdaptiveMarker(value: string | undefined): boolean {\n return value === ADAPTIVE_EFFORT_MARKER || value === 'auto';\n}\n\n/** Whether a provider is a virtual route owned by this plugin on this runtime. */\nfunction ownedVirtualProvider(llm: LlmRuntime, provider: string): boolean {\n return OWNED_ROUTES.get(routeScope(llm))?.has(provider) === true;\n}\n\n/**\n * The live policy facts the adaptive-effort surface reads.\n *\n * Kept structural rather than tied to {@link EffortInterceptor}: the surface\n * only needs the two values, and a caller that has them as getters gets the\n * live behaviour for free.\n */\nexport interface AdaptiveEffortPolicySource {\n /** Deployment `reasoningEffort` marker, or `undefined` when none is configured. */\n readonly setting: string | undefined;\n /** Deployment `effort.enabled` switch. */\n readonly enabled: boolean;\n}\n\n/** What {@link installAdaptiveEffortSurface} installed. */\nexport interface AdaptiveEffortSurface {\n /** Whether the deployment defaults virtual routes to the adaptive strategy. */\n readonly adaptive: boolean;\n /** Restore the original runtime methods. */\n dispose: () => void;\n}\n\n/**\n * Teach the LLM runtime that `reflex` is a selectable reasoning effort.\n *\n * This is the S4 fix, and it is deliberately a *runtime* change rather than a\n * plugin-local one: the model selector is built by the Host from\n * `llm.resolveModelInfo(...).reasoning.efforts`, and the selection round trip\n * goes through `llm.resolveCallConfig(...)`. A model therefore \"offers Reflex\n * (Auto)\" exactly when these two calls say so for that exact route.\n *\n * Three surfaces are wrapped:\n *\n * - `resolveModelInfo` gains the `reflex` entry (first, so it reads as the\n * default) for every route that declares at least one real effort. A model\n * that declares none is returned untouched, which is why a non-thinking model\n * shows no effort at all instead of a dead \"Reflex (Auto)\" choice.\n * - `resolveCallConfig` accepts the marker for a thinking model, clears it for a\n * model that cannot think, and injects it only for an owned virtual route\n * when the deployment enables adaptive effort.\n * - `prepareCall` translates any marker that survived to this last gate into\n * something the physical adapter accepts, so no code path can hand\n * `reasoningEffort: \"reflex\"` to a provider that never heard of it.\n *\n * With `effort.enabled` off the surface installs nothing that can be *chosen*:\n * the marker is not appended to any model's effort list, so a selector stops\n * offering \"Reflex (Auto)\", and every path that still carries a marker — a\n * persisted selection, a deployment setting, a hand-built call — has it cleared\n * at the last gate instead of being translated to a level the adapter supports.\n * The runtime is still wrapped rather than left alone, because a marker that\n * survives to `prepareCall` must never reach a physical provider.\n *\n * The two policy facts are read through the live interceptor on every call\n * rather than captured here, so a config-only save (the loader commits new\n * volatile values without remounting the plugin) changes what the selector\n * offers and what an unpinned virtual request inherits on the very next call.\n *\n * @param ctx - plugin context (kept for API compatibility).\n * @param llm - the LLM runtime to extend.\n * @param policy - live effort policy (`setting` + `enabled`) of the activation.\n * @returns the installed surface, whose `dispose()` restores the runtime.\n */\nexport function installAdaptiveEffortSurface(\n _ctx: Context,\n llm: LlmRuntime,\n policy: AdaptiveEffortPolicySource\n): AdaptiveEffortSurface {\n const runtime = llm as unknown as Record<string, unknown>;\n const originalResolveModelInfo = llm.resolveModelInfo.bind(llm);\n const originalResolveCallConfig = llm.resolveCallConfig.bind(llm);\n const originalPrepareCall = llm.prepareCall.bind(llm);\n\n /** Whether one exact route can think at all. */\n const supportsThinking = async (provider: string, model: string, signal?: AbortSignal): Promise<boolean> => {\n try {\n const info = await originalResolveModelInfo(provider, model, signal);\n const efforts = (info as unknown as LlmResolvedModelInfoLike)?.reasoning?.efforts;\n return Array.isArray(efforts) && efforts.length > 0;\n } catch {\n return false;\n }\n };\n\n runtime.resolveModelInfo = async (provider: string, model: string, signal?: AbortSignal) => {\n const info = await originalResolveModelInfo(provider, model, signal);\n // The switch is off: the plugin's own effort option is revoked, so no\n // selector can offer a mode this activation will not honour.\n if (!policy.enabled) return info;\n const reasoning = (info as unknown as LlmResolvedModelInfoLike)?.reasoning;\n if (!reasoning || reasoning.efforts.length === 0) return info;\n const efforts = reasoning.efforts as readonly { id: unknown }[];\n if (efforts.some((effort) => isAdaptiveMarker(String(effort.id)))) return info;\n return {\n ...info,\n reasoning: {\n ...reasoning,\n efforts: [{ id: ADAPTIVE_EFFORT_MARKER, name: 'Reflex (Auto)', description: 'System 1 adaptive reasoning effort, decided per turn' }, ...efforts]\n }\n };\n };\n\n runtime.resolveCallConfig = async (config: LlmCallConfig, signal?: AbortSignal) => {\n const requested = config.reasoningEffort as unknown as string | undefined;\n\n if (!policy.enabled) {\n // Nothing is injected for an owned virtual route, and a marker is stripped\n // instead of accepted: the call resolves with the provider's own default,\n // which is the only \"adaptive effort\" a disabled deployment can have.\n if (!isAdaptiveMarker(requested)) return originalResolveCallConfig(config, signal);\n const cleared = await originalResolveCallConfig(\n { ...config, reasoningEffort: undefined } as LlmCallConfig,\n signal\n );\n return { ...cleared, reasoningEffort: undefined };\n }\n\n if (isAdaptiveMarker(requested)) {\n const resolved = await originalResolveCallConfig(\n { ...config, reasoningEffort: undefined } as LlmCallConfig,\n signal\n );\n // A model that cannot think has no adaptive mode to be in: the marker is\n // dropped rather than forwarded, which is what keeps a non-thinking route\n // from failing with UNSUPPORTED_REASONING_EFFORT.\n if (!(await supportsThinking(resolved.provider, resolved.model, signal))) {\n return { ...resolved, reasoningEffort: undefined };\n }\n return { ...resolved, reasoningEffort: ADAPTIVE_EFFORT_MARKER as LlmCallConfig['reasoningEffort'] };\n }\n\n const resolved = await originalResolveCallConfig(config, signal);\n\n // No session identity is available at this runtime seam. Never infer a\n // physical request's intent from another session's model-selection event.\n // Virtual unpinned requests can inherit the deployment policy; physical\n // adaptive requests must carry their own explicit reflex/auto marker.\n if (requested === undefined && isAdaptiveMarker(policy.setting) &&\n ownedVirtualProvider(llm, resolved.provider)) {\n return { ...resolved, reasoningEffort: ADAPTIVE_EFFORT_MARKER as LlmCallConfig['reasoningEffort'] };\n }\n\n return resolved;\n };\n\n runtime.prepareCall = async (config: LlmCallConfig, signal?: AbortSignal, configure?: unknown) => {\n const requested = config.reasoningEffort as unknown as string | undefined;\n if (!isAdaptiveMarker(requested)) {\n return originalPrepareCall(config, signal, configure as never);\n }\n // Last gate before dispatch: the marker is an intent, never an effort any\n // physical adapter can accept, so it is resolved here for the paths that\n // never went through the `agent/pre-step` decision (hand-built one-shot\n // calls, `prepareCall` consumers). With the switch off there is no policy to\n // resolve it *to*, so it is deleted and the provider default applies.\n if (!policy.enabled) {\n const cleared = { ...config } as LlmCallConfig;\n delete (cleared as { reasoningEffort?: unknown }).reasoningEffort;\n return originalPrepareCall(cleared, signal, configure as never);\n }\n const info = await supportsThinking(config.provider, config.model, signal);\n const aligned = info\n ? await alignReasoningEffort(ADAPTIVE_EFFORT_MARKER, { provider: config.provider, model: config.model }, createReasoningProbe(llm, (provider, model) => originalResolveModelInfo(provider, model, signal)))\n : undefined;\n const next = { ...config } as LlmCallConfig;\n if (aligned === undefined) delete (next as { reasoningEffort?: unknown }).reasoningEffort;\n else next.reasoningEffort = aligned as LlmCallConfig['reasoningEffort'];\n return originalPrepareCall(next, signal, configure as never);\n };\n\n\n try {\n (llm as unknown as { emitAdaptersUpdated?: () => void }).emitAdaptersUpdated?.();\n } catch {\n // A catalog refresh is advisory.\n }\n\n let disposed = false;\n return {\n get adaptive() {\n return policy.enabled && isAdaptiveMarker(policy.setting);\n },\n dispose: () => {\n if (disposed) return;\n disposed = true;\n runtime.resolveModelInfo = originalResolveModelInfo;\n runtime.resolveCallConfig = originalResolveCallConfig;\n runtime.prepareCall = originalPrepareCall;\n try {\n (llm as unknown as { emitAdaptersUpdated?: () => void }).emitAdaptersUpdated?.();\n } catch {\n // Same.\n }\n }\n };\n}\n\n/** The `source` of a DSH message, as far as the notice filter reads it. */\ninterface MessageSourceLike {\n kind?: string;\n form?: string;\n summary?: string;\n}\n\n/** First text block of one message, or `''`. */\nfunction textOfMessage(message: unknown): string {\n const blocks = (message as { content?: readonly ContentBlock[] } | undefined)?.content;\n if (!Array.isArray(blocks)) return '';\n for (const block of blocks) {\n if (block?.type === 'text' && typeof block.text === 'string') return block.text;\n }\n return '';\n}\n\n/**\n * Whether one pre-step message is the model-switch notice for the *virtual* route.\n *\n * Routing a virtual model rewrites the request onto a physical target, so the\n * durable request header records the physical route while the user's selection\n * stays virtual. `installModelSelection` compares exactly those two and — seeing\n * a difference that is not a model change at all — appends \"the session\n * continues with `reflex/…`\" to every step. The notice states something false,\n * it costs context tokens on every single step, and it is not a user action, so\n * it is dropped here.\n *\n * The predicate is deliberately narrow: a genuine physical↔physical switch is\n * left alone, because its notice *is* true and the model needs it to interpret\n * the turns above it.\n *\n * @param message - one admitted pre-step message.\n * @param virtualProvider - the virtual provider route id.\n * @param virtualModels - the virtual model ids.\n * @returns whether the message is the pseudo-switch notice.\n */\nexport function isVirtualModelSwitchNotice(\n message: unknown,\n virtualProvider: string,\n virtualModels: readonly string[]\n): boolean {\n const source = (message as { source?: MessageSourceLike } | undefined)?.source;\n if (source?.kind !== 'model-selection' || source.form !== 'notice') return false;\n\n const summary = typeof source.summary === 'string' ? source.summary : '';\n const text = textOfMessage(message);\n const arrow = summary.lastIndexOf('→');\n const named =\n (arrow >= 0 ? summary.slice(arrow + 1) : '').trim() ||\n (text.match(/continues with ([^\\]]+)\\]/)?.[1] ?? '').trim();\n if (named.length === 0) return false;\n\n if (named.startsWith(`${virtualProvider}/`)) return true;\n if (virtualModels.includes(named)) return true;\n return named.split('/')[0] === virtualProvider;\n}\n\n/**\n * Drop the pseudo-switch notices from one pre-step decision.\n * @param decision - the decision returned by the inner waterfall.\n * @param virtualProvider - the virtual provider route id.\n * @param virtualModels - the virtual model ids.\n * @returns the decision, with the false notices removed when there were any.\n */\nexport function filterVirtualSwitchNotices<T extends { messages?: readonly unknown[] }>(\n decision: T,\n virtualProvider: string,\n virtualModels: readonly string[]\n): T {\n const messages = decision?.messages;\n if (!Array.isArray(messages) || messages.length === 0) return decision;\n const kept = messages.filter((message) => !isVirtualModelSwitchNotice(message, virtualProvider, virtualModels));\n if (kept.length === messages.length) return decision;\n return { ...decision, messages: kept };\n}\n\n/**\n * How long one step's route/effort decision may take before the step is\n * admitted with its selection untouched.\n *\n * The decision costs a System 1 round trip (routing) plus, adaptively, a second\n * one (effort). Real backends answer in tens of milliseconds; this bound only\n * exists so a hung or unreachable backend cannot stall a turn before its first\n * token. Timing out is a *degradation*, not an error: the step runs on the\n * adapter's own defaults, exactly like a deployment that never configured the\n * layer, and the next step tries again.\n */\nconst STEP_DECISION_TIMEOUT_MS = 4000;\n\n/**\n * The budget one step's decision actually gets.\n *\n * `REFLEX_STEP_DECISION_TIMEOUT_MS` overrides the default so a test can prove\n * the timeout path without waiting four seconds; an unset or unparseable value\n * keeps {@link STEP_DECISION_TIMEOUT_MS}.\n *\n * @returns the budget in milliseconds.\n */\nfunction stepDecisionBudget(): number {\n const raw = Number(process.env.REFLEX_STEP_DECISION_TIMEOUT_MS);\n return Number.isFinite(raw) && raw > 0 ? raw : STEP_DECISION_TIMEOUT_MS;\n}\n\n/** What {@link planStep} decided for one step. */\ninterface StepPlan {\n /** Physical provider route to write into the step's selection. */\n provider?: string;\n /** Physical model id to write into the step's selection. */\n model?: string;\n /**\n * Effort to write into the step's selection.\n *\n * An own-property `undefined` is a deliberate *clear* (the decision removed an\n * effort the selection carried); an absent key means the decision had nothing\n * to say about the effort, so the selection keeps its own.\n */\n reasoningEffort?: string | undefined;\n}\n\n/**\n * Run a decision but let nothing it does escape an enclosing `try`.\n *\n * Everything the decision needs from its payload is read by {@link planStep}\n * before the first `await`, so the attempt can safely be abandoned: a decision\n * that loses the timeout race keeps running detached, and a rejection it meets\n * afterwards lands in a no-op handler instead of becoming an unhandled rejection\n * that would take the Host down.\n *\n * @param run - the decision to start.\n * @returns a promise that settles exactly once and never rejects.\n */\nfunction startDecision(run: () => Promise<StepPlan | undefined>): Promise<StepPlan | undefined> {\n const attempt = Promise.resolve().then(run);\n attempt.catch(NOOP);\n return attempt;\n}\n\n/**\n * Race one decision against a deadline.\n *\n * The timer is unref'd and cleared on every path, so neither a settled decision\n * nor an abandoned one keeps the process alive or leaks a handle.\n *\n * @param attempt - the decision, already started.\n * @param ms - budget in milliseconds.\n * @returns the decision, or `undefined` when the budget ran out first.\n */\nfunction withBudget<T>(attempt: Promise<T>, ms: number): Promise<T | undefined> {\n return new Promise<T | undefined>((resolve) => {\n let settled = false;\n const finish = (value: T | undefined): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(value);\n };\n const timer = setTimeout(() => finish(undefined), ms);\n // Node keeps the process alive for a pending timer; a decision that never\n // answers must not turn into a hung host.\n (timer as unknown as { unref?: () => void }).unref?.();\n attempt.then(finish, () => finish(undefined));\n });\n}\n\n/**\n * Write one plan into the step's selection object.\n *\n * `payload.modelSelection` is `Readonly<ModelSelection>` in the contract, but\n * that is a compile-time marker only: DSH 0.2.2 does not freeze the object at\n * runtime, and mutating it here mutates `dsh-agent-loop`'s own local `selection`,\n * which is what its `prepareRequest` guards compare against. That is the whole\n * point of {@link installModelRouting}'s pre-step decision, and there is no\n * other seam — `agent.model.select()` records a selection that only the *next*\n * `current()` reads, and `current()` for this step has already been called.\n * The write therefore goes through a mutable view of the same object, and a\n * payload frozen by an embedder raises `TypeError`, which the caller catches.\n *\n * @param selection - the step's selection (the loop's `selection` object).\n * @param plan - the decided route and effort.\n */\nfunction applyPlan(\n selection: Readonly<{ provider: string; model: string; reasoningEffort?: unknown }>,\n plan: StepPlan\n): void {\n const target = selection as { provider: string; model: string; reasoningEffort?: unknown };\n if (plan.provider !== undefined) target.provider = plan.provider;\n if (plan.model !== undefined) target.model = plan.model;\n if (!('reasoningEffort' in plan)) return;\n if (plan.reasoningEffort === undefined) delete target.reasoningEffort;\n else target.reasoningEffort = plan.reasoningEffort;\n}\n\n/**\n * The provider route the caller composed this agent with.\n *\n * `agent.options` is the durable intent: it is what the model selector was set\n * to, and unlike the step's selection it is never overwritten by a physical\n * route this layer chose for one step.\n *\n * @param agent - the stepping agent.\n * @returns the composed provider id, or `undefined` when it carries none.\n */\nfunction intendedProvider(agent: Agent): string | undefined {\n try {\n const provider = (agent as { options?: { provider?: unknown } })?.options?.provider;\n return typeof provider === 'string' && provider.length > 0 ? provider : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The virtual model the caller composed this agent with.\n * @param agent - the stepping agent.\n * @returns the composed model id, or `undefined` when it carries none.\n */\nfunction intentModel(agent: Agent): string | undefined {\n try {\n const model = (agent as { options?: { model?: unknown } })?.options?.model;\n return typeof model === 'string' && model.length > 0 ? model : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Whether one agent is a delegated subagent.\n *\n * `effort-delegation.ts` treats a positive `delegationDepth` as authoritative and\n * falls back to `origin: 'subagent'`; this check has to agree with it, or a\n * child whose depth was recorded but whose origin was not would have its effort\n * decided here *and* inherited there.\n *\n * @param agent - the stepping agent.\n * @returns whether the agent was delegated.\n */\nfunction isDelegatedAgent(agent: Agent): boolean {\n try {\n const header = (agent as { session?: { header?: { origin?: string; delegationDepth?: number } } })?.session?.header;\n if (typeof header?.delegationDepth === 'number') return header.delegationDepth > 0;\n return header?.origin === 'subagent';\n } catch {\n return false;\n }\n}\n\n/** Everything {@link planStep} reads from the installation. */\ninterface StepPlanInput {\n /** Plugin context (the status emitter and the projection reader). */\n ctx: Context;\n /** The stepping agent. */\n agent: Agent;\n /** Turn the step belongs to. */\n turn: number | undefined;\n /** Step number in that turn. */\n step: number | undefined;\n /** The turn's cancellation signal. */\n signal?: AbortSignal;\n /** The selection the loop fixed for this step. */\n selection: Readonly<{ provider: string; model: string; reasoningEffort?: unknown }>;\n /** Router currently in force. */\n router: VirtualModelRouter;\n /** Live effort policy. */\n effort: EffortInterceptor;\n /** Whether these listeners may re-route at all. */\n routes: boolean;\n /** Per-installation memory. */\n facts: Map<string, AgentRoutingFacts>;\n /** Reasoning-vocabulary lookup of a physical route. */\n probe: ReasoningProbe;\n}\n\n/**\n * Decide one step's route and reasoning effort.\n *\n * This is the body the `agent/request` waterfall used to run (g-056). It\n * resolves the caller's durable intent, routes a virtual request through System\n * 1, then either adapts the effort (marker present) or aligns it onto the routed\n * model's vocabulary (concrete level). The order is preserved exactly —\n * intent → route → effort — because the effort is projected onto the model the\n * route actually chose.\n *\n * Reuse is part of the contract, not an optimisation: `agent/pre-step` runs once\n * per *step*, while a decision costs up to two System 1 round trips. A later step\n * of the same turn reuses the turn's plan, which is also why a turn can no longer\n * change its physical model mid-way.\n *\n * @param input - the step, its selection, and the installation's live seams.\n * @returns the plan to write, or `undefined` when the step needs no change.\n */\nasync function planStep(input: StepPlanInput): Promise<StepPlan | undefined> {\n const { ctx, agent, router, effort, routes, signal, selection, facts, probe } = input;\n\n // Everything below this line is read synchronously, before the first `await`,\n // so an abandoned (timed-out) attempt cannot observe a payload that moved on.\n if (signal?.aborted) return undefined;\n\n // The selection is the step's starting configuration; `resolveAdaptiveIntent`\n // may replace the virtual route and effort with the caller's durable intent.\n const base: LlmCallConfig = {\n provider: selection.provider,\n model: selection.model,\n ...(selection.reasoningEffort === undefined\n ? {}\n : { reasoningEffort: selection.reasoningEffort as LlmCallConfig['reasoningEffort'] })\n };\n const config = resolveAdaptiveIntent(ctx, agent, base, (provider) => router.owns(provider));\n\n const remembered = recallFacts(facts, agent);\n const requested = config.reasoningEffort as unknown as string | undefined;\n const task = remembered?.task;\n\n // With `effort.enabled` off this layer manages no effort at all: it still\n // routes, but the only edit it is allowed to make to `reasoningEffort` is\n // removing its own marker. That keeps a concrete level byte-identical on its\n // way to the adapter, and it means no decision, no audit entry and no status\n // can be produced for a deployment that switched the layer off.\n const effortOff = effort.enabled === false;\n\n // Reflex only automatically adapts reasoning effort when the effort was\n // explicitly chosen as reflex/auto, or when an unpinned request names the\n // virtual provider (which defaults to adaptive effort). If the user selected\n // High, Low, Medium, Off, or Provider Default, reflex does not touch effort.\n // A delegated agent's effort was already settled by `effort-delegation.ts` on\n // its own selection, so this layer must not adapt it here either.\n const delegated = isDelegatedAgent(agent);\n\n const isAdaptive =\n !effortOff &&\n !delegated &&\n (isAdaptiveMarker(requested) ||\n (requested === undefined && router.owns(config.provider) && isAdaptiveMarker(effort.setting)));\n\n // Same-turn follow-up steps (step > 1) reuse the turn's decision: no second\n // System 1 call, no second effort event, 0ms latency. The turn is the unit of\n // decision — a later step carrying user text is still the same turn, so it\n // does not break the reuse (g-063).\n const isFollowupStep =\n (input.step ?? 1) > 1 &&\n remembered?.decided !== undefined &&\n remembered.decided.turn === input.turn &&\n // A config-only save may replace the policy mid-turn; a decision taken\n // under the previous policy is not this turn's answer any more.\n remembered.decided.generation === effort.generation;\n\n // Whether this step belongs on the virtual route. It cannot be read off the\n // step's *selection*: this layer writes the physical target into that object,\n // and the loop records it as the session's latest selection (the request header\n // retires the pending choice), so every later step starts from a physical\n // provider this router does not own. Asking the selection would make routing\n // stop after the first step, which is why the question is asked of the\n // caller's durable intent — the agent's composed options — and of the intent\n // `resolveAdaptiveIntent` just recovered from the selection projection.\n const intent = intendedProvider(agent);\n const stepOwnsRoute = router.owns(config.provider);\n const onVirtualRoute = routes && ((intent !== undefined && router.owns(intent)) || stepOwnsRoute);\n // The route name to hand `routeModel`: the step's own when it still names the\n // virtual provider, otherwise the router's current name (the intent path).\n const virtualProviderForStep = stepOwnsRoute ? config.provider : router.virtualProvider;\n\n const plan: StepPlan = {};\n\n // Reuse only applies while the step is still *on the virtual route*: a caller\n // that has switched the session onto a physical model (or pinned a concrete\n // effort on one) must never have that decision replayed over its own choice.\n const sameVirtualModel = remembered?.decided?.virtualModel === undefined || remembered.decided.virtualModel === config.model;\n if (remembered?.decided && isFollowupStep && sameVirtualModel && onVirtualRoute) {\n // The turn's route and effort, replayed exactly: re-routing a later step\n // would move a warm session between physical models mid-turn.\n const reuse = remembered.decided;\n if (onVirtualRoute) {\n plan.provider = reuse.provider;\n plan.model = reuse.model;\n }\n if (reuse.effort !== undefined) plan.reasoningEffort = reuse.effort;\n return plan;\n }\n\n let routed = config;\n let switched: boolean | undefined;\n let heldForCache: boolean | undefined;\n if (onVirtualRoute) {\n // The virtual *model* to route is the one the caller's durable intent names,\n // which `resolveAdaptiveIntent` has already folded into `config` (it\n // prefers the session's pending selection over the step's own). Using\n // `selection.model` here would instead route on whatever this layer wrote\n // into the previous step, i.e. on a physical id it cannot route at all.\n const virtualModel = config.model;\n const decision = await router.routeModel({\n provider: virtualProviderForStep,\n model: virtualModel,\n task,\n ...describeAgent(agent),\n turn: input.turn,\n step: input.step,\n // Cache-affinity facts: the model this session already holds and how\n // much context it is defending.\n ...(remembered?.currentModel ? { currentModel: remembered.currentModel } : {}),\n ...(remembered === undefined ? {} : { contextChars: remembered.contextChars }),\n contextTokens: estimateContextTokens(remembered?.contextChars ?? 0)\n });\n routed = { ...config, provider: decision.target.provider, model: decision.target.model };\n switched = decision.switched;\n heldForCache = decision.reason === 'sticky-affinity';\n plan.provider = decision.target.provider;\n plan.model = decision.target.model;\n rememberTarget(facts, agent, decision.target);\n }\n\n // A routed turn is recorded even when no effort was decided: its later steps\n // must reuse the physical target instead of asking System 1 again, or a turn\n // could migrate between models on every tool call.\n const settle = (effortToWrite: string | undefined, changed: boolean): StepPlan | undefined => {\n if (plan.provider !== undefined) {\n rememberDecision(\n facts,\n agent,\n input.turn,\n routed,\n { changed, ...(effortToWrite === undefined ? {} : { effort: effortToWrite }), outcome: 'passthrough' },\n effort.generation,\n config.model\n );\n }\n if (changed) plan.reasoningEffort = effortToWrite;\n return Object.keys(plan).length === 0 ? undefined : plan;\n };\n\n if (!isAdaptive) {\n if (effortOff) {\n // Transparent pass-through: the selection keeps the caller's own level\n // (never aligned, never snapped onto the routed model's vocabulary), and\n // the plugin's marker is dropped instead of being translated — the\n // adapter then applies the provider default, which is the only safe\n // reading of \"reflex\" once the adaptive layer is switched off.\n return settle(undefined, isAdaptiveMarker(requested));\n }\n // A delegated selection keeps exactly the effort it fixed: not aligned, not\n // snapped. The selection layer has already made sure this value is a\n // concrete level the adapter accepts.\n if (delegated || requested === undefined) return settle(requested, false);\n // Concrete effort (high, low, off...): align if needed, never adapt! This is\n // the *non-adaptive* branch, and it moves here for the same reason the\n // adaptive one does — alignment is still a rewrite of the fixed value, which\n // `agent/request` may no longer make.\n const aligned = await alignReasoningEffort(requested, { provider: routed.provider, model: routed.model }, probe);\n return settle(aligned, aligned !== requested);\n }\n\n const resolution = await effort.resolve({\n requested,\n target: { provider: routed.provider, model: routed.model },\n probe,\n task,\n // Earlier turns of this agent: since g-063 every decision sees them, inside\n // the effort layer's window, so a short prompt is graded against the work it\n // continues instead of on its own few characters.\n ...(remembered?.turns?.length ? { history: remembered.turns.map((entry) => ({ text: entry.text })) } : {}),\n // The level the last adaptive decision produced. It was recorded since g-056\n // to recognise a header echo and nothing ever read it; g-063 makes it the\n // decision input's prior, so \"继续\" after a hard turn cannot be graded cold.\n ...(remembered?.lastAdaptiveEffort ? { previousLevel: remembered.lastAdaptiveEffort } : {}),\n agent: describeAgent(agent),\n turn: input.turn,\n step: input.step,\n requestedProvider: config.provider,\n requestedModel: config.model,\n ...(switched === undefined ? {} : { switched }),\n ...(heldForCache === undefined ? {} : { heldForCache })\n });\n\n // The decision is recorded where it is *made* now (g-056): the ledger, the\n // session audit and the status feed all hear about it from here, not from the\n // read-only request waterfall.\n if (resolution.status) reportEffort(ctx, agent, resolution.status);\n rememberDecision(facts, agent, input.turn, routed, resolution, effort.generation, config.model);\n\n // Only an effort that was asked for — or one this layer just decided — is\n // written. A selection that never carried one keeps carrying none.\n const decidedEffort = resolution.changed ? resolution.effort : requested;\n if (decidedEffort !== requested) plan.reasoningEffort = decidedEffort;\n return Object.keys(plan).length === 0 ? undefined : plan;\n}\n\n/**\n * Install the virtual route and its interception layers.\n * @param ctx - the plugin's context (untagged listeners here observe every agent).\n * @param options - runtime, router, and capture budget.\n * @returns the installation handle; `dispose()` is idempotent.\n */\nexport function installModelRouting(ctx: Context, options: ModelRoutingOptions): ModelRoutingInstallation {\n const { llm } = options;\n const warn = options.warn ?? NOOP;\n const facts = new Map<string, AgentRoutingFacts>();\n\n // The raw lookups are captured before the adaptive-effort surface wraps them:\n // the routing probe must see what a model *declares*, never the `reflex`\n // entry the surface adds for the selector.\n const rawResolveModelInfo = llm.resolveModelInfo.bind(llm);\n const rawProbe = (provider: string, model: string) =>\n rawResolveModelInfo(provider, model) as unknown as Promise<LlmResolvedModelInfoLike>;\n\n const surface = installAdaptiveEffortSurface(ctx, llm, options.effort);\n\n let disposed = false;\n const scope = routeScope(llm);\n const owned = OWNED_ROUTES.get(scope) ?? new Map<string, OwnedRoute>();\n OWNED_ROUTES.set(scope, owned);\n\n /**\n * Whether these listeners may rewrite a request's route. Registering the\n * route and *using* one are different questions: an activation without pools\n * must not fall through to a fails-closed pool it never configured, and it\n * must not steal the policy of the activation that does own the route.\n */\n let routes = false;\n let adapter: ReflexVirtualAdapter | undefined;\n let router = options.router;\n /** The shared route entry this activation holds, when it holds one. */\n let held: OwnedRoute | undefined;\n /** Whether this activation created a provider registration (not merely joined). */\n let created = false;\n /** `registerAdapter` calls made by this activation (diagnostics/idempotence). */\n let registrationEvents = 0;\n\n const readTaskBudget = (): number => {\n const budget = typeof options.maxTaskChars === 'function' ? options.maxTaskChars() : options.maxTaskChars;\n return Number.isFinite(budget) ? Math.max(1, budget) : 400;\n };\n\n const republish = (): void => {\n try { (llm as any).emitAdaptersUpdated?.(); } catch {}\n };\n\n /** Build the adapter for one provider name; the router is shared. */\n const buildAdapter = (provider: string): ReflexVirtualAdapter =>\n new ReflexVirtualAdapter({\n provider,\n router,\n dispatch: (dispatchOptions) => llm.stream(dispatchOptions),\n probeReasoning: createReasoningProbe(llm, rawProbe),\n resolveContextWindow: async (prov, mod) => {\n try {\n const info = await rawResolveModelInfo(prov, mod);\n return (info as any)?.context?.contextWindow;\n } catch {\n return undefined;\n }\n }\n });\n\n /**\n * Register (or join) the route for the router's current provider name.\n *\n * Joining rather than colliding is what lets several activations share the\n * process-wide route: the first registers, the rest increment the owner count\n * and adopt the shared router, whose policy the newest activation replaces.\n */\n const registerRoute = (): void => {\n if (routes || held) return;\n const provider = router.virtualProvider;\n const existing = owned.get(provider);\n if (existing) {\n existing.owners += 1;\n router = existing.adapter.router;\n router.updatePolicy({\n models: options.router.models,\n ...(options.router.fallback ? { fallback: options.router.fallback } : {})\n });\n held = existing;\n routes = true;\n warn(\n `dsh-reflex: virtual route \"${provider}\" is already registered in this process; this activation joins it with its own pool policy`\n );\n republish();\n return;\n }\n if (llm.listProviders().some((entry) => entry.id === provider)) {\n warn(\n `dsh-reflex: provider \"${provider}\" is already registered by another adapter; System 1 model routing stays off for this activation`\n );\n return;\n }\n const nextAdapter = buildAdapter(provider);\n let handle: () => void;\n try {\n // Registered on the *root* context on purpose: the provider route is\n // process-wide, and provider registrations are disposed with the fiber\n // that created them. A registration on this activation's fiber would\n // disappear the moment this activation is released — even while another\n // activation is still routing through the same adapter. The release below\n // is what actually withdraws the route, once the last owner is gone.\n handle = ctx.root.llm.registerAdapter([provider], nextAdapter);\n registrationEvents += 1;\n } catch (error) {\n warn(\n `dsh-reflex: could not register the virtual provider \"${provider}\" (${(error as Error).message}); System 1 model routing stays off`\n );\n return;\n }\n const entry: OwnedRoute = { provider, adapter: nextAdapter, owners: 1, handle };\n owned.set(provider, entry);\n held = entry;\n adapter = nextAdapter;\n created = true;\n routes = true;\n republish();\n };\n\n /**\n * Release this activation's hold on the route.\n *\n * The provider registration is withdrawn only when the last owner goes away;\n * until then the shared adapter and its router stay registered for the other\n * activations.\n */\n const releaseRoute = (): void => {\n const entry = held;\n held = undefined;\n routes = false;\n adapter = undefined;\n if (!entry) return;\n entry.owners -= 1;\n if (entry.owners > 0) return;\n if (owned.get(entry.provider) === entry) owned.delete(entry.provider);\n created = false;\n entry.handle();\n republish();\n };\n\n /**\n * Rename the virtual provider route in place.\n *\n * A rename has to leave no orphan adapter: the new name is registered before\n * the old one is withdrawn (registry names differ, so no duplicate), then the\n * ownership entry moves to the new name. Every activation sharing this route\n * shares the same router object, so mutating its provider name renames the\n * route consistently for all of them; the owner count still decides when the\n * registration is actually withdrawn.\n */\n const renameRoute = (provider: string): void => {\n if (router.virtualProvider === provider) return;\n const entry = held;\n if (!entry) {\n router.setVirtualProvider(provider);\n return;\n }\n const oldProvider = entry.provider;\n const nextAdapter = buildAdapter(provider);\n let handle: () => void;\n try {\n handle = ctx.root.llm.registerAdapter([provider], nextAdapter);\n registrationEvents += 1;\n } catch (error) {\n // Keep routing on the old name rather than leaving the activation with no\n // route at all; the next commit retries.\n warn(\n `dsh-reflex: could not rename the virtual provider to \"${provider}\" (${(error as Error).message}); keeping \"${oldProvider}\"`\n );\n return;\n }\n router.setVirtualProvider(provider);\n entry.handle();\n if (owned.get(oldProvider) === entry) owned.delete(oldProvider);\n entry.provider = provider;\n entry.adapter = nextAdapter;\n entry.handle = handle;\n owned.set(provider, entry);\n adapter = nextAdapter;\n republish();\n };\n\n /**\n * Reconcile the provider lifecycle with one resolved routing policy.\n * @param policy - the policy currently in force.\n */\n const reconcile = (policy: LiveRoutingPolicy): void => {\n if (disposed) return;\n const canRoute = policy.enabled && Object.values(policy.models).some((pool) => pool.length > 0);\n if (!canRoute) {\n releaseRoute();\n router.setVirtualProvider(policy.virtualProvider);\n return;\n }\n if (!held) {\n router.setVirtualProvider(policy.virtualProvider);\n registerRoute();\n return;\n }\n if (router.virtualProvider !== policy.virtualProvider) renameRoute(policy.virtualProvider);\n };\n\n if (options.route === false || !router.hasPools) {\n // Deliberately silent: a deployment that configured no pool asked for the\n // tool surface only, and the effort layer may still be configured.\n } else {\n registerRoute();\n }\n\n const probe = createReasoningProbe(llm, rawProbe);\n const disposers: Array<() => void> = [];\n /** Detachers of the per-agent pseudo-switch filters installed lazily. */\n const agentFilterDisposers: Array<() => void> = [];\n /** Agents that already carry a filter, so a step never installs a second one. */\n const agentFilters = new WeakSet<object>();\n\n disposers.push(\n ctx.on('llm/stream', (options, next) => {\n if (isAgentLoopRequest(options) || (options as any).__reflexLoopOwned === true) {\n markAgentLoopRequest(options);\n }\n return next();\n })\n );\n\n // The pools a virtual model advertises are read from the live router, so a\n // committed routing edit changes what the model picker must show. The runtime\n // refreshes the router first (its listener is registered before this one);\n // this only republishes the catalog. A Host without the loader event simply\n // never calls it.\n disposers.push(\n ctx.on('loader/volatile-update', () => {\n try { (llm as any).emitAdaptersUpdated?.(); } catch {}\n })\n );\n\n /**\n * Decide one step's route and reasoning effort, then write it into the step's\n * selection.\n *\n * ## Why the write happens here (g-056)\n *\n * `dsh-agent-loop` reads `const selection = this.model.current()` before it\n * dispatches `agent/pre-step`, keeps that very object as the step's fixed\n * selection, and afterwards rejects a request that proposes anything else:\n *\n * agent/request proposed reasoning effort \"high\" after step preparation\n * fixed \"reflex\"; use agent.model.select() before step preparation\n *\n * `payload.modelSelection` *is* that object — `preStep` hands the local\n * `selection` straight into the waterfall payload, so mutating the payload\n * mutates what the guards compare against. `AgentModel.current()` already\n * returned a fresh mutable copy (`{ ...recorded }` / a new object from\n * `toSelection`), which is why the object is writable at all.\n *\n * The `Readonly<ModelSelection>` in the contract is a compile-time marker with\n * no runtime freeze attached, and DSH 0.2.2 offers no other write path before\n * step preparation: `agent.model.select()` appends a `model/selection` event\n * that only the *next* `current()` reads, and `current()` has already been\n * called. So this is the only seam, and the cast below is its documentation.\n *\n * Every failure mode degrades to \"selection unchanged\": a throwing planner, a\n * frozen payload (the write raises `TypeError`, caught here), or a decision\n * that outran {@link STEP_DECISION_TIMEOUT_MS}. An unchanged `reflex` marker\n * is then stripped by the virtual provider's own `resolveCallConfig`, so the\n * request lands on the adapter default instead of an unsupported effort.\n *\n * `next()` is called *outside* the `try` on purpose: the rest of the waterfall\n * decides whether the step is admitted (`enter`/`reject`) and with which\n * messages, and swallowing its rejection would turn a rejected step into a\n * silently admitted one.\n */\n disposers.push(\n ctx.on('agent/pre-step', async (payload, next) => {\n // Outside the try: a rejection here must reach the loop unchanged.\n const decision = await next();\n try {\n // Cheap liveness: the host that commits config-only saves leaves the\n // resolved config stale until someone asks. The check is a handful of\n // identity comparisons and parses nothing unless the loader committed.\n options.refreshConfig?.();\n ensureVirtualSwitchFilter(payload.agent, router, agentFilterDisposers, agentFilters);\n rememberStep(facts, payload.agent, captureTask(payload.messages, readTaskBudget()), measureMessages(payload.messages), payload.turn);\n\n // The loop has already read `model.current()` for this step; reading our\n // own attributes synchronously here (not through a composable) is what\n // makes the attempt safely able to outlive its budget.\n const selection = payload.modelSelection;\n const attempt = startDecision(() =>\n planStep({\n ctx,\n agent: payload.agent,\n turn: payload.turn,\n step: payload.step,\n signal: payload.signal,\n selection,\n router,\n effort: options.effort,\n routes,\n facts,\n probe\n })\n );\n const budget = stepDecisionBudget();\n const settled = await withBudget(attempt, budget);\n if (settled === undefined) {\n warn(\n `dsh-reflex: the step decision for \"${agentKey(payload.agent) ?? 'agent'}\" did not finish in ${budget}ms; the step keeps the selection it fixed`\n );\n return decision;\n }\n // A read-only payload (frozen by an embedder, or a future Host that\n // freezes it) rejects the writes below; that is the same safe outcome.\n applyPlan(selection, settled);\n } catch {\n // Decision failure never vetoes a step: the selection keeps exactly what\n // the loop fixed, and the virtual provider's `resolveCallConfig` strips\n // the marker if one survives, so the request lands on the model default.\n }\n return decision;\n }, { prepend: true })\n );\n\n // Read-only by contract (see the module docstring): `await next()` and hand\n // the configuration back exactly as produced. DSH 0.2.2 throws when this\n // waterfall proposes a different provider, model, or reasoning effort than the\n // step's selection, and a listener that can only pass through can never do so.\n disposers.push(\n ctx.on('agent/request', async (_payload, next) => next(), { prepend: true })\n );\n\n const dispose = () => {\n if (disposed) return;\n disposed = true;\n for (const detach of disposers.reverse()) detach();\n disposers.length = 0;\n for (const detach of agentFilterDisposers.splice(0)) detach();\n facts.clear();\n surface.dispose();\n releaseRoute();\n };\n\n return {\n get router() {\n return router;\n },\n get adapter() {\n return adapter;\n },\n get registered() {\n return created;\n },\n get registrationEvents() {\n return registrationEvents;\n },\n refresh(policy: LiveRoutingPolicy): void {\n reconcile(policy);\n },\n dispose\n };\n}\n\n/**\n * Join the text blocks of the user messages admitted to one step.\n * @param messages - messages carried by `agent/pre-step`.\n * @param budget - maximum characters to keep.\n * @returns the joined task text, or `undefined` when the step carries no text.\n */\nfunction captureTask(messages: readonly UserMessage[], budget: number): string | undefined {\n const limit = Math.max(1, budget);\n const parts: string[] = [];\n let length = 0;\n\n for (const message of messages ?? []) {\n for (const block of (message?.content ?? []) as readonly ContentBlock[]) {\n if (block.type !== 'text' || typeof block.text !== 'string') continue;\n const text = block.text.trim();\n if (text.length === 0) continue;\n parts.push(text);\n length += text.length;\n if (length >= limit) break;\n }\n if (length >= limit) break;\n }\n\n return parts.length === 0 ? undefined : parts.join('\\n').slice(0, limit);\n}\n\n/**\n * Remember one agent's latest step, keeping the map bounded.\n *\n * A step that carries no text still counts towards the session's size and must\n * not erase the task the agent is working on, so the two facts are updated\n * independently.\n *\n * @param facts - the per-installation facts map.\n * @param agent - the agent proposing the step.\n * @param text - the captured task text, when the step carried any.\n * @param chars - characters of step input observed.\n * @param turn - the turn the step belongs to.\n */\nfunction rememberStep(\n facts: Map<string, AgentRoutingFacts>,\n agent: Agent,\n text: string | undefined,\n chars: number,\n turn?: number\n): void {\n const key = agentKey(agent);\n if (key === undefined) return;\n const previous = facts.get(key);\n const turns = rememberTurn(previous?.turns ?? [], text, turn);\n const next: AgentRoutingFacts = {\n ...(text ?? previous?.task ? { task: text ?? previous?.task } : {}),\n ...(previous?.currentModel ? { currentModel: previous.currentModel } : {}),\n contextChars: (previous?.contextChars ?? 0) + Math.max(0, Math.round(chars)),\n ...(previous?.decided ? { decided: previous.decided } : {}),\n ...(previous?.lastAdaptiveEffort ? { lastAdaptiveEffort: previous.lastAdaptiveEffort } : {}),\n ...(turns.length === 0 ? {} : { turns })\n };\n facts.delete(key);\n facts.set(key, next);\n while (facts.size > MAX_TRACKED_AGENTS) {\n const oldest = facts.keys().next();\n if (oldest.done) break;\n facts.delete(oldest.value);\n }\n}\n\n/**\n * Append one observed turn text, one entry per turn, bounded by the effort\n * layer's window.\n *\n * A second step of the *same* turn replaces that turn's entry instead of adding\n * another: the window is defined in turns, so a step count must not be able to\n * push an earlier turn out of it. Consecutive replies of the same text are folded\n * too — \"继续\" said three times is one piece of context, not three that grow\n * with every turn.\n *\n * @param turns - the turns kept so far, oldest first.\n * @param text - the text this step carried; a step without text adds nothing.\n * @param turn - the turn the step belongs to; `undefined` is treated as a new turn.\n * @returns the bounded turn list, oldest first.\n */\nfunction rememberTurn(turns: readonly TrackedTurn[], text: string | undefined, turn?: number): TrackedTurn[] {\n if (text === undefined) return [...turns];\n const last = turns.at(-1);\n // Without a turn number every step is its own turn: the pre-step hook is the\n // only place this is read, and guessing an increment would merge a multi-step\n // turn into one entry — which is harmless — while a wrong merge across real\n // turns would drop history. Separate entries is the safe reading.\n const entry: TrackedTurn = { turn: turn ?? (last === undefined ? 0 : last.turn + 1), text };\n const kept =\n turn !== undefined && last !== undefined && last.turn === turn ? [...turns.slice(0, -1), entry] : [...turns, entry];\n // The same text repeated consecutively is one context, not an ever-growing one.\n const deduped: TrackedTurn[] = [];\n for (const item of kept) {\n if (deduped.at(-1)?.text === item.text) continue;\n deduped.push(item);\n }\n return deduped.slice(-EFFORT_CONTEXT_TURNS);\n}\n\n/**\n * Remember one turn's decision so its later steps cost nothing.\n *\n * Only an *adaptive* decision is cached: a request that carries its own\n * concrete level needs no decision at all, and caching it would turn the\n * caller's explicit choice into a per-step replay of a value the request\n * already carries.\n *\n * @param facts - the per-installation facts map.\n * @param agent - the requesting agent.\n * @param turn - the turn the decision belongs to.\n * @param routed - the call configuration the decision was taken for.\n * @param resolution - the effort resolution, carrying the status when decided.\n * @param generation - effort policy version the decision was taken under.\n */\nfunction rememberDecision(\n facts: Map<string, AgentRoutingFacts>,\n agent: Agent,\n turn: number | undefined,\n routed: LlmCallConfig,\n resolution: EffortResolution,\n generation: number,\n virtualModel?: string\n): void {\n const key = agentKey(agent);\n if (key === undefined) return;\n const status = resolution.status;\n const decision: TurnDecision = {\n turn: turn ?? 0,\n provider: routed.provider,\n model: routed.model,\n ...(virtualModel === undefined ? {} : { virtualModel }),\n ...(resolution.effort === undefined ? {} : { effort: resolution.effort }),\n ...(status === undefined ? {} : { status }),\n generation\n };\n const previous = facts.get(key);\n // g-063: a later step of the *same* turn replays this decision instead of\n // asking again, so the previous level the next decision is given must be the\n // level this turn settled on, not the one from before it. Otherwise a five-step\n // turn hands the turn after it a stale prior.\n const settledEffort = resolution.decision ? resolution.effort : (previous?.decided?.effort ?? previous?.lastAdaptiveEffort);\n facts.delete(key);\n facts.set(key, {\n ...(previous?.task ? { task: previous.task } : {}),\n ...(previous?.currentModel ? { currentModel: previous.currentModel } : {}),\n contextChars: previous?.contextChars ?? 0,\n decided: decision,\n // An echo is only recognisable when this layer, not the user, chose the\n // effort — so the marker is recorded for adaptive decisions alone — and\n // since g-063 it is also the previous level the next decision is told about.\n ...(settledEffort === undefined ? {} : { lastAdaptiveEffort: settledEffort }),\n ...(previous?.turns?.length ? { turns: previous.turns } : {})\n });\n}\n\n/**\n * Re-publish one reused decision for a later step of the same turn.\n * @param decision - the turn's decision.\n * @param turn - the step's turn.\n * @param step - the step number.\n * @returns a status carrying this step's numbers, or `undefined` when none was published.\n */\nfunction statusForStep(\n decision: TurnDecision,\n turn: number | undefined,\n step: number | undefined\n): ReflexEffortStatus | undefined {\n if (!decision.status) return undefined;\n const status: ReflexEffortStatus = {\n ...decision.status,\n latencyMs: 0,\n at: Date.now(),\n ...(turn === undefined ? {} : { turn }),\n ...(step === undefined ? {} : { step })\n };\n return { ...status, line: formatEffortStatusLine(status) };\n}\n\n/**\n * Install the pseudo-switch filter on one agent's own context, once.\n *\n * Placement is the whole point. `installModelSelection` registers its notice\n * listener with `prepend` on the *agent* context, so it is the outermost\n * `agent/pre-step` wrapper and appends its notice after every other listener\n * returned. Registering this filter later, also with `prepend` but on that same\n * agent context, puts it at the front again, so it becomes the one wrapper that\n * sees the notice and can drop it. The first step of a turn never receives a\n * notice, which is exactly the step on which this filter gets installed.\n *\n * @param agent - the agent proposing the step.\n * @param router - the routing policy, naming the virtual route.\n * @param disposers - collector for the detachers.\n * @param installed - guard so one agent never gets two filters.\n */\nfunction ensureVirtualSwitchFilter(\n agent: Agent,\n router: VirtualModelRouter,\n disposers: Array<() => void>,\n installed: WeakSet<object>\n): void {\n const target = agent as unknown as object;\n if (!target || installed.has(target)) return;\n const agentCtx = (agent as { ctx?: Context }).ctx;\n if (!agentCtx || typeof agentCtx.on !== 'function') return;\n\n installed.add(target);\n try {\n const detach = agentCtx.on(\n 'agent/pre-step',\n (async (_payload: { agent: Agent }, next: () => Promise<unknown>) => {\n const decision = await next();\n return filterVirtualSwitchNotices(\n decision as { messages?: readonly unknown[] },\n router.virtualProvider,\n router.modelIds\n );\n }) as never,\n { prepend: true }\n );\n disposers.push(detach as unknown as () => void);\n } catch {\n // A synthetic or torn-down agent context must never break a step.\n installed.delete(target);\n }\n}\n\n/**\n * Remember the physical model one agent's request was routed onto.\n *\n * This is what the next decision defends: the model whose prompt prefix the\n * session has already paid to cache.\n *\n * @param facts - the per-installation facts map.\n * @param agent - the requesting agent.\n * @param target - the physical route the request was rewritten to.\n */\nfunction rememberTarget(facts: Map<string, AgentRoutingFacts>, agent: Agent, target: PhysicalTarget): void {\n const key = agentKey(agent);\n if (key === undefined) return;\n const previous = facts.get(key);\n facts.delete(key);\n facts.set(key, {\n ...(previous?.task ? { task: previous.task } : {}),\n currentModel: { provider: target.provider, model: target.model },\n contextChars: previous?.contextChars ?? 0,\n ...(previous?.decided ? { decided: previous.decided } : {}),\n ...(previous?.lastAdaptiveEffort ? { lastAdaptiveEffort: previous.lastAdaptiveEffort } : {}),\n ...(previous?.turns?.length ? { turns: previous.turns } : {})\n });\n}\n\n/**\n * Recall what one activation knows about one agent.\n * @param facts - the per-installation facts map.\n * @param agent - the requesting agent.\n * @returns the remembered task, current model and context size, when any.\n */\nfunction recallFacts(facts: Map<string, AgentRoutingFacts>, agent: Agent): AgentRoutingFacts | undefined {\n const key = agentKey(agent);\n return key === undefined ? undefined : facts.get(key);\n}\n\n/**\n * Count the text carried by one step's messages, without truncation.\n *\n * The task text is capped for the prompt; the session size must not be, or a\n * long session would look as small as the first turn forever.\n *\n * @param messages - messages carried by `agent/pre-step`.\n * @returns the number of characters of text, or `0`.\n */\nfunction measureMessages(messages: readonly UserMessage[]): number {\n let length = 0;\n for (const message of messages ?? []) {\n for (const block of (message?.content ?? []) as readonly ContentBlock[]) {\n if (block.type !== 'text' || typeof block.text !== 'string') continue;\n length += block.text.length;\n }\n }\n return length;\n}\n\n/**\n * Stable key for one agent.\n * @param agent - the agent to key.\n * @returns its id, or `undefined` when it has none.\n */\nfunction agentKey(agent: Agent): string | undefined {\n try {\n return typeof agent?.id === 'string' && agent.id.length > 0 ? agent.id : undefined;\n } catch {\n return undefined;\n }\n}\n"]}
|
package/dist/session-audit.d.ts
CHANGED
|
@@ -21,6 +21,18 @@ export declare const INTERVENTION_RECORD_TYPE = "plugin:dsh-reflex/intervention"
|
|
|
21
21
|
* permission, and the Session's own retention governs the copy's lifetime.
|
|
22
22
|
*/
|
|
23
23
|
export declare const PRUNED_ORIGINAL_RECORD_TYPE = "plugin:dsh-reflex/pruned-original";
|
|
24
|
+
/**
|
|
25
|
+
* Session-log record type of one delegated-agent effort downgrade.
|
|
26
|
+
*
|
|
27
|
+
* A delegated agent that was configured to decide its own effort (`reflex` /
|
|
28
|
+
* `auto`) cannot do so: the loop fixes the step's effort before any plugin hook
|
|
29
|
+
* runs, so the decision has to be taken on the *selection* instead, before that
|
|
30
|
+
* step reads it. That is a change of intent, not a routine decision, so it gets
|
|
31
|
+
* its own record rather than a disguised `effort` one: the configured marker is
|
|
32
|
+
* kept verbatim next to the level actually inherited, and a reader can see that
|
|
33
|
+
* the level came from the parent rather than from a System 1 judgment.
|
|
34
|
+
*/
|
|
35
|
+
export declare const EFFORT_INHERIT_RECORD_TYPE = "plugin:dsh-reflex/effort-inherit";
|
|
24
36
|
declare module '@deepseek-ai/dsh-session/types' {
|
|
25
37
|
interface PluginRecordMap {
|
|
26
38
|
/** One adaptive reasoning-effort decision, as dispatched. */
|
|
@@ -29,6 +41,8 @@ declare module '@deepseek-ai/dsh-session/types' {
|
|
|
29
41
|
'plugin:dsh-reflex/intervention': InterventionAuditRecord;
|
|
30
42
|
/** One pre-prune payload kept so a replacement stays verifiable. */
|
|
31
43
|
'plugin:dsh-reflex/pruned-original': PrunedOriginalRecord;
|
|
44
|
+
/** One delegated-agent marker replaced by the parent's level. */
|
|
45
|
+
'plugin:dsh-reflex/effort-inherit': EffortInheritAuditRecord;
|
|
32
46
|
}
|
|
33
47
|
}
|
|
34
48
|
/**
|
|
@@ -247,6 +261,62 @@ export declare function effortRecordsOf(events: readonly SessionEvent[] | undefi
|
|
|
247
261
|
* @returns whether it carries the fields this plugin writes.
|
|
248
262
|
*/
|
|
249
263
|
export declare function isEffortAuditRecord(data: unknown): data is EffortAuditRecord;
|
|
264
|
+
/**
|
|
265
|
+
* The JSON payload of one delegated-agent effort downgrade.
|
|
266
|
+
*
|
|
267
|
+
* Deliberately one record per *decision*, not per request: a child session may
|
|
268
|
+
* see its selection re-emitted several times, and only a change of outcome is
|
|
269
|
+
* news. `applied: null` means the marker was removed outright (the adapter's own
|
|
270
|
+
* default), which is a real outcome and must not look like a missing field.
|
|
271
|
+
*/
|
|
272
|
+
export interface EffortInheritAuditRecord {
|
|
273
|
+
/** The marker the deployment configured on the delegated agent (`reflex`/`auto`). */
|
|
274
|
+
requested: string;
|
|
275
|
+
/** The level the child now uses; `null` when the marker was removed. */
|
|
276
|
+
applied: string | null;
|
|
277
|
+
/**
|
|
278
|
+
* Why the delegation could not decide: `reflex`/`auto` is a per-turn
|
|
279
|
+
* System 1 decision taken inside the request waterfall, while a delegated
|
|
280
|
+
* step's effort is fixed before that waterfall runs.
|
|
281
|
+
*/
|
|
282
|
+
reason: 'subagent-cannot-decide';
|
|
283
|
+
/** The parent level that was copied; absent when the parent had none. */
|
|
284
|
+
inherited?: string;
|
|
285
|
+
/** Whether the parent had a recorded selection at all. */
|
|
286
|
+
parentLevel: 'present' | 'absent' | 'unreadable';
|
|
287
|
+
/** Provider/model of the child selection carrying the marker. */
|
|
288
|
+
provider: string;
|
|
289
|
+
model: string;
|
|
290
|
+
/** Human-readable, one line: what was configured and what it became. */
|
|
291
|
+
line: string;
|
|
292
|
+
/** Unix epoch milliseconds of the rewrite. */
|
|
293
|
+
at: number;
|
|
294
|
+
agentId?: string;
|
|
295
|
+
delegationDepth?: number;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Append one delegated-agent effort downgrade to a Session's log.
|
|
299
|
+
*
|
|
300
|
+
* Best-effort by the same contract as every other audit record here: a missing
|
|
301
|
+
* session (synthetic agent) or a rejected payload is swallowed and reported as
|
|
302
|
+
* `undefined`, never allowed to fail a turn.
|
|
303
|
+
* @param session - the delegated agent's session, when it has one.
|
|
304
|
+
* @param record - the rewrite to record.
|
|
305
|
+
* @returns the committed sequence number, or `undefined` when nothing was written.
|
|
306
|
+
*/
|
|
307
|
+
export declare function appendEffortInheritRecord(session: unknown, record: EffortInheritAuditRecord): number | undefined;
|
|
308
|
+
/**
|
|
309
|
+
* Read back the delegated-agent effort downgrades of one Session log.
|
|
310
|
+
* @param events - the session log, or any slice of it.
|
|
311
|
+
* @returns the validated records, oldest first; malformed payloads are dropped.
|
|
312
|
+
*/
|
|
313
|
+
export declare function effortInheritRecordsOf(events: readonly SessionEvent[] | undefined): EffortInheritAuditRecord[];
|
|
314
|
+
/**
|
|
315
|
+
* Validate one restored downgrade payload before a reader trusts it.
|
|
316
|
+
* @param data - the payload committed by an earlier build.
|
|
317
|
+
* @returns whether it carries the fields this plugin writes.
|
|
318
|
+
*/
|
|
319
|
+
export declare function isEffortInheritAuditRecord(data: unknown): data is EffortInheritAuditRecord;
|
|
250
320
|
/**
|
|
251
321
|
* Append one intervention decision to a Session's log.
|
|
252
322
|
*
|