@indexnetwork/protocol 4.4.1 → 4.5.0-rc.322.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.
Files changed (85) hide show
  1. package/dist/chat/chat.interrupt.classifier.d.ts.map +1 -1
  2. package/dist/chat/chat.interrupt.classifier.js +2 -2
  3. package/dist/chat/chat.interrupt.classifier.js.map +1 -1
  4. package/dist/chat/chat.suggester.d.ts.map +1 -1
  5. package/dist/chat/chat.suggester.js +2 -3
  6. package/dist/chat/chat.suggester.js.map +1 -1
  7. package/dist/chat/chat.summarizer.d.ts.map +1 -1
  8. package/dist/chat/chat.summarizer.js +11 -3
  9. package/dist/chat/chat.summarizer.js.map +1 -1
  10. package/dist/chat/chat.title.generator.d.ts.map +1 -1
  11. package/dist/chat/chat.title.generator.js +2 -2
  12. package/dist/chat/chat.title.generator.js.map +1 -1
  13. package/dist/contact/contact.inviter.d.ts.map +1 -1
  14. package/dist/contact/contact.inviter.js +2 -3
  15. package/dist/contact/contact.inviter.js.map +1 -1
  16. package/dist/context/context.generator.d.ts.map +1 -1
  17. package/dist/context/context.generator.js +2 -2
  18. package/dist/context/context.generator.js.map +1 -1
  19. package/dist/enrichment/enrichment.generator.d.ts +1 -1
  20. package/dist/enrichment/enrichment.generator.d.ts.map +1 -1
  21. package/dist/enrichment/enrichment.generator.js +3 -4
  22. package/dist/enrichment/enrichment.generator.js.map +1 -1
  23. package/dist/intent/intent.clarifier.d.ts.map +1 -1
  24. package/dist/intent/intent.clarifier.js +4 -5
  25. package/dist/intent/intent.clarifier.js.map +1 -1
  26. package/dist/intent/intent.indexer.d.ts.map +1 -1
  27. package/dist/intent/intent.indexer.js +2 -3
  28. package/dist/intent/intent.indexer.js.map +1 -1
  29. package/dist/intent/intent.inferrer.d.ts.map +1 -1
  30. package/dist/intent/intent.inferrer.js +2 -3
  31. package/dist/intent/intent.inferrer.js.map +1 -1
  32. package/dist/intent/intent.reconciler.d.ts.map +1 -1
  33. package/dist/intent/intent.reconciler.js +2 -3
  34. package/dist/intent/intent.reconciler.js.map +1 -1
  35. package/dist/intent/intent.verifier.d.ts.map +1 -1
  36. package/dist/intent/intent.verifier.js +2 -3
  37. package/dist/intent/intent.verifier.js.map +1 -1
  38. package/dist/negotiation/insight.generator.d.ts.map +1 -1
  39. package/dist/negotiation/insight.generator.js +2 -2
  40. package/dist/negotiation/insight.generator.js.map +1 -1
  41. package/dist/negotiation/negotiation.agent.js +2 -2
  42. package/dist/negotiation/negotiation.agent.js.map +1 -1
  43. package/dist/negotiation/negotiation.summarizer.d.ts +11 -0
  44. package/dist/negotiation/negotiation.summarizer.d.ts.map +1 -1
  45. package/dist/negotiation/negotiation.summarizer.js +13 -3
  46. package/dist/negotiation/negotiation.summarizer.js.map +1 -1
  47. package/dist/network/network.recommender.d.ts.map +1 -1
  48. package/dist/network/network.recommender.js +2 -3
  49. package/dist/network/network.recommender.js.map +1 -1
  50. package/dist/opportunity/feed/feed.categorizer.d.ts.map +1 -1
  51. package/dist/opportunity/feed/feed.categorizer.js +2 -3
  52. package/dist/opportunity/feed/feed.categorizer.js.map +1 -1
  53. package/dist/opportunity/opportunity.evaluator.d.ts.map +1 -1
  54. package/dist/opportunity/opportunity.evaluator.js +3 -4
  55. package/dist/opportunity/opportunity.evaluator.js.map +1 -1
  56. package/dist/opportunity/opportunity.presenter.d.ts.map +1 -1
  57. package/dist/opportunity/opportunity.presenter.js +3 -4
  58. package/dist/opportunity/opportunity.presenter.js.map +1 -1
  59. package/dist/opportunity/question.generator.d.ts.map +1 -1
  60. package/dist/opportunity/question.generator.js +17 -3
  61. package/dist/opportunity/question.generator.js.map +1 -1
  62. package/dist/premise/premise.analyzer.d.ts.map +1 -1
  63. package/dist/premise/premise.analyzer.js +2 -3
  64. package/dist/premise/premise.analyzer.js.map +1 -1
  65. package/dist/premise/premise.decomposer.d.ts.map +1 -1
  66. package/dist/premise/premise.decomposer.js +2 -3
  67. package/dist/premise/premise.decomposer.js.map +1 -1
  68. package/dist/premise/premise.indexer.d.ts.map +1 -1
  69. package/dist/premise/premise.indexer.js +2 -3
  70. package/dist/premise/premise.indexer.js.map +1 -1
  71. package/dist/questioner/questioner.agent.d.ts +2 -2
  72. package/dist/questioner/questioner.agent.d.ts.map +1 -1
  73. package/dist/questioner/questioner.agent.js +12 -4
  74. package/dist/questioner/questioner.agent.js.map +1 -1
  75. package/dist/shared/agent/model.config.d.ts +41 -2
  76. package/dist/shared/agent/model.config.d.ts.map +1 -1
  77. package/dist/shared/agent/model.config.js +98 -1
  78. package/dist/shared/agent/model.config.js.map +1 -1
  79. package/dist/shared/hyde/hyde.generator.d.ts.map +1 -1
  80. package/dist/shared/hyde/hyde.generator.js +2 -3
  81. package/dist/shared/hyde/hyde.generator.js.map +1 -1
  82. package/dist/shared/hyde/lens.inferrer.d.ts.map +1 -1
  83. package/dist/shared/hyde/lens.inferrer.js +2 -3
  84. package/dist/shared/hyde/lens.inferrer.js.map +1 -1
  85. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"opportunity.evaluator.js","sourceRoot":"/","sources":["opportunity/opportunity.evaluator.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAG5E,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAE/E,MAAM,MAAM,GAAG,cAAc,CA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import type { Runnable } from \"@langchain/core/runnables\";\nimport { HumanMessage, SystemMessage } from \"@langchain/core/messages\";\nimport { tool } from \"@langchain/core/tools\";\nimport { z } from \"zod\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport type { Lens } from \"../shared/hyde/lens.inferrer.js\";\nimport type { OpportunityStatus } from \"../shared/interfaces/database.interface.js\";\nimport { Timed } from \"../shared/observability/performance.js\";\nimport { stripUuids } from \"./opportunity.presentation.js\";\nimport { createModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\nimport type { OpportunityEvidence } from '../shared/schemas/network-assignment.schema.js';\nimport { renderOpportunityEvidenceForPrompt } from './opportunity.evidence.js';\n\nconst logger = protocolLogger(\"OpportunityEvaluator\");\n\nconst model = createModel(\"opportunityEvaluator\");\n\n// ──────────────────────────────────────────────────────────────\n// 1. SYSTEM PROMPT\n// ──────────────────────────────────────────────────────────────\n\n\nconst systemPrompt = `\n You are an expert \"Opportunity Matcher\" and super-connector.\n Your Goal: Analyze a Source User's profile against a Candidate User's profile to identify A SINGLE HIGH-VALUE opportunity.\n\n Input:\n - Source Context: The Source User's own Profile.\n - Candidate Profile (JSON)\n - Existing Opportunities (Context of matches already made)\n\n Output:\n - A list containing EXACTLY ONE \"Opportunity\" if a match exists.\n - If NO match exists, return an empty list.\n - Score (0-100): How strong is this match?\n - 90-100: \"Must Meet\" (Perfect alignment).\n - 70-89: \"Should Meet\" (Strong overlaps, clear potential).\n - <70: No opportunity (Return empty list).\n\n **CRITICAL: VALENCY & REASONING**\n \n 1. **Valency Analysis**:\n - Determine the semantic role of the Candidate relative to the Source's goal.\n - \"Agent\": The Candidate CAN DO something for the Source (e.g., Source needs a dev, Candidate IS a dev).\n - \"Patient\": The Candidate NEEDS something from the Source (e.g., Source is a mentor, Candidate needs mentoring).\n - \"Peer\": Symmetric collaboration.\n\n 2. **Reasoning (Third-Party Analytical Perspective)**:\n - **reasoning**: A neutral, third-party explanation of why this opportunity exists. Written for other LLM agents to read and understand.\n - Mention BOTH users by their roles (e.g. \"The source user\" and \"The candidate\") and explain why they are a match.\n - Do NOT address either user as \"you\". Write from an objective observer's perspective.\n - Include what each side brings to the connection and why it is mutually valuable.\n - NEVER leak private intents. If someone's intent is confidential, describe their relevant attributes instead.\n\n **VISIBILITY IMPLICATIONS OF ROLE ASSIGNMENT**\n\n The valency role you assign directly controls who sees the opportunity and when:\n - \"Agent\" (helper/provider): LAST to see the opportunity — only after the Patient has committed to reaching out. Agents are protected from noise; they only see high-intent connections.\n - \"Patient\" (seeker/requester): Sees the opportunity early and decides whether to reach out.\n - \"Peer\" (symmetric): Both parties see the opportunity immediately and either can initiate.\n\n Choose the role carefully — it determines the entire flow of how the connection unfolds.\n\n Rules:\n 1. SYNTHESIS (CRITICAL): If multiple distinct match angles exist, SYNTHESIZE them into a SINGLE, robust opportunity.\n 2. NEVER address either user directly — always use third-party references (\"the source\", \"the candidate\").\n 3. COMPREHENSIVE: The single opportunity must capture ALL the value of the connection.\n 4. Be specific about the \"Why\" for BOTH sides in the reasoning.\n 5. DEDUPLICATION: Do NOT suggest opportunities that duplicate \"Existing Opportunities\".\n 6. Do not suggest an opportunity if the source and candidate clearly already know each other (e.g. same company, co-founders, same team).\n 7. SAME-SIDE MATCHING: If both the source and candidate are SEEKING the same resource (e.g., both looking for investors, both seeking a co-founder), this is not an opportunity. Return an empty list unless one side clearly OFFERS what the other SEEKS.\n`;\n\n// Entity-bundle system prompt (C2): entities + four match patterns + actors output\n// NOTE: entityBundleSystemPrompt uses a >= 30 threshold (permissive) while\n// systemPrompt uses >= 70 (strict). This is intentional: batch mode casts a wide\n// net so the calling pipeline can apply its own filters; pairwise mode is strict\n// because it returns a single yes/no decision per candidate pair.\nconst entityBundleSystemPrompt = `\nYou are an expert \"Opportunity Matcher\" and super-connector.\nYour Goal: Analyze a set of entities (people), each with a profile and optional intents, and identify HIGH-VALUE opportunities among them.\n\nInput:\n- DISCOVERER: The user ID who triggered discovery (for context; they may or may not be in the entity list).\n- ENTITIES: A set of entities. Each entity has:\n - userId, networkId (the index through which they were found)\n - evidenceKey (stable key for the matched resource when available)\n - profile: name, bio, location, interests, skills, context\n - intents (optional): list of { intentId, payload, summary } — some entities are profile-only, some have intents\n - ragScore, matchedVia (how they were found)\n - evidence (typed retrieval evidence: discovery kind, network, score, lens, source/candidate ids)\n- EXISTING OPPORTUNITIES: Context of matches already made (for deduplication).\n\nBEFORE SCORING — determine role satisfiability:\n\nDefinitions:\n SUBSTITUTIVE ROLE: The candidate can directly fill the open position in the discoverer's intent. The candidate IS the person/entity the discoverer is seeking. Example: discoverer seeks \"co-founder\" → candidate is an engineer willing to co-found.\n COMPLEMENTARY ROLE: The candidate's contribution is defined relative to the seeker-sought relation from the outside — they fund, advise, recruit for, or enable the sought relationship rather than participating in it as the target. Example: discoverer seeks \"co-founder\" → candidate is a VC (funds the company, does not co-found it).\n\nStep 1 — Identify the open argument in each discoverer intent: what type of person or entity would satisfy the intent if found?\nStep 2 — For each candidate, ask: can this candidate directly fill that open argument position?\n YES → substitutive role. Proceed to scoring.\n NO → complementary role. Apply Rule 7 (score ≤ 30, return no opportunity).\nStep 3 — Contextual override: if the candidate's profile contains explicit evidence that they currently function in the substitutive role (e.g., a former investor who is now building full-time as a technical co-founder), re-evaluate Step 2 against their current role, not their categorical label.\n\nMatch patterns to consider:\n1. Profile-to-profile: Complementary backgrounds (skills, interests, location).\n2. Profile-to-intents+profile: Someone's skills/background match another's stated goals (intents).\n3. Intents+profile-to-profile: Someone's stated goals match another's skills/background.\n4. Intents+profile-to-intents+profile: Complementary or reciprocal goals between two or more people.\n\nOutput:\n- A list of 0..N opportunities. Each opportunity has:\n - reasoning: Third-party analytical explanation (for other LLM agents). Mention entities by role. Do NOT use \"you\". Never leak private intents.\n - score: 0-100.\n - 90-100: Must Meet — candidate's PRIMARY role directly matches what the discoverer seeks.\n Example: discoverer seeks \"AI/ML co-founder\" → candidate IS an AI/ML engineer who wants to co-found.\n - 70-89: Should Meet — meaningful overlap on role type AND complementary intent.\n - 50-69: Worth Considering — tangential overlap only.\n - <30 (return empty): Complementary-role mismatch (candidate cannot fill the discoverer's open argument position), same-side match, or already acquainted.\n Example: discoverer seeks \"co-founder\" → candidate is a VC investor. The investor's contribution is external to the co-founding relation; they cannot substitute into it. Score 0.\n - IMPORTANT: Include ALL reasonable matches with scores >= 30, and ONLY those. Any candidate you would reject (complementary-role mismatch, same-side, already-acquainted, or a hard location mismatch) must score strictly below 30 and be omitted entirely — the surfacing threshold is 30, so a rejected candidate parked at exactly 30 would be wrongly surfaced.\n - actors: At least 2 actors per opportunity. Each actor has:\n - userId\n - role: \"agent\" (can do something for others), \"patient\" (needs something from others), \"peer\" (symmetric collaboration)\n - intentId (optional): if the match is intent-driven, the specific intent ID for that user\n - evidenceKey (optional): copy the entity evidenceKey when the actor is driven by a specific listed entity\n\nVISIBILITY (role controls who sees the opportunity when):\n- agent: Last to see — after the patient has committed to reaching out.\n- patient: Sees early and decides whether to reach out.\n- peer: Both see immediately; either can initiate.\n\nRules:\n1. ONE OPPORTUNITY PER CANDIDATE: Create a SEPARATE opportunity for EACH candidate who matches. Do NOT combine multiple candidates into one opportunity. Each opportunity should have exactly 2 actors: the DISCOVERER and ONE candidate.\n2. INDIVIDUAL REASONING: Write specific reasoning for EACH candidate individually. Do NOT mention other candidates in the reasoning. Focus on why THIS specific candidate matches THIS specific discoverer.\n3. DEDUPLICATION: Do not suggest opportunities that duplicate Existing Opportunities.\n4. Write reasoning from an objective observer's perspective; be specific about the \"Why\" for each side.\n5. When in introduction mode, each opportunity must have exactly two actors — the two people being introduced. The discoverer (introducer) is added by the system and must not be included in your actors list.\n6. ALREADY KNOW EACH OTHER: Do NOT suggest an opportunity if the entities clearly already know each other. Examples: co-founders of the same company, same team at the same organization, same employer, or any relationship that is obviously existing from their profiles (bio, context). When in doubt, if both profiles mention the same company/org/team in a way that implies they work together, return an empty list for that pair.\n7. ROLE-SATISFIABILITY (evaluate before scoring): A candidate satisfies a discoverer's intent only if they can fill the SUBSTITUTIVE ROLE — the open argument position in the intent (the type of person the discoverer is seeking). A candidate in a COMPLEMENTARY ROLE (one that funds, advises, recruits for, or otherwise enables the sought relation from outside it) does not satisfy the intent, regardless of how closely associated their domain is.\n COMPLEMENTARY-ROLE CAP: If the candidate occupies a complementary rather than substitutive role relative to the discoverer's intent, score below 30 (e.g. 0–20). Return no opportunity. A \"reject\" score must be strictly below 30 so the candidate is not surfaced — never park a rejected candidate at exactly 30.\n CONTEXTUAL OVERRIDE: If the candidate's profile contains explicit evidence that they currently function in the substitutive role (not merely historically or tangentially), treat them as substitutive and score normally.\n8. SAME-SIDE MATCHING: Before scoring, check whether the DISCOVERER and CANDIDATE are both SEEKING the same thing. Look at both parties' intents for directionality:\n - SEEKING signals: \"looking for\", \"seeking\", \"want to find\", \"need\", \"raising\", \"hiring\"\n - OFFERING signals: \"can offer\", \"expert in\", \"investing in\", \"mentoring\", \"available for\"\n If both parties have SEEKING intents targeting the same resource (e.g., both seeking investors, both seeking co-founders, both seeking mentorship), this is NOT an opportunity — score <30. An opportunity requires one side to OFFER what the other SEEKS.\n9. LOCATION MATCHING: When the DISCOVERY REQUEST mentions a specific location (city, region, or country):\n a. If a candidate's profile.location is KNOWN and clearly does NOT match the requested location (different city/region), score below 30 (e.g. 0–25) and return no opportunity. An explicitly requested location is a hard constraint: a known geographic mismatch excludes the candidate.\n b. If a candidate's profile.location is UNKNOWN, EMPTY, or AMBIGUOUS, do NOT penalize — allow them through and score based on other factors. Note in reasoning that their location is unverified.\n c. If a candidate's profile.location matches or is reasonably close (e.g., \"Bay Area\" matches \"San Francisco\", \"Remote\" matches any location), score normally.\n d. \"Remote\" or \"Global\" locations are compatible with any requested location.\n10. EVENT NETWORK AWARENESS: When NETWORK CONTEXTS includes an event-type network (identified by dates, location, schedule, or themes):\n a. TEMPORAL RELEVANCE: If the event has start/end dates, factor time into scoring. Intents about meeting at the event, sharing logistics, or collaborating during the event are highly relevant when the event is upcoming or in progress. After the event ends, such intents lose relevance — score lower unless the connection has lasting value beyond the event.\n b. THEME ALIGNMENT: Event networks may list themes or tracks. Candidates whose expertise or intents align with event themes should score higher for that network's entities.\n c. CO-ATTENDANCE SIGNAL: Two entities found through the same event network share a co-attendance signal — they will likely be in the same place at the same time. This is a positive signal for in-person collaboration opportunities.\n d. SCHEDULE CONTEXT: If the event network includes upcoming events or sessions, use them as additional matching context. Two people attending the same session or interested in the same topic track are stronger matches.\n e. CO-ATTENDANCE ROLE: When two co-attendees express mutual or reciprocal collaboration intent — each seeking to work with the other's type, with no clear one-directional provider/seeker split — assign the \"peer\" role to both. Symmetric, two-sided collaboration is a peer relationship, not an agent/patient one; default to \"peer\" rather than \"agent\" for co-attendance matches.\n`;\n\n// ──────────────────────────────────────────────────────────────\n// 2. RESPONSE SCHEMA (Zod)\n// ──────────────────────────────────────────────────────────────\n\nconst OpportunitySchema = z.object({\n reasoning: z.string().describe('Third-party analytical explanation of why this opportunity exists. Mentions both users by role. Written for other LLM agents to understand the match.'),\n score: z.number().min(0).max(100).describe('Relevance score 0-100'),\n valencyRole: z.enum(['Agent', 'Patient', 'Peer']).describe(\"The semantic role of the Candidate relative to the Source\"),\n sourceId: z.string().describe('The user ID of the source'),\n candidateId: z.string().describe('The user ID of the candidate'),\n});\n\nconst responseFormat = z.object({\n opportunities: z.array(OpportunitySchema).describe(\"List of opportunities identified\"),\n});\n\n// ─── Entity-bundle evaluator (C1): types and output schema with actors ───\n\nexport interface EvaluatorEntity {\n userId: string;\n profile: {\n name?: string;\n bio?: string;\n location?: string;\n interests?: string[];\n skills?: string[];\n context?: string;\n };\n intents?: Array<{\n intentId: string;\n payload: string;\n summary?: string;\n }>;\n networkId: string;\n evidenceKey?: string;\n ragScore?: number;\n matchedVia?: string;\n evidence?: OpportunityEvidence[];\n}\n\nexport interface EvaluatorInput {\n /** The user who triggered discovery (for context, not special treatment). */\n discovererId: string;\n /** All relevant entities. In introduction mode, only the people being introduced (no introducer). */\n entities: EvaluatorEntity[];\n /** Existing opportunities for deduplication. */\n existingOpportunities?: string;\n /** When true, DISCOVERER is the introducer; reasoning and actors must be only among ENTITIES. */\n introductionMode?: boolean;\n /** Name of the introducer (for attribution in reasoning when introductionMode is true). */\n introducerName?: string;\n /** Optional hint/context from the introducer about why these people should meet. */\n introductionHint?: string;\n /** Optional discovery query (e.g. from chat). When set, only suggest opportunities where candidates clearly match this request. */\n discoveryQuery?: string;\n /** Pre-rendered network context markdown, keyed by networkId. */\n networkContexts?: Record<string, string>;\n}\n\nconst ActorSchema = z.object({\n userId: z.string(),\n role: z.enum(['agent', 'patient', 'peer']),\n intentId: z.string().nullable().describe('If the match is intent-driven, the specific intent ID; null otherwise'),\n evidenceKey: z.string().nullable().optional().describe('Stable evidence key for the matched entity; null if unknown'),\n});\n\nconst OpportunityWithActorsSchema = z.object({\n reasoning: z.string(),\n score: z.number().min(0).max(100),\n actors: z.array(ActorSchema).min(2).describe('All actors in this opportunity with their roles'),\n});\n\nconst entityBundleResponseFormat = z.object({\n opportunities: z.array(OpportunityWithActorsSchema).describe('List of opportunities (0..N)'),\n});\n\nexport type EvaluatorActor = z.infer<typeof ActorSchema>;\nexport type EvaluatedOpportunityWithActors = z.infer<typeof OpportunityWithActorsSchema>;\nexport type EvaluatorOutputBundle = z.infer<typeof entityBundleResponseFormat>;\n\n// ──────────────────────────────────────────────────────────────\n// 3. TYPE DEFINITIONS\n// ──────────────────────────────────────────────────────────────\n\ntype Opportunity = z.infer<typeof OpportunitySchema>;\ntype EvaluatorOutput = z.infer<typeof responseFormat>;\n\n// Define CandidateProfile type (simplified for now, ideally imported from shared types)\nexport interface CandidateProfile {\n userId: string;\n identity?: { name?: string; bio?: string; location?: string };\n attributes?: { interests?: string[]; skills?: string[] };\n narrative?: { context?: string };\n score?: number; // Search score\n}\n\ninterface OpportunityEvaluatorOptions {\n minScore?: number;\n limit?: number;\n hydeDescription?: string;\n /** Pre-inferred lenses (if not provided, lens inference runs automatically in HyDE graph). */\n lenses?: Lens[];\n existingOpportunities?: string;\n candidates?: CandidateProfile[]; // For direct evaluation\n filter?: Record<string, unknown>;\n initialStatus?: OpportunityStatus;\n}\n\n// ──────────────────────────────────────────────────────────────\n// 4. CLASS DEFINITION\n// ──────────────────────────────────────────────────────────────\n\n/** Optional test double for entity-bundle model (avoids live LLM in unit tests). */\nexport type OpportunityEvaluatorOptionsConstructor = {\n entityBundleModel?: Runnable;\n};\n\nexport class OpportunityEvaluator {\n private model: Runnable;\n private entityBundleModel: Runnable;\n\n constructor(options?: OpportunityEvaluatorOptionsConstructor) {\n this.model = model.withStructuredOutput(responseFormat, {\n name: \"opportunity_evaluator\"\n });\n this.entityBundleModel = options?.entityBundleModel ?? model.withStructuredOutput(entityBundleResponseFormat, {\n name: \"opportunity_evaluator_entity_bundle\"\n });\n }\n\n /**\n * Main Entry Point: Batch analysis of candidates.\n * \n * @param sourceProfileContext - The profile context string of the user we are finding opportunities FOR.\n * @param candidates - List of potential matches to evaluate.\n * @param options - Config (minScore, valid types, etc).\n * @returns A sorted list of high-value `Opportunity` objects.\n */\n @Timed()\n public async invoke(\n sourceProfileContext: string,\n candidates: CandidateProfile[],\n options: OpportunityEvaluatorOptions\n ): Promise<Opportunity[]> {\n const minScore = options.minScore || 70;\n\n logger.verbose(`[OpportunityEvaluator.invoke] Analyzing ${candidates.length} candidates...`);\n\n if (candidates.length === 0) {\n logger.verbose('[OpportunityEvaluator] No candidates provided.');\n return [];\n }\n\n const opportunities: Opportunity[] = [];\n\n // Analyze each candidate in parallel (bounded)\n const promises = candidates.map(async (candidate) => {\n // Pass existing opportunities context if provided\n const existingContext = options.existingOpportunities || '';\n return this.analyzeMatch(sourceProfileContext, candidate, candidate.userId, existingContext);\n });\n\n const results = await Promise.all(promises);\n results.flat().forEach(op => {\n if (op.score >= minScore) {\n opportunities.push(op as Opportunity);\n }\n });\n\n // Sort by score and take top 1\n const out = opportunities.sort((a, b) => b.score - a.score).slice(0, 1);\n logger.verbose('[OpportunityEvaluator.invoke] Done', { accepted: out.length });\n return out;\n }\n\n /**\n * Analyze a single match pair using the primary Agent model.\n */\n private async analyzeMatch(\n sourceProfileContext: string,\n candidateProfile: CandidateProfile,\n candidateUserId: string,\n existingOpportunities: string\n ): Promise<Opportunity[]> {\n try {\n // Construct the source context part of the prompt\n const sourceContext = `SOURCE PROFILE:\\n${sourceProfileContext}`;\n\n const existingContextPart = existingOpportunities\n ? `\\nEXISTING OPPORTUNITIES (Deduplication Context):\\n${existingOpportunities}\\n`\n : '';\n\n // Create candidate context using template string\n const candidateContext = `\n ID: ${candidateUserId}\n Name: ${candidateProfile.identity?.name || 'Unknown'}\n Bio: ${candidateProfile.identity?.bio || ''}\n Location: ${candidateProfile.identity?.location || ''}\n Interests: ${candidateProfile.attributes?.interests?.join(', ') || ''}\n Skills: ${candidateProfile.attributes?.skills?.join(', ') || ''}\n\n Context: ${candidateProfile.narrative?.context || ''}\n `;\n\n const messages = [\n new SystemMessage(systemPrompt),\n new HumanMessage(`${sourceContext}\\n${existingContextPart}\\nCANDIDATE PROFILE:\\n${candidateContext}`)\n ];\n\n const result = await invokeWithAbortSignal(this.model, messages);\n const output = responseFormat.parse(result);\n\n const mappedOpportunities = output.opportunities.map((op: Opportunity) => ({\n ...op,\n reasoning: stripUuids(op.reasoning),\n candidateId: candidateUserId,\n }));\n\n return mappedOpportunities;\n } catch (e: unknown) {\n const message = e instanceof Error ? e.message : String(e);\n logger.warn(`[OpportunityEvaluator] Analysis failed for candidate ${candidateUserId}`, { message });\n throw e;\n }\n }\n\n /**\n * Entity-bundle entry point (C3): single LLM call with all entities, returns 0..N opportunities with actors.\n */\n @Timed()\n public async invokeEntityBundle(\n input: EvaluatorInput,\n options: { minScore?: number; returnAll?: boolean } = {}\n ): Promise<EvaluatedOpportunityWithActors[]> {\n const minScore = options.minScore ?? 70;\n const returnAll = options.returnAll ?? false;\n const totalEntities = input.entities?.length ?? 0;\n if (!input.entities?.length) {\n logger.verbose('[OpportunityEvaluator.invokeEntityBundle] No entities.');\n return [];\n }\n const existingPart = input.existingOpportunities\n ? `\\nEXISTING OPPORTUNITIES:\\n${input.existingOpportunities}\\n`\n : '';\n const introModePart = input.introductionMode\n ? `\\nINTRODUCTION MODE: This is a human-curated introduction. ${input.introducerName ?? 'The introducer'} (DISCOVERER: ${input.discovererId}) explicitly wants these people to connect. This is NOT an automatic discovery — a real person saw value in this connection.\n\nCRITICAL REASONING INSTRUCTIONS FOR INTRODUCTIONS:\n- Your reasoning MUST acknowledge that this is an introduction initiated by ${input.introducerName ?? 'the introducer'}, not a system-discovered match.\n- Start reasoning with something like \"${input.introducerName ?? 'The introducer'} is connecting [Name A] and [Name B] because...\" or \"This introduction by ${input.introducerName ?? 'the introducer'} brings together...\"\n- Even if the parties' intents or profiles don't obviously overlap, the introduction is still valid because the introducer saw the connection. Explain what the introducer likely sees in this match.\n- If explicit intents align, mention them — but frame it as supporting the introducer's judgment, not as the primary reason.${input.introductionHint ? `\\nINTRODUCER'S CONTEXT: \"${input.introductionHint}\" — use this to inform your reasoning about why the introducer made this connection.` : ''}\n- Actors must refer ONLY to the ENTITIES below (the people being introduced). Do not include the DISCOVERER as an actor.\n- You must output exactly two actors per opportunity (the two people being introduced). The introducer is added separately; do not include them in actors.\n- Be generous with scoring (70+ for any introduction with a plausible basis, since a human made the judgment).\n`\n : '';\n const discoveryQueryPart = input.discoveryQuery?.trim()\n ? `\\nDISCOVERY REQUEST: The user asked: \"${input.discoveryQuery.trim()}\"\n\nCRITICAL SCORING RULES FOR DISCOVERY REQUESTS:\n\n0. QUERY IS PRIMARY: The DISCOVERY REQUEST above is the primary evaluation criterion. The source user's stored INTENTS (if listed below) are background context — use them ONLY to fill in blanks when the query is too broad or vague to evaluate on its own. If the query is specific enough to score candidates, score strictly against the query and IGNORE stored intents. Never let a stored intent override or replace the query as the basis for scoring. When a specific query imposes a hard identity, role, capability, or location constraint, candidates that only match background context or thematic adjacency must score strictly below 30 and be omitted.\n\n1. CLASSIFY THE QUERY TYPE — determine the predication type before scoring:\n\n IDENTITY/ROLE QUERY: The query term is a count noun or sortal that can serve as a predicate nominal — \"X IS A [query]\" is grammatical and meaningful. Examples: \"samurai\", \"investors\", \"designers\", \"nurses\", \"founders\". The user wants someone who IS that thing — not someone who works with, creates content about, or is tangentially associated with it.\n → Test: Can you say \"this person IS a [query term]\"? If yes, this is an identity query.\n → CRITICAL: Subject-matter contact is NOT identity. A character designer who draws samurai IS NOT a samurai. An engineer who raised funding IS NOT an investor. A journalist who covers finance IS NOT an investor. IS-A is not transitive through creative subject matter, professional adjacency, or domain familiarity.\n\n TOPICAL/DOMAIN QUERY: The query is a field, domain, or abstract topic — \"X IS A [query]\" is ungrammatical. Examples: \"machine learning\", \"sustainability\", \"blockchain\". The user wants someone who works in or has expertise in this domain.\n → Test: \"This person IS a machine learning\" makes no sense → topical query.\n\n NEED/CAPABILITY QUERY: The query contains a purposive frame — \"someone to help with X\", \"need a Y\", \"looking for Z\". The user describes a specific need.\n\n2. APPLY TYPE-SPECIFIC SCORING:\n\n For IDENTITY/ROLE queries — apply a categorical gate:\n - First, make a binary IS-A judgment for each candidate: does this person's PRIMARY professional identity or self-description place them within the extension of the query term?\n - IS-A = TRUE → score 75-100 (modulated by intent alignment and profile richness)\n - IS-A = FALSE → score <30. Hard ceiling. Return no opportunity. Do NOT award surfacing credit for subject-matter adjacency, thematic association, creative output involving the query term, having received the thing, or being adjacent to people who are the thing.\n - Do NOT rescue a failed IS-A judgment with background intents. If the user searched \"samurai\" and the candidate is a visual artist (IS-A = false), the candidate's alignment with a background intent like \"connect with visual artists\" does not matter — the explicit query takes priority. If the user searched \"investors\" and the candidate merely raised money, score <30. If the user searched \"scouts\" and the candidate was scouted, score <30. If the user searched \"art director\", a solo illustrator is not enough: require explicit evidence that the candidate owns visual direction, leads/briefs other artists, manages a visual system, or is described as an art/creative director. General visual taste, composition skill, or illustration output alone is a failed IS-A judgment and must score <30.\n\n For TOPICAL/DOMAIN queries — apply gradient scoring:\n - 90-100: Deep expertise, primary focus area\n - 70-89: Substantial engagement, meaningful work in the domain\n - 50-69: Peripheral involvement, tangential connection\n - <50: No meaningful engagement\n\n For NEED/CAPABILITY queries — apply capability + availability scoring:\n - Score based on both capability match AND openness to the described collaboration\n - 90-100: Perfect capability match with explicit availability\n - 70-89: Strong capability, plausible availability\n\n3. SAME-SIDE CHECK: If the candidate's intents show they are ALSO SEEKING what the discoverer is seeking (e.g., both looking for investors, both looking for co-founders), this is a same-side match. Score <30 regardless of keyword overlap in bios. The candidate must BE or OFFER what the discoverer is looking for, not also be looking for it.\n\n4. LOCATION ENFORCEMENT: If the discovery request mentions a specific location (e.g., \"in SF\", \"based in London\", \"Istanbul\"), check each candidate's profile.location:\n - KNOWN MISMATCH (e.g., request says \"SF\" but candidate is \"New York\"): Score <30 and return no opportunity. State the mismatch in reasoning if returning diagnostic output. A known location mismatch is a hard query failure, even when the candidate otherwise matches the source's background interests.\n - UNKNOWN/EMPTY location: Do not penalize, and do NOT reject solely because the query contains a location. Treat location as unverified/missing evidence, then score on the non-location parts of the query. If the candidate strongly satisfies the requested role/domain (e.g., query \"Unreal Engine developers in SF\" and candidate is clearly an Unreal Engine developer with empty location), score normally enough to surface (typically 60-89) and note that location is unverified.\n - MATCH or COMPATIBLE (e.g., \"Bay Area\" ≈ \"SF\", \"Remote\" ≈ any): Score normally.\n`\n : '';\n const hasDiscoveryQuery = !!input.discoveryQuery?.trim();\n const entitiesBlock = input.entities.map((e) => {\n const isSource = e.userId === input.discovererId;\n // When an explicit discovery query is active, label the source user's stored\n // intents as background context so the LLM treats the query as primary.\n const intentsLabel = isSource && hasDiscoveryQuery ? 'BACKGROUND INTENTS (use only if query is too vague)' : 'INTENTS';\n const intentsPart = e.intents?.length\n ? `\\n ${intentsLabel}:\\n${e.intents.map((i) => ` - ${i.intentId}: ${i.payload}`).join('\\n')}`\n : '';\n // Mask the discoverer's name so the LLM cannot leak it into reasoning.\n // The system prompt already says \"use third-party references\", but the LLM\n // ignores this when the actual name is visible. Masking it forces role-based\n // language (\"the source user is looking…\" instead of \"Alice is looking…\").\n const displayName = e.userId === input.discovererId\n ? '(source user)'\n : (e.profile.name ?? '');\n return `\n USER: ${e.userId}\n INDEX: ${e.networkId}\n EVIDENCE KEY: ${e.evidenceKey ?? '—'}\n PROFILE: Name: ${displayName} | Bio: ${e.profile.bio ?? ''} | Location: ${e.profile.location ?? ''} | Interests: ${e.profile.interests?.join(', ') ?? ''} | Skills: ${e.profile.skills?.join(', ') ?? ''} | Context: ${e.profile.context ?? ''}${intentsPart}\n RAG SCORE: ${e.ragScore ?? '—'}\n MATCHED VIA: ${e.matchedVia ?? '—'}\n EVIDENCE:\n${renderOpportunityEvidenceForPrompt(e.evidence ?? [])}`;\n }).join('\\n');\n const networkContextPart = input.networkContexts && Object.keys(input.networkContexts).length > 0\n ? `\\n\\nNETWORK CONTEXTS:\\n${Object.entries(input.networkContexts).map(([nid, ctx]) => `[INDEX: ${nid}]\\n${ctx}`).join('\\n\\n')}`\n : '';\n const humanContent = `DISCOVERER: ${input.discovererId}${introModePart}${discoveryQueryPart}${networkContextPart}\\n\\nENTITIES:\\n${entitiesBlock}${existingPart}`;\n const messages = [\n new SystemMessage(entityBundleSystemPrompt),\n new HumanMessage(humanContent),\n ];\n let parsedTotal = 0;\n try {\n const result = await invokeWithAbortSignal(this.entityBundleModel, messages);\n const parsed = entityBundleResponseFormat.parse(result);\n for (const op of parsed.opportunities) {\n op.reasoning = stripUuids(op.reasoning);\n }\n parsedTotal = parsed.opportunities.length;\n const introGuard =\n input.introductionMode\n ? parsed.opportunities.filter((op) => op.actors.length === 2)\n : parsed.opportunities;\n const filtered = introGuard.filter((op) => op.score >= minScore);\n logger.verbose('[OpportunityEvaluator.invokeEntityBundle] Done', {\n total: parsed.opportunities.length,\n afterIntroGuard: introGuard.length,\n accepted: filtered.length,\n returnAll,\n });\n return returnAll ? introGuard : filtered;\n } catch (llmError) {\n logger.error('[OpportunityEvaluator.invokeEntityBundle] Failed', {\n discovererId: input.discovererId,\n totalEntities,\n parsedTotal,\n minScore,\n llmError,\n });\n throw llmError;\n }\n }\n\n /**\n * Factory method to expose the agent as a LangChain tool.\n * Simplified to only accept direct evaluation arguments.\n * PURE: Does not perform any database lookups.\n */\n public static asTool() {\n return tool(\n async (args: {\n sourceProfileContext: string;\n candidatesJson?: string;\n minScore?: number;\n }) => {\n const agent = new OpportunityEvaluator();\n\n const sourceProfileContext = args.sourceProfileContext;\n\n let candidates: CandidateProfile[] = [];\n if (args.candidatesJson) {\n try {\n candidates = JSON.parse(args.candidatesJson);\n } catch (e) {\n logger.error(\"Failed to parse candidates JSON\");\n }\n }\n\n const options: OpportunityEvaluatorOptions = {\n minScore: args.minScore,\n };\n\n return await agent.invoke(sourceProfileContext, candidates, options);\n },\n {\n name: 'opportunity_evaluator',\n description: 'Evaluates candidates against a source profile. SOURCE PROFILE CONTEXT MUST BE PROVIDED.',\n schema: z.object({\n sourceProfileContext: z.string().describe('The resolved source user profile context'),\n candidatesJson: z.string().optional().describe('JSON string list of Candidates'),\n minScore: z.number().optional().describe('Minimum score to accept a match')\n })\n }\n );\n }\n}\n"]}
