Phase 003: remove the coding-agent and ekko-agent runtimes

Every chat session now runs through the Hermes bridge, so the three chat
chains become feature-equivalent instead of three partially-maintained
dispatch paths. Keeping the coding-agent and in-house agent runtimes alive
meant every bridge change had to be mirrored into two more runtimes that
had already drifted.

Historical rows are read, not migrated: sessions stored with the retired
source normalize to cli on load, workflow graphs naming the retired agents
keep loading and run on the bridge, and the visible-source check plus
SOURCE_LABELS still recognize the old value so those sessions stay listed.

The public surface follows the code: the OpenAPI generator and the MCP
chat-run tool schema drop the six retired entry fields so external callers
are not told about runtimes that no longer exist.

harness-check gains a RETIRED_RUNTIME scan so the residual check is a
mechanical gate instead of a manual grep, with the two surviving read-side
compat sites recorded with reasons.

Refs: docs/phases/phase_003.md
This commit is contained in:
2026-10-16 13:27:50 +08:00
parent c93e1fe1bd
commit 8c1ddf415f
123 changed files with 567 additions and 23599 deletions
+34 -41
View File
@@ -34,9 +34,6 @@ const listUserProfilesMock = vi.fn()
const readConfigYamlForProfileMock = vi.fn()
const bridgeSwitchSessionModelMock = vi.fn()
const bridgeGetRuntimeStateMock = vi.fn()
const codingAgentRunManagerMock = vi.hoisted(() => ({
stop: vi.fn(),
}))
vi.mock('../../packages/server/src/db/hermes/conversations-db', () => ({
listConversationSummariesFromDb: listConversationSummariesFromDbMock,
@@ -126,10 +123,6 @@ vi.mock('../../packages/server/src/services/config-helpers', () => ({
readConfigYamlForProfile: readConfigYamlForProfileMock,
}))
vi.mock('../../packages/server/src/services/agent-runner/coding-agent-run-manager', () => ({
codingAgentRunManager: codingAgentRunManagerMock,
}))
vi.mock('../../packages/server/src/db/hermes/compression-snapshot', () => ({
getCompressionSnapshot: getCompressionSnapshotMock,
}))
@@ -198,7 +191,6 @@ describe('session conversations controller', () => {
bridgeSwitchSessionModelMock.mockReset()
bridgeGetRuntimeStateMock.mockReset()
bridgeGetRuntimeStateMock.mockReturnValue({ ready: false, running: false, endpoint: 'ipc:///tmp/hermes-agent-bridge.sock' })
codingAgentRunManagerMock.stop.mockReset()
})
it('lists conversations from the local session store', async () => {
@@ -698,7 +690,7 @@ describe('session conversations controller', () => {
listUserProfilesMock.mockReturnValue([{ profile_name: 'default' }, { profile_name: 'travel' }])
localListSessionsMock.mockReturnValue([
{ id: 'default-session', profile: 'default', source: 'cli' },
{ id: 'travel-session', profile: 'travel', source: 'coding_agent' },
{ id: 'travel-session', profile: 'travel', source: 'global_agent' },
{ id: 'archived-session', profile: 'default', source: 'cli', is_archived: 1 },
{ id: 'secret-session', profile: 'secret', source: 'cli' },
{ id: 'unknown-profile-session', profile: 'missing', source: 'cli' },
@@ -839,14 +831,13 @@ describe('session conversations controller', () => {
])
})
it('keeps archived coding-agent sessions visible in Hermes history', async () => {
it('keeps archived sessions stored with a retired source visible in Hermes history', async () => {
localListSessionsMock.mockReturnValue([{
id: 'codex-archived',
id: 'legacy-archived',
profile: 'travel',
source: 'coding_agent',
agent: 'codex',
source: 'retired_source',
model: 'gpt-5',
title: 'Archived Codex',
title: 'Archived legacy session',
started_at: 1,
ended_at: null,
last_active: 2,
@@ -872,7 +863,7 @@ describe('session conversations controller', () => {
await mod.listHermesSessions(ctx)
expect(ctx.body.sessions).toEqual([
expect.objectContaining({ id: 'codex-archived', source: 'coding_agent', agent: 'codex', webui_imported: true }),
expect.objectContaining({ id: 'legacy-archived', source: 'retired_source', webui_imported: true }),
])
})
@@ -916,7 +907,7 @@ describe('session conversations controller', () => {
})
it('unarchives an existing accessible session', async () => {
getSessionMock.mockReturnValue({ id: 'session-1', profile: 'default', source: 'coding_agent', is_archived: 1 })
getSessionMock.mockReturnValue({ id: 'session-1', profile: 'default', source: 'retired_source', is_archived: 1 })
localSetSessionArchivedMock.mockReturnValue(true)
const mod = await import('../../packages/server/src/controllers/hermes/sessions')
@@ -1351,13 +1342,12 @@ describe('session conversations controller', () => {
expect(ctx.body).toEqual({ ok: true })
})
it('stores a coding agent session model and API mode without stopping the runner or notifying the Hermes bridge', async () => {
it('treats a session stored with a retired source like any bridge session when switching models', async () => {
bridgeGetRuntimeStateMock.mockReturnValue({ ready: true, running: true, endpoint: 'ipc:///tmp/hermes-agent-bridge.sock' })
getSessionMock.mockReturnValue({
id: 'codex-session',
id: 'legacy-session',
profile: 'default',
source: 'coding_agent',
agent: 'codex',
source: 'retired_source',
model: 'old-model',
provider: 'openrouter',
api_mode: 'codex_responses',
@@ -1367,20 +1357,23 @@ describe('session conversations controller', () => {
const mod = await import('../../packages/server/src/controllers/hermes/sessions')
const ctx: any = {
params: { id: 'codex-session' },
request: { body: { model: 'gpt-5.5', provider: 'openai-codex', apiMode: 'chat_completions' } },
params: { id: 'legacy-session' },
request: { body: { model: 'gpt-5.5', provider: 'openai', apiMode: 'chat_completions' } },
body: null,
}
await mod.setModel(ctx)
expect(localUpdateSessionMock).toHaveBeenCalledWith('codex-session', {
expect(localUpdateSessionMock).toHaveBeenCalledWith('legacy-session', {
model: 'gpt-5.5',
provider: 'openai-codex',
provider: 'openai',
api_mode: 'chat_completions',
agent_native_session_id: '',
})
expect(codingAgentRunManagerMock.stop).not.toHaveBeenCalled()
expect(bridgeSwitchSessionModelMock).not.toHaveBeenCalled()
expect(bridgeSwitchSessionModelMock).toHaveBeenCalledWith(
'legacy-session',
'gpt-5.5',
'openai',
'default',
)
expect(ctx.body).toEqual({ ok: true })
})
@@ -1404,22 +1397,22 @@ describe('session conversations controller', () => {
})
})
it('deletes a local coding-agent session without invoking Hermes CLI deletion', async () => {
it('deletes a session stored with a retired source through the normal path', async () => {
getSessionMock.mockReturnValue({
id: 'codex-session',
id: 'legacy-session',
profile: 'default',
source: 'coding_agent',
source: 'retired_source',
})
localDeleteSessionMock.mockReturnValue(true)
getExactSessionDetailFromDbWithProfileMock.mockResolvedValue(null)
const mod = await import('../../packages/server/src/controllers/hermes/sessions')
const ctx: any = { params: { id: 'codex-session' }, body: null }
const ctx: any = { params: { id: 'legacy-session' }, body: null }
await mod.remove(ctx)
expect(codingAgentRunManagerMock.stop).toHaveBeenCalledWith('codex-session', { reportClosed: false })
expect(getExactSessionDetailFromDbWithProfileMock).not.toHaveBeenCalled()
expect(getExactSessionDetailFromDbWithProfileMock).toHaveBeenCalledWith('legacy-session', 'default')
expect(deleteHermesSessionForProfileMock).not.toHaveBeenCalled()
expect(localDeleteSessionMock).toHaveBeenCalledWith('codex-session')
expect(localDeleteSessionMock).toHaveBeenCalledWith('legacy-session')
expect(ctx.body).toEqual({
ok: true,
deleted: true,
@@ -1463,29 +1456,29 @@ describe('session conversations controller', () => {
expect(ctx.body).toMatchObject({ ok: true, deleted: 2, failed: 0, hermesDeleted: 2 })
})
it('batch deletes local coding-agent sessions without invoking Hermes CLI deletion', async () => {
it('batch deletes sessions stored with a retired source through the normal path', async () => {
getSessionMock.mockReturnValue({
id: 'codex-session',
id: 'legacy-session',
profile: 'default',
source: 'coding_agent',
source: 'retired_source',
})
localDeleteSessionMock.mockReturnValue(true)
getExactSessionDetailFromDbWithProfileMock.mockResolvedValue(null)
const mod = await import('../../packages/server/src/controllers/hermes/sessions')
const ctx: any = {
request: {
body: {
sessions: [{ id: 'codex-session', profile: 'default' }],
sessions: [{ id: 'legacy-session', profile: 'default' }],
},
},
body: null,
}
await mod.batchRemove(ctx)
expect(codingAgentRunManagerMock.stop).toHaveBeenCalledWith('codex-session', { reportClosed: false })
expect(getExactSessionDetailFromDbWithProfileMock).not.toHaveBeenCalled()
expect(getExactSessionDetailFromDbWithProfileMock).toHaveBeenCalledWith('legacy-session', 'default')
expect(deleteHermesSessionForProfileMock).not.toHaveBeenCalled()
expect(localDeleteSessionMock).toHaveBeenCalledWith('codex-session')
expect(localDeleteSessionMock).toHaveBeenCalledWith('legacy-session')
expect(ctx.body).toMatchObject({ ok: true, deleted: 1, failed: 0, hermesDeleted: 0 })
})