processEvent | (frame: EventFrame, handler: EventHandlerHandle) => void | Convenience runner: classifyEvent → derivePolicy → handler.applyIntents. The full pipeline in one call. |
classifyEvent | (frame: EventFrame) => ClassifiedEvent | Bridge step 1. Maps a raw frame’s event field to an EventKind, extracts agentId / sessionKey (from agent:<id>: session keys or payload fields). Unrecognized events → kind: 'unknown'. |
parseChatPayload | (payload: unknown) => ChatEventPayload | null | Validates a chat payload: requires runId + sessionKey + a state of delta/final/aborted/error. Returns null if malformed. |
parseAgentPayload | (payload: unknown) => AgentEventPayload | null | Validates an agent payload: requires runId. Extracts seq, stream, data, sessionKey. Returns null if no runId. |
isReasoningStream | (stream: string) => boolean | True when the stream name reads as reasoning (reason/think/analysis/trace) and not assistant/tool/lifecycle. |
resolveLifecyclePatch | (input: { phase: LifecyclePhase; incomingRunId: string; currentRunId: string | null; timestamp: number }) => LifecycleTransition | Pure lifecycle reducer: start → running patch; end/error → terminal patch, but ignore when currentRunId is set and mismatches incomingRunId (stale-run guard). |
mergeRuntimeStream | (current: string, incoming: string) => string | Concatenates incoming streaming text onto the current buffer; no-ops on empty input. |
dedupeRunLines | (seen: Set<string>, lines: string[]) => { appended: string[]; nextSeen: Set<string> } | Filters out already-seen lines, returns the newly-appended subset plus an updated seen-set (immutable copy). |
extractText | (message: unknown) => string | null | Re-export of @clawboo/protocol. Strips assistant prefix / thinking tags / approval suffix from a message. |
extractThinking | (message: unknown) => string | null | Re-export of @clawboo/protocol. Pulls the thinking trace from block content / tagged streams. |
extractToolLines | (message: unknown) => string[] | Re-export of @clawboo/protocol. Formats tool calls/results as [[tool]] / [[tool-result]] markdown lines. |
derivePolicy | (event: ClassifiedEvent) => EventIntent[] | Policy router. Dispatches by event.kind to the four deciders below; malformed payloads / unknown kinds → [{ kind: 'ignore', … }]. |
decideAgentEvent | (event: ClassifiedEvent) => EventIntent[] | Agent-plane decider for summary-refresh (presence/heartbeat) → one debounced scheduleSummaryRefresh intent (delayMs: 750; includeHeartbeatRefresh true for heartbeat). |
decideTrustEvent | (event: ClassifiedEvent) => EventIntent[] | Trust-plane decider for approval events → approvalPending (exec.approval.pending/.requested) or approvalResolved. Ignores when agentId is missing. |
decideWorkChatEvent | (event: ClassifiedEvent, payload: ChatEventPayload) => EventIntent[] | Work-plane decider for chat frames: delta → queueLivePatch; final/aborted/error → clearPendingLivePatch + commitChat (+ a requestHistoryRefresh on a final with no thinking trace). |
decideWorkAgentEvent | (event: ClassifiedEvent, payload: AgentEventPayload) => EventIntent[] | Work/agent-plane decider for agent streams: lifecycle phases → updateAgentStatus; reasoning/assistant streams → queueLivePatch; tool/unknown streams → ignore. |
createEventHandler | (deps: EventHandlerDeps) => EventHandlerHandle | Builds the stateful Handler. Owns a debounced summary-refresh timer + a 30 s / 500-entry closed-runs guard against stale terminal events; dispatches intents to injected store callbacks. |
createPatchQueue | (onFlush: (patches: Patch[]) => void) => { enqueue: (patch: Patch) => void; flush: () => void; dispose: () => void } | RAF-batched per-agent patch merger. Merges updates per agentId until the next animation frame; a run-ID change discards the prior streaming state. SSR-guarded (no-op without requestAnimationFrame). |