1
+ {"version":3,"file":"opportunity.evaluator.js","sourceRoot":"/","sources":["opportunity/opportunity.evaluator.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAG5E,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAA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AE;;;;8DAyIP","sourcesContent":["import type { Runnable } from \"@langchain/core/runnables\";\nimport { HumanMessage, SystemMessage } from \"@langchain/core/messages\";\nimport { tool } from \"@langchain/core/tools\";\nimport { z } from \"zod\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport type { Lens } from \"../shared/hyde/lens.inferrer.js\";\nimport type { OpportunityStatus } from \"../shared/interfaces/database.interface.js\";\nimport { Timed } from \"../shared/observability/performance.js\";\nimport { stripUuids } from \"./opportunity.presentation.js\";\nimport { createStructuredModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\nimport type { OpportunityEvidence } from '../shared/schemas/network-assignment.schema.js';\nimport { renderOpportunityEvidenceForPrompt } from './opportunity.evidence.js';\n\nconst logger = protocolLogger(\"OpportunityEvaluator\");\n\n\n// ──────────────────────────────────────────────────────────────\n// 1. SYSTEM PROMPT\n// ──────────────────────────────────────────────────────────────\n\n\nconst systemPrompt = `\n You are an expert \"Opportunity Matcher\" and super-connector.\n Your Goal: Analyze a Source User's profile against a Candidate User's profile to identify A SINGLE HIGH-VALUE opportunity.\n\n Input:\n - Source Context: The Source User's own Profile.\n - Candidate Profile (JSON)\n - Existing Opportunities (Context of matches already made)\n\n Output:\n - A list containing EXACTLY ONE \"Opportunity\" if a match exists.\n - If NO match exists, return an empty list.\n - Score (0-100): How strong is this match?\n - 90-100: \"Must Meet\" (Perfect alignment).\n - 70-89: \"Should Meet\" (Strong overlaps, clear potential).\n - <70: No opportunity (Return empty list).\n\n **CRITICAL: VALENCY & REASONING**\n \n 1. **Valency Analysis**:\n - Determine the semantic role of the Candidate relative to the Source's goal.\n - \"Agent\": The Candidate CAN DO something for the Source (e.g., Source needs a dev, Candidate IS a dev).\n - \"Patient\": The Candidate NEEDS something from the Source (e.g., Source is a mentor, Candidate needs mentoring).\n - \"Peer\": Symmetric collaboration.\n\n 2. **Reasoning (Third-Party Analytical Perspective)**:\n - **reasoning**: A neutral, third-party explanation of why this opportunity exists. Written for other LLM agents to read and understand.\n - Mention BOTH users by their roles (e.g. \"The source user\" and \"The candidate\") and explain why they are a match.\n - Do NOT address either user as \"you\". Write from an objective observer's perspective.\n - Include what each side brings to the connection and why it is mutually valuable.\n - NEVER leak private intents. If someone's intent is confidential, describe their relevant attributes instead.\n\n **VISIBILITY IMPLICATIONS OF ROLE ASSIGNMENT**\n\n The valency role you assign directly controls who sees the opportunity and when:\n - \"Agent\" (helper/provider): LAST to see the opportunity — only after the Patient has committed to reaching out. Agents are protected from noise; they only see high-intent connections.\n - \"Patient\" (seeker/requester): Sees the opportunity early and decides whether to reach out.\n - \"Peer\" (symmetric): Both parties see the opportunity immediately and either can initiate.\n\n Choose the role carefully — it determines the entire flow of how the connection unfolds.\n\n Rules:\n 1. SYNTHESIS (CRITICAL): If multiple distinct match angles exist, SYNTHESIZE them into a SINGLE, robust opportunity.\n 2. NEVER address either user directly — always use third-party references (\"the source\", \"the candidate\").\n 3. COMPREHENSIVE: The single opportunity must capture ALL the value of the connection.\n 4. Be specific about the \"Why\" for BOTH sides in the reasoning.\n 5. DEDUPLICATION: Do NOT suggest opportunities that duplicate \"Existing Opportunities\".\n 6. Do not suggest an opportunity if the source and candidate clearly already know each other (e.g. same company, co-founders, same team).\n 7. SAME-SIDE MATCHING: If both the source and candidate are SEEKING the same resource (e.g., both looking for investors, both seeking a co-founder), this is not an opportunity. Return an empty list unless one side clearly OFFERS what the other SEEKS.\n`;\n\n// Entity-bundle system prompt (C2): entities + four match patterns + actors output\n// NOTE: entityBundleSystemPrompt uses a >= 30 threshold (permissive) while\n// systemPrompt uses >= 70 (strict). This is intentional: batch mode casts a wide\n// net so the calling pipeline can apply its own filters; pairwise mode is strict\n// because it returns a single yes/no decision per candidate pair.\nconst entityBundleSystemPrompt = `\nYou are an expert \"Opportunity Matcher\" and super-connector.\nYour Goal: Analyze a set of entities (people), each with a profile and optional intents, and identify HIGH-VALUE opportunities among them.\n\nInput:\n- DISCOVERER: The user ID who triggered discovery (for context; they may or may not be in the entity list).\n- ENTITIES: A set of entities. Each entity has:\n - userId, networkId (the index through which they were found)\n - evidenceKey (stable key for the matched resource when available)\n - profile: name, bio, location, interests, skills, context\n - intents (optional): list of { intentId, payload, summary } — some entities are profile-only, some have intents\n - ragScore, matchedVia (how they were found)\n - evidence (typed retrieval evidence: discovery kind, network, score, lens, source/candidate ids)\n- EXISTING OPPORTUNITIES: Context of matches already made (for deduplication).\n\nBEFORE SCORING — determine role satisfiability:\n\nDefinitions:\n SUBSTITUTIVE ROLE: The candidate can directly fill the open position in the discoverer's intent. The candidate IS the person/entity the discoverer is seeking. Example: discoverer seeks \"co-founder\" → candidate is an engineer willing to co-found.\n COMPLEMENTARY ROLE: The candidate's contribution is defined relative to the seeker-sought relation from the outside — they fund, advise, recruit for, or enable the sought relationship rather than participating in it as the target. Example: discoverer seeks \"co-founder\" → candidate is a VC (funds the company, does not co-found it).\n\nStep 1 — Identify the open argument in each discoverer intent: what type of person or entity would satisfy the intent if found?\nStep 2 — For each candidate, ask: can this candidate directly fill that open argument position?\n YES → substitutive role. Proceed to scoring.\n NO → complementary role. Apply Rule 7 (score ≤ 30, return no opportunity).\nStep 3 — Contextual override: if the candidate's profile contains explicit evidence that they currently function in the substitutive role (e.g., a former investor who is now building full-time as a technical co-founder), re-evaluate Step 2 against their current role, not their categorical label.\n\nMatch patterns to consider:\n1. Profile-to-profile: Complementary backgrounds (skills, interests, location).\n2. Profile-to-intents+profile: Someone's skills/background match another's stated goals (intents).\n3. Intents+profile-to-profile: Someone's stated goals match another's skills/background.\n4. Intents+profile-to-intents+profile: Complementary or reciprocal goals between two or more people.\n\nOutput:\n- A list of 0..N opportunities. Each opportunity has:\n - reasoning: Third-party analytical explanation (for other LLM agents). Mention entities by role. Do NOT use \"you\". Never leak private intents.\n - score: 0-100.\n - 90-100: Must Meet — candidate's PRIMARY role directly matches what the discoverer seeks.\n Example: discoverer seeks \"AI/ML co-founder\" → candidate IS an AI/ML engineer who wants to co-found.\n - 70-89: Should Meet — meaningful overlap on role type AND complementary intent.\n - 50-69: Worth Considering — tangential overlap only.\n - <30 (return empty): Complementary-role mismatch (candidate cannot fill the discoverer's open argument position), same-side match, or already acquainted.\n Example: discoverer seeks \"co-founder\" → candidate is a VC investor. The investor's contribution is external to the co-founding relation; they cannot substitute into it. Score 0.\n - IMPORTANT: Include ALL reasonable matches with scores >= 30, and ONLY those. Any candidate you would reject (complementary-role mismatch, same-side, already-acquainted, or a hard location mismatch) must score strictly below 30 and be omitted entirely — the surfacing threshold is 30, so a rejected candidate parked at exactly 30 would be wrongly surfaced.\n - actors: At least 2 actors per opportunity. Each actor has:\n - userId\n - role: \"agent\" (can do something for others), \"patient\" (needs something from others), \"peer\" (symmetric collaboration)\n - intentId (optional): if the match is intent-driven, the specific intent ID for that user\n - evidenceKey (optional): copy the entity evidenceKey when the actor is driven by a specific listed entity\n\nVISIBILITY (role controls who sees the opportunity when):\n- agent: Last to see — after the patient has committed to reaching out.\n- patient: Sees early and decides whether to reach out.\n- peer: Both see immediately; either can initiate.\n\nRules:\n1. ONE OPPORTUNITY PER CANDIDATE: Create a SEPARATE opportunity for EACH candidate who matches. Do NOT combine multiple candidates into one opportunity. Each opportunity should have exactly 2 actors: the DISCOVERER and ONE candidate.\n2. INDIVIDUAL REASONING: Write specific reasoning for EACH candidate individually. Do NOT mention other candidates in the reasoning. Focus on why THIS specific candidate matches THIS specific discoverer.\n3. DEDUPLICATION: Do not suggest opportunities that duplicate Existing Opportunities.\n4. Write reasoning from an objective observer's perspective; be specific about the \"Why\" for each side.\n5. When in introduction mode, each opportunity must have exactly two actors — the two people being introduced. The discoverer (introducer) is added by the system and must not be included in your actors list.\n6. ALREADY KNOW EACH OTHER: Do NOT suggest an opportunity if the entities clearly already know each other. Examples: co-founders of the same company, same team at the same organization, same employer, or any relationship that is obviously existing from their profiles (bio, context). When in doubt, if both profiles mention the same company/org/team in a way that implies they work together, return an empty list for that pair.\n7. ROLE-SATISFIABILITY (evaluate before scoring): A candidate satisfies a discoverer's intent only if they can fill the SUBSTITUTIVE ROLE — the open argument position in the intent (the type of person the discoverer is seeking). A candidate in a COMPLEMENTARY ROLE (one that funds, advises, recruits for, or otherwise enables the sought relation from outside it) does not satisfy the intent, regardless of how closely associated their domain is.\n COMPLEMENTARY-ROLE CAP: If the candidate occupies a complementary rather than substitutive role relative to the discoverer's intent, score below 30 (e.g. 0–20). Return no opportunity. A \"reject\" score must be strictly below 30 so the candidate is not surfaced — never park a rejected candidate at exactly 30.\n CONTEXTUAL OVERRIDE: If the candidate's profile contains explicit evidence that they currently function in the substitutive role (not merely historically or tangentially), treat them as substitutive and score normally.\n8. SAME-SIDE MATCHING: Before scoring, check whether the DISCOVERER and CANDIDATE are both SEEKING the same thing. Look at both parties' intents for directionality:\n - SEEKING signals: \"looking for\", \"seeking\", \"want to find\", \"need\", \"raising\", \"hiring\"\n - OFFERING signals: \"can offer\", \"expert in\", \"investing in\", \"mentoring\", \"available for\"\n If both parties have SEEKING intents targeting the same resource (e.g., both seeking investors, both seeking co-founders, both seeking mentorship), this is NOT an opportunity — score <30. An opportunity requires one side to OFFER what the other SEEKS.\n9. LOCATION MATCHING: When the DISCOVERY REQUEST mentions a specific location (city, region, or country):\n a. If a candidate's profile.location is KNOWN and clearly does NOT match the requested location (different city/region), score below 30 (e.g. 0–25) and return no opportunity. An explicitly requested location is a hard constraint: a known geographic mismatch excludes the candidate.\n b. If a candidate's profile.location is UNKNOWN, EMPTY, or AMBIGUOUS, do NOT penalize — allow them through and score based on other factors. Note in reasoning that their location is unverified.\n c. If a candidate's profile.location matches or is reasonably close (e.g., \"Bay Area\" matches \"San Francisco\", \"Remote\" matches any location), score normally.\n d. \"Remote\" or \"Global\" locations are compatible with any requested location.\n10. EVENT NETWORK AWARENESS: When NETWORK CONTEXTS includes an event-type network (identified by dates, location, schedule, or themes):\n a. TEMPORAL RELEVANCE: If the event has start/end dates, factor time into scoring. Intents about meeting at the event, sharing logistics, or collaborating during the event are highly relevant when the event is upcoming or in progress. After the event ends, such intents lose relevance — score lower unless the connection has lasting value beyond the event.\n b. THEME ALIGNMENT: Event networks may list themes or tracks. Candidates whose expertise or intents align with event themes should score higher for that network's entities.\n c. CO-ATTENDANCE SIGNAL: Two entities found through the same event network share a co-attendance signal — they will likely be in the same place at the same time. This is a positive signal for in-person collaboration opportunities.\n d. SCHEDULE CONTEXT: If the event network includes upcoming events or sessions, use them as additional matching context. Two people attending the same session or interested in the same topic track are stronger matches.\n e. CO-ATTENDANCE ROLE: When two co-attendees express mutual or reciprocal collaboration intent — each seeking to work with the other's type, with no clear one-directional provider/seeker split — assign the \"peer\" role to both. Symmetric, two-sided collaboration is a peer relationship, not an agent/patient one; default to \"peer\" rather than \"agent\" for co-attendance matches.\n`;\n\n// ──────────────────────────────────────────────────────────────\n// 2. RESPONSE SCHEMA (Zod)\n// ──────────────────────────────────────────────────────────────\n\nconst OpportunitySchema = z.object({\n reasoning: z.string().describe('Third-party analytical explanation of why this opportunity exists. Mentions both users by role. Written for other LLM agents to understand the match.'),\n score: z.number().min(0).max(100).describe('Relevance score 0-100'),\n valencyRole: z.enum(['Agent', 'Patient', 'Peer']).describe(\"The semantic role of the Candidate relative to the Source\"),\n sourceId: z.string().describe('The user ID of the source'),\n candidateId: z.string().describe('The user ID of the candidate'),\n});\n\nconst responseFormat = z.object({\n opportunities: z.array(OpportunitySchema).describe(\"List of opportunities identified\"),\n});\n\n// ─── Entity-bundle evaluator (C1): types and output schema with actors ───\n\nexport interface EvaluatorEntity {\n userId: string;\n profile: {\n name?: string;\n bio?: string;\n location?: string;\n interests?: string[];\n skills?: string[];\n context?: string;\n };\n intents?: Array<{\n intentId: string;\n payload: string;\n summary?: string;\n }>;\n networkId: string;\n evidenceKey?: string;\n ragScore?: number;\n matchedVia?: string;\n evidence?: OpportunityEvidence[];\n}\n\nexport interface EvaluatorInput {\n /** The user who triggered discovery (for context, not special treatment). */\n discovererId: string;\n /** All relevant entities. In introduction mode, only the people being introduced (no introducer). */\n entities: EvaluatorEntity[];\n /** Existing opportunities for deduplication. */\n existingOpportunities?: string;\n /** When true, DISCOVERER is the introducer; reasoning and actors must be only among ENTITIES. */\n introductionMode?: boolean;\n /** Name of the introducer (for attribution in reasoning when introductionMode is true). */\n introducerName?: string;\n /** Optional hint/context from the introducer about why these people should meet. */\n introductionHint?: string;\n /** Optional discovery query (e.g. from chat). When set, only suggest opportunities where candidates clearly match this request. */\n discoveryQuery?: string;\n /** Pre-rendered network context markdown, keyed by networkId. */\n networkContexts?: Record<string, string>;\n}\n\nconst ActorSchema = z.object({\n userId: z.string(),\n role: z.enum(['agent', 'patient', 'peer']),\n intentId: z.string().nullable().describe('If the match is intent-driven, the specific intent ID; null otherwise'),\n evidenceKey: z.string().nullable().optional().describe('Stable evidence key for the matched entity; null if unknown'),\n});\n\nconst OpportunityWithActorsSchema = z.object({\n reasoning: z.string(),\n score: z.number().min(0).max(100),\n actors: z.array(ActorSchema).min(2).describe('All actors in this opportunity with their roles'),\n});\n\nconst entityBundleResponseFormat = z.object({\n opportunities: z.array(OpportunityWithActorsSchema).describe('List of opportunities (0..N)'),\n});\n\nexport type EvaluatorActor = z.infer<typeof ActorSchema>;\nexport type EvaluatedOpportunityWithActors = z.infer<typeof OpportunityWithActorsSchema>;\nexport type EvaluatorOutputBundle = z.infer<typeof entityBundleResponseFormat>;\n\n// ──────────────────────────────────────────────────────────────\n// 3. TYPE DEFINITIONS\n// ──────────────────────────────────────────────────────────────\n\ntype Opportunity = z.infer<typeof OpportunitySchema>;\ntype EvaluatorOutput = z.infer<typeof responseFormat>;\n\n// Define CandidateProfile type (simplified for now, ideally imported from shared types)\nexport interface CandidateProfile {\n userId: string;\n identity?: { name?: string; bio?: string; location?: string };\n attributes?: { interests?: string[]; skills?: string[] };\n narrative?: { context?: string };\n score?: number; // Search score\n}\n\ninterface OpportunityEvaluatorOptions {\n minScore?: number;\n limit?: number;\n hydeDescription?: string;\n /** Pre-inferred lenses (if not provided, lens inference runs automatically in HyDE graph). */\n lenses?: Lens[];\n existingOpportunities?: string;\n candidates?: CandidateProfile[]; // For direct evaluation\n filter?: Record<string, unknown>;\n initialStatus?: OpportunityStatus;\n}\n\n// ──────────────────────────────────────────────────────────────\n// 4. CLASS DEFINITION\n// ──────────────────────────────────────────────────────────────\n\n/** Optional test double for entity-bundle model (avoids live LLM in unit tests). */\nexport type OpportunityEvaluatorOptionsConstructor = {\n entityBundleModel?: Runnable;\n};\n\nexport class OpportunityEvaluator {\n private model: Runnable;\n private entityBundleModel: Runnable;\n\n constructor(options?: OpportunityEvaluatorOptionsConstructor) {\n this.model = createStructuredModel(\"opportunityEvaluator\", responseFormat, {\n name: \"opportunity_evaluator\"\n });\n this.entityBundleModel = options?.entityBundleModel ?? createStructuredModel(\"opportunityEvaluator\", entityBundleResponseFormat, {\n name: \"opportunity_evaluator_entity_bundle\"\n });\n }\n\n /**\n * Main Entry Point: Batch analysis of candidates.\n * \n * @param sourceProfileContext - The profile context string of the user we are finding opportunities FOR.\n * @param candidates - List of potential matches to evaluate.\n * @param options - Config (minScore, valid types, etc).\n * @returns A sorted list of high-value `Opportunity` objects.\n */\n @Timed()\n public async invoke(\n sourceProfileContext: string,\n candidates: CandidateProfile[],\n options: OpportunityEvaluatorOptions\n ): Promise<Opportunity[]> {\n const minScore = options.minScore || 70;\n\n logger.verbose(`[OpportunityEvaluator.invoke] Analyzing ${candidates.length} candidates...`);\n\n if (candidates.length === 0) {\n logger.verbose('[OpportunityEvaluator] No candidates provided.');\n return [];\n }\n\n const opportunities: Opportunity[] = [];\n\n // Analyze each candidate in parallel (bounded)\n const promises = candidates.map(async (candidate) => {\n // Pass existing opportunities context if provided\n const existingContext = options.existingOpportunities || '';\n return this.analyzeMatch(sourceProfileContext, candidate, candidate.userId, existingContext);\n });\n\n const results = await Promise.all(promises);\n results.flat().forEach(op => {\n if (op.score >= minScore) {\n opportunities.push(op as Opportunity);\n }\n });\n\n // Sort by score and take top 1\n const out = opportunities.sort((a, b) => b.score - a.score).slice(0, 1);\n logger.verbose('[OpportunityEvaluator.invoke] Done', { accepted: out.length });\n return out;\n }\n\n /**\n * Analyze a single match pair using the primary Agent model.\n */\n private async analyzeMatch(\n sourceProfileContext: string,\n candidateProfile: CandidateProfile,\n candidateUserId: string,\n existingOpportunities: string\n ): Promise<Opportunity[]> {\n try {\n // Construct the source context part of the prompt\n const sourceContext = `SOURCE PROFILE:\\n${sourceProfileContext}`;\n\n const existingContextPart = existingOpportunities\n ? `\\nEXISTING OPPORTUNITIES (Deduplication Context):\\n${existingOpportunities}\\n`\n : '';\n\n // Create candidate context using template string\n const candidateContext = `\n ID: ${candidateUserId}\n Name: ${candidateProfile.identity?.name || 'Unknown'}\n Bio: ${candidateProfile.identity?.bio || ''}\n Location: ${candidateProfile.identity?.location || ''}\n Interests: ${candidateProfile.attributes?.interests?.join(', ') || ''}\n Skills: ${candidateProfile.attributes?.skills?.join(', ') || ''}\n\n Context: ${candidateProfile.narrative?.context || ''}\n `;\n\n const messages = [\n new SystemMessage(systemPrompt),\n new HumanMessage(`${sourceContext}\\n${existingContextPart}\\nCANDIDATE PROFILE:\\n${candidateContext}`)\n ];\n\n const result = await invokeWithAbortSignal(this.model, messages);\n const output = responseFormat.parse(result);\n\n const mappedOpportunities = output.opportunities.map((op: Opportunity) => ({\n ...op,\n reasoning: stripUuids(op.reasoning),\n candidateId: candidateUserId,\n }));\n\n return mappedOpportunities;\n } catch (e: unknown) {\n const message = e instanceof Error ? e.message : String(e);\n logger.warn(`[OpportunityEvaluator] Analysis failed for candidate ${candidateUserId}`, { message });\n throw e;\n }\n }\n\n /**\n * Entity-bundle entry point (C3): single LLM call with all entities, returns 0..N opportunities with actors.\n */\n @Timed()\n public async invokeEntityBundle(\n input: EvaluatorInput,\n options: { minScore?: number; returnAll?: boolean } = {}\n ): Promise<EvaluatedOpportunityWithActors[]> {\n const minScore = options.minScore ?? 70;\n const returnAll = options.returnAll ?? false;\n const totalEntities = input.entities?.length ?? 0;\n if (!input.entities?.length) {\n logger.verbose('[OpportunityEvaluator.invokeEntityBundle] No entities.');\n return [];\n }\n const existingPart = input.existingOpportunities\n ? `\\nEXISTING OPPORTUNITIES:\\n${input.existingOpportunities}\\n`\n : '';\n const introModePart = input.introductionMode\n ? `\\nINTRODUCTION MODE: This is a human-curated introduction. ${input.introducerName ?? 'The introducer'} (DISCOVERER: ${input.discovererId}) explicitly wants these people to connect. This is NOT an automatic discovery — a real person saw value in this connection.\n\nCRITICAL REASONING INSTRUCTIONS FOR INTRODUCTIONS:\n- Your reasoning MUST acknowledge that this is an introduction initiated by ${input.introducerName ?? 'the introducer'}, not a system-discovered match.\n- Start reasoning with something like \"${input.introducerName ?? 'The introducer'} is connecting [Name A] and [Name B] because...\" or \"This introduction by ${input.introducerName ?? 'the introducer'} brings together...\"\n- Even if the parties' intents or profiles don't obviously overlap, the introduction is still valid because the introducer saw the connection. Explain what the introducer likely sees in this match.\n- If explicit intents align, mention them — but frame it as supporting the introducer's judgment, not as the primary reason.${input.introductionHint ? `\\nINTRODUCER'S CONTEXT: \"${input.introductionHint}\" — use this to inform your reasoning about why the introducer made this connection.` : ''}\n- Actors must refer ONLY to the ENTITIES below (the people being introduced). Do not include the DISCOVERER as an actor.\n- You must output exactly two actors per opportunity (the two people being introduced). The introducer is added separately; do not include them in actors.\n- Be generous with scoring (70+ for any introduction with a plausible basis, since a human made the judgment).\n`\n : '';\n const discoveryQueryPart = input.discoveryQuery?.trim()\n ? `\\nDISCOVERY REQUEST: The user asked: \"${input.discoveryQuery.trim()}\"\n\nCRITICAL SCORING RULES FOR DISCOVERY REQUESTS:\n\n0. QUERY IS PRIMARY: The DISCOVERY REQUEST above is the primary evaluation criterion. The source user's stored INTENTS (if listed below) are background context — use them ONLY to fill in blanks when the query is too broad or vague to evaluate on its own. If the query is specific enough to score candidates, score strictly against the query and IGNORE stored intents. Never let a stored intent override or replace the query as the basis for scoring. When a specific query imposes a hard identity, role, capability, or location constraint, candidates that only match background context or thematic adjacency must score strictly below 30 and be omitted.\n\n1. CLASSIFY THE QUERY TYPE — determine the predication type before scoring:\n\n IDENTITY/ROLE QUERY: The query term is a count noun or sortal that can serve as a predicate nominal — \"X IS A [query]\" is grammatical and meaningful. Examples: \"samurai\", \"investors\", \"designers\", \"nurses\", \"founders\". The user wants someone who IS that thing — not someone who works with, creates content about, or is tangentially associated with it.\n → Test: Can you say \"this person IS a [query term]\"? If yes, this is an identity query.\n → CRITICAL: Subject-matter contact is NOT identity. A character designer who draws samurai IS NOT a samurai. An engineer who raised funding IS NOT an investor. A journalist who covers finance IS NOT an investor. IS-A is not transitive through creative subject matter, professional adjacency, or domain familiarity.\n\n TOPICAL/DOMAIN QUERY: The query is a field, domain, or abstract topic — \"X IS A [query]\" is ungrammatical. Examples: \"machine learning\", \"sustainability\", \"blockchain\". The user wants someone who works in or has expertise in this domain.\n → Test: \"This person IS a machine learning\" makes no sense → topical query.\n\n NEED/CAPABILITY QUERY: The query contains a purposive frame — \"someone to help with X\", \"need a Y\", \"looking for Z\". The user describes a specific need.\n\n2. APPLY TYPE-SPECIFIC SCORING:\n\n For IDENTITY/ROLE queries — apply a categorical gate:\n - First, make a binary IS-A judgment for each candidate: does this person's PRIMARY professional identity or self-description place them within the extension of the query term?\n - IS-A = TRUE → score 75-100 (modulated by intent alignment and profile richness)\n - IS-A = FALSE → score <30. Hard ceiling. Return no opportunity. Do NOT award surfacing credit for subject-matter adjacency, thematic association, creative output involving the query term, having received the thing, or being adjacent to people who are the thing.\n - Do NOT rescue a failed IS-A judgment with background intents. If the user searched \"samurai\" and the candidate is a visual artist (IS-A = false), the candidate's alignment with a background intent like \"connect with visual artists\" does not matter — the explicit query takes priority. If the user searched \"investors\" and the candidate merely raised money, score <30. If the user searched \"scouts\" and the candidate was scouted, score <30. If the user searched \"art director\", a solo illustrator is not enough: require explicit evidence that the candidate owns visual direction, leads/briefs other artists, manages a visual system, or is described as an art/creative director. General visual taste, composition skill, or illustration output alone is a failed IS-A judgment and must score <30.\n\n For TOPICAL/DOMAIN queries — apply gradient scoring:\n - 90-100: Deep expertise, primary focus area\n - 70-89: Substantial engagement, meaningful work in the domain\n - 50-69: Peripheral involvement, tangential connection\n - <50: No meaningful engagement\n\n For NEED/CAPABILITY queries — apply capability + availability scoring:\n - Score based on both capability match AND openness to the described collaboration\n - 90-100: Perfect capability match with explicit availability\n - 70-89: Strong capability, plausible availability\n\n3. SAME-SIDE CHECK: If the candidate's intents show they are ALSO SEEKING what the discoverer is seeking (e.g., both looking for investors, both looking for co-founders), this is a same-side match. Score <30 regardless of keyword overlap in bios. The candidate must BE or OFFER what the discoverer is looking for, not also be looking for it.\n\n4. LOCATION ENFORCEMENT: If the discovery request mentions a specific location (e.g., \"in SF\", \"based in London\", \"Istanbul\"), check each candidate's profile.location:\n - KNOWN MISMATCH (e.g., request says \"SF\" but candidate is \"New York\"): Score <30 and return no opportunity. State the mismatch in reasoning if returning diagnostic output. A known location mismatch is a hard query failure, even when the candidate otherwise matches the source's background interests.\n - UNKNOWN/EMPTY location: Do not penalize, and do NOT reject solely because the query contains a location. Treat location as unverified/missing evidence, then score on the non-location parts of the query. If the candidate strongly satisfies the requested role/domain (e.g., query \"Unreal Engine developers in SF\" and candidate is clearly an Unreal Engine developer with empty location), score normally enough to surface (typically 60-89) and note that location is unverified.\n - MATCH or COMPATIBLE (e.g., \"Bay Area\" ≈ \"SF\", \"Remote\" ≈ any): Score normally.\n`\n : '';\n const hasDiscoveryQuery = !!input.discoveryQuery?.trim();\n const entitiesBlock = input.entities.map((e) => {\n const isSource = e.userId === input.discovererId;\n // When an explicit discovery query is active, label the source user's stored\n // intents as background context so the LLM treats the query as primary.\n const intentsLabel = isSource && hasDiscoveryQuery ? 'BACKGROUND INTENTS (use only if query is too vague)' : 'INTENTS';\n const intentsPart = e.intents?.length\n ? `\\n ${intentsLabel}:\\n${e.intents.map((i) => ` - ${i.intentId}: ${i.payload}`).join('\\n')}`\n : '';\n // Mask the discoverer's name so the LLM cannot leak it into reasoning.\n // The system prompt already says \"use third-party references\", but the LLM\n // ignores this when the actual name is visible. Masking it forces role-based\n // language (\"the source user is looking…\" instead of \"Alice is looking…\").\n const displayName = e.userId === input.discovererId\n ? '(source user)'\n : (e.profile.name ?? '');\n return `\n USER: ${e.userId}\n INDEX: ${e.networkId}\n EVIDENCE KEY: ${e.evidenceKey ?? '—'}\n PROFILE: Name: ${displayName} | Bio: ${e.profile.bio ?? ''} | Location: ${e.profile.location ?? ''} | Interests: ${e.profile.interests?.join(', ') ?? ''} | Skills: ${e.profile.skills?.join(', ') ?? ''} | Context: ${e.profile.context ?? ''}${intentsPart}\n RAG SCORE: ${e.ragScore ?? '—'}\n MATCHED VIA: ${e.matchedVia ?? '—'}\n EVIDENCE:\n${renderOpportunityEvidenceForPrompt(e.evidence ?? [])}`;\n }).join('\\n');\n const networkContextPart = input.networkContexts && Object.keys(input.networkContexts).length > 0\n ? `\\n\\nNETWORK CONTEXTS:\\n${Object.entries(input.networkContexts).map(([nid, ctx]) => `[INDEX: ${nid}]\\n${ctx}`).join('\\n\\n')}`\n : '';\n const humanContent = `DISCOVERER: ${input.discovererId}${introModePart}${discoveryQueryPart}${networkContextPart}\\n\\nENTITIES:\\n${entitiesBlock}${existingPart}`;\n const messages = [\n new SystemMessage(entityBundleSystemPrompt),\n new HumanMessage(humanContent),\n ];\n let parsedTotal = 0;\n try {\n const result = await invokeWithAbortSignal(this.entityBundleModel, messages);\n const parsed = entityBundleResponseFormat.parse(result);\n for (const op of parsed.opportunities) {\n op.reasoning = stripUuids(op.reasoning);\n }\n parsedTotal = parsed.opportunities.length;\n const introGuard =\n input.introductionMode\n ? parsed.opportunities.filter((op) => op.actors.length === 2)\n : parsed.opportunities;\n const filtered = introGuard.filter((op) => op.score >= minScore);\n logger.verbose('[OpportunityEvaluator.invokeEntityBundle] Done', {\n total: parsed.opportunities.length,\n afterIntroGuard: introGuard.length,\n accepted: filtered.length,\n returnAll,\n });\n return returnAll ? introGuard : filtered;\n } catch (llmError) {\n logger.error('[OpportunityEvaluator.invokeEntityBundle] Failed', {\n discovererId: input.discovererId,\n totalEntities,\n parsedTotal,\n minScore,\n llmError,\n });\n throw llmError;\n }\n }\n\n /**\n * Factory method to expose the agent as a LangChain tool.\n * Simplified to only accept direct evaluation arguments.\n * PURE: Does not perform any database lookups.\n */\n public static asTool() {\n return tool(\n async (args: {\n sourceProfileContext: string;\n candidatesJson?: string;\n minScore?: number;\n }) => {\n const agent = new OpportunityEvaluator();\n\n const sourceProfileContext = args.sourceProfileContext;\n\n let candidates: CandidateProfile[] = [];\n if (args.candidatesJson) {\n try {\n candidates = JSON.parse(args.candidatesJson);\n } catch (e) {\n logger.error(\"Failed to parse candidates JSON\");\n }\n }\n\n const options: OpportunityEvaluatorOptions = {\n minScore: args.minScore,\n };\n\n return await agent.invoke(sourceProfileContext, candidates, options);\n },\n {\n name: 'opportunity_evaluator',\n description: 'Evaluates candidates against a source profile. SOURCE PROFILE CONTEXT MUST BE PROVIDED.',\n schema: z.object({\n sourceProfileContext: z.string().describe('The resolved source user profile context'),\n candidatesJson: z.string().optional().describe('JSON string list of Candidates'),\n minScore: z.number().optional().describe('Minimum score to accept a match')\n })\n }\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"opportunity.presenter.d.ts","sourceRoot":"/","sources":["opportunity/opportunity.presenter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAC7F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAG1E;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,0BAA0B,EAC1B,YAAY,GAAG,kBAAkB,GAAG,YAAY,GAAG,oBAAoB,CACxE,CAAC;AAcF,QAAA,MAAM,kBA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ACxB,OAAO,CAAC,aAAa,CAAW;;YAWlB,iBAAiB;IA4B/B;;OAEG;IAEU,OAAO,CAClB,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,6BAA6B,CAAC;IAuDzC;;;;;;;OAOG;IAEU,eAAe,CAC1B,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,iBAAiB,CAAC;IAyG7B;;OAEG;IAEU,YAAY,CACvB,MAAM,EAAE,cAAc,EAAE,EACxB,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GACjC,OAAO,CAAC,6BAA6B,EAAE,CAAC;IAa3C;;;OAGG;IAEU,oBAAoB,CAC/B,MAAM,EAAE,sBAAsB,EAAE,EAChC,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GACjC,OAAO,CAAC,iBAAiB,EAAE,CAAC;CAYhC;AA0ED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,EAChB,wBAAwB,CAAC,EAAE,MAAM,GAChC,OAAO,CAAC,cAAc,CAAC,CAkOzB"}
@@ -19,12 +19,11 @@ import { HumanMessage, SystemMessage } from "@langchain/core/messages";
19
19
  import { z } from "zod";
20
20
  import { Timed } from "../shared/observability/performance.js";
21
21
  import { protocolLogger } from "../shared/observability/protocol.logger.js";
22
- import { createModel } from "../shared/agent/model.config.js";
22
+ import { createStructuredModel } from "../shared/agent/model.config.js";
23
23
  import { viewerCentricCardSummary } from "./opportunity.presentation.js";
24
24
  import { stripUuids, stripIntroducerMentions, truncateAtBoundary } from "./opportunity.presentation.js";
25
25
  const logger = protocolLogger("OpportunityPresenter");
26
26
  const LLM_TIMEOUT_MS = 20000;
27
- const model = createModel("opportunityPresenter");
28
27
  const GREETING_DESCRIPTION = "A 2-4 sentence first-person message the viewer could send to the counterpart, in the viewer's voice, referencing what they have in common. Plain prose only — no markdown, no greeting prefix like 'Hey {Name},'. Example body: 'Saw we're both working on regenerative coordination tooling — your post on consent flows resonated. Would love to compare notes if you have time this week.'";
29
28
  // ──────────────────────────────────────────────────────────────
30
29
  // SCHEMA & TYPES
@@ -197,10 +196,10 @@ When the viewer is the introducer and the opportunity status is "latent", the in
197
196
  // ──────────────────────────────────────────────────────────────
198
197
  export class OpportunityPresenter {
199
198
  constructor() {
200
- this.model = model.withStructuredOutput(responseFormat, {
199
+ this.model = createStructuredModel("opportunityPresenter", responseFormat, {
201
200
  name: "opportunity_presenter",
202
201
  });
203
- this.homeCardModel = model.withStructuredOutput(homeCardResponseFormat, {
202
+ this.homeCardModel = createStructuredModel("opportunityPresenter", homeCardResponseFormat, {
204
203
  name: "opportunity_presenter_home_card",
205
204
  });
206
205
  }
@@ -1 +1 @@
1
- {"version":3,"file":"opportunity.presenter.js","sourceRoot":"/","sources":["opportunity/opportunity.presenter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;;;;;;;;;AAGH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIzE,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAWxG,MAAM,MAAM,GAAG,cAAc,CAAC,sBAAsB,CAAC,CAAC;AACtD,MAAM,cAAc,GAAG,KAAM,CAAC;AAE9B,MAAM,KAAK,GAAG,WAAW,CAAC,sBAAsB,CAAC,CAAC;AAElD,MAAM,oBAAoB,GACxB,+XAA+X,CAAC;AAElY,iEAA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EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE;QAChF,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,mBAAmB,GAAG,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAClE,MAAM,cAAc,GAClB,eAAe,IAAI,MAAM,CAAC,SAAS;QACjC,CAAC,CAAC,wBAAwB,CACtB,MAAM,CAAC,SAAS,EAChB,eAAe,EACf,GAAG,EACH,mBAAmB,EACnB,cAAc,CACf;QACH,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAEnC,IAAI,oBAAoB,EAAE,CAAC;QACzB,aAAa,IAAI,oBAAoB,CAAC;IACxC,CAAC;IACD,IAAI,mBAAmB,EAAE,CAAC;QACxB,iBAAiB,IAAI,mBAAmB,CAAC;IAC3C,CAAC;IAED,MAAM,MAAM,GAAmB;QAC7B,aAAa;QACb,iBAAiB;QACjB,cAAc;QACd,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,YAAY;QACzC,UAAU,EACR,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ;YACnC,CAAC,CAAC,MAAM,CAAC,UAAU;YACnB,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACrD,cAAc;QACd,SAAS,EAAE,WAAW,EAAE,KAAK,IAAI,cAAc,IAAI,EAAE;QACrD,UAAU,EAAE,OAAO,CAAC,IAAI,IAAI,OAAO;QACnC,cAAc;QACd,cAAc;KACf,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Opportunity Presenter Agent\n *\n * Generates personalized, second-person explanations of why an opportunity\n * matters to the viewing user. Uses full opportunity data (interpretation,\n * actors, profiles, intents, index) to produce headline, personalizedSummary,\n * and suggestedAction for chat tools and user-facing surfaces.\n */\n\nimport type { Runnable } from \"@langchain/core/runnables\";\nimport { HumanMessage, SystemMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod\";\n\nimport { Timed } from \"../shared/observability/performance.js\";\n\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { createModel } from \"../shared/agent/model.config.js\";\nimport { viewerCentricCardSummary } from \"./opportunity.presentation.js\";\nimport type { Opportunity } from \"../shared/interfaces/database.interface.js\";\nimport type { ChatGraphCompositeDatabase } from \"../shared/interfaces/database.interface.js\";\nimport type { NegotiationContext } from \"./negotiation-context.loader.js\";\nimport { stripUuids, stripIntroducerMentions, truncateAtBoundary } from \"./opportunity.presentation.js\";\n\n/**\n * Minimal database interface required by gatherPresenterContext.\n * Any database adapter that implements these three methods can be passed.\n */\nexport type PresenterDatabase = Pick<\n ChatGraphCompositeDatabase,\n \"getProfile\" | \"getActiveIntents\" | \"getNetwork\" | \"getPremisesForUser\"\n>;\n\nconst logger = protocolLogger(\"OpportunityPresenter\");\nconst LLM_TIMEOUT_MS = 20_000;\n\nconst model = createModel(\"opportunityPresenter\");\n\nconst GREETING_DESCRIPTION =\n \"A 2-4 sentence first-person message the viewer could send to the counterpart, in the viewer's voice, referencing what they have in common. Plain prose only — no markdown, no greeting prefix like 'Hey {Name},'. Example body: 'Saw we're both working on regenerative coordination tooling — your post on consent flows resonated. Would love to compare notes if you have time this week.'\";\n\n// ──────────────────────────────────────────────────────────────\n// SCHEMA & TYPES\n// ──────────────────────────────────────────────────────────────\n\nconst PresentationSchema = z.object({\n headline: z\n .string()\n .describe(\n \"Short, compelling headline for this opportunity (e.g., 'A React expert who needs your design skills')\",\n ),\n personalizedSummary: z\n .string()\n .describe(\n \"2-3 sentence explanation using 'you' language, explaining why this opportunity is specifically valuable for the viewer based on their intents and profile\",\n ),\n suggestedAction: z.string().describe(\"Brief suggested next step\"),\n greeting: z.string().max(500).describe(GREETING_DESCRIPTION),\n});\n\nconst responseFormat = z.object({\n presentation: PresentationSchema,\n});\n\nexport type OpportunityPresentationResult = z.infer<typeof PresentationSchema> & {\n /** True when the LLM call failed and this is fallback-shaped copy built from raw reasoning. */\n isFallback?: boolean;\n};\n\n/** Input for home-card presenter call; extends PresenterInput with optional mutual intent count. */\nexport interface HomeCardPresenterInput extends PresenterInput {\n /** Number of overlapping intents (for generating mutualIntentsLabel). */\n mutualIntentCount?: number;\n /**\n * Snapshot of the opportunity's negotiation, if one exists. When status is\n * `negotiating`, the presenter returns a templated chip without invoking\n * the LLM. For `pending`/`stalled`/`accepted`/`rejected`, the full\n * transcript and outcome ground the LLM's explanation.\n */\n negotiationContext?: NegotiationContext;\n}\n\n/** LLM-generated fields for home-card presentation (buttons are hardcoded by callers, not LLM-generated). */\nexport const HomeCardLLMSchema = z.object({\n headline: z\n .string()\n .describe(\"Short, compelling headline for this opportunity\"),\n personalizedSummary: z\n .string()\n .describe(\n \"2-3 sentence explanation in 'you' language for the main card body\",\n ),\n digestSummary: z\n .string()\n .max(220)\n .describe(\n \"One concise digest-ready sentence for a morning brief. It must be addressed to the viewer and mention the counterpart by name, e.g. 'You might like meeting Paul because ...'. No markdown.\",\n ),\n suggestedAction: z\n .string()\n .describe(\"Brief suggested next step (e.g. CTA line)\"),\n narratorRemark: z\n .string()\n .max(80)\n .describe(\n \"One short sentence for the narrator chip, max ~80 chars (e.g. who is suggesting and why)\",\n ),\n mutualIntentsLabel: z\n .string()\n .max(48)\n .describe(\n \"Short line for the subtitle under the other party name (e.g. '3 mutual intents', 'Shared interests', 'Aligned goals'). NEVER output '0 mutual intents' — use a qualitative phrase like 'Shared interests' when no numeric count is available.\",\n ),\n greeting: z.string().max(500).describe(GREETING_DESCRIPTION),\n});\n\n/** LLM-generated result from presentHomeCard (callers append button labels from opportunity.constants). */\nexport type HomeCardLLMResult = z.infer<typeof HomeCardLLMSchema> & {\n /**\n * True when the LLM call failed and this is fallback-shaped copy built from\n * raw match reasoning. Callers with strict quality requirements (digests,\n * long-lived caches) should check this before sending/persisting — fallback\n * output is otherwise indistinguishable from genuine LLM output.\n */\n isFallback?: boolean;\n};\n\n/** Full home-card display contract including hardcoded button labels (assembled by callers). */\nexport type HomeCardPresentationResult = HomeCardLLMResult & {\n primaryActionLabel: string;\n secondaryActionLabel: string;\n};\n\nconst homeCardResponseFormat = z.object({\n presentation: HomeCardLLMSchema,\n});\n\n/** Input for a single presenter call (all context pre-assembled). */\nexport interface PresenterInput {\n viewerContext: string;\n otherPartyContext: string;\n matchReasoning: string;\n category: string;\n confidence: number;\n signalsSummary: string;\n indexName: string;\n viewerRole: string;\n opportunityStatus?: string;\n /** True when this opportunity was created via an explicit introduction (not automatic discovery). */\n isIntroduction?: boolean;\n /** Name of the person who made the introduction, if applicable. */\n introducerName?: string;\n}\n\n// ──────────────────────────────────────────────────────────────\n// SYSTEM PROMPT\n// ──────────────────────────────────────────────────────────────\n\nconst systemPrompt = `\nYou are an expert at presenting connection opportunities to users in a way that feels personal and compelling.\n\nYour goal: Given raw context about the viewer (their profile, intents), the other person(s), and why the system matched them, produce a short headline, a personalized summary, and a suggested action.\n\nRules:\n1. Address the VIEWER directly using \"you\" and \"your\". This is for them.\n2. Be concise and compelling — not analytical or third-party. No \"The source user\" or \"The candidate\"; use names or \"they\" where needed.\n3. Do not leak private or confidential details. Use only the context provided.\n4. Vary user-facing nouns naturally. Do not repeatedly use the same label in one response.\n5. If possible, avoid repeating \"opportunity\" in both headline and summary. Prefer alternatives like \"connection\", \"thought partner\", \"mutual fit\", \"valuable conversation\", or \"peer\".\n6. Prefer first names in user-facing copy. Do not repeatedly use full names unless needed to disambiguate.\n\n**Introduction-originated opportunities:**\nWhen INTRODUCTION CONTEXT is provided, this opportunity was explicitly created by an introducer (a real person who saw value in this connection). This is NOT an automatic system discovery — someone made a deliberate judgment.\n- For ALL roles: acknowledge the introducer's role naturally. E.g., \"[Introducer name] thinks you should meet [other person]\" or \"[Introducer name] connected you because...\"\n- The introduction itself is a strong signal — treat it with the weight of a personal recommendation.\n- If the parties' intents don't obviously overlap, that's fine — the introducer saw something worth connecting. Focus on what the introducer likely saw.\n\n**Role-Specific Presentation:**\n\n**If viewer is \"introducer\":**\n- The viewer suggested this connection between two (or more) OTHER people. The opportunity is NOT about the viewer's own needs.\n- Headline: describe the connection between the parties (e.g., \"Connecting a React expert with a startup founder\").\n- Personalized summary: explain why the people YOU are introducing should meet. Reference THEIR profiles and intents, not yours. Frame it as \"you're connecting X and Y because...\" rather than \"this matches your intent\".\n- Suggested action: guide sharing (e.g., \"Share this with [name] to get things started\").\n- CRITICAL: Do NOT reference the introducer's own intents, skills, or needs. The introducer is the matchmaker, not a party.\n\n**If viewer is \"patient\" or \"party\":**\n- Reference their specific intents, skills, or interests that align with this opportunity.\n- If this is an introduction: mention who introduced them and frame it as a personal recommendation.\n- Headline: one short line that hooks (e.g., \"[Name] thinks you should meet [Other]\" or \"A React expert who needs your design skills\").\n- Personalized summary: 2-3 sentences. Why is this opportunity for *them*? If introduced, lead with the introduction.\n- Suggested action: encourage action (\"Send a message to start the conversation\" or \"Share this intro\").\n\n**If viewer is \"agent\":**\n- They are seeing this because someone already reached out.\n- If this is an introduction: mention who made the introduction.\n- Reference their skills/expertise that make them a match.\n- Headline: what the other person needs that they can provide.\n- Personalized summary: 2-3 sentences. Why someone reached out to them.\n- Suggested action: \"Someone is interested in connecting — check their message\" or \"Review and respond\".\n\n**If viewer is \"peer\":**\n- Mutual opportunity. Reference shared or complementary interests.\n- If this is an introduction: mention who connected them.\n- Headline: the mutual connection angle.\n- Personalized summary: 2-3 sentences. Why this is mutually valuable.\n- Suggested action: \"Send an intro to connect\" or \"Start a conversation\".\n`;\n\nconst homeCardSystemPrompt = `\nYou are an expert at presenting connection opportunities for a home feed card.\n\nGiven context about the viewer, the other person, and why they were matched, produce:\n1. headline: one short hook line.\n2. personalizedSummary: 2-3 sentences in \"you\" language (main body text).\n3. digestSummary: one polished morning-brief sentence that can be printed directly after the person's linked name. No markdown, no field labels.\n4. suggestedAction: one brief suggested next step.\n5. narratorRemark: one short sentence for the narrator chip (who is suggesting and why; max ~80 chars).\n6. greeting: a 2-4 sentence first-person message the viewer could send to the counterpart. Plain prose, no greeting prefix, no markdown.\n7. mutualIntentsLabel: short subtitle under the other party's name. Examples: \"3 mutual intents\", \"Shared interests\", \"Aligned goals\" — keep it brief. NEVER output \"0 mutual intents\" or any zero-count label; use a qualitative phrase instead.\n\nRules:\n- Address the viewer with \"you\"/\"your\". Be concise and compelling.\n- narratorRemark should feel like a single sentence from the narrator (Index or a person), not meta-commentary.\n- narratorRemark is displayed with the narrator name prepended (e.g. \"Index: …\" or \"Alice: …\"). Do NOT start narratorRemark with the narrator's name or repeat it; write only the remark (e.g. \"Based on your overlapping intents\" or \"introduced you two, sensing a valuable connection\").\n- Vary wording for the match itself. Do not repeat \"opportunity\" across headline, summary, and narratorRemark when alternatives fit.\n- Prefer first names in user-facing copy. Avoid repeated full names unless disambiguation is necessary.\n- digestSummary must be grammatically complete as a standalone sentence. It should usually start with \"You might like meeting {Name} because ...\" for direct connections, or \"You may be able to help {Name} because ...\" for connector/introducer cards.\n- digestSummary must NOT use awkward third-person fragments like \"Name is...\", \"they're ..., and is...\", \"you is...\", or \"the discoverer's query\".\n- digestSummary must be one sentence, MUST fit within 180 characters when possible, and MUST contain no markdown links; the caller will attach links.\n- If you cannot fit every detail, choose one clear reason and stop. Do not rely on downstream truncation.\n\n**Introduction-originated opportunities (ONLY when INTRODUCTION CONTEXT is provided):**\nWhen INTRODUCTION CONTEXT is provided, this opportunity was explicitly created by an introducer. It was NOT automatically discovered.\n- For parties/patients/agents/peers viewing an introduction: keep the introducer signal in narratorRemark (and narrator chip), not in personalizedSummary.\n- For these introduced parties, personalizedSummary must focus ONLY on fit/value between viewer and counterpart. Do NOT mention the introducer there.\n- narratorRemark should carry the introduction signal (e.g., \"saw strong alignment between you two\" or \"thought this connection could be valuable\"), without repeating the narrator name at the start.\n- This is a personal recommendation, not an algorithm match. Frame it accordingly.\n\n**CRITICAL: NEVER include introducer names in personalizedSummary. Examples:**\n❌ WRONG: \"Seref introduced you to Lucy, who is actively seeking a product co-founder...\"\n✅ CORRECT: \"Lucy is actively seeking a product co-founder for a niche APAC marketplace. With your expertise in UX and AI, this could be an ideal collaboration.\"\n\n❌ WRONG: \"Bob thinks you should meet Alice because your React skills align with her needs.\"\n✅ CORRECT: \"Alice is building a React-based platform and needs frontend expertise. Your experience with component architecture makes you a strong fit.\"\n\n❌ WRONG: \"Jane connected you to Mark, who is looking for a designer.\"\n✅ CORRECT: \"Mark is building a consumer app and needs design expertise. Your background in user-centered design aligns well with what he's building.\"\n\nRemember: The introducer's name goes ONLY in narratorRemark, NEVER in personalizedSummary.\n\n**When INTRODUCTION CONTEXT is NOT provided (system-discovered match):**\n- Do NOT use introducer-style wording. Do NOT say \"you suggested\", \"this is an introduction you suggested\", or \"you suggested this connection\". The system found this match; no human introducer was involved.\n- Instead, narratorRemark should describe why the match is relevant (e.g. \"Based on your overlapping intents\", \"Your skills align with what they need\").\n\n**Negotiation-grounded explanations (ONLY when NEGOTIATION CONTEXT is provided):**\nWhen NEGOTIATION CONTEXT is provided, this opportunity passed through an agent-to-agent negotiation. Use the transcript to ground your explanation in the concrete reasoning the agents exchanged.\n- Personalize the summary with *why* the negotiation produced this match — reference the roles the agents agreed on, the specific concerns raised, and how they were resolved.\n- For status \"stalled\" with reason \"turn_cap\": the agents hit the turn limit without reaching agreement. Frame the card as a hedged possibility rather than a confident match; narratorRemark should signal \"agents couldn't fully converge\" without sounding negative.\n- For status \"stalled\" with reason \"timeout\": one side went silent. Suggest the user re-engage if interested.\n- For status \"accepted\": the agents agreed; the card should confidently explain *why* they agreed.\n- For status \"rejected\": the agents declined. The card should explain the reason briefly so the user understands — not dwell on it.\n- Do NOT invent turn content. Only reference what is in the NEGOTIATION CONTEXT block.\n\n- Exception for connector/introducer: if viewer role is \"introducer\" (any status), this is a curation/connector card. Use:\n - suggestedAction: one short line about sharing the intro or confirming the match.\n - mutualIntentsLabel: a short connector label (e.g. \"Connector match\", \"You can bridge this\").\n - headline: describe the connection between the parties (e.g., \"Connecting a PhD researcher with a translator\"). Do NOT reference the introducer's own needs.\n - personalizedSummary: explain why the parties you're introducing should meet, referencing THEIR profiles and intents, not yours.\n\n**CRITICAL for latent introducer cards (opportunity status is \"latent\"):**\nWhen the viewer is the introducer and the opportunity status is \"latent\", the introducer has NOT yet approved this match. They are evaluating whether to make the introduction.\n- narratorRemark MUST use evaluation/curation language (e.g. \"Could be a strong match\", \"Worth introducing?\", \"Interesting overlap here\").\n- Do NOT say \"you suggested\", \"you introduced\", \"you connected\", or any past-tense language implying the introduction was already made.\n- suggestedAction should encourage evaluation (e.g. \"Approve if you see the fit\").\n- Exception for new-connection reveal: if viewer role is \"agent\", status is \"accepted\", and there is an introducer, this is the agent's first time seeing this opportunity. Use:\n - suggestedAction: a short line about joining the conversation.\n`;\n\n// ──────────────────────────────────────────────────────────────\n// CLASS\n// ──────────────────────────────────────────────────────────────\n\nexport class OpportunityPresenter {\n private model: Runnable;\n private homeCardModel: Runnable;\n\n constructor() {\n this.model = model.withStructuredOutput(responseFormat, {\n name: \"opportunity_presenter\",\n });\n this.homeCardModel = model.withStructuredOutput(homeCardResponseFormat, {\n name: \"opportunity_presenter_home_card\",\n });\n }\n\n private async invokeWithTimeout(\n targetModel: Runnable,\n messages: (SystemMessage | HumanMessage)[],\n ): Promise<unknown> {\n const timeoutReason = `LLM invoke timed out after ${LLM_TIMEOUT_MS}ms`;\n const controller = new AbortController();\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const invokePromise = targetModel.invoke(messages, {\n signal: controller.signal,\n });\n\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => {\n controller.abort(timeoutReason);\n reject(new Error(timeoutReason));\n }, LLM_TIMEOUT_MS);\n });\n\n try {\n return await Promise.race([invokePromise, timeoutPromise]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n }\n\n /**\n * Generate personalized presentation for a single opportunity.\n */\n @Timed()\n public async present(\n input: PresenterInput,\n ): Promise<OpportunityPresentationResult> {\n const introContext = input.isIntroduction\n ? `\\nINTRODUCTION CONTEXT: This opportunity was created by an explicit introduction from ${input.introducerName ?? \"someone in the community\"}. It was NOT discovered automatically — a real person made this connection.\\n`\n : \"\";\n const humanContent = `\nVIEWER (the person seeing this opportunity):\n${input.viewerContext}\n\nOTHER PARTY:\n${input.otherPartyContext}\n\nMATCH CONTEXT:\n- Category: ${input.category}\n- Confidence: ${input.confidence}\n- Why we matched: ${input.matchReasoning}\n- Signals: ${input.signalsSummary}\n${introContext}\nCOMMUNITY: ${input.indexName}\nViewer's role in this opportunity: ${input.viewerRole}\n\nProduce headline, personalizedSummary (2-3 sentences in \"you\" language), suggestedAction, and greeting.\n`;\n\n try {\n const messages = [\n new SystemMessage(systemPrompt),\n new HumanMessage(humanContent),\n ];\n const result = await this.invokeWithTimeout(this.model, messages);\n const parsed = responseFormat.parse(result);\n parsed.presentation.personalizedSummary = stripUuids(parsed.presentation.personalizedSummary);\n return parsed.presentation;\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n const timeoutReason = message.includes(\"timed out\") ? message : undefined;\n logger.warn(\n \"[OpportunityPresenter.present] LLM failed, returning fallback\",\n {\n event: \"presenter_fallback\",\n presenter: \"opportunity\",\n reason: timeoutReason ? \"timeout\" : \"parse_error\",\n message,\n timeoutReason,\n },\n );\n return {\n headline: \"A promising connection\",\n personalizedSummary: truncateAtBoundary(stripUuids(input.matchReasoning), 300),\n suggestedAction: \"Take a look and decide whether to reach out.\",\n greeting: \"\",\n isFallback: true,\n };\n }\n }\n\n /**\n * Generate LLM-powered home-card content (headline, body, narrator remark, mutual-intent label).\n * Callers append button labels from opportunity.constants.\n *\n * When `negotiationContext.status === 'negotiating'`, returns a templated\n * chip synchronously without invoking the LLM — the card just reflects\n * \"negotiation in progress\" at that point.\n */\n @Timed()\n public async presentHomeCard(\n input: HomeCardPresenterInput,\n ): Promise<HomeCardLLMResult> {\n if (input.negotiationContext?.status === 'negotiating') {\n return buildNegotiatingChip(input);\n }\n\n const mutualHint =\n input.mutualIntentCount != null && input.mutualIntentCount > 0\n ? `There are ${input.mutualIntentCount} overlapping intent(s) between viewer and other party.`\n : \"Match is based on profile and intent alignment. Do not cite a numeric intent count.\";\n const introContext = input.isIntroduction\n ? `\\nINTRODUCTION CONTEXT: This opportunity was created by an explicit introduction from ${input.introducerName ?? \"someone in the community\"}. It was NOT discovered automatically — a real person made this connection.\\n`\n : \"\";\n const negotiationBlock = buildNegotiationPromptBlock(input.negotiationContext);\n // When negotiation context exists, lead with it — these cards exist\n // *because* the negotiation happened. Trailing the block lets weaker\n // models lean on surface signals and ignore the transcript entirely.\n const negotiationDirective = negotiationBlock\n ? `\\nIMPORTANT: This opportunity surfaced because the agents negotiated and converged. Both your personalizedSummary AND your digestSummary MUST reference at least one specific signal from the NEGOTIATION CONTEXT block below — what concern was raised, what was confirmed, what the agents agreed on. The digestSummary is the one-line morning-brief sentence a user reads before deciding to act, so it must communicate *why this specific match* surfaced now (the negotiation that led to it), not a generic skill-complementarity line. Do not produce the generic summary every card looked like before this negotiation happened.\\n`\n : \"\";\n const humanContent = `\n${negotiationBlock}${negotiationDirective}\nVIEWER (the person seeing this opportunity):\n${input.viewerContext}\n\nOTHER PARTY:\n${input.otherPartyContext}\n\nMATCH CONTEXT:\n- Category: ${input.category}\n- Confidence: ${input.confidence}\n- Why we matched: ${input.matchReasoning}\n- Signals: ${input.signalsSummary}\n- ${mutualHint}\n${introContext}\nCOMMUNITY: ${input.indexName}\nViewer's role in this opportunity: ${input.viewerRole}\nOpportunity status: ${input.opportunityStatus ?? \"pending\"}\n\nProduce headline, personalizedSummary, digestSummary, suggestedAction, narratorRemark, greeting, and mutualIntentsLabel.\n`;\n\n const isIntroducer = input.viewerRole === \"introducer\";\n\n try {\n const messages = [\n new SystemMessage(homeCardSystemPrompt),\n new HumanMessage(humanContent),\n ];\n const result = await this.invokeWithTimeout(this.homeCardModel, messages);\n const parsed = homeCardResponseFormat.parse(result);\n parsed.presentation.personalizedSummary = stripUuids(parsed.presentation.personalizedSummary);\n parsed.presentation.digestSummary = stripUuids(parsed.presentation.digestSummary);\n parsed.presentation.narratorRemark = stripUuids(parsed.presentation.narratorRemark);\n if (/^0\\s+(mutual|overlapping)\\s+intent/i.test(parsed.presentation.mutualIntentsLabel)) {\n parsed.presentation.mutualIntentsLabel = \"Shared interests\";\n }\n if (input.isIntroduction && input.introducerName) {\n parsed.presentation.personalizedSummary = stripIntroducerMentions(\n parsed.presentation.personalizedSummary,\n input.introducerName,\n );\n parsed.presentation.digestSummary = stripIntroducerMentions(\n parsed.presentation.digestSummary,\n input.introducerName,\n );\n }\n return parsed.presentation;\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n const timeoutReason = message.includes(\"timed out\") ? message : undefined;\n logger.warn(\n \"[OpportunityPresenter.presentHomeCard] LLM failed, returning fallback\",\n {\n event: \"presenter_fallback\",\n presenter: \"home_card\",\n reason: timeoutReason ? \"timeout\" : \"parse_error\",\n message,\n timeoutReason,\n },\n );\n let fallbackSummary = truncateAtBoundary(stripUuids(input.matchReasoning), 300);\n if (input.isIntroduction && input.introducerName) {\n fallbackSummary = stripIntroducerMentions(fallbackSummary, input.introducerName);\n }\n return {\n headline: \"A promising connection\",\n personalizedSummary: fallbackSummary,\n digestSummary: isIntroducer\n ? \"You may be able to help make a useful introduction here.\"\n : \"You might like meeting them based on your current interests.\",\n suggestedAction: isIntroducer\n ? \"Share this introduction to get things started.\"\n : \"Take a look and decide whether to reach out.\",\n narratorRemark: \"Worth a look.\",\n mutualIntentsLabel: isIntroducer\n ? \"Connector match\"\n : input.mutualIntentCount != null && input.mutualIntentCount > 0\n ? `${input.mutualIntentCount} mutual intent${input.mutualIntentCount !== 1 ? \"s\" : \"\"}`\n : \"Shared interests\",\n greeting: \"\",\n isFallback: true,\n };\n }\n }\n\n /**\n * Process multiple opportunities in parallel with bounded concurrency.\n */\n @Timed()\n public async presentBatch(\n inputs: PresenterInput[],\n options?: { concurrency?: number },\n ): Promise<OpportunityPresentationResult[]> {\n const concurrency = options?.concurrency ?? 5;\n const results: OpportunityPresentationResult[] = [];\n for (let i = 0; i < inputs.length; i += concurrency) {\n const chunk = inputs.slice(i, i + concurrency);\n const chunkResults = await Promise.all(\n chunk.map((inp) => this.present(inp)),\n );\n results.push(...chunkResults);\n }\n return results;\n }\n\n /**\n * Process multiple opportunities as home cards in parallel with bounded concurrency.\n * Returns full home-card display contracts (headline, body, narrator remark, action labels, mutual-intent label).\n */\n @Timed()\n public async presentHomeCardBatch(\n inputs: HomeCardPresenterInput[],\n options?: { concurrency?: number },\n ): Promise<HomeCardLLMResult[]> {\n const concurrency = options?.concurrency ?? 5;\n const results: HomeCardLLMResult[] = [];\n for (let i = 0; i < inputs.length; i += concurrency) {\n const chunk = inputs.slice(i, i + concurrency);\n const chunkResults = await Promise.all(\n chunk.map((inp) => this.presentHomeCard(inp)),\n );\n results.push(...chunkResults);\n }\n return results;\n }\n}\n\n// ──────────────────────────────────────────────────────────────\n// NEGOTIATION CONTEXT HELPERS\n// ──────────────────────────────────────────────────────────────\n\n/**\n * Builds a \"NEGOTIATION CONTEXT:\" block for the home-card prompt. Returns an\n * empty string when the opportunity has no meaningful negotiation context\n * (draft/latent) or when the opportunity is still negotiating (handled via\n * the templated chip, not the LLM).\n */\nfunction buildNegotiationPromptBlock(context: NegotiationContext | undefined): string {\n if (!context || context.status === 'negotiating') return \"\";\n\n const turnCapLabel = context.turnCap > 0 ? `${context.turnCap}` : \"unlimited\";\n const reason = context.outcome?.reason;\n const reasonLabel = reason === 'turn_cap'\n ? \"agents hit the turn cap without converging\"\n : reason === 'timeout'\n ? \"counterpart went silent before responding\"\n : undefined;\n\n const turnLines = (context.turns ?? []).map((turn, index) => {\n const action = turn.action;\n const reasoning = turn.assessment?.reasoning ?? \"(no reasoning)\";\n const message = turn.message ? ` — said: \"${turn.message}\"` : \"\";\n return `Turn ${index + 1} (${action}): ${reasoning}${message}`;\n });\n\n const outcomeSummary = context.outcome\n ? `Final outcome: ${context.outcome.hasOpportunity ? \"agreed\" : \"declined\"} — ${context.outcome.reasoning}`\n : \"Final outcome: not recorded.\";\n\n return `\nNEGOTIATION CONTEXT:\n- Negotiation status: ${context.status}${reasonLabel ? ` (${reasonLabel})` : \"\"}\n- Turns exchanged: ${context.turnCount} of ${turnCapLabel}\n- Transcript:\n${turnLines.length > 0 ? turnLines.map((l) => ` ${l}`).join(\"\\n\") : \" (no turns recorded)\"}\n- ${outcomeSummary}\n`;\n}\n\n/**\n * Builds a templated home-card result for an opportunity whose negotiation\n * is still in progress. Bypasses the LLM so users see a stable \"currently\n * negotiating\" chip while turns are still being exchanged.\n */\nfunction buildNegotiatingChip(input: HomeCardPresenterInput): HomeCardLLMResult {\n const ctx = input.negotiationContext;\n const turnCount = ctx?.turnCount ?? 0;\n const turnCap = ctx?.turnCap && ctx.turnCap > 0 ? ctx.turnCap : undefined;\n const narratorRemark = turnCap\n ? `Currently negotiating · turn ${turnCount} of ${turnCap}`\n : `Currently negotiating · turn ${turnCount}`;\n\n return {\n headline: \"Negotiation in progress\",\n personalizedSummary: \"Your agent is still talking with theirs to see if this connection makes sense. We'll surface the full match as soon as they converge.\",\n digestSummary: \"Your agent is still checking whether this connection makes sense.\",\n suggestedAction: \"Check back shortly — no action needed yet.\",\n narratorRemark,\n mutualIntentsLabel: input.mutualIntentCount && input.mutualIntentCount > 0\n ? `${input.mutualIntentCount} mutual intent${input.mutualIntentCount !== 1 ? \"s\" : \"\"}`\n : \"Shared interests\",\n greeting: \"\",\n };\n}\n\n// ──────────────────────────────────────────────────────────────\n// CONTEXT GATHERER (used by tools)\n// ──────────────────────────────────────────────────────────────\n\n/**\n * Gather all context needed for the presenter from the database.\n * Fetches viewer profile, viewer intents, other party profile(s), and index in parallel.\n *\n * @param displayCounterpartUserId - When set (e.g. for home card), only this counterpart is included in otherPartyContext so the presenter writes about the person on the card. Omitted for introducer view (card shows both parties).\n */\nexport async function gatherPresenterContext(\n database: PresenterDatabase,\n opportunity: Opportunity,\n viewerId: string,\n displayCounterpartUserId?: string,\n): Promise<PresenterInput> {\n const myActor = opportunity.actors.find((a) => a.userId === viewerId);\n if (!myActor) {\n throw new Error(\"Viewer is not an actor in this opportunity\");\n }\n\n const isIntroducer = myActor.role === \"introducer\";\n const otherActors = opportunity.actors.filter((a) => a.userId !== viewerId);\n let otherPartyIds = [...new Set(otherActors.map((a) => a.userId))];\n if (\n displayCounterpartUserId &&\n !isIntroducer &&\n otherPartyIds.includes(displayCounterpartUserId)\n ) {\n otherPartyIds = [displayCounterpartUserId];\n }\n\n const contextIndexId = opportunity.context?.networkId;\n\n // For introducers: fetch profiles + intents for both parties; skip introducer's own intents.\n // For other roles: fetch viewer's profile + intents and other party profiles.\n const [viewerProfile, indexRecord, ...otherProfiles] = await Promise.all([\n database.getProfile(viewerId),\n contextIndexId ? database.getNetwork(contextIndexId) : Promise.resolve(null),\n ...otherPartyIds.map((uid) => database.getProfile(uid)),\n ]);\n\n // Fetch intents: for introducer, fetch each party's intents; otherwise fetch viewer's intents.\n let viewerIntents:\n | Awaited<ReturnType<typeof database.getActiveIntents>>\n | undefined;\n let partyIntentsMap:\n | Map<string, Awaited<ReturnType<typeof database.getActiveIntents>>>\n | undefined;\n\n if (isIntroducer) {\n const partyIntentResults = await Promise.all(\n otherPartyIds.map(async (uid) => ({\n uid,\n intents: await database.getActiveIntents(uid),\n })),\n );\n partyIntentsMap = new Map(\n partyIntentResults.map((r) => [r.uid, r.intents]),\n );\n } else {\n viewerIntents = await database.getActiveIntents(viewerId);\n }\n\n // Fetch premises when any actor is premise-grounded\n const premiseGroundedActors = opportunity.actors.filter((a) => a.premise);\n let viewerPremiseContext = '';\n let otherPremiseContext = '';\n\n if (premiseGroundedActors.length > 0) {\n // Only fetch premises for actors that are actually premise-grounded, not all parties\n const groundedOtherIds = premiseGroundedActors\n .filter((a) => a.userId !== viewerId)\n .map((a) => a.userId);\n const viewerIsGrounded = premiseGroundedActors.some((a) => a.userId === viewerId);\n\n const results = await Promise.all([\n ...(viewerIsGrounded ? [database.getPremisesForUser(viewerId, 'ACTIVE')] : []),\n ...groundedOtherIds.map((uid) => database.getPremisesForUser(uid, 'ACTIVE')),\n ]);\n\n let idx = 0;\n if (viewerIsGrounded) {\n const viewerPremises = results[idx++];\n if (viewerPremises?.length) {\n viewerPremiseContext =\n '\\nPremises (self-descriptions):\\n' +\n viewerPremises\n .slice(0, 5)\n .map((p) => `- ${p.assertion.text}`)\n .join('\\n');\n }\n }\n\n const otherPremiseLines: string[] = [];\n for (let i = 0; i < groundedOtherIds.length; i++) {\n const premises = results[idx++];\n if (premises?.length) {\n for (const p of premises.slice(0, 3)) {\n otherPremiseLines.push(`- ${p.assertion.text}`);\n }\n }\n }\n if (otherPremiseLines.length > 0) {\n otherPremiseContext = '\\nPremises (self-descriptions):\\n' + otherPremiseLines.join('\\n');\n }\n }\n\n let viewerContext: string;\n let otherPartyContext: string;\n\n if (isIntroducer) {\n // Introducer view: minimal viewer context (just name + role), rich other-party context with intents\n const introducerApproved = opportunity.actors.find(a => a.role === 'introducer')?.approved === true;\n const hasApproved = introducerApproved || opportunity.status !== 'latent';\n viewerContext = [\n \"Profile:\",\n `Name: ${viewerProfile?.identity?.name ?? \"Unknown\"}`,\n hasApproved\n ? \"Role: You are the introducer who suggested this connection.\"\n : \"Role: You are being asked whether these two people would benefit from meeting. You have NOT yet approved this introduction.\",\n ].join(\"\\n\");\n\n const otherParts = otherPartyIds.map((uid, idx) => {\n const profile = otherProfiles[idx] as Awaited<\n ReturnType<typeof database.getProfile>\n >;\n const name = profile?.identity?.name ?? \"Unknown\";\n const bio = profile?.identity?.bio ?? \"\";\n const location = profile?.identity?.location ?? \"\";\n const context = profile?.context ?? \"\";\n const intents = partyIntentsMap?.get(uid);\n const intentLines = intents?.length\n ? intents\n .slice(0, 5)\n .map((i) => ` - ${i.payload}${i.summary ? ` (${i.summary})` : \"\"}`)\n : [\" (no active intents)\"];\n return [\n `${name}:`,\n ` Bio: ${bio}`,\n location ? ` Location: ${location}` : null,\n context ? ` Context: ${context}` : null,\n ` Active intents:`,\n ...intentLines,\n ]\n .filter(Boolean)\n .join(\"\\n\");\n });\n otherPartyContext =\n otherParts.join(\"\\n\\n\") || \"Parties (details not available).\";\n } else {\n // Non-introducer view: full viewer profile + intents, other party profiles\n const viewerContextLines = [\n \"Profile:\",\n `Name: ${viewerProfile?.identity?.name ?? \"Unknown\"}`,\n `Bio: ${viewerProfile?.identity?.bio ?? \"\"}`,\n `Location: ${viewerProfile?.identity?.location ?? \"\"}`,\n `Context: ${viewerProfile?.context ?? \"\"}`,\n \"Active intents:\",\n ...(viewerIntents?.length\n ? viewerIntents.map(\n (i) => `- ${i.payload}${i.summary ? ` (${i.summary})` : \"\"}`,\n )\n : [\"(none listed)\"]),\n ];\n viewerContext = viewerContextLines.join(\"\\n\");\n\n const otherParts = otherPartyIds.map((uid, idx) => {\n const profile = otherProfiles[idx] as Awaited<\n ReturnType<typeof database.getProfile>\n >;\n const name = profile?.identity?.name ?? \"Unknown\";\n const bio = profile?.identity?.bio ?? \"\";\n return `${name}: ${bio}`;\n });\n otherPartyContext =\n otherParts.join(\"\\n\\n\") || \"Other party (details not available).\";\n }\n\n const interp = opportunity.interpretation;\n const signalsSummary =\n interp.signals?.map((s) => `${s.type}: ${s.detail ?? s.type}`).join(\"; \") ??\n \"Match based on profile and intent alignment.\";\n\n // Detect introduction-originated opportunities: only when there is an explicit introducer actor.\n // Do NOT use detection.source === \"manual\" alone — system-discovered opportunities can have manual source without an introducer.\n const introducerActor = opportunity.actors.find(\n (a) => a.role === \"introducer\",\n );\n const isIntroduction = !!introducerActor;\n let introducerName: string | undefined;\n if (introducerActor) {\n introducerName = opportunity.detection.createdByName;\n if (!introducerName) {\n const introducerProfile = await database.getProfile(\n introducerActor.userId,\n );\n introducerName = introducerProfile?.identity?.name ?? undefined;\n }\n }\n\n const counterpartName =\n otherPartyIds.length === 1 && otherProfiles[0]\n ? (otherProfiles[0] as { identity?: { name?: string } })?.identity?.name?.trim()\n : undefined;\n const viewerNameForFilter = viewerProfile?.identity?.name?.trim();\n const matchReasoning =\n counterpartName && interp.reasoning\n ? viewerCentricCardSummary(\n interp.reasoning,\n counterpartName,\n 400,\n viewerNameForFilter,\n introducerName,\n )\n : stripUuids(interp.reasoning);\n\n if (viewerPremiseContext) {\n viewerContext += viewerPremiseContext;\n }\n if (otherPremiseContext) {\n otherPartyContext += otherPremiseContext;\n }\n\n const result: PresenterInput = {\n viewerContext,\n otherPartyContext,\n matchReasoning,\n category: interp.category ?? \"connection\",\n confidence:\n typeof interp.confidence === \"number\"\n ? interp.confidence\n : parseFloat(String(interp.confidence ?? 0)) || 0,\n signalsSummary,\n indexName: indexRecord?.title ?? contextIndexId ?? \"\",\n viewerRole: myActor.role ?? \"party\",\n isIntroduction,\n introducerName,\n };\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"opportunity.presenter.js","sourceRoot":"/","sources":["opportunity/opportunity.presenter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;;;;;;;;;AAGH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIzE,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAWxG,MAAM,MAAM,GAAG,cAAc,CAAC,sBAAsB,CAAC,CAAC;AACtD,MAAM,cAAc,GAAG,KAAM,CAAC;AAG9B,MAAM,oBAAoB,GACxB,+XAA+X,CAAC;AAElY,iEAAiE;AACjE,iBAAiB;AACjB,iEAAiE;AAEjE,MAAM,kBAAkB,GAAG,CAAC,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SAAS,CAAC;IAChB,MAAM,mBAAmB,GAAG,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAClE,MAAM,cAAc,GAClB,eAAe,IAAI,MAAM,CAAC,SAAS;QACjC,CAAC,CAAC,wBAAwB,CACtB,MAAM,CAAC,SAAS,EAChB,eAAe,EACf,GAAG,EACH,mBAAmB,EACnB,cAAc,CACf;QACH,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAEnC,IAAI,oBAAoB,EAAE,CAAC;QACzB,aAAa,IAAI,oBAAoB,CAAC;IACxC,CAAC;IACD,IAAI,mBAAmB,EAAE,CAAC;QACxB,iBAAiB,IAAI,mBAAmB,CAAC;IAC3C,CAAC;IAED,MAAM,MAAM,GAAmB;QAC7B,aAAa;QACb,iBAAiB;QACjB,cAAc;QACd,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,YAAY;QACzC,UAAU,EACR,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ;YACnC,CAAC,CAAC,MAAM,CAAC,UAAU;YACnB,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACrD,cAAc;QACd,SAAS,EAAE,WAAW,EAAE,KAAK,IAAI,cAAc,IAAI,EAAE;QACrD,UAAU,EAAE,OAAO,CAAC,IAAI,IAAI,OAAO;QACnC,cAAc;QACd,cAAc;KACf,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Opportunity Presenter Agent\n *\n * Generates personalized, second-person explanations of why an opportunity\n * matters to the viewing user. Uses full opportunity data (interpretation,\n * actors, profiles, intents, index) to produce headline, personalizedSummary,\n * and suggestedAction for chat tools and user-facing surfaces.\n */\n\nimport type { Runnable } from \"@langchain/core/runnables\";\nimport { HumanMessage, SystemMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod\";\n\nimport { Timed } from \"../shared/observability/performance.js\";\n\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { createStructuredModel } from \"../shared/agent/model.config.js\";\nimport { viewerCentricCardSummary } from \"./opportunity.presentation.js\";\nimport type { Opportunity } from \"../shared/interfaces/database.interface.js\";\nimport type { ChatGraphCompositeDatabase } from \"../shared/interfaces/database.interface.js\";\nimport type { NegotiationContext } from \"./negotiation-context.loader.js\";\nimport { stripUuids, stripIntroducerMentions, truncateAtBoundary } from \"./opportunity.presentation.js\";\n\n/**\n * Minimal database interface required by gatherPresenterContext.\n * Any database adapter that implements these three methods can be passed.\n */\nexport type PresenterDatabase = Pick<\n ChatGraphCompositeDatabase,\n \"getProfile\" | \"getActiveIntents\" | \"getNetwork\" | \"getPremisesForUser\"\n>;\n\nconst logger = protocolLogger(\"OpportunityPresenter\");\nconst LLM_TIMEOUT_MS = 20_000;\n\n\nconst GREETING_DESCRIPTION =\n \"A 2-4 sentence first-person message the viewer could send to the counterpart, in the viewer's voice, referencing what they have in common. Plain prose only — no markdown, no greeting prefix like 'Hey {Name},'. Example body: 'Saw we're both working on regenerative coordination tooling — your post on consent flows resonated. Would love to compare notes if you have time this week.'\";\n\n// ──────────────────────────────────────────────────────────────\n// SCHEMA & TYPES\n// ──────────────────────────────────────────────────────────────\n\nconst PresentationSchema = z.object({\n headline: z\n .string()\n .describe(\n \"Short, compelling headline for this opportunity (e.g., 'A React expert who needs your design skills')\",\n ),\n personalizedSummary: z\n .string()\n .describe(\n \"2-3 sentence explanation using 'you' language, explaining why this opportunity is specifically valuable for the viewer based on their intents and profile\",\n ),\n suggestedAction: z.string().describe(\"Brief suggested next step\"),\n greeting: z.string().max(500).describe(GREETING_DESCRIPTION),\n});\n\nconst responseFormat = z.object({\n presentation: PresentationSchema,\n});\n\nexport type OpportunityPresentationResult = z.infer<typeof PresentationSchema> & {\n /** True when the LLM call failed and this is fallback-shaped copy built from raw reasoning. */\n isFallback?: boolean;\n};\n\n/** Input for home-card presenter call; extends PresenterInput with optional mutual intent count. */\nexport interface HomeCardPresenterInput extends PresenterInput {\n /** Number of overlapping intents (for generating mutualIntentsLabel). */\n mutualIntentCount?: number;\n /**\n * Snapshot of the opportunity's negotiation, if one exists. When status is\n * `negotiating`, the presenter returns a templated chip without invoking\n * the LLM. For `pending`/`stalled`/`accepted`/`rejected`, the full\n * transcript and outcome ground the LLM's explanation.\n */\n negotiationContext?: NegotiationContext;\n}\n\n/** LLM-generated fields for home-card presentation (buttons are hardcoded by callers, not LLM-generated). */\nexport const HomeCardLLMSchema = z.object({\n headline: z\n .string()\n .describe(\"Short, compelling headline for this opportunity\"),\n personalizedSummary: z\n .string()\n .describe(\n \"2-3 sentence explanation in 'you' language for the main card body\",\n ),\n digestSummary: z\n .string()\n .max(220)\n .describe(\n \"One concise digest-ready sentence for a morning brief. It must be addressed to the viewer and mention the counterpart by name, e.g. 'You might like meeting Paul because ...'. No markdown.\",\n ),\n suggestedAction: z\n .string()\n .describe(\"Brief suggested next step (e.g. CTA line)\"),\n narratorRemark: z\n .string()\n .max(80)\n .describe(\n \"One short sentence for the narrator chip, max ~80 chars (e.g. who is suggesting and why)\",\n ),\n mutualIntentsLabel: z\n .string()\n .max(48)\n .describe(\n \"Short line for the subtitle under the other party name (e.g. '3 mutual intents', 'Shared interests', 'Aligned goals'). NEVER output '0 mutual intents' — use a qualitative phrase like 'Shared interests' when no numeric count is available.\",\n ),\n greeting: z.string().max(500).describe(GREETING_DESCRIPTION),\n});\n\n/** LLM-generated result from presentHomeCard (callers append button labels from opportunity.constants). */\nexport type HomeCardLLMResult = z.infer<typeof HomeCardLLMSchema> & {\n /**\n * True when the LLM call failed and this is fallback-shaped copy built from\n * raw match reasoning. Callers with strict quality requirements (digests,\n * long-lived caches) should check this before sending/persisting — fallback\n * output is otherwise indistinguishable from genuine LLM output.\n */\n isFallback?: boolean;\n};\n\n/** Full home-card display contract including hardcoded button labels (assembled by callers). */\nexport type HomeCardPresentationResult = HomeCardLLMResult & {\n primaryActionLabel: string;\n secondaryActionLabel: string;\n};\n\nconst homeCardResponseFormat = z.object({\n presentation: HomeCardLLMSchema,\n});\n\n/** Input for a single presenter call (all context pre-assembled). */\nexport interface PresenterInput {\n viewerContext: string;\n otherPartyContext: string;\n matchReasoning: string;\n category: string;\n confidence: number;\n signalsSummary: string;\n indexName: string;\n viewerRole: string;\n opportunityStatus?: string;\n /** True when this opportunity was created via an explicit introduction (not automatic discovery). */\n isIntroduction?: boolean;\n /** Name of the person who made the introduction, if applicable. */\n introducerName?: string;\n}\n\n// ──────────────────────────────────────────────────────────────\n// SYSTEM PROMPT\n// ──────────────────────────────────────────────────────────────\n\nconst systemPrompt = `\nYou are an expert at presenting connection opportunities to users in a way that feels personal and compelling.\n\nYour goal: Given raw context about the viewer (their profile, intents), the other person(s), and why the system matched them, produce a short headline, a personalized summary, and a suggested action.\n\nRules:\n1. Address the VIEWER directly using \"you\" and \"your\". This is for them.\n2. Be concise and compelling — not analytical or third-party. No \"The source user\" or \"The candidate\"; use names or \"they\" where needed.\n3. Do not leak private or confidential details. Use only the context provided.\n4. Vary user-facing nouns naturally. Do not repeatedly use the same label in one response.\n5. If possible, avoid repeating \"opportunity\" in both headline and summary. Prefer alternatives like \"connection\", \"thought partner\", \"mutual fit\", \"valuable conversation\", or \"peer\".\n6. Prefer first names in user-facing copy. Do not repeatedly use full names unless needed to disambiguate.\n\n**Introduction-originated opportunities:**\nWhen INTRODUCTION CONTEXT is provided, this opportunity was explicitly created by an introducer (a real person who saw value in this connection). This is NOT an automatic system discovery — someone made a deliberate judgment.\n- For ALL roles: acknowledge the introducer's role naturally. E.g., \"[Introducer name] thinks you should meet [other person]\" or \"[Introducer name] connected you because...\"\n- The introduction itself is a strong signal — treat it with the weight of a personal recommendation.\n- If the parties' intents don't obviously overlap, that's fine — the introducer saw something worth connecting. Focus on what the introducer likely saw.\n\n**Role-Specific Presentation:**\n\n**If viewer is \"introducer\":**\n- The viewer suggested this connection between two (or more) OTHER people. The opportunity is NOT about the viewer's own needs.\n- Headline: describe the connection between the parties (e.g., \"Connecting a React expert with a startup founder\").\n- Personalized summary: explain why the people YOU are introducing should meet. Reference THEIR profiles and intents, not yours. Frame it as \"you're connecting X and Y because...\" rather than \"this matches your intent\".\n- Suggested action: guide sharing (e.g., \"Share this with [name] to get things started\").\n- CRITICAL: Do NOT reference the introducer's own intents, skills, or needs. The introducer is the matchmaker, not a party.\n\n**If viewer is \"patient\" or \"party\":**\n- Reference their specific intents, skills, or interests that align with this opportunity.\n- If this is an introduction: mention who introduced them and frame it as a personal recommendation.\n- Headline: one short line that hooks (e.g., \"[Name] thinks you should meet [Other]\" or \"A React expert who needs your design skills\").\n- Personalized summary: 2-3 sentences. Why is this opportunity for *them*? If introduced, lead with the introduction.\n- Suggested action: encourage action (\"Send a message to start the conversation\" or \"Share this intro\").\n\n**If viewer is \"agent\":**\n- They are seeing this because someone already reached out.\n- If this is an introduction: mention who made the introduction.\n- Reference their skills/expertise that make them a match.\n- Headline: what the other person needs that they can provide.\n- Personalized summary: 2-3 sentences. Why someone reached out to them.\n- Suggested action: \"Someone is interested in connecting — check their message\" or \"Review and respond\".\n\n**If viewer is \"peer\":**\n- Mutual opportunity. Reference shared or complementary interests.\n- If this is an introduction: mention who connected them.\n- Headline: the mutual connection angle.\n- Personalized summary: 2-3 sentences. Why this is mutually valuable.\n- Suggested action: \"Send an intro to connect\" or \"Start a conversation\".\n`;\n\nconst homeCardSystemPrompt = `\nYou are an expert at presenting connection opportunities for a home feed card.\n\nGiven context about the viewer, the other person, and why they were matched, produce:\n1. headline: one short hook line.\n2. personalizedSummary: 2-3 sentences in \"you\" language (main body text).\n3. digestSummary: one polished morning-brief sentence that can be printed directly after the person's linked name. No markdown, no field labels.\n4. suggestedAction: one brief suggested next step.\n5. narratorRemark: one short sentence for the narrator chip (who is suggesting and why; max ~80 chars).\n6. greeting: a 2-4 sentence first-person message the viewer could send to the counterpart. Plain prose, no greeting prefix, no markdown.\n7. mutualIntentsLabel: short subtitle under the other party's name. Examples: \"3 mutual intents\", \"Shared interests\", \"Aligned goals\" — keep it brief. NEVER output \"0 mutual intents\" or any zero-count label; use a qualitative phrase instead.\n\nRules:\n- Address the viewer with \"you\"/\"your\". Be concise and compelling.\n- narratorRemark should feel like a single sentence from the narrator (Index or a person), not meta-commentary.\n- narratorRemark is displayed with the narrator name prepended (e.g. \"Index: …\" or \"Alice: …\"). Do NOT start narratorRemark with the narrator's name or repeat it; write only the remark (e.g. \"Based on your overlapping intents\" or \"introduced you two, sensing a valuable connection\").\n- Vary wording for the match itself. Do not repeat \"opportunity\" across headline, summary, and narratorRemark when alternatives fit.\n- Prefer first names in user-facing copy. Avoid repeated full names unless disambiguation is necessary.\n- digestSummary must be grammatically complete as a standalone sentence. It should usually start with \"You might like meeting {Name} because ...\" for direct connections, or \"You may be able to help {Name} because ...\" for connector/introducer cards.\n- digestSummary must NOT use awkward third-person fragments like \"Name is...\", \"they're ..., and is...\", \"you is...\", or \"the discoverer's query\".\n- digestSummary must be one sentence, MUST fit within 180 characters when possible, and MUST contain no markdown links; the caller will attach links.\n- If you cannot fit every detail, choose one clear reason and stop. Do not rely on downstream truncation.\n\n**Introduction-originated opportunities (ONLY when INTRODUCTION CONTEXT is provided):**\nWhen INTRODUCTION CONTEXT is provided, this opportunity was explicitly created by an introducer. It was NOT automatically discovered.\n- For parties/patients/agents/peers viewing an introduction: keep the introducer signal in narratorRemark (and narrator chip), not in personalizedSummary.\n- For these introduced parties, personalizedSummary must focus ONLY on fit/value between viewer and counterpart. Do NOT mention the introducer there.\n- narratorRemark should carry the introduction signal (e.g., \"saw strong alignment between you two\" or \"thought this connection could be valuable\"), without repeating the narrator name at the start.\n- This is a personal recommendation, not an algorithm match. Frame it accordingly.\n\n**CRITICAL: NEVER include introducer names in personalizedSummary. Examples:**\n❌ WRONG: \"Seref introduced you to Lucy, who is actively seeking a product co-founder...\"\n✅ CORRECT: \"Lucy is actively seeking a product co-founder for a niche APAC marketplace. With your expertise in UX and AI, this could be an ideal collaboration.\"\n\n❌ WRONG: \"Bob thinks you should meet Alice because your React skills align with her needs.\"\n✅ CORRECT: \"Alice is building a React-based platform and needs frontend expertise. Your experience with component architecture makes you a strong fit.\"\n\n❌ WRONG: \"Jane connected you to Mark, who is looking for a designer.\"\n✅ CORRECT: \"Mark is building a consumer app and needs design expertise. Your background in user-centered design aligns well with what he's building.\"\n\nRemember: The introducer's name goes ONLY in narratorRemark, NEVER in personalizedSummary.\n\n**When INTRODUCTION CONTEXT is NOT provided (system-discovered match):**\n- Do NOT use introducer-style wording. Do NOT say \"you suggested\", \"this is an introduction you suggested\", or \"you suggested this connection\". The system found this match; no human introducer was involved.\n- Instead, narratorRemark should describe why the match is relevant (e.g. \"Based on your overlapping intents\", \"Your skills align with what they need\").\n\n**Negotiation-grounded explanations (ONLY when NEGOTIATION CONTEXT is provided):**\nWhen NEGOTIATION CONTEXT is provided, this opportunity passed through an agent-to-agent negotiation. Use the transcript to ground your explanation in the concrete reasoning the agents exchanged.\n- Personalize the summary with *why* the negotiation produced this match — reference the roles the agents agreed on, the specific concerns raised, and how they were resolved.\n- For status \"stalled\" with reason \"turn_cap\": the agents hit the turn limit without reaching agreement. Frame the card as a hedged possibility rather than a confident match; narratorRemark should signal \"agents couldn't fully converge\" without sounding negative.\n- For status \"stalled\" with reason \"timeout\": one side went silent. Suggest the user re-engage if interested.\n- For status \"accepted\": the agents agreed; the card should confidently explain *why* they agreed.\n- For status \"rejected\": the agents declined. The card should explain the reason briefly so the user understands — not dwell on it.\n- Do NOT invent turn content. Only reference what is in the NEGOTIATION CONTEXT block.\n\n- Exception for connector/introducer: if viewer role is \"introducer\" (any status), this is a curation/connector card. Use:\n - suggestedAction: one short line about sharing the intro or confirming the match.\n - mutualIntentsLabel: a short connector label (e.g. \"Connector match\", \"You can bridge this\").\n - headline: describe the connection between the parties (e.g., \"Connecting a PhD researcher with a translator\"). Do NOT reference the introducer's own needs.\n - personalizedSummary: explain why the parties you're introducing should meet, referencing THEIR profiles and intents, not yours.\n\n**CRITICAL for latent introducer cards (opportunity status is \"latent\"):**\nWhen the viewer is the introducer and the opportunity status is \"latent\", the introducer has NOT yet approved this match. They are evaluating whether to make the introduction.\n- narratorRemark MUST use evaluation/curation language (e.g. \"Could be a strong match\", \"Worth introducing?\", \"Interesting overlap here\").\n- Do NOT say \"you suggested\", \"you introduced\", \"you connected\", or any past-tense language implying the introduction was already made.\n- suggestedAction should encourage evaluation (e.g. \"Approve if you see the fit\").\n- Exception for new-connection reveal: if viewer role is \"agent\", status is \"accepted\", and there is an introducer, this is the agent's first time seeing this opportunity. Use:\n - suggestedAction: a short line about joining the conversation.\n`;\n\n// ──────────────────────────────────────────────────────────────\n// CLASS\n// ──────────────────────────────────────────────────────────────\n\nexport class OpportunityPresenter {\n private model: Runnable;\n private homeCardModel: Runnable;\n\n constructor() {\n this.model = createStructuredModel(\"opportunityPresenter\", responseFormat, {\n name: \"opportunity_presenter\",\n });\n this.homeCardModel = createStructuredModel(\"opportunityPresenter\", homeCardResponseFormat, {\n name: \"opportunity_presenter_home_card\",\n });\n }\n\n private async invokeWithTimeout(\n targetModel: Runnable,\n messages: (SystemMessage | HumanMessage)[],\n ): Promise<unknown> {\n const timeoutReason = `LLM invoke timed out after ${LLM_TIMEOUT_MS}ms`;\n const controller = new AbortController();\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const invokePromise = targetModel.invoke(messages, {\n signal: controller.signal,\n });\n\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => {\n controller.abort(timeoutReason);\n reject(new Error(timeoutReason));\n }, LLM_TIMEOUT_MS);\n });\n\n try {\n return await Promise.race([invokePromise, timeoutPromise]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n }\n\n /**\n * Generate personalized presentation for a single opportunity.\n */\n @Timed()\n public async present(\n input: PresenterInput,\n ): Promise<OpportunityPresentationResult> {\n const introContext = input.isIntroduction\n ? `\\nINTRODUCTION CONTEXT: This opportunity was created by an explicit introduction from ${input.introducerName ?? \"someone in the community\"}. It was NOT discovered automatically — a real person made this connection.\\n`\n : \"\";\n const humanContent = `\nVIEWER (the person seeing this opportunity):\n${input.viewerContext}\n\nOTHER PARTY:\n${input.otherPartyContext}\n\nMATCH CONTEXT:\n- Category: ${input.category}\n- Confidence: ${input.confidence}\n- Why we matched: ${input.matchReasoning}\n- Signals: ${input.signalsSummary}\n${introContext}\nCOMMUNITY: ${input.indexName}\nViewer's role in this opportunity: ${input.viewerRole}\n\nProduce headline, personalizedSummary (2-3 sentences in \"you\" language), suggestedAction, and greeting.\n`;\n\n try {\n const messages = [\n new SystemMessage(systemPrompt),\n new HumanMessage(humanContent),\n ];\n const result = await this.invokeWithTimeout(this.model, messages);\n const parsed = responseFormat.parse(result);\n parsed.presentation.personalizedSummary = stripUuids(parsed.presentation.personalizedSummary);\n return parsed.presentation;\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n const timeoutReason = message.includes(\"timed out\") ? message : undefined;\n logger.warn(\n \"[OpportunityPresenter.present] LLM failed, returning fallback\",\n {\n event: \"presenter_fallback\",\n presenter: \"opportunity\",\n reason: timeoutReason ? \"timeout\" : \"parse_error\",\n message,\n timeoutReason,\n },\n );\n return {\n headline: \"A promising connection\",\n personalizedSummary: truncateAtBoundary(stripUuids(input.matchReasoning), 300),\n suggestedAction: \"Take a look and decide whether to reach out.\",\n greeting: \"\",\n isFallback: true,\n };\n }\n }\n\n /**\n * Generate LLM-powered home-card content (headline, body, narrator remark, mutual-intent label).\n * Callers append button labels from opportunity.constants.\n *\n * When `negotiationContext.status === 'negotiating'`, returns a templated\n * chip synchronously without invoking the LLM — the card just reflects\n * \"negotiation in progress\" at that point.\n */\n @Timed()\n public async presentHomeCard(\n input: HomeCardPresenterInput,\n ): Promise<HomeCardLLMResult> {\n if (input.negotiationContext?.status === 'negotiating') {\n return buildNegotiatingChip(input);\n }\n\n const mutualHint =\n input.mutualIntentCount != null && input.mutualIntentCount > 0\n ? `There are ${input.mutualIntentCount} overlapping intent(s) between viewer and other party.`\n : \"Match is based on profile and intent alignment. Do not cite a numeric intent count.\";\n const introContext = input.isIntroduction\n ? `\\nINTRODUCTION CONTEXT: This opportunity was created by an explicit introduction from ${input.introducerName ?? \"someone in the community\"}. It was NOT discovered automatically — a real person made this connection.\\n`\n : \"\";\n const negotiationBlock = buildNegotiationPromptBlock(input.negotiationContext);\n // When negotiation context exists, lead with it — these cards exist\n // *because* the negotiation happened. Trailing the block lets weaker\n // models lean on surface signals and ignore the transcript entirely.\n const negotiationDirective = negotiationBlock\n ? `\\nIMPORTANT: This opportunity surfaced because the agents negotiated and converged. Both your personalizedSummary AND your digestSummary MUST reference at least one specific signal from the NEGOTIATION CONTEXT block below — what concern was raised, what was confirmed, what the agents agreed on. The digestSummary is the one-line morning-brief sentence a user reads before deciding to act, so it must communicate *why this specific match* surfaced now (the negotiation that led to it), not a generic skill-complementarity line. Do not produce the generic summary every card looked like before this negotiation happened.\\n`\n : \"\";\n const humanContent = `\n${negotiationBlock}${negotiationDirective}\nVIEWER (the person seeing this opportunity):\n${input.viewerContext}\n\nOTHER PARTY:\n${input.otherPartyContext}\n\nMATCH CONTEXT:\n- Category: ${input.category}\n- Confidence: ${input.confidence}\n- Why we matched: ${input.matchReasoning}\n- Signals: ${input.signalsSummary}\n- ${mutualHint}\n${introContext}\nCOMMUNITY: ${input.indexName}\nViewer's role in this opportunity: ${input.viewerRole}\nOpportunity status: ${input.opportunityStatus ?? \"pending\"}\n\nProduce headline, personalizedSummary, digestSummary, suggestedAction, narratorRemark, greeting, and mutualIntentsLabel.\n`;\n\n const isIntroducer = input.viewerRole === \"introducer\";\n\n try {\n const messages = [\n new SystemMessage(homeCardSystemPrompt),\n new HumanMessage(humanContent),\n ];\n const result = await this.invokeWithTimeout(this.homeCardModel, messages);\n const parsed = homeCardResponseFormat.parse(result);\n parsed.presentation.personalizedSummary = stripUuids(parsed.presentation.personalizedSummary);\n parsed.presentation.digestSummary = stripUuids(parsed.presentation.digestSummary);\n parsed.presentation.narratorRemark = stripUuids(parsed.presentation.narratorRemark);\n if (/^0\\s+(mutual|overlapping)\\s+intent/i.test(parsed.presentation.mutualIntentsLabel)) {\n parsed.presentation.mutualIntentsLabel = \"Shared interests\";\n }\n if (input.isIntroduction && input.introducerName) {\n parsed.presentation.personalizedSummary = stripIntroducerMentions(\n parsed.presentation.personalizedSummary,\n input.introducerName,\n );\n parsed.presentation.digestSummary = stripIntroducerMentions(\n parsed.presentation.digestSummary,\n input.introducerName,\n );\n }\n return parsed.presentation;\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n const timeoutReason = message.includes(\"timed out\") ? message : undefined;\n logger.warn(\n \"[OpportunityPresenter.presentHomeCard] LLM failed, returning fallback\",\n {\n event: \"presenter_fallback\",\n presenter: \"home_card\",\n reason: timeoutReason ? \"timeout\" : \"parse_error\",\n message,\n timeoutReason,\n },\n );\n let fallbackSummary = truncateAtBoundary(stripUuids(input.matchReasoning), 300);\n if (input.isIntroduction && input.introducerName) {\n fallbackSummary = stripIntroducerMentions(fallbackSummary, input.introducerName);\n }\n return {\n headline: \"A promising connection\",\n personalizedSummary: fallbackSummary,\n digestSummary: isIntroducer\n ? \"You may be able to help make a useful introduction here.\"\n : \"You might like meeting them based on your current interests.\",\n suggestedAction: isIntroducer\n ? \"Share this introduction to get things started.\"\n : \"Take a look and decide whether to reach out.\",\n narratorRemark: \"Worth a look.\",\n mutualIntentsLabel: isIntroducer\n ? \"Connector match\"\n : input.mutualIntentCount != null && input.mutualIntentCount > 0\n ? `${input.mutualIntentCount} mutual intent${input.mutualIntentCount !== 1 ? \"s\" : \"\"}`\n : \"Shared interests\",\n greeting: \"\",\n isFallback: true,\n };\n }\n }\n\n /**\n * Process multiple opportunities in parallel with bounded concurrency.\n */\n @Timed()\n public async presentBatch(\n inputs: PresenterInput[],\n options?: { concurrency?: number },\n ): Promise<OpportunityPresentationResult[]> {\n const concurrency = options?.concurrency ?? 5;\n const results: OpportunityPresentationResult[] = [];\n for (let i = 0; i < inputs.length; i += concurrency) {\n const chunk = inputs.slice(i, i + concurrency);\n const chunkResults = await Promise.all(\n chunk.map((inp) => this.present(inp)),\n );\n results.push(...chunkResults);\n }\n return results;\n }\n\n /**\n * Process multiple opportunities as home cards in parallel with bounded concurrency.\n * Returns full home-card display contracts (headline, body, narrator remark, action labels, mutual-intent label).\n */\n @Timed()\n public async presentHomeCardBatch(\n inputs: HomeCardPresenterInput[],\n options?: { concurrency?: number },\n ): Promise<HomeCardLLMResult[]> {\n const concurrency = options?.concurrency ?? 5;\n const results: HomeCardLLMResult[] = [];\n for (let i = 0; i < inputs.length; i += concurrency) {\n const chunk = inputs.slice(i, i + concurrency);\n const chunkResults = await Promise.all(\n chunk.map((inp) => this.presentHomeCard(inp)),\n );\n results.push(...chunkResults);\n }\n return results;\n }\n}\n\n// ──────────────────────────────────────────────────────────────\n// NEGOTIATION CONTEXT HELPERS\n// ──────────────────────────────────────────────────────────────\n\n/**\n * Builds a \"NEGOTIATION CONTEXT:\" block for the home-card prompt. Returns an\n * empty string when the opportunity has no meaningful negotiation context\n * (draft/latent) or when the opportunity is still negotiating (handled via\n * the templated chip, not the LLM).\n */\nfunction buildNegotiationPromptBlock(context: NegotiationContext | undefined): string {\n if (!context || context.status === 'negotiating') return \"\";\n\n const turnCapLabel = context.turnCap > 0 ? `${context.turnCap}` : \"unlimited\";\n const reason = context.outcome?.reason;\n const reasonLabel = reason === 'turn_cap'\n ? \"agents hit the turn cap without converging\"\n : reason === 'timeout'\n ? \"counterpart went silent before responding\"\n : undefined;\n\n const turnLines = (context.turns ?? []).map((turn, index) => {\n const action = turn.action;\n const reasoning = turn.assessment?.reasoning ?? \"(no reasoning)\";\n const message = turn.message ? ` — said: \"${turn.message}\"` : \"\";\n return `Turn ${index + 1} (${action}): ${reasoning}${message}`;\n });\n\n const outcomeSummary = context.outcome\n ? `Final outcome: ${context.outcome.hasOpportunity ? \"agreed\" : \"declined\"} — ${context.outcome.reasoning}`\n : \"Final outcome: not recorded.\";\n\n return `\nNEGOTIATION CONTEXT:\n- Negotiation status: ${context.status}${reasonLabel ? ` (${reasonLabel})` : \"\"}\n- Turns exchanged: ${context.turnCount} of ${turnCapLabel}\n- Transcript:\n${turnLines.length > 0 ? turnLines.map((l) => ` ${l}`).join(\"\\n\") : \" (no turns recorded)\"}\n- ${outcomeSummary}\n`;\n}\n\n/**\n * Builds a templated home-card result for an opportunity whose negotiation\n * is still in progress. Bypasses the LLM so users see a stable \"currently\n * negotiating\" chip while turns are still being exchanged.\n */\nfunction buildNegotiatingChip(input: HomeCardPresenterInput): HomeCardLLMResult {\n const ctx = input.negotiationContext;\n const turnCount = ctx?.turnCount ?? 0;\n const turnCap = ctx?.turnCap && ctx.turnCap > 0 ? ctx.turnCap : undefined;\n const narratorRemark = turnCap\n ? `Currently negotiating · turn ${turnCount} of ${turnCap}`\n : `Currently negotiating · turn ${turnCount}`;\n\n return {\n headline: \"Negotiation in progress\",\n personalizedSummary: \"Your agent is still talking with theirs to see if this connection makes sense. We'll surface the full match as soon as they converge.\",\n digestSummary: \"Your agent is still checking whether this connection makes sense.\",\n suggestedAction: \"Check back shortly — no action needed yet.\",\n narratorRemark,\n mutualIntentsLabel: input.mutualIntentCount && input.mutualIntentCount > 0\n ? `${input.mutualIntentCount} mutual intent${input.mutualIntentCount !== 1 ? \"s\" : \"\"}`\n : \"Shared interests\",\n greeting: \"\",\n };\n}\n\n// ──────────────────────────────────────────────────────────────\n// CONTEXT GATHERER (used by tools)\n// ──────────────────────────────────────────────────────────────\n\n/**\n * Gather all context needed for the presenter from the database.\n * Fetches viewer profile, viewer intents, other party profile(s), and index in parallel.\n *\n * @param displayCounterpartUserId - When set (e.g. for home card), only this counterpart is included in otherPartyContext so the presenter writes about the person on the card. Omitted for introducer view (card shows both parties).\n */\nexport async function gatherPresenterContext(\n database: PresenterDatabase,\n opportunity: Opportunity,\n viewerId: string,\n displayCounterpartUserId?: string,\n): Promise<PresenterInput> {\n const myActor = opportunity.actors.find((a) => a.userId === viewerId);\n if (!myActor) {\n throw new Error(\"Viewer is not an actor in this opportunity\");\n }\n\n const isIntroducer = myActor.role === \"introducer\";\n const otherActors = opportunity.actors.filter((a) => a.userId !== viewerId);\n let otherPartyIds = [...new Set(otherActors.map((a) => a.userId))];\n if (\n displayCounterpartUserId &&\n !isIntroducer &&\n otherPartyIds.includes(displayCounterpartUserId)\n ) {\n otherPartyIds = [displayCounterpartUserId];\n }\n\n const contextIndexId = opportunity.context?.networkId;\n\n // For introducers: fetch profiles + intents for both parties; skip introducer's own intents.\n // For other roles: fetch viewer's profile + intents and other party profiles.\n const [viewerProfile, indexRecord, ...otherProfiles] = await Promise.all([\n database.getProfile(viewerId),\n contextIndexId ? database.getNetwork(contextIndexId) : Promise.resolve(null),\n ...otherPartyIds.map((uid) => database.getProfile(uid)),\n ]);\n\n // Fetch intents: for introducer, fetch each party's intents; otherwise fetch viewer's intents.\n let viewerIntents:\n | Awaited<ReturnType<typeof database.getActiveIntents>>\n | undefined;\n let partyIntentsMap:\n | Map<string, Awaited<ReturnType<typeof database.getActiveIntents>>>\n | undefined;\n\n if (isIntroducer) {\n const partyIntentResults = await Promise.all(\n otherPartyIds.map(async (uid) => ({\n uid,\n intents: await database.getActiveIntents(uid),\n })),\n );\n partyIntentsMap = new Map(\n partyIntentResults.map((r) => [r.uid, r.intents]),\n );\n } else {\n viewerIntents = await database.getActiveIntents(viewerId);\n }\n\n // Fetch premises when any actor is premise-grounded\n const premiseGroundedActors = opportunity.actors.filter((a) => a.premise);\n let viewerPremiseContext = '';\n let otherPremiseContext = '';\n\n if (premiseGroundedActors.length > 0) {\n // Only fetch premises for actors that are actually premise-grounded, not all parties\n const groundedOtherIds = premiseGroundedActors\n .filter((a) => a.userId !== viewerId)\n .map((a) => a.userId);\n const viewerIsGrounded = premiseGroundedActors.some((a) => a.userId === viewerId);\n\n const results = await Promise.all([\n ...(viewerIsGrounded ? [database.getPremisesForUser(viewerId, 'ACTIVE')] : []),\n ...groundedOtherIds.map((uid) => database.getPremisesForUser(uid, 'ACTIVE')),\n ]);\n\n let idx = 0;\n if (viewerIsGrounded) {\n const viewerPremises = results[idx++];\n if (viewerPremises?.length) {\n viewerPremiseContext =\n '\\nPremises (self-descriptions):\\n' +\n viewerPremises\n .slice(0, 5)\n .map((p) => `- ${p.assertion.text}`)\n .join('\\n');\n }\n }\n\n const otherPremiseLines: string[] = [];\n for (let i = 0; i < groundedOtherIds.length; i++) {\n const premises = results[idx++];\n if (premises?.length) {\n for (const p of premises.slice(0, 3)) {\n otherPremiseLines.push(`- ${p.assertion.text}`);\n }\n }\n }\n if (otherPremiseLines.length > 0) {\n otherPremiseContext = '\\nPremises (self-descriptions):\\n' + otherPremiseLines.join('\\n');\n }\n }\n\n let viewerContext: string;\n let otherPartyContext: string;\n\n if (isIntroducer) {\n // Introducer view: minimal viewer context (just name + role), rich other-party context with intents\n const introducerApproved = opportunity.actors.find(a => a.role === 'introducer')?.approved === true;\n const hasApproved = introducerApproved || opportunity.status !== 'latent';\n viewerContext = [\n \"Profile:\",\n `Name: ${viewerProfile?.identity?.name ?? \"Unknown\"}`,\n hasApproved\n ? \"Role: You are the introducer who suggested this connection.\"\n : \"Role: You are being asked whether these two people would benefit from meeting. You have NOT yet approved this introduction.\",\n ].join(\"\\n\");\n\n const otherParts = otherPartyIds.map((uid, idx) => {\n const profile = otherProfiles[idx] as Awaited<\n ReturnType<typeof database.getProfile>\n >;\n const name = profile?.identity?.name ?? \"Unknown\";\n const bio = profile?.identity?.bio ?? \"\";\n const location = profile?.identity?.location ?? \"\";\n const context = profile?.context ?? \"\";\n const intents = partyIntentsMap?.get(uid);\n const intentLines = intents?.length\n ? intents\n .slice(0, 5)\n .map((i) => ` - ${i.payload}${i.summary ? ` (${i.summary})` : \"\"}`)\n : [\" (no active intents)\"];\n return [\n `${name}:`,\n ` Bio: ${bio}`,\n location ? ` Location: ${location}` : null,\n context ? ` Context: ${context}` : null,\n ` Active intents:`,\n ...intentLines,\n ]\n .filter(Boolean)\n .join(\"\\n\");\n });\n otherPartyContext =\n otherParts.join(\"\\n\\n\") || \"Parties (details not available).\";\n } else {\n // Non-introducer view: full viewer profile + intents, other party profiles\n const viewerContextLines = [\n \"Profile:\",\n `Name: ${viewerProfile?.identity?.name ?? \"Unknown\"}`,\n `Bio: ${viewerProfile?.identity?.bio ?? \"\"}`,\n `Location: ${viewerProfile?.identity?.location ?? \"\"}`,\n `Context: ${viewerProfile?.context ?? \"\"}`,\n \"Active intents:\",\n ...(viewerIntents?.length\n ? viewerIntents.map(\n (i) => `- ${i.payload}${i.summary ? ` (${i.summary})` : \"\"}`,\n )\n : [\"(none listed)\"]),\n ];\n viewerContext = viewerContextLines.join(\"\\n\");\n\n const otherParts = otherPartyIds.map((uid, idx) => {\n const profile = otherProfiles[idx] as Awaited<\n ReturnType<typeof database.getProfile>\n >;\n const name = profile?.identity?.name ?? \"Unknown\";\n const bio = profile?.identity?.bio ?? \"\";\n return `${name}: ${bio}`;\n });\n otherPartyContext =\n otherParts.join(\"\\n\\n\") || \"Other party (details not available).\";\n }\n\n const interp = opportunity.interpretation;\n const signalsSummary =\n interp.signals?.map((s) => `${s.type}: ${s.detail ?? s.type}`).join(\"; \") ??\n \"Match based on profile and intent alignment.\";\n\n // Detect introduction-originated opportunities: only when there is an explicit introducer actor.\n // Do NOT use detection.source === \"manual\" alone — system-discovered opportunities can have manual source without an introducer.\n const introducerActor = opportunity.actors.find(\n (a) => a.role === \"introducer\",\n );\n const isIntroduction = !!introducerActor;\n let introducerName: string | undefined;\n if (introducerActor) {\n introducerName = opportunity.detection.createdByName;\n if (!introducerName) {\n const introducerProfile = await database.getProfile(\n introducerActor.userId,\n );\n introducerName = introducerProfile?.identity?.name ?? undefined;\n }\n }\n\n const counterpartName =\n otherPartyIds.length === 1 && otherProfiles[0]\n ? (otherProfiles[0] as { identity?: { name?: string } })?.identity?.name?.trim()\n : undefined;\n const viewerNameForFilter = viewerProfile?.identity?.name?.trim();\n const matchReasoning =\n counterpartName && interp.reasoning\n ? viewerCentricCardSummary(\n interp.reasoning,\n counterpartName,\n 400,\n viewerNameForFilter,\n introducerName,\n )\n : stripUuids(interp.reasoning);\n\n if (viewerPremiseContext) {\n viewerContext += viewerPremiseContext;\n }\n if (otherPremiseContext) {\n otherPartyContext += otherPremiseContext;\n }\n\n const result: PresenterInput = {\n viewerContext,\n otherPartyContext,\n matchReasoning,\n category: interp.category ?? \"connection\",\n confidence:\n typeof interp.confidence === \"number\"\n ? interp.confidence\n : parseFloat(String(interp.confidence ?? 0)) || 0,\n signalsSummary,\n indexName: indexRecord?.title ?? contextIndexId ?? \"\",\n viewerRole: myActor.role ?? \"party\",\n isIntroduction,\n introducerName,\n };\n\n return result;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"question.generator.d.ts","sourceRoot":"/","sources":["opportunity/question.generator.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAkD,KAAK,wBAAwB,EAAoD,MAAM,sCAAsC,CAAC;AAKvL,OAAO,EAAsC,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAOvG,oFAAoF;AACpF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAAiD;;IAS9D;;;;;;;;;;OAUG;IAEG,QAAQ,CACZ,KAAK,EAAE,sBAAsB,EAC7B,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACjC,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;CAyC5C"}
1
+ {"version":3,"file":"question.generator.d.ts","sourceRoot":"/","sources":["opportunity/question.generator.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAkD,KAAK,wBAAwB,EAAoD,MAAM,sCAAsC,CAAC;AAKvL,OAAO,EAAsC,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAOvG,oFAAoF;AACpF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAA2C;;IAQxD;;;;;;;;;;OAUG;IAEG,QAAQ,CACZ,KAAK,EAAE,sBAAsB,EAC7B,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACjC,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;CAyC5C"}