import type { AdapterHealth, AdapterId, CliAdapter, NativeSession } from "../adapters/types.js"; import type { GroupXEnvelope } from "../core/envelope.js"; import type { AcceptMessageLimits, AgentDatedMemoryRollupRecord, ClaimedTurn, CreateIdentityInput, CreateMemoryInput, IdentityQuery, IdentityRecord, MemoryQuery, MemoryRecord, RecoveryResult, RuntimeTransport, StoredEventRecord, TurnRecord, TurnStatus } from "../storage/types.js"; export interface BrokerSupervisionPair { observers: readonly string[]; mode: "live_steer"; } export interface BrokerMessageRequest { clientCommandId: string; to: readonly string[]; content: string; replyToEventId?: string; supervision?: BrokerSupervisionPair; } /** * The caller binding is supplied by the HTTP/MCP composition layer. It is a * provenance association, not an authentication credential. */ export interface AcceptBrokerMessageInput { bindingId: string; request: BrokerMessageRequest; roomId?: string; commandType?: string; causationId?: string; correlationId?: string; parentTurnId?: string; hopCount?: number; sourceEventType?: "message.created" | "operator.dispatch"; operation?: "send" | "worker_dispatch" | "worker_ask" | "dispatch_event"; existingSourceEventId?: string; } export interface BrokerSessionProvider { resolve(input: { actorId: string; adapterId: AdapterId; }): NativeSession | Promise; } export interface BrokerContextPacket { contextPacket?: string; contextThroughSeq: number; /** Persisted summary boundary actually embedded in contextPacket. */ summaryThroughSeq?: number; } export interface BrokerContextProvider { prepare(input: { turn: TurnRecord; sourceEvent: StoredEventRecord; lastDeliveredSeq: number; }): BrokerContextPacket | Promise; } export interface BrokerContextController { inspectUsage(roomId: string): import("../memory/types.js").RoomContextUsage; compactNow(roomId: string): Promise; resetNow(roomId: string, resetNativeSessions?: boolean): import("../memory/types.js").RoomContextResetResult; } export interface BrokerDatedMemoryController { /** Schedules best-effort rollup work after a successful terminal commit. */ noteCompleted(record: AgentDatedMemoryRollupRecord): void; } export interface BrokerEventPublisher { publish(envelope: GroupXEnvelope): void | Promise; } export interface BrokerAgentController { restart(actorId: string): void | Promise; } export interface ActiveBrokerTurnContext { bindingId: string; turnId: string; sourceEventId: string; rootCorrelationId: string; hopCount: number; } /** * Synchronous composition hook used to associate native MCP calls with the * currently executing GroupX Turn. It is provenance/causality state, not an * authorization decision point. */ export interface BrokerTurnLifecycle { activate(context: ActiveBrokerTurnContext): void; deactivate(context: ActiveBrokerTurnContext): void; } export interface BrokerClock { now(): string; } export type BrokerIdFactory = (prefix: string) => string; export interface BrokerErrorContext { operation: "publish" | "dispatch" | "context" | "memory" | "restart" | "recovery"; actorId?: string; turnId?: string; } export interface BrokerDependencies { store: import("../storage/types.js").GroupXStore; adapters: import("../adapters/registry.js").AdapterRegistry; sessions: BrokerSessionProvider; publisher: BrokerEventPublisher; agentController?: BrokerAgentController; contextProvider?: BrokerContextProvider; contextController?: BrokerContextController; datedMemoryController?: BrokerDatedMemoryController; turnLifecycle?: BrokerTurnLifecycle; acceptMessageLimits?: AcceptMessageLimits; steerLimit?: number; watchTimeoutMs?: number; selectedTransport: RuntimeTransport; clock?: BrokerClock; idFactory?: BrokerIdFactory; defaultRoomId?: string; partialCheckpointChars?: number; nativeCancelTimeoutMs?: number; closeTimeoutMs?: number; onError?: (error: unknown, context: BrokerErrorContext) => void; } export interface CancelTurnOutcome { turnId: string; accepted: boolean; status: TurnStatus; } export interface CancelTurnFromBindingInput { turnId: string; bindingId: string; clientCommandId: string; } export interface CompactContextFromBindingInput { bindingId: string; clientCommandId: string; roomId?: string; } export interface ResetContextFromBindingInput { bindingId: string; clientCommandId: string; roomId?: string; resetNativeSessions?: boolean; } export interface SupervisionStatusQuery { pairId?: string; correlationId?: string; } export interface CorrelationReadResult { correlationId?: string; events: GroupXEnvelope[]; turns: Array<{ target: string; turnId: string; status: string; responseEventId?: string; errorCode?: string; }>; nextAfterSeq?: number; } export interface ReadCorrelationInput { correlationId?: string; roomId?: string; afterSeq?: number; limit?: number; } export interface WatchSubjectInput { watchTurnId: string; subjectTurnId?: string; afterSeq?: number; until: "next_milestone" | "terminal"; timeoutMs?: number; signal?: AbortSignal; } export interface WatchSubjectResult { snapshot: import("../core/supervision.js").SupervisionSnapshot; until: "next_milestone" | "terminal"; timedOut: boolean; } export interface SteerSubjectInput { bindingId: string; watchTurnId: string; subjectTurnId?: string; action: "nudge" | "interrupt"; reason: string; content: string; clientCommandId: string; } export interface SteerSubjectResult { action: "nudge" | "interrupt"; reason: string; subjectTurnId: string; messageEventId: string; correlationId: string; nextTurnId?: string; steeredEventId?: string; } export interface WaitForCorrelationInput { correlationId: string; /** * For groupx.ask this is the exact child Turn set returned by acceptMessage. * If omitted, the Broker snapshots the correlation's current Turns. */ childTurnIds?: readonly string[]; /** Exact child Turn set created from this durable public message. */ sourceEventId?: string; roomId?: string; timeoutMs?: number; signal?: AbortSignal; } export interface TurnQueueSnapshot { turnId: string; queuePosition: number; activeTurnId?: string; } export interface CorrelationWaitResult { state: "terminal" | "timeout" | "aborted"; correlationId: string; turns: TurnRecord[]; read: CorrelationReadResult; /** Exact final response events for the waited child Turns, independent of read pagination. */ responseEvents: GroupXEnvelope[]; } export interface BrokerHealth { store: { available: boolean; integrityOk: boolean; schemaVersion: number; journalMode: string; }; agents: AdapterHealth[]; activeTurns: number; queuedTurns: number; } export interface BrokerTurnProjection { turnId: string; targetActorId: string; status: TurnRecord["status"]; sourceEventId: string; } export interface BrokerBootstrap { schema: "groupx.bootstrap/0.1"; room: { roomId: string; throughSeq: number; }; agents: Array<{ actorId: string; displayName: string; status: string; instanceId?: string; }>; recentEvents: GroupXEnvelope[]; activeTurns: BrokerTurnProjection[]; } export interface RememberMemoryFromBindingInput extends Omit { bindingId: string; clientCommandId: string; roomId?: string; correlationId?: string; } export interface RememberIdentityFromBindingInput extends Omit { bindingId: string; clientCommandId: string; roomId?: string; correlationId?: string; } export interface SupersedeMemoryFromBindingInput { bindingId: string; clientCommandId: string; roomId?: string; correlationId?: string; kind?: CreateMemoryInput["kind"]; content: string; sourceEventId?: string; } export interface SupersedeIdentityFromBindingInput { bindingId: string; clientCommandId: string; roomId?: string; correlationId?: string; kind?: string; content: string; sourceEventId?: string; } export interface RetractRecordFromBindingInput { bindingId: string; clientCommandId: string; roomId?: string; correlationId?: string; } export interface BrokerFacade { acceptMessage(input: AcceptBrokerMessageInput): Promise; assertObserverRouting(watchTurnId: string, targets: readonly string[]): void; watchSubject(input: WatchSubjectInput): Promise; steerSubject(input: SteerSubjectInput): Promise; cancelTurn(turnId: string): Promise; cancelFromBinding(input: CancelTurnFromBindingInput): Promise; contextUsage(roomId?: string): import("../memory/types.js").RoomContextUsage; compactContextFromBinding(input: CompactContextFromBindingInput): Promise; readCorrelation(input?: ReadCorrelationInput): CorrelationReadResult; waitForCorrelation(input: WaitForCorrelationInput): Promise; inspectTurnQueue(turnId: string): TurnQueueSnapshot; health(): BrokerHealth; bootstrap(input?: { roomId?: string; recentLimit?: number; }): BrokerBootstrap; queryMemory(input?: MemoryQuery): MemoryRecord[]; queryIdentity(input?: IdentityQuery): IdentityRecord[]; rememberMemory(input: RememberMemoryFromBindingInput): Promise; supersedeMemory(memoryId: string, input: SupersedeMemoryFromBindingInput): Promise; retractMemory(memoryId: string, input: RetractRecordFromBindingInput): Promise; rememberIdentity(input: RememberIdentityFromBindingInput): Promise; supersedeIdentity(identityId: string, input: SupersedeIdentityFromBindingInput): Promise; retractIdentity(identityId: string, input: RetractRecordFromBindingInput): Promise; recoverAfterRestart(): Promise; notifySessionReady(actorId: string): void; restartAgent(actorId: string): Promise; waitForIdle(): Promise; close(): Promise; } export interface DispatchPreparation { claim: ClaimedTurn; adapter: CliAdapter; session: NativeSession; sourceEvent: StoredEventRecord; promptContent: string; contextPacket?: string; } //# sourceMappingURL=types.d.ts.map