@indexnetwork/protocol 0.1.0

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 (365) hide show
  1. package/dist/agents/chat.agent.d.ts +218 -0
  2. package/dist/agents/chat.agent.d.ts.map +1 -0
  3. package/dist/agents/chat.agent.js +884 -0
  4. package/dist/agents/chat.agent.js.map +1 -0
  5. package/dist/agents/chat.prompt.d.ts +18 -0
  6. package/dist/agents/chat.prompt.d.ts.map +1 -0
  7. package/dist/agents/chat.prompt.js +372 -0
  8. package/dist/agents/chat.prompt.js.map +1 -0
  9. package/dist/agents/chat.prompt.modules.d.ts +61 -0
  10. package/dist/agents/chat.prompt.modules.d.ts.map +1 -0
  11. package/dist/agents/chat.prompt.modules.js +366 -0
  12. package/dist/agents/chat.prompt.modules.js.map +1 -0
  13. package/dist/agents/chat.title.generator.d.ts +20 -0
  14. package/dist/agents/chat.title.generator.d.ts.map +1 -0
  15. package/dist/agents/chat.title.generator.js +66 -0
  16. package/dist/agents/chat.title.generator.js.map +1 -0
  17. package/dist/agents/home.categorizer.d.ts +28 -0
  18. package/dist/agents/home.categorizer.d.ts.map +1 -0
  19. package/dist/agents/home.categorizer.js +170 -0
  20. package/dist/agents/home.categorizer.js.map +1 -0
  21. package/dist/agents/hyde.generator.d.ts +27 -0
  22. package/dist/agents/hyde.generator.d.ts.map +1 -0
  23. package/dist/agents/hyde.generator.js +75 -0
  24. package/dist/agents/hyde.generator.js.map +1 -0
  25. package/dist/agents/hyde.strategies.d.ts +17 -0
  26. package/dist/agents/hyde.strategies.d.ts.map +1 -0
  27. package/dist/agents/hyde.strategies.js +29 -0
  28. package/dist/agents/hyde.strategies.js.map +1 -0
  29. package/dist/agents/intent.clarifier.d.ts +29 -0
  30. package/dist/agents/intent.clarifier.d.ts.map +1 -0
  31. package/dist/agents/intent.clarifier.js +186 -0
  32. package/dist/agents/intent.clarifier.js.map +1 -0
  33. package/dist/agents/intent.indexer.d.ts +77 -0
  34. package/dist/agents/intent.indexer.d.ts.map +1 -0
  35. package/dist/agents/intent.indexer.js +164 -0
  36. package/dist/agents/intent.indexer.js.map +1 -0
  37. package/dist/agents/intent.inferrer.d.ts +95 -0
  38. package/dist/agents/intent.inferrer.d.ts.map +1 -0
  39. package/dist/agents/intent.inferrer.js +238 -0
  40. package/dist/agents/intent.inferrer.js.map +1 -0
  41. package/dist/agents/intent.reconciler.d.ts +106 -0
  42. package/dist/agents/intent.reconciler.d.ts.map +1 -0
  43. package/dist/agents/intent.reconciler.js +184 -0
  44. package/dist/agents/intent.reconciler.js.map +1 -0
  45. package/dist/agents/intent.verifier.d.ts +97 -0
  46. package/dist/agents/intent.verifier.d.ts.map +1 -0
  47. package/dist/agents/intent.verifier.js +234 -0
  48. package/dist/agents/intent.verifier.js.map +1 -0
  49. package/dist/agents/invite.generator.d.ts +47 -0
  50. package/dist/agents/invite.generator.d.ts.map +1 -0
  51. package/dist/agents/invite.generator.js +56 -0
  52. package/dist/agents/invite.generator.js.map +1 -0
  53. package/dist/agents/lens.inferrer.d.ts +37 -0
  54. package/dist/agents/lens.inferrer.d.ts.map +1 -0
  55. package/dist/agents/lens.inferrer.js +98 -0
  56. package/dist/agents/lens.inferrer.js.map +1 -0
  57. package/dist/agents/model.config.d.ts +120 -0
  58. package/dist/agents/model.config.d.ts.map +1 -0
  59. package/dist/agents/model.config.js +76 -0
  60. package/dist/agents/model.config.js.map +1 -0
  61. package/dist/agents/negotiation.insights.generator.d.ts +32 -0
  62. package/dist/agents/negotiation.insights.generator.d.ts.map +1 -0
  63. package/dist/agents/negotiation.insights.generator.js +105 -0
  64. package/dist/agents/negotiation.insights.generator.js.map +1 -0
  65. package/dist/agents/negotiation.proposer.d.ts +26 -0
  66. package/dist/agents/negotiation.proposer.d.ts.map +1 -0
  67. package/dist/agents/negotiation.proposer.js +67 -0
  68. package/dist/agents/negotiation.proposer.js.map +1 -0
  69. package/dist/agents/negotiation.responder.d.ts +26 -0
  70. package/dist/agents/negotiation.responder.d.ts.map +1 -0
  71. package/dist/agents/negotiation.responder.js +71 -0
  72. package/dist/agents/negotiation.responder.js.map +1 -0
  73. package/dist/agents/opportunity.evaluator.d.ts +253 -0
  74. package/dist/agents/opportunity.evaluator.d.ts.map +1 -0
  75. package/dist/agents/opportunity.evaluator.js +413 -0
  76. package/dist/agents/opportunity.evaluator.js.map +1 -0
  77. package/dist/agents/opportunity.presenter.d.ts +115 -0
  78. package/dist/agents/opportunity.presenter.d.ts.map +1 -0
  79. package/dist/agents/opportunity.presenter.js +524 -0
  80. package/dist/agents/opportunity.presenter.js.map +1 -0
  81. package/dist/agents/profile.generator.d.ts +67 -0
  82. package/dist/agents/profile.generator.d.ts.map +1 -0
  83. package/dist/agents/profile.generator.js +97 -0
  84. package/dist/agents/profile.generator.js.map +1 -0
  85. package/dist/agents/profile.hyde.generator.d.ts +43 -0
  86. package/dist/agents/profile.hyde.generator.d.ts.map +1 -0
  87. package/dist/agents/profile.hyde.generator.js +113 -0
  88. package/dist/agents/profile.hyde.generator.js.map +1 -0
  89. package/dist/agents/suggestion.generator.d.ts +24 -0
  90. package/dist/agents/suggestion.generator.d.ts.map +1 -0
  91. package/dist/agents/suggestion.generator.js +96 -0
  92. package/dist/agents/suggestion.generator.js.map +1 -0
  93. package/dist/graphs/chat.graph.d.ts +312 -0
  94. package/dist/graphs/chat.graph.d.ts.map +1 -0
  95. package/dist/graphs/chat.graph.js +267 -0
  96. package/dist/graphs/chat.graph.js.map +1 -0
  97. package/dist/graphs/home.graph.d.ts +180 -0
  98. package/dist/graphs/home.graph.d.ts.map +1 -0
  99. package/dist/graphs/home.graph.js +598 -0
  100. package/dist/graphs/home.graph.js.map +1 -0
  101. package/dist/graphs/hyde.graph.d.ts +110 -0
  102. package/dist/graphs/hyde.graph.d.ts.map +1 -0
  103. package/dist/graphs/hyde.graph.js +235 -0
  104. package/dist/graphs/hyde.graph.js.map +1 -0
  105. package/dist/graphs/index.graph.d.ts +620 -0
  106. package/dist/graphs/index.graph.d.ts.map +1 -0
  107. package/dist/graphs/index.graph.js +226 -0
  108. package/dist/graphs/index.graph.js.map +1 -0
  109. package/dist/graphs/index_membership.graph.d.ts +250 -0
  110. package/dist/graphs/index_membership.graph.d.ts.map +1 -0
  111. package/dist/graphs/index_membership.graph.js +204 -0
  112. package/dist/graphs/index_membership.graph.js.map +1 -0
  113. package/dist/graphs/intent.graph.d.ts +490 -0
  114. package/dist/graphs/intent.graph.d.ts.map +1 -0
  115. package/dist/graphs/intent.graph.js +787 -0
  116. package/dist/graphs/intent.graph.js.map +1 -0
  117. package/dist/graphs/intent_index.graph.d.ts +396 -0
  118. package/dist/graphs/intent_index.graph.d.ts.map +1 -0
  119. package/dist/graphs/intent_index.graph.js +331 -0
  120. package/dist/graphs/intent_index.graph.js.map +1 -0
  121. package/dist/graphs/maintenance.graph.d.ts +177 -0
  122. package/dist/graphs/maintenance.graph.d.ts.map +1 -0
  123. package/dist/graphs/maintenance.graph.js +173 -0
  124. package/dist/graphs/maintenance.graph.js.map +1 -0
  125. package/dist/graphs/negotiation.graph.d.ts +819 -0
  126. package/dist/graphs/negotiation.graph.d.ts.map +1 -0
  127. package/dist/graphs/negotiation.graph.js +255 -0
  128. package/dist/graphs/negotiation.graph.js.map +1 -0
  129. package/dist/graphs/opportunity.graph.d.ts +1082 -0
  130. package/dist/graphs/opportunity.graph.d.ts.map +1 -0
  131. package/dist/graphs/opportunity.graph.js +2534 -0
  132. package/dist/graphs/opportunity.graph.js.map +1 -0
  133. package/dist/graphs/profile.graph.d.ts +617 -0
  134. package/dist/graphs/profile.graph.d.ts.map +1 -0
  135. package/dist/graphs/profile.graph.js +839 -0
  136. package/dist/graphs/profile.graph.js.map +1 -0
  137. package/dist/graphs/tests/chat.graph.mocks.d.ts +104 -0
  138. package/dist/graphs/tests/chat.graph.mocks.d.ts.map +1 -0
  139. package/dist/graphs/tests/chat.graph.mocks.js +225 -0
  140. package/dist/graphs/tests/chat.graph.mocks.js.map +1 -0
  141. package/dist/index.d.ts +62 -0
  142. package/dist/index.d.ts.map +1 -0
  143. package/dist/index.js +44 -0
  144. package/dist/index.js.map +1 -0
  145. package/dist/interfaces/auth.interface.d.ts +15 -0
  146. package/dist/interfaces/auth.interface.d.ts.map +1 -0
  147. package/dist/interfaces/auth.interface.js +2 -0
  148. package/dist/interfaces/auth.interface.js.map +1 -0
  149. package/dist/interfaces/cache.interface.d.ts +43 -0
  150. package/dist/interfaces/cache.interface.d.ts.map +1 -0
  151. package/dist/interfaces/cache.interface.js +6 -0
  152. package/dist/interfaces/cache.interface.js.map +1 -0
  153. package/dist/interfaces/chat-session.interface.d.ts +11 -0
  154. package/dist/interfaces/chat-session.interface.d.ts.map +1 -0
  155. package/dist/interfaces/chat-session.interface.js +2 -0
  156. package/dist/interfaces/chat-session.interface.js.map +1 -0
  157. package/dist/interfaces/contact.interface.d.ts +48 -0
  158. package/dist/interfaces/contact.interface.d.ts.map +1 -0
  159. package/dist/interfaces/contact.interface.js +2 -0
  160. package/dist/interfaces/contact.interface.js.map +1 -0
  161. package/dist/interfaces/database.interface.d.ts +1495 -0
  162. package/dist/interfaces/database.interface.d.ts.map +1 -0
  163. package/dist/interfaces/database.interface.js +2 -0
  164. package/dist/interfaces/database.interface.js.map +1 -0
  165. package/dist/interfaces/embedder.interface.d.ts +85 -0
  166. package/dist/interfaces/embedder.interface.d.ts.map +1 -0
  167. package/dist/interfaces/embedder.interface.js +5 -0
  168. package/dist/interfaces/embedder.interface.js.map +1 -0
  169. package/dist/interfaces/enrichment.interface.d.ts +40 -0
  170. package/dist/interfaces/enrichment.interface.d.ts.map +1 -0
  171. package/dist/interfaces/enrichment.interface.js +2 -0
  172. package/dist/interfaces/enrichment.interface.js.map +1 -0
  173. package/dist/interfaces/integration.interface.d.ts +91 -0
  174. package/dist/interfaces/integration.interface.d.ts.map +1 -0
  175. package/dist/interfaces/integration.interface.js +2 -0
  176. package/dist/interfaces/integration.interface.js.map +1 -0
  177. package/dist/interfaces/queue.interface.d.ts +17 -0
  178. package/dist/interfaces/queue.interface.d.ts.map +1 -0
  179. package/dist/interfaces/queue.interface.js +5 -0
  180. package/dist/interfaces/queue.interface.js.map +1 -0
  181. package/dist/interfaces/scraper.interface.d.ts +31 -0
  182. package/dist/interfaces/scraper.interface.d.ts.map +1 -0
  183. package/dist/interfaces/scraper.interface.js +2 -0
  184. package/dist/interfaces/scraper.interface.js.map +1 -0
  185. package/dist/interfaces/storage.interface.d.ts +46 -0
  186. package/dist/interfaces/storage.interface.d.ts.map +1 -0
  187. package/dist/interfaces/storage.interface.js +6 -0
  188. package/dist/interfaces/storage.interface.js.map +1 -0
  189. package/dist/mcp/mcp.server.d.ts +29 -0
  190. package/dist/mcp/mcp.server.d.ts.map +1 -0
  191. package/dist/mcp/mcp.server.js +171 -0
  192. package/dist/mcp/mcp.server.js.map +1 -0
  193. package/dist/states/chat.state.d.ts +126 -0
  194. package/dist/states/chat.state.d.ts.map +1 -0
  195. package/dist/states/chat.state.js +112 -0
  196. package/dist/states/chat.state.js.map +1 -0
  197. package/dist/states/home.state.d.ts +100 -0
  198. package/dist/states/home.state.d.ts.map +1 -0
  199. package/dist/states/home.state.js +74 -0
  200. package/dist/states/home.state.js.map +1 -0
  201. package/dist/states/hyde.state.d.ts +54 -0
  202. package/dist/states/hyde.state.d.ts.map +1 -0
  203. package/dist/states/hyde.state.js +66 -0
  204. package/dist/states/hyde.state.js.map +1 -0
  205. package/dist/states/index.state.d.ts +179 -0
  206. package/dist/states/index.state.d.ts.map +1 -0
  207. package/dist/states/index.state.js +56 -0
  208. package/dist/states/index.state.js.map +1 -0
  209. package/dist/states/index_membership.state.d.ts +77 -0
  210. package/dist/states/index_membership.state.d.ts.map +1 -0
  211. package/dist/states/index_membership.state.js +43 -0
  212. package/dist/states/index_membership.state.js.map +1 -0
  213. package/dist/states/intent.state.d.ts +203 -0
  214. package/dist/states/intent.state.d.ts.map +1 -0
  215. package/dist/states/intent.state.js +153 -0
  216. package/dist/states/intent.state.js.map +1 -0
  217. package/dist/states/intent_index.state.d.ts +148 -0
  218. package/dist/states/intent_index.state.d.ts.map +1 -0
  219. package/dist/states/intent_index.state.js +100 -0
  220. package/dist/states/intent_index.state.js.map +1 -0
  221. package/dist/states/maintenance.state.d.ts +36 -0
  222. package/dist/states/maintenance.state.d.ts.map +1 -0
  223. package/dist/states/maintenance.state.js +56 -0
  224. package/dist/states/maintenance.state.js.map +1 -0
  225. package/dist/states/negotiation.state.d.ts +230 -0
  226. package/dist/states/negotiation.state.d.ts.map +1 -0
  227. package/dist/states/negotiation.state.js +82 -0
  228. package/dist/states/negotiation.state.js.map +1 -0
  229. package/dist/states/opportunity.state.d.ts +300 -0
  230. package/dist/states/opportunity.state.d.ts.map +1 -0
  231. package/dist/states/opportunity.state.js +207 -0
  232. package/dist/states/opportunity.state.js.map +1 -0
  233. package/dist/states/profile.state.d.ts +172 -0
  234. package/dist/states/profile.state.d.ts.map +1 -0
  235. package/dist/states/profile.state.js +133 -0
  236. package/dist/states/profile.state.js.map +1 -0
  237. package/dist/streamers/chat.streamer.d.ts +55 -0
  238. package/dist/streamers/chat.streamer.d.ts.map +1 -0
  239. package/dist/streamers/chat.streamer.js +186 -0
  240. package/dist/streamers/chat.streamer.js.map +1 -0
  241. package/dist/streamers/index.d.ts +3 -0
  242. package/dist/streamers/index.d.ts.map +1 -0
  243. package/dist/streamers/index.js +3 -0
  244. package/dist/streamers/index.js.map +1 -0
  245. package/dist/streamers/response.streamer.d.ts +36 -0
  246. package/dist/streamers/response.streamer.d.ts.map +1 -0
  247. package/dist/streamers/response.streamer.js +46 -0
  248. package/dist/streamers/response.streamer.js.map +1 -0
  249. package/dist/support/chat.utils.d.ts +42 -0
  250. package/dist/support/chat.utils.d.ts.map +1 -0
  251. package/dist/support/chat.utils.js +89 -0
  252. package/dist/support/chat.utils.js.map +1 -0
  253. package/dist/support/debug-meta.sanitizer.d.ts +18 -0
  254. package/dist/support/debug-meta.sanitizer.d.ts.map +1 -0
  255. package/dist/support/debug-meta.sanitizer.js +82 -0
  256. package/dist/support/debug-meta.sanitizer.js.map +1 -0
  257. package/dist/support/feed.health.d.ts +32 -0
  258. package/dist/support/feed.health.d.ts.map +1 -0
  259. package/dist/support/feed.health.js +76 -0
  260. package/dist/support/feed.health.js.map +1 -0
  261. package/dist/support/introducer.discovery.d.ts +78 -0
  262. package/dist/support/introducer.discovery.d.ts.map +1 -0
  263. package/dist/support/introducer.discovery.js +101 -0
  264. package/dist/support/introducer.discovery.js.map +1 -0
  265. package/dist/support/log.d.ts +65 -0
  266. package/dist/support/log.d.ts.map +1 -0
  267. package/dist/support/log.js +76 -0
  268. package/dist/support/log.js.map +1 -0
  269. package/dist/support/lucide.icon-catalog.d.ts +22 -0
  270. package/dist/support/lucide.icon-catalog.d.ts.map +1 -0
  271. package/dist/support/lucide.icon-catalog.js +101 -0
  272. package/dist/support/lucide.icon-catalog.js.map +1 -0
  273. package/dist/support/opportunity.card-text.d.ts +39 -0
  274. package/dist/support/opportunity.card-text.d.ts.map +1 -0
  275. package/dist/support/opportunity.card-text.js +333 -0
  276. package/dist/support/opportunity.card-text.js.map +1 -0
  277. package/dist/support/opportunity.constants.d.ts +9 -0
  278. package/dist/support/opportunity.constants.d.ts.map +1 -0
  279. package/dist/support/opportunity.constants.js +11 -0
  280. package/dist/support/opportunity.constants.js.map +1 -0
  281. package/dist/support/opportunity.discover.d.ts +144 -0
  282. package/dist/support/opportunity.discover.d.ts.map +1 -0
  283. package/dist/support/opportunity.discover.js +610 -0
  284. package/dist/support/opportunity.discover.js.map +1 -0
  285. package/dist/support/opportunity.enricher.d.ts +44 -0
  286. package/dist/support/opportunity.enricher.d.ts.map +1 -0
  287. package/dist/support/opportunity.enricher.js +245 -0
  288. package/dist/support/opportunity.enricher.js.map +1 -0
  289. package/dist/support/opportunity.persist.d.ts +39 -0
  290. package/dist/support/opportunity.persist.d.ts.map +1 -0
  291. package/dist/support/opportunity.persist.js +63 -0
  292. package/dist/support/opportunity.persist.js.map +1 -0
  293. package/dist/support/opportunity.presentation.d.ts +21 -0
  294. package/dist/support/opportunity.presentation.d.ts.map +1 -0
  295. package/dist/support/opportunity.presentation.js +75 -0
  296. package/dist/support/opportunity.presentation.js.map +1 -0
  297. package/dist/support/opportunity.sanitize.d.ts +18 -0
  298. package/dist/support/opportunity.sanitize.d.ts.map +1 -0
  299. package/dist/support/opportunity.sanitize.js +89 -0
  300. package/dist/support/opportunity.sanitize.js.map +1 -0
  301. package/dist/support/opportunity.utils.d.ts +99 -0
  302. package/dist/support/opportunity.utils.d.ts.map +1 -0
  303. package/dist/support/opportunity.utils.js +184 -0
  304. package/dist/support/opportunity.utils.js.map +1 -0
  305. package/dist/support/performance.d.ts +19 -0
  306. package/dist/support/performance.d.ts.map +1 -0
  307. package/dist/support/performance.js +43 -0
  308. package/dist/support/performance.js.map +1 -0
  309. package/dist/support/profile.enrichment-display-name.d.ts +16 -0
  310. package/dist/support/profile.enrichment-display-name.d.ts.map +1 -0
  311. package/dist/support/profile.enrichment-display-name.js +22 -0
  312. package/dist/support/profile.enrichment-display-name.js.map +1 -0
  313. package/dist/support/protocol.logger.d.ts +22 -0
  314. package/dist/support/protocol.logger.d.ts.map +1 -0
  315. package/dist/support/protocol.logger.js +44 -0
  316. package/dist/support/protocol.logger.js.map +1 -0
  317. package/dist/support/request-context.d.ts +19 -0
  318. package/dist/support/request-context.d.ts.map +1 -0
  319. package/dist/support/request-context.js +7 -0
  320. package/dist/support/request-context.js.map +1 -0
  321. package/dist/tools/contact.tools.d.ts +7 -0
  322. package/dist/tools/contact.tools.d.ts.map +1 -0
  323. package/dist/tools/contact.tools.js +115 -0
  324. package/dist/tools/contact.tools.js.map +1 -0
  325. package/dist/tools/index.d.ts +17 -0
  326. package/dist/tools/index.d.ts.map +1 -0
  327. package/dist/tools/index.js +140 -0
  328. package/dist/tools/index.js.map +1 -0
  329. package/dist/tools/index.tools.d.ts +3 -0
  330. package/dist/tools/index.tools.d.ts.map +1 -0
  331. package/dist/tools/index.tools.js +423 -0
  332. package/dist/tools/index.tools.js.map +1 -0
  333. package/dist/tools/integration.tools.d.ts +13 -0
  334. package/dist/tools/integration.tools.d.ts.map +1 -0
  335. package/dist/tools/integration.tools.js +77 -0
  336. package/dist/tools/integration.tools.js.map +1 -0
  337. package/dist/tools/intent.tools.d.ts +3 -0
  338. package/dist/tools/intent.tools.d.ts.map +1 -0
  339. package/dist/tools/intent.tools.js +458 -0
  340. package/dist/tools/intent.tools.js.map +1 -0
  341. package/dist/tools/opportunity.tools.d.ts +44 -0
  342. package/dist/tools/opportunity.tools.d.ts.map +1 -0
  343. package/dist/tools/opportunity.tools.js +814 -0
  344. package/dist/tools/opportunity.tools.js.map +1 -0
  345. package/dist/tools/profile.tools.d.ts +3 -0
  346. package/dist/tools/profile.tools.d.ts.map +1 -0
  347. package/dist/tools/profile.tools.js +513 -0
  348. package/dist/tools/profile.tools.js.map +1 -0
  349. package/dist/tools/tool.helpers.d.ts +225 -0
  350. package/dist/tools/tool.helpers.d.ts.map +1 -0
  351. package/dist/tools/tool.helpers.js +172 -0
  352. package/dist/tools/tool.helpers.js.map +1 -0
  353. package/dist/tools/tool.registry.d.ts +12 -0
  354. package/dist/tools/tool.registry.d.ts.map +1 -0
  355. package/dist/tools/tool.registry.js +62 -0
  356. package/dist/tools/tool.registry.js.map +1 -0
  357. package/dist/tools/utility.tools.d.ts +3 -0
  358. package/dist/tools/utility.tools.d.ts.map +1 -0
  359. package/dist/tools/utility.tools.js +107 -0
  360. package/dist/tools/utility.tools.js.map +1 -0
  361. package/dist/types/chat-streaming.types.d.ts +472 -0
  362. package/dist/types/chat-streaming.types.d.ts.map +1 -0
  363. package/dist/types/chat-streaming.types.js +260 -0
  364. package/dist/types/chat-streaming.types.js.map +1 -0
  365. package/package.json +32 -0
