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
+30 -41
View File
@@ -3,13 +3,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
const updateSessionStatsMock = vi.fn()
const updateSessionMock = vi.fn()
const flushBridgePendingToDbMock = vi.fn()
const flushResponseRunToDbMock = vi.fn()
const replaceStateMock = vi.fn()
const calcAndUpdateUsageMock = vi.fn()
const codingAgentRunManagerMock = vi.hoisted(() => ({
hasSession: vi.fn(() => false),
stop: vi.fn(() => false),
}))
vi.mock('../../packages/server/src/db/hermes/session-store', () => ({
updateSession: updateSessionMock,
@@ -24,10 +19,6 @@ vi.mock('../../packages/server/src/services/hermes/run-chat/bridge-message', ()
flushBridgePendingToDb: flushBridgePendingToDbMock,
}))
vi.mock('../../packages/server/src/services/hermes/run-chat/response-stream', () => ({
flushResponseRunToDb: flushResponseRunToDbMock,
}))
vi.mock('../../packages/server/src/services/hermes/run-chat/compression', () => ({
replaceState: replaceStateMock,
}))
@@ -36,10 +27,6 @@ vi.mock('../../packages/server/src/services/hermes/run-chat/usage', () => ({
calcAndUpdateUsage: calcAndUpdateUsageMock,
}))
vi.mock('../../packages/server/src/services/agent-runner/coding-agent-run-manager', () => ({
codingAgentRunManager: codingAgentRunManagerMock,
}))
function makeHarness() {
const emit = vi.fn()
const nsp = {
@@ -56,8 +43,6 @@ function makeHarness() {
describe('run chat abort goal handling', () => {
beforeEach(() => {
vi.clearAllMocks()
codingAgentRunManagerMock.hasSession.mockReturnValue(false)
codingAgentRunManagerMock.stop.mockReturnValue(false)
calcAndUpdateUsageMock.mockResolvedValue({ inputTokens: 0, outputTokens: 0 })
})
@@ -149,72 +134,76 @@ describe('run chat abort goal handling', () => {
})
it('stops a workflow-scoped coding-agent run instead of misrouting abort through the bridge', async () => {
it('aborts a workflow-scoped run through the bridge', async () => {
const { handleAbort } = await import('../../packages/server/src/services/hermes/run-chat/abort')
const { emit, nsp, socket } = makeHarness()
codingAgentRunManagerMock.hasSession.mockReturnValue(true)
codingAgentRunManagerMock.stop.mockReturnValue(true)
const state = {
messages: [],
isWorking: true,
isAborting: false,
events: [],
queue: [],
runId: 'coding-run-1',
runId: 'workflow-run-1',
profile: 'default',
source: 'workflow',
} as any
const sessionMap = new Map([['session-1', state]])
const bridge = {
interrupt: vi.fn().mockRejectedValue(new Error('unknown session: session-1')),
goalPause: vi.fn(),
interrupt: vi.fn().mockResolvedValue({ ok: true, synced: true }),
goalPause: vi.fn().mockResolvedValue({ handled: true }),
}
const runQueuedItem = vi.fn()
await handleAbort(nsp as any, socket as any, 'session-1', sessionMap, bridge, runQueuedItem)
expect(bridge.interrupt).not.toHaveBeenCalled()
expect(bridge.goalPause).not.toHaveBeenCalled()
expect(codingAgentRunManagerMock.stop).toHaveBeenCalledWith('session-1', { reportClosed: false })
expect(bridge.interrupt).toHaveBeenCalledWith('session-1', 'Aborted by user', 'default')
expect(bridge.goalPause).toHaveBeenCalled()
expect(updateSessionMock).toHaveBeenCalledWith('session-1', expect.objectContaining({
ended_at: expect.any(Number),
end_reason: 'abort',
}))
expect(flushResponseRunToDbMock).toHaveBeenCalledWith(expect.objectContaining({
expect(flushBridgePendingToDbMock).toHaveBeenCalledWith(expect.objectContaining({
source: 'workflow',
}), 'session-1')
expect(flushBridgePendingToDbMock).not.toHaveBeenCalled()
expect(codingAgentRunManagerMock.stop).toHaveBeenCalledWith('session-1', { reportClosed: false })
expect(state.isWorking).toBe(false)
expect(state.isAborting).toBe(false)
expect(emit).toHaveBeenCalledWith('abort.completed', expect.objectContaining({
session_id: 'session-1',
run_id: 'coding-run-1',
run_id: 'workflow-run-1',
synced: true,
}))
})
it('stops a coding-agent run even when chat-run state was not marked working', async () => {
it('aborts a session stored with a retired source through the bridge', async () => {
const { handleAbort } = await import('../../packages/server/src/services/hermes/run-chat/abort')
const { emit, nsp, socket } = makeHarness()
const sessionMap = new Map()
codingAgentRunManagerMock.hasSession.mockReturnValue(true)
codingAgentRunManagerMock.stop.mockReturnValue(true)
const state = {
messages: [],
isWorking: true,
isAborting: false,
events: [],
queue: [],
runId: 'legacy-run-1',
profile: 'default',
source: 'retired_source',
} as any
const sessionMap = new Map([['session-1', state]])
const bridge = {
interrupt: vi.fn().mockResolvedValue({ ok: true, synced: true }),
goalPause: vi.fn().mockResolvedValue({ handled: true }),
}
const runQueuedItem = vi.fn()
await handleAbort(nsp as any, socket as any, 'session-1', sessionMap as any, {}, runQueuedItem)
await handleAbort(nsp as any, socket as any, 'session-1', sessionMap, bridge, runQueuedItem)
expect(codingAgentRunManagerMock.stop).toHaveBeenCalledWith('session-1', { reportClosed: false })
expect(sessionMap.get('session-1')).toEqual(expect.objectContaining({
isWorking: false,
isAborting: false,
source: 'coding_agent',
expect(bridge.interrupt).toHaveBeenCalledWith('session-1', 'Aborted by user', 'default')
expect(updateSessionMock).toHaveBeenCalledWith('session-1', expect.objectContaining({
ended_at: expect.any(Number),
end_reason: 'abort',
}))
expect(flushResponseRunToDbMock).toHaveBeenCalledWith(expect.objectContaining({
source: 'coding_agent',
}), 'session-1')
expect(emit).toHaveBeenCalledWith('abort.completed', expect.objectContaining({
session_id: 'session-1',
run_id: 'legacy-run-1',
synced: true,
}))
})