import type { MastraCodeState } from '@mastra/code-sdk/schema'; import type { AgentController, Session } from '@mastra/core/agent-controller'; import type { BoardRegistry } from '../boards/index.js'; import type { AuditRecorder } from '../storage/domains/audit/domain.js'; import type { FactoryFeedReader } from '../storage/domains/comments/feed-context.js'; import type { FactoryDeferredDecisionRecord, FactoryRunBindingRecord, WorkItemRow, WorkItemsStorage } from '../storage/domains/work-items/base.js'; import type { FactoryTransitionService } from './transition-service.js'; import type { FactoryCommitDecision } from './types.js'; type FactoryController = Pick, 'getSessionByResource' | 'listActiveThreadRuns'>; type BoundDispatcherSession = Session; export interface FactoryBindingPreparationInput { record: FactoryDeferredDecisionRecord; item: WorkItemRow; role: string; } export interface FactoryDecisionDispatcherOptions { audit?: AuditRecorder; controller: FactoryController; transitionService: Pick; storage: WorkItemsStorage; /** Installed boards; defaults to the built-in Work and Review boards. */ boards?: BoardRegistry; ownerId?: string; /** `false` parks `invokeSkill` effects as `proposed`; every other effect still runs. */ isAutoRunEnabled: (tenant: { orgId: string; factoryProjectId: string; }) => Promise; /** `true` lets the dispatcher answer a run's plan itself, so started work carries to Done. */ autoApprovePlans?: (tenant: { orgId: string; factoryProjectId: string; }) => Promise; reconcileToolResults?: () => Promise; prepareBinding?: (input: FactoryBindingPreparationInput) => Promise; /** * Re-applies the factory project's current observational-memory settings to a * reused session before it runs. Fresh preparation hydrates these settings, * but a reused binding keeps the models it was created with; without this a * project whose OM models changed keeps observing with the stale ones. */ refreshManagedMemorySettings?: (input: { binding: FactoryRunBindingRecord; session: BoundDispatcherSession; }) => Promise; primeCredentials?: (tenant: { orgId: string; userId: string; }) => Promise; /** Injects the work item's recent comments into skill-invocation kickoffs. */ feedReader?: FactoryFeedReader; resolveLinkedWorkItemParentId?: (input: { orgId: string; factoryProjectId: string; decision: Extract; }) => Promise; maxInFlight?: number; /** How often the stale-binding sweep runs. Defaults to 10 minutes. */ staleBindingSweepIntervalMs?: number; /** Active bindings older than this are revoked by the sweep. Defaults to 24 hours. */ staleBindingTtlMs?: number; /** How often the bound-thread reconcile walk runs. Defaults to 30 seconds. */ reconcileIntervalMs?: number; /** * How long a run the registry still shows in flight is observed before it fails as overdue. Defaults to 6 hours. * A run the registry no longer shows fails for retry at the next ten-minute heartbeat instead. */ skillCompletionObservationTimeoutMs?: number; } export declare class FactoryDecisionDispatcher { #private; constructor(options: FactoryDecisionDispatcherOptions); start(): void; stop(): Promise; runOnce(now?: Date): Promise; } export declare const FACTORY_DISPATCH_CONSTANTS: { readonly leaseMs: 30000; readonly pollMs: 1000; readonly batchSize: 10; readonly maxAttempts: 5; readonly maxErrorLength: 512; readonly maxBackoffMs: 60000; readonly skillCompletionObservationTimeoutMs: number; readonly runRegistryHeartbeatMs: number; readonly maxInFlight: 25; readonly stages: readonly ["intake", "triage", "planning", "execute", "review", "done", "canceled"]; }; export {}; //# sourceMappingURL=dispatcher.d.ts.map