The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
refactor(runtime): replace the legacy manager with engine facets (#1088)
Deea9895b02c040
diff --git a/cli/scripts/handoff-2026-10-08/mutate-runtime.py b/cli/scripts/handoff-2026-10-08/mutate-runtime.pyindex ed0baf973..15104c8e4 100644--- a/cli/scripts/handoff-2026-10-08/mutate-runtime.py+++ b/cli/scripts/handoff-2026-10-08/mutate-runtime.py@@ -1,30 +1,59 @@-# Flip one engine's runtime-profile reading at a time and check the runtime golden fails.-import subprocess, sys, os-cli = sys.argv[1]-M_ = 'src/lib/runtimeProfileManager.ts'-E = lambda e: f'src/engines/{e}/runtimeProfile.ts'-M = [- ('pi footer read as grok', M_, "engineNow('pi', 'its pane was read')?.parsePiFooterProfile(paneText)", "engineNow('grok', 'x')?.parseGrokFooterProfile(paneText)"),- ('grok footer ignored', M_, "engineNow('grok', 'its pane was read')?.parseGrokFooterProfile(paneText)", "null"),- ('agy footer ignored', M_, "engineNow('agy', 'its pane was read')?.parseAgyFooterProfile(paneText)", "null"),- ('devin footer ignored', M_, "engineNow('devin', 'its pane was read')?.devinFooterModel(paneText)", "null"),- ('hermes status ignored', M_, "engineNow('hermes', 'its pane was read')?.hermesStatusModel(paneText)", "null"),- ('commandcode banner ignored', M_, "engineNow('commandcode', 'its pane was read')?.commandcodeBannerModel(paneText)", "null"),- ('opencode footer without catalog', M_, "opencode?.opencodeFooterModelId(paneText, this.opencodeCatalogCache?.entries ?? [])", "opencode?.opencodeFooterModelId(paneText, [])"),- ('kilo footer without catalog', M_, "?.kiloFooterModelId(paneText, this.kiloCatalogCache?.entries ?? [])", "?.kiloFooterModelId(paneText, [])"),- ('hermes config effort', M_, " state.effort = parsed.effort ?? 'auto'\n state.observedAt = Date.now()\n const after = this.selectedModel(session)\n this.wake(session.sessionId)\n if (!silent && this.suppressNotifications === 0 && before !== after && !this.controls.has(session.sessionId)) {\n this.scheduleChanged(session.sessionId)\n }\n return before !== after\n }\n if (session.engine === 'muse') {", " state.effort = 'auto'\n state.observedAt = Date.now()\n const after = this.selectedModel(session)\n this.wake(session.sessionId)\n if (!silent && this.suppressNotifications === 0 && before !== after && !this.controls.has(session.sessionId)) {\n this.scheduleChanged(session.sessionId)\n }\n return before !== after\n }\n if (session.engine === 'muse') {"),- ('muse settings ignored', M_, "muse.parseMuseSettings(await readText(join(env.MUSE_CONFIG_DIR, 'settings.json')))", "muse.parseMuseSettings('')"),- ('amp session ignored', M_, "amp.parseAmpSession(await readText(join(env.AMP_STATE_DIR, 'session.json')))", "amp.parseAmpSession('')"),- ('devin catalog empty', M_, " entries = devin.parseDevinModelsOutput(result.stdout)", " entries = devin.parseDevinModelsOutput('')"),- ('cursor footer (manager own code)', M_, "const parsed = footerLines.map(parseCursorFooter).find((item) => item !== null)", "const parsed = null as ReturnType<typeof parseCursorFooter>"),+"""Break runtime wiring in an isolated worktree; every break must fail a golden assertion."""+import os+from pathlib import Path+import re+import subprocess+import sys++cli = Path(sys.argv[1]).resolve()+reader = lambda engine: f'src/engines/{engine}/profileReader.ts'+owner = 'src/lib/runtimeProfileState.ts'+observations = 'src/engines/otherRuntime.golden.spec.ts'+state = 'src/lib/runtimeProfileState.golden.spec.ts'+# Label, source, former expression, broken expression, golden, selected test.+mutations = [+ ('pi footer ignored', reader('pi'), 'pi.parsePiFooterProfile(paneText)', 'null', observations, 'pi: every pane'),+ ('grok footer ignored', reader('grok'), 'grok.parseGrokFooterProfile(paneText)', 'null', observations, 'grok: every pane'),+ ('agy footer ignored', reader('agy'), 'agy.parseAgyFooterProfile(paneText)', 'null', observations, 'agy: every pane'),+ ('devin footer ignored', reader('devin'), 'devin.devinFooterModel(paneText)', 'null', observations, 'resolves OpenCode'),+ ('hermes status ignored', reader('hermes'), 'hermes.hermesStatusModel(paneText)', 'null', observations, 'hermes: every pane'),+ ('commandcode banner ignored', reader('commandcode'), 'commandcode.commandcodeBannerModel(paneText)', 'null', observations, 'commandcode: every pane'),+ ('opencode catalog disconnected', reader('opencode'), 'opencode.opencodeFooterModelId(paneText, this.opencodeCatalogCache?.entries ?? [])', 'opencode.opencodeFooterModelId(paneText, [])', observations, 'resolves OpenCode'),+ ('kilo catalog disconnected', reader('kilo'), 'kilo.kiloFooterModelId(paneText, this.kiloCatalogCache?.entries ?? [])', 'kilo.kiloFooterModelId(paneText, [])', observations, 'resolves OpenCode'),+ ('hermes effort discarded', reader('hermes'), "state.effort = parsed.effort ?? 'auto'", "state.effort = 'auto'", observations, 'reads each config'),+ ('muse settings ignored', reader('muse'), "muse.parseMuseSettings(await readText(join(env.MUSE_CONFIG_DIR, 'settings.json')))", "muse.parseMuseSettings('')", observations, 'reads each config'),+ ('amp session ignored', reader('amp'), "amp.parseAmpSession(await readText(join(env.AMP_STATE_DIR, 'session.json')))", "amp.parseAmpSession('')", observations, 'reads each config'),+ ('devin catalog ignored', reader('devin'), 'devin.parseDevinModelsOutput(result.stdout)', "devin.parseDevinModelsOutput('')", observations, 'resolves OpenCode'),+ ('cursor footer ignored', reader('cursor'), 'const parsed = footerLines.map(parseCursorFooter).find((item) => item !== null)', 'const parsed = null', observations, 'cursor: every pane'),+ ('confirmed model corrupted', owner, 'state.model = target.model', "state.model = 'wrong-model'", state, 'linux'),+ ('forgotten state retained', owner, 'this.states.delete(sessionId)', 'void sessionId', state, 'linux'),+ ('config contribution dropped', owner, 'Object.assign(state, context.state)', 'Object.assign(state, {})', observations, 'reads each config'),]-for name, path, old, new in M:- p = os.path.join(cli, path)- s = open(p).read()- assert s.count(old) == 1, (name, s.count(old))- open(p, 'w').write(s.replace(old, new))++env = {**os.environ, 'TZ': 'UTC', 'TMPDIR': '/tmp'}+for key in ['RECORD_OTHER_ENGINES_GOLDEN', 'RECORD_RUNTIME_STATE_GOLDEN', 'TMUX', 'TMUX_PANE']:+ env.pop(key, None)+logs = cli.parent / '.harness' / 'runtime-mutations'+logs.mkdir(parents=True, exist_ok=True)+failed = []+for index, (name, path, old, new, golden, pattern) in enumerate(mutations, 1):+ file = cli / path+ original = file.read_text()+ if original.count(old) != 1:+ raise RuntimeError(f'{name}: expected one source anchor, got {original.count(old)}')+ file.write_text(original.replace(old, new))try:- r = subprocess.run(['node', 'node_modules/vitest/vitest.mjs', 'run', 'src/engines/otherRuntime.golden.spec.ts'], cwd=cli, capture_output=True, text=True)- print(f"{name:45s} {'FAILS (caught)' if r.returncode else 'PASSES (NOT caught)'}", flush=True)+ run = subprocess.run(['node', 'node_modules/vitest/vitest.mjs', 'run', golden, '-t', pattern, '--maxWorkers=1',+ '--testTimeout=15000', '--hookTimeout=45000'],+ cwd=cli, env=env, capture_output=True, text=True, timeout=150)+ output = run.stdout + run.stderr+ (logs / f'{index:02d}.log').write_text(output)+ caught = run.returncode != 0 and re.search(r'AssertionError|AssertionError:', output) is not None+ print(f'{name}: {"assertion caught" if caught else "NOT caught by an assertion"}', flush=True)+ if not caught:+ failed.append(name)finally:- open(p, 'w').write(s)+ file.write_text(original)+if failed:+ raise SystemExit('Unproven mutations: ' + ', '.join(failed))+print(f'All {len(mutations)} wiring mutations failed golden assertions.', flush=True)diff --git a/cli/src/architecture.spec.ts b/cli/src/architecture.spec.tsindex 7d187035f..0f0bff233 100644--- a/cli/src/architecture.spec.ts+++ b/cli/src/architecture.spec.ts@@ -255,7 +255,7 @@ const FACETS_FREE_OF_THEM: Array<[string, string]> = [['core/engines/cursorTasks.ts', '(o3)'],['core/turns/agyBackstop.ts', '(o3)'],// What the core reads of their model and effort, and how a switch of theirs would be driven.- ['lib/runtimeProfileManager.ts', '(o4)'],+ ['lib/runtimeProfileState.ts', '(o4)'],['lib/runtimeControl.ts', '(o4)'],// Where their conversations are: the registry's layouts and Cursor's homes, declared; bind's finders and// repair's readers, loaded; Cursor's discovery and its queued Tasks, built on first use; Hermes's store.@@ -323,7 +323,7 @@ describe('the daemon\'s shape', () => {it('runtime profile authority and wire values load contracts without vendor profile implementations', () => {for (const entry of ['core/engines/runtimeSessions.ts', 'core/engines/runtimeProfiles.ts',- 'core/engines/runtimeTransport.ts', 'lib/runtimeProfileWire.ts', 'lib/runtimeProfileManager.ts']) {+ 'core/engines/runtimeTransport.ts', 'lib/runtimeProfileWire.ts', 'lib/runtimeProfileState.ts']) {expect([...closureOf(entry).keys()].filter(file => /^engines\/(claude|codex)\//.test(file)), entry).toEqual([])expect(closureOf(entry).has('lib/runtimeProfile.ts'), entry).toBe(false)}diff --git a/cli/src/core/engines/runtimeProfiles.spec.ts b/cli/src/core/engines/runtimeProfiles.spec.tsindex 4e336c367..881f82821 100644--- a/cli/src/core/engines/runtimeProfiles.spec.ts+++ b/cli/src/core/engines/runtimeProfiles.spec.ts@@ -15,7 +15,7 @@ function setup(isolated = true) {cwd: '/tmp', transcriptPath: '/tmp/transcript' } as RegisteredSessionconst target = { sessionId: session.agentId, engine: session.engine, model: 'reported-model', effort: 'high' }const id = encodeRuntimeProfile(target)- const legacy = new RuntimeProfileManager()+ const local = new RuntimeProfileManager()const read = vi.fn(async (_engine: string, context: RuntimeContext, operation: RuntimeOperation): Promise<RuntimeAnswer> => {const state = { ...context.state, model: target.model, effort: target.effort }return { state, cliVersion: session.cliVersion, selectedModel: id, control: context.control ?? null,@@ -23,18 +23,18 @@ function setup(isolated = true) {...(operation.kind === 'catalog' ? { catalog: [{ slug: target.model, displayName: 'Worker choice', listed: true, defaultEffort: 'high', efforts: ['high'] }] } : {}),...(operation.kind === 'effort' ? { effortAllowed: operation.effort === 'high' } : {}) }})- const profiles = createRuntimeProfiles({ legacy, handles: engine => isolated && engine === 'codex',+ const profiles = createRuntimeProfiles({ local, handles: engine => isolated && engine === 'codex',resolve: value => [session.agentId, session.sessionId].includes(value) ? session : undefined,transport: { read, connected: vi.fn(), disconnected: vi.fn() } })active.push(profiles)- return { session, target: { ...target, id }, legacy, read, profiles }+ return { session, target: { ...target, id }, local, read, profiles }}afterEach(() => { active.splice(0).forEach(p => p.stop()); vi.useRealTimers(); vi.restoreAllMocks() })describe('runtime profile routing', () => {it('uses only worker reports for isolated observations, catalog and eligibility', async () => {const t = setup(), { profiles: p, session: s } = t- const inline = vi.spyOn(t.legacy, 'ingestPane').mockImplementation(() => { throw new Error('inline reader called') })+ const inline = vi.spyOn(t.local, 'ingestPane').mockImplementation(() => { throw new Error('inline reader called') })expect(p.selectedModel(s)).toBeNull()expect(await p.ingestPane(s, 'vendor UI')).toBe(true)expect(p.selectedModel(s)).toBe(t.target.id)@@ -91,23 +91,23 @@ describe('runtime profile routing', () => {expect(changed).toHaveBeenCalledWith(s.sessionId)p.cancelControl(s.sessionId)p.forget(s.sessionId); expect(p.getState(s.sessionId)).toEqual(blankRuntimeState())- t.legacy.onChanged?.('legacy-session'); expect(changed).toHaveBeenLastCalledWith('legacy-session')- p.stop(); t.legacy.onChanged?.('later'); expect(changed).toHaveBeenLastCalledWith('legacy-session')+ t.local.onChanged?.('local-session'); expect(changed).toHaveBeenLastCalledWith('local-session')+ p.stop(); t.local.onChanged?.('later'); expect(changed).toHaveBeenLastCalledWith('local-session')})it('preserves explicit inline compatibility and the unchanged other-engine methods', async () => {- const t = setup(false), { profiles: p, session: s, legacy } = t- const pane = vi.spyOn(legacy, 'ingestPane').mockReturnValue(true)- const config = vi.spyOn(legacy, 'ingestConfig').mockResolvedValue(true)- const raw = vi.spyOn(legacy, 'ingest').mockReturnValue(false)- const hydrate = vi.spyOn(legacy, 'hydrate').mockImplementation(() => {})- const fields = vi.spyOn(legacy, 'transcriptFields').mockReturnValue(['model'])+ const t = setup(false), { profiles: p, session: s, local } = t+ const pane = vi.spyOn(local, 'ingestPane').mockReturnValue(true)+ const config = vi.spyOn(local, 'ingestConfig').mockResolvedValue(true)+ const raw = vi.spyOn(local, 'ingest').mockReturnValue(false)+ const hydrate = vi.spyOn(local, 'hydrate').mockImplementation(() => {})+ const fields = vi.spyOn(local, 'transcriptFields').mockReturnValue(['model'])const stage = { ingest: vi.fn(), commit: vi.fn() }- vi.spyOn(legacy, 'beginHydrate').mockReturnValue(stage)- vi.spyOn(legacy, 'supportsControl').mockReturnValue(true)- vi.spyOn(legacy, 'effortAllowed').mockReturnValue(true)- vi.spyOn(legacy, 'codexCatalog').mockResolvedValue([])- vi.spyOn(legacy, 'modelsForSession').mockResolvedValue([])+ vi.spyOn(local, 'beginHydrate').mockReturnValue(stage)+ vi.spyOn(local, 'supportsControl').mockReturnValue(true)+ vi.spyOn(local, 'effortAllowed').mockReturnValue(true)+ vi.spyOn(local, 'codexCatalog').mockResolvedValue([])+ vi.spyOn(local, 'modelsForSession').mockResolvedValue([])expect(p.ingestPane(s, 'pane')).toBe(true); expect(pane).toHaveBeenCalledWith(s, 'pane', false)expect(await p.ingestConfig(s)).toBe(true); expect(config).toHaveBeenCalledWith(s, false)expect(p.ingest(s, '{}')).toBe(false); expect(raw).toHaveBeenCalledWith(s, '{}', false)diff --git a/cli/src/core/engines/runtimeProfiles.ts b/cli/src/core/engines/runtimeProfiles.tsindex 27297102e..02a9c08da 100644--- a/cli/src/core/engines/runtimeProfiles.ts+++ b/cli/src/core/engines/runtimeProfiles.ts@@ -1,5 +1,5 @@/** Route profile interpretation to workers while keeping accepted state and control authority in core. */-import type { LegacyRuntimeProfileManager } from '../../lib/runtimeProfileManager.js'+import type { RuntimeProfileState } from '../../lib/runtimeProfileState.js'import type { RegisteredSession } from '../../lib/registry.js'import type { LiveFrame } from '../../engines/worker/liveProtocol.js'import type { RuntimeProfile, RuntimeRecord } from '../../engines/facets/runtime.js'@@ -16,7 +16,7 @@ export interface ProfileHydration {}export interface RuntimeProfilesDeps {- legacy: LegacyRuntimeProfileManager+ local: RuntimeProfileStatehandles(engine: string): booleanresolve(id: string): RegisteredSession | undefinedtransport: RuntimeTransport@@ -32,12 +32,12 @@ function evidence(frames: readonly LiveFrame[]): RuntimeRecord[] {return records}-export function createRuntimeProfiles({ legacy, handles, resolve, transport }: RuntimeProfilesDeps) {+export function createRuntimeProfiles({ local, handles, resolve, transport }: RuntimeProfilesDeps) {let changed: ((id: string) => void) | null = nullconst remote = createRuntimeSessions({ resolve, transport, changed: id => changed?.(id) })- legacy.onChanged = id => changed?.(id)- const forId = (id: string) => handles(resolve(id)?.engine ?? '') ? remote : legacy- const forSession = (session: RegisteredSession) => handles(session.engine) ? remote : legacy+ local.onChanged = id => changed?.(id)+ const forId = (id: string) => handles(resolve(id)?.engine ?? '') ? remote : local+ const forSession = (session: RegisteredSession) => handles(session.engine) ? remote : localconst rawUnavailable = (): never => { throw new EngineReadError('ENGINE_INVALID_REQUEST') }const observe = async (session: RegisteredSession, operation: { kind: 'config' } | { kind: 'pane'; text: string }, silent: boolean): Promise<boolean> => {const before = remote.selectedModel(session)@@ -57,23 +57,23 @@ export function createRuntimeProfiles({ legacy, handles, resolve, transport }: RconfirmControlProfile: (target: RuntimeProfile) => forId(target.sessionId).confirmControlProfile(target),waitForModel: (id: string, timeout: number) => forId(id).waitForModel(id, timeout),waitForProfile: (id: string, timeout: number) => forId(id).waitForProfile(id, timeout),- forget(id: string): void { remote.forget(id); legacy.forget(id) },+ forget(id: string): void { remote.forget(id); local.forget(id) },stop(): void { remote.stop(); changed = null },withoutChangeEvents<T>(run: () => Promise<T>): Promise<T> {- return remote.withoutChangeEvents(() => legacy.withoutChangeEvents(run))+ return remote.withoutChangeEvents(() => local.withoutChangeEvents(run))},ingest(session: RegisteredSession, line: string, silent = false): boolean {- return handles(session.engine) ? rawUnavailable() : legacy.ingest(session, line, silent)+ return handles(session.engine) ? rawUnavailable() : local.ingest(session, line, silent)},hydrate(session: RegisteredSession, lines: string[]): void {if (handles(session.engine)) rawUnavailable()- legacy.hydrate(session, lines)+ local.hydrate(session, lines)},transcriptFields(session: RegisteredSession, line: string) {- return handles(session.engine) ? rawUnavailable() : legacy.transcriptFields(session, line)+ return handles(session.engine) ? rawUnavailable() : local.transcriptFields(session, line)},beginHydrate(session: RegisteredSession): ProfileHydration {- if (!handles(session.engine)) return legacy.beginHydrate(session)+ if (!handles(session.engine)) return local.beginHydrate(session)const pending = remote.stage(session, true, true)return { ingest: rawUnavailable, commit: rawUnavailable,ingestFrames: frames => pending.ingest(evidence(frames)),@@ -84,36 +84,36 @@ export function createRuntimeProfiles({ legacy, handles, resolve, transport }: Rreturn remote.prepare(session, evidence(frames))},ingestPane(session: RegisteredSession, text: string, silent = false): boolean | Promise<boolean> {- return handles(session.engine) ? observe(session, { kind: 'pane', text }, silent) : legacy.ingestPane(session, text, silent)+ return handles(session.engine) ? observe(session, { kind: 'pane', text }, silent) : local.ingestPane(session, text, silent)},ingestConfig(session: RegisteredSession, silent = false): Promise<boolean> {- return handles(session.engine) ? observe(session, { kind: 'config' }, silent) : legacy.ingestConfig(session, silent)+ return handles(session.engine) ? observe(session, { kind: 'config' }, silent) : local.ingestConfig(session, silent)},async supportsControl(session: RegisteredSession): Promise<boolean> {if (session.gateway) return false- return handles(session.engine) ? (await remote.read(session, { kind: 'describe' })).supportsControl : legacy.supportsControl(session)+ return handles(session.engine) ? (await remote.read(session, { kind: 'describe' })).supportsControl : local.supportsControl(session)},async effortAllowed(session: RegisteredSession, model: string, effort: string, listed: readonly string[] | null): Promise<boolean> {return handles(session.engine)? (await remote.read(session, { kind: 'effort', model, effort, listed: listed && [...listed] })).effortAllowed!- : legacy.effortAllowed(session, model, effort, listed)+ : local.effortAllowed(session, model, effort, listed)},async codexCatalog(session: RegisteredSession) {- return handles(session.engine) ? (await remote.read(session, { kind: 'catalog' })).catalog! : legacy.codexCatalog(session)+ return handles(session.engine) ? (await remote.read(session, { kind: 'catalog' })).catalog! : local.codexCatalog(session)},async modelsForSession(session: RegisteredSession) {if (session.gateway) return []- return handles(session.engine) ? (await remote.read(session, { kind: 'models' })).models! : legacy.modelsForSession(session)+ return handles(session.engine) ? (await remote.read(session, { kind: 'models' })).models! : local.modelsForSession(session)},async modelsForSessions(sessions: RegisteredSession[]) {return (await Promise.all(sessions.map(session => this.modelsForSession(session)))).flat()},- cursorTarget: legacy.cursorTarget.bind(legacy),- devinTarget: legacy.devinTarget.bind(legacy),- commandcodeTarget: legacy.commandcodeTarget.bind(legacy),- hermesTarget: legacy.hermesTarget.bind(legacy),- opencodeCatalog: legacy.opencodeCatalog.bind(legacy),- kiloCatalog: legacy.kiloCatalog.bind(legacy),+ cursorTarget: local.cursorTarget.bind(local),+ devinTarget: local.devinTarget.bind(local),+ commandcodeTarget: local.commandcodeTarget.bind(local),+ hermesTarget: local.hermesTarget.bind(local),+ opencodeCatalog: local.opencodeCatalog.bind(local),+ kiloCatalog: local.kiloCatalog.bind(local),}}diff --git a/cli/src/core/main.ts b/cli/src/core/main.tsindex a7380862e..4103d2a49 100644--- a/cli/src/core/main.ts+++ b/cli/src/core/main.ts@@ -198,7 +198,7 @@ import { forgetAgentProject } from '../lib/agentProject.js'import { createUsageLink } from './usageLink.js'import type { UsageSnapshots } from './usageLink.js'import type { AgentUsageTarget } from '../lib/agentUsageWire.js'-import { LegacyRuntimeProfileManager, type RuntimeModelOption } from '../lib/runtimeProfileManager.js'+import { RuntimeProfileState, type RuntimeModelOption } from '../lib/runtimeProfileState.js'import { createRuntimeProfiles } from './engines/runtimeProfiles.js'import { createRuntimeTransport } from './engines/runtimeTransport.js'import { RuntimeProfileController } from '../lib/runtimeControl.js'@@ -624,7 +624,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {// Which engine workers are linked now: a close's read refused by a restart waits here for the new link.const engineLinks = createEngineLinks()const runtimeProfiles = createRuntimeProfiles({- legacy: new LegacyRuntimeProfileManager(engine => isolatedRuntime(engine) ? undefined : inline?.runtimeFor(engine)),+ local: new RuntimeProfileState(engine => isolatedRuntime(engine) ? undefined : inline?.runtimeFor(engine), id => registry.resolve(id)),handles: isolatedRuntime,resolve: id => registry.resolve(id), transport: runtimeTransport })const questionControls = createQuestionControls({diff --git a/cli/src/core/transcripts/attach.runtime.spec.ts b/cli/src/core/transcripts/attach.runtime.spec.tsnew file mode 100644index 000000000..e27ca87e5--- /dev/null+++ b/cli/src/core/transcripts/attach.runtime.spec.ts@@ -0,0 +1,77 @@+import { mkdtempSync, rmSync, statSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { afterEach, expect, it, vi } from 'vitest'+import { liveFor } from '../../engines/live.js'+import { runtime as claudeRuntime } from '../../engines/claude/runtimeProfile.js'+import type { RegisteredSession } from '../../lib/registry.js'+import { RuntimeProfileState } from '../../lib/runtimeProfileState.js'+import { createAttach } from './attach.js'+import { createSessionNormalizers } from './normalizers.js'++const roots: string[] = []+afterEach(() => {+ vi.restoreAllMocks()+ for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })+})++function setup() {+ const root = mkdtempSync(join(tmpdir(), 'attach-profile-'))+ roots.push(root)+ const path = join(root, 'session.jsonl')+ writeFileSync(path, `${JSON.stringify({ type: 'assistant', version: '2.1.209',+ message: { role: 'assistant', model: 'claude-opus-5', content: [] } })}\n`)+ const session = { agentId: 'agent', sessionId: 'session', engine: 'claude', cwd: root,+ transcriptPath: path, cliVersion: '2.1.100', model: 'claude-sonnet-4-6' } as RegisteredSession+ let finish!: (effort: string) => void, fail!: (error: Error) => void+ const configuredEffort = vi.fn(() => new Promise<string>((resolve, reject) => { finish = resolve; fail = reject }))+ const profiles = new RuntimeProfileState(() => ({ ...claudeRuntime, configuredEffort }), () => session)+ profiles.hydrate(session, [])+ profiles.confirmEffort(session.sessionId, 'high')+ const before = profiles.getState(session.sessionId)+ const normalizers = createSessionNormalizers()+ const oldParser = liveFor('claude')!.create(session)+ normalizers.liveParsers.set(session.sessionId, oldParser)+ const hold = { offset: statSync(path).size, expired: false, release: vi.fn() }+ const emit = vi.fn(), addSession = vi.fn(async () => {})+ const attach = createAttach({ liveFor, normalizers, runtimeProfiles: profiles,+ terminalGone: async () => false, watcher: { hold: async () => hold, tails: () => true, addSession },+ cursorDiscovery: { add: async () => {} }, device: () => undefined,+ captureTerminal: async () => null, emit, announceTurnAborted: vi.fn(),+ questionWatcher: { start: vi.fn() }, terminalLabel: () => 'private fixture',+ dbs: { opencode: join(root, 'o.db'), kilo: join(root, 'k.db'), devin: join(root, 'd.db') },+ devinHome: root, hermesDb: async () => join(root, 'h.db'), concurrency: 1,+ })+ const attaching = attach.attachSession(session, true)+ return { session, profiles, before, normalizers, oldParser, hold, emit, addSession, configuredEffort,+ attaching, finish: (effort: string) => finish(effort), fail: (error: Error) => fail(error) }+}++it.each(['expired', 'superseded', 'failed', 'installed'] as const)(+ 'publishes the local parser and profile together after config: %s', async outcome => {+ const p = setup()+ await vi.waitFor(() => expect(p.configuredEffort).toHaveBeenCalledOnce())+ // Reading history and waiting for config must expose neither its version nor its model.+ expect(p.profiles.getState(p.session.sessionId)).toEqual(p.before)+ expect(p.session.cliVersion).toBe('2.1.100')+ expect(p.normalizers.liveParsers.get(p.session.sessionId)).toBe(p.oldParser)+ if (outcome === 'expired') p.hold.expired = true+ if (outcome === 'superseded') p.profiles.confirmEffort(p.session.sessionId, 'high')+ if (outcome === 'failed') p.fail(new Error('private config unavailable'))+ else p.finish('low')+ expect(await p.attaching).toBe(true)+ expect(p.hold.release).toHaveBeenCalled()+ if (outcome === 'installed') {+ expect(p.profiles.getState(p.session.sessionId)).toMatchObject({ model: 'claude-opus-5', effort: 'low', cliVersion: '2.1.209' })+ expect(p.session.cliVersion).toBe('2.1.209')+ expect(p.normalizers.liveParsers.get(p.session.sessionId)).not.toBe(p.oldParser)+ } else {+ expect(p.profiles.getState(p.session.sessionId)).toMatchObject({ ...p.before, observedAt: expect.any(Number) })+ expect(p.session.cliVersion).toBe('2.1.100')+ expect(p.normalizers.liveParsers.get(p.session.sessionId)).toBe(p.oldParser)+ expect(p.emit).not.toHaveBeenCalled()+ expect(p.addSession).not.toHaveBeenCalled()+ }+ p.profiles.forget(p.session.sessionId)+ },+)diff --git a/cli/src/core/transcripts/attach.ts b/cli/src/core/transcripts/attach.tsindex d8c2ea24d..9448c6790 100644--- a/cli/src/core/transcripts/attach.ts+++ b/cli/src/core/transcripts/attach.ts@@ -231,7 +231,6 @@ export function createAttach({return handover.hold ? keepLiveNormalizer('could not reach its engine worker') : true}if (handover.hold?.expired) { remote.discard(prepared); return keepLiveNormalizer('outlasted its hold on the tail') }- if (!profileHydration.commitWith) profileHydration.commit()fromEnd = { next: prepared.page.cursor.offset, records: prepared.records, content: prepared.content }handover.next = fromEnd.nexthistoryTurnOpen = !live && prepared.state.handle.turnOpen@@ -245,6 +244,7 @@ export function createAttach({const live = replayLive && handover.hold === nullconst stream = new TranscriptFold(fromEndFold.ingest, fromEndFold.turnOpen, live)const profile = runtimeProfiles.beginHydrate(session)+ profileHydration = profileconst read = await attachTranscript(session.transcriptPath, fromEndFold.rules, {// Ids named for this window cannot repeat ones another fold of the session sent.start: (span) => parser!.windowStart(span.turnFrom),@@ -255,7 +255,8 @@ export function createAttach({if (handover.hold && (read.failed || handover.hold.expired)) {return keepLiveNormalizer(read.failed ? 'could not read the transcript' : 'outlasted its hold on the tail')}- profile.commit()+ try { await profile.config?.() }+ catch { return keepLiveNormalizer('could not read its runtime profile') }fromEnd = readhandover.next = read.nexthistoryTurnOpen = take(stream.finish())@@ -289,10 +290,14 @@ export function createAttach({remote!.discard(prepared); remote!.retry(session)return keepLiveNormalizer('was superseded while reading')}+ if (!profileHydration?.commitWith) profileHydration?.commit()liveParsers.set(session.sessionId, prepared.state.handle)} else if (parser) {if (!fromEnd) historyTurnOpen = fold((line) => parser.ingest(line).events, () => parser.turnOpen)- liveParsers.set(session.sessionId, parser)+ const install = () => { liveParsers.set(session.sessionId, parser); return true }+ if (profileHydration?.commitWith) {+ if (!profileHydration.commitWith(install)) return keepLiveNormalizer('was superseded while reading')+ } else { install(); profileHydration?.commit() }} else if (engine('cursor')) {const normalizer = new (engine('cursor')!).CursorNormalizer('live', session.sessionId)historyTurnOpen = fold((line) => normalizer.ingest(line), () => normalizer.turnOpen)diff --git a/cli/src/engines/__fixtures__/other-runtime.golden.json b/cli/src/engines/__fixtures__/other-runtime.golden.jsonindex 0a81a830f..c7e24295f 100644--- a/cli/src/engines/__fixtures__/other-runtime.golden.json+++ b/cli/src/engines/__fixtures__/other-runtime.golden.json@@ -379,6 +379,7 @@"path","vitest","./registry.js",+ "../engines/inProcess.js","./runtimeProfile.js","engine","session:1",@@ -608,6 +609,7 @@"vitest","../engines/codex/modelPicker.js","./registry.js",+ "../engines/inProcess.js","./runtimeProfile.js","./runtimeProfileController.js","./__fixtures__/rewindPickers.js",@@ -926,7 +928,11 @@"claude-4.5-sonnet","Sonnet 4.5 / Auto","→ Add a follow-up",- "UNSUPPORTED_CLI_VERSION"+ "UNSUPPORTED_CLI_VERSION",+ "refuses a switch of another engine whose code could not be loaded, before any key or the input lock",+ "vibe/minimax-m3",+ "supportsControl",+ "MiniMax M3"],"lib/runtimeProfileManager.spec.ts": ["node:fs",@@ -939,6 +945,7 @@"./runtimeProfileManager.js","./runtimeProfile.js","./runtimeProfileWire.js",+ "../engines/inProcess.js","__fixtures__","utf8","engine",@@ -948,15 +955,24 @@"1.0.0","/tmp","/tmp/profile-recording.jsonl",- "runtime profiles without the pilot implementations",+ "another engine whose code could not be loaded",+ "reads nothing of its panes, config files or catalog, and leaves its chips as they were",+ "devin",+ "hermes",+ "commandcode",+ "opencode",+ "kilo",+ "grok",+ "agy",+ "any pane",+ "muse","amp",+ "runtime profiles without the pilot implementations","amp-session.jsonl","amp-session-queued.jsonl",- "muse","muse-session.jsonl","copilot","copilot-session.jsonl",- "agy","agy-session.jsonl","preserves the registry seed when replaying the recorded %s transcript %s","unknown",@@ -991,7 +1007,7 @@]},"cases": {- "opencode panes": "715595c7a8b411a7eddd",+ "opencode panes": "7acacee90b90e18e25f7","opencode transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","opencode transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","opencode transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1017,7 +1033,7 @@"opencode transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","opencode transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","opencode switch": "a5ff8a8d4c7b2b9f2c20",- "cursor panes": "35a72b9e8329895bb001",+ "cursor panes": "917e520a3ed9dd31ae9a","cursor transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","cursor transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","cursor transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1043,7 +1059,7 @@"cursor transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","cursor transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "db9e473dd8d5918e73ea","cursor switch": "a5ff8a8d4c7b2b9f2c20",- "kilo panes": "67c55990c7776c6d6175",+ "kilo panes": "10a4fa3919037b67f4f2","kilo transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","kilo transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","kilo transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1069,7 +1085,7 @@"kilo transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","kilo transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","kilo switch": "a5ff8a8d4c7b2b9f2c20",- "devin panes": "67c55990c7776c6d6175",+ "devin panes": "10a4fa3919037b67f4f2","devin transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","devin transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","devin transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1095,7 +1111,7 @@"devin transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","devin transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","devin switch": "a5ff8a8d4c7b2b9f2c20",- "hermes panes": "401aff6dcd9ec2246c45",+ "hermes panes": "8e332a7aa0ea09e55cd5","hermes transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","hermes transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","hermes transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1121,7 +1137,7 @@"hermes transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","hermes transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","hermes switch": "a5ff8a8d4c7b2b9f2c20",- "amp panes": "67c55990c7776c6d6175",+ "amp panes": "10a4fa3919037b67f4f2","amp transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","amp transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","amp transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1147,7 +1163,7 @@"amp transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","amp transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","amp switch": "a5ff8a8d4c7b2b9f2c20",- "agy panes": "4a7692c7072a9c921556",+ "agy panes": "bdcfead0940bfc525994","agy transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","agy transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","agy transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1173,7 +1189,7 @@"agy transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","agy transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","agy switch": "a5ff8a8d4c7b2b9f2c20",- "grok panes": "81052bb6d505e26eb159",+ "grok panes": "b6ae70ee3abbe0cdb93c","grok transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","grok transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","grok transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1199,7 +1215,7 @@"grok transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","grok transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","grok switch": "a5ff8a8d4c7b2b9f2c20",- "copilot panes": "67c55990c7776c6d6175",+ "copilot panes": "10a4fa3919037b67f4f2","copilot transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","copilot transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","copilot transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1225,7 +1241,7 @@"copilot transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","copilot transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","copilot switch": "a5ff8a8d4c7b2b9f2c20",- "commandcode panes": "906036a2d7daf69b5f32",+ "commandcode panes": "fdb25cdd0d66b61c2435","commandcode transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","commandcode transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","commandcode transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1251,7 +1267,7 @@"commandcode transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","commandcode transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "6cfd51fd6186b776feb1","commandcode switch": "a5ff8a8d4c7b2b9f2c20",- "muse panes": "67c55990c7776c6d6175",+ "muse panes": "10a4fa3919037b67f4f2","muse transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","muse transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","muse transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1277,7 +1293,7 @@"muse transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","muse transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","muse switch": "a5ff8a8d4c7b2b9f2c20",- "pi panes": "bdc86b6f3641eff1e841",+ "pi panes": "35b331ddd26ee9f986c6","pi transcript: lib/__fixtures__/agy-session.jsonl": "75fb94294849f1378a16","pi transcript: lib/__fixtures__/amp-session-queued.jsonl": "570c99b3f3956b025567","pi transcript: lib/__fixtures__/amp-session.jsonl": "9c9cec21f716a0927c48",@@ -1303,10 +1319,10 @@"pi transcript: engines/muse/normalizer.spec.ts#cdc1c45e4378": "01a89b866f339f9ca63f","pi transcript: engines/pi/normalizer.spec.ts#74a8b245d519": "9c9cec21f716a0927c48","pi switch": "a5ff8a8d4c7b2b9f2c20",- "hermes config": "07a06bd5eafee1d69eba",- "muse config": "616c142cf5e37f99e56a",- "amp config": "6b6419ef529e39732cb3",- "commandcode config": "09f0ea0fcad2465bec98",+ "hermes config": "27d692b96d6c23b60ffe",+ "muse config": "b8c8f032f30f57741436",+ "amp config": "d5c3b8013090a7dc126c",+ "commandcode config": "28aca2a05b3be7549f22","opencode catalog #0: none": "f1caf45cac5732aea084","opencode catalog #1: a9127f3d3436": "f1caf45cac5732aea084","opencode catalog #2: 9dc81d7015f7": "f1caf45cac5732aea084",diff --git a/cli/src/engines/agy/inProcess.ts b/cli/src/engines/agy/inProcess.tsindex 9357ce3a3..4d6762be4 100644--- a/cli/src/engines/agy/inProcess.ts+++ b/cli/src/engines/agy/inProcess.ts@@ -7,3 +7,5 @@ export { AgyNormalizer, agyMessagesToEvents, lastAgyTurnText } from './normalizeexport { agyPaneIdle, parseAgyFooterProfile } from './runtimeProfile.js'export { agyConversationForPid, findAgyTranscript } from './session.js'export { agyProvider } from '../../lib/sessionSearch/externals/agy.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/agy/profileReader.ts b/cli/src/engines/agy/profileReader.tsnew file mode 100644index 000000000..6085112af--- /dev/null+++ b/cli/src/engines/agy/profileReader.ts@@ -0,0 +1,20 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import * as agy from './runtimeProfile.js'++class ProfileReader {+ readonly engine = 'agy' as const++ pane(context: InlineRuntimeContext, paneText: string): void | false {+ const { state } = context+ // agy's transcript never names the model, so the pane footer is the only continuous source; the+ // hook payload's `modelName` seeds it at session start.+ const footer = agy.parseAgyFooterProfile(paneText)+ if (footer) {+ state.model = footer.model+ state.effort = footer.effort+ state.observedAt = Date.now()+ }+ }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'agy' } { return new ProfileReader() }diff --git a/cli/src/engines/amp/inProcess.ts b/cli/src/engines/amp/inProcess.tsindex d35a88f54..c616468d5 100644--- a/cli/src/engines/amp/inProcess.ts+++ b/cli/src/engines/amp/inProcess.ts@@ -6,3 +6,5 @@export { AmpNormalizer, ampMessagesToEvents, lastAmpTurnText } from './normalizer.js'export { ampThreadToEvents, readAmpThread } from './threadExport.js'export { parseAmpSession } from './runtimeProfile.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/amp/profileReader.ts b/cli/src/engines/amp/profileReader.tsnew file mode 100644index 000000000..1433fa06a--- /dev/null+++ b/cli/src/engines/amp/profileReader.ts@@ -0,0 +1,23 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import { readRuntimeText as readText } from '../kit/runtimeReader.js'+import { env } from '../../config/env.js'+import { join } from 'node:path'+import * as amp from './runtimeProfile.js'++class ProfileReader {+ readonly engine = 'amp' as const++ async config(context: InlineRuntimeContext): Promise<boolean> {+ const { state } = context+ // Amp has no models — only agent MODES — so the mode is reported as the model and there is no+ // second axis to report. `~/.local/share/amp/session.json` is the only local place it is written.+ const parsed = amp.parseAmpSession(await readText(join(env.AMP_STATE_DIR, 'session.json')))+ if (parsed.mode) state.model = parsed.mode+ state.effort = 'auto'+ state.observedAt = Date.now()++ return true+ }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'amp' } { return new ProfileReader() }diff --git a/cli/src/engines/commandcode/inProcess.ts b/cli/src/engines/commandcode/inProcess.tsindex 62321914b..3e2e146de 100644--- a/cli/src/engines/commandcode/inProcess.ts+++ b/cli/src/engines/commandcode/inProcess.ts@@ -6,3 +6,5 @@export { CommandCodeNormalizer, commandCodeRunError, commandCodeRunErrorSummary, commandcodeMessagesToEvents, lastCommandCodeTurnText, windowCommandCodeLines } from './normalizer.js'export { COMMANDCODE_EFFORT_LEVELS, COMMANDCODE_EFFORTS, commandcodeBannerModel, countCommandcodeRefusals, parseCommandcodeModelsOutput } from './runtimeProfile.js'export { commandcodeProvider } from '../../lib/sessionSearch/externals/commandcode.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/commandcode/profileReader.ts b/cli/src/engines/commandcode/profileReader.tsnew file mode 100644index 000000000..7b6c9fdbf--- /dev/null+++ b/cli/src/engines/commandcode/profileReader.ts@@ -0,0 +1,140 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import type { RuntimeModelOption } from '../facets/runtime.js'+import { effortLabel, encodeRuntimeProfile, readJson, record, runtimeModelLabel, text, RUNTIME_EFFORTS } from '../kit/runtime.js'+import { env } from '../../config/env.js'+import { join } from 'node:path'+import { execFile } from 'node:child_process'+import { promisify } from 'node:util'+import * as commandcode from './runtimeProfile.js'+import type { CommandcodeModelTarget } from './runtimeProfile.js'++const execFileAsync = promisify(execFile)+const CATALOG_TTL_MS = 5 * 60_000++const EFFORTS = RUNTIME_EFFORTS+/** Command Code ids are "vendor/name"; everything we store and show uses the name alone. */+function shortCommandcodeModel(id: string): string {+ return id.slice(id.lastIndexOf('/') + 1)+}++/**+ * Command Code keeps the reasoning level in its GLOBAL config, keyed by the FULL gateway id:+ * { "model": "deepseek/deepseek-v4-flash", "reasoningEffort": { "deepseek/deepseek-v4-flash": "high" } }+ * Nothing in the transcript, the pane footer or the session header carries it, so this file is the only+ * source. It is per MACHINE rather than per session: two agents on the same model necessarily read the same+ * level. Matching is done on the short name because that is what the running model is stored as.+ */+/** The configured level for `model`, or 'auto' when the model has none set. */+async function commandcodeConfiguredEffort(model: string | null): Promise<{ effort: string; defaultModel: string }> {+ const config = await readJson(join(env.COMMANDCODE_HOME, 'config.json'))+ const defaultModel = shortCommandcodeModel(text(config?.model))+ const efforts = record(config?.reasoningEffort)+ const wanted = model || defaultModel+ if (!efforts || !wanted) return { effort: 'auto', defaultModel }+ for (const [id, level] of Object.entries(efforts)) {+ if (shortCommandcodeModel(id) !== wanted) continue+ const normalized = text(level).toLowerCase()+ if (normalized && normalized !== 'default' && EFFORTS.has(normalized)) return { effort: normalized, defaultModel }+ }+ return { effort: 'auto', defaultModel }+}+++class ProfileReader {+ readonly engine = 'commandcode' as const+ private commandcodeCatalogCache: { key: string; expiresAt: number; entries: CommandcodeModelTarget[] } | null = null+ private readonly commandcodeTargets = new Map<string, Map<string, CommandcodeModelTarget>>()++ pane(context: InlineRuntimeContext, paneText: string): void | false {+ const { state } = context+ // `/model` reprints the session banner (`# models: kimi-k2.6 · taste-1`) with the new model. The+ // transcript would say the same thing, but only after the NEXT turn runs — too late to confirm a+ // switch, and long enough for the chip to look stuck.+ const model = commandcode.commandcodeBannerModel(paneText)+ if (model && model !== state.model) {+ state.model = model+ state.observedAt = Date.now()+ // Effort is stored per model in the CLI's global config, so the level we hold belongs to the old+ // one. Re-read rather than carry it across.+ context.refreshConfig(true)+ }+ }++ transcript(context: InlineRuntimeContext, raw: Record<string, unknown>): void {+ const { state } = context+ const before = state.model+ const model = text(raw.model)+ if (!model) return+ state.model = shortCommandcodeModel(model)+ // Effort is NOT touched here: it comes from the CLI config (ingestConfig), and stamping 'auto' on every+ // assistant line would wipe a configured level a second after it was read.+ state.observedAt = Date.now()+ if (state.model !== before) context.refreshConfig()+ }++ target(sessionId: string, profileId: string): CommandcodeModelTarget | null {+ return this.commandcodeTargets.get(sessionId)?.get(profileId) ?? null+ }++ forget(sessionId: string): void { this.commandcodeTargets.delete(sessionId) }++ async models(context: InlineRuntimeContext): Promise<RuntimeModelOption[]> {+ const { session, state } = context+ const entries = await this.commandcodeCatalog()+ const targets = new Map<string, CommandcodeModelTarget>()+ const output: RuntimeModelOption[] = []+ const seen = new Set<string>()+ const add = (entry: CommandcodeModelTarget, effort: string): void => {+ const id = encodeRuntimeProfile({+ sessionId: session.agentId, engine: 'commandcode', model: entry.shortId, effort,+ })+ if (seen.has(id)) return+ seen.add(id)+ targets.set(id, entry)+ output.push({ id, displayName: `${runtimeModelLabel(entry.shortId)} / ${effortLabel(effort)}` })+ }+ for (const entry of entries) {+ add(entry, 'auto')+ for (const level of commandcode.COMMANDCODE_EFFORT_LEVELS) add(entry, level)+ }+ // `entries.length` guards the fallback: a model row is worth adding when the catalogue is readable but+ // does not list what the session runs (a pinned build, a just-removed model). When the catalogue could+ // not be read at all, one lone row is a picker that cannot pick anything — better to offer none.+ if (entries.length && state?.model && !entries.some((entry) => entry.shortId === state.model)) {+ const own: CommandcodeModelTarget = { id: state.model, shortId: state.model, section: '', isDefault: false }+ add(own, 'auto')+ if (state.effort && commandcode.COMMANDCODE_EFFORTS.has(state.effort)) add(own, state.effort)+ }+ this.commandcodeTargets.set(session.sessionId, targets)+ return output+ }++ private async commandcodeCatalog(): Promise<CommandcodeModelTarget[]> {+ // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.+ const key = env.COMMANDCODE_HOME+ if (this.commandcodeCatalogCache?.key === key && this.commandcodeCatalogCache.expiresAt > Date.now()) {+ return this.commandcodeCatalogCache.entries+ }+ let entries: CommandcodeModelTarget[] = []+ try {+ const result = await execFileAsync('commandcode', ['--list-models'], {+ env: process.env, timeout: 15_000, maxBuffer: 1024 * 1024,+ })+ entries = commandcode.parseCommandcodeModelsOutput(result.stdout)+ } catch (err) {+ console.warn('[runtime-profile] Command Code model catalog failed:', err instanceof Error ? err.message : err)+ }+ this.commandcodeCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }+ return entries+ }++ async config({ state }: InlineRuntimeContext): Promise<boolean> {+ const config = await commandcodeConfiguredEffort(state.model)+ state.effort = config.effort+ if (!state.model && config.defaultModel) state.model = config.defaultModel+ state.observedAt = Date.now()+ return true+ }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'commandcode' } { return new ProfileReader() }diff --git a/cli/src/engines/copilot/inProcess.ts b/cli/src/engines/copilot/inProcess.tsindex 4f528b60e..d4d4bbe18 100644--- a/cli/src/engines/copilot/inProcess.ts+++ b/cli/src/engines/copilot/inProcess.ts@@ -6,3 +6,5 @@export { CopilotNormalizer, copilotHistoryTurnOpen, copilotMessagesToEvents, lastCopilotTurnText } from './normalizer.js'export { copilotSessionCwd, copilotSessionForPid, findCopilotTranscript } from './session.js'export { copilotProvider } from '../../lib/sessionSearch/externals/copilot.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/copilot/profileReader.ts b/cli/src/engines/copilot/profileReader.tsnew file mode 100644index 000000000..61aa58003--- /dev/null+++ b/cli/src/engines/copilot/profileReader.ts@@ -0,0 +1,7 @@+import type { InlineRuntimeReader } from '../facets/inlineRuntime.js'++class ProfileReader {+ readonly engine = 'copilot' as const+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'copilot' } { return new ProfileReader() }diff --git a/cli/src/engines/cursor/inProcess.ts b/cli/src/engines/cursor/inProcess.tsindex 2296ce9cf..dac9c371c 100644--- a/cli/src/engines/cursor/inProcess.ts+++ b/cli/src/engines/cursor/inProcess.ts@@ -10,3 +10,5 @@ export { cursorConfigDir, cursorDataDir } from './home.js'export { CursorTranscriptDiscovery, findCursorTranscript } from './discovery.js'export { loadCursorPendingTasks, removeCursorPendingTasks } from './pendingTasks.js'export { cursorProvider } from '../../lib/sessionSearch/externals/cursor.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/cursor/profileReader.ts b/cli/src/engines/cursor/profileReader.tsnew file mode 100644index 000000000..2509abbe0--- /dev/null+++ b/cli/src/engines/cursor/profileReader.ts@@ -0,0 +1,375 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import type { RuntimeModelOption } from '../facets/runtime.js'+import { currentPaneUi, effortLabel, encodeRuntimeProfile, stripAnsi, text } from '../kit/runtime.js'+import { env } from '../../config/env.js'+import { join } from 'node:path'+import { execFile } from 'node:child_process'+import { promisify } from 'node:util'++const execFileAsync = promisify(execFile)+const CATALOG_TTL_MS = 5 * 60_000++export interface CursorModelTarget {+ rawId: string+ modelKey: string+ familyLabel: string+ context: string | null+ reasoning: string | null+ fast: boolean | null+ thinking: boolean | null+ /** Effort text rendered in the idle footer; null means Cursor omits its native default. */+ footerEffort?: string | null+}++interface CursorCatalogEntry {+ target: CursorModelTarget+ effort: string+ modelLabel: string+}++const CURSOR_EFFORTS = new Set(['auto', 'none', 'low', 'medium', 'high', 'xhigh', 'max'])+const CURSOR_CATALOG_TTL_MS = CATALOG_TTL_MS++function cursorEffortFromId(rawId: string): { effort: string | null; modelKey: string } {+ const parts = rawId.split('-')+ let index = -1+ let width = 1+ for (let i = 2; i < parts.length; i++) {+ if (parts[i] === 'extra' && parts[i + 1] === 'high') {+ index = i+ width = 2+ i+++ } else if (['none', 'low', 'medium', 'high', 'xhigh', 'max'].includes(parts[i])) {+ index = i+ width = 1+ }+ }+ if (index < 0) return { effort: null, modelKey: rawId }+ const rawEffort = parts.slice(index, index + width).join('-')+ parts.splice(index, width)+ return {+ effort: rawEffort === 'extra-high' ? 'xhigh' : rawEffort,+ modelKey: parts.join('-'),+ }+}++function cursorEffortFromDisplay(value: string): string | null {+ const match = /\b(Extra High|None|Low|Medium|High|Max)\b/i.exec(value)+ if (!match) return null+ return match[1].toLowerCase().replace(/\s+/g, '') === 'extrahigh'+ ? 'xhigh'+ : match[1].toLowerCase()+}++function cursorDisplayParts(displayName: string): {+ familyLabel: string+ context: string | null+ fast: boolean+ thinking: boolean+} {+ let value = displayName+ .replace(/\s+\((?:current|default)(?:,\s*(?:current|default))?\)\s*$/i, '')+ .replace(/\s+\(NO ZDR\)\s*$/i, '')+ .replace(/\s*[·│]\s*\d+(?:\.\d+)?%.*$/i, '')+ .trim()+ const contextMatch = /\b(\d+(?:\.\d+)?[KM])\b/i.exec(value)+ const context = contextMatch?.[1].toLowerCase() ?? null+ const fast = /\bFast\b/i.test(value)+ const thinking = !/\bNo\s+Thinking\b/i.test(value) && /\bThinking\b/i.test(value)+ value = value+ .replace(/\b\d+(?:\.\d+)?[KM]\b/gi, '')+ .replace(/\bExtra High\b/gi, '')+ .replace(/\b(?:None|Low|Medium|High|Max)\b/gi, '')+ .replace(/\bNo\s+Thinking\b/gi, '')+ .replace(/\b(?:Fast|Thinking)\b/gi, '')+ .replace(/\s+/g, ' ')+ .trim()+ return { familyLabel: value, context, fast, thinking }+}++/** Strictly parse `agent models`; headings, tips and malformed rows are ignored. */+export function parseCursorModelsOutput(output: string): CursorCatalogEntry[] {+ const candidates: Array<CursorCatalogEntry & { explicitEffort: boolean }> = []+ for (const rawLine of output.split('\n')) {+ const match = /^([a-z0-9][a-z0-9._-]*) - (.+?)\s*$/i.exec(rawLine)+ if (!match) continue+ const rawId = match[1]+ const displayName = match[2].trim()+ const display = cursorDisplayParts(displayName)+ if (!display.familyLabel) continue+ if (rawId === 'auto') {+ candidates.push({+ target: {+ rawId,+ modelKey: rawId,+ familyLabel: 'Auto',+ context: null,+ reasoning: null,+ fast: null,+ thinking: null,+ footerEffort: 'auto',+ },+ effort: 'auto',+ modelLabel: 'Auto',+ explicitEffort: true,+ })+ continue+ }+ const parsed = cursorEffortFromId(rawId)+ const effort = parsed.effort+ const footerEffort = cursorEffortFromDisplay(displayName)+ candidates.push({+ target: {+ rawId,+ modelKey: parsed.modelKey,+ familyLabel: display.familyLabel,+ context: display.context,+ reasoning: effort,+ fast: display.fast,+ thinking: display.thinking,+ footerEffort,+ },+ effort: effort ?? 'auto',+ modelLabel: [+ display.familyLabel,+ display.context ? `(${display.context.toUpperCase()})` : '',+ display.thinking ? 'Thinking' : '',+ display.fast ? 'Fast' : '',+ ].filter(Boolean).join(' '),+ explicitEffort: effort !== null,+ })+ }++ // Some medium/default rows omit the effort segment (for example `gpt-5.3-codex`).+ // Infer medium only when explicit siblings prove that the same exact model group has efforts.+ const effortfulGroups = new Set(candidates.filter((item) => item.explicitEffort).map((item) => item.target.modelKey))+ for (const item of candidates) {+ if (item.target.rawId === 'auto' || item.effort !== 'auto' || !effortfulGroups.has(item.target.modelKey)) continue+ item.effort = 'medium'+ item.target.reasoning = 'medium'+ }+ return candidates.map(({ explicitEffort: _explicitEffort, ...item }) => item)+}++function parseCursorFooter(value: string): {+ familyLabel: string+ context: string | null+ effort: string | null+ fast: boolean+ thinking: boolean+} | null {+ const line = stripAnsi(value).trim()+ if (/^Auto(?:\s*$|\s*[·│])/i.test(line)) {+ return { familyLabel: 'Auto', context: null, effort: 'auto', fast: false, thinking: false }+ }+ const effort = cursorEffortFromDisplay(line)+ const hasUsage = /[·│]\s*\d+(?:\.\d+)?%/i.test(line)+ const hasThinkingMode = /\b(?:No\s+Thinking|Thinking)\b/i.test(line)+ if (!effort && !hasUsage && !hasThinkingMode) return null+ const parts = cursorDisplayParts(line)+ if (!parts.familyLabel || !/\d/.test(parts.familyLabel)) return null+ return {+ ...parts,+ effort,+ }+}++function cursorSyntheticTarget(+ parsed: NonNullable<ReturnType<typeof parseCursorFooter>>,+ effort: string,+): CursorModelTarget {+ if (parsed.familyLabel.toLowerCase() === 'auto' && parsed.effort === 'auto') {+ return {+ rawId: 'auto',+ modelKey: 'auto',+ familyLabel: 'Auto',+ context: null,+ reasoning: null,+ fast: null,+ thinking: null,+ footerEffort: 'auto',+ }+ }+ const family = parsed.familyLabel.toLowerCase().replace(/[^a-z0-9.]+/g, '-').replace(/^-|-$/g, '') || 'model'+ // Keep the public runtime-v1 model key compatible with every client formatter. The Cursor routing+ // details remain on CursorModelTarget (and rawId) for selection/confirmation; they do not belong in+ // the user-facing profile key as a percent-encoded "[fast=...,thinking=...]" implementation detail.+ const modelKey = [+ family,+ parsed.context?.toLowerCase() ?? '',+ parsed.thinking ? 'thinking' : '',+ parsed.fast ? 'fast' : '',+ ].filter(Boolean).join('-')+ const parameters = [+ parsed.context ? `context=${parsed.context}` : '',+ `fast=${parsed.fast}`,+ `thinking=${parsed.thinking}`,+ ].filter(Boolean).join(',')+ return {+ rawId: `cursor-${family}[${parameters},effort=${effort}]`,+ modelKey,+ familyLabel: parsed.familyLabel,+ context: parsed.context,+ reasoning: effort === 'auto' ? null : effort,+ fast: parsed.fast,+ thinking: parsed.thinking,+ footerEffort: parsed.effort,+ }+}+++class ProfileReader {+ readonly engine = 'cursor' as const+ private readonly cursorTargets = new Map<string, Map<string, CursorModelTarget>>()+ private cursorCatalogCache: { key: string; expiresAt: number; entries: CursorCatalogEntry[] } | null = null++ pane(context: InlineRuntimeContext, paneText: string): void | false {+ const { session, state, control } = context+ const currentUi = currentPaneUi(paneText)+ if (/Available models|Models matching|— Edit Parameters|Type to filter.*Tab to edit|Esc to go back/i.test(currentUi)) return false+ const footerLines = currentUi.split('\n')+ .filter((line) => stripAnsi(line).trim())+ .slice(-12)+ .reverse()+ const parsed = footerLines.map(parseCursorFooter).find((item) => item !== null)+ if (parsed) {+ const targets = this.cursorTargets.get(session.sessionId) ?? new Map<string, CursorModelTarget>()+ let target = [...targets.values()].find((candidate) =>+ candidate.familyLabel.toLowerCase() === parsed.familyLabel.toLowerCase()+ && (parsed.effort+ ? (candidate.reasoning ?? 'auto') === parsed.effort+ : candidate.footerEffort === null)+ && (candidate.fast ?? false) === parsed.fast+ && (candidate.thinking ?? false) === parsed.thinking+ && (!candidate.context || candidate.context === parsed.context))+ const effort = parsed.effort ?? target?.reasoning ?? 'auto'+ if (!target) {+ target = cursorSyntheticTarget(parsed, effort)+ const id = encodeRuntimeProfile({+ sessionId: session.agentId,+ engine: 'cursor',+ model: target.modelKey,+ effort,+ })+ targets.set(id, target)+ this.cursorTargets.set(session.sessionId, targets)+ }+ state.model = target.modelKey+ state.effort = effort+ state.observedAt = Date.now()+ if (control && target?.modelKey === control.target.model && effort === control.target.effort) {+ control.modelConfirmed = true+ control.effortConfirmed = true+ }+ }+ if (/\bPlan\b/i.test(currentUi)) state.mode = 'plan'+ else if (/Plan, search, build anything/i.test(currentUi)) state.mode = 'default'+ }++ transcript(context: InlineRuntimeContext, raw: Record<string, unknown>): void {+ const { session, state } = context+ const version = text(raw.version) || text(raw.cursor_version)+ if (version) {+ session.cliVersion = version+ state.cliVersion = version+ }+ const model = text(raw.model)+ if (model) {+ state.model = model+ // Default the effort to 'auto' when we do not have one yet. selectedModel() returns null unless BOTH+ // axes are known, so without this a Cursor session whose model we DO know shows nothing at all on+ // the device — the model is thrown away because the effort is missing.+ //+ // Cursor reports its model in the transcript but its reasoning level only in the pane footer, so+ // the effort arrives later (ingestPane) or not at all for a model that has no reasoning levels.+ // 'auto' is not a guess about Cursor's behaviour: it is exactly how the device renders "not+ // specified", and the pane path overwrites it with the real value the moment one is read.+ state.effort ??= 'auto'+ state.observedAt = Date.now()+ }+ }++ target(sessionId: string, profileId: string): CursorModelTarget | null {+ return this.cursorTargets.get(sessionId)?.get(profileId) ?? null+ }++ forget(sessionId: string): void { this.cursorTargets.delete(sessionId) }++ async models(context: InlineRuntimeContext): Promise<RuntimeModelOption[]> {+ const { session, state } = context+ const key = `${session.cliVersion ?? 'unknown'}\0${process.env.HOME ?? ''}`+ let entries = this.cursorCatalogCache?.key === key && this.cursorCatalogCache.expiresAt > Date.now()+ ? this.cursorCatalogCache.entries+ : null+ if (!entries) {+ try {+ const result = await execFileAsync('agent', ['models'], {+ env: process.env,+ timeout: 5_000,+ maxBuffer: 1024 * 1024,+ })+ entries = parseCursorModelsOutput(result.stdout)+ this.cursorCatalogCache = { key, entries, expiresAt: Date.now() + CURSOR_CATALOG_TTL_MS }+ } catch (err) {+ console.warn('[runtime-profile] Cursor model catalog failed:', err instanceof Error ? err.message : err)+ entries = []+ }+ }++ const output: RuntimeModelOption[] = []+ const previousTargets = this.cursorTargets.get(session.sessionId) ?? new Map<string, CursorModelTarget>()+ const targets = new Map<string, CursorModelTarget>()+ const seen = new Set<string>()+ for (const entry of entries) {+ if (!CURSOR_EFFORTS.has(entry.effort)) continue+ const id = encodeRuntimeProfile({+ sessionId: session.agentId,+ engine: 'cursor',+ model: entry.target.modelKey,+ effort: entry.effort,+ })+ if (seen.has(id)) continue+ seen.add(id)+ targets.set(id, entry.target)+ output.push({ id, displayName: `${entry.modelLabel} / ${effortLabel(entry.effort)}` })+ }+ const current = state?.model && state.effort+ ? encodeRuntimeProfile({+ sessionId: session.agentId,+ engine: 'cursor',+ model: state.model,+ effort: state.effort,+ })+ : null+ const observed = current ? previousTargets.get(current) : null+ if (observed) {+ const familyEfforts = [...new Set(entries+ .filter((entry) => entry.target.familyLabel.toLowerCase() === observed.familyLabel.toLowerCase())+ .map((entry) => entry.effort)+ .filter((effort) => effort !== 'auto'))]+ const efforts = familyEfforts.length ? familyEfforts : [state!.effort!]+ for (const effort of efforts) {+ const id = encodeRuntimeProfile({+ sessionId: session.agentId,+ engine: 'cursor',+ model: observed.modelKey,+ effort,+ })+ if (seen.has(id)) continue+ seen.add(id)+ targets.set(id, { ...observed, reasoning: effort, footerEffort: effort })+ const label = [+ observed.familyLabel,+ observed.context ? `(${observed.context.toUpperCase()})` : '',+ observed.thinking ? 'Thinking' : '',+ observed.fast ? 'Fast' : '',+ ].filter(Boolean).join(' ')+ output.push({ id, displayName: `${label} / ${effortLabel(effort)}` })+ }+ }+ this.cursorTargets.set(session.sessionId, targets)+ return output+ }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'cursor' } { return new ProfileReader() }diff --git a/cli/src/engines/devin/inProcess.ts b/cli/src/engines/devin/inProcess.tsindex 25dfa52bd..7b164f5ee 100644--- a/cli/src/engines/devin/inProcess.ts+++ b/cli/src/engines/devin/inProcess.ts@@ -7,3 +7,5 @@ export { DevinReader, readDevinMessages } from './reader.js'export { devinMessagesToEvents, lastDevinTurnText, windowDevinMessages } from './normalizer.js'export { DEVIN_EFFORTS, devinFooterModel, devinModelCommandResult, parseDevinModelsOutput } from './runtimeProfile.js'export { devinProvider } from '../../lib/sessionSearch/externals/devin.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/devin/profileReader.ts b/cli/src/engines/devin/profileReader.tsnew file mode 100644index 000000000..7d5555b24--- /dev/null+++ b/cli/src/engines/devin/profileReader.ts@@ -0,0 +1,115 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import type { RuntimeModelOption } from '../facets/runtime.js'+import { effortLabel, encodeRuntimeProfile, record } from '../kit/runtime.js'+import { confirmObserved } from '../kit/runtimeReader.js'+import { env } from '../../config/env.js'+import { execFile } from 'node:child_process'+import { promisify } from 'node:util'+import * as devin from './runtimeProfile.js'+import type { DevinModelTarget } from './runtimeProfile.js'++const execFileAsync = promisify(execFile)+const CATALOG_TTL_MS = 5 * 60_000+const CATALOG_LIMIT = 96++class ProfileReader {+ readonly engine = 'devin' as const+ private readonly devinTargets = new Map<string, Map<string, DevinModelTarget>>()+ private devinCatalogCache: { key: string; expiresAt: number; entries: DevinModelTarget[] } | null = null++ pane(context: InlineRuntimeContext, paneText: string): void | false {+ const { session, state, control } = context+ // Devin writes no transcript unless the user passes `--export`, so the footer's bottom-left cell is+ // the only per-session record of the running model. It is a DISPLAY name (`SWE-1.6 Slow`); the+ // catalog resolves it back to a model key so the chip and the picker agree.+ const label = devin.devinFooterModel(paneText)+ const model = label ? this.devinModelKeyForLabel(session.sessionId, label) : null+ if (model) {+ state.model = model.modelKey+ state.effort = model.effort+ state.observedAt = Date.now()+ confirmObserved(control, model.modelKey, model.effort)+ }+ }++ target(sessionId: string, profileId: string): DevinModelTarget | null {+ return this.devinTargets.get(sessionId)?.get(profileId) ?? null+ }++ forget(sessionId: string): void { this.devinTargets.delete(sessionId) }++ private devinModelKeyForLabel(sessionId: string, label: string): DevinModelTarget | null {+ // Resolve against the CATALOG, not the per-session id map. That map is only built when something opens+ // the model picker, so a session nobody had picked on could not read its own footer and the chip stayed+ // blank. The catalog is the same data minus the per-session ids, and ingestConfig warms it on attach.+ // The session map stays first: its rows are the ones the picker will offer.+ const targets = this.devinTargets.get(sessionId)+ const pool: Iterable<DevinModelTarget> = targets?.size+ ? targets.values()+ : this.devinCatalogCache?.entries ?? []+ const wanted = label.trim().toLowerCase()+ for (const target of pool) {+ // A row whose id carries no effort keeps the effort word in its label ("GLM-5.2 High"), so an exact+ // label match is what identifies it; anything looser would tie the footer to the wrong sibling.+ if (target.label.toLowerCase() === wanted) return target+ if (target.effort !== 'auto' && `${target.label} ${effortLabel(target.effort)}`.toLowerCase() === wanted) {+ return target+ }+ }+ return null+ }++ async models(context: InlineRuntimeContext): Promise<RuntimeModelOption[]> {+ const { session, state } = context+ const entries = await this.devinCatalog()+ const targets = new Map<string, DevinModelTarget>()+ // Keep every row of the running model together with it, so its effort list stays complete.+ const ordered = state?.model+ ? [...entries].sort((a, b) => Number(b.modelKey === state.model) - Number(a.modelKey === state.model))+ : entries++ const output: RuntimeModelOption[] = []+ const seen = new Set<string>()+ for (const entry of ordered) {+ if (output.length >= CATALOG_LIMIT) break+ if (!devin.DEVIN_EFFORTS.has(entry.effort)) continue+ const id = encodeRuntimeProfile({+ sessionId: session.agentId,+ engine: 'devin',+ model: entry.modelKey,+ effort: entry.effort,+ })+ if (seen.has(id)) continue+ seen.add(id)+ targets.set(id, entry)+ output.push({ id, displayName: `${entry.label} / ${effortLabel(entry.effort)}` })+ }+ this.devinTargets.set(session.sessionId, targets)+ return output+ }++ private async devinCatalog(): Promise<DevinModelTarget[]> {+ // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.+ const key = env.DEVIN_HOME+ if (this.devinCatalogCache?.key === key && this.devinCatalogCache.expiresAt > Date.now()) {+ return this.devinCatalogCache.entries+ }+ let entries: DevinModelTarget[] = []+ try {+ const result = await execFileAsync('devin', ['models', 'list'], {+ env: process.env,+ timeout: 10_000,+ maxBuffer: 1024 * 1024,+ })+ entries = devin.parseDevinModelsOutput(result.stdout)+ } catch (err) {+ console.warn('[runtime-profile] Devin model catalog failed:', err instanceof Error ? err.message : err)+ }+ this.devinCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }+ return entries+ }++ async config(): Promise<boolean> { await this.devinCatalog(); return false }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'devin' } { return new ProfileReader() }diff --git a/cli/src/engines/facets/inlineRuntime.ts b/cli/src/engines/facets/inlineRuntime.tsnew file mode 100644index 000000000..2bb37d0ff--- /dev/null+++ b/cli/src/engines/facets/inlineRuntime.ts@@ -0,0 +1,32 @@+import type { RegisteredSession } from '../../lib/registry.js'+import type { RuntimeContext, RuntimeModelOption } from './runtime.js'+import type { CursorModelTarget } from '../cursor/profileReader.js'+import type { DevinModelTarget } from '../devin/runtimeProfile.js'+import type { HermesModelTarget } from '../hermes/runtimeProfile.js'+import type { CommandcodeModelTarget } from '../commandcode/runtimeProfile.js'+import type { OpencodeModelTarget } from '../opencode/runtimeProfile.js'+import type { KiloModelTarget } from '../kilo/runtimeProfile.js'++/** Optional observations only. State, control waiters and notifications stay with the eager owner. */+export interface InlineRuntimeContext extends RuntimeContext {+ session: RegisteredSession+ refreshConfig(silent?: boolean): void+}+export interface InlineRuntimeReaderBase {+ transcript?(context: InlineRuntimeContext, record: Record<string, unknown>): void+ /** False means this screen must not participate in observation/confirmation. */+ pane?(context: InlineRuntimeContext, text: string): void | false+ /** False means a warm-up or unavailable read, with no state contribution. */+ config?(context: InlineRuntimeContext): Promise<boolean>+ models?(context: InlineRuntimeContext): Promise<RuntimeModelOption[]>+ forget?(sessionId: string): void+}+export type InlineRuntimeReader = InlineRuntimeReaderBase & (+ | { engine: 'cursor'; target(sessionId: string, profileId: string): CursorModelTarget | null }+ | { engine: 'devin'; target(sessionId: string, profileId: string): DevinModelTarget | null }+ | { engine: 'hermes'; target(sessionId: string, profileId: string): HermesModelTarget | null }+ | { engine: 'commandcode'; target(sessionId: string, profileId: string): CommandcodeModelTarget | null }+ | { engine: 'opencode'; catalog(): Promise<OpencodeModelTarget[]> }+ | { engine: 'kilo'; catalog(): Promise<KiloModelTarget[]> }+ | { engine: 'pi' | 'grok' | 'agy' | 'amp' | 'muse' | 'copilot' }+)diff --git a/cli/src/engines/grok/inProcess.ts b/cli/src/engines/grok/inProcess.tsindex fc587dbf0..a19024f82 100644--- a/cli/src/engines/grok/inProcess.ts+++ b/cli/src/engines/grok/inProcess.ts@@ -7,3 +7,5 @@ export { GrokNormalizer, grokMessagesToEvents, lastGrokTurnText } from './normalexport { parseGrokFooterProfile } from './runtimeProfile.js'export { findGrokTranscript } from './session.js'export { grokProvider } from '../../lib/sessionSearch/externals/grok.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/grok/profileReader.ts b/cli/src/engines/grok/profileReader.tsnew file mode 100644index 000000000..437d7680e--- /dev/null+++ b/cli/src/engines/grok/profileReader.ts@@ -0,0 +1,30 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import { record, text } from '../kit/runtime.js'+import * as grok from './runtimeProfile.js'++class ProfileReader {+ readonly engine = 'grok' as const++ pane(context: InlineRuntimeContext, paneText: string): void | false {+ const { state } = context+ const footer = grok.parseGrokFooterProfile(paneText)+ if (footer) {+ state.model = footer.model+ state.effort = footer.effort+ state.observedAt = Date.now()+ }+ }++ transcript(context: InlineRuntimeContext, raw: Record<string, unknown>): void {+ const { state } = context+ const params = record(raw.params)+ const update = record(params?.update)+ const meta = record(update?._meta)+ const model = text(meta?.modelId)+ if (!model) return+ state.model = model+ state.observedAt = Date.now()+ }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'grok' } { return new ProfileReader() }diff --git a/cli/src/engines/hermes/inProcess.ts b/cli/src/engines/hermes/inProcess.tsindex 49fd0d392..ced525dbd 100644--- a/cli/src/engines/hermes/inProcess.ts+++ b/cli/src/engines/hermes/inProcess.ts@@ -10,3 +10,5 @@ export { HERMES_EFFORTS, hermesStatusModel, parseHermesConfig, parseHermesModelsexport { hermesDbForSession } from '../../lib/hermesHome.js'export { probeHermesHome } from './homeProbe.js'export { hermesProvider } from '../../lib/sessionSearch/externals/hermes.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/hermes/profileReader.ts b/cli/src/engines/hermes/profileReader.tsnew file mode 100644index 000000000..bfd924576--- /dev/null+++ b/cli/src/engines/hermes/profileReader.ts@@ -0,0 +1,88 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import type { RuntimeModelOption } from '../facets/runtime.js'+import { encodeRuntimeProfile, readJson, runtimeModelLabel } from '../kit/runtime.js'+import { readRuntimeText as readText } from '../kit/runtimeReader.js'+import { env } from '../../config/env.js'+import { join } from 'node:path'+import * as hermes from './runtimeProfile.js'+import type { HermesModelTarget } from './runtimeProfile.js'++const CATALOG_TTL_MS = 5 * 60_000++class ProfileReader {+ readonly engine = 'hermes' as const+ private hermesCatalogCache = new Map<string, { expiresAt: number; entries: HermesModelTarget[] }>()+ private readonly hermesTargets = new Map<string, Map<string, HermesModelTarget>>()++ pane(context: InlineRuntimeContext, paneText: string): void | false {+ const { state } = context+ // `⚕ minimax-m3 │ ctx --` — the status line is how a switch is seen immediately; config.yaml is+ // rewritten too, but the poll that reads it runs on its own schedule.+ const model = hermes.hermesStatusModel(paneText)+ if (model && model !== state.model) {+ state.model = model+ state.observedAt = Date.now()+ }+ }++ target(sessionId: string, profileId: string): HermesModelTarget | null {+ return this.hermesTargets.get(sessionId)?.get(profileId) ?? null+ }++ forget(sessionId: string): void { this.hermesTargets.delete(sessionId) }++ async models(context: InlineRuntimeContext): Promise<RuntimeModelOption[]> {+ const { session, state } = context+ const entries = await this.hermesCatalog(session.hermesHome || env.HERMES_HOME)+ const targets = new Map<string, HermesModelTarget>()+ const output: RuntimeModelOption[] = []+ const seen = new Set<string>()+ const effort = state?.effort && hermes.HERMES_EFFORTS.has(state.effort) ? state.effort : 'auto'+ const add = (entry: HermesModelTarget): void => {+ const short = entry.id.slice(entry.id.lastIndexOf('/') + 1)+ const id = encodeRuntimeProfile({+ sessionId: session.agentId, engine: 'hermes', model: short, effort,+ })+ if (seen.has(id)) return+ seen.add(id)+ targets.set(id, entry)+ output.push({ id, displayName: runtimeModelLabel(short) })+ }+ for (const entry of entries) add(entry)+ // The provider in use is often absent from the picker cache (a `custom` gateway is its own one-model+ // page), so the configured model is always offered — otherwise the running model is missing from its+ // own list.+ if (state?.model && !seen.size) add({ id: state.model, provider: '' })+ else if (state?.model && ![...targets.values()].some((t) => t.id.endsWith(state.model!))) {+ add({ id: state.model, provider: '' })+ }+ this.hermesTargets.set(session.sessionId, targets)+ return output+ }++ private async hermesCatalog(home = env.HERMES_HOME): Promise<HermesModelTarget[]> {+ // Keyed by home, and now actually asked per home: a profile has its own providers, so the cache+ // key was already right and only the path it read was not.+ const cached = this.hermesCatalogCache.get(home)+ if (cached && cached.expiresAt > Date.now()) return cached.entries+ const cache = await readJson(join(home, 'provider_models_cache.json'))+ const entries = hermes.parseHermesModelsCache(cache)+ this.hermesCatalogCache.set(home, { entries, expiresAt: Date.now() + CATALOG_TTL_MS })+ return entries+ }++ async config(context: InlineRuntimeContext): Promise<boolean> {+ const { session, state } = context+ // Both axes are scalars in config.yaml and neither is announced, so this poll is the only reader.+ // This agent's OWN home: `hermes -p <name>` keeps its model and effort in the profile's+ // config.yaml, and reading the default one reported the wrong model on every profile agent.+ const parsed = hermes.parseHermesConfig(await readText(join(session.hermesHome || env.HERMES_HOME, 'config.yaml')))+ if (parsed.model) state.model = parsed.model.slice(parsed.model.lastIndexOf('/') + 1)+ state.effort = parsed.effort ?? 'auto'+ state.observedAt = Date.now()++ return true+ }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'hermes' } { return new ProfileReader() }diff --git a/cli/src/engines/kilo/inProcess.ts b/cli/src/engines/kilo/inProcess.tsindex 895719893..a59841226 100644--- a/cli/src/engines/kilo/inProcess.ts+++ b/cli/src/engines/kilo/inProcess.ts@@ -8,3 +8,5 @@ export { kiloMessagesToEvents, lastKiloTurnText, windowKiloMessages } from './noexport { kiloFooterModelId, parseKiloModelsOutput } from './runtimeProfile.js'// Its adoption reader, which Kilo shares with OpenCode: their stores are one shape.export { opencodeProvider } from '../../lib/sessionSearch/externals/opencode.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/kilo/profileReader.ts b/cli/src/engines/kilo/profileReader.tsnew file mode 100644index 000000000..bd1dcefd6--- /dev/null+++ b/cli/src/engines/kilo/profileReader.ts@@ -0,0 +1,72 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import type { RuntimeModelOption } from '../facets/runtime.js'+import { encodeRuntimeProfile } from '../kit/runtime.js'+import { confirmObserved } from '../kit/runtimeReader.js'+import { env } from '../../config/env.js'+import { execFile } from 'node:child_process'+import { promisify } from 'node:util'+import * as kilo from './runtimeProfile.js'+import type { KiloModelTarget } from './runtimeProfile.js'++const execFileAsync = promisify(execFile)+const CATALOG_TTL_MS = 5 * 60_000++class ProfileReader {+ readonly engine = 'kilo' as const+ private kiloCatalogCache: { key: string; expiresAt: number; entries: KiloModelTarget[] } | null = null++ pane(context: InlineRuntimeContext, paneText: string): void | false {+ const { state, control } = context+ // Kilo names the model in its composer footer too, but the line is shaped differently enough that+ // its resolver had to be rewritten rather than renamed — see engines/kilo/runtimeProfile.ts.+ const id = kilo.kiloFooterModelId(paneText, this.kiloCatalogCache?.entries ?? [])+ if (id) {+ state.model = id+ state.effort = 'auto'+ state.observedAt = Date.now()+ confirmObserved(control, id, 'auto')+ }+ }++ async models(context: InlineRuntimeContext): Promise<RuntimeModelOption[]> {+ const { session } = context+ const entries = await this.catalog()+ const output: RuntimeModelOption[] = []+ const seen = new Set<string>()+ for (const entry of entries) {+ const id = encodeRuntimeProfile({+ sessionId: session.agentId, engine: 'kilo', model: entry.id, effort: 'auto',+ })+ if (seen.has(id)) continue+ seen.add(id)+ output.push({ id, displayName: entry.id })+ }+ return output+ }++ async catalog(): Promise<KiloModelTarget[]> {+ // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.+ const key = env.KILO_DATA_DIR+ if (this.kiloCatalogCache?.key === key && this.kiloCatalogCache.expiresAt > Date.now()) {+ return this.kiloCatalogCache.entries+ }+ let entries: KiloModelTarget[] = []+ try {+ // Measured: `kilo models` answers WITHOUT the user being logged in (unlike `kilo profile`), and+ // prints 299 ids on this machine — so an empty catalog here means the binary is missing, not that+ // the account is signed out.+ const result = await execFileAsync(env.KILO_PATH || 'kilo', ['models'], {+ env: process.env, timeout: 10_000, maxBuffer: 1024 * 1024,+ })+ entries = kilo.parseKiloModelsOutput(result.stdout)+ } catch (err) {+ console.warn('[runtime-profile] Kilo model catalog failed:', err instanceof Error ? err.message : err)+ }+ this.kiloCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }+ return entries+ }++ async config(): Promise<boolean> { await this.catalog(); return false }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'kilo' } { return new ProfileReader() }diff --git a/cli/src/engines/kit/runtimeReader.ts b/cli/src/engines/kit/runtimeReader.tsnew file mode 100644index 000000000..211ab8a81--- /dev/null+++ b/cli/src/engines/kit/runtimeReader.ts@@ -0,0 +1,13 @@+import { readFile } from 'node:fs/promises'+import type { RuntimeControl } from '../facets/runtime.js'++/** Optional native configuration: an unreadable file contributes no text. */+export async function readRuntimeText(file: string): Promise<string> {+ try { return await readFile(file, 'utf8') } catch { return '' }+}++export function confirmObserved(control: RuntimeControl | undefined, model: string, effort: string): void {+ if (!control || control.target.model !== model || control.target.effort !== effort) return+ control.modelConfirmed = true+ control.effortConfirmed = true+}diff --git a/cli/src/engines/muse/inProcess.ts b/cli/src/engines/muse/inProcess.tsindex faa11c6e1..3558d4ed6 100644--- a/cli/src/engines/muse/inProcess.ts+++ b/cli/src/engines/muse/inProcess.ts@@ -7,3 +7,5 @@ export { MuseNormalizer, lastMuseTurnText, museMessagesToEvents } from './normalexport { parseMuseSettings } from './runtimeProfile.js'export { museEvent, museWorkspaceRoot } from './normalizer.js'export { museProvider } from '../../lib/sessionSearch/externals/muse.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/muse/profileReader.ts b/cli/src/engines/muse/profileReader.tsnew file mode 100644index 000000000..f7da7a8ce--- /dev/null+++ b/cli/src/engines/muse/profileReader.ts@@ -0,0 +1,25 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import { readRuntimeText as readText } from '../kit/runtimeReader.js'+import { env } from '../../config/env.js'+import { join } from 'node:path'+import * as muse from './runtimeProfile.js'++class ProfileReader {+ readonly engine = 'muse' as const++ async config(context: InlineRuntimeContext): Promise<boolean> {+ const { state } = context+ // Both axes are plain scalars in ~/.config/muse/settings.json (`model`, `reasoning_effort`) and+ // neither is announced anywhere, so reading the file IS the only way the chip is ever populated.+ // `reasoning_effort` is muse's own vocabulary (none|minimal|low|medium|high|xhigh|ultra); the+ // absence of the key means the CLI default, which its own --help documents as `high`.+ const parsed = muse.parseMuseSettings(await readText(join(env.MUSE_CONFIG_DIR, 'settings.json')))+ if (parsed.model) state.model = parsed.model+ state.effort = parsed.effort ?? 'auto'+ state.observedAt = Date.now()++ return true+ }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'muse' } { return new ProfileReader() }diff --git a/cli/src/engines/opencode/inProcess.ts b/cli/src/engines/opencode/inProcess.tsindex ed7d61b82..a1858a42f 100644--- a/cli/src/engines/opencode/inProcess.ts+++ b/cli/src/engines/opencode/inProcess.ts@@ -10,3 +10,5 @@ export { countOpencodePickers, opencodeFooterModelId, opencodeRowMatches, opencoexport { isOpencodeV2, opencodeMajorVersion } from './version.js'export { applyOpencodeSessionModel, parseOpencodeModelId } from './sessionModel.js'export { opencodeProvider } from '../../lib/sessionSearch/externals/opencode.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/opencode/profileReader.ts b/cli/src/engines/opencode/profileReader.tsnew file mode 100644index 000000000..9c84ac1c1--- /dev/null+++ b/cli/src/engines/opencode/profileReader.ts@@ -0,0 +1,89 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import type { RuntimeModelOption } from '../facets/runtime.js'+import { encodeRuntimeProfile } from '../kit/runtime.js'+import { confirmObserved } from '../kit/runtimeReader.js'+import { env } from '../../config/env.js'+import { execFile } from 'node:child_process'+import { promisify } from 'node:util'+import * as opencode from './runtimeProfile.js'+import { opencodeBin } from '../../lib/engineBin.js'+import type { OpencodeModelTarget } from './runtimeProfile.js'++const execFileAsync = promisify(execFile)+const CATALOG_TTL_MS = 5 * 60_000++class ProfileReader {+ readonly engine = 'opencode' as const+ private opencodeCatalogCache: { key: string; expiresAt: number; entries: OpencodeModelTarget[] } | null = null++ pane(context: InlineRuntimeContext, paneText: string): void | false {+ const { state, control } = context+ // OpenCode names what is running in its composer footer+ // (`Build · MiniMax M3 (vibe) Vibe Gateway · high`). Prefer the catalog entry it resolves to,+ // because that id is also what a SWITCH is addressed to — the cached entries rather than a+ // fresh (async) fetch, since this runs on the pane poll.+ //+ // Fall back to the footer's own words when the catalog does not list it. That is not a corner+ // case: with no provider connected OpenCode runs a built-in free model that `opencode models`+ // never prints, so insisting on a catalog match left the chips blank on a freshly opened agent+ // — showing nothing about a model the terminal was naming two lines below.+ const footer = opencode.parseOpencodeFooter(paneText)+ const id = opencode.opencodeFooterModelId(paneText, this.opencodeCatalogCache?.entries ?? [])+ const model = id ?? footer?.target ?? null+ if (model) {+ // 'auto' remains the default: early builds had no reasoning axis at all, and inventing a+ // level for them would put a wrong value on the chip instead of an empty one.+ const effort = footer?.effort ?? 'auto'+ state.model = model+ state.effort = effort+ state.observedAt = Date.now()+ confirmObserved(control, model, effort)+ }+ }++ async models(context: InlineRuntimeContext): Promise<RuntimeModelOption[]> {+ const { session, state } = context+ const entries = await this.catalog()+ const output: RuntimeModelOption[] = []+ const seen = new Set<string>()+ for (const entry of entries) {+ const id = encodeRuntimeProfile({+ sessionId: session.agentId, engine: 'opencode', model: entry.id, effort: 'auto',+ })+ if (seen.has(id)) continue+ seen.add(id)+ output.push({ id, displayName: entry.id })+ }+ // See commandcodeModels: only worth a row when the catalogue itself came back.+ if (entries.length && state?.model && !entries.some((entry) => entry.id === state.model)) {+ const id = encodeRuntimeProfile({+ sessionId: session.agentId, engine: 'opencode', model: state.model, effort: 'auto',+ })+ if (!seen.has(id)) output.push({ id, displayName: state.model })+ }+ return output+ }++ async catalog(): Promise<OpencodeModelTarget[]> {+ // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.+ const key = env.OPENCODE_DATA_DIR+ if (this.opencodeCatalogCache?.key === key && this.opencodeCatalogCache.expiresAt > Date.now()) {+ return this.opencodeCatalogCache.entries+ }+ let entries: OpencodeModelTarget[] = []+ try {+ const result = await execFileAsync(opencodeBin(), ['models'], {+ env: process.env, timeout: 10_000, maxBuffer: 1024 * 1024,+ })+ entries = opencode.parseOpencodeModelsOutput(result.stdout)+ } catch (err) {+ console.warn('[runtime-profile] OpenCode model catalog failed:', err instanceof Error ? err.message : err)+ }+ this.opencodeCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }+ return entries+ }++ async config(): Promise<boolean> { await this.catalog(); return false }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'opencode' } { return new ProfileReader() }diff --git a/cli/src/engines/otherRuntime.golden.spec.ts b/cli/src/engines/otherRuntime.golden.spec.tsindex 305101c80..42a166011 100644--- a/cli/src/engines/otherRuntime.golden.spec.ts+++ b/cli/src/engines/otherRuntime.golden.spec.ts@@ -2,7 +2,7 @@* What the core reads of the twelve other engines' model and effort, and what a switch of theirs does, recorded* from main before their runtime-profile parsers left the core's static imports* (docs/design/2026-10-08-other-engines-out-of-core.md, (o4)). Through the core's own entries, wired as core/main.ts- * wires them for an engine no worker serves (`new LegacyRuntimeProfileManager(() => undefined)`):+ * wires them for an engine no worker serves (`new RuntimeProfileState(() => undefined)`):** - every pane through `ingestPane`, for every engine, from a fresh session: what it reports changed and the state;* - every transcript through `hydrate`, and line by line through `ingest` and `transcriptFields`;@@ -39,7 +39,7 @@ const ENGINES = ['opencode', 'cursor', 'kilo', 'devin', 'hermes', 'amp', 'agy',type Engine = (typeof ENGINES)[number]const SPEC_FILES = [...['agy', 'commandcode', 'devin', 'grok', 'hermes', 'kilo', 'opencode', 'pi'].map((e) => `engines/${e}/runtimeProfile.spec.ts`),- 'lib/runtimeProfile.spec.ts', 'lib/runtimeProfileController.spec.ts', 'lib/runtimeProfileManager.spec.ts',+ 'lib/runtimeProfile.spec.ts', 'lib/runtimeProfileController.spec.ts', 'lib/runtimeProfileState.spec.ts',]const NOW = Date.parse('2026-10-08T12:00:00.000Z')const fixturesDir = join(SRC, 'lib', '__fixtures__')@@ -69,15 +69,15 @@ function fixturePanes(): string[] {]}-type Manager = InstanceType<Awaited<ReturnType<typeof loadCore>>['LegacyRuntimeProfileManager']>+type Manager = InstanceType<Awaited<ReturnType<typeof loadCore>>['RuntimeProfileState']>async function loadCore() {- const { LegacyRuntimeProfileManager } = await import('../lib/runtimeProfileManager.js')+ const { RuntimeProfileState } = await import('../lib/runtimeProfileState.js')const { RuntimeProfileController } = await import('../lib/runtimeControl.js')const { encodeRuntimeProfile } = await import('../engines/kit/runtime.js')- return { LegacyRuntimeProfileManager, RuntimeProfileController, encodeRuntimeProfile }+ return { RuntimeProfileState, RuntimeProfileController, encodeRuntimeProfile }}let core: Awaited<ReturnType<typeof loadCore>>-const manager = (): Manager => new core.LegacyRuntimeProfileManager(() => undefined)+const manager = (): Manager => new core.RuntimeProfileState(() => undefined)const stateOf = (m: Manager, s: RegisteredSession) => ({ state: m.getState(s.sessionId), selected: m.selectedModel(s) })let golden: Goldendiff --git a/cli/src/engines/pi/inProcess.ts b/cli/src/engines/pi/inProcess.tsindex 945641d32..6d6e5cd09 100644--- a/cli/src/engines/pi/inProcess.ts+++ b/cli/src/engines/pi/inProcess.ts@@ -6,3 +6,5 @@export { PiNormalizer, lastPiTurnText, piMessagesToEvents, windowPiLines } from './normalizer.js'export { PI_EFFORTS, PI_THINKING_LEVELS, parsePiFooterProfile, parsePiModelsOutput, parsePiThinkingSelection, piThinkingSteps } from './runtimeProfile.js'export { piProvider, piSessionFolder, readPiHead } from '../../lib/sessionSearch/externals/pi.js'++export { createRuntimeProfileReader } from './profileReader.js'diff --git a/cli/src/engines/pi/profileReader.ts b/cli/src/engines/pi/profileReader.tsnew file mode 100644index 000000000..31ec927e2--- /dev/null+++ b/cli/src/engines/pi/profileReader.ts@@ -0,0 +1,71 @@+import type { InlineRuntimeContext, InlineRuntimeReader } from '../facets/inlineRuntime.js'+import type { RuntimeModelOption } from '../facets/runtime.js'+import { addOption } from '../kit/runtime.js'+import { confirmObserved } from '../kit/runtimeReader.js'+import { env } from '../../config/env.js'+import { execFile } from 'node:child_process'+import { promisify } from 'node:util'+import * as pi from './runtimeProfile.js'+import type { parsePiModelsOutput } from './runtimeProfile.js'++const execFileAsync = promisify(execFile)+const CATALOG_TTL_MS = 5 * 60_000++class ProfileReader {+ readonly engine = 'pi' as const+ private piCatalogCache: { key: string; expiresAt: number; entries: ReturnType<typeof parsePiModelsOutput> } | null = null++ pane(context: InlineRuntimeContext, paneText: string): void | false {+ const { state, control } = context+ // Pi puts both axes in one footer cell: `minimax/minimax-m3 • high`.+ const footer = pi.parsePiFooterProfile(paneText)+ if (footer) {+ state.model = footer.model+ state.effort = footer.effort+ state.observedAt = Date.now()+ confirmObserved(control, footer.model, footer.effort)+ }+ }++ async models(context: InlineRuntimeContext): Promise<RuntimeModelOption[]> {+ const { session, state } = context+ const entries = await this.piCatalog()+ const output: RuntimeModelOption[] = []+ const seen = new Set<string>()+ for (const entry of entries) {+ addOption(output, seen, session, entry.model, 'auto', entry.model)+ if (!entry.thinking) continue+ for (const level of pi.PI_THINKING_LEVELS) addOption(output, seen, session, entry.model, level, entry.model)+ }+ if (entries.length && state?.model) {+ addOption(output, seen, session, state.model, 'auto', state.model)+ if (state.effort && pi.PI_EFFORTS.has(state.effort)) {+ addOption(output, seen, session, state.model, state.effort, state.model)+ }+ }+ return output+ }++ private async piCatalog(): Promise<ReturnType<typeof parsePiModelsOutput>> {+ // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.+ const key = env.PI_HOME+ if (this.piCatalogCache?.key === key && this.piCatalogCache.expiresAt > Date.now()) {+ return this.piCatalogCache.entries+ }+ let entries: ReturnType<typeof parsePiModelsOutput> = []+ try {+ const result = await execFileAsync('pi', ['--list-models'], {+ env: process.env,+ timeout: 10_000,+ maxBuffer: 1024 * 1024,+ })+ entries = pi.parsePiModelsOutput(result.stdout)+ } catch (err) {+ console.warn('[runtime-profile] Pi model catalog failed:', err instanceof Error ? err.message : err)+ }+ this.piCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }+ return entries+ }+}++export function createRuntimeProfileReader(): InlineRuntimeReader & { engine: 'pi' } { return new ProfileReader() }diff --git a/cli/src/lib/__fixtures__/runtime-profile-state.golden.json b/cli/src/lib/__fixtures__/runtime-profile-state.golden.jsonnew file mode 100644index 000000000..71487cfc6--- /dev/null+++ b/cli/src/lib/__fixtures__/runtime-profile-state.golden.json@@ -0,0 +1,2948 @@+{+ "linux": {+ "claude": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": "runtime-v1:session-claude:claude:registered-model@auto",+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": "runtime-v1:session-claude:claude:registered-model@auto",+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-claude:claude:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-claude:claude:chosen-model@high",+ "changes": [+ "session-claude"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-claude:claude:chosen-model@high",+ "changes": [+ "session-claude",+ "session-claude"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-claude",+ "session-claude"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "codex": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-codex:codex:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-codex:codex:chosen-model@high",+ "changes": [+ "session-codex"+ ]+ },+ "supported": true,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-codex:codex:chosen-model@high",+ "changes": [+ "session-codex",+ "session-codex"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-codex",+ "session-codex"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "cursor": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-cursor:cursor:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-cursor:cursor:chosen-model@high",+ "changes": [+ "session-cursor"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-cursor:cursor:chosen-model@high",+ "changes": [+ "session-cursor",+ "session-cursor"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-cursor",+ "session-cursor"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "opencode": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-opencode:opencode:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-opencode:opencode:chosen-model@high",+ "changes": [+ "session-opencode"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-opencode:opencode:chosen-model@high",+ "changes": [+ "session-opencode",+ "session-opencode"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-opencode",+ "session-opencode"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "kilo": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-kilo:kilo:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-kilo:kilo:chosen-model@high",+ "changes": [+ "session-kilo"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-kilo:kilo:chosen-model@high",+ "changes": [+ "session-kilo",+ "session-kilo"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-kilo",+ "session-kilo"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "devin": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-devin:devin:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-devin:devin:chosen-model@high",+ "changes": [+ "session-devin"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-devin:devin:chosen-model@high",+ "changes": [+ "session-devin",+ "session-devin"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-devin",+ "session-devin"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "hermes": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-hermes:hermes:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-hermes:hermes:chosen-model@high",+ "changes": [+ "session-hermes"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-hermes:hermes:chosen-model@high",+ "changes": [+ "session-hermes",+ "session-hermes"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-hermes",+ "session-hermes"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "amp": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-amp:amp:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-amp:amp:chosen-model@high",+ "changes": [+ "session-amp"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-amp:amp:chosen-model@high",+ "changes": [+ "session-amp",+ "session-amp"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-amp",+ "session-amp"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "agy": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-agy:agy:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-agy:agy:chosen-model@high",+ "changes": [+ "session-agy"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-agy:agy:chosen-model@high",+ "changes": [+ "session-agy",+ "session-agy"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-agy",+ "session-agy"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "grok": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-grok:grok:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-grok:grok:chosen-model@high",+ "changes": [+ "session-grok"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-grok:grok:chosen-model@high",+ "changes": [+ "session-grok",+ "session-grok"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-grok",+ "session-grok"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "copilot": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-copilot:copilot:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-copilot:copilot:chosen-model@high",+ "changes": [+ "session-copilot"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-copilot:copilot:chosen-model@high",+ "changes": [+ "session-copilot",+ "session-copilot"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-copilot",+ "session-copilot"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "commandcode": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-commandcode:commandcode:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-commandcode:commandcode:chosen-model@high",+ "changes": [+ "session-commandcode"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-commandcode:commandcode:chosen-model@high",+ "changes": [+ "session-commandcode",+ "session-commandcode"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-commandcode",+ "session-commandcode"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "muse": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-muse:muse:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-muse:muse:chosen-model@high",+ "changes": [+ "session-muse"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-muse:muse:chosen-model@high",+ "changes": [+ "session-muse",+ "session-muse"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-muse",+ "session-muse"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "pi": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-pi:pi:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-pi:pi:chosen-model@high",+ "changes": [+ "session-pi"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-pi:pi:chosen-model@high",+ "changes": [+ "session-pi",+ "session-pi"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-pi",+ "session-pi"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "generic": {+ "state": {+ "model": null,+ "effort": "high",+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": 1791504000360+ },+ "selected": null,+ "timedOut": false+ },+ "unbound": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "own": null,+ "other": null+ },+ "staged": {+ "before": {+ "model": "gpt-6.1-sol",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000375+ },+ "during": {+ "model": "gpt-6.1-sol",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000375+ },+ "committed": {+ "model": "gpt-6-luna",+ "effort": "low",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000375+ },+ "afterSuppressed": {+ "model": "gpt-6.1-sol",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000375+ },+ "fields": [+ "model",+ "effort"+ ],+ "emitted": []+ }+ },+ "darwin": {+ "claude": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": "runtime-v1:session-claude:claude:registered-model@auto",+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": "runtime-v1:session-claude:claude:registered-model@auto",+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-claude:claude:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-claude:claude:chosen-model@high",+ "changes": [+ "session-claude"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-claude:claude:chosen-model@high",+ "changes": [+ "session-claude",+ "session-claude"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-claude",+ "session-claude"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "codex": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-codex:codex:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-codex:codex:chosen-model@high",+ "changes": [+ "session-codex"+ ]+ },+ "supported": true,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-codex:codex:chosen-model@high",+ "changes": [+ "session-codex",+ "session-codex"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-codex",+ "session-codex"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "cursor": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-cursor:cursor:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-cursor:cursor:chosen-model@high",+ "changes": [+ "session-cursor"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-cursor:cursor:chosen-model@high",+ "changes": [+ "session-cursor",+ "session-cursor"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-cursor",+ "session-cursor"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "opencode": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-opencode:opencode:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-opencode:opencode:chosen-model@high",+ "changes": [+ "session-opencode"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-opencode:opencode:chosen-model@high",+ "changes": [+ "session-opencode",+ "session-opencode"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-opencode",+ "session-opencode"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "kilo": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-kilo:kilo:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-kilo:kilo:chosen-model@high",+ "changes": [+ "session-kilo"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-kilo:kilo:chosen-model@high",+ "changes": [+ "session-kilo",+ "session-kilo"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-kilo",+ "session-kilo"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "devin": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-devin:devin:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-devin:devin:chosen-model@high",+ "changes": [+ "session-devin"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-devin:devin:chosen-model@high",+ "changes": [+ "session-devin",+ "session-devin"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-devin",+ "session-devin"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "hermes": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-hermes:hermes:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-hermes:hermes:chosen-model@high",+ "changes": [+ "session-hermes"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-hermes:hermes:chosen-model@high",+ "changes": [+ "session-hermes",+ "session-hermes"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-hermes",+ "session-hermes"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "amp": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-amp:amp:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-amp:amp:chosen-model@high",+ "changes": [+ "session-amp"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-amp:amp:chosen-model@high",+ "changes": [+ "session-amp",+ "session-amp"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-amp",+ "session-amp"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "agy": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-agy:agy:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-agy:agy:chosen-model@high",+ "changes": [+ "session-agy"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-agy:agy:chosen-model@high",+ "changes": [+ "session-agy",+ "session-agy"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-agy",+ "session-agy"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "grok": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-grok:grok:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-grok:grok:chosen-model@high",+ "changes": [+ "session-grok"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-grok:grok:chosen-model@high",+ "changes": [+ "session-grok",+ "session-grok"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-grok",+ "session-grok"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "copilot": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-copilot:copilot:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-copilot:copilot:chosen-model@high",+ "changes": [+ "session-copilot"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-copilot:copilot:chosen-model@high",+ "changes": [+ "session-copilot",+ "session-copilot"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-copilot",+ "session-copilot"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "commandcode": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-commandcode:commandcode:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-commandcode:commandcode:chosen-model@high",+ "changes": [+ "session-commandcode"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-commandcode:commandcode:chosen-model@high",+ "changes": [+ "session-commandcode",+ "session-commandcode"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-commandcode",+ "session-commandcode"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "muse": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-muse:muse:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-muse:muse:chosen-model@high",+ "changes": [+ "session-muse"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-muse:muse:chosen-model@high",+ "changes": [+ "session-muse",+ "session-muse"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-muse",+ "session-muse"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "pi": {+ "fresh": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "hydrated": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "begin": true,+ "duplicate": false,+ "invalidEffort": {+ "state": {+ "model": "registered-model",+ "effort": null,+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": null+ },+ "selected": null,+ "changes": []+ },+ "confirmed": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-pi:pi:chosen-model@high",+ "changes": [],+ "modelWait": true,+ "profileWait": true+ },+ "finished": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-pi:pi:chosen-model@high",+ "changes": [+ "session-pi"+ ]+ },+ "supported": false,+ "gatewaySupported": false,+ "cancelled": {+ "state": {+ "model": "chosen-model",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000000+ },+ "selected": "runtime-v1:session-pi:pi:chosen-model@high",+ "changes": [+ "session-pi",+ "session-pi"+ ],+ "waited": false+ },+ "forgotten": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "selected": null,+ "changes": [+ "session-pi",+ "session-pi"+ ],+ "waited": false+ },+ "targets": [+ null,+ null,+ null,+ null+ ]+ },+ "generic": {+ "state": {+ "model": null,+ "effort": "high",+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": 1791504000360+ },+ "selected": null,+ "timedOut": false+ },+ "unbound": {+ "state": {+ "model": null,+ "effort": null,+ "mode": "unknown",+ "cliVersion": null,+ "observedAt": null+ },+ "own": null,+ "other": null+ },+ "staged": {+ "before": {+ "model": "gpt-6.1-sol",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000375+ },+ "during": {+ "model": "gpt-6.1-sol",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000375+ },+ "committed": {+ "model": "gpt-6-luna",+ "effort": "low",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000375+ },+ "afterSuppressed": {+ "model": "gpt-6.1-sol",+ "effort": "high",+ "mode": "unknown",+ "cliVersion": "1.0.0",+ "observedAt": 1791504000375+ },+ "fields": [+ "model",+ "effort"+ ],+ "emitted": []+ }+ }+}diff --git a/cli/src/lib/commandcodeModel.spec.ts b/cli/src/lib/commandcodeModel.spec.tsindex ed9a25099..0fdd752ed 100644--- a/cli/src/lib/commandcodeModel.spec.ts+++ b/cli/src/lib/commandcodeModel.spec.ts@@ -16,6 +16,9 @@ let commandcodeHome = ''async function loadRuntimeProfile() {vi.resetModules()process.env.COMMANDCODE_HOME = commandcodeHome+ // The daemon's attach loads native interpretation before delivering transcript records.+ const { loadEngine } = await import('../engines/inProcess.js')+ await loadEngine('commandcode')return import('./runtimeProfile.js')}@@ -127,10 +130,12 @@ describe('a Command Code agent', () => {expect(parseRuntimeProfile(manager.selectedModel(target))?.effort).toBe('high')manager.ingest(target, assistantLine('moonshotai/kimi-k3'))- await new Promise((resolve) => setTimeout(resolve, 20)) // the re-read ingest() fires is async- const profile = parseRuntimeProfile(manager.selectedModel(target))- expect(profile?.model).toBe('kimi-k3')- expect(profile?.effort).toBe('auto')+ manager.ingest(target, assistantLine('moonshotai/kimi-k3')) // one watcher batch can contain several replies+ await vi.waitFor(() => {+ const profile = parseRuntimeProfile(manager.selectedModel(target))+ expect(profile?.model).toBe('kimi-k3')+ expect(profile?.effort).toBe('auto')+ })})it('offers nothing to pick when the catalogue cannot be read', async () => {diff --git a/cli/src/lib/runtimeProfile.ts b/cli/src/lib/runtimeProfile.tsindex 1b24e29b0..dfe8f348e 100644--- a/cli/src/lib/runtimeProfile.ts+++ b/cli/src/lib/runtimeProfile.ts@@ -1,15 +1,17 @@/** Inline compatibility composition. Supervised core must not import this module. */import type { RegisteredSession } from './registry.js'import { runtimeFor } from '../engines/runtime.js'-import { LegacyRuntimeProfileManager } from './runtimeProfileManager.js'+import { RuntimeProfileState } from './runtimeProfileState.js'-export * from './runtimeProfileManager.js'+export * from './runtimeProfileState.js'export { codexEffortAllowed } from '../engines/codex/runtimeProfile.js'export function supportsNativeRuntimeControl(session: RegisteredSession): boolean {return !session.gateway && (runtimeFor(session.engine)?.supportsControl(session) ?? false)}-export class RuntimeProfileManager extends LegacyRuntimeProfileManager {+export class RuntimeProfileManager extends RuntimeProfileState {constructor() { super(runtimeFor) }}++export { parseCursorModelsOutput, type CursorModelTarget } from '../engines/cursor/profileReader.js'diff --git a/cli/src/lib/runtimeProfileManager.spec.ts b/cli/src/lib/runtimeProfileManager.spec.tsdeleted file mode 100644index d741e0a38..000000000--- a/cli/src/lib/runtimeProfileManager.spec.ts+++ /dev/null@@ -1,136 +0,0 @@-import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'-import { tmpdir } from 'node:os'-import { join } from 'node:path'-import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'-import { env } from '../config/env.js'-import { runtime as claudeRuntime } from '../engines/claude/runtimeProfile.js'-import type { RegisteredSession } from './registry.js'-import { LegacyRuntimeProfileManager } from './runtimeProfileManager.js'-import { RuntimeProfileManager } from './runtimeProfile.js'-import { parseRuntimeProfile } from './runtimeProfileWire.js'-import { engineNow, loadEngine, OTHER_ENGINES } from '../engines/inProcess.js'--// A test may say an engine's code could not be loaded.-vi.mock('../engines/inProcess.js', async (real) => {- const actual = await real<typeof import('../engines/inProcess.js')>()- return { ...actual, engineNow: vi.fn(actual.engineNow), loadEngine: vi.fn(actual.loadEngine) }-})--const fixture = (name: string): string => readFileSync(join(import.meta.dirname, '__fixtures__', name), 'utf8')-const session = (engine: RegisteredSession['engine']): RegisteredSession => ({- agentId: 'agent', sessionId: 'conversation', engine, model: 'registered-model', cliVersion: '1.0.0',- cwd: '/tmp', transcriptPath: '/tmp/profile-recording.jsonl',-} as RegisteredSession)-afterEach(() => { vi.restoreAllMocks(); vi.useRealTimers() })-// The other engines' profile readers load as one of their sessions enters the registry (engines/inProcess.ts-// `preloadEngine`): before any pane of theirs is read, as here.-beforeAll(async () => { for (const engine of OTHER_ENGINES) await loadEngine(engine) })--describe('another engine whose code could not be loaded', () => {- it('reads nothing of its panes, config files or catalog, and leaves its chips as they were', async () => {- const manager = new LegacyRuntimeProfileManager(() => undefined)- vi.mocked(engineNow).mockReturnValue(null)- vi.mocked(loadEngine).mockResolvedValue(null as never)- try {- for (const engine of ['devin', 'hermes', 'commandcode', 'opencode', 'kilo', 'pi', 'grok', 'agy'] as const) {- const agent = { ...session(engine), sessionId: `${engine}-s` }- expect(manager.ingestPane(agent, 'any pane', true), engine).toBe(false)- expect(manager.getState(agent.sessionId), engine).toMatchObject({ model: null, effort: null })- }- for (const engine of ['hermes', 'muse', 'amp'] as const) {- expect(await manager.ingestConfig({ ...session(engine), sessionId: `${engine}-c` }, true), engine).toBe(false)- }- expect(await manager.opencodeCatalog()).toEqual([])- expect(await manager.kiloCatalog()).toEqual([])- } finally {- vi.mocked(engineNow).mockReset()- vi.mocked(loadEngine).mockReset()- }- })-})--describe('runtime profiles without the pilot implementations', () => {- it.each([- ['amp', 'amp-session.jsonl'], ['amp', 'amp-session-queued.jsonl'],- ['muse', 'muse-session.jsonl'], ['copilot', 'copilot-session.jsonl'], ['agy', 'agy-session.jsonl'],- ] as const)('preserves the registry seed when replaying the recorded %s transcript %s', (engine, file) => {- const lines = fixture(file).trim().split('\n')- // Audit the removed fallback against recordings, not formats inferred from Claude. None of these- // native records contributed profile metadata through that reader; their own config/panes do.- expect(lines.map(line => claudeRuntime.decode(JSON.parse(line))).filter(Boolean)).toEqual([])- const manager = new LegacyRuntimeProfileManager(() => undefined)- const agent = session(engine)- manager.hydrate(agent, lines)- expect(manager.getState(agent.sessionId)).toEqual({- model: 'registered-model', effort: null, mode: 'unknown', cliVersion: '1.0.0', observedAt: null,- })- })-- it('keeps Pi metadata in its native footer and never treats answer text as Claude commands', () => {- const manager = new LegacyRuntimeProfileManager(() => undefined)- const agent = session('pi')- // These metadata records are copied from the Pi 0.82.1 recording in pi/normalizer.spec.ts.- const lines = [- '{"type":"session","version":3,"id":"019fa2a5-a26d-700c-bf8c-97af19ae3d5f","timestamp":"2026-07-27T08:16:31.854Z","cwd":"/tmp/pi-probe"}',- '{"type":"model_change","id":"45215278","parentId":null,"model":"minimax/minimax-m3"}',- '{"type":"thinking_level_change","id":"1da16955","parentId":"45215278","level":"medium"}',- ]- expect(lines.map(line => claudeRuntime.decode(JSON.parse(line)))).toEqual([null, null, null])- manager.hydrate(agent, lines)- manager.ingestPane(agent, '0.0%/500k (auto) minimax/minimax-m3 • high', true)- const before = manager.getState(agent.sessionId)- expect(parseRuntimeProfile(manager.selectedModel(agent))).toMatchObject({- engine: 'pi', model: 'minimax/minimax-m3', effort: 'high',- })- // An answer explaining another CLI uses ordinary text in Pi's recorded message envelope.- expect(manager.ingest(agent, JSON.stringify({ type: 'message', message: {- role: 'assistant', content: [{ type: 'text', text: 'Set model to Opus 5\nSet effort level to low' }],- } }), true)).toBe(false)- expect(manager.getState(agent.sessionId)).toEqual(before)- })-- it.each(['amp', 'muse', 'copilot', 'terminal'] as const)('does not interpret Claude UI quoted in a %s pane', engine => {- // Apply the same boundary in explicit inline mode. Supplying a Claude facet must not make it a- // fallback for engines whose profile source is their own config or registration.- const manager = new RuntimeProfileManager(), agent = session(engine)- manager.hydrate(agent, [])- const before = manager.getState(agent.sessionId)- expect(manager.ingestPane(agent, 'Claude Code v2.1.212\nOpus 5 with high effort · Claude Max\nplan mode on', true)).toBe(false)- expect(manager.getState(agent.sessionId)).toEqual(before)- })-- it('retains the native Muse and Amp config sources without loading either pilot facet', async () => {- const root = mkdtempSync(join(tmpdir(), 'legacy-profile-'))- const defaults = { muse: env.MUSE_CONFIG_DIR, amp: env.AMP_STATE_DIR }- try {- env.MUSE_CONFIG_DIR = join(root, 'muse'); env.AMP_STATE_DIR = join(root, 'amp')- mkdirSync(env.MUSE_CONFIG_DIR); mkdirSync(env.AMP_STATE_DIR)- // Verified config shapes documented in each engine's runtimeProfile.ts.- writeFileSync(join(env.MUSE_CONFIG_DIR, 'settings.json'), JSON.stringify({- schema_version: 1, provider: 'meta', model: 'muse-spark-1.2-contributor',- }))- writeFileSync(join(env.AMP_STATE_DIR, 'session.json'), JSON.stringify({ agentMode: 'medium' }))- const manager = new LegacyRuntimeProfileManager(() => undefined)- for (const [engine, model, effort] of [- ['muse', 'muse-spark-1.2-contributor', 'high'], ['amp', 'medium', 'auto'],- ] as const) {- const agent = { ...session(engine), sessionId: engine }- await manager.ingestConfig(agent, true)- expect(parseRuntimeProfile(manager.selectedModel(agent))).toMatchObject({ engine, model, effort })- }- } finally {- env.MUSE_CONFIG_DIR = defaults.muse; env.AMP_STATE_DIR = defaults.amp- rmSync(root, { recursive: true, force: true })- }- })-- it('still reads the captured agy footer and the registry-supplied CLI version', () => {- const manager = new LegacyRuntimeProfileManager(() => undefined), agent = session('agy')- manager.hydrate(agent, [])- manager.ingestPane(agent, fixture('permission-agy.txt'), true)- expect(parseRuntimeProfile(manager.selectedModel(agent))).toMatchObject({- engine: 'agy', model: 'gemini-3.7-flash-high', effort: 'high',- })- expect(manager.getState(agent.sessionId).cliVersion).toBe('1.0.0')- })-})diff --git a/cli/src/lib/runtimeProfileManager.ts b/cli/src/lib/runtimeProfileManager.tsdeleted file mode 100644index 44f404d3e..000000000--- a/cli/src/lib/runtimeProfileManager.ts+++ /dev/null@@ -1,1336 +0,0 @@-import { parseRuntimeProfile } from './runtimeProfileWire.js'-export { parseRuntimeProfile } from './runtimeProfileWire.js'-import { readFile } from 'fs/promises'-import { join } from 'path'-import { execFile } from 'child_process'-import { promisify } from 'util'-import { env } from '../config/env.js'-import type { AgentEngine } from '../engines/types.js'-import type { RegisteredSession } from './registry.js'-import type { DevinModelTarget } from '../engines/devin/runtimeProfile.js'-import type { HermesModelTarget } from '../engines/hermes/runtimeProfile.js'-import type { CommandcodeModelTarget } from '../engines/commandcode/runtimeProfile.js'-import type { OpencodeModelTarget } from '../engines/opencode/runtimeProfile.js'-import type { KiloModelTarget } from '../engines/kilo/runtimeProfile.js'-import type { parsePiModelsOutput } from '../engines/pi/runtimeProfile.js'-// The other engines' readers of their own profiles are their own code, loaded in this process as one of their-// sessions enters the registry (engines/inProcess.ts): a pane read takes them as loaded, a config or catalog read-// waits for them, and without them the chip keeps its last values.-import { engineNow, loadEngine } from '../engines/inProcess.js'-import type { RuntimeFor } from '../engines/facets/runtime.js'-import type { RuntimeProfile, RuntimeModelOption, RuntimeState, RuntimeField, RuntimeControl, RuntimeCatalogModel } from '../engines/facets/runtime.js'-export type { RuntimeProfile, RuntimeModelOption, RuntimeState, RuntimeField } from '../engines/facets/runtime.js'-import { addOption, currentPaneUi, effortLabel, encodeRuntimeProfile, parseVersion, readJson, record, runtimeModelLabel, stripAnsi, text, transcriptFields, versionAtLeast, RUNTIME_EFFORTS } from '../engines/kit/runtime.js'-export { encodeRuntimeProfile, runtimeModelLabel } from '../engines/kit/runtime.js'--const blankState = (): RuntimeState => ({ model: null, effort: null, mode: 'unknown', cliVersion: null, observedAt: null })--/** Where a session's runtime state starts before its transcript is read. */-function freshState(session: RegisteredSession): RuntimeState {- return {- ...blankState(),- // Registries written by older builds can hold a non-string model; treat it as unknown instead of- // letting it reach claudeAliasForModel and abort startup.- model: typeof session.model === 'string' ? session.model : null,- cliVersion: session.cliVersion,- }-}--export interface CursorModelTarget {- rawId: string- modelKey: string- familyLabel: string- context: string | null- reasoning: string | null- fast: boolean | null- thinking: boolean | null- /** Effort text rendered in the idle footer; null means Cursor omits its native default. */- footerEffort?: string | null-}--interface CursorCatalogEntry {- target: CursorModelTarget- effort: string- modelLabel: string-}--interface StateWaiter {- check: () => boolean- resolve: (matched: boolean) => void- timer: NodeJS.Timeout-}--const CURSOR_EFFORTS = new Set(['auto', 'none', 'low', 'medium', 'high', 'xhigh', 'max'])-/** Wire parsing accepts all known effort labels; each engine owns its support policy. */-const EFFORTS = RUNTIME_EFFORTS-/**- * Versions whose model UI was driven by hand before wiring it up. Open-ended upward: a newer CLI is- * assumed compatible (the alternative — refusing to switch after every auto-update — is worse), but a- * KNOWN-older one is refused rather than driven blind.- */-const DEVIN_CONTROL_MIN_VERSION: [number, number, number] = [3000, 3, 22]-const PI_CONTROL_MIN_VERSION: [number, number, number] = [0, 82, 0]-const OPENCODE_CONTROL_MIN_VERSION: [number, number, number] = [1, 18, 7]-/**- * 1.6.0 is the first Command Code that can be driven at all: it added `--list-models` (a catalog on- * stdout) and made `/model <id>` and `/effort <level>` take arguments. On 1.5 and older the only route was- * arrow-driving a 49-row picker, which is exactly what got the first attempt reverted — so older builds- * are refused rather than driven.- */-const COMMANDCODE_CONTROL_MIN_VERSION: [number, number, number] = [1, 6, 0]-/**- * Hermes ships no version its hook payload exposes, and its `/model` picker has been the same two-level- * arrow list throughout — so it is gated on the picker being recognisable rather than on a number. The- * driver refuses to move if it cannot read the cursor (see setHermes), which is the real safety net.- */-const HERMES_CONTROL_UNVERSIONED = true-/**- * Cap on how many rows an engine's catalog may contribute. Devin publishes 166 across 72 families, and a- * 49-row picker was enough to stall the device's the device UI task into a watchdog reset (see the Command Code- * revert, 2026-07-30). The device already truncates at CATALOG_MAX/PICK_MAX, but truncation there is- * arbitrary — bounding here keeps the rows we DO send meaningful (see devinModels).- */-const CATALOG_LIMIT = 96-const CHANGE_DEBOUNCE_MS = 120-const CURSOR_CONTROLLED_BUILD = '2026.07.20-8cc9c0b'-const CURSOR_CATALOG_TTL_MS = 5 * 60_000-/** Shared TTL for the stdout catalogs (devin, pi) — same rationale as the cursor one. */-const CATALOG_TTL_MS = 5 * 60_000-import { opencodeBin } from './engineBin.js'--const execFileAsync = promisify(execFile)---function cursorEffortFromId(rawId: string): { effort: string | null; modelKey: string } {- const parts = rawId.split('-')- let index = -1- let width = 1- for (let i = 2; i < parts.length; i++) {- if (parts[i] === 'extra' && parts[i + 1] === 'high') {- index = i- width = 2- i++- } else if (['none', 'low', 'medium', 'high', 'xhigh', 'max'].includes(parts[i])) {- index = i- width = 1- }- }- if (index < 0) return { effort: null, modelKey: rawId }- const rawEffort = parts.slice(index, index + width).join('-')- parts.splice(index, width)- return {- effort: rawEffort === 'extra-high' ? 'xhigh' : rawEffort,- modelKey: parts.join('-'),- }-}--function cursorEffortFromDisplay(value: string): string | null {- const match = /\b(Extra High|None|Low|Medium|High|Max)\b/i.exec(value)- if (!match) return null- return match[1].toLowerCase().replace(/\s+/g, '') === 'extrahigh'- ? 'xhigh'- : match[1].toLowerCase()-}--function cursorDisplayParts(displayName: string): {- familyLabel: string- context: string | null- fast: boolean- thinking: boolean-} {- let value = displayName- .replace(/\s+\((?:current|default)(?:,\s*(?:current|default))?\)\s*$/i, '')- .replace(/\s+\(NO ZDR\)\s*$/i, '')- .replace(/\s*[·│]\s*\d+(?:\.\d+)?%.*$/i, '')- .trim()- const contextMatch = /\b(\d+(?:\.\d+)?[KM])\b/i.exec(value)- const context = contextMatch?.[1].toLowerCase() ?? null- const fast = /\bFast\b/i.test(value)- const thinking = !/\bNo\s+Thinking\b/i.test(value) && /\bThinking\b/i.test(value)- value = value- .replace(/\b\d+(?:\.\d+)?[KM]\b/gi, '')- .replace(/\bExtra High\b/gi, '')- .replace(/\b(?:None|Low|Medium|High|Max)\b/gi, '')- .replace(/\bNo\s+Thinking\b/gi, '')- .replace(/\b(?:Fast|Thinking)\b/gi, '')- .replace(/\s+/g, ' ')- .trim()- return { familyLabel: value, context, fast, thinking }-}--/** Strictly parse `agent models`; headings, tips and malformed rows are ignored. */-export function parseCursorModelsOutput(output: string): CursorCatalogEntry[] {- const candidates: Array<CursorCatalogEntry & { explicitEffort: boolean }> = []- for (const rawLine of output.split('\n')) {- const match = /^([a-z0-9][a-z0-9._-]*) - (.+?)\s*$/i.exec(rawLine)- if (!match) continue- const rawId = match[1]- const displayName = match[2].trim()- const display = cursorDisplayParts(displayName)- if (!display.familyLabel) continue- if (rawId === 'auto') {- candidates.push({- target: {- rawId,- modelKey: rawId,- familyLabel: 'Auto',- context: null,- reasoning: null,- fast: null,- thinking: null,- footerEffort: 'auto',- },- effort: 'auto',- modelLabel: 'Auto',- explicitEffort: true,- })- continue- }- const parsed = cursorEffortFromId(rawId)- const effort = parsed.effort- const footerEffort = cursorEffortFromDisplay(displayName)- candidates.push({- target: {- rawId,- modelKey: parsed.modelKey,- familyLabel: display.familyLabel,- context: display.context,- reasoning: effort,- fast: display.fast,- thinking: display.thinking,- footerEffort,- },- effort: effort ?? 'auto',- modelLabel: [- display.familyLabel,- display.context ? `(${display.context.toUpperCase()})` : '',- display.thinking ? 'Thinking' : '',- display.fast ? 'Fast' : '',- ].filter(Boolean).join(' '),- explicitEffort: effort !== null,- })- }-- // Some medium/default rows omit the effort segment (for example `gpt-5.3-codex`).- // Infer medium only when explicit siblings prove that the same exact model group has efforts.- const effortfulGroups = new Set(candidates.filter((item) => item.explicitEffort).map((item) => item.target.modelKey))- for (const item of candidates) {- if (item.target.rawId === 'auto' || item.effort !== 'auto' || !effortfulGroups.has(item.target.modelKey)) continue- item.effort = 'medium'- item.target.reasoning = 'medium'- }- return candidates.map(({ explicitEffort: _explicitEffort, ...item }) => item)-}--function parseCursorFooter(value: string): {- familyLabel: string- context: string | null- effort: string | null- fast: boolean- thinking: boolean-} | null {- const line = stripAnsi(value).trim()- if (/^Auto(?:\s*$|\s*[·│])/i.test(line)) {- return { familyLabel: 'Auto', context: null, effort: 'auto', fast: false, thinking: false }- }- const effort = cursorEffortFromDisplay(line)- const hasUsage = /[·│]\s*\d+(?:\.\d+)?%/i.test(line)- const hasThinkingMode = /\b(?:No\s+Thinking|Thinking)\b/i.test(line)- if (!effort && !hasUsage && !hasThinkingMode) return null- const parts = cursorDisplayParts(line)- if (!parts.familyLabel || !/\d/.test(parts.familyLabel)) return null- return {- ...parts,- effort,- }-}--function cursorSyntheticTarget(- parsed: NonNullable<ReturnType<typeof parseCursorFooter>>,- effort: string,-): CursorModelTarget {- if (parsed.familyLabel.toLowerCase() === 'auto' && parsed.effort === 'auto') {- return {- rawId: 'auto',- modelKey: 'auto',- familyLabel: 'Auto',- context: null,- reasoning: null,- fast: null,- thinking: null,- footerEffort: 'auto',- }- }- const family = parsed.familyLabel.toLowerCase().replace(/[^a-z0-9.]+/g, '-').replace(/^-|-$/g, '') || 'model'- // Keep the public runtime-v1 model key compatible with every client formatter. The Cursor routing- // details remain on CursorModelTarget (and rawId) for selection/confirmation; they do not belong in- // the user-facing profile key as a percent-encoded "[fast=...,thinking=...]" implementation detail.- const modelKey = [- family,- parsed.context?.toLowerCase() ?? '',- parsed.thinking ? 'thinking' : '',- parsed.fast ? 'fast' : '',- ].filter(Boolean).join('-')- const parameters = [- parsed.context ? `context=${parsed.context}` : '',- `fast=${parsed.fast}`,- `thinking=${parsed.thinking}`,- ].filter(Boolean).join(',')- return {- rawId: `cursor-${family}[${parameters},effort=${effort}]`,- modelKey,- familyLabel: parsed.familyLabel,- context: parsed.context,- reasoning: effort === 'auto' ? null : effort,- fast: parsed.fast,- thinking: parsed.thinking,- footerEffort: parsed.effort,- }-}--/** Raw file text, or '' when it cannot be read — hermes' config is YAML, not JSON. */-async function readText(file: string): Promise<string> {- try { return await readFile(file, 'utf8') } catch { return '' }-}--/** Command Code ids are "vendor/name"; everything we store and show uses the name alone. */-function shortCommandcodeModel(id: string): string {- return id.slice(id.lastIndexOf('/') + 1)-}--/**- * Command Code keeps the reasoning level in its GLOBAL config, keyed by the FULL gateway id:- * { "model": "deepseek/deepseek-v4-flash", "reasoningEffort": { "deepseek/deepseek-v4-flash": "high" } }- * Nothing in the transcript, the pane footer or the session header carries it, so this file is the only- * source. It is per MACHINE rather than per session: two agents on the same model necessarily read the same- * level. Matching is done on the short name because that is what the running model is stored as.- */-/** The configured level for `model`, or 'auto' when the model has none set. */-async function commandcodeConfiguredEffort(model: string | null): Promise<{ effort: string; defaultModel: string }> {- const config = await readJson(join(env.COMMANDCODE_HOME, 'config.json'))- const defaultModel = shortCommandcodeModel(text(config?.model))- const efforts = record(config?.reasoningEffort)- const wanted = model || defaultModel- if (!efforts || !wanted) return { effort: 'auto', defaultModel }- for (const [id, level] of Object.entries(efforts)) {- if (shortCommandcodeModel(id) !== wanted) continue- const normalized = text(level).toLowerCase()- if (normalized && normalized !== 'default' && EFFORTS.has(normalized)) return { effort: normalized, defaultModel }- }- return { effort: 'auto', defaultModel }-}--/** Other engines retain their native readers. Pilot facets are injected only for inline compatibility. */-export class LegacyRuntimeProfileManager {- constructor(private readonly runtimeFor: RuntimeFor) {}-- supportsControl(session: RegisteredSession): boolean {- return !session.gateway && (this.runtimeFor(session.engine)?.supportsControl(session) ?? false)- }-- effortAllowed(session: RegisteredSession, model: string, effort: string, listed: readonly string[] | null): boolean {- return this.runtimeFor(session.engine)?.effortAllowed?.(model, effort, listed) ?? false- }-- private readonly states = new Map<string, RuntimeState>()- private readonly controls = new Map<string, RuntimeControl>()- private readonly waiters = new Map<string, Set<StateWaiter>>()- private readonly changeTimers = new Map<string, NodeJS.Timeout>()- private readonly cursorTargets = new Map<string, Map<string, CursorModelTarget>>()- /** profile id → the exact `/model` argument, per session (devin ids are not derivable from the key). */- private readonly devinTargets = new Map<string, Map<string, DevinModelTarget>>()- private devinCatalogCache: { key: string; expiresAt: number; entries: DevinModelTarget[] } | null = null- private piCatalogCache: { key: string; expiresAt: number; entries: ReturnType<typeof parsePiModelsOutput> } | null = null- private opencodeCatalogCache: { key: string; expiresAt: number; entries: OpencodeModelTarget[] } | null = null- private kiloCatalogCache: { key: string; expiresAt: number; entries: KiloModelTarget[] } | null = null- private commandcodeCatalogCache: { key: string; expiresAt: number; entries: CommandcodeModelTarget[] } | null = null- /** profile id → the full `/model` argument (the profile carries the SHORT name the device labels by). */- private readonly commandcodeTargets = new Map<string, Map<string, CommandcodeModelTarget>>()- /** Per HOME, not one slot: a desk with a default-home agent and a profile agent would otherwise- * evict each other's catalog on every menu open (`hermes -p <name>` has its own providers). */- private hermesCatalogCache = new Map<string, { expiresAt: number; entries: HermesModelTarget[] }>()- /** profile id → the picker page + row a hermes model sits on. */- private readonly hermesTargets = new Map<string, Map<string, HermesModelTarget>>()- private cursorCatalogCache: { key: string; expiresAt: number; entries: CursorCatalogEntry[] } | null = null- private suppressNotifications = 0- onChanged: ((sessionId: string) => void) | null = null-- hydrate(session: RegisteredSession, rawLines: string[]): void {- if (this.unbound(session.sessionId)) return- this.states.set(session.sessionId, freshState(session))- for (const line of rawLines) this.ingest(session, line, true)- }-- /**- * `hydrate`, for a Claude Code or Codex transcript streamed in rather than loaded- * (lib/attachTranscript.ts): records are read into a staged state, and what the session shows only- * changes at `commit` — never an empty chip while the read runs, never a live record overwritten by- * an older one read after it.- */- beginHydrate(session: RegisteredSession): { ingest(rawLine: string): void; commit(): void } {- const staged = freshState(session)- return {- ingest: (rawLine) => {- let raw: Record<string, unknown> | null- try { raw = record(JSON.parse(rawLine)) } catch { return }- if (!raw) return- this.runtimeFor(session.engine)?.transcript({ session, state: staged, control: this.controls.get(session.sessionId) }, raw)- },- commit: () => {- if (this.unbound(session.sessionId)) return- this.states.set(session.sessionId, staged)- this.wake(session.sessionId)- },- }- }-- ingest(session: RegisteredSession, rawLine: string, silent = false): boolean {- let raw: Record<string, unknown> | null- try { raw = record(JSON.parse(rawLine)) } catch { return false }- if (!raw) return false- const before = this.selectedModel(session)- const runtime = this.runtimeFor(session.engine)- if (runtime) runtime.transcript({ session, state: this.state(session.sessionId), control: this.controls.get(session.sessionId) }, raw)- else if (session.engine === 'cursor') this.ingestCursor(session, raw)- else if (session.engine === 'commandcode') {- const model = this.states.get(session.sessionId)?.model ?? null- this.ingestCommandcode(session, raw)- // The reasoning level is stored PER MODEL, so a model change makes the level we are holding wrong.- // Re-read it now instead of showing the previous model's level until the next poll.- if ((this.states.get(session.sessionId)?.model ?? null) !== model) {- void this.ingestConfig(session, silent).catch(() => undefined)- }- }- else if (session.engine === 'grok') this.ingestGrok(session, raw)- // A different engine's answer can quote Claude commands. Only its own format may change its profile.- const after = this.selectedModel(session)- this.wake(session.sessionId)- if (!silent && this.suppressNotifications === 0 && before !== after && !this.controls.has(session.sessionId)) this.scheduleChanged(session.sessionId)- return before !== after- }-- /**- * Which of model, effort and mode one Claude or Codex transcript record sets — asked of the same- * readers `ingest` uses, on a scratch state, so the two cannot disagree. An attach that reads only the- * end of a transcript (lib/attachTranscript.ts) reaches back to the newest record that set each one.- *- * It can only under-report (the session's own model-switch control is not consulted), and the attach- * replays every record from the oldest one it reached, so under-reporting costs a longer reach, never- * a wrong value.- */- transcriptFields(session: RegisteredSession, rawLine: string): RuntimeField[] {- return transcriptFields(this.runtimeFor(session.engine), session, rawLine)- }-- async ingestConfig(session: RegisteredSession, silent = false): Promise<boolean> {- if (session.engine === 'hermes') {- // Both axes are scalars in config.yaml and neither is announced, so this poll is the only reader.- const before = this.selectedModel(session)- const state = this.state(session.sessionId)- // This agent's OWN home: `hermes -p <name>` keeps its model and effort in the profile's- // config.yaml, and reading the default one reported the wrong model on every profile agent.- const hermes = await loadEngine('hermes')- if (!hermes) return false- const parsed = hermes.parseHermesConfig(await readText(join(session.hermesHome || env.HERMES_HOME, 'config.yaml')))- if (parsed.model) state.model = parsed.model.slice(parsed.model.lastIndexOf('/') + 1)- state.effort = parsed.effort ?? 'auto'- state.observedAt = Date.now()- const after = this.selectedModel(session)- this.wake(session.sessionId)- if (!silent && this.suppressNotifications === 0 && before !== after && !this.controls.has(session.sessionId)) {- this.scheduleChanged(session.sessionId)- }- return before !== after- }- if (session.engine === 'muse') {- // Both axes are plain scalars in ~/.config/muse/settings.json (`model`, `reasoning_effort`) and- // neither is announced anywhere, so reading the file IS the only way the chip is ever populated.- // `reasoning_effort` is muse's own vocabulary (none|minimal|low|medium|high|xhigh|ultra); the- // absence of the key means the CLI default, which its own --help documents as `high`.- const before = this.selectedModel(session)- const state = this.state(session.sessionId)- const muse = await loadEngine('muse')- if (!muse) return false- const parsed = muse.parseMuseSettings(await readText(join(env.MUSE_CONFIG_DIR, 'settings.json')))- if (parsed.model) state.model = parsed.model- state.effort = parsed.effort ?? 'auto'- state.observedAt = Date.now()- const after = this.selectedModel(session)- this.wake(session.sessionId)- if (!silent && this.suppressNotifications === 0 && before !== after && !this.controls.has(session.sessionId)) {- this.scheduleChanged(session.sessionId)- }- return before !== after- }- if (session.engine === 'amp') {- // Amp has no models — only agent MODES — so the mode is reported as the model and there is no- // second axis to report. `~/.local/share/amp/session.json` is the only local place it is written.- const before = this.selectedModel(session)- const state = this.state(session.sessionId)- const amp = await loadEngine('amp')- if (!amp) return false- const parsed = amp.parseAmpSession(await readText(join(env.AMP_STATE_DIR, 'session.json')))- if (parsed.mode) state.model = parsed.mode- state.effort = 'auto'- state.observedAt = Date.now()- const after = this.selectedModel(session)- this.wake(session.sessionId)- if (!silent && this.suppressNotifications === 0 && before !== after && !this.controls.has(session.sessionId)) {- this.scheduleChanged(session.sessionId)- }- return before !== after- }- if (session.engine === 'opencode') {- // The footer only resolves against the catalog, so warm it here — `ingestPane` is synchronous and- // cannot fetch, and without this the chip stays blank until the web happens to ask for models.- await this.opencodeCatalog()- return false- }- if (session.engine === 'kilo') {- // Same reason as opencode: kilo names its model only in the composer footer, which resolves only- // against the catalog, and `ingestPane` is synchronous.- await this.kiloCatalog()- return false- }- if (session.engine === 'devin') {- // Same shape: devin's model exists only as a DISPLAY name in its pane footer, and only the catalog- // maps that back to a model key + effort. Warm it on attach so the first pane read resolves.- await this.devinCatalog()- return false- }- if (session.engine !== 'claude' && session.engine !== 'commandcode') return false- const before = this.selectedModel(session)- const state = this.state(session.sessionId)- if (session.engine === 'commandcode') {- const config = await commandcodeConfiguredEffort(state.model)- state.effort = config.effort- // Before the agent has answered once there is no transcript line to read the model from; the config's- // own model is what a fresh session starts on, so the chip names it instead of falling back to Auto.- if (!state.model && config.defaultModel) state.model = config.defaultModel- } else {- state.effort = await this.runtimeFor(session.engine)?.configuredEffort?.(session) ?? state.effort- }- state.observedAt = Date.now()- const after = this.selectedModel(session)- this.wake(session.sessionId)- if (!silent && this.suppressNotifications === 0 && before !== after && !this.controls.has(session.sessionId)) {- this.scheduleChanged(session.sessionId)- }- return before !== after- }-- ingestPane(session: RegisteredSession, paneText: string, silent = false): boolean {- const before = this.selectedModel(session)- const state = this.state(session.sessionId)- paneText = stripAnsi(paneText)- const currentUi = currentPaneUi(paneText)- const runtime = this.runtimeFor(session.engine)- if (runtime) {- runtime.pane({ session, state, control: this.controls.get(session.sessionId) }, paneText)- } else if (session.engine === 'cursor') {- if (/Available models|Models matching|— Edit Parameters|Type to filter.*Tab to edit|Esc to go back/i.test(currentUi)) return false- const footerLines = currentUi.split('\n')- .filter((line) => stripAnsi(line).trim())- .slice(-12)- .reverse()- const parsed = footerLines.map(parseCursorFooter).find((item) => item !== null)- if (parsed) {- const targets = this.cursorTargets.get(session.sessionId) ?? new Map<string, CursorModelTarget>()- let target = [...targets.values()].find((candidate) =>- candidate.familyLabel.toLowerCase() === parsed.familyLabel.toLowerCase()- && (parsed.effort- ? (candidate.reasoning ?? 'auto') === parsed.effort- : candidate.footerEffort === null)- && (candidate.fast ?? false) === parsed.fast- && (candidate.thinking ?? false) === parsed.thinking- && (!candidate.context || candidate.context === parsed.context))- const effort = parsed.effort ?? target?.reasoning ?? 'auto'- if (!target) {- target = cursorSyntheticTarget(parsed, effort)- const id = encodeRuntimeProfile({- sessionId: session.agentId,- engine: 'cursor',- model: target.modelKey,- effort,- })- targets.set(id, target)- this.cursorTargets.set(session.sessionId, targets)- }- state.model = target.modelKey- state.effort = effort- state.observedAt = Date.now()- const control = this.controls.get(session.sessionId)- if (control && target?.modelKey === control.target.model && effort === control.target.effort) {- control.modelConfirmed = true- control.effortConfirmed = true- }- }- if (/\bPlan\b/i.test(currentUi)) state.mode = 'plan'- else if (/Plan, search, build anything/i.test(currentUi)) state.mode = 'default'- } else if (session.engine === 'devin') {- // Devin writes no transcript unless the user passes `--export`, so the footer's bottom-left cell is- // the only per-session record of the running model. It is a DISPLAY name (`SWE-1.6 Slow`); the- // catalog resolves it back to a model key so the chip and the picker agree.- const label = engineNow('devin', 'its pane was read')?.devinFooterModel(paneText)- const model = label ? this.devinModelKeyForLabel(session.sessionId, label) : null- if (model) {- state.model = model.modelKey- state.effort = model.effort- state.observedAt = Date.now()- this.confirmObserved(session.sessionId, model.modelKey, model.effort)- }- } else if (session.engine === 'hermes') {- // `⚕ minimax-m3 │ ctx --` — the status line is how a switch is seen immediately; config.yaml is- // rewritten too, but the poll that reads it runs on its own schedule.- const model = engineNow('hermes', 'its pane was read')?.hermesStatusModel(paneText)- if (model && model !== state.model) {- state.model = model- state.observedAt = Date.now()- }- } else if (session.engine === 'commandcode') {- // `/model` reprints the session banner (`# models: kimi-k2.6 · taste-1`) with the new model. The- // transcript would say the same thing, but only after the NEXT turn runs — too late to confirm a- // switch, and long enough for the chip to look stuck.- const model = engineNow('commandcode', 'its pane was read')?.commandcodeBannerModel(paneText)- if (model && model !== state.model) {- state.model = model- state.observedAt = Date.now()- // Effort is stored per model in the CLI's global config, so the level we hold belongs to the old- // one. Re-read rather than carry it across.- void this.ingestConfig(session, true).catch(() => undefined)- }- } else if (session.engine === 'opencode') {- // OpenCode names what is running in its composer footer- // (`Build · MiniMax M3 (vibe) Vibe Gateway · high`). Prefer the catalog entry it resolves to,- // because that id is also what a SWITCH is addressed to — the cached entries rather than a- // fresh (async) fetch, since this runs on the pane poll.- //- // Fall back to the footer's own words when the catalog does not list it. That is not a corner- // case: with no provider connected OpenCode runs a built-in free model that `opencode models`- // never prints, so insisting on a catalog match left the chips blank on a freshly opened agent- // — showing nothing about a model the terminal was naming two lines below.- const opencode = engineNow('opencode', 'its pane was read')- const footer = opencode?.parseOpencodeFooter(paneText)- const id = opencode?.opencodeFooterModelId(paneText, this.opencodeCatalogCache?.entries ?? [])- const model = id ?? footer?.target ?? null- if (model) {- // 'auto' remains the default: early builds had no reasoning axis at all, and inventing a- // level for them would put a wrong value on the chip instead of an empty one.- const effort = footer?.effort ?? 'auto'- state.model = model- state.effort = effort- state.observedAt = Date.now()- this.confirmObserved(session.sessionId, model, effort)- }- } else if (session.engine === 'kilo') {- // Kilo names the model in its composer footer too, but the line is shaped differently enough that- // its resolver had to be rewritten rather than renamed — see engines/kilo/runtimeProfile.ts.- const id = engineNow('kilo', 'its pane was read')?.kiloFooterModelId(paneText, this.kiloCatalogCache?.entries ?? [])- if (id) {- state.model = id- state.effort = 'auto'- state.observedAt = Date.now()- this.confirmObserved(session.sessionId, id, 'auto')- }- } else if (session.engine === 'pi') {- // Pi puts both axes in one footer cell: `minimax/minimax-m3 • high`.- const footer = engineNow('pi', 'its pane was read')?.parsePiFooterProfile(paneText)- if (footer) {- state.model = footer.model- state.effort = footer.effort- state.observedAt = Date.now()- this.confirmObserved(session.sessionId, footer.model, footer.effort)- }- } else if (session.engine === 'grok') {- const footer = engineNow('grok', 'its pane was read')?.parseGrokFooterProfile(paneText)- if (footer) {- state.model = footer.model- state.effort = footer.effort- state.observedAt = Date.now()- }- } else if (session.engine === 'agy') {- // agy's transcript never names the model, so the pane footer is the only continuous source; the- // hook payload's `modelName` seeds it at session start.- const footer = engineNow('agy', 'its pane was read')?.parseAgyFooterProfile(paneText)- if (footer) {- state.model = footer.model- state.effort = footer.effort- state.observedAt = Date.now()- }- }- const after = this.selectedModel(session)- this.wake(session.sessionId)- if (!silent && this.suppressNotifications === 0 && before !== after && !this.controls.has(session.sessionId)) this.scheduleChanged(session.sessionId)- return before !== after- }-- getState(sessionId: string): RuntimeState {- return { ...this.state(sessionId) }- }-- async withoutChangeEvents<T>(operation: () => Promise<T>): Promise<T> {- this.suppressNotifications++- try { return await operation() } finally { this.suppressNotifications-- }- }-- selectedModel(session: RegisteredSession): string | null {- if (this.unbound(session.sessionId)) return null- const state = this.states.get(session.sessionId)- if (!state?.model) return null- const adapter = this.runtimeFor(session.engine)- if (adapter) return adapter.selectedModel(session, state)- const model = state.model- const effort = state.effort- if (!effort) return null- return encodeRuntimeProfile({- sessionId: session.agentId,- engine: session.engine,- model,- effort,- })- }-- beginControl(session: RegisteredSession, target: RuntimeProfile): boolean {- if (this.controls.has(session.sessionId)) return false- const before = this.selectedModel(session)- const current = parseRuntimeProfile(before)- this.controls.set(session.sessionId, {- target,- before,- modelConfirmed: current?.model === target.model,- effortConfirmed: current?.effort === target.effort,- })- return true- }-- cancelControl(sessionId: string): void {- const control = this.controls.get(sessionId)- this.controls.delete(sessionId)- this.wake(sessionId)- if (control) this.scheduleChanged(sessionId)- }-- finishControl(session: RegisteredSession): void {- const control = this.controls.get(session.sessionId)- this.controls.delete(session.sessionId)- this.wake(session.sessionId)- this.scheduleChanged(session.sessionId)- }-- confirmEffort(sessionId: string, effort: string): void {- if (!EFFORTS.has(effort)) return- const state = this.state(sessionId)- state.effort = effort- state.observedAt = Date.now()- const control = this.controls.get(sessionId)- if (control) control.effortConfirmed = control.target.effort === effort- this.wake(sessionId)- }-- confirmControlProfile(target: RuntimeProfile): void {- const state = this.state(target.sessionId)- state.model = target.model- state.effort = target.effort- state.observedAt = Date.now()- const control = this.controls.get(target.sessionId)- if (control?.target.id === target.id) {- control.modelConfirmed = true- control.effortConfirmed = true- }- this.wake(target.sessionId)- }-- waitForModel(sessionId: string, timeoutMs: number): Promise<boolean> {- return this.waitFor(sessionId, () => this.controls.get(sessionId)?.modelConfirmed === true, timeoutMs)- }-- waitForProfile(sessionId: string, timeoutMs: number): Promise<boolean> {- return this.waitFor(sessionId, () => {- const control = this.controls.get(sessionId)- return control?.modelConfirmed === true && control.effortConfirmed === true- }, timeoutMs)- }-- forget(sessionId: string): void {- this.states.delete(sessionId)- this.controls.delete(sessionId)- const timer = this.changeTimers.get(sessionId)- if (timer) clearTimeout(timer)- this.changeTimers.delete(sessionId)- this.cursorTargets.delete(sessionId)- for (const waiter of this.waiters.get(sessionId) ?? []) {- clearTimeout(waiter.timer)- waiter.resolve(false)- }- this.waiters.delete(sessionId)- }-- async modelsForSessions(sessions: RegisteredSession[]): Promise<RuntimeModelOption[]> {- const groups = await Promise.all(sessions.map((session) => this.modelsForSession(session)))- return groups.flat()- }-- /**- * Only Claude and Codex can be SWITCHED from the device (owner, 2026-07-31). Every other engine is- * view-only: its chip still names the model and effort it is running — that comes from the ingest paths,- * not from here — but it offers nothing to pick.- *- * An empty catalogue is the whole mechanism: the device's picker returns to the projects screen when the- * list comes back empty, so this policy lives in one place and needs no firmware change to revise.- * The per-engine builders (cursor/opencode/pi/hermes/commandcode/devin) are kept, unused by this path,- * because the catalogues they fetch are what the ingest paths resolve pane footers against.- */- async modelsForSession(session: RegisteredSession): Promise<RuntimeModelOption[]> {- // Display-only through a gateway: the empty catalogue IS the mechanism (see the note above), so web- // renders a static chip and the device picker closes instead of offering a list we cannot enumerate.- if (session.gateway) return []- return this.runtimeFor(session.engine)?.models(session, this.states.get(session.sessionId)) ?? []- }-- cursorTarget(sessionId: string, profileId: string): CursorModelTarget | null {- return this.cursorTargets.get(sessionId)?.get(profileId) ?? null- }-- /** The `/model` argument for a devin profile id — devin's ids do not follow from the model key. */- devinTarget(sessionId: string, profileId: string): DevinModelTarget | null {- return this.devinTargets.get(sessionId)?.get(profileId) ?? null- }-- /** Mark an in-flight control confirmed once the pane shows the profile it asked for. */- private confirmObserved(sessionId: string, model: string, effort: string): void {- const control = this.controls.get(sessionId)- if (!control || control.target.model !== model || control.target.effort !== effort) return- control.modelConfirmed = true- control.effortConfirmed = true- }-- /** Resolve devin's footer display name (`SWE-1.6 Slow`) back to the catalog row it names. */- private devinModelKeyForLabel(sessionId: string, label: string): DevinModelTarget | null {- // Resolve against the CATALOG, not the per-session id map. That map is only built when something opens- // the model picker, so a session nobody had picked on could not read its own footer and the chip stayed- // blank. The catalog is the same data minus the per-session ids, and ingestConfig warms it on attach.- // The session map stays first: its rows are the ones the picker will offer.- const targets = this.devinTargets.get(sessionId)- const pool: Iterable<DevinModelTarget> = targets?.size- ? targets.values()- : this.devinCatalogCache?.entries ?? []- const wanted = label.trim().toLowerCase()- for (const target of pool) {- // A row whose id carries no effort keeps the effort word in its label ("GLM-5.2 High"), so an exact- // label match is what identifies it; anything looser would tie the footer to the wrong sibling.- if (target.label.toLowerCase() === wanted) return target- if (target.effort !== 'auto' && `${target.label} ${effortLabel(target.effort)}`.toLowerCase() === wanted) {- return target- }- }- return null- }-- /**- * An agent that has not bound an engine session yet. Its `sessionId` is the EMPTY STRING, which is- * not an identity — every unbound agent would share one entry in a map keyed on it, across engines.- *- * That is not hypothetical. A claude agent ten seconds old was retargeted onto a grid, and the- * "what model was it on?" read that the retarget keeps — so a later move home can restore it —- * answered `opencode/big-pickle`: an OpenCode agent sitting at `''` had written its footer there- * first. The claude pane came home with `ANTHROPIC_MODEL=opencode/big-pickle` and Claude Code- * answered "There's an issue with the selected model (opencode/big-pickle). It may not exist".- *- * So `''` gets no entry in this conversation cache, and writes land in a throwaway rather than a- * bucket the next agent will read. Transcript state is re-read once a real conversation binds.- */- private unbound(sessionId: string): boolean {- return !sessionId- }-- private state(sessionId: string): RuntimeState {- if (this.unbound(sessionId)) return blankState()- let state = this.states.get(sessionId)- if (!state) {- state = blankState()- this.states.set(sessionId, state)- }- return state- }-- private ingestCursor(session: RegisteredSession, raw: Record<string, unknown>): void {- const state = this.state(session.sessionId)- const version = text(raw.version) || text(raw.cursor_version)- if (version) {- session.cliVersion = version- state.cliVersion = version- }- const model = text(raw.model)- if (model) {- state.model = model- // Default the effort to 'auto' when we do not have one yet. selectedModel() returns null unless BOTH- // axes are known, so without this a Cursor session whose model we DO know shows nothing at all on- // the device — the model is thrown away because the effort is missing.- //- // Cursor reports its model in the transcript but its reasoning level only in the pane footer, so- // the effort arrives later (ingestPane) or not at all for a model that has no reasoning levels.- // 'auto' is not a guess about Cursor's behaviour: it is exactly how the device renders "not- // specified", and the pane path overwrites it with the real value the moment one is read.- state.effort ??= 'auto'- state.observedAt = Date.now()- }- }-- private ingestGrok(session: RegisteredSession, raw: Record<string, unknown>): void {- const params = record(raw.params)- const update = record(params?.update)- const meta = record(update?._meta)- const model = text(meta?.modelId)- if (!model) return- const state = this.state(session.sessionId)- state.model = model- state.observedAt = Date.now()- }-- /**- * The catalog Codex builds its own `/model` picker from, read fresh: what the controller matches the- * picker's rows against (engines/codex/modelPicker.ts). Empty when there is no cache to read.- */- async codexCatalog(session: RegisteredSession): Promise<RuntimeCatalogModel[]> {- return this.runtimeFor(session.engine)?.catalog?.(session) ?? []- }-- /** Command Code stamps the model on every assistant line as the full gateway id- * ("deepseek/deepseek-v4-flash"). Store the short name so it matches the catalogue and the chip label.- * `raw.version` here is the transcript SCHEMA version (3), not a CLI version — never read it as one. */- private ingestCommandcode(session: RegisteredSession, raw: Record<string, unknown>): void {- const model = text(raw.model)- if (!model) return- const state = this.state(session.sessionId)- state.model = shortCommandcodeModel(model)- // Effort is NOT touched here: it comes from the CLI config (ingestConfig), and stamping 'auto' on every- // assistant line would wipe a configured level a second after it was read.- state.observedAt = Date.now()- }-- private async cursorModels(session: RegisteredSession): Promise<RuntimeModelOption[]> {- const key = `${session.cliVersion ?? 'unknown'}\0${process.env.HOME ?? ''}`- let entries = this.cursorCatalogCache?.key === key && this.cursorCatalogCache.expiresAt > Date.now()- ? this.cursorCatalogCache.entries- : null- if (!entries) {- try {- const result = await execFileAsync('agent', ['models'], {- env: process.env,- timeout: 5_000,- maxBuffer: 1024 * 1024,- })- entries = parseCursorModelsOutput(result.stdout)- this.cursorCatalogCache = { key, entries, expiresAt: Date.now() + CURSOR_CATALOG_TTL_MS }- } catch (err) {- console.warn('[runtime-profile] Cursor model catalog failed:', err instanceof Error ? err.message : err)- entries = []- }- }-- const output: RuntimeModelOption[] = []- const previousTargets = this.cursorTargets.get(session.sessionId) ?? new Map<string, CursorModelTarget>()- const targets = new Map<string, CursorModelTarget>()- const seen = new Set<string>()- for (const entry of entries) {- if (!CURSOR_EFFORTS.has(entry.effort)) continue- const id = encodeRuntimeProfile({- sessionId: session.agentId,- engine: 'cursor',- model: entry.target.modelKey,- effort: entry.effort,- })- if (seen.has(id)) continue- seen.add(id)- targets.set(id, entry.target)- output.push({ id, displayName: `${entry.modelLabel} / ${effortLabel(entry.effort)}` })- }- const state = this.states.get(session.sessionId)- const current = state?.model && state.effort- ? encodeRuntimeProfile({- sessionId: session.agentId,- engine: 'cursor',- model: state.model,- effort: state.effort,- })- : null- const observed = current ? previousTargets.get(current) : null- if (observed) {- const familyEfforts = [...new Set(entries- .filter((entry) => entry.target.familyLabel.toLowerCase() === observed.familyLabel.toLowerCase())- .map((entry) => entry.effort)- .filter((effort) => effort !== 'auto'))]- const efforts = familyEfforts.length ? familyEfforts : [state!.effort!]- for (const effort of efforts) {- const id = encodeRuntimeProfile({- sessionId: session.agentId,- engine: 'cursor',- model: observed.modelKey,- effort,- })- if (seen.has(id)) continue- seen.add(id)- targets.set(id, { ...observed, reasoning: effort, footerEffort: effort })- const label = [- observed.familyLabel,- observed.context ? `(${observed.context.toUpperCase()})` : '',- observed.thinking ? 'Thinking' : '',- observed.fast ? 'Fast' : '',- ].filter(Boolean).join(' ')- output.push({ id, displayName: `${label} / ${effortLabel(effort)}` })- }- }- this.cursorTargets.set(session.sessionId, targets)- return output- }-- /**- * Devin's catalog comes from `devin models list` on stdout — no picker to scrape. It is big (166 rows- * across 72 models on this account), so it is trimmed to CATALOG_LIMIT, and the model the session is- * ACTUALLY running is pinned to the front so trimming can never hide it.- */- private async devinModels(session: RegisteredSession): Promise<RuntimeModelOption[]> {- const devin = await loadEngine('devin')- if (!devin) return []- const entries = await this.devinCatalog()- const targets = new Map<string, DevinModelTarget>()- const state = this.states.get(session.sessionId)- // Keep every row of the running model together with it, so its effort list stays complete.- const ordered = state?.model- ? [...entries].sort((a, b) => Number(b.modelKey === state.model) - Number(a.modelKey === state.model))- : entries-- const output: RuntimeModelOption[] = []- const seen = new Set<string>()- for (const entry of ordered) {- if (output.length >= CATALOG_LIMIT) break- if (!devin.DEVIN_EFFORTS.has(entry.effort)) continue- const id = encodeRuntimeProfile({- sessionId: session.agentId,- engine: 'devin',- model: entry.modelKey,- effort: entry.effort,- })- if (seen.has(id)) continue- seen.add(id)- targets.set(id, entry)- output.push({ id, displayName: `${entry.label} / ${effortLabel(entry.effort)}` })- }- this.devinTargets.set(session.sessionId, targets)- return output- }-- private async devinCatalog(): Promise<DevinModelTarget[]> {- // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.- const devin = await loadEngine('devin')- if (!devin) return []- const key = env.DEVIN_HOME- if (this.devinCatalogCache?.key === key && this.devinCatalogCache.expiresAt > Date.now()) {- return this.devinCatalogCache.entries- }- let entries: DevinModelTarget[] = []- try {- const result = await execFileAsync('devin', ['models', 'list'], {- env: process.env,- timeout: 10_000,- maxBuffer: 1024 * 1024,- })- entries = devin.parseDevinModelsOutput(result.stdout)- } catch (err) {- console.warn('[runtime-profile] Devin model catalog failed:', err instanceof Error ? err.message : err)- }- this.devinCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }- return entries- }-- /**- * Pi lists models on stdout too, and its `thinking` column says which of them accept a reasoning depth —- * so effort rows are attached per model instead of assumed. A model that is configured but absent from- * the table (the state fallback) still gets its own row so the chip never goes blank.- */- private async piModels(session: RegisteredSession): Promise<RuntimeModelOption[]> {- const pi = await loadEngine('pi')- if (!pi) return []- const entries = await this.piCatalog()- const output: RuntimeModelOption[] = []- const seen = new Set<string>()- for (const entry of entries) {- addOption(output, seen, session, entry.model, 'auto', entry.model)- if (!entry.thinking) continue- for (const level of pi.PI_THINKING_LEVELS) addOption(output, seen, session, entry.model, level, entry.model)- }- const state = this.states.get(session.sessionId)- if (entries.length && state?.model) {- addOption(output, seen, session, state.model, 'auto', state.model)- if (state.effort && pi.PI_EFFORTS.has(state.effort)) {- addOption(output, seen, session, state.model, state.effort, state.model)- }- }- return output- }-- /** The picker page + row a hermes profile id points at. */- hermesTarget(sessionId: string, profileId: string): HermesModelTarget | null {- return this.hermesTargets.get(sessionId)?.get(profileId) ?? null- }-- /**- * Hermes offers MODELS only. Its reasoning effort lives in `agent.reasoning_effort` in config.yaml with- * no in-session command to change it (`/config` only prints), and a running session does not re-read the- * file — so an effort row would be a control that silently does nothing. The level is still OBSERVED, so- * the chip names it truthfully; it just cannot be picked.- */- private async hermesModels(session: RegisteredSession): Promise<RuntimeModelOption[]> {- const hermes = await loadEngine('hermes')- if (!hermes) return []- const entries = await this.hermesCatalog(session.hermesHome || env.HERMES_HOME)- const state = this.states.get(session.sessionId)- const targets = new Map<string, HermesModelTarget>()- const output: RuntimeModelOption[] = []- const seen = new Set<string>()- const effort = state?.effort && hermes.HERMES_EFFORTS.has(state.effort) ? state.effort : 'auto'- const add = (entry: HermesModelTarget): void => {- const short = entry.id.slice(entry.id.lastIndexOf('/') + 1)- const id = encodeRuntimeProfile({- sessionId: session.agentId, engine: 'hermes', model: short, effort,- })- if (seen.has(id)) return- seen.add(id)- targets.set(id, entry)- output.push({ id, displayName: runtimeModelLabel(short) })- }- for (const entry of entries) add(entry)- // The provider in use is often absent from the picker cache (a `custom` gateway is its own one-model- // page), so the configured model is always offered — otherwise the running model is missing from its- // own list.- if (state?.model && !seen.size) add({ id: state.model, provider: '' })- else if (state?.model && ![...targets.values()].some((t) => t.id.endsWith(state.model!))) {- add({ id: state.model, provider: '' })- }- this.hermesTargets.set(session.sessionId, targets)- return output- }-- private async hermesCatalog(home = env.HERMES_HOME): Promise<HermesModelTarget[]> {- // Keyed by home, and now actually asked per home: a profile has its own providers, so the cache- // key was already right and only the path it read was not.- const cached = this.hermesCatalogCache.get(home)- if (cached && cached.expiresAt > Date.now()) return cached.entries- const hermes = await loadEngine('hermes')- if (!hermes) return []- const cache = await readJson(join(home, 'provider_models_cache.json'))- const entries = hermes.parseHermesModelsCache(cache)- this.hermesCatalogCache.set(home, { entries, expiresAt: Date.now() + CATALOG_TTL_MS })- return entries- }-- /** The full `/model` argument for a Command Code profile id — the profile itself holds the short name. */- commandcodeTarget(sessionId: string, profileId: string): CommandcodeModelTarget | null {- return this.commandcodeTargets.get(sessionId)?.get(profileId) ?? null- }-- /**- * Command Code's catalog comes from `--list-models`. Effort rows are attached to every model because the- * CLI does not publish which models take one; an unsupported pick is refused in words at apply time- * (see COMMANDCODE_EFFORT_LEVELS).- */- private async commandcodeModels(session: RegisteredSession): Promise<RuntimeModelOption[]> {- const commandcode = await loadEngine('commandcode')- if (!commandcode) return []- const entries = await this.commandcodeCatalog()- const targets = new Map<string, CommandcodeModelTarget>()- const output: RuntimeModelOption[] = []- const seen = new Set<string>()- const add = (entry: CommandcodeModelTarget, effort: string): void => {- const id = encodeRuntimeProfile({- sessionId: session.agentId, engine: 'commandcode', model: entry.shortId, effort,- })- if (seen.has(id)) return- seen.add(id)- targets.set(id, entry)- output.push({ id, displayName: `${runtimeModelLabel(entry.shortId)} / ${effortLabel(effort)}` })- }- for (const entry of entries) {- add(entry, 'auto')- for (const level of commandcode.COMMANDCODE_EFFORT_LEVELS) add(entry, level)- }- const state = this.states.get(session.sessionId)- // `entries.length` guards the fallback: a model row is worth adding when the catalogue is readable but- // does not list what the session runs (a pinned build, a just-removed model). When the catalogue could- // not be read at all, one lone row is a picker that cannot pick anything — better to offer none.- if (entries.length && state?.model && !entries.some((entry) => entry.shortId === state.model)) {- const own: CommandcodeModelTarget = { id: state.model, shortId: state.model, section: '', isDefault: false }- add(own, 'auto')- if (state.effort && commandcode.COMMANDCODE_EFFORTS.has(state.effort)) add(own, state.effort)- }- this.commandcodeTargets.set(session.sessionId, targets)- return output- }-- private async commandcodeCatalog(): Promise<CommandcodeModelTarget[]> {- // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.- const commandcode = await loadEngine('commandcode')- if (!commandcode) return []- const key = env.COMMANDCODE_HOME- if (this.commandcodeCatalogCache?.key === key && this.commandcodeCatalogCache.expiresAt > Date.now()) {- return this.commandcodeCatalogCache.entries- }- let entries: CommandcodeModelTarget[] = []- try {- const result = await execFileAsync('commandcode', ['--list-models'], {- env: process.env, timeout: 15_000, maxBuffer: 1024 * 1024,- })- entries = commandcode.parseCommandcodeModelsOutput(result.stdout)- } catch (err) {- console.warn('[runtime-profile] Command Code model catalog failed:', err instanceof Error ? err.message : err)- }- this.commandcodeCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }- return entries- }-- /** OpenCode has no effort axis, so every model is one `auto` row and the label carries no effort. */- private async opencodeModels(session: RegisteredSession): Promise<RuntimeModelOption[]> {- const entries = await this.opencodeCatalog()- const output: RuntimeModelOption[] = []- const seen = new Set<string>()- for (const entry of entries) {- const id = encodeRuntimeProfile({- sessionId: session.agentId, engine: 'opencode', model: entry.id, effort: 'auto',- })- if (seen.has(id)) continue- seen.add(id)- output.push({ id, displayName: entry.id })- }- const state = this.states.get(session.sessionId)- // See commandcodeModels: only worth a row when the catalogue itself came back.- if (entries.length && state?.model && !entries.some((entry) => entry.id === state.model)) {- const id = encodeRuntimeProfile({- sessionId: session.agentId, engine: 'opencode', model: state.model, effort: 'auto',- })- if (!seen.has(id)) output.push({ id, displayName: state.model })- }- return output- }-- async opencodeCatalog(): Promise<OpencodeModelTarget[]> {- // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.- const opencode = await loadEngine('opencode')- if (!opencode) return []- const key = env.OPENCODE_DATA_DIR- if (this.opencodeCatalogCache?.key === key && this.opencodeCatalogCache.expiresAt > Date.now()) {- return this.opencodeCatalogCache.entries- }- let entries: OpencodeModelTarget[] = []- try {- const result = await execFileAsync(opencodeBin(), ['models'], {- env: process.env, timeout: 10_000, maxBuffer: 1024 * 1024,- })- entries = opencode.parseOpencodeModelsOutput(result.stdout)- } catch (err) {- console.warn('[runtime-profile] OpenCode model catalog failed:', err instanceof Error ? err.message : err)- }- this.opencodeCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }- return entries- }-- /** Kilo has no effort axis either, so every model is one `auto` row. */- private async kiloModels(session: RegisteredSession): Promise<RuntimeModelOption[]> {- const entries = await this.kiloCatalog()- const output: RuntimeModelOption[] = []- const seen = new Set<string>()- for (const entry of entries) {- const id = encodeRuntimeProfile({- sessionId: session.agentId, engine: 'kilo', model: entry.id, effort: 'auto',- })- if (seen.has(id)) continue- seen.add(id)- output.push({ id, displayName: entry.id })- }- return output- }-- async kiloCatalog(): Promise<KiloModelTarget[]> {- // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.- const kilo = await loadEngine('kilo')- if (!kilo) return []- const key = env.KILO_DATA_DIR- if (this.kiloCatalogCache?.key === key && this.kiloCatalogCache.expiresAt > Date.now()) {- return this.kiloCatalogCache.entries- }- let entries: KiloModelTarget[] = []- try {- // Measured: `kilo models` answers WITHOUT the user being logged in (unlike `kilo profile`), and- // prints 299 ids on this machine — so an empty catalog here means the binary is missing, not that- // the account is signed out.- const result = await execFileAsync(env.KILO_PATH || 'kilo', ['models'], {- env: process.env, timeout: 10_000, maxBuffer: 1024 * 1024,- })- entries = kilo.parseKiloModelsOutput(result.stdout)- } catch (err) {- console.warn('[runtime-profile] Kilo model catalog failed:', err instanceof Error ? err.message : err)- }- this.kiloCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }- return entries- }-- private async piCatalog(): Promise<ReturnType<typeof parsePiModelsOutput>> {- // Its output is read with the engine's own code: without it there is no catalog, and nothing is run.- const pi = await loadEngine('pi')- if (!pi) return []- const key = env.PI_HOME- if (this.piCatalogCache?.key === key && this.piCatalogCache.expiresAt > Date.now()) {- return this.piCatalogCache.entries- }- let entries: ReturnType<typeof parsePiModelsOutput> = []- try {- const result = await execFileAsync('pi', ['--list-models'], {- env: process.env,- timeout: 10_000,- maxBuffer: 1024 * 1024,- })- entries = pi.parsePiModelsOutput(result.stdout)- } catch (err) {- console.warn('[runtime-profile] Pi model catalog failed:', err instanceof Error ? err.message : err)- }- this.piCatalogCache = { key, entries, expiresAt: Date.now() + CATALOG_TTL_MS }- return entries- }-- private scheduleChanged(sessionId: string): void {- const previous = this.changeTimers.get(sessionId)- if (previous) clearTimeout(previous)- this.changeTimers.set(sessionId, setTimeout(() => {- this.changeTimers.delete(sessionId)- if (!this.controls.has(sessionId)) this.onChanged?.(sessionId)- }, CHANGE_DEBOUNCE_MS))- }-- private waitFor(sessionId: string, check: () => boolean, timeoutMs: number): Promise<boolean> {- if (check()) return Promise.resolve(true)- return new Promise((resolve) => {- const waiter: StateWaiter = {- check,- resolve,- timer: setTimeout(() => {- this.waiters.get(sessionId)?.delete(waiter)- resolve(false)- }, timeoutMs),- }- const set = this.waiters.get(sessionId) ?? new Set<StateWaiter>()- set.add(waiter)- this.waiters.set(sessionId, set)- })- }-- private wake(sessionId: string): void {- const set = this.waiters.get(sessionId)- if (!set) return- for (const waiter of [...set]) {- if (!waiter.check()) continue- clearTimeout(waiter.timer)- set.delete(waiter)- waiter.resolve(true)- }- if (set.size === 0) this.waiters.delete(sessionId)- }-}diff --git a/cli/src/lib/runtimeProfileRegistry.spec.ts b/cli/src/lib/runtimeProfileRegistry.spec.tsnew file mode 100644index 000000000..c3b0b590e--- /dev/null+++ b/cli/src/lib/runtimeProfileRegistry.spec.ts@@ -0,0 +1,87 @@+import { mkdtempSync, rmSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { afterEach, expect, it, vi } from 'vitest'+import { runtime as claudeRuntime } from '../engines/claude/runtimeProfile.js'+import { RuntimeProfileState } from './runtimeProfileState.js'+import { engineNow, loadEngine } from '../engines/inProcess.js'+import type { InlineRuntimeContext } from '../engines/facets/inlineRuntime.js'++vi.mock('./bootId.js', async real => ({ ...await real<object>(), currentBootId: () => 'fixture-boot' }))+vi.mock('../engines/inProcess.js', async real => ({ ...await real<object>(), engineNow: vi.fn(), loadEngine: vi.fn() }))++let root: string | undefined+afterEach(() => {+ vi.restoreAllMocks(); vi.unstubAllEnvs()+ if (root) rmSync(root, { recursive: true, force: true })+})++it('fences deferred config, staged history and detached pane observations against Registry.register replacements', async () => {+ root = mkdtempSync(join(tmpdir(), 'profile-registry-'))+ vi.stubEnv('ADAPTER_DATA_DIR', root)+ vi.stubEnv('CLAUDE_PROJECTS_DIR', root)+ vi.resetModules()+ const { registry } = await import('./registry.js')+ registry.load()+ const input = { engine: 'hermes' as const, sessionId: '20261009_060000_abc123', tmuxPane: '%81', cwd: root,+ hermesHome: join(root, 'first') }+ registry.openProcessAgent({ ...input, processIdentity: { pid: 7001, executable: 'hermes', startMarker: 'fixture' } })+ const old = registry.register(input)!.entry+ let finish!: (effort: string) => void+ const configuredEffort = vi.fn(() => new Promise<string>(resolve => { finish = resolve }))+ const pane = vi.fn(({ state }) => { state.model = 'from-pane' })+ const profiles = new RuntimeProfileState(() => ({ ...claudeRuntime, configuredEffort, pane }), id => registry.resolve(id))+ profiles.hydrate(old, [])+ profiles.confirmEffort(old.sessionId, 'high')+ const before = profiles.getState(old.sessionId)+ const pending = profiles.ingestConfig(old), staged = profiles.beginHydrate(old)+ staged.ingest(JSON.stringify({ type: 'assistant', version: '9.9.9', message: { model: 'claude-opus-5' } }))+ const current = registry.register({ ...input, hermesHome: join(root, 'second') })!.entry+ expect(current).not.toBe(old)+ expect(current.agentId).toBe(old.agentId)+ expect(old.hermesHome).toBe(input.hermesHome)+ finish('low')+ expect(await pending).toBe(false)+ expect(profiles.getState(old.sessionId)).toEqual(before)+ const install = vi.fn(() => true)+ expect(staged.commitWith!(install)).toBe(false)+ expect(install).not.toHaveBeenCalled()+ profiles.hydrate(old, [])+ expect(profiles.ingest(old, JSON.stringify({ type: 'assistant', message: { model: 'stale' } }))).toBe(false)+ expect(profiles.ingestPane(old, 'stale pane')).toBe(false)+ expect(await profiles.ingestConfig(old)).toBe(false)+ expect(pane).not.toHaveBeenCalled()+ expect(configuredEffort).toHaveBeenCalledOnce()+ expect(profiles.getState(old.sessionId)).toEqual(before)+ profiles.ingestPane(current, 'current pane', true)+ expect(pane).toHaveBeenCalledOnce()+ expect(profiles.getState(current.sessionId).model).toBe('from-pane')+ profiles.forget(old.sessionId)+})++it('drops an optional config refresh queued by a row replaced before the refresh starts', async () => {+ root = mkdtempSync(join(tmpdir(), 'profile-registry-'))+ vi.stubEnv('ADAPTER_DATA_DIR', root)+ vi.stubEnv('CLAUDE_PROJECTS_DIR', root)+ vi.resetModules()+ const { registry } = await import('./registry.js')+ registry.load()+ const input = { engine: 'hermes' as const, sessionId: '20261009_060001_abc123', tmuxPane: '%82', cwd: root,+ hermesHome: join(root, 'first') }+ registry.openProcessAgent({ ...input, processIdentity: { pid: 7002, executable: 'hermes', startMarker: 'fixture' } })+ const old = registry.register(input)!.entry+ const config = vi.fn(async () => true)+ const reader = { engine: 'hermes', target: () => null, config,+ pane: ({ state, refreshConfig }: InlineRuntimeContext) => { state.model = 'observed'; refreshConfig() } }+ const module = { createRuntimeProfileReader: () => reader }+ vi.mocked(engineNow).mockReturnValue(module as never)+ vi.mocked(loadEngine).mockResolvedValue(module as never)+ const profiles = new RuntimeProfileState(() => undefined, id => registry.resolve(id))+ profiles.ingestPane(old, 'old pane', true)+ const current = registry.register({ ...input, hermesHome: join(root, 'second') })!.entry+ expect(current).not.toBe(old)+ await Promise.resolve()+ expect(config).not.toHaveBeenCalled()+ expect(loadEngine).not.toHaveBeenCalled()+ profiles.forget(old.sessionId)+})diff --git a/cli/src/lib/runtimeProfileState.golden.spec.ts b/cli/src/lib/runtimeProfileState.golden.spec.tsnew file mode 100644index 000000000..01f0c71ec--- /dev/null+++ b/cli/src/lib/runtimeProfileState.golden.spec.ts@@ -0,0 +1,124 @@+/** Former manager answers, recorded before item 6 removes the legacy composition. */+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'+import { join } from 'node:path'+import { afterEach, describe, expect, it, vi } from 'vitest'+import type { RegisteredSession } from './registry.js'+import type { RuntimeProfile } from '../engines/facets/runtime.js'++const GOLDEN = new URL('./__fixtures__/runtime-profile-state.golden.json', import.meta.url)+const RECORD = process.env.RECORD_RUNTIME_STATE_GOLDEN === '1'+const NOW = Date.parse('2026-10-09T00:00:00Z')+const platforms = ['linux', 'darwin'] as const+const engines = ['claude', 'codex', 'cursor', 'opencode', 'kilo', 'devin', 'hermes', 'amp', 'agy', 'grok', 'copilot', 'commandcode', 'muse', 'pi'] as const+const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform')!+const recorded: Record<string, unknown> = {}+let root = ''++afterEach(() => {+ vi.useRealTimers()+ vi.unstubAllEnvs()+ Object.defineProperty(process, 'platform', originalPlatform)+ if (root) rmSync(root, { recursive: true, force: true })+})++describe('former runtime manager state and control golden', () => {+ for (const platform of platforms) it(platform, async () => {+ Object.defineProperty(process, 'platform', { ...originalPlatform, value: platform })+ root = mkdtempSync('/tmp/runtime-state-golden-')+ const home = join(root, 'home')+ mkdirSync(home)+ for (const [key, value] of Object.entries({ HOME: home, ADAPTER_DATA_DIR: join(root, 'data'),+ CLAUDE_CONFIG_DIR: join(home, '.claude'), CODEX_HOME: join(home, '.codex'),+ HERMES_HOME: join(home, '.hermes'), COMMANDCODE_HOME: join(home, '.commandcode'),+ CURSOR_HOME: join(home, '.cursor'), XDG_CONFIG_HOME: join(home, '.config'),+ XDG_DATA_HOME: join(home, '.local', 'share'), PATH: '/nonexistent-runtime-golden-bin', TZ: 'UTC',+ })) vi.stubEnv(key, value)+ vi.resetModules()+ const { RuntimeProfileManager } = await import('./runtimeProfile.js')+ const { RuntimeProfileState } = await import('./runtimeProfileState.js')+ const { loadEngine } = await import('../engines/inProcess.js')+ const { encodeRuntimeProfile } = await import('../engines/kit/runtime.js')+ for (const engine of engines) if (engine !== 'claude' && engine !== 'codex') await loadEngine(engine)+ vi.useFakeTimers({ toFake: ['Date', 'setTimeout', 'clearTimeout'] })+ vi.setSystemTime(NOW)+ const value = (engine: typeof engines[number], id = `session-${engine}`): RegisteredSession => ({+ agentId: id, sessionId: id, engine, model: 'registered-model', cliVersion: '1.0.0',+ cwd: '/work/runtime-golden', transcriptPath: null,+ } as RegisteredSession)+ const answers: Record<string, unknown> = {}+ for (const engine of engines) {+ vi.setSystemTime(NOW)+ const m = new RuntimeProfileManager(), s = value(engine)+ const changes: string[] = []+ m.onChanged = id => changes.push(id)+ const snapshot = () => ({ state: m.getState(s.sessionId), selected: m.selectedModel(s), changes: [...changes] })+ const states: Record<string, unknown> = { fresh: snapshot() }+ m.hydrate(s, ['invalid json', 'null', '[]'])+ states.hydrated = snapshot()+ const target: RuntimeProfile = { id: encodeRuntimeProfile({ sessionId: s.sessionId, engine, model: 'chosen-model', effort: 'high' }),+ sessionId: s.sessionId, engine, model: 'chosen-model', effort: 'high' }+ states.begin = m.beginControl(s, target)+ states.duplicate = m.beginControl(s, target)+ const modelWait = m.waitForModel(s.sessionId, 100)+ const profileWait = m.waitForProfile(s.sessionId, 100)+ m.confirmEffort(s.sessionId, 'invalid-effort')+ states.invalidEffort = snapshot()+ m.confirmControlProfile(target)+ states.confirmed = { ...snapshot(), modelWait: await modelWait, profileWait: await profileWait }+ m.finishControl(s)+ await vi.advanceTimersByTimeAsync(120)+ states.finished = snapshot()+ states.supported = m.supportsControl(s)+ states.gatewaySupported = m.supportsControl({ ...s, gateway: {} } as RegisteredSession)+ const other = { ...target, id: `${target.id}-other`, model: 'other-model', effort: 'low' }+ m.beginControl(s, other)+ const cancelled = m.waitForProfile(s.sessionId, 100)+ m.cancelControl(s.sessionId)+ await vi.advanceTimersByTimeAsync(120)+ states.cancelled = { ...snapshot(), waited: await cancelled }+ m.beginControl(s, other)+ const forgotten = m.waitForModel(s.sessionId, 100)+ m.forget(s.sessionId)+ await vi.advanceTimersByTimeAsync(120)+ states.forgotten = { ...snapshot(), waited: await forgotten }+ states.targets = [m.cursorTarget(s.sessionId, target.id), m.devinTarget(s.sessionId, target.id),+ m.hermesTarget(s.sessionId, target.id), m.commandcodeTarget(s.sessionId, target.id)]+ answers[engine] = states+ }+ // The supervised core has no pilot reader. It still owns confirmation, waiters and cleanup.+ const generic = new RuntimeProfileState(() => undefined), g = value('codex', 'generic')+ const target: RuntimeProfile = { id: 'runtime-v1:generic:codex:chosen@high', sessionId: 'generic', engine: 'codex', model: 'chosen', effort: 'high' }+ generic.beginControl(g, target)+ generic.confirmEffort(g.sessionId, 'high')+ const timedOut = generic.waitForModel(g.sessionId, 15)+ await vi.advanceTimersByTimeAsync(15)+ answers.generic = { state: generic.getState(g.sessionId), selected: generic.selectedModel(g), timedOut: await timedOut }+ generic.forget(g.sessionId)+ const blank = value('opencode', '')+ generic.ingestPane(blank, ' ┃ Build · Big Pickle OpenCode Zen', true)+ generic.hydrate(blank, ['{}'])+ answers.unbound = { state: generic.getState(''), own: generic.selectedModel(blank), other: generic.selectedModel(value('claude', '')) }++ const staged = new RuntimeProfileManager(), c = value('codex', 'staged')+ const line = JSON.stringify({ type: 'turn_context', payload: { model: 'gpt-6.1-sol', reasoning_effort: 'high' } })+ staged.hydrate(c, [line])+ const before = staged.getState(c.sessionId)+ const pending = staged.beginHydrate(c)+ pending.ingest('invalid')+ pending.ingest('null')+ pending.ingest(JSON.stringify({ type: 'turn_context', payload: { model: 'gpt-6-luna', reasoning_effort: 'low' } }))+ const during = staged.getState(c.sessionId)+ pending.commit()+ const committed = staged.getState(c.sessionId)+ const emitted: string[] = []+ staged.onChanged = id => emitted.push(id)+ await staged.withoutChangeEvents(async () => { staged.ingest(c, line) })+ await vi.advanceTimersByTimeAsync(120)+ answers.staged = { before, during, committed, afterSuppressed: staged.getState(c.sessionId), fields: staged.transcriptFields(c, line), emitted }+ staged.forget(c.sessionId)++ recorded[platform] = answers+ if (RECORD) writeFileSync(GOLDEN, `${JSON.stringify(recorded, null, 2)}\n`)+ else expect(answers).toEqual(JSON.parse(readFileSync(GOLDEN, 'utf8'))[platform])+ })+})diff --git a/cli/src/lib/runtimeProfileState.spec.ts b/cli/src/lib/runtimeProfileState.spec.tsnew file mode 100644index 000000000..43adfb540--- /dev/null+++ b/cli/src/lib/runtimeProfileState.spec.ts@@ -0,0 +1,390 @@+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'+import { env } from '../config/env.js'+import { runtime as claudeRuntime } from '../engines/claude/runtimeProfile.js'+import type { RegisteredSession } from './registry.js'+import { RuntimeProfileState } from './runtimeProfileState.js'+import { RuntimeProfileManager } from './runtimeProfile.js'+import { parseRuntimeProfile } from './runtimeProfileWire.js'+import { engineNow, loadEngine, OTHER_ENGINES } from '../engines/inProcess.js'+import type { InlineRuntimeContext } from '../engines/facets/inlineRuntime.js'++// A test may say an engine's code could not be loaded.+vi.mock('../engines/inProcess.js', async (real) => {+ const actual = await real<typeof import('../engines/inProcess.js')>()+ return { ...actual, engineNow: vi.fn(actual.engineNow), loadEngine: vi.fn(actual.loadEngine) }+})++const fixture = (name: string): string => readFileSync(join(import.meta.dirname, '__fixtures__', name), 'utf8')+const session = (engine: RegisteredSession['engine']): RegisteredSession => ({+ agentId: 'agent', sessionId: 'conversation', engine, model: 'registered-model', cliVersion: '1.0.0',+ cwd: '/tmp', transcriptPath: '/tmp/profile-recording.jsonl',+} as RegisteredSession)+afterEach(() => { vi.restoreAllMocks(); vi.useRealTimers(); vi.mocked(engineNow).mockReset(); vi.mocked(loadEngine).mockReset() })+// The other engines' profile readers load as one of their sessions enters the registry (engines/inProcess.ts+// `preloadEngine`): before any pane of theirs is read, as here.+beforeAll(async () => { for (const engine of OTHER_ENGINES) await loadEngine(engine) })++describe('another engine whose code could not be loaded', () => {+ it('contains a missing or throwing reader factory while core confirmation and cleanup still work', async () => {+ vi.spyOn(console, 'warn').mockImplementation(() => {})+ for (const createRuntimeProfileReader of [undefined, () => { throw new Error('broken facet') }]) {+ vi.mocked(engineNow).mockReturnValue({ createRuntimeProfileReader } as never)+ vi.mocked(loadEngine).mockResolvedValue({ createRuntimeProfileReader } as never)+ const manager = new RuntimeProfileState(() => undefined), agent = session('cursor')+ manager.hydrate(agent, [])+ expect(manager.ingestPane(agent, 'Auto · 10%', true)).toBe(false)+ expect(manager.ingestPane(agent, 'Auto · 10%', true)).toBe(false)+ expect(await manager.ingestConfig(agent)).toBe(false)+ manager.confirmEffort(agent.sessionId, 'high')+ expect(manager.getState(agent.sessionId).effort).toBe('high')+ manager.forget(agent.sessionId)+ expect(manager.getState(agent.sessionId).model).toBeNull()+ }+ expect(console.warn).toHaveBeenCalledTimes(2)+ vi.mocked(engineNow).mockReset()+ vi.mocked(loadEngine).mockReset()+ })++ it('reads nothing of its panes, config files or catalog, and leaves its chips as they were', async () => {+ const manager = new RuntimeProfileState(() => undefined)+ vi.mocked(engineNow).mockReturnValue(null)+ vi.mocked(loadEngine).mockResolvedValue(null as never)+ try {+ for (const engine of ['cursor', 'devin', 'hermes', 'commandcode', 'opencode', 'kilo', 'pi', 'grok', 'agy'] as const) {+ const agent = { ...session(engine), sessionId: `${engine}-s` }+ expect(manager.ingestPane(agent, 'any pane', true), engine).toBe(false)+ expect(manager.getState(agent.sessionId), engine).toMatchObject({ model: null, effort: null })+ }+ for (const engine of ['hermes', 'muse', 'amp'] as const) {+ expect(await manager.ingestConfig({ ...session(engine), sessionId: `${engine}-c` }, true), engine).toBe(false)+ }+ expect(await manager.opencodeCatalog()).toEqual([])+ expect(await manager.kiloCatalog()).toEqual([])+ } finally {+ vi.mocked(engineNow).mockReset()+ vi.mocked(loadEngine).mockReset()+ }+ })+})++describe('late optional profile observations', () => {+ it.each(['explicit read', 'confirmation'] as const)('does not let a queued refresh supersede a newer %s', async newer => {+ const config = vi.fn(async ({ state }: InlineRuntimeContext) => { state.effort = 'low'; return true })+ const module = { createRuntimeProfileReader: () => ({ engine: 'commandcode', target: () => null, config,+ pane: ({ state, refreshConfig }: InlineRuntimeContext) => { state.model = 'model'; refreshConfig() },+ }) }+ vi.mocked(engineNow).mockReturnValue(module as never)+ vi.mocked(loadEngine).mockResolvedValue(module as never)+ const manager = new RuntimeProfileState(() => undefined), agent = session('commandcode')+ manager.ingestPane(agent, 'model', true)+ if (newer === 'explicit read') {+ await manager.ingestConfig(agent, true)+ expect(config).toHaveBeenCalledOnce()+ expect(manager.getState(agent.sessionId).effort).toBe('low')+ } else {+ manager.confirmEffort(agent.sessionId, 'high')+ await Promise.resolve()+ expect(config).not.toHaveBeenCalled()+ expect(manager.getState(agent.sessionId).effort).toBe('high')+ }+ manager.forget(agent.sessionId)+ })++ it.each(['cancel', 'finish'] as const)('does not revive a forgotten state when late control cleanup calls %s', async end => {+ const cleanup = vi.fn(() => { throw new Error('optional cleanup failed') })+ vi.spyOn(console, 'warn').mockImplementation(() => {})+ vi.mocked(engineNow).mockReturnValue({ createRuntimeProfileReader: () => ({+ engine: 'cursor', pane: () => false, forget: cleanup,+ }) } as never)+ const manager = new RuntimeProfileState(() => undefined), agent = session('cursor')+ manager.ingestPane(agent, '')+ manager.forget(agent.sessionId)+ if (end === 'cancel') manager.cancelControl(agent.sessionId)+ else manager.finishControl(agent)+ await Promise.resolve()+ expect(cleanup).toHaveBeenCalledExactlyOnceWith(agent.sessionId)+ expect(console.warn).toHaveBeenCalledOnce()+ manager.forget(agent.sessionId)+ })++ it('keeps newer control flags even when neither a value nor the control object changes', async () => {+ let finish!: (effort: string) => void+ const manager = new RuntimeProfileState(() => ({ ...claudeRuntime,+ transcript: ({ control }, raw) => { if (raw.confirm && control) control.modelConfirmed = true },+ configuredEffort: () => new Promise<string>(resolve => { finish = resolve }),+ })), agent = session('claude')+ manager.hydrate(agent, [])+ manager.confirmEffort(agent.sessionId, 'high')+ manager.beginControl(agent, { id: 'target', sessionId: agent.agentId, engine: agent.engine, model: 'new-model', effort: 'high' })+ const pending = manager.ingestConfig(agent)+ manager.ingest(agent, '{"confirm":true}')+ finish('low')+ await pending+ expect(await manager.waitForProfile(agent.sessionId, 10)).toBe(true)+ expect(manager.getState(agent.sessionId).effort).toBe('high')+ manager.forget(agent.sessionId)+ })++ it.each(['cancel', 'finish'] as const)('invalidates config and hydration across a complete control %s cycle', async end => {+ let finish!: (effort: string) => void+ const manager = new RuntimeProfileState(() => ({ ...claudeRuntime,+ configuredEffort: () => new Promise<string>(resolve => { finish = resolve }),+ })), agent = session('claude')+ manager.hydrate(agent, [])+ manager.confirmEffort(agent.sessionId, 'high')+ const before = manager.getState(agent.sessionId)+ const pending = manager.ingestConfig(agent), stage = manager.beginHydrate(agent)+ stage.ingest(JSON.stringify({ type: 'assistant', message: { model: 'staged-model' } }))+ expect(manager.beginControl(agent, { id: 'target', sessionId: agent.agentId, engine: agent.engine,+ model: 'new-model', effort: 'high' })).toBe(true)+ if (end === 'cancel') manager.cancelControl(agent.sessionId)+ else manager.finishControl(agent)+ finish('low')+ expect(await pending).toBe(false)+ const install = vi.fn(() => true)+ expect(stage.commitWith!(install)).toBe(false)+ expect(install).not.toHaveBeenCalled()+ expect(manager.getState(agent.sessionId)).toEqual(before)+ manager.forget(agent.sessionId)+ })++ it('treats a repeated confirmation as newer authority than a pending config or transcript stage', async () => {+ let finish!: (effort: string) => void+ const manager = new RuntimeProfileState(() => ({ ...claudeRuntime,+ configuredEffort: () => new Promise<string>(resolve => { finish = resolve }),+ })), agent = session('claude')+ manager.hydrate(agent, [])+ manager.confirmEffort(agent.sessionId, 'high')+ const pending = manager.ingestConfig(agent)+ manager.confirmEffort(agent.sessionId, 'high')+ finish('low')+ expect(await pending).toBe(false)+ expect(manager.getState(agent.sessionId).effort).toBe('high')+ const stage = manager.beginHydrate(agent)+ const before = manager.getState(agent.sessionId)+ manager.confirmEffort(agent.sessionId, 'high')+ stage.commit()+ expect(manager.getState(agent.sessionId)).toEqual(before)+ })++ it('keeps a same-value pane observation ahead of a pending config answer', async () => {+ let finish!: (effort: string) => void+ const manager = new RuntimeProfileState(() => ({ ...claudeRuntime,+ pane: ({ state }) => { state.effort = 'high' },+ configuredEffort: () => new Promise<string>(resolve => { finish = resolve }),+ })), agent = session('claude')+ manager.hydrate(agent, [])+ manager.confirmEffort(agent.sessionId, 'high')+ const pending = manager.ingestConfig(agent)+ manager.ingestPane(agent, 'same evidence', true)+ finish('low')+ expect(await pending).toBe(false)+ expect(manager.getState(agent.sessionId).effort).toBe('high')+ })++ it('finishes core waiters and every optional cleanup despite a throwing reader', async () => {+ const later = vi.fn()+ vi.spyOn(console, 'warn').mockImplementation(() => {})+ vi.mocked(engineNow).mockImplementation(engine => ({ createRuntimeProfileReader: () => ({+ engine, target: () => null, forget: engine === 'cursor' ? () => { throw new Error('broken cleanup') } : later,+ }) }) as never)+ const manager = new RuntimeProfileState(() => undefined), agent = session('cursor')+ manager.ingestPane(agent, '', true)+ manager.ingestPane(session('grok'), '', true)+ manager.beginControl(agent, { id: 'target', sessionId: agent.sessionId, engine: agent.engine, model: 'wanted', effort: 'high' })+ const waiting = manager.waitForModel(agent.sessionId, 100)+ expect(() => manager.forget(agent.sessionId)).not.toThrow()+ expect(await waiting).toBe(false)+ expect(later).toHaveBeenCalledWith(agent.sessionId)+ expect(manager.getState(agent.sessionId).model).toBeNull()+ })++ it('cannot commit a staged transcript after forget or newer live evidence', () => {+ for (const forget of [true, false]) {+ const manager = new RuntimeProfileManager(), agent = session('codex')+ const line = (model: string) => JSON.stringify({ type: 'turn_context', payload: { model, reasoning_effort: 'high' } })+ manager.hydrate(agent, [line('first')])+ const stage = manager.beginHydrate(agent)+ stage.ingest(line('old-history'))+ if (forget) manager.forget(agent.sessionId)+ else manager.ingest(agent, line('latest'), true)+ const before = manager.getState(agent.sessionId)+ stage.commit()+ expect(manager.getState(agent.sessionId)).toEqual(before)+ }+ })++ it('keeps the session version and control confirmation private until a stage commits', async () => {+ const manager = new RuntimeProfileState(() => ({ ...claudeRuntime,+ transcript(context) {+ context.session.cliVersion = 'staged-version'+ context.state.model = 'staged-model'+ if (context.control) context.control.modelConfirmed = true+ },+ })), agent = session('claude')+ const target = { id: 'runtime-v1:conversation:claude:staged-model@high', sessionId: agent.sessionId,+ engine: agent.engine, model: 'staged-model', effort: 'high' }+ manager.beginControl(agent, target)+ const stage = manager.beginHydrate(agent)+ stage.ingest('{}')+ expect(agent.cliVersion).toBe('1.0.0')+ vi.useFakeTimers()+ const waiting = manager.waitForModel(agent.sessionId, 15)+ await vi.advanceTimersByTimeAsync(15)+ expect(await waiting).toBe(false)+ stage.commit()+ expect(agent.cliVersion).toBe('staged-version')+ expect(await manager.waitForModel(agent.sessionId, 15)).toBe(true)+ manager.forget(agent.sessionId)+ })++ it('cannot recreate state when its module finishes loading after forget', async () => {+ const manager = new RuntimeProfileState(() => undefined), agent = session('hermes')+ let finish!: (value: Awaited<ReturnType<typeof loadEngine<'hermes'>>>) => void+ const module = await loadEngine('hermes')+ const read = vi.fn(async ({ state }: InlineRuntimeContext) => {+ state.model = 'late-model'; state.effort = 'high'; return true+ })+ vi.mocked(loadEngine).mockReturnValueOnce(new Promise(resolve => { finish = resolve }) as never)+ const pending = manager.ingestConfig(agent)+ manager.forget(agent.sessionId)+ finish({ ...module!, createRuntimeProfileReader: () => ({ engine: 'hermes', target: () => null, config: read }) })+ expect(await pending).toBe(false)+ expect(read).not.toHaveBeenCalled()+ expect(manager.getState(agent.sessionId)).toMatchObject({ model: null, effort: null })+ })++ it('does not replace a confirmed effort with a config read started earlier', async () => {+ let finish!: (effort: string) => void+ const configuredEffort = vi.fn(() => new Promise<string>(resolve => { finish = resolve }))+ const manager = new RuntimeProfileState(() => ({ ...claudeRuntime, configuredEffort })), agent = session('claude')+ manager.hydrate(agent, [])+ const pending = manager.ingestConfig(agent)+ manager.confirmEffort(agent.sessionId, 'high')+ finish('low')+ expect(await pending).toBe(false)+ expect(manager.getState(agent.sessionId).effort).toBe('high')+ })++ it('does not notify for a read completed after the session was forgotten', async () => {+ vi.useFakeTimers()+ let finish!: (effort: string) => void+ const configuredEffort = () => new Promise<string>(resolve => { finish = resolve })+ const manager = new RuntimeProfileState(() => ({ ...claudeRuntime, configuredEffort })), agent = session('claude')+ manager.hydrate(agent, [])+ manager.confirmEffort(agent.sessionId, 'high')+ const changed = vi.fn(); manager.onChanged = changed+ const pending = manager.ingestConfig(agent)+ manager.forget(agent.sessionId)+ finish('low')+ expect(await pending).toBe(false)+ await vi.advanceTimersByTimeAsync(120)+ expect(changed).not.toHaveBeenCalled()+ })++ it('discards a config answer for a different native home on the same mutable row', async () => {+ const module = await loadEngine('hermes')+ let finish!: () => void+ const config = vi.fn(async ({ state }: InlineRuntimeContext) => {+ await new Promise<void>(resolve => { finish = resolve })+ state.model = 'old-home-model'; state.effort = 'high'; return true+ })+ vi.mocked(loadEngine).mockResolvedValueOnce({ ...module!, createRuntimeProfileReader: () => ({ engine: 'hermes', target: () => null, config }) })+ const manager = new RuntimeProfileState(() => undefined), agent = { ...session('hermes'), hermesHome: '/tmp/first-profile' }+ const pending = manager.ingestConfig(agent)+ await vi.waitFor(() => expect(config).toHaveBeenCalledOnce())+ agent.hermesHome = '/tmp/replacement-profile'+ finish()+ expect(await pending).toBe(false)+ expect(manager.getState(agent.sessionId)).toMatchObject({ model: null, effort: null })+ })+})++describe('runtime profiles without the pilot implementations', () => {+ it.each([+ ['amp', 'amp-session.jsonl'], ['amp', 'amp-session-queued.jsonl'],+ ['muse', 'muse-session.jsonl'], ['copilot', 'copilot-session.jsonl'], ['agy', 'agy-session.jsonl'],+ ] as const)('preserves the registry seed when replaying the recorded %s transcript %s', (engine, file) => {+ const lines = fixture(file).trim().split('\n')+ // Audit the removed fallback against recordings, not formats inferred from Claude. None of these+ // native records contributed profile metadata through that reader; their own config/panes do.+ expect(lines.map(line => claudeRuntime.decode(JSON.parse(line))).filter(Boolean)).toEqual([])+ const manager = new RuntimeProfileState(() => undefined)+ const agent = session(engine)+ manager.hydrate(agent, lines)+ expect(manager.getState(agent.sessionId)).toEqual({+ model: 'registered-model', effort: null, mode: 'unknown', cliVersion: '1.0.0', observedAt: null,+ })+ })++ it('keeps Pi metadata in its native footer and never treats answer text as Claude commands', () => {+ const manager = new RuntimeProfileState(() => undefined)+ const agent = session('pi')+ // These metadata records are copied from the Pi 0.82.1 recording in pi/normalizer.spec.ts.+ const lines = [+ '{"type":"session","version":3,"id":"019fa2a5-a26d-700c-bf8c-97af19ae3d5f","timestamp":"2026-07-27T08:16:31.854Z","cwd":"/tmp/pi-probe"}',+ '{"type":"model_change","id":"45215278","parentId":null,"model":"minimax/minimax-m3"}',+ '{"type":"thinking_level_change","id":"1da16955","parentId":"45215278","level":"medium"}',+ ]+ expect(lines.map(line => claudeRuntime.decode(JSON.parse(line)))).toEqual([null, null, null])+ manager.hydrate(agent, lines)+ manager.ingestPane(agent, '0.0%/500k (auto) minimax/minimax-m3 • high', true)+ const before = manager.getState(agent.sessionId)+ expect(parseRuntimeProfile(manager.selectedModel(agent))).toMatchObject({+ engine: 'pi', model: 'minimax/minimax-m3', effort: 'high',+ })+ // An answer explaining another CLI uses ordinary text in Pi's recorded message envelope.+ expect(manager.ingest(agent, JSON.stringify({ type: 'message', message: {+ role: 'assistant', content: [{ type: 'text', text: 'Set model to Opus 5\nSet effort level to low' }],+ } }), true)).toBe(false)+ expect(manager.getState(agent.sessionId)).toEqual(before)+ })++ it.each(['amp', 'muse', 'copilot', 'terminal'] as const)('does not interpret Claude UI quoted in a %s pane', engine => {+ // Apply the same boundary in explicit inline mode. Supplying a Claude facet must not make it a+ // fallback for engines whose profile source is their own config or registration.+ const manager = new RuntimeProfileManager(), agent = session(engine)+ manager.hydrate(agent, [])+ const before = manager.getState(agent.sessionId)+ expect(manager.ingestPane(agent, 'Claude Code v2.1.212\nOpus 5 with high effort · Claude Max\nplan mode on', true)).toBe(false)+ expect(manager.getState(agent.sessionId)).toEqual(before)+ })++ it('retains the native Muse and Amp config sources without loading either pilot facet', async () => {+ const root = mkdtempSync(join(tmpdir(), 'legacy-profile-'))+ const defaults = { muse: env.MUSE_CONFIG_DIR, amp: env.AMP_STATE_DIR }+ try {+ env.MUSE_CONFIG_DIR = join(root, 'muse'); env.AMP_STATE_DIR = join(root, 'amp')+ mkdirSync(env.MUSE_CONFIG_DIR); mkdirSync(env.AMP_STATE_DIR)+ // Verified config shapes documented in each engine's runtimeProfile.ts.+ writeFileSync(join(env.MUSE_CONFIG_DIR, 'settings.json'), JSON.stringify({+ schema_version: 1, provider: 'meta', model: 'muse-spark-1.2-contributor',+ }))+ writeFileSync(join(env.AMP_STATE_DIR, 'session.json'), JSON.stringify({ agentMode: 'medium' }))+ const manager = new RuntimeProfileState(() => undefined)+ for (const [engine, model, effort] of [+ ['muse', 'muse-spark-1.2-contributor', 'high'], ['amp', 'medium', 'auto'],+ ] as const) {+ const agent = { ...session(engine), sessionId: engine }+ await manager.ingestConfig(agent, true)+ expect(parseRuntimeProfile(manager.selectedModel(agent))).toMatchObject({ engine, model, effort })+ }+ } finally {+ env.MUSE_CONFIG_DIR = defaults.muse; env.AMP_STATE_DIR = defaults.amp+ rmSync(root, { recursive: true, force: true })+ }+ })++ it('still reads the captured agy footer and the registry-supplied CLI version', () => {+ const manager = new RuntimeProfileState(() => undefined), agent = session('agy')+ manager.hydrate(agent, [])+ manager.ingestPane(agent, fixture('permission-agy.txt'), true)+ expect(parseRuntimeProfile(manager.selectedModel(agent))).toMatchObject({+ engine: 'agy', model: 'gemini-3.7-flash-high', effort: 'high',+ })+ expect(manager.getState(agent.sessionId).cliVersion).toBe('1.0.0')+ })+})diff --git a/cli/src/lib/runtimeProfileState.ts b/cli/src/lib/runtimeProfileState.tsnew file mode 100644index 000000000..40330f5d4--- /dev/null+++ b/cli/src/lib/runtimeProfileState.ts@@ -0,0 +1,463 @@+/** Eager state/control owner; native interpretation is supplied by engine facets. */+import { parseRuntimeProfile } from './runtimeProfileWire.js'+export { parseRuntimeProfile } from './runtimeProfileWire.js'+import type { RegisteredSession } from './registry.js'+import type { RuntimeFor, RuntimeProfile, RuntimeModelOption, RuntimeState, RuntimeField, RuntimeControl, RuntimeCatalogModel } from '../engines/facets/runtime.js'+import type { InlineRuntimeContext, InlineRuntimeReader } from '../engines/facets/inlineRuntime.js'+export type { RuntimeProfile, RuntimeModelOption, RuntimeState, RuntimeField } from '../engines/facets/runtime.js'+import { encodeRuntimeProfile, record, stripAnsi, transcriptFields, RUNTIME_EFFORTS } from '../engines/kit/runtime.js'+export { encodeRuntimeProfile, runtimeModelLabel } from '../engines/kit/runtime.js'+import { engineNow, isOtherEngine, loadEngine } from '../engines/inProcess.js'++const blankState = (): RuntimeState => ({ model: null, effort: null, mode: 'unknown', cliVersion: null, observedAt: null })++/** Where a session's runtime state starts before its transcript is read. */+function freshState(session: RegisteredSession): RuntimeState {+ return {+ ...blankState(),+ // Registries written by older builds can hold a non-string model; treat it as unknown instead of+ // letting it reach claudeAliasForModel and abort startup.+ model: typeof session.model === 'string' ? session.model : null,+ cliVersion: session.cliVersion,+ }+}++interface StateWaiter {+ check: () => boolean+ resolve: (matched: boolean) => void+ timer: NodeJS.Timeout+}++const EFFORTS = RUNTIME_EFFORTS+const CHANGE_DEBOUNCE_MS = 120+const readIdentity = (session: RegisteredSession): string => JSON.stringify([session.agentId, session.sessionId,+ session.engine, session.cwd, session.transcriptPath, session.codexHome, session.hermesHome,+ session.model, session.cliVersion, session.boundAt, session.tmuxPane, session.primaryRuntimeKey, session.runtimes])+const copyControl = (control: RuntimeControl | undefined): RuntimeControl | undefined => control && {+ ...control, target: { ...control.target },+}++export class RuntimeProfileState {+ constructor(private readonly runtimeFor: RuntimeFor,+ private readonly resolve?: (agentId: string) => RegisteredSession | undefined) {}+ private readonly states = new Map<string, RuntimeState>()+ private readonly controls = new Map<string, RuntimeControl>()+ private readonly waiters = new Map<string, Set<StateWaiter>>()+ private readonly changeTimers = new Map<string, NodeJS.Timeout>()+ private readonly readers = new Map<string, InlineRuntimeReader>()+ private readonly failedReaders = new Set<string>()+ private readonly versions = new WeakMap<RuntimeState, number>()+ private readonly configReads = new WeakMap<RuntimeState, object>()+ private suppressNotifications = 0+ onChanged: ((sessionId: string) => void) | null = null++ private version(state: RuntimeState): number { return this.versions.get(state) ?? 0 }+ private accepted(state: RuntimeState): void { this.versions.set(state, this.version(state) + 1) }+ private authoritative(state: RuntimeState): void {+ this.accepted(state)+ // Core confirmation/control revokes queued reads as well as reads already in flight.+ this.configReads.set(state, {})+ }+ private currentSession(session: RegisteredSession, identity = readIdentity(session)): RegisteredSession | undefined {+ const current = this.resolve ? this.resolve(session.agentId) : session+ return current && readIdentity(current) === identity && readIdentity(session) === identity ? current : undefined+ }++ private observe(context: InlineRuntimeContext): InlineRuntimeContext {+ // A repeated authoritative value is still newer evidence. Track writes, not value differences;+ // ignored transcript records must not starve a pending config read during a long answer.+ const track = <T extends object>(value: T): T => new Proxy(value, { set: (target, key, next) => {+ this.accepted(context.state)+ return Reflect.set(target, key, next)+ } })+ return { ...context, state: track(context.state), control: context.control && track(context.control) }+ }++ private keep(engine: string, module: { createRuntimeProfileReader?: () => InlineRuntimeReader }): InlineRuntimeReader | null {+ const existing = this.readers.get(engine)+ if (existing) return existing+ if (this.failedReaders.has(engine)) return null+ try {+ const reader = module.createRuntimeProfileReader?.()+ if (!reader || reader.engine !== engine) throw new Error('runtime reader is missing or belongs to another engine')+ this.readers.set(engine, reader)+ return reader+ } catch (error) {+ this.failedReaders.add(engine)+ console.warn(`[runtime-profile] ${engine} reader unavailable:`, error instanceof Error ? error.message : String(error))+ return null+ }+ }++ private readerNow(engine: string): InlineRuntimeReader | null {+ if (!isOtherEngine(engine)) return null+ const module = engineNow(engine, 'its profile was read')+ if (!module) return null+ return this.keep(engine, module)+ }++ private async reader(engine: string): Promise<InlineRuntimeReader | null> {+ if (!isOtherEngine(engine)) return null+ const module = await loadEngine(engine)+ if (!module) return null+ return this.keep(engine, module)+ }++ private context(session: RegisteredSession, silent: boolean): InlineRuntimeContext {+ const state = this.state(session.sessionId)+ const identity = readIdentity(session)+ return { session, state, control: this.controls.get(session.sessionId),+ refreshConfig: (override) => {+ const read = this.configReads.get(state)+ // Finish accepting the synchronous observation before starting its dependent config read.+ queueMicrotask(() => {+ if (this.states.get(session.sessionId) === state && this.currentSession(session, identity)+ && this.configReads.get(state) === read) {+ void this.ingestConfig(session, override ?? silent).catch(() => undefined)+ }+ })+ } }+ }++ private observed(session: RegisteredSession, before: string | null, silent: boolean): boolean {+ const after = this.selectedModel(session)+ this.wake(session.sessionId)+ if (!silent && this.suppressNotifications === 0 && before !== after && !this.controls.has(session.sessionId)) this.scheduleChanged(session.sessionId)+ return before !== after+ }++ ingest(session: RegisteredSession, rawLine: string, silent = false): boolean {+ const current = this.currentSession(session)+ if (!current) return false+ session = current+ let raw: Record<string, unknown> | null+ try { raw = record(JSON.parse(rawLine)) } catch { return false }+ if (!raw) return false+ const before = this.selectedModel(session)+ const runtime = this.runtimeFor(session.engine)+ const context = this.observe(this.context(session, silent))+ if (runtime) runtime.transcript(context, raw)+ else this.readerNow(session.engine)?.transcript?.(context, raw)+ return this.observed(session, before, silent)+ }++ ingestPane(session: RegisteredSession, paneText: string, silent = false): boolean {+ const current = this.currentSession(session)+ if (!current) return false+ session = current+ const before = this.selectedModel(session)+ const runtime = this.runtimeFor(session.engine)+ const context = this.observe(this.context(session, silent))+ const text = stripAnsi(paneText)+ if (runtime) runtime.pane(context, text)+ else if (this.readerNow(session.engine)?.pane?.(context, text) === false) return false+ return this.observed(session, before, silent)+ }++ async ingestConfig(session: RegisteredSession, silent = false): Promise<boolean> {+ if (this.unbound(session.sessionId) || !this.currentSession(session)) return false+ const state = this.state(session.sessionId), version = this.version(state)+ const identity = readIdentity(session), token = {}+ const control = this.controls.get(session.sessionId)+ this.configReads.set(state, token)+ const current = () => this.states.get(session.sessionId) === state && this.version(state) === version+ && this.configReads.get(state) === token && !!this.currentSession(session, identity)+ && this.controls.get(session.sessionId) === control+ const runtime = this.runtimeFor(session.engine)+ const reader = runtime ? null : await this.reader(session.engine)+ if (!current() || (!runtime?.configuredEffort && !reader?.config)) return false+ const before = this.selectedModel(session)+ const context = { ...this.context(session, silent), session: { ...session }, state: { ...state }, control: copyControl(control) }+ if (runtime?.configuredEffort) {+ context.state.effort = await runtime.configuredEffort(context.session)+ context.state.observedAt = Date.now()+ } else if (!await reader!.config!(context)) return false+ // An optional reader cannot publish into a forgotten/rebound row or replace newer evidence.+ if (!current()) return false+ Object.assign(state, context.state)+ if (control) Object.assign(control, context.control)+ this.accepted(state)+ return this.observed(session, before, silent)+ }++ supportsControl(session: RegisteredSession): boolean {+ return !session.gateway && (this.runtimeFor(session.engine)?.supportsControl(session) ?? false)+ }++ effortAllowed(session: RegisteredSession, model: string, effort: string, listed: readonly string[] | null): boolean {+ return this.runtimeFor(session.engine)?.effortAllowed?.(model, effort, listed) ?? false+ }++ hydrate(session: RegisteredSession, rawLines: string[]): void {+ if (this.unbound(session.sessionId) || !this.currentSession(session)) return+ this.states.set(session.sessionId, freshState(session))+ for (const line of rawLines) this.ingest(session, line, true)+ }++ beginHydrate(session: RegisteredSession): {+ ingest(rawLine: string): void+ commit(): void+ config?(): Promise<void>+ commitWith?(install: () => boolean): boolean+ } {+ const previous = this.state(session.sessionId), version = this.version(previous)+ const identity = readIdentity(session), control = this.controls.get(session.sessionId)+ const stagedSession = { ...session }, stagedControl = copyControl(control)+ const staged = freshState(session)+ let committed = false, failed = false+ const current = () => !committed && !failed && !this.unbound(session.sessionId)+ && this.states.get(session.sessionId) === previous && this.version(previous) === version+ && !!this.currentSession(session, identity) && this.controls.get(session.sessionId) === control+ const commitWith = (install: () => boolean): boolean => {+ if (!current() || !install()) return false+ committed = true+ this.currentSession(session, identity)!.cliVersion = stagedSession.cliVersion+ if (control) Object.assign(control, stagedControl)+ this.states.set(session.sessionId, staged)+ this.wake(session.sessionId)+ return true+ }+ return {+ ingest: (rawLine) => {+ if (!current()) return+ let raw: Record<string, unknown> | null+ try { raw = record(JSON.parse(rawLine)) } catch { return }+ if (!raw) return+ this.runtimeFor(stagedSession.engine)?.transcript({ session: stagedSession, state: staged, control: stagedControl }, raw)+ },+ config: async () => {+ if (!current()) return+ try {+ const runtime = this.runtimeFor(stagedSession.engine)+ if (runtime?.configuredEffort) {+ staged.effort = await runtime.configuredEffort(stagedSession)+ staged.observedAt = Date.now()+ } else if (!runtime) {+ const reader = await this.reader(stagedSession.engine)+ if (current()) await reader?.config?.({ session: stagedSession, state: staged, control: stagedControl, refreshConfig: () => {} })+ }+ } catch (error) { failed = true; throw error }+ },+ commitWith,+ commit: () => { commitWith(() => true) },+ }+ }++ transcriptFields(session: RegisteredSession, rawLine: string): RuntimeField[] {+ return transcriptFields(this.runtimeFor(session.engine), session, rawLine)+ }++ getState(sessionId: string): RuntimeState {+ return { ...this.state(sessionId) }+ }++ async withoutChangeEvents<T>(operation: () => Promise<T>): Promise<T> {+ this.suppressNotifications+++ try { return await operation() } finally { this.suppressNotifications-- }+ }++ selectedModel(session: RegisteredSession): string | null {+ if (this.unbound(session.sessionId)) return null+ const state = this.states.get(session.sessionId)+ if (!state?.model) return null+ const adapter = this.runtimeFor(session.engine)+ if (adapter) return adapter.selectedModel(session, state)+ const model = state.model+ const effort = state.effort+ if (!effort) return null+ return encodeRuntimeProfile({+ sessionId: session.agentId,+ engine: session.engine,+ model,+ effort,+ })+ }++ beginControl(session: RegisteredSession, target: RuntimeProfile): boolean {+ if (this.controls.has(session.sessionId)) return false+ const before = this.selectedModel(session)+ const current = parseRuntimeProfile(before)+ this.controls.set(session.sessionId, {+ target,+ before,+ modelConfirmed: current?.model === target.model,+ effortConfirmed: current?.effort === target.effort,+ })+ this.authoritative(this.state(session.sessionId))+ return true+ }++ cancelControl(sessionId: string): void {+ const control = this.controls.get(sessionId)+ this.controls.delete(sessionId)+ const state = this.states.get(sessionId)+ if (state) this.authoritative(state)+ this.wake(sessionId)+ if (control) this.scheduleChanged(sessionId)+ }++ finishControl(session: RegisteredSession): void {+ this.controls.delete(session.sessionId)+ const state = this.states.get(session.sessionId)+ if (state) this.authoritative(state)+ this.wake(session.sessionId)+ this.scheduleChanged(session.sessionId)+ }++ confirmEffort(sessionId: string, effort: string): void {+ if (!EFFORTS.has(effort)) return+ const state = this.state(sessionId)+ state.effort = effort+ state.observedAt = Date.now()+ this.authoritative(state)+ const control = this.controls.get(sessionId)+ if (control) control.effortConfirmed = control.target.effort === effort+ this.wake(sessionId)+ }++ confirmControlProfile(target: RuntimeProfile): void {+ const state = this.state(target.sessionId)+ state.model = target.model+ state.effort = target.effort+ state.observedAt = Date.now()+ this.authoritative(state)+ const control = this.controls.get(target.sessionId)+ if (control?.target.id === target.id) {+ control.modelConfirmed = true+ control.effortConfirmed = true+ }+ this.wake(target.sessionId)+ }++ waitForModel(sessionId: string, timeoutMs: number): Promise<boolean> {+ return this.waitFor(sessionId, () => this.controls.get(sessionId)?.modelConfirmed === true, timeoutMs)+ }++ waitForProfile(sessionId: string, timeoutMs: number): Promise<boolean> {+ return this.waitFor(sessionId, () => {+ const control = this.controls.get(sessionId)+ return control?.modelConfirmed === true && control.effortConfirmed === true+ }, timeoutMs)+ }++ forget(sessionId: string): void {+ this.states.delete(sessionId)+ this.controls.delete(sessionId)+ const timer = this.changeTimers.get(sessionId)+ if (timer) clearTimeout(timer)+ this.changeTimers.delete(sessionId)+ for (const waiter of this.waiters.get(sessionId) ?? []) {+ clearTimeout(waiter.timer)+ waiter.resolve(false)+ }+ this.waiters.delete(sessionId)+ // Native cleanup is optional and cannot interrupt the caller's eager tail/input/turn cleanup.+ const readers = [...this.readers.values()]+ queueMicrotask(() => {+ if (this.states.has(sessionId)) return+ for (const reader of readers) {+ try { reader.forget?.(sessionId) }+ catch (error) { console.warn(`[runtime-profile] ${reader.engine} cleanup failed:`, error instanceof Error ? error.message : String(error)) }+ }+ })+ }++ async modelsForSessions(sessions: RegisteredSession[]): Promise<RuntimeModelOption[]> {+ const groups = await Promise.all(sessions.map((session) => this.modelsForSession(session)))+ return groups.flat()+ }++ async modelsForSession(session: RegisteredSession): Promise<RuntimeModelOption[]> {+ // Display-only through a gateway: the empty catalogue IS the mechanism (see the note above), so web+ // renders a static chip and the device picker closes instead of offering a list we cannot enumerate.+ if (session.gateway) return []+ return this.runtimeFor(session.engine)?.models(session, this.states.get(session.sessionId)) ?? []+ }++ private unbound(sessionId: string): boolean {+ return !sessionId+ }++ private state(sessionId: string): RuntimeState {+ if (this.unbound(sessionId)) return blankState()+ let state = this.states.get(sessionId)+ if (!state) {+ state = blankState()+ this.states.set(sessionId, state)+ }+ return state+ }++ async codexCatalog(session: RegisteredSession): Promise<RuntimeCatalogModel[]> {+ return this.runtimeFor(session.engine)?.catalog?.(session) ?? []+ }++ private scheduleChanged(sessionId: string): void {+ const previous = this.changeTimers.get(sessionId)+ if (previous) clearTimeout(previous)+ this.changeTimers.set(sessionId, setTimeout(() => {+ this.changeTimers.delete(sessionId)+ if (!this.controls.has(sessionId)) this.onChanged?.(sessionId)+ }, CHANGE_DEBOUNCE_MS))+ }++ private waitFor(sessionId: string, check: () => boolean, timeoutMs: number): Promise<boolean> {+ if (check()) return Promise.resolve(true)+ return new Promise((resolve) => {+ const waiter: StateWaiter = {+ check,+ resolve,+ timer: setTimeout(() => {+ this.waiters.get(sessionId)?.delete(waiter)+ resolve(false)+ }, timeoutMs),+ }+ const set = this.waiters.get(sessionId) ?? new Set<StateWaiter>()+ set.add(waiter)+ this.waiters.set(sessionId, set)+ })+ }++ private wake(sessionId: string): void {+ const set = this.waiters.get(sessionId)+ if (!set) return+ for (const waiter of [...set]) {+ if (!waiter.check()) continue+ clearTimeout(waiter.timer)+ set.delete(waiter)+ waiter.resolve(true)+ }+ if (set.size === 0) this.waiters.delete(sessionId)+ }++ cursorTarget(sessionId: string, profileId: string) {+ const reader = this.readerNow('cursor')+ return reader?.engine === 'cursor' ? reader.target(sessionId, profileId) : null+ }++ devinTarget(sessionId: string, profileId: string) {+ const reader = this.readerNow('devin')+ return reader?.engine === 'devin' ? reader.target(sessionId, profileId) : null+ }++ hermesTarget(sessionId: string, profileId: string) {+ const reader = this.readerNow('hermes')+ return reader?.engine === 'hermes' ? reader.target(sessionId, profileId) : null+ }++ commandcodeTarget(sessionId: string, profileId: string) {+ const reader = this.readerNow('commandcode')+ return reader?.engine === 'commandcode' ? reader.target(sessionId, profileId) : null+ }++ async opencodeCatalog() {+ const reader = await this.reader('opencode')+ return reader?.engine === 'opencode' ? reader.catalog() : []+ }++ async kiloCatalog() {+ const reader = await this.reader('kilo')+ return reader?.engine === 'kilo' ? reader.catalog() : []+ }++}diff --git a/docs/design/2026-10-09-runtime-profile-facets.md b/docs/design/2026-10-09-runtime-profile-facets.mdnew file mode 100644index 000000000..7e02c08e1--- /dev/null+++ b/docs/design/2026-10-09-runtime-profile-facets.md@@ -0,0 +1,60 @@+# Runtime profiles after the legacy manager++The former manager combined accepted session state and control waiters with native+configuration, catalogs and footer interpretation. Item 6 removes that file. The+state owner remains eager; optional engine readers hold only their native catalogs+and model targets. The supervised Claude Code and Codex worker boundary stays as it+was. Explicit inline mode supplies their existing runtime facets to the same state+owner.++`lib/runtimeProfileState.ts` owns accepted model/effort state, hydration, control+confirmation, waiters, notifications and forget. It performs no file reads or+subprocess work. `core/engines/runtimeProfiles.ts` routes supervised pilot readings+to the existing transport and local observations to that owner. Session stop,+binding, admission, launch, discovery and resume do not ask these readers.++Each other engine's `profileReader.ts` owns the interpretation previously embedded+in the manager. Its existing lazy `inProcess.ts` entry exports a factory. One+reader per engine per owner holds that engine's catalogs and targets. Cursor's+catalog/footer logic belongs to Cursor; Hermes reads the session's own native+home; Command Code refreshes per-model effort after an observed model change.+Catalog subprocesses keep their prior timeouts and size limits. These other engines+remain display-only. Their latent picker builders and the six unreachable pane+drivers are retained; this move enables no additional model control.++A missing chunk, missing factory or throwing factory leaves the existing accepted+profile intact. State confirmation and cleanup need no reader. A failed factory is+reported once and remains unavailable for that owner's lifetime.++Configuration reads and staged transcript hydration publish only against the same+current registry row, session identity, state object, state revision and control transaction. Configuration+also checks the latest read token. Native-home changes, newer observations, another+hydration, control changes and forget discard stale answers. Interpretation uses+copies; a staged read cannot expose a CLI version or confirmation before commit.+A repeated confirmation or same-value observation still advances the revision;+ignored records do not. A dependent config refresh starts after its synchronous+observation is accepted and is dropped if the registry replaces its row, newer+confirmation arrives, or an explicit config read has already started. It cannot+supersede the explicit read that a caller awaits.+Inline transcript attachment reads config into the staged profile, then installs+the parser and profile in one synchronous commit after the final tail-hold check.+Expiry, failure or newer evidence keeps both the previous parser and its profile.+Forget completes core state, timer and waiter cleanup before optional native+cleanup runs; a broken reader cannot interrupt the caller's session cleanup.+These are safety corrections found while extracting the former implementation,+covered by regressions that failed before the publication checks were added.++The daemon loads each native reader before delivering its transcript. Direct+compatibility callers must honor that same ordering; the Command Code regression+fixture now does. A pre-existing pane-poll limitation remains: a registry row+mutated in place while capture is pending needs a snapshot taken at dispatch.+Entry-time identity checks alone cannot distinguish that older screen; this is+tracked separately from the extraction's asynchronous config/stage fences.++The former-code baseline is commit `996476cf0`; its observation and state/control+fixtures must remain unchanged. The baseline method is in+[the recording note](../research/2026-10-09-runtime-profile-golden.md). Validation+includes deliberate wiring mutations, typecheck, architecture, core/harnessd 100%+gates, profile/controller/reader specs, and isolated reader/model-control/lean+end-to-end lanes. Performance uses the preceding four-agent/two-active workload,+with the same toolchain and short measurement windows, not a new threshold.diff --git a/docs/research/2026-10-09-daemon-separation-progress.md b/docs/research/2026-10-09-daemon-separation-progress.mdindex fcb8e24e2..2b104a063 100644--- a/docs/research/2026-10-09-daemon-separation-progress.md+++ b/docs/research/2026-10-09-daemon-separation-progress.md@@ -105,8 +105,48 @@ Final broad receipt `20261009T051228.567255Z-74018` passed typecheck, 1,785 coreA two-agent soak/chaos smoke passed in 105.0 seconds (`20261009T051533.050394Z-3315`). The matched performance run passed in 70.7 seconds (`20261009T051852.532251Z-32229`): empty/idle/active core CPU was 0.75/1.65/6.91% of one logical CPU, mean RSS 81.2/95.1/98.8 MiB and event-loop p95 11.07/11.08/11.12 ms. Both turns completed with p95 6.976 seconds. The preceding usage baseline was 0.55/1.50/6.94%, 82.5/95.9/101.7 MiB and 7.015 seconds, on the same Node, machine, tmux and four-agent/two-active workload. These ten-second windows measure only the core PID, exclude services, engines, tmux and USB, and support neither a new threshold nor a long-term growth claim.-Time accounting (UTC): implementation and diagnosis began after the usage merge at 03:03:42 and production corrections ended at 05:11. Independent production approval followed at about 05:13; the final test-only readiness correction passed at 05:14. Final broad local validation ran 05:12:28–05:17:21, overlapping the short soak/chaos run. The matched measurement ran 05:18:52–05:20:03. Final test/documentation review and head checks follow before the authorized merge. All daemons, homes and tmux servers used for testing are disposable. Publication remains zero.--## Added core follow-up+Time accounting (UTC): implementation and diagnosis began after the usage merge at 03:03:42 and production corrections ended at 05:11. Independent production approval followed at about 05:13; the final test-only readiness correction passed at 05:14. Final broad local validation ran 05:12:28–05:17:21, overlapping the short soak/chaos run. The matched measurement ran 05:18:52–05:20:03. Final delta receipt `20261009T052103.008133Z-46578` passed typecheck and both adoption cases in 51.7 seconds. Independent review approved final head `371910cf4` against `e130ad8e1`; [final automatic CI](https://github.com/autonomous-ai/openharness/actions/runs/37888168905) passed all selected checks including `ci/required`. PR #1081 merged as `4cad218c9` at 05:26:10. The merge helper ran 05:25:56–05:26:10; CI waiting ended about 05:25:45. This item took 2 hours 22 minutes 28 seconds; the whole request through that merge took 5 hours 59 minutes 29 seconds. All daemons, homes and tmux servers used for testing are disposable. Publication remains zero.++## Item 6: native runtime readers++[PR #1088](https://github.com/autonomous-ai/openharness/pull/1088) removes the legacy+manager. Former-code commit `996476cf0` recorded 482 other-engine observations and+the public state/control answers on pinned Linux and Darwin. Both fixture files+remain unchanged. The eager owner keeps accepted state, control, waiters and+cleanup; engine facets keep native catalogs, targets and interpretation. Other+engines remain display-only, with the six unreachable drivers retained.++Independent review required monotonic evidence revisions, current registry-row+checks, atomic local parser/profile installation after config and tail-hold+validation, and containment of optional cleanup. It then found the complete+start/cancel control cycle and late cleanup after forget. These were reproduced+and corrected; review approved `08fc7d1fa` against `79c658faa`. The final Linux+shard exposed an old Command Code fixture delivering records before loading the+reader. Matching production ordering then reproduced a queued-refresh race:+a queued read could revoke the explicit config read its caller awaited. The+queue now checks its original read token; core control and confirmation revoke+that token too. Repeated same-model records in one watcher batch preserve the+dependent refresh, which reads the latest accepted model. New tests+cover explicit-read and confirmation supersession; final review/CI are pending.++On `08fc7d1fa`, typecheck, architecture, 1,789 core tests at per-file 100%, 265+harnessd tests with one existing skip at 100%, 1,770 affected tests with seven+existing skips, and 298 resume tests at 100% passed. The resume run first timed+out in the existing 2,050-file fixture under concurrent load; the passing run+used the previously established one-worker/45-second limits. The attempted+receipt reuse did not match the inherited environment and reran checks; that+cost is included in elapsed validation, not hidden. All sixteen wiring mutations+failed golden assertions. The final three state-owner mutations were repeated;+one first hit the five-second compilation deadline, then all three failed the+required assertions with explicit test deadlines. A two-agent half-minute soak+and half-minute chaos smoke passed in 101.7 seconds. Final receipts and landing+times will be recorded after the CI correction is reviewed and validated.++## Added core follow-ups++Pane profile polling also needs a session/route snapshot taken before capture:+the entry-time check cannot reject an older screen if the same registry object+changed in place during the capture. This pre-existing limitation is independent+of the runtime extraction's config and staged-history publication checks.The owner reported that two panes of the same agent started in one millisecond fail. Onboarding avoids it today; the fix belongs in core. The current session-label generator contains only the engine and a millisecond timestamp, so concurrent same-engine creates can collide. Reproduce with a pinned clock, fix the shared label generation, and verify two isolated panes can start together. This is not blocking the completed usage separation.diff --git a/docs/research/2026-10-09-runtime-profile-golden.md b/docs/research/2026-10-09-runtime-profile-golden.mdnew file mode 100644index 000000000..96e8aa3bb--- /dev/null+++ b/docs/research/2026-10-09-runtime-profile-golden.md@@ -0,0 +1,23 @@+# Runtime profile removal: former-code baseline++Recorded from main `e130ad8e1`, before any runtime implementation change, under+`TZ=UTC TMPDIR=/tmp`. The existing other-engine matrix was re-recorded against+its current spec strings: imports and unavailable-engine regressions added since+the original recording expand the pane and config inputs. Only the twelve pane+and four config hashes change; all transcript, catalog and switch hashes stay+identical. The complete matrix contains 482 cases. This commit freezes the new+inputs and answers before moving code; the move must keep the fixtures unchanged.++`runtimeProfileState.golden.spec.ts` additionally records public state/control+answers: registry seeds, malformed input, staged hydration, selected profiles,+confirmation, duplicate control, cancellation, waiter timeouts, forget, change+notifications, gateway restrictions and unbound identity. It exercises all+fourteen engines plus the supervised composition without pilot readers. Darwin+and Linux produce identical answers. The earlier matrix pins Linux; both replace+engine homes and commands, and neither uses a host engine executable. No emitted+value depends on a host Node or tmux path.++Both golden files recorded successfully: 18 tests in two files. Verification of+the frozen fixtures, deliberate wiring mutations, the required coverage gates and+isolated runtime e2e lanes follows the implementation. The six unreachable pane+drivers remain, as the owner decided.