@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,366 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════════
2
+ // EXTRACTION
3
+ // ═══════════════════════════════════════════════════════════════════════════════
4
+ /**
5
+ * Extracts tool calls from all AI messages since the last HumanMessage.
6
+ *
7
+ * Scans backwards to find the last HumanMessage, then collects all tool calls
8
+ * from AIMessages after that point. This ensures multi-iteration tool history
9
+ * is available for module resolution within a single user turn.
10
+ *
11
+ * @param messages - The current conversation message array
12
+ * @returns Flattened array of tool name + args from the current agent turn
13
+ */
14
+ export function extractRecentToolCalls(messages) {
15
+ // Find the index of the last HumanMessage
16
+ let lastHumanIdx = -1;
17
+ for (let i = messages.length - 1; i >= 0; i--) {
18
+ if (messages[i]._getType() === "human") {
19
+ lastHumanIdx = i;
20
+ break;
21
+ }
22
+ }
23
+ // Collect tool calls from all AIMessages after the last HumanMessage
24
+ const toolCalls = [];
25
+ const startIdx = lastHumanIdx + 1;
26
+ for (let i = startIdx; i < messages.length; i++) {
27
+ const msg = messages[i];
28
+ if (msg._getType() === "ai") {
29
+ const aiMsg = msg;
30
+ const calls = aiMsg.tool_calls ?? [];
31
+ for (const tc of calls) {
32
+ toolCalls.push({
33
+ name: tc.name,
34
+ args: (tc.args ?? {}),
35
+ });
36
+ }
37
+ }
38
+ }
39
+ return toolCalls;
40
+ }
41
+ // ═══════════════════════════════════════════════════════════════════════════════
42
+ // HELPERS
43
+ // ═══════════════════════════════════════════════════════════════════════════════
44
+ /**
45
+ * Checks whether recent tool calls include create_opportunities with
46
+ * introduction-specific arguments (partyUserIds or introTargetUserId).
47
+ */
48
+ function hasIntroductionArgs(recentTools) {
49
+ return recentTools.some((t) => t.name === "create_opportunities" &&
50
+ (t.args.partyUserIds || t.args.introTargetUserId));
51
+ }
52
+ // ═══════════════════════════════════════════════════════════════════════════════
53
+ // MODULE DEFINITIONS
54
+ // ═══════════════════════════════════════════════════════════════════════════════
55
+ const discoveryModule = {
56
+ id: "discovery",
57
+ triggers: ["create_opportunities", "update_opportunity"],
58
+ triggerFilter: (iterCtx) => !hasIntroductionArgs(iterCtx.recentTools),
59
+ content: () => `
60
+ ### 1. User wants to find connections or discover (default for connection-seeking)
61
+
62
+ For open-ended connection-seeking ("find me a mentor", "who needs a React dev", "I want to meet people in AI", "looking for investors", "find me X"), run **discovery first**.
63
+
64
+ **CRITICAL: DO NOT create an intent first. Discovery comes FIRST.**
65
+
66
+ **Network scoping**: When the user says "in my network", "from my contacts", "people I know", "among my connections", or similar network-scoping language, pass the user's **personal index ID** as \`indexId\`. The personal index (\`isPersonal: true\` in preloaded memberships) contains the user's contacts — scoping discovery to it restricts results to people the user already knows. If no network-scoping language is used, do not pass a personal index ID — let discovery run across all indexes as usual.
67
+
68
+ - Call \`create_opportunities(searchQuery=user's request)\` IMMEDIATELY (with indexId when scoped).
69
+ - Do NOT call \`create_intent\` unless the user **explicitly** asks to "create", "save", "add", or "remember" an intent/signal.
70
+ - Phrases like "looking for X", "find me X", "I want to meet X", "I need X" are discovery requests — NOT intent creation requests.
71
+ - If the tool returns \`createIntentSuggested\` and \`suggestedIntentDescription\`, the system will create an intent and retry discovery automatically; use the final result (candidates or "no matches") for your reply.
72
+ - If the tool returns \`suggestIntentCreationForVisibility: true\` and \`suggestedIntentDescription\`, after presenting the opportunity cards ask the user whether they'd also like to create a signal so others can find them (e.g. *"Would you also like to create a signal for this so others can find you?"*). If the user agrees, call \`create_intent(description=suggestedIntentDescription)\` and include the returned \`\`\`intent_proposal block verbatim — this is the same proposal flow as explicit intent creation; the user approves or skips via the card. Ask only once per conversation; do not repeat the question on follow-up turns.
73
+ - When the tool indicates all results are exhausted (no remaining candidates), do NOT offer to "show more". Instead suggest the user create a signal so others can find them. This uses the same \`create_intent\` flow as above.
74
+ - If the user **explicitly** says they want to create/save an intent (e.g. "add a signal", "create an intent", "save that I'm looking for X", "remember this"), use pattern 2 instead.
75
+
76
+ ### 1a. User wants to connect with a specific mentioned person
77
+
78
+ When the user mentions a specific person via @mention or name AND expresses interest in connecting, collaborating, or exploring overlap (e.g. "what can I do with @X", "connect me with @X", user says "yes" after you present shared context with someone):
79
+
80
+ **This is a direct connection — NOT an introduction (introductions connect two OTHER people).**
81
+
82
+ \`\`\`
83
+ 1. If not already done: read_user_profiles(userId=X) + read_index_memberships(userId=X)
84
+ 2. Find shared indexes with the user (intersect with preloaded memberships)
85
+ 3. If no shared indexes: tell the user you can't find a connection path
86
+ 4. create_opportunities(targetUserId=X, searchQuery="<synthesized reason for connecting based on shared context>")
87
+ 5. Present the opportunity card
88
+ \`\`\`
89
+
90
+ **Do NOT call read_intents before create_opportunities here.** The opportunity tool fetches intents internally for both discovery and direct connection modes. Only introduction mode (partyUserIds + entities) requires pre-gathered intents.
91
+
92
+ The searchQuery should be a brief description of why they'd connect (e.g. "shared interest in design and technology, both in Kernel community"). This gives the evaluator context for scoring.
93
+
94
+ ### 7. Opportunities in chat
95
+
96
+ Chat only proposes opportunities from **create_opportunities** in this conversation (discovery or introduction). Do not offer to "list" or "show" all opportunities — the user's other opportunities (sent, received, accepted) are already shown on the home view. When you run create_opportunities, include the returned \`\`\`opportunity code blocks in your reply so they render as cards.
97
+
98
+ Draft or latent opportunities can be sent (update_opportunity with status='pending'). Status translation: draft/latent → "draft", pending → "sent", accepted → "connected"
99
+
100
+ **CRITICAL: Only describe what the tool response confirms happened.** "pending" sends a notification — not a message or invite. "accepted" adds a contact — for ghost users, the invite email is sent only when the user opens a chat and messages them. Never claim you sent invites, connection requests, or messages on behalf of the user.
101
+
102
+ ### Discovery-first; intent as follow-up
103
+ - For connection-seeking (find connections, discover, who's looking for X), use \`create_opportunities(searchQuery=...)\` first. Do not lead with \`create_intent\` unless the user explicitly asks to create or save an intent.
104
+ - When the tool returns \`createIntentSuggested\`, the system may create an intent and retry; respond from the final discovery result.
105
+ - Visibility-signal follow-up: apply the Pattern 1 rule above (\`suggestIntentCreationForVisibility\` → ask once; on yes, call \`create_intent(description=suggestedIntentDescription)\` and include the returned \`\`\`intent_proposal block).
106
+ - When the tool response says "These are all the connections I found", suggest the user create a signal so others can discover them. Use the existing \`suggestIntentCreationForVisibility\` flow: call \`create_intent(description=suggestedIntentDescription)\` if the user agrees. Do not ask "Would you like to see more?" when there are no more candidates.
107
+ - **Introducer exception**: Never suggest signal/intent creation when \`introTargetUserId\` was used. The search describes the other person's needs, not the signed-in user's — creating a signal from it would be meaningless.
108
+ - Only call \`create_opportunities\` for: (a) discovery ("find me connections"), (b) introductions between two other people, or (c) direct connection with a specific mentioned person (Pattern 1a).
109
+ `,
110
+ };
111
+ const introductionModule = {
112
+ id: "introduction",
113
+ triggers: ["create_opportunities"],
114
+ excludes: ["discovery"],
115
+ triggerFilter: (iterCtx) => hasIntroductionArgs(iterCtx.recentTools),
116
+ content: () => `
117
+ ### 6. Introduce two people
118
+
119
+ **An introduction is always between exactly two people.** Do not call create_opportunities for an introduction unless you have exactly two parties (two distinct people to introduce to each other). The entities array must have exactly two entities. The introducer (current user) must not be included in the entities array; entities must refer to two distinct other users.
120
+
121
+ **You MUST gather all context before calling create_opportunities. The tool does NOT fetch data internally.**
122
+
123
+ \`\`\`
124
+ 1. read_index_memberships(userId=A) + read_index_memberships(userId=B) → find shared indexes
125
+ 2. If no shared indexes: tell user they're not in any shared community
126
+ 3. read_user_profiles(userId=A) + read_user_profiles(userId=B)
127
+ 4. For each shared index: read_intents(indexId=X, userId=A) + read_intents(indexId=X, userId=B)
128
+ 5. Summarize to user: "Here's what I found about A and B..."
129
+ 6. create_opportunities(partyUserIds=[A,B], entities=[{userId:A, profile:{...}, intents:[...], indexId:shared}, {userId:B, ...}], hint="user's reason")
130
+ 7. Present the draft introduction
131
+ \`\`\`
132
+
133
+ The entities array must include each party's userId, profile data, intents from shared indexes, and the shared indexId. The hint is the user's stated reason (e.g. "both AI devs"). If the user asks to introduce only one person or to "introduce" themselves to someone, explain that introductions connect two other people and suggest they name two people to connect.
134
+
135
+ ### 6a. Discover who to introduce to someone
136
+
137
+ **When the user asks "who should I introduce to @Person" or "find connections for @Person"** — they want YOU to discover good connections for that person, presented as introduction cards.
138
+
139
+ \`\`\`
140
+ 1. Identify the person's userId from the @mention (call it mentionedUserId)
141
+ 2. create_opportunities(introTargetUserId=mentionedUserId, searchQuery="<optional refinement>")
142
+ 3. Present the returned cards (they will be formatted as introduction cards automatically)
143
+ \`\`\`
144
+
145
+ This is different from Pattern 6 (where user names BOTH parties). Here the user names ONE person and asks you to find connections for them. Do NOT use Pattern 6 for this — Pattern 6 requires both parties to be known upfront. Do NOT ask the user for a second person. Do NOT use targetUserId or partyUserIds. The system will find connections automatically.
146
+
147
+ **CRITICAL — no signal creation in introducer flows:** When \`introTargetUserId\` is used (Patterns 6 and 6a), the user is searching for connections on behalf of someone else — the search reflects the other person's needs, not the user's own. Do NOT suggest creating a signal or intent in this context. The search query describes what the *other person* needs (e.g. "biotech investors for Levi"), so creating a signal from it for the signed-in user would be wrong. Never offer signal/intent creation CTAs after introducer discovery — not for the other person (users can only create signals for themselves) and not for the signed-in user (the query doesn't represent their intent).
148
+ `,
149
+ };
150
+ const intentCreationModule = {
151
+ id: "intent-creation",
152
+ triggers: ["create_intent"],
153
+ content: () => `
154
+ ### 2. User explicitly wants to create or save an intent
155
+
156
+ **YOU decide if it's specific enough. The tool proposes — the user confirms.**
157
+
158
+ \`\`\`
159
+ IF description is vague ("find a job", "meet people", "learn something"):
160
+ 1. read_user_profiles() → get their background
161
+ 2. read_intents() → see existing intents for context
162
+ 3. THINK: given their profile and existing intents, suggest a refined version
163
+ 4. Reply: "Based on your background in X, did you mean something like 'Y'?"
164
+ 5. Wait for confirmation
165
+ 6. On "yes" → create_intent(description=exact_refined_text)
166
+
167
+ IF description is specific enough ("contribute to an open-source LLM project"):
168
+ → create_intent(description=...) directly
169
+ \`\`\`
170
+
171
+ **CRITICAL: Never write a \`\`\`intent_proposal block yourself.** To propose an intent you MUST call create_intent(description=...). The tool returns a \`\`\`intent_proposal code block (with proposalId and description). You MUST include that exact block verbatim in your response — it renders as an interactive card. Do not summarize or invent the block; only the tool provides a valid one. Add a brief explanation that creating this intent will let the system look for relevant people in the background.
172
+
173
+ Specificity test: Does it contain a concrete domain, action, or scope? If just a single generic verb+noun ("find a job"), it's vague. If it has qualifying detail ("senior UX design role at a tech company in Berlin"), it's specific.
174
+ `,
175
+ };
176
+ const intentManagementModule = {
177
+ id: "intent-management",
178
+ triggers: ["update_intent", "delete_intent"],
179
+ content: () => `
180
+ ### 4. Update or delete an intent
181
+
182
+ **YOU look up the ID first.**
183
+
184
+ \`\`\`
185
+ 1. read_intents() → get current intents with IDs
186
+ 2. Match user's request to the right intent
187
+ 3. update_intent(intentId=exact_id, newDescription=...) or delete_intent(intentId=exact_id)
188
+ \`\`\`
189
+ `,
190
+ };
191
+ const personLookupModule = {
192
+ id: "person-lookup",
193
+ triggers: ["read_user_profiles"],
194
+ content: () => `
195
+ ### 0. User asks about a specific person by name
196
+
197
+ When the user mentions a specific person by name ("find [name]", "look up [name]", "who is [name]?", "tell me about [name]"), look them up by name first — do NOT use discovery.
198
+
199
+ - Call \`read_user_profiles(query="the name")\` — this finds members by name across the user's indexes
200
+ - If one match: the result already includes their full profile; present it naturally
201
+ - If multiple matches: present the list and ask the user to clarify which person
202
+ - If no matches: tell the user you couldn't find anyone by that name in their network
203
+ - If the user then asks for semantic discovery (e.g. "find people like them"), use Pattern 1.
204
+ - If the user wants to connect with this specific person (e.g. "yes, connect us", "what can I do with them", "I'd like to reach out"), use Pattern 1a.
205
+ `,
206
+ };
207
+ const urlScrapingModule = {
208
+ id: "url-scraping",
209
+ triggers: ["scrape_url"],
210
+ regex: /(https?:\/\/)/i,
211
+ content: () => `
212
+ ### 3. User includes a URL
213
+
214
+ **YOU handle scraping before intent creation.**
215
+
216
+ \`\`\`
217
+ 1. scrape_url(url, objective="Extract key details for an intent")
218
+ 2. Synthesize a conceptual description from scraped content
219
+ 3. create_intent(description=synthesized_summary)
220
+ \`\`\`
221
+
222
+ Exception: for profile creation, pass URLs directly to create_user_profile (it handles scraping internally).
223
+
224
+ If the user pastes or types a profile URL (e.g. linkedin.com/..., github.com/...) to create or update their profile, you MUST pass that exact URL in the corresponding parameter (e.g. linkedinUrl, githubUrl, twitterUrl) to create_user_profile, or use scrape_url with that URL then update_user_profile; do not use the user's stored social links for that request.
225
+ `,
226
+ };
227
+ const communityModule = {
228
+ id: "community",
229
+ triggers: ["read_indexes", "create_index", "create_index_membership", "update_index", "delete_index", "delete_index_membership"],
230
+ content: () => `
231
+ ### 8. Explore what a community is about
232
+
233
+ \`\`\`
234
+ 0. If user asks about communities they belong to, first use preloaded memberships in this prompt.
235
+ 1. read_indexes() → get index details (title, prompt)
236
+ 2. read_intents(indexId=X) → what members are looking for
237
+ 3. read_index_memberships(indexId=X) → who's in it
238
+ 4. Synthesize: community purpose, active needs, member composition
239
+ \`\`\`
240
+
241
+ ### When to mention community/index
242
+ Index and community membership is background: handle it without talking about indexes unless the user asks or it's sign-up, leave, or owner settings. Do not proactively mention "your indexes", "your communities", "which index", "in your current communities", or similar. Only mention indexes (or communities, lists) when: (i) post-onboarding sign-up to a community, (ii) user explicitly asked about their indexes/communities, (iii) user wants to leave one, (iv) owner is changing index/community settings. Otherwise use neutral language ("where you're connected", "people you're connected with") and do not narrate "your indexes", "your current communities", "in this index", etc.
243
+ `,
244
+ };
245
+ const contactsModule = {
246
+ id: "contacts",
247
+ triggers: ["import_gmail_contacts", "add_contact", "list_contacts", "remove_contact"],
248
+ content: () => `
249
+ ### 9. Import contacts from Gmail
250
+
251
+ **Single-step workflow:**
252
+
253
+ \`\`\`
254
+ import_gmail_contacts()
255
+ → If not connected: returns { requiresAuth: true, authUrl: "..." } — share the URL with the user
256
+ → If connected: imports contacts directly and returns stats { imported, skipped, newContacts, existingContacts }
257
+ \`\`\`
258
+
259
+ Ghost users are contacts without accounts — they're enriched with public data (LinkedIn, GitHub, X) and can appear in opportunity discovery once enriched.
260
+
261
+ ### 10. Add or manage contacts manually
262
+
263
+ \`\`\`
264
+ # Add a single contact
265
+ add_contact(email="alice@example.com", name="Alice Smith")
266
+
267
+ # List user's network
268
+ list_contacts() → returns contacts with names, emails, and whether they're ghost users
269
+
270
+ # Remove a contact
271
+ remove_contact(contactId=X)
272
+ \`\`\`
273
+ `,
274
+ };
275
+ const sharedContextModule = {
276
+ id: "shared-context",
277
+ triggers: ["read_index_memberships"],
278
+ content: () => `
279
+ ### 5. Find shared context between two users
280
+
281
+ \`\`\`
282
+ 1. read_index_memberships(userId=me) → my indexes
283
+ 2. read_index_memberships(userId=other) → their indexes
284
+ 3. Intersect indexIds
285
+ 4. For each shared index: read_intents(indexId=shared)
286
+ 5. read_user_profiles(userId=other)
287
+ 6. Synthesize: what overlaps, where they could collaborate
288
+ \`\`\`
289
+ `,
290
+ };
291
+ const mentionsModule = {
292
+ id: "mentions",
293
+ triggers: [],
294
+ regex: /@\[.*?\]\(.*?\)/,
295
+ content: () => `- Messages may contain \`@[Display Name](userId)\` markup. The value in parentheses is the userId.
296
+ `,
297
+ };
298
+ // ═══════════════════════════════════════════════════════════════════════════════
299
+ // MODULE REGISTRY
300
+ // ═══════════════════════════════════════════════════════════════════════════════
301
+ /** All registered prompt modules. */
302
+ export const PROMPT_MODULES = [
303
+ discoveryModule,
304
+ introductionModule,
305
+ intentCreationModule,
306
+ intentManagementModule,
307
+ personLookupModule,
308
+ urlScrapingModule,
309
+ communityModule,
310
+ contactsModule,
311
+ sharedContextModule,
312
+ mentionsModule,
313
+ ];
314
+ // ═══════════════════════════════════════════════════════════════════════════════
315
+ // RESOLUTION
316
+ // ═══════════════════════════════════════════════════════════════════════════════
317
+ /**
318
+ * Resolves which prompt modules should be injected for the current iteration.
319
+ *
320
+ * Phase 1: Skip all modules when onboarding is active (early exit).
321
+ * Phase 2: Collect candidate modules by checking triggers and regex.
322
+ * Phase 3: Apply exclusions (unidirectional — the excluding module stays).
323
+ *
324
+ * @param iterCtx - Current iteration context (tool history, user message, resolved context)
325
+ * @returns Concatenated prompt text from all matched modules
326
+ */
327
+ export function resolveModules(iterCtx) {
328
+ // Phase 1 (early exit): Skip all modules during onboarding
329
+ if (iterCtx.ctx.isOnboarding) {
330
+ return "";
331
+ }
332
+ const toolNames = new Set(iterCtx.recentTools.map((t) => t.name));
333
+ // Phase 2: Collect candidates
334
+ const candidates = new Map();
335
+ for (const mod of PROMPT_MODULES) {
336
+ let matched = false;
337
+ // Check tool triggers (with optional filter for arg-based disambiguation)
338
+ if (mod.triggers.length > 0 && mod.triggers.some((t) => toolNames.has(t))) {
339
+ matched = mod.triggerFilter ? mod.triggerFilter(iterCtx) : true;
340
+ }
341
+ // Check regex trigger
342
+ if (!matched && mod.regex && iterCtx.currentMessage && mod.regex.test(iterCtx.currentMessage)) {
343
+ matched = true;
344
+ }
345
+ if (matched) {
346
+ candidates.set(mod.id, mod);
347
+ }
348
+ }
349
+ // Phase 3: Apply exclusions (skip self-exclusion)
350
+ for (const mod of candidates.values()) {
351
+ if (mod.excludes) {
352
+ for (const excludedId of mod.excludes) {
353
+ if (excludedId !== mod.id) {
354
+ candidates.delete(excludedId);
355
+ }
356
+ }
357
+ }
358
+ }
359
+ // Build output
360
+ const sections = [];
361
+ for (const mod of candidates.values()) {
362
+ sections.push(mod.content(iterCtx.ctx));
363
+ }
364
+ return sections.join("\n");
365
+ }
366
+ //# sourceMappingURL=chat.prompt.modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.prompt.modules.js","sourceRoot":"","sources":["../../src/agents/chat.prompt.modules.ts"],"names":[],"mappings":"AAsCA,kFAAkF;AAClF,aAAa;AACb,kFAAkF;AAElF;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAuB;IAEvB,0CAA0C;IAC1C,IAAI,YAAY,GAAG,CAAC,CAAC,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;YACvC,YAAY,GAAG,CAAC,CAAC;YACjB,MAAM;QACR,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,MAAM,SAAS,GAA2D,EAAE,CAAC;IAC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AAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,20 @@
1
+ export interface TitleGeneratorInput {
2
+ messages: Array<{
3
+ role: string;
4
+ content: string;
5
+ }>;
6
+ }
7
+ /**
8
+ * Generates a short, descriptive title for a chat session using the first exchange.
9
+ * Only meaningful when there is at least one user message and one assistant message.
10
+ */
11
+ export declare class ChatTitleGenerator {
12
+ private model;
13
+ constructor();
14
+ /**
15
+ * Suggests a title from the conversation excerpt.
16
+ * Call only when there is at least one user and one assistant message.
17
+ */
18
+ invoke(input: TitleGeneratorInput): Promise<string>;
19
+ }
20
+ //# sourceMappingURL=chat.title.generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.title.generator.d.ts","sourceRoot":"","sources":["../../src/agents/chat.title.generator.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,KAAK,CAAa;;IAM1B;;;OAGG;IAEG,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;CA0B1D"}
@@ -0,0 +1,66 @@
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 { log } from "../support/log.js";
12
+ import { Timed } from "../support/performance.js";
13
+ import { createModel } from "./model.config.js";
14
+ const logger = log.lib.from("ChatTitleGenerator");
15
+ const SYSTEM_PROMPT = `You suggest a very short title for a chat conversation.
16
+
17
+ Rules:
18
+ - Reply with ONLY the title, no quotes or punctuation.
19
+ - Maximum 6 words.
20
+ - If the conversation is just greetings (hi, hello, hey, thanks) or has no clear topic yet, reply with exactly: New chat
21
+ - Otherwise summarize the main topic or intent in a few words.`;
22
+ /**
23
+ * Generates a short, descriptive title for a chat session using the first exchange.
24
+ * Only meaningful when there is at least one user message and one assistant message.
25
+ */
26
+ export class ChatTitleGenerator {
27
+ constructor() {
28
+ this.model = createModel("chatTitleGenerator");
29
+ }
30
+ /**
31
+ * Suggests a title from the conversation excerpt.
32
+ * Call only when there is at least one user and one assistant message.
33
+ */
34
+ async invoke(input) {
35
+ const { messages } = input;
36
+ if (messages.length === 0)
37
+ return "New chat";
38
+ const excerpt = messages
39
+ .slice(0, 6)
40
+ .map((m) => `${m.role === "user" ? "User" : "Assistant"}: ${m.content.slice(0, 200)}`)
41
+ .join("\n");
42
+ try {
43
+ const response = await this.model.invoke([
44
+ new SystemMessage(SYSTEM_PROMPT),
45
+ new HumanMessage(`Conversation:\n${excerpt}\n\nSuggested title:`),
46
+ ]);
47
+ const text = typeof response.content === "string" ? response.content : String(response.content ?? "").trim();
48
+ const title = text.slice(0, 80).trim() || "New chat";
49
+ logger.verbose("[ChatTitleGenerator.invoke] Title generated", { titleLength: title.length });
50
+ return title;
51
+ }
52
+ catch (error) {
53
+ logger.warn("[ChatTitleGenerator.invoke] Failed to generate title", {
54
+ error: error instanceof Error ? error.message : String(error),
55
+ });
56
+ return "New chat";
57
+ }
58
+ }
59
+ }
60
+ __decorate([
61
+ Timed(),
62
+ __metadata("design:type", Function),
63
+ __metadata("design:paramtypes", [Object]),
64
+ __metadata("design:returntype", Promise)
65
+ ], ChatTitleGenerator.prototype, "invoke", null);
66
+ //# sourceMappingURL=chat.title.generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.title.generator.js","sourceRoot":"","sources":["../../src/agents/chat.title.generator.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAElD,MAAM,aAAa,GAAG;;;;;;+DAMyC,CAAC;AAMhE;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAG7B;QACE,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IAEG,AAAN,KAAK,CAAC,MAAM,CAAC,KAA0B;QACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;QAC3B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,UAAU,CAAC;QAE7C,MAAM,OAAO,GAAG,QAAQ;aACrB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;aACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;aACrF,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;gBACvC,IAAI,aAAa,CAAC,aAAa,CAAC;gBAChC,IAAI,YAAY,CAAC,kBAAkB,OAAO,sBAAsB,CAAC;aAClE,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YAC7G,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,UAAU,CAAC;YACrD,MAAM,CAAC,OAAO,CAAC,6CAA6C,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7F,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,sDAAsD,EAAE;gBAClE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;YACH,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;CACF;AA1BO;IADL,KAAK,EAAE;;;;gDA0BP"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Home Categorizer Agent
3
+ *
4
+ * Takes a list of presenter-produced opportunity cards and returns dynamic sections
5
+ * with CTA-style titles and Lucide icon names. Used by the home graph after
6
+ * generateCardText.
7
+ */
8
+ import type { HomeSectionProposal } from '../states/home.state.js';
9
+ export type CategorizerInputItem = {
10
+ index: number;
11
+ headline?: string;
12
+ mainText: string;
13
+ name: string;
14
+ viewerRole?: string;
15
+ opportunityStatus?: string;
16
+ };
17
+ export type CategorizerResult = {
18
+ sections: HomeSectionProposal[];
19
+ };
20
+ export declare class HomeCategorizerAgent {
21
+ private model;
22
+ constructor();
23
+ /**
24
+ * Categorize presenter-produced cards into 1–5 sections with CTA-style titles and icons.
25
+ */
26
+ categorize(cards: CategorizerInputItem[]): Promise<CategorizerResult>;
27
+ }
28
+ //# sourceMappingURL=home.categorizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"home.categorizer.d.ts","sourceRoot":"","sources":["../../src/agents/home.categorizer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAwBnE,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,mBAAmB,EAAE,CAAC;CACjC,CAAC;AAkEF,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,KAAK,CAAiD;;IAO9D;;OAEG;IAEG,UAAU,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAsE5E"}