import type { PublicProvenance } from "../core/envelope.js"; export type JsonObject = Readonly>; export type RuntimeTransport = "direct" | "structured"; export interface ActorRecord { actorId: string; kind: "user" | "agent" | "system"; displayName: string; enabled: boolean; createdAt: string; updatedAt: string; } export interface UpsertActorInput { actorId: string; kind: ActorRecord["kind"]; displayName: string; enabled?: boolean; now?: string; } export interface AgentInstanceRecord { instanceId: string; actorId: string; adapterId: string; transport?: RuntimeTransport; processStartedAt: string; processEndedAt?: string; status: AgentInstanceStatus; } export declare const AGENT_INSTANCE_STATUSES: readonly ["starting", "ready", "stopping", "stopped", "failed", "interrupted"]; export type AgentInstanceStatus = (typeof AGENT_INSTANCE_STATUSES)[number]; export interface CreateAgentInstanceInput { instanceId: string; actorId: string; adapterId: string; transport?: RuntimeTransport; processStartedAt?: string; status?: Extract; } export interface FinishAgentInstanceInput { status: Extract; processEndedAt?: string; } export interface SessionBindingRecord { bindingId: string; instanceId: string; actorId: string; nativeSessionId?: string; protocol: string; transport?: RuntimeTransport; protocolVersion?: string; status: SessionBindingStatus; capabilities: JsonObject; createdAt: string; lastReadyAt?: string; closedAt?: string; } export declare const SESSION_BINDING_STATUSES: readonly ["starting", "ready", "closed", "failed", "interrupted"]; export type SessionBindingStatus = (typeof SESSION_BINDING_STATUSES)[number]; export interface CreateSessionBindingInput { bindingId: string; instanceId: string; actorId: string; nativeSessionId?: string; protocol: string; transport?: RuntimeTransport; protocolVersion?: string; status?: Extract; capabilities?: JsonObject; createdAt?: string; lastReadyAt?: string; } export interface MarkSessionBindingReadyInput { nativeSessionId?: string; protocolVersion?: string; capabilities?: JsonObject; lastReadyAt?: string; } export interface MarkSessionBindingFailedInput { status?: Extract; closedAt?: string; } export interface RuntimeRecoveryResult { agentInstances: AgentInstanceRecord[]; sessionBindings: SessionBindingRecord[]; } export interface ClientCommandRecord { commandId: string; sourceBindingId: string; clientCommandId: string; commandType: string; canonicalHash: string; completed: boolean; result: TResult | null; acceptedAt: string; } export interface BeginClientCommandInput { sourceBindingId: string; clientCommandId: string; commandType: string; canonicalPayload: JsonObject; acceptedAt?: string; } export type BeginClientCommandOutcome = { disposition: "accepted"; } | { disposition: "pending"; } | { disposition: "replayed"; result: TResult; }; export interface CompleteClientCommandInput { sourceBindingId: string; clientCommandId: string; result: TResult; } export interface DurableEventInput { eventId?: string; schemaVersion?: string; roomId: string; eventType: string; actorId: string; instanceId?: string; targets?: readonly string[]; replyToEventId?: string; causationId?: string; correlationId: string; idempotencyKey?: string; occurredAt?: string; body: TBody; provenance?: PublicProvenance; } export interface StoredEventRecord { seq: number; eventId: string; schemaVersion: string; roomId: string; eventType: string; actorId: string; actorKind: ActorRecord["kind"]; actorDisplayName: string; instanceId?: string; targets: string[]; replyToEventId?: string; causationId?: string; correlationId: string; idempotencyKey?: string; occurredAt: string; body: TBody; provenance?: PublicProvenance; } export interface EventPage { events: StoredEventRecord[]; afterSeq: number; nextAfterSeq: number; hasMore: boolean; } export declare const TURN_STATUSES: readonly ["queued", "dispatching", "running", "cancelling", "completed", "failed", "cancelled", "interrupted"]; export type TurnStatus = (typeof TURN_STATUSES)[number]; export type RunningTurnStatus = Extract; export type TerminalTurnStatus = Exclude; export interface TurnTargetInput { actorId: string; adapterId: string; transport: RuntimeTransport; bindingId?: string; parentTurnId?: string; hopCount?: number; } export interface AcceptMessageLimits { /** Defaults mirror the v0.1 config schema; this exported value is the storage fallback source. */ rootTurns: number; hopCount: number; actorCallsPerRoot: number; queuePerActor: number; } export declare const DEFAULT_ACCEPT_MESSAGE_LIMITS: Readonly; export interface SupervisionAcceptInput { observers: readonly TurnTargetInput[]; mode: "live_steer"; } export interface AcceptMessageInput { sourceBindingId: string; clientCommandId: string; commandType?: string; roomId: string; targets: readonly TurnTargetInput[]; content: string; replyToEventId?: string; causationId?: string; correlationId?: string; idempotencyKey?: string; occurredAt?: string; provenance?: PublicProvenance; limits?: AcceptMessageLimits; supervision?: SupervisionAcceptInput; sourceEventType?: "message.created" | "operator.dispatch"; operation?: "send" | "worker_dispatch" | "worker_ask" | "dispatch_event"; existingSourceEventId?: string; } export interface AcceptedTurnResult { target: string; turnId: string; status: "queued"; } export interface AcceptMessageResult { messageEventId: string; correlationId: string; turns: AcceptedTurnResult[]; watchTurns?: AcceptedTurnResult[]; watchEventId?: string; pairEventId?: string; } export interface AcceptMessageOutcome { result: AcceptMessageResult; disposition: "accepted" | "replayed"; } export interface TurnRecord { turnId: string; sourceEventId: string; targetActorId: string; adapterId: string; transport: RuntimeTransport; bindingId?: string; nativeTurnId?: string; parentTurnId?: string; rootCorrelationId: string; hopCount: number; enqueueSeq: number; queuedEventId: string; status: TurnStatus; partialText?: string; responseEventId?: string; terminalEventId?: string; errorCode?: string; queuedAt: string; startedAt?: string; terminalAt?: string; } export interface RoomBootstrapSnapshot { roomId: string; throughSeq: number; recentEvents: StoredEventRecord[]; activeTurns: TurnRecord[]; } export interface EnqueueTurnInput { turnId?: string; sourceEventId: string; targetActorId: string; adapterId: string; transport: RuntimeTransport; bindingId?: string; parentTurnId?: string; rootCorrelationId: string; hopCount?: number; queuedAt?: string; } export interface TerminalToolProgressInput { occurredAt: string; nativeType: "tool.started" | "tool.completed"; toolCallId?: string; details: unknown; } export interface TerminalTurnInput { turnId: string; attemptId?: string; status: TerminalTurnStatus; content?: string; /** Aggregated native reasoning for durable transcript replay; never a Context Packet input. */ reasoning?: string; /** Bounded native tool projections for durable UI replay; never a Context Packet input. */ toolProgress?: readonly TerminalToolProgressInput[]; errorCode?: string; eventType?: string; eventBody?: JsonObject; occurredAt?: string; } export interface TerminalTurnResult { turn: TurnRecord; reasoningEvent?: StoredEventRecord; toolProgressEvents?: StoredEventRecord[]; responseEvent?: StoredEventRecord; /** Durable rollup source/checkpoint registered without blocking the business Turn. */ datedMemoryRollup?: AgentDatedMemoryRollupRecord; terminalEvent: StoredEventRecord; } export declare const DELIVERY_CERTAINTIES: readonly ["not_delivered", "delivered", "unknown", "terminal"]; export type DeliveryCertainty = (typeof DELIVERY_CERTAINTIES)[number]; export declare const DISPATCH_PHASES: readonly ["prepared", "prompt_invoked", "native_started", "terminal"]; export type DispatchPhase = (typeof DISPATCH_PHASES)[number]; export interface TurnAttemptRecord { attemptId: string; turnId: string; bindingId: string; instanceId: string; contextThroughSeq: number; /** Highest room sequence represented by a persisted summary in this attempt. */ summaryThroughSeq?: number; nativeTurnId?: string; dispatchPhase: DispatchPhase; claimedAt: string; promptInvokedAt?: string; startedAt?: string; terminalAt?: string; deliveryCertainty: DeliveryCertainty; } export interface ClaimedTurn { turn: TurnRecord; attempt: TurnAttemptRecord; } export interface DeliveryCursorRecord { actorId: string; roomId: string; lastDeliveredSeq: number; lastSummarySeq?: number; updatedAt: string; } export declare const SUMMARY_STATUSES: readonly ["active", "superseded"]; export type SummaryStatus = (typeof SUMMARY_STATUSES)[number]; /** A cumulative, derived room checkpoint. The source transcript remains authoritative. */ export interface SummaryRecord { summaryId: string; roomId: string; fromSeq: number; throughSeq: number; content: string; generatorActorId: string; status: SummaryStatus; createdAt: string; } export interface ReplaceRoomSummaryInput { summaryId?: string; roomId: string; fromSeq: number; throughSeq: number; content: string; generatorActorId: string; /** Compare-and-set guard. Omit only when the room has no active summary. */ expectedPreviousSummaryId?: string; createdAt?: string; } export interface RecoveryResult { queuedTurns: TurnRecord[]; interruptedTurns: TurnRecord[]; } export declare const MEMORY_SCOPE_TYPES: readonly ["room", "agent", "correlation"]; export type MemoryScopeType = (typeof MEMORY_SCOPE_TYPES)[number]; export declare const MEMORY_KINDS: readonly ["fact", "decision", "preference", "instruction", "constraint", "summary", "note"]; export type MemoryKind = (typeof MEMORY_KINDS)[number]; export declare const AGENT_MEMORY_TYPES: readonly ["core", "dated"]; export type AgentMemoryType = (typeof AGENT_MEMORY_TYPES)[number]; export type RecordStatus = "active" | "superseded" | "retracted"; export interface MemoryRecord { memoryId: string; scopeType: MemoryScopeType; scopeId: string; /** Present only for Agent-scoped records. */ agentMemoryType?: AgentMemoryType; kind: MemoryKind; authorActorId: string; subjectActorId?: string; content: string; sourceEventId?: string; sourceKind: string; status: RecordStatus; supersedesMemoryId?: string; createdAt: string; retractedAt?: string; } export interface CreateMemoryInput { memoryId?: string; scopeType: MemoryScopeType; scopeId: string; /** Required for Agent scope and forbidden for room/correlation scope. */ agentMemoryType?: AgentMemoryType; kind: MemoryKind; authorActorId: string; subjectActorId?: string; content: string; sourceEventId?: string; sourceKind: string; createdAt?: string; } export type MemoryMutationCommand = { kind: "remember"; record: CreateMemoryInput; } | { kind: "supersede"; memoryId: string; replacement: CreateMemoryInput; } | { kind: "retract"; memoryId: string; }; export interface MutateMemoryInput { sourceBindingId: string; clientCommandId: string; roomId: string; correlationId?: string; occurredAt?: string; mutation: MemoryMutationCommand; } export interface MemoryMutationResult { record: MemoryRecord; event: StoredEventRecord; } export interface MemoryMutationOutcome { result: MemoryMutationResult; disposition: "accepted" | "replayed"; } export interface MemoryQuery { scopeType?: MemoryScopeType; scopeId?: string; agentMemoryType?: AgentMemoryType; kind?: MemoryKind; authorActorId?: string; subjectActorId?: string; text?: string; includeHistory?: boolean; /** Offset in deterministic result order; use against a mutation-free snapshot. */ cursor?: number; limit?: number; } /** One recoverable per-room/per-Agent/per-local-date rollup checkpoint. */ export interface AgentDatedMemoryRollupRecord { roomId: string; actorId: string; localDate: string; memoryId?: string; summarizedThroughSeq: number; pendingThroughSeq?: number; pendingTurns: number; pendingChars: number; firstPendingAt?: string; lastPendingAt?: string; failureCount: number; lastAttemptAt?: string; nextAttemptAt?: string; lastErrorCode?: string; updatedAt: string; } /** Bounded semantic input for one successful Turn; reasoning/tool records are never joined. */ export interface AgentDatedMemorySourceRecord { turnId: string; roomId: string; actorId: string; localDate: string; sourceEventId: string; sourceSeq: number; responseEventId: string; responseSeq: number; currentMessage: string; finalResponse: string; sourceChars: number; terminalAt: string; processedAt?: string; memoryId?: string; } export interface CommitAgentDatedMemoryRollupInput { roomId: string; actorId: string; localDate: string; /** Omit only when the date has no generated memory yet. */ expectedMemoryId?: string; selectedTurnIds: readonly string[]; /** Empty means the batch was intentionally checkpointed as semantically trivial. */ content: string; generatedAt?: string; } export interface CommitAgentDatedMemoryRollupResult { rollup: AgentDatedMemoryRollupRecord; memory?: MemoryRecord; event?: StoredEventRecord; } export interface RecordAgentDatedMemoryRollupFailureInput { roomId: string; actorId: string; localDate: string; expectedMemoryId?: string; errorCode: string; attemptedAt?: string; nextAttemptAt: string; } export interface IdentityRecord { identityId: string; subjectActorId: string; authorActorId: string; kind: string; content: string; sourceEventId?: string; sourceKind: string; status: RecordStatus; supersedesIdentityId?: string; createdAt: string; retractedAt?: string; } export interface CreateIdentityInput { identityId?: string; subjectActorId: string; authorActorId: string; kind: string; content: string; sourceEventId?: string; sourceKind: string; createdAt?: string; } export type IdentityMutationCommand = { kind: "remember"; record: CreateIdentityInput; } | { kind: "supersede"; identityId: string; replacement: CreateIdentityInput; } | { kind: "retract"; identityId: string; }; export interface MutateIdentityInput { sourceBindingId: string; clientCommandId: string; roomId: string; correlationId?: string; occurredAt?: string; mutation: IdentityMutationCommand; } export interface IdentityMutationResult { record: IdentityRecord; event: StoredEventRecord; } export interface IdentityMutationOutcome { result: IdentityMutationResult; disposition: "accepted" | "replayed"; } export interface IdentityQuery { subjectActorId?: string; authorActorId?: string; kind?: string; text?: string; includeHistory?: boolean; /** Offset in deterministic result order; use against a mutation-free snapshot. */ cursor?: number; limit?: number; } export type SupervisionTurnRole = "worker" | "observer"; export interface SupervisionPairRecord { pairId: string; roomId: string; correlationId: string; sourceEventId: string; watchEventId: string; pairEventId: string; mode: "live_steer"; createdAt: string; } export interface SupervisionPairTurnRecord { pairId: string; turnId: string; role: SupervisionTurnRole; actorId: string; createdAt: string; } export interface AssistantConversationMessageRecord { messageId: string; role: "user" | "assistant"; content: string; createdAt: string; clientCommandId?: string; } export interface AppendAssistantMessageInput { messageId?: string; role: "user" | "assistant"; content: string; createdAt?: string; clientCommandId?: string; } export interface ContextResetRecord { resetId: string; roomId: string; throughSeq: number; createdAt: string; resetNativeSessions: boolean; } export interface IntegrityCheckResult { ok: boolean; messages: string[]; } export interface GroupXStore { readonly databasePath: string; getSchemaVersion(): number; getJournalMode(): string; upsertActor(input: UpsertActorInput): ActorRecord; getActor(actorId: string): ActorRecord | undefined; listActors(): ActorRecord[]; createAgentInstance(input: CreateAgentInstanceInput): AgentInstanceRecord; getAgentInstance(instanceId: string): AgentInstanceRecord | undefined; finishAgentInstance(instanceId: string, input: FinishAgentInstanceInput): AgentInstanceRecord; createSessionBinding(input: CreateSessionBindingInput): SessionBindingRecord; getSessionBinding(bindingId: string): SessionBindingRecord | undefined; listSessionBindings(): SessionBindingRecord[]; markSessionBindingReady(bindingId: string, input?: MarkSessionBindingReadyInput): SessionBindingRecord; markSessionBindingFailed(bindingId: string, input?: MarkSessionBindingFailedInput): SessionBindingRecord; closeSessionBinding(bindingId: string, closedAt?: string): SessionBindingRecord; recoverStaleRuntimeRecords(now?: string): RuntimeRecoveryResult; getClientCommand(sourceBindingId: string, clientCommandId: string): ClientCommandRecord | undefined; beginClientCommand(input: BeginClientCommandInput): BeginClientCommandOutcome; completeClientCommand(input: CompleteClientCommandInput): TResult; acceptMessage(input: AcceptMessageInput): AcceptMessageResult; acceptMessageWithDisposition(input: AcceptMessageInput): AcceptMessageOutcome; getSupervisionPair(pairId: string): SupervisionPairRecord | undefined; getSupervisionPairByTurn(turnId: string): SupervisionPairRecord | undefined; getSupervisionPairByCorrelation(correlationId: string): SupervisionPairRecord | undefined; listSupervisionPairs(input?: { roomId?: string; correlationId?: string; }): SupervisionPairRecord[]; getSupervisionTurnRole(turnId: string): SupervisionTurnRole | undefined; listSupervisionPairTurns(pairId: string): SupervisionPairTurnRecord[]; appendAssistantMessage(input: AppendAssistantMessageInput): AssistantConversationMessageRecord; listAssistantMessages(limit?: number): AssistantConversationMessageRecord[]; getAssistantMessageByClientCommandId(clientCommandId: string): AssistantConversationMessageRecord | undefined; getAssistantReplyAfter(messageId: string): AssistantConversationMessageRecord | undefined; recordContextReset(input: { roomId: string; throughSeq: number; resetNativeSessions?: boolean; createdAt?: string; }): ContextResetRecord; getLatestContextResetThroughSeq(roomId: string): number; attachSupervisionWorkerTurn(input: { pairId: string; turnId: string; actorId: string; createdAt?: string; }): SupervisionPairTurnRecord; getSteerCount(subjectTurnId: string): number; incrementSteerCount(subjectTurnId: string, limit: number): number; appendDurableEvent(input: DurableEventInput): StoredEventRecord; getEvent(eventId: string): StoredEventRecord | undefined; listEvents(input: { roomId: string; afterSeq?: number; limit?: number; }): EventPage; getRoomHighWaterSeq(roomId: string): number; listEventsThrough(input: { roomId: string; afterSeq?: number; throughSeq: number; limit?: number; }): EventPage; readRoomBootstrapSnapshot(input: { roomId: string; recentLimit?: number; }): RoomBootstrapSnapshot; countEvents(roomId?: string): number; enqueueTurn(input: EnqueueTurnInput): TurnRecord; getTurn(turnId: string): TurnRecord | undefined; listTurns(input?: { status?: TurnStatus; targetActorId?: string; rootCorrelationId?: string; sourceEventId?: string; }): TurnRecord[]; countTurns(): number; claimNextQueuedTurn(input: { targetActorId: string; bindingId: string; instanceId: string; contextThroughSeq: number; summaryThroughSeq?: number; expectedTurnId: string; expectedTransport: RuntimeTransport; claimedAt?: string; }): ClaimedTurn | undefined; getTurnAttempt(attemptId: string): TurnAttemptRecord | undefined; listTurnAttempts(turnId: string): TurnAttemptRecord[]; markPromptInvoked(attemptId: string, invokedAt?: string): ClaimedTurn; bindAttemptNativeTurnId(attemptId: string, nativeTurnId: string): ClaimedTurn; markAttemptRunning(attemptId: string, nativeTurnId?: string, startedAt?: string): ClaimedTurn; requestTurnCancellation(turnId: string): TurnRecord; cancelQueuedTurn(turnId: string, occurredAt?: string): TerminalTurnResult; failQueuedTurn(turnId: string, errorCode: string, occurredAt?: string, eventBody?: JsonObject): TerminalTurnResult; saveTurnPartialText(turnId: string, partialText: string): TurnRecord; terminalizeTurn(input: TerminalTurnInput): TerminalTurnResult; getAgentDatedMemoryRollup(input: { roomId: string; actorId: string; localDate: string; }): AgentDatedMemoryRollupRecord | undefined; listAgentDatedMemoryRollups(input?: { roomId?: string; actorId?: string; pendingOnly?: boolean; }): AgentDatedMemoryRollupRecord[]; listAgentDatedMemorySources(input: { roomId: string; actorId: string; localDate: string; pendingOnly?: boolean; limit?: number; }): AgentDatedMemorySourceRecord[]; commitAgentDatedMemoryRollup(input: CommitAgentDatedMemoryRollupInput): CommitAgentDatedMemoryRollupResult; recordAgentDatedMemoryRollupFailure(input: RecordAgentDatedMemoryRollupFailureInput): AgentDatedMemoryRollupRecord; getDeliveryCursor(actorId: string, roomId: string): DeliveryCursorRecord | undefined; getActiveSummary(roomId: string, throughSeq?: number): SummaryRecord | undefined; listSummaries(input: { roomId: string; includeHistory?: boolean; limit?: number; }): SummaryRecord[]; replaceActiveSummary(input: ReplaceRoomSummaryInput): SummaryRecord; recoverAfterRestart(now?: string): RecoveryResult; rememberMemory(input: CreateMemoryInput): MemoryRecord; mutateMemoryWithDisposition(input: MutateMemoryInput): MemoryMutationOutcome; getMemory(memoryId: string): MemoryRecord | undefined; supersedeMemory(memoryId: string, replacement: CreateMemoryInput): MemoryRecord; retractMemory(memoryId: string, retractedAt?: string): MemoryRecord; searchMemory(input?: MemoryQuery): MemoryRecord[]; rememberIdentity(input: CreateIdentityInput): IdentityRecord; mutateIdentityWithDisposition(input: MutateIdentityInput): IdentityMutationOutcome; getIdentity(identityId: string): IdentityRecord | undefined; supersedeIdentity(identityId: string, replacement: CreateIdentityInput): IdentityRecord; retractIdentity(identityId: string, retractedAt?: string): IdentityRecord; readIdentity(input?: IdentityQuery): IdentityRecord[]; integrityCheck(): IntegrityCheckResult; close(): void; } //# sourceMappingURL=types.d.ts.map