import type { GoalNode, GoalStatus, GoalPriority } from './knowledge-graph.js'; import type { KnowledgeGraph } from './knowledge-graph.js'; import type { FleetBus } from './fleet-bus.js'; import type { Mailbox } from './mailbox-types.js'; export type { GoalStatus, GoalPriority }; export interface TaskBid { id: string; taskId: string; agentId: string; agentName: string; agentRole: string; /** Dispatcher score for this task */ score: number; /** Why this agent is a good fit */ rationale: string; submittedAt: string; } export interface TaskAuctionOptions { graph: KnowledgeGraph; fleet?: FleetBus | undefined; mailbox?: Mailbox | undefined; selfAgentId?: string | undefined; /** How long a bid window stays open before auto-awarding. Default: 30s */ bidWindowMs?: number | undefined; /** Maximum concurrent tasks per agent. Default: 3 */ maxTasksPerAgent?: number | undefined; /** Minimum confidence threshold for dispatcher scoring. Default: 0.3 */ minConfidence?: number | undefined; /** * Maximum times a task can be republished when no bids are received. * After this, the task is marked as 'failed' with reason 'no_bids'. * Default: 3. */ maxBidRetries?: number | undefined; } export declare class TaskAuctioneer { private readonly graph; private readonly fleet?; private readonly mailbox?; private readonly selfAgentId; private readonly bidWindowMs; private readonly maxTasksPerAgent; private readonly minConfidence; private readonly maxBidRetries; /** Pending bids keyed by taskId. */ private readonly pendingBids; /** Active bid windows keyed by taskId. */ private readonly bidTimers; /** FleetBus subscription disposers, detached in dispose(). */ private readonly unsubs; /** How many times a task has been republished with no bids received. */ private readonly bidRetryCounts; /** Agent → current task count (from graph + in-flight). */ private readonly agentTaskCounts; constructor(opts: TaskAuctionOptions); /** * Detach all FleetBus subscriptions and cancel any open bid-window timers. * Call when the owning coordinator stops/restarts so handlers and timers * don't accumulate across cycles. */ dispose(): void; /** * Publish a new task to the auction. Creates a GoalNode and broadcasts * it to all online agents. Returns the goal id. * * If `targetAgent` is specified, the task is assigned directly without auction. */ publishTask(input: { title: string; description: string; priority?: GoalPriority; tags?: string[]; targetAgent?: string; parentGoal?: string; satisfiesGoals?: string[]; /** Goal ids that must reach 'done' before this goal becomes workable. */ blockedBy?: string[]; deadline?: string; reward?: string; }): Promise; /** * Submit a bid for a task. Called by agents who want to work on it. * Returns true if the bid was accepted, false if the task was already claimed. */ bid(taskId: string, agent: { agentId: string; agentName: string; agentRole: string; }, rationale: string): Promise; /** * Award a task to a specific agent. Called internally by the bid window * expiry, or can be called directly to force an award. */ claim(taskId: string, agentId: string, agentName: string): Promise; /** * Mark a task as done. Called by the agent when it finishes. */ complete(taskId: string, _result?: string): Promise; /** * Mark a task as failed. Optionally spawn a retry. */ fail(taskId: string, error: string): Promise; /** * Find the best available tasks for an agent based on its capabilities. * Returns tasks sorted by match score (best first). */ findWork(_agentId: string, agentRole: string, limit?: number): Promise<{ task: GoalNode; score: number; bids: number; }[]>; /** Get all pending tasks (available for bidding). */ getPendingTasks(): GoalNode[]; /** Get tasks assigned to a specific agent. */ getTasksForAgent(agentId: string): GoalNode[]; /** Get the current bid count for a task. */ getBidCount(taskId: string): number; /** Get bids for a task. */ getBids(taskId: string): TaskBid[]; /** Get task stats for a project-wide dashboard. */ getStats(): { total: number; pending: number; in_progress: number; done: number; failed: number; totalBids: number; avgBidsPerTask: number; }; private _emit; private _broadcastTask; private _mailboxPublish; private _notifyAgent; private _startBidWindow; private _cancelBidWindow; private _evaluateBids; private _assignDirect; private _onBidEvent; private _onClaimedEvent; private _getAgentTaskCount; private agentTaskCount; } //# sourceMappingURL=task-auctioneer.d.ts.map