@indexnetwork/protocol 0.17.0-rc.44.1 → 0.18.0-rc.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,6 +77,12 @@ export declare class OpportunityGraphFactory {
77
77
  * (short timeout). Without it, the chat path always uses a short timeout.
78
78
  */
79
79
  private agentDispatcher?;
80
+ /**
81
+ * Callback to enqueue a negotiate_existing job for an opportunity.
82
+ * When provided, negotiate_existing mode uses this to queue follow-up
83
+ * negotiations after introducer approval.
84
+ */
85
+ private queueNegotiateExisting?;
80
86
  constructor(database: OpportunityGraphDatabase, embedder: Embedder, hydeGenerator: {
81
87
  invoke: (input: HydeGeneratorInvokeInput) => Promise<{
82
88
  hydeEmbeddings: Record<string, number[]>;
@@ -95,7 +101,13 @@ export declare class OpportunityGraphFactory {
95
101
  * agent (long timeout) or fall back to the system agent immediately
96
102
  * (short timeout). Without it, the chat path always uses a short timeout.
97
103
  */
98
- agentDispatcher?: Pick<AgentDispatcher, "hasPersonalAgent"> | undefined);
104
+ agentDispatcher?: Pick<AgentDispatcher, "hasPersonalAgent"> | undefined,
105
+ /**
106
+ * Callback to enqueue a negotiate_existing job for an opportunity.
107
+ * When provided, negotiate_existing mode uses this to queue follow-up
108
+ * negotiations after introducer approval.
109
+ */
110
+ queueNegotiateExisting?: ((opportunityId: string, userId: string) => Promise<void>) | undefined);
99
111
  createGraph(): import("@langchain/langgraph").CompiledStateGraph<{
100
112
  userId: Id<"users">;
101
113
  searchQuery: string | undefined;
@@ -109,7 +121,7 @@ export declare class OpportunityGraphFactory {
109
121
  opportunityId: string;
110
122
  counterpartyUserId: string;
111
123
  }[];
112
- operationMode: "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send";
124
+ operationMode: "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction";
113
125
  introductionEntities: EvaluatorEntity[];
114
126
  introductionHint: string | undefined;
115
127
  requiredNetworkId: Id<"networks"> | undefined;
@@ -186,7 +198,7 @@ export declare class OpportunityGraphFactory {
186
198
  opportunityId: string;
187
199
  counterpartyUserId: string;
188
200
  }[]> | undefined;
189
- operationMode?: "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send"> | undefined;
201
+ operationMode?: "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction"> | undefined;
190
202
  introductionEntities?: EvaluatorEntity[] | import("@langchain/langgraph").OverwriteValue<EvaluatorEntity[]> | undefined;
191
203
  introductionHint?: string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined;
192
204
  requiredNetworkId?: Id<"networks"> | import("@langchain/langgraph").OverwriteValue<Id<"networks"> | undefined> | undefined;
@@ -278,7 +290,7 @@ export declare class OpportunityGraphFactory {
278
290
  data?: Record<string, unknown>;
279
291
  }[]> | undefined;
280
292
  agentTimings?: DebugMetaAgent[] | import("@langchain/langgraph").OverwriteValue<DebugMetaAgent[]> | undefined;
281
- }, "update" | "read" | "__start__" | "prep" | "send" | "scope" | "resolve" | "discovery" | "evaluation" | "ranking" | "intro_validation" | "intro_evaluation" | "persist" | "delete_opp" | "negotiate", {
293
+ }, "update" | "read" | "__start__" | "prep" | "send" | "negotiate_existing" | "approve_introduction" | "scope" | "resolve" | "discovery" | "evaluation" | "ranking" | "intro_validation" | "intro_evaluation" | "persist" | "delete_opp" | "negotiate", {
282
294
  userId: import("@langchain/langgraph").BaseChannel<Id<"users">, Id<"users"> | import("@langchain/langgraph").OverwriteValue<Id<"users">>, unknown>;
283
295
  searchQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
284
296
  networkId: import("@langchain/langgraph").BaseChannel<Id<"networks"> | undefined, Id<"networks"> | import("@langchain/langgraph").OverwriteValue<Id<"networks"> | undefined> | undefined, unknown>;
@@ -297,7 +309,7 @@ export declare class OpportunityGraphFactory {
297
309
  opportunityId: string;
298
310
  counterpartyUserId: string;
299
311
  }[]>, unknown>;
300
- operationMode: import("@langchain/langgraph").BaseChannel<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send", "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send">, unknown>;
312
+ operationMode: import("@langchain/langgraph").BaseChannel<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction", "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction">, unknown>;
301
313
  introductionEntities: import("@langchain/langgraph").BaseChannel<EvaluatorEntity[], EvaluatorEntity[] | import("@langchain/langgraph").OverwriteValue<EvaluatorEntity[]>, unknown>;
302
314
  introductionHint: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
303
315
  requiredNetworkId: import("@langchain/langgraph").BaseChannel<Id<"networks"> | undefined, Id<"networks"> | import("@langchain/langgraph").OverwriteValue<Id<"networks"> | undefined> | undefined, unknown>;
@@ -439,7 +451,7 @@ export declare class OpportunityGraphFactory {
439
451
  opportunityId: string;
440
452
  counterpartyUserId: string;
441
453
  }[]>, unknown>;
442
- operationMode: import("@langchain/langgraph").BaseChannel<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send", "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send">, unknown>;
454
+ operationMode: import("@langchain/langgraph").BaseChannel<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction", "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction">, unknown>;
443
455
  introductionEntities: import("@langchain/langgraph").BaseChannel<EvaluatorEntity[], EvaluatorEntity[] | import("@langchain/langgraph").OverwriteValue<EvaluatorEntity[]>, unknown>;
444
456
  introductionHint: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
445
457
  requiredNetworkId: import("@langchain/langgraph").BaseChannel<Id<"networks"> | undefined, Id<"networks"> | import("@langchain/langgraph").OverwriteValue<Id<"networks"> | undefined> | undefined, unknown>;
@@ -582,7 +594,7 @@ export declare class OpportunityGraphFactory {
582
594
  opportunityId: string;
583
595
  counterpartyUserId: string;
584
596
  }[]>, unknown>;
585
- operationMode: import("@langchain/langgraph").BaseChannel<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send", "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send">, unknown>;
597
+ operationMode: import("@langchain/langgraph").BaseChannel<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction", "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction">, unknown>;
586
598
  introductionEntities: import("@langchain/langgraph").BaseChannel<EvaluatorEntity[], EvaluatorEntity[] | import("@langchain/langgraph").OverwriteValue<EvaluatorEntity[]>, unknown>;
587
599
  introductionHint: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
588
600
  requiredNetworkId: import("@langchain/langgraph").BaseChannel<Id<"networks"> | undefined, Id<"networks"> | import("@langchain/langgraph").OverwriteValue<Id<"networks"> | undefined> | undefined, unknown>;
@@ -954,7 +966,7 @@ export declare class OpportunityGraphFactory {
954
966
  opportunityId: string;
955
967
  counterpartyUserId: string;
956
968
  }[]>, unknown>;
957
- operationMode: import("@langchain/langgraph").BaseChannel<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send", "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send">, unknown>;
969
+ operationMode: import("@langchain/langgraph").BaseChannel<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction", "create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction" | import("@langchain/langgraph").OverwriteValue<"create" | "update" | "delete" | "read" | "create_introduction" | "continue_discovery" | "send" | "negotiate_existing" | "approve_introduction">, unknown>;
958
970
  introductionEntities: import("@langchain/langgraph").BaseChannel<EvaluatorEntity[], EvaluatorEntity[] | import("@langchain/langgraph").OverwriteValue<EvaluatorEntity[]>, unknown>;
959
971
  introductionHint: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
960
972
  requiredNetworkId: import("@langchain/langgraph").BaseChannel<Id<"networks"> | undefined, Id<"networks"> | import("@langchain/langgraph").OverwriteValue<Id<"networks"> | undefined> | undefined, unknown>;
@@ -1142,6 +1154,24 @@ export declare class OpportunityGraphFactory {
1142
1154
  error?: undefined;
1143
1155
  };
1144
1156
  };
1157
+ negotiate_existing: {
1158
+ error?: undefined;
1159
+ } | {
1160
+ error: string;
1161
+ };
1162
+ approve_introduction: {
1163
+ mutationResult: {
1164
+ success: boolean;
1165
+ error: string;
1166
+ opportunityId?: undefined;
1167
+ };
1168
+ } | {
1169
+ mutationResult: {
1170
+ success: boolean;
1171
+ opportunityId: string;
1172
+ error?: undefined;
1173
+ };
1174
+ };
1145
1175
  negotiate: {
1146
1176
  trace?: undefined;
1147
1177
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"opportunity.graph.d.ts","sourceRoot":"","sources":["../../src/opportunity/opportunity.graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,4CAA4C,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC/B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAK3F,yDAAyD;AACzD,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,CAAC,EAAE,CACP,oBAAoB,EAAE,MAAM,EAC5B,UAAU,EAAE,gBAAgB,EAAE,EAC9B,OAAO,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAC3B,OAAO,CAAC,KAAK,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;QAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA81DlG"}
@@ -73,7 +73,13 @@ export class OpportunityGraphFactory {
73
73
  * agent (long timeout) or fall back to the system agent immediately
74
74
  * (short timeout). Without it, the chat path always uses a short timeout.
75
75
  */
76
- agentDispatcher) {
76
+ agentDispatcher,
77
+ /**
78
+ * Callback to enqueue a negotiate_existing job for an opportunity.
79
+ * When provided, negotiate_existing mode uses this to queue follow-up
80
+ * negotiations after introducer approval.
81
+ */
82
+ queueNegotiateExisting) {
77
83
  this.database = database;
78
84
  this.embedder = embedder;
79
85
  this.hydeGenerator = hydeGenerator;
@@ -81,6 +87,7 @@ export class OpportunityGraphFactory {
81
87
  this.queueNotification = queueNotification;
82
88
  this.negotiationGraph = negotiationGraph;
83
89
  this.agentDispatcher = agentDispatcher;
90
+ this.queueNegotiateExisting = queueNegotiateExisting;
84
91
  }
85
92
  createGraph() {
86
93
  const evaluatorAgent = this.optionalEvaluator ?? new OpportunityEvaluator();
@@ -1480,6 +1487,11 @@ export class OpportunityGraphFactory {
1480
1487
  // so the negotiation graph's finalize node can update its status from the outcome.
1481
1488
  const candidateEntries = state.opportunities
1482
1489
  .map(opp => {
1490
+ // Skip opportunities where any introducer exists but has not yet approved.
1491
+ const introducerActors = opp.actors
1492
+ .filter(a => a.role === 'introducer');
1493
+ if (introducerActors.length > 0 && !introducerActors.every(a => a.approved === true))
1494
+ return null;
1483
1495
  const candidateActor = opp.actors
1484
1496
  .find(a => a.userId !== discoveryUserId);
1485
1497
  if (!candidateActor)
@@ -2018,7 +2030,7 @@ export class OpportunityGraphFactory {
2018
2030
  ? evaluatorActors
2019
2031
  : [
2020
2032
  ...evaluatorActors,
2021
- { networkId: indexIdForActors, userId: state.userId, role: 'introducer' },
2033
+ { networkId: indexIdForActors, userId: state.userId, role: 'introducer', approved: false },
2022
2034
  ];
2023
2035
  data = {
2024
2036
  detection: {
@@ -2068,7 +2080,7 @@ export class OpportunityGraphFactory {
2068
2080
  ? evaluatorActors
2069
2081
  : [
2070
2082
  ...evaluatorActors,
2071
- { networkId: indexIdForActors, userId: state.userId, role: 'introducer' },
2083
+ { networkId: indexIdForActors, userId: state.userId, role: 'introducer', approved: false },
2072
2084
  ];
2073
2085
  const candidateUserId = evaluated.actors.find((a) => a.userId !== state.onBehalfOfUserId)?.userId;
2074
2086
  const overlapping = candidateUserId
@@ -2577,6 +2589,158 @@ export class OpportunityGraphFactory {
2577
2589
  }
2578
2590
  });
2579
2591
  };
2592
+ /**
2593
+ * Negotiate Existing Node: Load an existing opportunity by ID and run bilateral negotiation.
2594
+ * Used after introducer approval to trigger the normal negotiation flow for a latent opportunity.
2595
+ */
2596
+ const negotiateExistingNode = async (state) => {
2597
+ if (!state.opportunityId)
2598
+ return {};
2599
+ if (!this.negotiationGraph) {
2600
+ logger.warn('[Graph:NegotiateExisting] No negotiationGraph wired; skipping', {
2601
+ opportunityId: state.opportunityId,
2602
+ });
2603
+ return {};
2604
+ }
2605
+ try {
2606
+ const opp = await this.database.getOpportunity(state.opportunityId);
2607
+ if (!opp) {
2608
+ logger.warn('[Graph:NegotiateExisting] Opportunity not found', { opportunityId: state.opportunityId });
2609
+ return {};
2610
+ }
2611
+ const actors = opp.actors;
2612
+ const nonIntroducerActors = actors.filter(a => a.role !== 'introducer');
2613
+ // Find the sourceActor: non-introducer with role patient or party, fallback to first non-introducer
2614
+ const sourceActor = nonIntroducerActors.find(a => a.role === 'patient' || a.role === 'party')
2615
+ ?? nonIntroducerActors[0];
2616
+ if (!sourceActor) {
2617
+ logger.warn('[Graph:NegotiateExisting] No source actor found', { opportunityId: state.opportunityId });
2618
+ return {};
2619
+ }
2620
+ // Find the candidateActor: non-introducer that is NOT the sourceActor
2621
+ const candidateActor = nonIntroducerActors.find(a => a.userId !== sourceActor.userId);
2622
+ if (!candidateActor) {
2623
+ logger.warn('[Graph:NegotiateExisting] No candidate actor found', { opportunityId: state.opportunityId });
2624
+ return {};
2625
+ }
2626
+ // Load user data for both actors in parallel
2627
+ const [sourceUserAccount, sourceProfile, sourceIntents, candidateAccount, candidateProfile, candidateIntents] = await Promise.all([
2628
+ this.database.getUser(sourceActor.userId).catch(() => null),
2629
+ this.database.getProfile(sourceActor.userId).catch(() => null),
2630
+ this.database.getActiveIntents(sourceActor.userId).catch(() => []),
2631
+ this.database.getUser(candidateActor.userId).catch(() => null),
2632
+ this.database.getProfile(candidateActor.userId).catch(() => null),
2633
+ this.database.getActiveIntents(candidateActor.userId).catch(() => []),
2634
+ ]);
2635
+ const toNegIntent = (ai) => ({
2636
+ id: ai.id,
2637
+ title: ai.summary ?? '',
2638
+ description: ai.payload ?? '',
2639
+ confidence: 1,
2640
+ });
2641
+ const sourceUser = {
2642
+ id: sourceActor.userId,
2643
+ intents: sourceIntents.slice(0, 5).map(toNegIntent),
2644
+ profile: {
2645
+ name: sourceProfile?.identity?.name ?? sourceUserAccount?.name,
2646
+ bio: sourceProfile?.identity?.bio ?? sourceUserAccount?.intro ?? undefined,
2647
+ location: sourceProfile?.identity?.location ?? sourceUserAccount?.location ?? undefined,
2648
+ skills: sourceProfile?.attributes?.skills,
2649
+ interests: sourceProfile?.attributes?.interests,
2650
+ },
2651
+ };
2652
+ const candidateIntentsForNeg = candidateIntents.slice(0, 5).map(toNegIntent);
2653
+ const candidate = {
2654
+ userId: candidateActor.userId,
2655
+ opportunityId: opp.id,
2656
+ reasoning: opp.interpretation?.reasoning ?? '',
2657
+ valencyRole: candidateActor.role ?? 'peer',
2658
+ networkId: candidateActor.networkId,
2659
+ candidateUser: {
2660
+ id: candidateActor.userId,
2661
+ intents: candidateIntentsForNeg,
2662
+ profile: {
2663
+ name: candidateProfile?.identity?.name ?? candidateAccount?.name,
2664
+ bio: candidateProfile?.identity?.bio ?? candidateAccount?.intro ?? undefined,
2665
+ location: candidateProfile?.identity?.location ?? candidateAccount?.location ?? undefined,
2666
+ skills: candidateProfile?.attributes?.skills,
2667
+ interests: candidateProfile?.attributes?.interests,
2668
+ },
2669
+ },
2670
+ };
2671
+ // Load index context for the candidate's network
2672
+ const indexContextMap = new Map();
2673
+ if (candidate.networkId) {
2674
+ const ctx = await this.database.getNetworkMemberContext(candidate.networkId, sourceActor.userId).catch(() => null);
2675
+ const prompt = [ctx?.indexPrompt, ctx?.memberPrompt]
2676
+ .filter((v) => !!v?.trim())
2677
+ .join('\n\n');
2678
+ if (prompt)
2679
+ indexContextMap.set(candidate.networkId, prompt);
2680
+ }
2681
+ const acceptedResults = await negotiateCandidates(this.negotiationGraph, sourceUser, [candidate], { networkId: '', prompt: '' }, {
2682
+ maxTurns: 6,
2683
+ indexContextOverrides: indexContextMap,
2684
+ timeoutMs: AMBIENT_PARK_WINDOW_MS,
2685
+ trigger: 'ambient',
2686
+ });
2687
+ // Send notifications to non-introducer actors if negotiation was accepted
2688
+ if (acceptedResults.length > 0 && this.queueNotification) {
2689
+ for (const actor of nonIntroducerActors) {
2690
+ await this.queueNotification(opp.id, actor.userId, 'high').catch((err) => {
2691
+ logger.warn('[Graph:NegotiateExisting] Failed to queue notification', { actorId: actor.userId, error: err });
2692
+ });
2693
+ }
2694
+ }
2695
+ logger.info('[Graph:NegotiateExisting] Negotiation complete', {
2696
+ opportunityId: opp.id,
2697
+ accepted: acceptedResults.length > 0,
2698
+ });
2699
+ }
2700
+ catch (err) {
2701
+ logger.error('[Graph:NegotiateExisting] Failed', { opportunityId: state.opportunityId, error: err });
2702
+ return { error: `Failed to load opportunity: ${err instanceof Error ? err.message : String(err)}` };
2703
+ }
2704
+ return {};
2705
+ };
2706
+ /**
2707
+ * Node: Approve Introduction
2708
+ * Called by the introducer to approve a latent introducer-pattern opportunity.
2709
+ * Sets approved=true on the introducer actor (status stays latent), then
2710
+ * enqueues a negotiate_existing job so the parties negotiate normally.
2711
+ */
2712
+ const approveIntroductionNode = async (state) => {
2713
+ const { opportunityId, userId } = state;
2714
+ if (!opportunityId) {
2715
+ return { mutationResult: { success: false, error: 'opportunityId required for approve_introduction' } };
2716
+ }
2717
+ let opp;
2718
+ try {
2719
+ opp = await this.database.getOpportunity(opportunityId);
2720
+ }
2721
+ catch (err) {
2722
+ return { mutationResult: { success: false, error: `Failed to load opportunity: ${err instanceof Error ? err.message : String(err)}` } };
2723
+ }
2724
+ if (!opp) {
2725
+ return { mutationResult: { success: false, error: 'Opportunity not found' } };
2726
+ }
2727
+ const introducerActor = opp.actors
2728
+ .find(a => a.role === 'introducer' && a.userId === userId);
2729
+ if (!introducerActor) {
2730
+ return { mutationResult: { success: false, error: 'You are not the introducer for this opportunity' } };
2731
+ }
2732
+ if (introducerActor.approved === true) {
2733
+ return { mutationResult: { success: false, error: 'Introduction already approved' } };
2734
+ }
2735
+ const updated = await this.database.updateOpportunityActorApproval(opportunityId, userId, true);
2736
+ if (!updated) {
2737
+ return { mutationResult: { success: false, error: 'Failed to update approval' } };
2738
+ }
2739
+ if (this.queueNegotiateExisting) {
2740
+ await this.queueNegotiateExisting(opportunityId, userId);
2741
+ }
2742
+ return { mutationResult: { success: true, opportunityId } };
2743
+ };
2580
2744
  // ═══════════════════════════════════════════════════════════════
2581
2745
  // CONDITIONAL ROUTING FUNCTIONS
2582
2746
  // ═══════════════════════════════════════════════════════════════
@@ -2595,6 +2759,10 @@ export class OpportunityGraphFactory {
2595
2759
  return 'send';
2596
2760
  if (mode === 'create_introduction')
2597
2761
  return 'intro_validation';
2762
+ if (mode === 'negotiate_existing')
2763
+ return 'negotiate_existing';
2764
+ if (mode === 'approve_introduction')
2765
+ return 'approve_introduction';
2598
2766
  // 'create' is the default discovery pipeline
2599
2767
  return 'prep';
2600
2768
  };
@@ -2667,6 +2835,8 @@ export class OpportunityGraphFactory {
2667
2835
  .addNode('update', updateNode)
2668
2836
  .addNode('delete_opp', deleteNode)
2669
2837
  .addNode('send', sendNode)
2838
+ .addNode('negotiate_existing', negotiateExistingNode)
2839
+ .addNode('approve_introduction', approveIntroductionNode)
2670
2840
  // Route by operation mode from START
2671
2841
  .addConditionalEdges(START, routeByMode, {
2672
2842
  prep: 'prep',
@@ -2675,6 +2845,8 @@ export class OpportunityGraphFactory {
2675
2845
  update: 'update',
2676
2846
  delete_opp: 'delete_opp',
2677
2847
  send: 'send',
2848
+ negotiate_existing: 'negotiate_existing',
2849
+ approve_introduction: 'approve_introduction',
2678
2850
  })
2679
2851
  // Introduction path: validation -> evaluation -> persist (or END on validation error)
2680
2852
  .addConditionalEdges('intro_validation', routeAfterIntroValidation, {
@@ -2687,6 +2859,8 @@ export class OpportunityGraphFactory {
2687
2859
  .addEdge('update', END)
2688
2860
  .addEdge('delete_opp', END)
2689
2861
  .addEdge('send', END)
2862
+ .addEdge('negotiate_existing', END)
2863
+ .addEdge('approve_introduction', END)
2690
2864
  // Conditional routing: early exit if no indexed intents
2691
2865
  .addConditionalEdges('prep', shouldContinueAfterPrep, {
2692
2866
  scope: 'scope',