refactor(x): decouple the new runtime from the legacy engine file

Findings from a fresh post-refactor review. The turn-runtime bridges
imported convertFromMessages and getToolPermissionMetadata from
agents/runtime.ts — the legacy engine file — making it undeletable;
both move to neutral modules (agents/message-encoding.ts,
agents/permission-metadata.ts) that both engines now share. The
abort registry, used by the live tool registry, moves out of the
legacy runs/ cluster into turns/. Dead surface goes: the zero-consumer
CopilotInstructions, skillCatalog, RunLogger, and MappedToolCall
exports are deleted, mapAgentTool/StreamStepMessageBuilder become
module-private, and the mid-file import scar from the composer
extraction is hoisted.

Three review fixes ride along: ITurnEventBus gains
subscribe/subscribeAll so consumers stop resolving the concrete hub;
skill carry-forward becomes its own registry trait instead of
overloading workspaceContext; and connection checks (slack/composio/
code-mode/google) collapse into one shared connections.ts consumed by
both skill availability and the copilot prompt blocks — plus stale
doc pointers (VIDEO_MODE.md to moved prompt text, CLAUDE.md's dangling
AGENTS.md reference).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Ramnique Singh 2026-07-10 10:37:15 +05:30
parent 6375704d66
commit fdce639839
26 changed files with 449 additions and 445 deletions

View file

@ -31,7 +31,7 @@ import { ServiceEvent } from '@x/shared/dist/service-events.js';
import type { SessionBusEvent } from '@x/shared/dist/sessions.js';
import { isDurableTurnEvent } from '@x/shared/dist/turns.js';
import type { ISessions, EmitterSessionBus } from '@x/core/dist/sessions/index.js';
import type { TurnEventHub } from '@x/core/dist/turns/event-hub.js';
import type { ITurnEventBus } from '@x/core/dist/turns/event-hub.js';
import container from '@x/core/dist/di/container.js';
import { listOnboardingModels } from '@x/core/dist/models/models-dev.js';
import { testModelConnection, listModelsForProvider, generateOneShot } from '@x/core/dist/models/models.js';
@ -728,7 +728,7 @@ export function startTurnEventsWatcher(): void {
if (turnEventsWatcher) {
return;
}
const hub = container.resolve<TurnEventHub>('turnEventBus');
const hub = container.resolve<ITurnEventBus>('turnEventBus');
turnEventsWatcher = hub.subscribeAll((event) => {
if (isDurableTurnEvent(event.event)) {
broadcastToWindows('turns:events', event);