import { type TraceEmitter } from "../../shared/observability/request-context.js"; import type { NegotiationGraphDatabase, OpportunityStatus, NegotiationContinuationReceipt } from "../../shared/interfaces/database.interface.js"; import type { NegotiationTimeoutQueue } from "../../shared/interfaces/negotiation-events.interface.js"; import type { AgentDispatcher } from "../../shared/interfaces/agent-dispatcher.interface.js"; import { type NegotiationTurn, type NegotiationOutcome, type UserNegotiationContext, type NegotiationGraphLike } from "../domain/negotiation.state.js"; import { type NegotiationConsultationReason } from "../domain/negotiation.consultation-policy.js"; import { type ScreenDecisionRecord } from "./negotiation.screen.js"; import { type DeadlockShiftRecord } from "../domain/negotiation.deadlock.js"; import type { NegotiationProtocolVersion } from "../../shared/schemas/negotiation-state.schema.js"; import type { QuestionerEnqueueFn } from "../../capabilities/questions.enqueue.facade.js"; import type { ReflectEnqueueFn } from "./negotiation.reflect.js"; import type { NegotiatorMemoryEntry, NegotiatorMemoryRetrieveFn } from "../domain/negotiation.memory.js"; /** * Factory for the bilateral negotiation LangGraph state machine. * @remarks Accepts an AgentDispatcher for per-turn agent resolution. */ export declare class NegotiationGraphFactory { private database; private dispatcher; private timeoutQueue?; private questionerEnqueue?; private reflectEnqueue?; private memoryRetrieve?; constructor(database: NegotiationGraphDatabase, dispatcher: AgentDispatcher, timeoutQueue?: NegotiationTimeoutQueue | undefined, questionerEnqueue?: QuestionerEnqueueFn | undefined, reflectEnqueue?: ReflectEnqueueFn | undefined, memoryRetrieve?: NegotiatorMemoryRetrieveFn | undefined); createGraph(): import("@langchain/langgraph").CompiledStateGraph<{ sourceUser: UserNegotiationContext; candidateUser: UserNegotiationContext; sourceIntentId: string | undefined; candidateIntentId: string | undefined; indexContext: { networkId: string; prompt: string; }; seedAssessment: import("../domain/negotiation.state.js").SeedAssessment; initiatorUserId: string | undefined; discoveryQuery: string | undefined; protocolVersion: NegotiationProtocolVersion; screenDecision: ScreenDecisionRecord | null; deadlockShift: DeadlockShiftRecord | null; memoryBySide: Partial>; isContinuation: boolean; priorAttribution: unknown; outreachOpened: boolean; firstTurnScreenedOut: boolean; opportunityId: string; opportunityStatus: OpportunityStatus | undefined; opportunityUpdatedAt: Date | undefined; resumeFromTaskId: string | undefined; continuationSettlementId: string | undefined; continuationExecution: import("../../shared/interfaces/database.interface.js").NegotiationContinuationExecution | undefined; continuationReceipt: NegotiationContinuationReceipt | undefined; privateConsultation: import("../../shared/interfaces/database.interface.js").NegotiationPrivateConsultation | undefined; consultationPolicyReason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | undefined; conversationId: string; taskId: string; messages: import("../domain/negotiation.state.js").NegotiationMessage[]; turnCount: number; maxTurns: number | undefined; timeoutMs: number; currentSpeaker: "source" | "candidate"; lastTurn: { action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | null; status: "waiting_for_agent" | "input_required" | "completed" | "active"; priorTurnCount: number; userAnswers: import("../../shared/interfaces/database.interface.js").NegotiationUserAnswer[]; outcome: { reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | null; error: string | null; }, { sourceUser?: UserNegotiationContext | import("@langchain/langgraph").OverwriteValue | undefined; candidateUser?: UserNegotiationContext | import("@langchain/langgraph").OverwriteValue | undefined; sourceIntentId?: string | import("@langchain/langgraph").OverwriteValue | undefined; candidateIntentId?: string | import("@langchain/langgraph").OverwriteValue | undefined; indexContext?: { networkId: string; prompt: string; } | import("@langchain/langgraph").OverwriteValue<{ networkId: string; prompt: string; }> | undefined; seedAssessment?: import("../domain/negotiation.state.js").SeedAssessment | import("@langchain/langgraph").OverwriteValue | undefined; initiatorUserId?: string | import("@langchain/langgraph").OverwriteValue | undefined; discoveryQuery?: string | import("@langchain/langgraph").OverwriteValue | undefined; protocolVersion?: NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue | undefined; screenDecision?: ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue | null | undefined; deadlockShift?: DeadlockShiftRecord | import("@langchain/langgraph").OverwriteValue | null | undefined; memoryBySide?: Partial> | import("@langchain/langgraph").OverwriteValue>> | undefined; isContinuation?: boolean | import("@langchain/langgraph").OverwriteValue | undefined; priorAttribution?: unknown; outreachOpened?: boolean | import("@langchain/langgraph").OverwriteValue | undefined; firstTurnScreenedOut?: boolean | import("@langchain/langgraph").OverwriteValue | undefined; opportunityId?: string | import("@langchain/langgraph").OverwriteValue | undefined; opportunityStatus?: OpportunityStatus | import("@langchain/langgraph").OverwriteValue | undefined; opportunityUpdatedAt?: Date | import("@langchain/langgraph").OverwriteValue | undefined; resumeFromTaskId?: string | import("@langchain/langgraph").OverwriteValue | undefined; continuationSettlementId?: string | import("@langchain/langgraph").OverwriteValue | undefined; continuationExecution?: import("../../shared/interfaces/database.interface.js").NegotiationContinuationExecution | import("@langchain/langgraph").OverwriteValue | undefined; continuationReceipt?: NegotiationContinuationReceipt | import("@langchain/langgraph").OverwriteValue | undefined; privateConsultation?: import("../../shared/interfaces/database.interface.js").NegotiationPrivateConsultation | import("@langchain/langgraph").OverwriteValue | undefined; consultationPolicyReason?: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | import("@langchain/langgraph").OverwriteValue<"unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | undefined> | undefined; conversationId?: string | import("@langchain/langgraph").OverwriteValue | undefined; taskId?: string | import("@langchain/langgraph").OverwriteValue | undefined; messages?: import("../domain/negotiation.state.js").NegotiationMessage[] | import("@langchain/langgraph").OverwriteValue | undefined; turnCount?: number | import("@langchain/langgraph").OverwriteValue | undefined; maxTurns?: number | import("@langchain/langgraph").OverwriteValue | undefined; timeoutMs?: number | import("@langchain/langgraph").OverwriteValue | undefined; currentSpeaker?: "source" | "candidate" | import("@langchain/langgraph").OverwriteValue<"source" | "candidate"> | undefined; lastTurn?: { action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | import("@langchain/langgraph").OverwriteValue<{ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | null> | null | undefined; status?: "waiting_for_agent" | "input_required" | "completed" | "active" | import("@langchain/langgraph").OverwriteValue<"waiting_for_agent" | "input_required" | "completed" | "active"> | undefined; priorTurnCount?: number | import("@langchain/langgraph").OverwriteValue | undefined; userAnswers?: import("../../shared/interfaces/database.interface.js").NegotiationUserAnswer[] | import("@langchain/langgraph").OverwriteValue | undefined; outcome?: { reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | import("@langchain/langgraph").OverwriteValue<{ reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | null> | null | undefined; error?: string | import("@langchain/langgraph").OverwriteValue | null | undefined; }, "screen" | "turn" | "__start__" | "init" | "finalize", { sourceUser: import("@langchain/langgraph").BaseChannel, unknown>; candidateUser: import("@langchain/langgraph").BaseChannel, unknown>; sourceIntentId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; candidateIntentId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; indexContext: import("@langchain/langgraph").BaseChannel<{ networkId: string; prompt: string; }, { networkId: string; prompt: string; } | import("@langchain/langgraph").OverwriteValue<{ networkId: string; prompt: string; }>, unknown>; seedAssessment: import("@langchain/langgraph").BaseChannel, unknown>; initiatorUserId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; discoveryQuery: import("@langchain/langgraph").BaseChannel | undefined, unknown>; protocolVersion: import("@langchain/langgraph").BaseChannel, unknown>; screenDecision: import("@langchain/langgraph").BaseChannel | null, unknown>; deadlockShift: import("@langchain/langgraph").BaseChannel | null, unknown>; memoryBySide: import("@langchain/langgraph").BaseChannel>, Partial> | import("@langchain/langgraph").OverwriteValue>>, unknown>; isContinuation: import("@langchain/langgraph").BaseChannel, unknown>; priorAttribution: import("@langchain/langgraph").BaseChannel; outreachOpened: import("@langchain/langgraph").BaseChannel, unknown>; firstTurnScreenedOut: import("@langchain/langgraph").BaseChannel, unknown>; opportunityId: import("@langchain/langgraph").BaseChannel, unknown>; opportunityStatus: import("@langchain/langgraph").BaseChannel | undefined, unknown>; opportunityUpdatedAt: import("@langchain/langgraph").BaseChannel | undefined, unknown>; resumeFromTaskId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; continuationSettlementId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; continuationExecution: import("@langchain/langgraph").BaseChannel | undefined, unknown>; continuationReceipt: import("@langchain/langgraph").BaseChannel | undefined, unknown>; privateConsultation: import("@langchain/langgraph").BaseChannel | undefined, unknown>; consultationPolicyReason: import("@langchain/langgraph").BaseChannel<"unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | undefined, "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | import("@langchain/langgraph").OverwriteValue<"unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | undefined> | undefined, unknown>; conversationId: import("@langchain/langgraph").BaseChannel, unknown>; taskId: import("@langchain/langgraph").BaseChannel, unknown>; messages: import("@langchain/langgraph").BaseChannel, unknown>; turnCount: import("@langchain/langgraph").BaseChannel, unknown>; maxTurns: import("@langchain/langgraph").BaseChannel | undefined, unknown>; timeoutMs: import("@langchain/langgraph").BaseChannel, unknown>; currentSpeaker: import("@langchain/langgraph").BaseChannel<"source" | "candidate", "source" | "candidate" | import("@langchain/langgraph").OverwriteValue<"source" | "candidate">, unknown>; lastTurn: import("@langchain/langgraph").BaseChannel<{ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | null, { action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | import("@langchain/langgraph").OverwriteValue<{ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | null> | null, unknown>; status: import("@langchain/langgraph").BaseChannel<"waiting_for_agent" | "input_required" | "completed" | "active", "waiting_for_agent" | "input_required" | "completed" | "active" | import("@langchain/langgraph").OverwriteValue<"waiting_for_agent" | "input_required" | "completed" | "active">, unknown>; priorTurnCount: import("@langchain/langgraph").BaseChannel, unknown>; userAnswers: import("@langchain/langgraph").BaseChannel, unknown>; outcome: import("@langchain/langgraph").BaseChannel<{ reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | null, { reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | import("@langchain/langgraph").OverwriteValue<{ reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | null> | null, unknown>; error: import("@langchain/langgraph").BaseChannel | null, unknown>; }, { sourceUser: import("@langchain/langgraph").BaseChannel, unknown>; candidateUser: import("@langchain/langgraph").BaseChannel, unknown>; sourceIntentId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; candidateIntentId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; indexContext: import("@langchain/langgraph").BaseChannel<{ networkId: string; prompt: string; }, { networkId: string; prompt: string; } | import("@langchain/langgraph").OverwriteValue<{ networkId: string; prompt: string; }>, unknown>; seedAssessment: import("@langchain/langgraph").BaseChannel, unknown>; initiatorUserId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; discoveryQuery: import("@langchain/langgraph").BaseChannel | undefined, unknown>; protocolVersion: import("@langchain/langgraph").BaseChannel, unknown>; screenDecision: import("@langchain/langgraph").BaseChannel | null, unknown>; deadlockShift: import("@langchain/langgraph").BaseChannel | null, unknown>; memoryBySide: import("@langchain/langgraph").BaseChannel>, Partial> | import("@langchain/langgraph").OverwriteValue>>, unknown>; isContinuation: import("@langchain/langgraph").BaseChannel, unknown>; priorAttribution: import("@langchain/langgraph").BaseChannel; outreachOpened: import("@langchain/langgraph").BaseChannel, unknown>; firstTurnScreenedOut: import("@langchain/langgraph").BaseChannel, unknown>; opportunityId: import("@langchain/langgraph").BaseChannel, unknown>; opportunityStatus: import("@langchain/langgraph").BaseChannel | undefined, unknown>; opportunityUpdatedAt: import("@langchain/langgraph").BaseChannel | undefined, unknown>; resumeFromTaskId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; continuationSettlementId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; continuationExecution: import("@langchain/langgraph").BaseChannel | undefined, unknown>; continuationReceipt: import("@langchain/langgraph").BaseChannel | undefined, unknown>; privateConsultation: import("@langchain/langgraph").BaseChannel | undefined, unknown>; consultationPolicyReason: import("@langchain/langgraph").BaseChannel<"unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | undefined, "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | import("@langchain/langgraph").OverwriteValue<"unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | undefined> | undefined, unknown>; conversationId: import("@langchain/langgraph").BaseChannel, unknown>; taskId: import("@langchain/langgraph").BaseChannel, unknown>; messages: import("@langchain/langgraph").BaseChannel, unknown>; turnCount: import("@langchain/langgraph").BaseChannel, unknown>; maxTurns: import("@langchain/langgraph").BaseChannel | undefined, unknown>; timeoutMs: import("@langchain/langgraph").BaseChannel, unknown>; currentSpeaker: import("@langchain/langgraph").BaseChannel<"source" | "candidate", "source" | "candidate" | import("@langchain/langgraph").OverwriteValue<"source" | "candidate">, unknown>; lastTurn: import("@langchain/langgraph").BaseChannel<{ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | null, { action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | import("@langchain/langgraph").OverwriteValue<{ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | null> | null, unknown>; status: import("@langchain/langgraph").BaseChannel<"waiting_for_agent" | "input_required" | "completed" | "active", "waiting_for_agent" | "input_required" | "completed" | "active" | import("@langchain/langgraph").OverwriteValue<"waiting_for_agent" | "input_required" | "completed" | "active">, unknown>; priorTurnCount: import("@langchain/langgraph").BaseChannel, unknown>; userAnswers: import("@langchain/langgraph").BaseChannel, unknown>; outcome: import("@langchain/langgraph").BaseChannel<{ reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | null, { reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | import("@langchain/langgraph").OverwriteValue<{ reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | null> | null, unknown>; error: import("@langchain/langgraph").BaseChannel | null, unknown>; }, import("@langchain/langgraph").StateDefinition, { init: { error: string; } | { messages?: { id: string; senderId: string; role: "agent"; parts: unknown[]; createdAt: Date; taskId: string | null; }[] | undefined; privateConsultation?: import("../../shared/interfaces/database.interface.js").NegotiationPrivateConsultation | undefined; userAnswers?: import("../../shared/interfaces/database.interface.js").NegotiationUserAnswer[] | undefined; priorAttribution?: import("../negotiation.attribution.js").SeededAttribution | undefined; conversationId: string; taskId: string; currentSpeaker: "source" | "candidate"; turnCount: number; maxTurns: number; isContinuation: boolean; initiatorUserId: string; protocolVersion: NegotiationProtocolVersion; priorTurnCount: number; error?: undefined; } | { messages?: { id: string; senderId: string; role: "agent"; parts: unknown[]; createdAt: Date; taskId: string | null; }[] | undefined; consultationPolicyReason: NegotiationConsultationReason; privateConsultation?: import("../../shared/interfaces/database.interface.js").NegotiationPrivateConsultation | undefined; userAnswers?: import("../../shared/interfaces/database.interface.js").NegotiationUserAnswer[] | undefined; priorAttribution?: import("../negotiation.attribution.js").SeededAttribution | undefined; conversationId: string; taskId: string; currentSpeaker: "source" | "candidate"; turnCount: number; maxTurns: number; isContinuation: boolean; initiatorUserId: string; protocolVersion: NegotiationProtocolVersion; priorTurnCount: number; error?: undefined; }; screen: { screenDecision: ScreenDecisionRecord; memoryBySide: { [x: string]: NegotiatorMemoryEntry[]; }; }; turn: import("@langchain/langgraph").UpdateType<{ sourceUser: import("@langchain/langgraph").BaseChannel, unknown>; candidateUser: import("@langchain/langgraph").BaseChannel, unknown>; sourceIntentId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; candidateIntentId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; indexContext: import("@langchain/langgraph").BaseChannel<{ networkId: string; prompt: string; }, { networkId: string; prompt: string; } | import("@langchain/langgraph").OverwriteValue<{ networkId: string; prompt: string; }>, unknown>; seedAssessment: import("@langchain/langgraph").BaseChannel, unknown>; initiatorUserId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; discoveryQuery: import("@langchain/langgraph").BaseChannel | undefined, unknown>; protocolVersion: import("@langchain/langgraph").BaseChannel, unknown>; screenDecision: import("@langchain/langgraph").BaseChannel | null, unknown>; deadlockShift: import("@langchain/langgraph").BaseChannel | null, unknown>; memoryBySide: import("@langchain/langgraph").BaseChannel>, Partial> | import("@langchain/langgraph").OverwriteValue>>, unknown>; isContinuation: import("@langchain/langgraph").BaseChannel, unknown>; priorAttribution: import("@langchain/langgraph").BaseChannel; outreachOpened: import("@langchain/langgraph").BaseChannel, unknown>; firstTurnScreenedOut: import("@langchain/langgraph").BaseChannel, unknown>; opportunityId: import("@langchain/langgraph").BaseChannel, unknown>; opportunityStatus: import("@langchain/langgraph").BaseChannel | undefined, unknown>; opportunityUpdatedAt: import("@langchain/langgraph").BaseChannel | undefined, unknown>; resumeFromTaskId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; continuationSettlementId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; continuationExecution: import("@langchain/langgraph").BaseChannel | undefined, unknown>; continuationReceipt: import("@langchain/langgraph").BaseChannel | undefined, unknown>; privateConsultation: import("@langchain/langgraph").BaseChannel | undefined, unknown>; consultationPolicyReason: import("@langchain/langgraph").BaseChannel<"unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | undefined, "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | import("@langchain/langgraph").OverwriteValue<"unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority" | undefined> | undefined, unknown>; conversationId: import("@langchain/langgraph").BaseChannel, unknown>; taskId: import("@langchain/langgraph").BaseChannel, unknown>; messages: import("@langchain/langgraph").BaseChannel, unknown>; turnCount: import("@langchain/langgraph").BaseChannel, unknown>; maxTurns: import("@langchain/langgraph").BaseChannel | undefined, unknown>; timeoutMs: import("@langchain/langgraph").BaseChannel, unknown>; currentSpeaker: import("@langchain/langgraph").BaseChannel<"source" | "candidate", "source" | "candidate" | import("@langchain/langgraph").OverwriteValue<"source" | "candidate">, unknown>; lastTurn: import("@langchain/langgraph").BaseChannel<{ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | null, { action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | import("@langchain/langgraph").OverwriteValue<{ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user"; assessment: { reasoning: string; suggestedRoles: { ownUser: "agent" | "patient" | "peer"; otherUser: "agent" | "patient" | "peer"; }; }; message?: string | null | undefined; askUser?: { reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority"; } | null | undefined; } | null> | null, unknown>; status: import("@langchain/langgraph").BaseChannel<"waiting_for_agent" | "input_required" | "completed" | "active", "waiting_for_agent" | "input_required" | "completed" | "active" | import("@langchain/langgraph").OverwriteValue<"waiting_for_agent" | "input_required" | "completed" | "active">, unknown>; priorTurnCount: import("@langchain/langgraph").BaseChannel, unknown>; userAnswers: import("@langchain/langgraph").BaseChannel, unknown>; outcome: import("@langchain/langgraph").BaseChannel<{ reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | null, { reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | import("@langchain/langgraph").OverwriteValue<{ reasoning: string; hasOpportunity: boolean; agreedRoles: { userId: string; role: "agent" | "patient" | "peer"; }[]; turnCount: number; reason?: "timeout" | "turn_cap" | "screened_out" | undefined; } | null> | null, unknown>; error: import("@langchain/langgraph").BaseChannel | null, unknown>; }>; finalize: {}; }, unknown, unknown, []>; } export interface NegotiationCandidate { userId: string; /** Exact opportunity-bound source and candidate intent IDs. */ sourceIntentId?: string; candidateIntentId?: string; /** Per-opportunity source context when its exact actor intent differs across a fan-out. */ sourceUser?: UserNegotiationContext; reasoning: string; valencyRole: string; networkId?: string; candidateUser: UserNegotiationContext; /** The explicit search query that triggered discovery (if any). */ discoveryQuery?: string; /** * ID of the opportunity this negotiation is for. When set, the negotiation * graph's finalize node updates the opportunity's status based on the outcome * (`accept` → 'pending', `reject` → 'rejected', otherwise → 'stalled'). */ opportunityId?: string; /** Exact persisted lifecycle state claimed by this negotiation attempt. */ opportunityStatus?: OpportunityStatus; opportunityUpdatedAt?: Date; } export interface NegotiationResult { userId: string; agreedRoles: NegotiationOutcome["agreedRoles"]; reasoning: string; turnCount: number; } /** * Per-candidate resolution hook — fires as each negotiation settles, before * Promise.all aggregates. Awaited so the caller can run async work before the * next settle. * * `turns` and `outcome` are passed through from the underlying negotiation * graph so consumers can build per-candidate decision-question inputs without * re-walking trace events or DB artifacts. Both are present on every * resolution (accepted, rejected, stalled, error); error paths receive a * synthesized `outcome` with `hasOpportunity: false`. */ export type OnNegotiationResolved = (entry: { candidate: NegotiationCandidate; accepted: NegotiationResult | null; turns: NegotiationTurn[]; outcome: NegotiationOutcome; continuationReceipt?: import('../../shared/interfaces/database.interface.js').NegotiationContinuationReceipt; }) => Promise; /** * Runs bilateral negotiation for each candidate in parallel. * @returns Only candidates that produced an opportunity */ export declare function negotiateCandidates(negotiationGraph: NegotiationGraphLike, sourceUser: UserNegotiationContext, candidates: NegotiationCandidate[], indexContext: { networkId: string; prompt: string; }, opts?: { maxTurns?: number; traceEmitter?: TraceEmitter; indexContextOverrides?: Map; timeoutMs?: number; onCandidateResolved?: OnNegotiationResolved; /** * Initiator seat for every candidate session in this fan-out (v2 stamp). * Passed through to the negotiation graph, which may still override it by * inheriting from a prior task on the same opportunity/conversation. */ initiatorUserId?: string; /** Exact settled task to resume; only the durable run-existing path sets this. */ resumeFromTaskId?: string; /** Deterministic settlement key paired with resumeFromTaskId. */ continuationSettlementId?: string; /** Current durable lease/fence for this exact continuation successor. */ continuationExecution?: import('../../shared/interfaces/database.interface.js').NegotiationContinuationExecution; }): Promise;