Public declaration syntax from forge-ts/packages/forge-collab/src/roles.ts Original source SHA-256: f6aa5cf9195b736a639e7734b4eee3cea2da9323b2e88a57f60e0ac5b74764f1 Function bodies and constant values are omitted. This is not the complete implementation. Source line 29 export interface CoordinatorContract { /** * Decomposes a high-level task into smaller sub-tasks. * * @param task - The task to decompose. * @returns A list of sub-tasks derived from the original task. * @throws {CollabError} DelegationFailed if the task cannot be decomposed. */ decomposeTask(task: DelegatedTask): Promise; /** * Assigns a task to a specific worker agent. * * @param task - The task to assign. * @param workerDid - The OAS DID of the target worker. * @returns A TaskAcknowledgment from the worker. * @throws {CollabError} CapabilityMismatch or DelegationFailed. */ assignTask( task: DelegatedTask, workerDid: string ): Promise; /** * Aggregates results from multiple worker tasks into a single result. * * @param results - The results from all completed sub-tasks. * @returns A single aggregated TaskResult. * @throws {CollabError} DelegationFailed if results cannot be aggregated. */ aggregateResults(results: readonly TaskResult[]): Promise; /** * Handles a failure reported by a worker. * * @param taskId - The ID of the failed task. * @param workerDid - The DID of the worker that failed. * @param error - A description of the failure. * @throws {CollabError} DelegationFailed if recovery is not possible. */ handleWorkerFailure( taskId: string, workerDid: string, error: string ): Promise; } Source line 86 export interface WorkerContract { /** * Called when a task is delegated to this worker. * * @param task - The delegated task to evaluate. * @returns A TaskAcknowledgment indicating acceptance or rejection. */ onTaskDelegated(task: DelegatedTask): Promise; /** * Reports progress on an in-flight task. * * @param progress - The progress report. * @throws {CollabError} TaskNotFound if the task ID is unknown. */ reportProgress(progress: TaskProgress): Promise; /** * Submits the result of a completed task. * * @param result - The task result to submit. * @throws {CollabError} TaskNotFound if the task ID is unknown. */ submitResult(result: TaskResult): Promise; /** * Called when a task is cancelled by the coordinator. * * @param taskId - The ID of the cancelled task. * @param reason - A human-readable cancellation reason. */ onTaskCancelled(taskId: string, reason: string): Promise; } Source line 129 export interface PeerContract { /** * Submits a proposal for peer consensus. * * @param proposal - The proposal data to submit for voting. * @returns A unique proposal ID string. */ propose(proposal: unknown): Promise; /** * Votes on an existing proposal. * * @param proposalId - The ID of the proposal to vote on. * @param approve - true to approve, false to reject. */ vote(proposalId: string, approve: boolean): Promise; /** * Called when consensus is reached on a proposal. * * @param proposalId - The ID of the proposal that reached consensus. * @param result - The consensus result data. */ onConsensus(proposalId: string, result: unknown): Promise; }