[STG-1566] Flow logger schema and collection cleanup to prepare for Observability

PI
8mo ago
+3537-1286

Refactored flow logging to an event-based system with FlowLogger and a pluggable eventStore, improving LLM/CDP traces, action and screenshot events, and concise prompt/response summaries. V3 now carries a sessionId and flowLoggerContext. Split the server into server-v3 and server-v4 with separate OpenAPI, routes, and SEA builds, and updated CI.

  • New Features

    • Added eventStore with FileEventStore, queries, aggregate metrics, and bus attachment; exported getEventStore, setEventStore, destroyEventStore, and getFlowLogConfigDir.
    • Replaced SessionFileLogger with FlowLogger across agents and handlers; added wrapWithLogging for Page actions; standardized event names via toTitleCase.
    • Switched to concise LLM summary helpers (extractLlmPromptSummary, extractLlmCuaPromptSummary, extractLlmCuaResponseSummary) and FlowLogger.createLlmLoggingMiddleware.
    • V3Options.sessionId now used to associate flows; CDP calls are linked to flow events for better correlation.
    • Exported FlowLogger, FlowEvent, and toTitleCase from @core/v3/index.
  • Migration

    • Replace SessionFileLogger and @logAction with FlowLogger methods (log*, wrapWithLogging).
    • Use setEventStore/getEventStore to plug custom storage (FileEventStore by default); optionally pass sessionId in V3Options.
    • Update paths/scripts from packages/server to packages/server-v3; use new binaries stagehand-server-v3-*/stagehand-server-v4-*.