@@ -0,0 +1,413 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { HumanMessage, SystemMessage } from "@langchain/core/messages";
11
+ import { tool } from "@langchain/core/tools";
12
+ import { z } from "zod";
13
+ import { protocolLogger } from "../support/protocol.logger.js";
14
+ import { Timed } from "../support/performance.js";
15
+ import { stripUuids } from "../support/opportunity.sanitize.js";
16
+ import { createModel } from "./model.config.js";
17
+ const logger = protocolLogger("OpportunityEvaluator");
18
+ /**
19
+ * Config
20
+ */
21
+ import { config } from "dotenv";
22
+ config({ path: '.env.development' });
23
+ const model = createModel("opportunityEvaluator");
24
+ // ──────────────────────────────────────────────────────────────
25
+ // 1. SYSTEM PROMPT
26
+ // ──────────────────────────────────────────────────────────────
27
+ const systemPrompt = `
28
+ You are an expert "Opportunity Matcher" and super-connector.
29
+ Your Goal: Analyze a Source User's profile against a Candidate User's profile to identify A SINGLE HIGH-VALUE opportunity.
30
+
31
+ Input:
32
+ - Source Context: The Source User's own Profile.
33
+ - Candidate Profile (JSON)
34
+ - Existing Opportunities (Context of matches already made)
35
+
36
+ Output:
37
+ - A list containing EXACTLY ONE "Opportunity" if a match exists.
38
+ - If NO match exists, return an empty list.
39
+ - Score (0-100): How strong is this match?
40
+ - 90-100: "Must Meet" (Perfect alignment).
41
+ - 70-89: "Should Meet" (Strong overlaps, clear potential).
42
+ - <70: No opportunity (Return empty list).
43
+
44
+ **CRITICAL: VALENCY & REASONING**
45
+
46
+ 1. **Valency Analysis**:
47
+ - Determine the semantic role of the Candidate relative to the Source's goal.
48
+ - "Agent": The Candidate CAN DO something for the Source (e.g., Source needs a dev, Candidate IS a dev).
49
+ - "Patient": The Candidate NEEDS something from the Source (e.g., Source is a mentor, Candidate needs mentoring).
50
+ - "Peer": Symmetric collaboration.
51
+
52
+ 2. **Reasoning (Third-Party Analytical Perspective)**:
53
+ - **reasoning**: A neutral, third-party explanation of why this opportunity exists. Written for other LLM agents to read and understand.
54
+ - Mention BOTH users by their roles (e.g. "The source user" and "The candidate") and explain why they are a match.
55
+ - Do NOT address either user as "you". Write from an objective observer's perspective.
56
+ - Include what each side brings to the connection and why it is mutually valuable.
57
+ - NEVER leak private intents. If someone's intent is confidential, describe their relevant attributes instead.
58
+
59
+ **VISIBILITY IMPLICATIONS OF ROLE ASSIGNMENT**
60
+
61
+ The valency role you assign directly controls who sees the opportunity and when:
62
+ - "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.
63
+ - "Patient" (seeker/requester): Sees the opportunity early and decides whether to reach out.
64
+ - "Peer" (symmetric): Both parties see the opportunity immediately and either can initiate.
65
+
66
+ Choose the role carefully — it determines the entire flow of how the connection unfolds.
67
+
68
+ Rules:
69
+ 1. SYNTHESIS (CRITICAL): If multiple distinct match angles exist, SYNTHESIZE them into a SINGLE, robust opportunity.
70
+ 2. NEVER address either user directly — always use third-party references ("the source", "the candidate").
71
+ 3. COMPREHENSIVE: The single opportunity must capture ALL the value of the connection.
72
+ 4. Be specific about the "Why" for BOTH sides in the reasoning.
73
+ 5. DEDUPLICATION: Do NOT suggest opportunities that duplicate "Existing Opportunities".
74
+ 6. Do not suggest an opportunity if the source and candidate clearly already know each other (e.g. same company, co-founders, same team).
75
+ 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.
76
+ `;
77
+ // Entity-bundle system prompt (C2): entities + four match patterns + actors output
78
+ // NOTE: entityBundleSystemPrompt uses a >= 30 threshold (permissive) while
79
+ // systemPrompt uses >= 70 (strict). This is intentional: batch mode casts a wide
80
+ // net so the calling pipeline can apply its own filters; pairwise mode is strict
81
+ // because it returns a single yes/no decision per candidate pair.
82
+ const entityBundleSystemPrompt = `
83
+ You are an expert "Opportunity Matcher" and super-connector.
84
+ Your Goal: Analyze a set of entities (people), each with a profile and optional intents, and identify HIGH-VALUE opportunities among them.
85
+
86
+ Input:
87
+ - DISCOVERER: The user ID who triggered discovery (for context; they may or may not be in the entity list).
88
+ - ENTITIES: A set of entities. Each entity has:
89
+ - userId, indexId (the index through which they were found)
90
+ - profile: name, bio, location, interests, skills, context
91
+ - intents (optional): list of { intentId, payload, summary } — some entities are profile-only, some have intents
92
+ - ragScore, matchedVia (how they were found)
93
+ - EXISTING OPPORTUNITIES: Context of matches already made (for deduplication).
94
+
95
+ BEFORE SCORING — determine role satisfiability:
96
+
97
+ Definitions:
98
+ 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.
99
+ 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).
100
+
101
+ Step 1 — Identify the open argument in each discoverer intent: what type of person or entity would satisfy the intent if found?
102
+ Step 2 — For each candidate, ask: can this candidate directly fill that open argument position?
103
+ YES → substitutive role. Proceed to scoring.
104
+ NO → complementary role. Apply Rule 7 (score ≤ 30, return no opportunity).
105
+ Step 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.
106
+
107
+ Match patterns to consider:
108
+ 1. Profile-to-profile: Complementary backgrounds (skills, interests, location).
109
+ 2. Profile-to-intents+profile: Someone's skills/background match another's stated goals (intents).
110
+ 3. Intents+profile-to-profile: Someone's stated goals match another's skills/background.
111
+ 4. Intents+profile-to-intents+profile: Complementary or reciprocal goals between two or more people.
112
+
113
+ Output:
114
+ - A list of 0..N opportunities. Each opportunity has:
115
+ - reasoning: Third-party analytical explanation (for other LLM agents). Mention entities by role. Do NOT use "you". Never leak private intents.
116
+ - score: 0-100.
117
+ - 90-100: Must Meet — candidate's PRIMARY role directly matches what the discoverer seeks.
118
+ Example: discoverer seeks "AI/ML co-founder" → candidate IS an AI/ML engineer who wants to co-found.
119
+ - 70-89: Should Meet — meaningful overlap on role type AND complementary intent.
120
+ - 50-69: Worth Considering — tangential overlap only.
121
+ - <30 (return empty): Complementary-role mismatch (candidate cannot fill the discoverer's open argument position), same-side match, or already acquainted.
122
+ 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.
123
+ - IMPORTANT: Include ALL reasonable matches with scores >= 30. Let the system filter by threshold.
124
+ - actors: At least 2 actors per opportunity. Each actor has:
125
+ - userId
126
+ - role: "agent" (can do something for others), "patient" (needs something from others), "peer" (symmetric collaboration)
127
+ - intentId (optional): if the match is intent-driven, the specific intent ID for that user
128
+
129
+ VISIBILITY (role controls who sees the opportunity when):
130
+ - agent: Last to see — after the patient has committed to reaching out.
131
+ - patient: Sees early and decides whether to reach out.
132
+ - peer: Both see immediately; either can initiate.
133
+
134
+ Rules:
135
+ 1. 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.
136
+ 2. 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.
137
+ 3. DEDUPLICATION: Do not suggest opportunities that duplicate Existing Opportunities.
138
+ 4. Write reasoning from an objective observer's perspective; be specific about the "Why" for each side.
139
+ 5. 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.
140
+ 6. 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.
141
+ 7. 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.
142
+ COMPLEMENTARY-ROLE CAP: If the candidate occupies a complementary rather than substitutive role relative to the discoverer's intent, score ≤ 30. Return no opportunity.
143
+ 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.
144
+ 8. SAME-SIDE MATCHING: Before scoring, check whether the DISCOVERER and CANDIDATE are both SEEKING the same thing. Look at both parties' intents for directionality:
145
+ - SEEKING signals: "looking for", "seeking", "want to find", "need", "raising", "hiring"
146
+ - OFFERING signals: "can offer", "expert in", "investing in", "mentoring", "available for"
147
+ 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.
148
+ 9. LOCATION MATCHING: When the DISCOVERY REQUEST mentions a specific location (city, region, or country):
149
+ a. If a candidate's profile.location is KNOWN and clearly does NOT match the requested location (different city/region), score ≤ 40 for that candidate. Geographic mismatch is a strong negative signal when the user explicitly requested a location.
150
+ 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.
151
+ 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.
152
+ d. "Remote" or "Global" locations are compatible with any requested location.
153
+ `;
154
+ // ──────────────────────────────────────────────────────────────
155
+ // 2. RESPONSE SCHEMA (Zod)
156
+ // ──────────────────────────────────────────────────────────────
157
+ const OpportunitySchema = z.object({
158
+ 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.'),
159
+ score: z.number().min(0).max(100).describe('Relevance score 0-100'),
160
+ valencyRole: z.enum(['Agent', 'Patient', 'Peer']).describe("The semantic role of the Candidate relative to the Source"),
161
+ sourceId: z.string().describe('The user ID of the source'),
162
+ candidateId: z.string().describe('The user ID of the candidate'),
163
+ });
164
+ const responseFormat = z.object({
165
+ opportunities: z.array(OpportunitySchema).describe("List of opportunities identified"),
166
+ });
167
+ const ActorSchema = z.object({
168
+ userId: z.string(),
169
+ role: z.enum(['agent', 'patient', 'peer']),
170
+ intentId: z.string().nullable().describe('If the match is intent-driven, the specific intent ID; null otherwise'),
171
+ });
172
+ const OpportunityWithActorsSchema = z.object({
173
+ reasoning: z.string(),
174
+ score: z.number().min(0).max(100),
175
+ actors: z.array(ActorSchema).min(2).describe('All actors in this opportunity with their roles'),
176
+ });
177
+ const entityBundleResponseFormat = z.object({
178
+ opportunities: z.array(OpportunityWithActorsSchema).describe('List of opportunities (0..N)'),
179
+ });
180
+ export class OpportunityEvaluator {
181
+ constructor(options) {
182
+ this.model = model.withStructuredOutput(responseFormat, {
183
+ name: "opportunity_evaluator"
184
+ });
185
+ this.entityBundleModel = options?.entityBundleModel ?? model.withStructuredOutput(entityBundleResponseFormat, {
186
+ name: "opportunity_evaluator_entity_bundle"
187
+ });
188
+ }
189
+ /**
190
+ * Main Entry Point: Batch analysis of candidates.
191
+ *
192
+ * @param sourceProfileContext - The profile context string of the user we are finding opportunities FOR.
193
+ * @param candidates - List of potential matches to evaluate.
194
+ * @param options - Config (minScore, valid types, etc).
195
+ * @returns A sorted list of high-value `Opportunity` objects.
196
+ */
197
+ async invoke(sourceProfileContext, candidates, options) {
198
+ const minScore = options.minScore || 70;
199
+ logger.verbose(`[OpportunityEvaluator.invoke] Analyzing ${candidates.length} candidates...`);
200
+ if (candidates.length === 0) {
201
+ logger.verbose('[OpportunityEvaluator] No candidates provided.');
202
+ return [];
203
+ }
204
+ const opportunities = [];
205
+ // Analyze each candidate in parallel (bounded)
206
+ const promises = candidates.map(async (candidate) => {
207
+ // Pass existing opportunities context if provided
208
+ const existingContext = options.existingOpportunities || '';
209
+ return this.analyzeMatch(sourceProfileContext, candidate, candidate.userId, existingContext);
210
+ });
211
+ const results = await Promise.all(promises);
212
+ results.flat().forEach(op => {
213
+ if (op.score >= minScore) {
214
+ opportunities.push(op);
215
+ }
216
+ });
217
+ // Sort by score and take top 1
218
+ const out = opportunities.sort((a, b) => b.score - a.score).slice(0, 1);
219
+ logger.verbose('[OpportunityEvaluator.invoke] Done', { accepted: out.length });
220
+ return out;
221
+ }
222
+ /**
223
+ * Analyze a single match pair using the primary Agent model.
224
+ */
225
+ async analyzeMatch(sourceProfileContext, candidateProfile, candidateUserId, existingOpportunities) {
226
+ try {
227
+ // Construct the source context part of the prompt
228
+ const sourceContext = `SOURCE PROFILE:\n${sourceProfileContext}`;
229
+ const existingContextPart = existingOpportunities
230
+ ? `\nEXISTING OPPORTUNITIES (Deduplication Context):\n${existingOpportunities}\n`
231
+ : '';
232
+ // Create candidate context using template string
233
+ const candidateContext = `
234
+ ID: ${candidateUserId}
235
+ Name: ${candidateProfile.identity?.name || 'Unknown'}
236
+ Bio: ${candidateProfile.identity?.bio || ''}
237
+ Location: ${candidateProfile.identity?.location || ''}
238
+ Interests: ${candidateProfile.attributes?.interests?.join(', ') || ''}
239
+ Skills: ${candidateProfile.attributes?.skills?.join(', ') || ''}
240
+
241
+ Context: ${candidateProfile.narrative?.context || ''}
242
+ `;
243
+ const messages = [
244
+ new SystemMessage(systemPrompt),
245
+ new HumanMessage(`${sourceContext}\n${existingContextPart}\nCANDIDATE PROFILE:\n${candidateContext}`)
246
+ ];
247
+ const result = await this.model.invoke(messages);
248
+ const output = responseFormat.parse(result);
249
+ const mappedOpportunities = output.opportunities.map((op) => ({
250
+ ...op,
251
+ reasoning: stripUuids(op.reasoning),
252
+ candidateId: candidateUserId,
253
+ }));
254
+ return mappedOpportunities;
255
+ }
256
+ catch (e) {
257
+ const message = e instanceof Error ? e.message : String(e);
258
+ logger.warn(`[OpportunityEvaluator] Analysis failed for candidate ${candidateUserId}`, { message });
259
+ throw e;
260
+ }
261
+ }
262
+ /**
263
+ * Entity-bundle entry point (C3): single LLM call with all entities, returns 0..N opportunities with actors.
264
+ */
265
+ async invokeEntityBundle(input, options = {}) {
266
+ const minScore = options.minScore ?? 70;
267
+ const returnAll = options.returnAll ?? false;
268
+ const totalEntities = input.entities?.length ?? 0;
269
+ if (!input.entities?.length) {
270
+ logger.verbose('[OpportunityEvaluator.invokeEntityBundle] No entities.');
271
+ return [];
272
+ }
273
+ const existingPart = input.existingOpportunities
274
+ ? `\nEXISTING OPPORTUNITIES:\n${input.existingOpportunities}\n`
275
+ : '';
276
+ const introModePart = input.introductionMode
277
+ ? `\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.
278
+
279
+ CRITICAL REASONING INSTRUCTIONS FOR INTRODUCTIONS:
280
+ - Your reasoning MUST acknowledge that this is an introduction initiated by ${input.introducerName ?? 'the introducer'}, not a system-discovered match.
281
+ - 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..."
282
+ - 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.
283
+ - 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.` : ''}
284
+ - Actors must refer ONLY to the ENTITIES below (the people being introduced). Do not include the DISCOVERER as an actor.
285
+ - You must output exactly two actors per opportunity (the two people being introduced). The introducer is added separately; do not include them in actors.
286
+ - Be generous with scoring (70+ for any introduction with a plausible basis, since a human made the judgment).
287
+ `
288
+ : '';
289
+ const discoveryQueryPart = input.discoveryQuery?.trim()
290
+ ? `\nDISCOVERY REQUEST: The user asked: "${input.discoveryQuery.trim()}"
291
+
292
+ CRITICAL SCORING RULES FOR DISCOVERY REQUESTS:
293
+ 0. 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.
294
+ 1. MATCH THE REQUEST TYPE FIRST: If the user asks for "investors", prioritize candidates who are ACTUALLY investors (VCs, angels, fund partners). Engineers and collaborators should score LOWER unless they are also investors.
295
+ 2. ROLE KEYWORDS MATTER: Look for keywords in bios like "investor", "VC", "venture", "fund", "partner at [fund]", "angel", "mentor", etc. that match what the user asked for.
296
+ 3. SCORING HIERARCHY:
297
+ - 90-100: Candidate's PRIMARY role matches the request (e.g., "investor" request → actual investor/VC partner)
298
+ - 70-89: Candidate has SOME relevance to the request (e.g., "investor" request → someone who occasionally invests but is primarily a builder)
299
+ - 50-69: Weak match - candidate is tangentially related but doesn't fit the primary request
300
+ - <50: Does not match the request - exclude or heavily down-rank
301
+ 4. DO NOT score collaborators/builders highly when the user explicitly asks for investors, and vice versa.
302
+ 5. 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.
303
+ 6. LOCATION ENFORCEMENT: If the discovery request mentions a specific location (e.g., "in SF", "based in London", "Istanbul"), check each candidate's profile.location:
304
+ - KNOWN MISMATCH (e.g., request says "SF" but candidate is "New York"): Score ≤ 40. State the mismatch in reasoning.
305
+ - UNKNOWN/EMPTY location: Do not penalize. Note that location is unverified.
306
+ - MATCH or COMPATIBLE (e.g., "Bay Area" ≈ "SF", "Remote" ≈ any): Score normally.
307
+ `
308
+ : '';
309
+ const hasDiscoveryQuery = !!input.discoveryQuery?.trim();
310
+ const entitiesBlock = input.entities.map((e) => {
311
+ const isSource = e.userId === input.discovererId;
312
+ // When an explicit discovery query is active, label the source user's stored
313
+ // intents as background context so the LLM treats the query as primary.
314
+ const intentsLabel = isSource && hasDiscoveryQuery ? 'BACKGROUND INTENTS (use only if query is too vague)' : 'INTENTS';
315
+ const intentsPart = e.intents?.length
316
+ ? `\n ${intentsLabel}:\n${e.intents.map((i) => ` - ${i.intentId}: ${i.payload}`).join('\n')}`
317
+ : '';
318
+ // Mask the discoverer's name so the LLM cannot leak it into reasoning.
319
+ // The system prompt already says "use third-party references", but the LLM
320
+ // ignores this when the actual name is visible. Masking it forces role-based
321
+ // language ("the source user is looking…" instead of "Alice is looking…").
322
+ const displayName = e.userId === input.discovererId
323
+ ? '(source user)'
324
+ : (e.profile.name ?? '');
325
+ return `
326
+ USER: ${e.userId}
327
+ INDEX: ${e.indexId}
328
+ 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}
329
+ RAG SCORE: ${e.ragScore ?? '—'}
330
+ MATCHED VIA: ${e.matchedVia ?? '—'}`;
331
+ }).join('\n');
332
+ const humanContent = `DISCOVERER: ${input.discovererId}${introModePart}${discoveryQueryPart}\n\nENTITIES:\n${entitiesBlock}${existingPart}`;
333
+ const messages = [
334
+ new SystemMessage(entityBundleSystemPrompt),
335
+ new HumanMessage(humanContent),
336
+ ];
337
+ let parsedTotal = 0;
338
+ try {
339
+ const result = await this.entityBundleModel.invoke(messages);
340
+ const parsed = entityBundleResponseFormat.parse(result);
341
+ for (const op of parsed.opportunities) {
342
+ op.reasoning = stripUuids(op.reasoning);
343
+ }
344
+ parsedTotal = parsed.opportunities.length;
345
+ const introGuard = input.introductionMode
346
+ ? parsed.opportunities.filter((op) => op.actors.length === 2)
347
+ : parsed.opportunities;
348
+ const filtered = introGuard.filter((op) => op.score >= minScore);
349
+ logger.verbose('[OpportunityEvaluator.invokeEntityBundle] Done', {
350
+ total: parsed.opportunities.length,
351
+ afterIntroGuard: introGuard.length,
352
+ accepted: filtered.length,
353
+ returnAll,
354
+ });
355
+ return returnAll ? introGuard : filtered;
356
+ }
357
+ catch (llmError) {
358
+ logger.error('[OpportunityEvaluator.invokeEntityBundle] Failed', {
359
+ discovererId: input.discovererId,
360
+ totalEntities,
361
+ parsedTotal,
362
+ minScore,
363
+ llmError,
364
+ });
365
+ throw llmError;
366
+ }
367
+ }
368
+ /**
369
+ * Factory method to expose the agent as a LangChain tool.
370
+ * Simplified to only accept direct evaluation arguments.
371
+ * PURE: Does not perform any database lookups.
372
+ */
373
+ static asTool() {
374
+ return tool(async (args) => {
375
+ const agent = new OpportunityEvaluator();
376
+ const sourceProfileContext = args.sourceProfileContext;
377
+ let candidates = [];
378
+ if (args.candidatesJson) {
379
+ try {
380
+ candidates = JSON.parse(args.candidatesJson);
381
+ }
382
+ catch (e) {
383
+ logger.error("Failed to parse candidates JSON");
384
+ }
385
+ }
386
+ const options = {
387
+ minScore: args.minScore,
388
+ };
389
+ return await agent.invoke(sourceProfileContext, candidates, options);
390
+ }, {
391
+ name: 'opportunity_evaluator',
392
+ description: 'Evaluates candidates against a source profile. SOURCE PROFILE CONTEXT MUST BE PROVIDED.',
393
+ schema: z.object({
394
+ sourceProfileContext: z.string().describe('The resolved source user profile context'),
395
+ candidatesJson: z.string().optional().describe('JSON string list of Candidates'),
396
+ minScore: z.number().optional().describe('Minimum score to accept a match')
397
+ })
398
+ });
399
+ }
400
+ }
401
+ __decorate([
402
+ Timed(),
403
+ __metadata("design:type", Function),
404
+ __metadata("design:paramtypes", [String, Array, Object]),
405
+ __metadata("design:returntype", Promise)
406
+ ], OpportunityEvaluator.prototype, "invoke", null);
407
+ __decorate([
408
+ Timed(),
409
+ __metadata("design:type", Function),
410
+ __metadata("design:paramtypes", [Object, Object]),
411
+ __metadata("design:returntype", Promise)
412
+ ], OpportunityEvaluator.prototype, "invokeEntityBundle", null);
413
+ //# sourceMappingURL=opportunity.evaluator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opportunity.evaluator.js","sourceRoot":"","sources":["../../src/agents/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,+BAA+B,CAAC;AAG/D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,GAAG,cAAc,CAAC,sBAAsB,CAAC,CAAC;AAEtD;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAErC,MAAM,KAAK,GAAG,WAAW,CAAC,sBAAsB,CAAC,CAAC;AAElD,iEAAiE;AACjE,mBAAmB;AACnB,iEAAiE;AAGjE,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDpB,CAAC;AAEF,mFAAmF;AACnF,2EAA2E;AAC3E,iFAAiF;AACjF,iFAAiF;AACjF,kEAAkE;AAClE,MAAM,wBAAwB,GAAG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AAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;gBAChF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;aAC5E,CAAC;SACH,CACF,CAAC;IACJ,CAAC;CACF;AAhPc;IADZ,KAAK,EAAE;;;;kDAmCP;AAyDY;IADZ,KAAK,EAAE;;;;8DA0GP"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Opportunity Presenter Agent
3
+ *
4
+ * Generates personalized, second-person explanations of why an opportunity
5
+ * matters to the viewing user. Uses full opportunity data (interpretation,
6
+ * actors, profiles, intents, index) to produce headline, personalizedSummary,
7
+ * and suggestedAction for chat tools and user-facing surfaces.
8
+ */
9
+ import { z } from "zod";
10
+ import type { Opportunity } from "../interfaces/database.interface.js";
11
+ import type { ChatGraphCompositeDatabase } from "../interfaces/database.interface.js";
12
+ /**
13
+ * Minimal database interface required by gatherPresenterContext.
14
+ * Any database adapter that implements these three methods can be passed.
15
+ */
16
+ export type PresenterDatabase = Pick<ChatGraphCompositeDatabase, "getProfile" | "getActiveIntents" | "getIndex">;
17
+ declare const PresentationSchema: z.ZodObject<{
18
+ headline: z.ZodString;
19
+ personalizedSummary: z.ZodString;
20
+ suggestedAction: z.ZodString;
21
+ }, "strip", z.ZodTypeAny, {
22
+ headline: string;
23
+ personalizedSummary: string;
24
+ suggestedAction: string;
25
+ }, {
26
+ headline: string;
27
+ personalizedSummary: string;
28
+ suggestedAction: string;
29
+ }>;
30
+ export type OpportunityPresentationResult = z.infer<typeof PresentationSchema>;
31
+ /** Input for home-card presenter call; extends PresenterInput with optional mutual intent count. */
32
+ export interface HomeCardPresenterInput extends PresenterInput {
33
+ /** Number of overlapping intents (for generating mutualIntentsLabel). */
34
+ mutualIntentCount?: number;
35
+ }
36
+ /** LLM-generated fields for home-card presentation (buttons are hardcoded by callers, not LLM-generated). */
37
+ export declare const HomeCardLLMSchema: z.ZodObject<{
38
+ headline: z.ZodString;
39
+ personalizedSummary: z.ZodString;
40
+ suggestedAction: z.ZodString;
41
+ narratorRemark: z.ZodString;
42
+ mutualIntentsLabel: z.ZodString;
43
+ }, "strip", z.ZodTypeAny, {
44
+ headline: string;
45
+ personalizedSummary: string;
46
+ suggestedAction: string;
47
+ narratorRemark: string;
48
+ mutualIntentsLabel: string;
49
+ }, {
50
+ headline: string;
51
+ personalizedSummary: string;
52
+ suggestedAction: string;
53
+ narratorRemark: string;
54
+ mutualIntentsLabel: string;
55
+ }>;
56
+ /** LLM-generated result from presentHomeCard (callers append button labels from opportunity.constants). */
57
+ export type HomeCardLLMResult = z.infer<typeof HomeCardLLMSchema>;
58
+ /** Full home-card display contract including hardcoded button labels (assembled by callers). */
59
+ export type HomeCardPresentationResult = HomeCardLLMResult & {
60
+ primaryActionLabel: string;
61
+ secondaryActionLabel: string;
62
+ };
63
+ /** Input for a single presenter call (all context pre-assembled). */
64
+ export interface PresenterInput {
65
+ viewerContext: string;
66
+ otherPartyContext: string;
67
+ matchReasoning: string;
68
+ category: string;
69
+ confidence: number;
70
+ signalsSummary: string;
71
+ indexName: string;
72
+ viewerRole: string;
73
+ opportunityStatus?: string;
74
+ /** True when this opportunity was created via an explicit introduction (not automatic discovery). */
75
+ isIntroduction?: boolean;
76
+ /** Name of the person who made the introduction, if applicable. */
77
+ introducerName?: string;
78
+ }
79
+ export declare class OpportunityPresenter {
80
+ private model;
81
+ private homeCardModel;
82
+ constructor();
83
+ private invokeWithTimeout;
84
+ /**
85
+ * Generate personalized presentation for a single opportunity.
86
+ */
87
+ present(input: PresenterInput): Promise<OpportunityPresentationResult>;
88
+ /**
89
+ * Generate LLM-powered home-card content (headline, body, narrator remark, mutual-intent label).
90
+ * Callers append button labels from opportunity.constants.
91
+ */
92
+ presentHomeCard(input: HomeCardPresenterInput): Promise<HomeCardLLMResult>;
93
+ /**
94
+ * Process multiple opportunities in parallel with bounded concurrency.
95
+ */
96
+ presentBatch(inputs: PresenterInput[], options?: {
97
+ concurrency?: number;
98
+ }): Promise<OpportunityPresentationResult[]>;
99
+ /**
100
+ * Process multiple opportunities as home cards in parallel with bounded concurrency.
101
+ * Returns full home-card display contracts (headline, body, narrator remark, action labels, mutual-intent label).
102
+ */
103
+ presentHomeCardBatch(inputs: HomeCardPresenterInput[], options?: {
104
+ concurrency?: number;
105
+ }): Promise<HomeCardLLMResult[]>;
106
+ }
107
+ /**
108
+ * Gather all context needed for the presenter from the database.
109
+ * Fetches viewer profile, viewer intents, other party profile(s), and index in parallel.
110
+ *
111
+ * @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).
112
+ */
113
+ export declare function gatherPresenterContext(database: PresenterDatabase, opportunity: Opportunity, viewerId: string, displayCounterpartUserId?: string): Promise<PresenterInput>;
114
+ export {};
115
+ //# sourceMappingURL=opportunity.presenter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opportunity.presenter.d.ts","sourceRoot":"","sources":["../../src/agents/opportunity.presenter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAGtF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,0BAA0B,EAC1B,YAAY,GAAG,kBAAkB,GAAG,UAAU,CAC/C,CAAC;AAWF,QAAA,MAAM,kBAAkB;;;;;;;;;;;;EAYtB,CAAC;AAMH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE/E,oGAAoG;AACpG,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,6GA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