/* * SPEC: PJ2026-0104010803 Workbench唯一投影 draft-2026-06-18-p0-unique-projection; PJ2026-010403 API契约 draft-2026-06-18-r1. * 职责: WorkbenchReadModel 组件入口。只通过 WorkbenchFactsStore 读取 durable projection facts,不执行 AgentRun sync/finalize/repair。 */ import { createWorkbenchFactsStore } from "./workbench-facts-store.ts"; import { projectionDiagnostics as workbenchProjectionDiagnostics } from "./workbench-turn-projection.ts"; export function createWorkbenchReadModel(options = {}, actor = null) { const facts = createWorkbenchFactsStore(options, actor); return { facts, queryFacts: (input = {}) => facts.queryFacts(input), listSessions: (input = {}) => facts.listSessions(input), getSessionById: (sessionId) => facts.getSessionById(sessionId), getSessionByRouteId: (routeId) => facts.getSessionByRouteId(routeId), getSessionByTraceId: (traceId) => facts.getSessionByTraceId(traceId), resultForTrace: (traceId) => facts.resultForTrace(traceId), traceSnapshot: (traceId) => facts.traceSnapshot(traceId), traceSnapshotSync: (traceId) => facts.traceSnapshotSync(traceId), subscribeTrace: (traceId, listener) => facts.subscribeTrace(traceId, listener), canReadOwner: (ownerUserId) => facts.canReadOwner(ownerUserId), projectionDiagnostics: ({ traceId, result = null, trace = null, projection = null, refreshError = null } = {}) => workbenchProjectionDiagnostics({ traceId, result, trace, projection, refreshError }) }; }