/** * Building blocks for the read-only sub-clients that surface QAR's * `bulletin.post`, `artifact.add`, `state.update`, and `agent.spawn` * envelopes to opt-in consumers. * * These sub-clients are observers — they tap inbound envelopes alongside the * `TaskSubscription` chain (so the same envelope still drives the canonical * `AsyncIterable` from `client.tasks.start()`). Multiple handlers * per kind are allowed and run in registration order; throws are swallowed * so a misbehaving consumer never crashes the WS loop. */ import type { Envelope, EnvelopeKind } from '../qar/envelopes.js'; /** * Token returned by the four `client.{bulletin,artifacts,state,agents}.on*` * methods. `close()` deregisters the handler; subsequent envelopes do not * invoke it. Idempotent. * * Distinct from `Subscription` (`unsubscribe()`) on `ToolClient` — the four * read-only event surfaces use `close()` to mirror QAR's spawn-lifecycle * vocabulary (see `docs/sdk2/event-surfaces.md`). */ export interface EventSubscription { close(): void; } /** * Shared base for the four kind-filtered observer sub-clients. Holds the * handler registry; `attach`/`detach` are called by `QodoClient` on * `connect`/`disconnect`. Registrations made before `connect()` are honored * once the WS opens — consumers can wire handlers eagerly during construction. */ export declare abstract class KindObserverClient { private readonly kind; private port; private connection; private readonly registrations; protected constructor(kind: K); /** * Called by the port from `close()` / `fail()`. The connection is already * tearing itself down (it cleared its own subscription set), so do NOT * call `unsubscribe` here — just clear the sub-client's pointers so a * later `attach()` against a fresh connection starts cleanly. Guards on * identity in case a stale port from a prior attach cycle fires after * the sub-client already moved on. */ private onPortUnbound; /** * Register a handler. The optional `matches` predicate runs per envelope — * sub-classes pass their filter shape through it. Returns an * `EventSubscription` whose `close()` is idempotent. */ protected register(handler: (env: E) => void, matches?: (env: E) => boolean): EventSubscription; private dispatch; private logHandlerError; } //# sourceMappingURL=observers.d.ts.map