import type { MastraDBMessage, MessageList } from '@mastra/core/agent/message-list'; import type { ComputeStateSignalArgs, ComputeStateSignalResult, ProcessInputArgs, ProcessInputStepArgs, Processor } from '@mastra/core/processors'; import type { BoardRegistry } from '../boards/index.js'; import type { FactoryRunBindingRecord, WorkItemsStorage, WorkItemRow } from '../storage/domains/work-items/base.js'; import type { FactoryTransitionService } from './transition-service.js'; import type { FactoryRuleJsonValue } from './types.js'; type PersistedMessageReader = { listMessages(input: { threadId: string; resourceId?: string; page: number; perPage: number; filter?: { dateRange?: { start?: Date; }; }; orderBy: { field: 'createdAt'; direction: 'ASC'; }; }): Promise<{ messages: MastraDBMessage[]; hasMore: boolean; }>; }; /** * Marks this run's Factory memory settings as unavailable so memory falls back * to auto, and tells the thread once per request that saved choices were not * applied. The reserved request-context key keeps clients from spoofing it. */ export declare function reportMemorySettingsUnavailable(requestContext: NonNullable, reason: string): void; export declare class FactoryPhaseStateProcessor implements Processor<'factory-phase'> { private readonly options; readonly id = "factory-phase"; readonly stateId = "factory-phase"; /** Request contexts whose caller row is already resolved for this request. */ private readonly loadedMemorySettings; constructor(options: { configVersion: string; storage: WorkItemsStorage; boards: BoardRegistry; loadMemorySettings?: (args: { requestContext: ProcessInputStepArgs['requestContext']; binding: FactoryRunBindingRecord | null; }) => Promise; transitionService?: Pick; messageReader?: PersistedMessageReader; recordPullRequestProvenance?: (input: { binding: FactoryRunBindingRecord; item: WorkItemRow; assistantMessageId: string; toolCallId: string; toolName: string; toolInput: FactoryRuleJsonValue; toolResult: FactoryRuleJsonValue; status: 'success' | 'error'; }) => Promise; }); /** * Memory settings are caller state, not run state. Factory invokes this while * resolving its configured processor list, before Agent resolves dynamic * Memory and enumerates Memory's processors. This guarantees both the Memory * options and its model callbacks see the authoritative row for this * invocation. Doing this in `processInputStep` would be too late: Memory's * input-step hook runs before configured processors. */ prepareMemorySettings(requestContext: ProcessInputArgs['requestContext']): Promise; processInput(args: ProcessInputArgs): Promise; processInputStep(args: ProcessInputStepArgs): Promise; /** * Loads the caller's row once per invocation. The input hook always refreshes * it in case the controller reused a request context; later step hooks reuse * that value (`undefined` means it has not been loaded yet; `null` means an * empty row). * * The WeakSet covers loaders that do not set the context key themselves, so a * request is still loaded once. A failed load records an unavailable sentinel * (memory then runs both roles on auto with default thresholds) and is not * marked loaded so the next step can retry. */ private loadCallerMemorySettings; computeStateSignal(args: ComputeStateSignalArgs): Promise; reconcileAllBoundThreads(): Promise; reconcileBinding(binding: FactoryRunBindingRecord): Promise; private ingestMessages; private ingestToolResult; } export {}; //# sourceMappingURL=processor.d.ts.map