/** * Society Protocol — Chain of Collaboration (CoC) Engine v1.0 * * State-of-the-art features: * - Complete DAG execution engine * - Lease-based fault tolerance with automatic handoff * - Reputation-aware agent selection * - Multi-criteria consensus * - Dynamic DAG expansion hooks * - Comprehensive event logging */ import { EventEmitter } from 'events'; import { type Identity } from './identity.js'; import { type RoomManager } from './rooms.js'; import { type Storage } from './storage.js'; import { type ReputationEngine } from './reputation.js'; import type { CocDagNode, CocMergeBody, Artifact, StepRequirements } from './swp.js'; export type ChainStatus = 'open' | 'running' | 'completed' | 'failed' | 'cancelled'; export type StepStatus = 'proposed' | 'assigned' | 'submitted' | 'reviewed' | 'merged' | 'rejected' | 'cancelled'; export interface CocStep { step_id: string; chain_id: string; kind: 'task' | 'review' | 'merge' | 'decision' | 'synthesis' | 'verification'; title: string; description?: string; status: StepStatus; depends_on: string[]; requirements?: StepRequirements; assigned_to?: string; lease_expires_at?: number; submitted_at?: number; result_memo?: string; artifacts?: string[]; retries?: number; max_retries?: number; assignee_did?: string; } export interface CocChain { chain_id: string; room_id: string; goal: string; template_id?: string; status: ChainStatus; priority: 'low' | 'normal' | 'high' | 'critical'; created_by: string; created_at: number; closed_at?: number; timeout_at?: number; final_report?: string; steps: CocStep[]; } export interface StepAssignment { chain_id: string; step_id: string; assignee_did: string; lease_ms: number; lease_started_at: number; } export interface ConsensusConfig { type: 'single' | 'multi' | 'weighted' | 'majority'; approvers?: string[]; required?: number; threshold?: number; weights?: Record; } export declare class CocEngine extends EventEmitter { private identity; private rooms; private storage; private reputation?; private activeChains; private leaseMonitorInterval?; constructor(identity: Identity, rooms: RoomManager, storage: Storage, reputation?: ReputationEngine); private bindEvents; openChain(roomId: string, goal: string, options?: { priority?: 'low' | 'normal' | 'high' | 'critical'; templateId?: string; timeoutMs?: number; privacyLevel?: 'public' | 'encrypted' | 'private'; }): Promise; private handleChainOpen; publishPlan(roomId: string, chainId: string, dag: CocDagNode[], plannerVersion?: string): Promise; private handlePlan; private applyPlan; assignStep(roomId: string, chainId: string, stepId: string, assigneeDid: string, leaseMs?: number, leaseType?: 'exclusive' | 'shared'): Promise; private handleAssign; submitStep(roomId: string, chainId: string, stepId: string, status: 'completed' | 'failed' | 'partial', memo: string, artifacts: Artifact[], metrics?: { tokens_used?: number; latency_ms?: number; cost?: number; }): Promise; private handleSubmit; reviewStep(roomId: string, chainId: string, stepId: string, decision: 'approved' | 'rejected' | 'needs_revision' | 'escalated', notes: string, options?: { suggestions?: string[]; qualityScore?: number; }): Promise; private handleReview; mergeChain(roomId: string, chainId: string, summary: string, outputs: string[], options?: { qualityScore?: number; lessonsLearned?: string[]; metrics?: CocMergeBody['metrics']; }): Promise; private handleMerge; closeChain(roomId: string, chainId: string, reason: 'completed' | 'cancelled' | 'timeout' | 'failed', finalReport?: string): Promise; private handleClose; private handleHandoff; private handleCancel; private handleAdapterLeaseRequest; private handleAdapterSubmitRequest; private evaluateChain; private startLeaseMonitor; private checkExpiredLeases; private validateDag; private getActiveStep; selectOptimalAgent(step: CocStep, candidates: string[]): Promise; getChain(chainId: string): CocChain | null; getActiveChains(): CocChain[]; getStep(stepId: string): CocStep | undefined; destroy(): void; } //# sourceMappingURL=coc.d.ts.map