import type { TenantId } from '../../types/ids/index.js'; import { type ResidentDecision, type ResidentExecutionStore, type ResidentState } from './store.js'; import { type ResidentActivitySource } from './activity.js'; import { type ResidentHistorySource } from './history.js'; import { type ResidentFeedback, type ResidentObservation } from './initiative.js'; import { type ResidentLearningEvidence, type ResidentLearningState, type ResidentProfileUpdate, type ResidentSkillCandidate, type ResidentSkillEvaluation } from './learning.js'; import { type ResidentDeliveryOutcome, type ResidentMessageInput, type ResidentOutboxMessage } from './outbox.js'; import { type ResidentProposal, type ResidentProposalLimits, type ResidentProposalOrigin } from './proposal.js'; /** @experimental One pursuit shares its agent's identity, but has its own lifecycle. */ export interface ResidentPursuit { readonly id: string; readonly state: ResidentState; readonly feedback?: ResidentFeedback; readonly origin?: ResidentProposalOrigin; /** Archived direct children still consume the parent's lifetime admission bound. */ readonly retiredChildren?: number; } /** @experimental Bounded shared admission record; at most one pursuit may be running. */ export interface ResidentAgendaState { readonly tenantId: string; readonly agentKey: string; readonly identity: string; readonly revision: number; readonly paused: boolean; /** Durable pause requests; absent means zero. Resuming never resets this generation. */ readonly pauseGeneration?: number; readonly pursuits: readonly ResidentPursuit[]; readonly outbox?: readonly ResidentOutboxMessage[]; readonly archiveHead?: number; readonly learning?: ResidentLearningState; } /** @experimental Explicit terminal entries to retire from active capacity together. */ export interface ResidentArchiveRequest { readonly pursuitIds?: readonly string[]; readonly messageIds?: readonly string[]; } /** @experimental A committed removal, whose immutable predecessor preserves the full records. */ export interface ResidentArchiveEntry { readonly revision: number; readonly pursuits: readonly ResidentPursuit[]; readonly messages: readonly ResidentOutboxMessage[]; } /** @experimental Pages count archive events; each event contains at most 32 pursuits and 128 messages. */ export interface ResidentArchivePage { readonly entries: readonly ResidentArchiveEntry[]; readonly nextBeforeRevision: number | null; } /** @experimental The cursor is the next archive-event revision returned by a previous page. */ export interface ResidentArchiveListOptions { readonly beforeRevision?: number; /** Number of archive events to inspect; defaults to 8 and cannot exceed 32. */ readonly limit?: number; } /** @experimental Atomic whole-agent admission plus independently addressable pursuits. */ export interface ResidentAgendaStore { read(): Promise; create(identity: string): Promise; add(expected: ResidentAgendaState, objective: string): Promise; /** Each committed true request advances pauseGeneration, even when already paused. */ setPaused(expected: ResidentAgendaState, paused: boolean): Promise; wake(id: string, expected: ResidentState, reason: string, now: number): Promise; execution(id: string): ResidentExecutionStore; /** Optional atomic extensions required by a configured resident initiative host. */ executionAt?(id: string, expected: ResidentAgendaState): ResidentExecutionStore; settleObserved?(id: string, expected: ResidentState, decision: ResidentDecision, observation: ResidentObservation, now: number): Promise; /** Optional atomic settlement and outbound intent; no transport runs during persistence. */ settleWithMessage?(id: string, expected: ResidentState, decision: ResidentDecision, message: ResidentMessageInput, now: number, observation?: ResidentObservation): Promise; enqueueMessage?(expected: ResidentAgendaState, input: ResidentMessageInput): Promise; claimMessage?(expected: ResidentAgendaState, id: string, now: number): Promise; settleMessage?(expected: ResidentOutboxMessage, outcome: ResidentDeliveryOutcome, now: number): Promise; } /** * @experimental One immutable revision contains identity, pause state and all * pursuits. Admission therefore serializes this agent even across processes * choosing different pursuits. Trusted local filesystems only; no lease expiry. */ export declare class DiskResidentAgenda implements ResidentAgendaStore { private readonly records; private readonly historyRecords; private readonly location; private readonly tenantId; private readonly agentKey; private readonly historyRoot; private readonly historyRevisions; constructor(root: string, scope: { tenantId: TenantId; agentKey: string; }); private checked; read(): Promise; /** Read one authoritative immutable commit, never the compatibility projection. */ readRevision(revision: number): Promise; /** * Bind bounded historical reads to this pursuit and a host-selected upper * agenda revision (normally ResidentStepContext.agendaRevision). No I/O or * inference occurs until search/read; the boundary never advances itself. */ history(pursuit: ResidentState, throughRevision: number): ResidentHistorySource; /** @experimental Bounded admission/settlement history, including archived pursuits. */ activity(throughRevision: number): ResidentActivitySource; private retire; /** Free active slots while preserving full records in the immutable predecessor commit. */ archive(expected: ResidentAgendaState, input: ResidentArchiveRequest): Promise; private archiveEntry; /** Bounded archive-event pages; exact-ID deduplication may inspect the complete chain. */ listArchived(options?: ResidentArchiveListOptions): Promise; private archivedMatch; private assertArchivedIntent; create(identity: string): Promise; private change; private pursuit; add(expected: ResidentAgendaState, objective: string): Promise; /** Host-approved proposal admission is atomic and inert until a future invocation. */ admitProposal(expected: ResidentAgendaState, input: ResidentProposal, limits: ResidentProposalLimits): Promise; setPaused(expected: ResidentAgendaState, paused: boolean): Promise; private learn; /** Append a host-evidenced correction only while pursuit admission is idle. */ updateProfile(expected: ResidentAgendaState, input: ResidentProfileUpdate): Promise; /** Bind evaluated guidance to the current learning version and an idle agenda. */ promoteSkill(expected: ResidentAgendaState, candidate: ResidentSkillCandidate, evaluation: ResidentSkillEvaluation, evidence: ResidentLearningEvidence): Promise; /** Restore one skill from an immutable agenda revision while retaining the current profile. */ rollbackSkill(expected: ResidentAgendaState, name: string, fromRevision: number, evidence: ResidentLearningEvidence): Promise; private updatePursuit; wake(id: string, expected: ResidentState, reason: string, now: number): Promise; settleObserved(id: string, expected: ResidentState, decision: ResidentDecision, observation: ResidentObservation, now: number): Promise; /** Commit the step, observation and message intent together; delivery is separate. */ settleWithMessage(id: string, expected: ResidentState, decision: ResidentDecision, message: ResidentMessageInput, now: number, observation?: ResidentObservation): Promise; /** Enqueue host-authorized intent without invoking a transport or changing pursuit state. */ enqueueMessage(expected: ResidentAgendaState, input: ResidentMessageInput): Promise; /** Admit one delivery against the same agenda snapshot used by the host's gate. */ claimMessage(expected: ResidentAgendaState, id: string, now: number): Promise; /** Settle the exact delivery claim; unrelated agenda writes never repeat the transport. */ settleMessage(expected: ResidentOutboxMessage, outcome: ResidentDeliveryOutcome, now: number): Promise; executionAt(id: string, expected: ResidentAgendaState): ResidentExecutionStore; execution(id: string): ResidentExecutionStore; } //# sourceMappingURL=agenda.d.ts.map