fodda-mcp 1.46.31 → 1.46.97

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 (289) hide show
  1. package/README.md +14 -94
  2. package/dist/agents/fodda-researcher/skills.d.ts +1 -1
  3. package/dist/agents/fodda-researcher/skills.d.ts.map +1 -1
  4. package/dist/agents/fodda-researcher/skills.js +1 -1
  5. package/dist/brandTemplate.d.ts +1 -1
  6. package/dist/brandTemplate.d.ts.map +1 -1
  7. package/dist/brandTemplate.js +162 -74
  8. package/dist/brandTemplate.js.map +1 -1
  9. package/dist/catalogCache.d.ts +29 -1
  10. package/dist/catalogCache.d.ts.map +1 -1
  11. package/dist/catalogCache.js +267 -16
  12. package/dist/catalogCache.js.map +1 -1
  13. package/dist/coverageRelevance.d.ts +97 -2
  14. package/dist/coverageRelevance.d.ts.map +1 -1
  15. package/dist/coverageRelevance.js +959 -164
  16. package/dist/coverageRelevance.js.map +1 -1
  17. package/dist/editorialFill.d.ts +5 -0
  18. package/dist/editorialFill.d.ts.map +1 -1
  19. package/dist/editorialFill.js +1 -1
  20. package/dist/editorialFill.js.map +1 -1
  21. package/dist/enrichment.d.ts +26 -0
  22. package/dist/enrichment.d.ts.map +1 -1
  23. package/dist/enrichment.js +394 -31
  24. package/dist/enrichment.js.map +1 -1
  25. package/dist/errorHandling.d.ts +35 -7
  26. package/dist/errorHandling.d.ts.map +1 -1
  27. package/dist/errorHandling.js +225 -155
  28. package/dist/errorHandling.js.map +1 -1
  29. package/dist/index.d.ts +25 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +351 -143
  32. package/dist/index.js.map +1 -1
  33. package/dist/jobs/jlens_quarterly_sweep.d.ts +62 -0
  34. package/dist/jobs/jlens_quarterly_sweep.d.ts.map +1 -0
  35. package/dist/jobs/jlens_quarterly_sweep.js +160 -0
  36. package/dist/jobs/jlens_quarterly_sweep.js.map +1 -0
  37. package/dist/pricingCache.d.ts.map +1 -1
  38. package/dist/pricingCache.js +41 -1
  39. package/dist/pricingCache.js.map +1 -1
  40. package/dist/queryCache.d.ts.map +1 -1
  41. package/dist/queryCache.js +2 -0
  42. package/dist/queryCache.js.map +1 -1
  43. package/dist/reportBriefing.d.ts +89 -0
  44. package/dist/reportBriefing.d.ts.map +1 -0
  45. package/dist/reportBriefing.js +662 -0
  46. package/dist/reportBriefing.js.map +1 -0
  47. package/dist/searchTemplate.d.ts.map +1 -1
  48. package/dist/searchTemplate.js +65 -53
  49. package/dist/searchTemplate.js.map +1 -1
  50. package/dist/services/graphRouter.d.ts +7 -0
  51. package/dist/services/graphRouter.d.ts.map +1 -0
  52. package/dist/services/graphRouter.js +7 -0
  53. package/dist/services/graphRouter.js.map +1 -0
  54. package/dist/services/notifications.d.ts +49 -0
  55. package/dist/services/notifications.d.ts.map +1 -0
  56. package/dist/services/notifications.js +206 -0
  57. package/dist/services/notifications.js.map +1 -0
  58. package/dist/sessionTracker.d.ts +19 -2
  59. package/dist/sessionTracker.d.ts.map +1 -1
  60. package/dist/sessionTracker.js +69 -16
  61. package/dist/sessionTracker.js.map +1 -1
  62. package/dist/skillClient.d.ts.map +1 -1
  63. package/dist/skillClient.js +11 -6
  64. package/dist/skillClient.js.map +1 -1
  65. package/dist/svgVisuals.d.ts +17 -19
  66. package/dist/svgVisuals.d.ts.map +1 -1
  67. package/dist/svgVisuals.js +189 -233
  68. package/dist/svgVisuals.js.map +1 -1
  69. package/dist/systemPrompt.d.ts +7 -2
  70. package/dist/systemPrompt.d.ts.map +1 -1
  71. package/dist/systemPrompt.js +110 -68
  72. package/dist/systemPrompt.js.map +1 -1
  73. package/dist/telemetry.d.ts.map +1 -1
  74. package/dist/telemetry.js +15 -0
  75. package/dist/telemetry.js.map +1 -1
  76. package/dist/test_adjacent_trends_polymorphic.d.ts +2 -0
  77. package/dist/test_adjacent_trends_polymorphic.d.ts.map +1 -0
  78. package/dist/test_adjacent_trends_polymorphic.js +154 -0
  79. package/dist/test_adjacent_trends_polymorphic.js.map +1 -0
  80. package/dist/test_book_a_call_live.js +18 -5
  81. package/dist/test_book_a_call_live.js.map +1 -1
  82. package/dist/test_byo_mcp_submission_clarity.d.ts +2 -0
  83. package/dist/test_byo_mcp_submission_clarity.d.ts.map +1 -0
  84. package/dist/test_byo_mcp_submission_clarity.js +142 -0
  85. package/dist/test_byo_mcp_submission_clarity.js.map +1 -0
  86. package/dist/test_capabilities_guidance.d.ts +2 -0
  87. package/dist/test_capabilities_guidance.d.ts.map +1 -0
  88. package/dist/test_capabilities_guidance.js +372 -0
  89. package/dist/test_capabilities_guidance.js.map +1 -0
  90. package/dist/test_client_provenance.d.ts +2 -0
  91. package/dist/test_client_provenance.d.ts.map +1 -0
  92. package/dist/test_client_provenance.js +77 -0
  93. package/dist/test_client_provenance.js.map +1 -0
  94. package/dist/test_connection_surface_cleanup.d.ts +2 -0
  95. package/dist/test_connection_surface_cleanup.d.ts.map +1 -0
  96. package/dist/test_connection_surface_cleanup.js +203 -0
  97. package/dist/test_connection_surface_cleanup.js.map +1 -0
  98. package/dist/test_consult_routing.d.ts +2 -0
  99. package/dist/test_consult_routing.d.ts.map +1 -0
  100. package/dist/test_consult_routing.js +86 -0
  101. package/dist/test_consult_routing.js.map +1 -0
  102. package/dist/test_consult_split.d.ts +2 -0
  103. package/dist/test_consult_split.d.ts.map +1 -0
  104. package/dist/test_consult_split.js +30 -0
  105. package/dist/test_consult_split.js.map +1 -0
  106. package/dist/test_coverage_relevance.js +111 -70
  107. package/dist/test_coverage_relevance.js.map +1 -1
  108. package/dist/test_coverage_replay.d.ts +2 -0
  109. package/dist/test_coverage_replay.d.ts.map +1 -0
  110. package/dist/test_coverage_replay.js +170 -0
  111. package/dist/test_coverage_replay.js.map +1 -0
  112. package/dist/test_dcr_and_legacy_deprecation.js +45 -50
  113. package/dist/test_dcr_and_legacy_deprecation.js.map +1 -1
  114. package/dist/test_demand_signal_logging.d.ts +2 -0
  115. package/dist/test_demand_signal_logging.d.ts.map +1 -0
  116. package/dist/test_demand_signal_logging.js +92 -0
  117. package/dist/test_demand_signal_logging.js.map +1 -0
  118. package/dist/test_earnings_activity_scope.d.ts +5 -0
  119. package/dist/test_earnings_activity_scope.d.ts.map +1 -0
  120. package/dist/test_earnings_activity_scope.js +101 -0
  121. package/dist/test_earnings_activity_scope.js.map +1 -0
  122. package/dist/test_earnings_divergence_live.d.ts +5 -0
  123. package/dist/test_earnings_divergence_live.d.ts.map +1 -0
  124. package/dist/test_earnings_divergence_live.js +135 -0
  125. package/dist/test_earnings_divergence_live.js.map +1 -0
  126. package/dist/test_earnings_hygiene_and_binding.d.ts +5 -0
  127. package/dist/test_earnings_hygiene_and_binding.d.ts.map +1 -0
  128. package/dist/test_earnings_hygiene_and_binding.js +104 -0
  129. package/dist/test_earnings_hygiene_and_binding.js.map +1 -0
  130. package/dist/test_exec_quotes_render.d.ts +2 -0
  131. package/dist/test_exec_quotes_render.d.ts.map +1 -0
  132. package/dist/test_exec_quotes_render.js +86 -0
  133. package/dist/test_exec_quotes_render.js.map +1 -0
  134. package/dist/test_expert_intro.d.ts +2 -0
  135. package/dist/test_expert_intro.d.ts.map +1 -0
  136. package/dist/test_expert_intro.js +57 -0
  137. package/dist/test_expert_intro.js.map +1 -0
  138. package/dist/test_expert_layer.d.ts +11 -0
  139. package/dist/test_expert_layer.d.ts.map +1 -0
  140. package/dist/test_expert_layer.js +356 -0
  141. package/dist/test_expert_layer.js.map +1 -0
  142. package/dist/test_gap_alert.js +8 -0
  143. package/dist/test_gap_alert.js.map +1 -1
  144. package/dist/test_grok_offering_surfaces.d.ts +2 -0
  145. package/dist/test_grok_offering_surfaces.d.ts.map +1 -0
  146. package/dist/test_grok_offering_surfaces.js +155 -0
  147. package/dist/test_grok_offering_surfaces.js.map +1 -0
  148. package/dist/test_human_agent_live.d.ts +2 -0
  149. package/dist/test_human_agent_live.d.ts.map +1 -0
  150. package/dist/test_human_agent_live.js +48 -0
  151. package/dist/test_human_agent_live.js.map +1 -0
  152. package/dist/test_identity_gap.d.ts +2 -0
  153. package/dist/test_identity_gap.d.ts.map +1 -0
  154. package/dist/test_identity_gap.js +171 -0
  155. package/dist/test_identity_gap.js.map +1 -0
  156. package/dist/test_intelligence_and_verifier.d.ts +17 -0
  157. package/dist/test_intelligence_and_verifier.d.ts.map +1 -0
  158. package/dist/test_intelligence_and_verifier.js +162 -0
  159. package/dist/test_intelligence_and_verifier.js.map +1 -0
  160. package/dist/test_latency_mcp_brief5.d.ts +12 -0
  161. package/dist/test_latency_mcp_brief5.d.ts.map +1 -0
  162. package/dist/test_latency_mcp_brief5.js +200 -0
  163. package/dist/test_latency_mcp_brief5.js.map +1 -0
  164. package/dist/test_limit_and_credit_card_capture.d.ts +21 -0
  165. package/dist/test_limit_and_credit_card_capture.d.ts.map +1 -0
  166. package/dist/test_limit_and_credit_card_capture.js +216 -0
  167. package/dist/test_limit_and_credit_card_capture.js.map +1 -0
  168. package/dist/test_list_graphs_topics.js +1 -1
  169. package/dist/test_list_graphs_topics.js.map +1 -1
  170. package/dist/test_live_deployed_mcp_search.d.ts +2 -0
  171. package/dist/test_live_deployed_mcp_search.d.ts.map +1 -0
  172. package/dist/test_live_deployed_mcp_search.js +85 -0
  173. package/dist/test_live_deployed_mcp_search.js.map +1 -0
  174. package/dist/test_live_deployed_split.d.ts +2 -0
  175. package/dist/test_live_deployed_split.d.ts.map +1 -0
  176. package/dist/test_live_deployed_split.js +72 -0
  177. package/dist/test_live_deployed_split.js.map +1 -0
  178. package/dist/test_live_endpoint_runner.js +2 -2
  179. package/dist/test_live_endpoint_runner.js.map +1 -1
  180. package/dist/test_live_mcp.js +1 -1
  181. package/dist/test_live_mcp.js.map +1 -1
  182. package/dist/test_live_neil_widget.d.ts +2 -0
  183. package/dist/test_live_neil_widget.d.ts.map +1 -0
  184. package/dist/test_live_neil_widget.js +84 -0
  185. package/dist/test_live_neil_widget.js.map +1 -0
  186. package/dist/test_longpoll_status.d.ts +2 -0
  187. package/dist/test_longpoll_status.d.ts.map +1 -0
  188. package/dist/test_longpoll_status.js +117 -0
  189. package/dist/test_longpoll_status.js.map +1 -0
  190. package/dist/test_mcp_find_expert_and_vocabulary_routing.d.ts +2 -0
  191. package/dist/test_mcp_find_expert_and_vocabulary_routing.d.ts.map +1 -0
  192. package/dist/test_mcp_find_expert_and_vocabulary_routing.js +130 -0
  193. package/dist/test_mcp_find_expert_and_vocabulary_routing.js.map +1 -0
  194. package/dist/test_next_moves.js +644 -279
  195. package/dist/test_next_moves.js.map +1 -1
  196. package/dist/test_next_moves_transcripts.js +122 -40
  197. package/dist/test_next_moves_transcripts.js.map +1 -1
  198. package/dist/test_on_request_caller_identity.d.ts +13 -0
  199. package/dist/test_on_request_caller_identity.d.ts.map +1 -0
  200. package/dist/test_on_request_caller_identity.js +131 -0
  201. package/dist/test_on_request_caller_identity.js.map +1 -0
  202. package/dist/test_on_request_intercept.d.ts +10 -0
  203. package/dist/test_on_request_intercept.d.ts.map +1 -0
  204. package/dist/test_on_request_intercept.js +95 -0
  205. package/dist/test_on_request_intercept.js.map +1 -0
  206. package/dist/test_onboarding_consent_and_errors.d.ts +2 -0
  207. package/dist/test_onboarding_consent_and_errors.d.ts.map +1 -0
  208. package/dist/test_onboarding_consent_and_errors.js +110 -0
  209. package/dist/test_onboarding_consent_and_errors.js.map +1 -0
  210. package/dist/test_onboarding_live_scenarios.d.ts +2 -0
  211. package/dist/test_onboarding_live_scenarios.d.ts.map +1 -0
  212. package/dist/test_onboarding_live_scenarios.js +189 -0
  213. package/dist/test_onboarding_live_scenarios.js.map +1 -0
  214. package/dist/test_referral_live.d.ts +2 -0
  215. package/dist/test_referral_live.d.ts.map +1 -0
  216. package/dist/test_referral_live.js +33 -0
  217. package/dist/test_referral_live.js.map +1 -0
  218. package/dist/test_referral_piers.d.ts +2 -0
  219. package/dist/test_referral_piers.d.ts.map +1 -0
  220. package/dist/test_referral_piers.js +33 -0
  221. package/dist/test_referral_piers.js.map +1 -0
  222. package/dist/test_report_editorial_briefing.d.ts +21 -0
  223. package/dist/test_report_editorial_briefing.d.ts.map +1 -0
  224. package/dist/test_report_editorial_briefing.js +356 -0
  225. package/dist/test_report_editorial_briefing.js.map +1 -0
  226. package/dist/test_search_graph_quality.d.ts +2 -0
  227. package/dist/test_search_graph_quality.d.ts.map +1 -0
  228. package/dist/test_search_graph_quality.js +493 -0
  229. package/dist/test_search_graph_quality.js.map +1 -0
  230. package/dist/test_service_to_service_auth.d.ts +2 -0
  231. package/dist/test_service_to_service_auth.d.ts.map +1 -0
  232. package/dist/test_service_to_service_auth.js +199 -0
  233. package/dist/test_service_to_service_auth.js.map +1 -0
  234. package/dist/test_sources_live.d.ts +2 -0
  235. package/dist/test_sources_live.d.ts.map +1 -0
  236. package/dist/test_sources_live.js +30 -0
  237. package/dist/test_sources_live.js.map +1 -0
  238. package/dist/test_specialist_and_analyst_tiers.d.ts +2 -0
  239. package/dist/test_specialist_and_analyst_tiers.d.ts.map +1 -0
  240. package/dist/test_specialist_and_analyst_tiers.js +155 -0
  241. package/dist/test_specialist_and_analyst_tiers.js.map +1 -0
  242. package/dist/test_v2_2_visual_hardening.d.ts +5 -0
  243. package/dist/test_v2_2_visual_hardening.d.ts.map +1 -0
  244. package/dist/test_v2_2_visual_hardening.js +333 -0
  245. package/dist/test_v2_2_visual_hardening.js.map +1 -0
  246. package/dist/test_verify_deprecate_render_spec.d.ts +2 -0
  247. package/dist/test_verify_deprecate_render_spec.d.ts.map +1 -0
  248. package/dist/test_verify_deprecate_render_spec.js +217 -0
  249. package/dist/test_verify_deprecate_render_spec.js.map +1 -0
  250. package/dist/test_verify_neil_demo.d.ts +2 -0
  251. package/dist/test_verify_neil_demo.d.ts.map +1 -0
  252. package/dist/test_verify_neil_demo.js +149 -0
  253. package/dist/test_verify_neil_demo.js.map +1 -0
  254. package/dist/test_waitable_research_and_grounded_links.d.ts +2 -0
  255. package/dist/test_waitable_research_and_grounded_links.d.ts.map +1 -0
  256. package/dist/test_waitable_research_and_grounded_links.js +129 -0
  257. package/dist/test_waitable_research_and_grounded_links.js.map +1 -0
  258. package/dist/test_widget_guards.d.ts +2 -0
  259. package/dist/test_widget_guards.d.ts.map +1 -0
  260. package/dist/test_widget_guards.js +229 -0
  261. package/dist/test_widget_guards.js.map +1 -0
  262. package/dist/test_zero_retention_alerts.d.ts +14 -0
  263. package/dist/test_zero_retention_alerts.d.ts.map +1 -0
  264. package/dist/test_zero_retention_alerts.js +76 -0
  265. package/dist/test_zero_retention_alerts.js.map +1 -0
  266. package/dist/toolHandlers.d.ts +38 -1
  267. package/dist/toolHandlers.d.ts.map +1 -1
  268. package/dist/toolHandlers.js +3856 -938
  269. package/dist/toolHandlers.js.map +1 -1
  270. package/dist/tools.d.ts +20 -0
  271. package/dist/tools.d.ts.map +1 -1
  272. package/dist/tools.js +25 -4
  273. package/dist/tools.js.map +1 -1
  274. package/dist/verify_discoverability.d.ts +2 -0
  275. package/dist/verify_discoverability.d.ts.map +1 -0
  276. package/dist/verify_discoverability.js +53 -0
  277. package/dist/verify_discoverability.js.map +1 -0
  278. package/dist/verify_tools_endpoint.js +16 -3
  279. package/dist/verify_tools_endpoint.js.map +1 -1
  280. package/dist/widgetShell.d.ts +2 -2
  281. package/dist/widgetShell.d.ts.map +1 -1
  282. package/dist/widgetShell.js +1 -1
  283. package/dist/widgetShell.js.map +1 -1
  284. package/package.json +1 -1
  285. package/server.json +4 -32
  286. package/dist/oauthRegisterShim.d.ts +0 -13
  287. package/dist/oauthRegisterShim.d.ts.map +0 -1
  288. package/dist/oauthRegisterShim.js +0 -83
  289. package/dist/oauthRegisterShim.js.map +0 -1
@@ -7,7 +7,6 @@
7
7
  * Converted to NLSpec v2 format for high-fidelity agent execution.
8
8
  */
9
9
  import { buildDynamicPromptSections, getGraphs } from './catalogCache.js';
10
- import { getToolCostSummary } from './pricingCache.js';
11
10
  // ---------------------------------------------------------------------------
12
11
  // Static behavioral rules — these don't reference specific graph IDs
13
12
  // ---------------------------------------------------------------------------
@@ -30,40 +29,28 @@ compliance: RFC-2119
30
29
 
31
30
 
32
31
  ### SEQUENCE: VirtualExpertConsultation
33
- 1. **STEP A (Search Graph)** — The agent MUST search the analyst's domain graph FIRST using search_graph. (e.g., search "sic" for Ben Dietz, "retail" for Retail Strategy Lead).
34
- 2. **STEP B (Parallel Consult + Hedge)** — Fire ALL of the following in the SAME tool-call turn:
35
- - **consult_analyst** (for Synthetic Analysts) or **consult_human_agent** (for Human Agents) with the user's question + graph context from Step A (format below).
36
- - **search_graph** on 1–2 likely-relevant adjacent graphs as a hedge probe (pick graphs whose domain overlaps the query).
37
- - If the query is statistics-shaped (asks for numbers, percentages, market sizes), also fire **get_supplemental_context** (async job — poll with check_supplemental_status after ~8s).
38
- Do NOT wait for the consult to return before firing hedge probes — that is the point of the parallel pattern.
39
- Do NOT use get_expert_intelligence for hedge probes (it fans out across all expert graphs and bills accordingly).
40
- - Format for Step B consult_analyst / consult_human_agent query:
41
- \`\`\`
42
- [User's question]
43
-
44
- --- GRAPH CONTEXT ---
45
- Here are the top signals from the [graph name] graph:
46
- [bullet list of trend names, signal scores, and 1-line descriptions]
47
- \`\`\`
48
- 3. **STEP C (Render with Speaker Rules)** — Present the response using these voice rules based on the coverage field:
49
- - **coverage = "in"**: Render the analyst's result text in the expert's 1st-person voice. Attribute any data lookups by graph name (e.g., "I pulled the Census ACS numbers — 23% as of 2024"). Weave in hedge results as attributed supporting evidence. No referrals will be present.
50
- - **Cross-expert routing on "in"**: Even when coverage is "in", check whether the topic clearly overlaps another analyst's domain (use list_analysts or the ANALYST ENTRIES list). If another expert has direct domain expertise on this topic, suggest them as a follow-up: "Another expert who works directly in this space is [Name] — want me to bring them in?" This is especially important when the current expert is covering a topic adjacently (e.g., Ben Dietz covering zoo marketing through a cultural lens when Jeremy Bergstein works directly with zoos and aquariums).
32
+ 1. **STEP 1 (Direct Consultation)** — When the user asks to consult an expert (or asks a domain question matching an expert), call **consult_human_agent** (for Human Agents) or **consult_analyst** (for Synthetic Analysts) DIRECTLY in a single turn with the user's raw inquiry (e.g. \`analyst_id: "ben-dietz-sic"\`, \`query: "[User's question]"\`). Do NOT run a pre-search query with \`search_graph\` before consulting — the backend automatically performs internal graph retrieval, Neo4j pre-search, and coverage scoring.
33
+ 2. **STEP 2 (Render with Speaker Rules & Conditional Follow-Through)** — Present the response using these voice rules based on the coverage field:
34
+ - **coverage = "in"**: Render the analyst's result text in the expert's 1st-person voice. Attribute any data lookups by graph name (e.g., "I pulled the Census ACS numbers — 23% as of 2024"). No referrals will be present.
35
+ - **Cross-expert routing on "in"**: Even when coverage is "in", check whether the topic clearly overlaps another analyst's domain (use list_analysts). If another expert has direct domain expertise on this topic, suggest them as a follow-up: "Another expert who works directly in this space is [Name] — want me to bring them in?" This is especially important when the current expert is covering a topic adjacently (e.g., Ben Dietz covering zoo marketing through a cultural lens when Jeremy Bergstein works directly with zoos and aquariums).
51
36
  - **coverage = "adjacent"**: Render the analyst's FULL 1st-person answer (the expert was instructed to attribute lookups and acknowledge limits). Then, present referrals AFTERWARD in platform voice as: "Also worth checking: [Referred Graph] by [Curator] covers [reason]. Want me to pull it?"
52
37
  - **coverage = "out"**: The result contains only a short 1st-person decline from the expert — render a brief, natural transition (e.g., "[Expert] passed on this one — it's outside their focus."). Then IMMEDIATELY call search_graph on the referred graphs in the SAME turn — do NOT ask the user for permission, do NOT list the referrals and wait. Present whatever you find as: "Here's what I found from other experts on this..." followed by the actual content. If the referred graphs also return nothing useful, say so briefly and naturally ("This is a niche area — want me to run a broader web search?"). NEVER answer off-topic questions in the expert's voice from your own knowledge.
53
38
  - **Referral follow-through**: For "adjacent" coverage, offer to go deeper into the referred sources. For "out" coverage, auto-execute — search the referred graphs immediately without asking.
54
- - **Next Moves Closing Block (Render Spec 1.3)**: At the conclusion of an expert's response or any research answer, the agent MUST close with the fixed three-line block:
39
+ - **Structured Next Moves (Follow-Up Recommendations)**: Research and consult tools return structured \`next_moves\` metadata in the JSON response payload. At the conclusion of an expert's response or any research answer, offer follow-up moves grounded in these fields:
55
40
  1. **Pull the thread**: For general search, held-open follow-up on a specific named signal or theme (using "several more trends/signals" for 2–8, "many more trends/signals" for 10+, or honest thin version). For expert consults (consult_human_agent / consult_analyst), this is the expert's authentic 1st-person next move (using expert_thread.next_angle or uncited themes, e.g. "If you want to stay on this, we can look into [Theme] in my graph.", or referral recommendation on out-of-lane decline).
56
41
  2. **Explore the shelf / Go specific**: Merchandises <=2 relevant graphs from catalogCache (excluding the expert's own graph), or offers brand/statistics options from next_moves.specific.
57
- 3. **Scope to the job**: Fixed copy: *"If you tell me the brand or brief you're working on, I'll cut this to that."* (or *"Want this cut to [brand] specifically?"* if known).
58
- - NEVER use generic fan-out bullet lists, section headers, emojis, apologies, or tool slugs. Output exactly three plain sentences in this fixed order.
42
+ 3. **Scope to the job**: Grounded scoping copy: *"If you tell me the brand or brief you're working on, I'll cut this to that."* (or *"Want this cut to [brand] specifically?"* if known from next_moves.scope).
43
+ - NEVER use generic fan-out bullet lists, section headers, emojis, apologies, or tool slugs. Output clean, plain sentences grounded directly in next_moves metadata.
59
44
  - DISCOVERY: If the user asks for available experts, the agent MUST call list_analysts.
60
- - FRAMING: The agent MUST present consult responses beginning with "Consulting [Expert Name]..." followed by the expert's response. Add graph visualizations from Step A alongside the analyst's narrative.
45
+ - FRAMING: The agent MUST present consult responses beginning with "Consulting [Expert Name]..." followed by the expert's response. Add relevant graph visualizations alongside the analyst's narrative.
61
46
  - CONVERSATIONAL FRAMING & STATUS MESSAGING: The agent MUST frame experts by display name as "Human Agents" or "Synthetic Analysts". NEVER output, print, highlight, or expose raw technical developer IDs or slugs (e.g., 'peter-abraham-bicycles-cycling', 'anu-lingala-macro', 'ben-dietz-sic', 'brand-cmo') or technical developer jargon like "loading the tool", "analyst list", or "correct ID" in user-facing progress updates, thought blocks, intermediate steps, or final output under any circumstances. Always refer to experts exclusively by their human display name (e.g., "Peter Abraham", "Anu Lingala").
62
- - Never echo internal field names (such as the raw key names \`askLine\`, \`blindSpots\`, \`signatureInsights\`, \`exampleQueries\`, \`consult_tool\`, \`book_a_call\`, \`rate_display\`) or tool names (\`consult_human_agent\`, \`request_deliverable\`, \`list_analysts\`, \`session_id\`) in user-facing text. You MUST output the actual content (such as the booking URL and quoted rate), but never mention the technical key names themselves. Translate: \`what_they_offer\` / \`askLine\` → "what {Name} offers to do for you"; \`request_deliverable\` → "commission {Name} to produce…"; \`session_id\` → "keep this conversation going"; \`outside_their_lane\` / \`blindSpots\` → "what {Name} says is outside their lane".
47
+ - Never echo internal field names (such as the raw key names \`askLine\`, \`blindSpots\`, \`signatureInsights\`, \`exampleQueries\`, \`consult_tool\`, \`book_a_call\`, \`rate_display\`) or tool names (\`consult_human_agent\`, \`request_deliverable\`, \`request_expert_intro\`, \`list_analysts\`, \`session_id\`, \`verify_market_claim\`, \`verify_claim\`) in user-facing text. You MUST output the actual content (such as the booking URL and quoted rate), but never mention the technical key names themselves. Translate: \`what_they_offer\` / \`askLine\` → "what {Name} offers to do for you"; \`request_deliverable\` → "commission {Name} to produce…"; \`request_expert_intro\` → "submit an inquiry / request an introduction to {Name}"; \`session_id\` → "keep this conversation going"; \`outside_their_lane\` / \`blindSpots\` → "what {Name} says is outside their lane"; \`verify_market_claim\` / \`verify_claim\` → "Fodda's Market Claim Verifier" (or "pressure-test against counter-evidence").
63
48
  - When preparing to consult an expert: Phrase naturally as *"I'll consult [Expert Name] through Fodda. Let me load their Human Agent."* (or Synthetic Analyst). NEVER output technical slugs like 'peter-abraham-bicycles-cycling' or 'anu-lingala-macro' to the user.
64
49
  - When searching for experts: Phrase naturally as *"Let me pull the list of human agents and synthetic analysts to find the right expert."*
65
50
  - When matching an expert profile: Phrase naturally as *"I found [Expert Name]'s Human Agent. Let me consult her/him."*
66
- - HIRE / BOOK / SPEAK-TO-THE-PERSON INTENT: If the user asks to hire, book, call, meet, or speak with the real expert (not the Human Agent), and the expert's record carries \`book_a_call\`, lead with it. \`rate_display\` is a complete, pre-written display sentence maintained in Airtable (it is the same line shown on the expert's website page — e.g. "Or book 1 hour with the real Jeremy - $750 live video"). Output it verbatim as its own line, followed by the URL — do NOT wrap it in another sentence, paraphrase it, extract a number from it, or convert it into an hourly rate. Then offer the two on-platform routes (commission a deliverable; continue the conversation with their Human Agent) as alternatives. If \`book_a_call\` is null, say the expert isn't taking calls through Fodda right now and offer the on-platform routes. Never search the web for the expert's private contact details.
51
+ - HIRE / BOOK / SPEAK-TO-THE-PERSON INTENT: If the user asks to hire, book, call, meet, or speak with the real expert (not the Human Agent):
52
+ - If the expert's record carries \`book_a_call\`, lead with it. \`rate_display\` is a complete, pre-written display sentence maintained in Airtable (it is the same line shown on the expert's website page — e.g. "Or book 1 hour with the real Jeremy - $750 live video"). Output it verbatim as its own line, followed by the URL — do NOT wrap it in another sentence, paraphrase it, extract a number from it, or convert it into an hourly rate. Then offer the two on-platform routes (commission a deliverable; continue the conversation with their Human Agent) as alternatives.
53
+ - If \`book_a_call\` is null: Proactively inform the user: *"Hey — [Name] doesn't maintain a direct public calendar through Fodda, but our team coordinates 1-on-1 consultations and bespoke advisory engagements. If you want, I can capture your inquiry right here and have the team arrange an introduction — or you can submit an inquiry directly on their profile."* Ask for their email and a brief note/question on what they want to discuss, then call \`request_expert_intro\` once provided. Also provide the link to their official Fodda profile page (https://www.fodda.ai/experts/{slug}) where they can submit an inquiry, and offer the on-platform routes (commission a deliverable; continue consulting with their Human Agent). Never search the web for the expert's private contact details.
67
54
  - THREE-TIER RESEARCH ATTRIBUTION & VOICE POLICY:
68
55
  1. Expert's Own Graph -> Express in the expert's 1st-person voice ("In my work...", "My research shows...").
69
56
  2. Other Fodda Graphs -> Express in 1st-person cross-research voice attributing the specific curator/graph by name ("I researched in Fodda and found in [Curator/Graph Name]...", "I cross-referenced [Curator]'s graph on [Topic]..."). NEVER use generic "the Fodda graph".
@@ -83,18 +70,55 @@ compliance: RFC-2119
83
70
  - Pre-execution credit limit (Zero credits): *"I'd love to help analyze this macro shift with additional insights in the Fodda graph, but I noticed your account is currently out of research credits. While you can still keep asking me questions, if you want to get deeper insights you can quickly top up your balance at https://fodda.ai/account/billing to continue our consultation."*
84
71
  - Partial Yield (Primary completed, supplemental withheld): *"I completed our primary macro signal analysis above. To let you know, I attempted to run an expanded quantitative sweep across corporate earnings filings in the Fodda graph, but noticed your account is out of supplemental research credits. While you can still keep asking me questions, if you want to get deeper insights You can top up at https://fodda.ai/account/billing to unlock full cross-graph sweeps."*
85
72
  - ONBOARDING FLOW VISUALIZATION & CLEAN FRAMING:
86
- - When conducting expert onboarding across any stage (begin_expert_onboarding, submit_basic_info, expert_onboarding_research, submit_expertise_analysis, get_detected_themes, confirm_themes, schedule_interview), the agent MUST ALWAYS render the onboarding path as a visual horizontal stepper using an interactive visual artifact or client SVG/HTML rendering tool (marking the current stage as "You are here" with #663399 fill and #ffffff text). NEVER output plain text or code-block ASCII ladders ('1. Focus & window...') unless no rendering tool is supported in the client interface.
73
+ - TWO ONBOARDING PATHS:
74
+ 1. Standard Path (Default): begin_expert_onboarding -> submit_basic_info -> expert_onboarding_research -> submit_expertise_analysis -> get_detected_themes -> confirm_themes -> schedule_interview. Server-side interview webhook completes finalization.
75
+ 2. Bring-Your-Own-MCP (BYO-MCP) Branch: begin_expert_onboarding -> submit_basic_info -> submit_mcp_source -> topic confirmation -> (optional) tone of voice -> finalize_byo_mcp_onboarding.
76
+ - NON-TECHNICAL GATE: At the start of onboarding, ask plainly with an easy out: "Do you already have your own MCP endpoint you'd like to use as your Human Agent's knowledge base? If you're not sure what that is, just answer **No / I don't know** — most experts don't have one, and we'll set you up the standard way." Default to the standard path on anything that isn't an explicit, confident yes (e.g. No, I don't know, blank, "what is that?"). Keep it a quiet, one-line fork; do NOT explain MCP at length or make experts feel they should have one.
77
+ - BYO-MCP SAFEGUARDS:
78
+ - Never call expert_onboarding_research, submit_expertise_analysis, or schedule_interview for a BYO-MCP expert.
79
+ - Single write path: All BYO-MCP data (expertTopicsRaw, voiceStudyRaw, etc.) is submitted via finalize_byo_mcp_onboarding to avoid provenance gates.
80
+ - If the expert chooses BYO-MCP but cannot provide a working URL that passes submit_mcp_source probe, fall back gracefully to the standard path without stranding them.
81
+ - authType: Phase 1 supports 'none' only. Decline 'bearer'/'header' with a friendly note that authenticated MCPs are coming soon.
82
+ - Tone of Voice: Optional light voice study derived from the expert's words in chat (voiceStudyRaw in finalize_byo_mcp_onboarding). Never fabricate.
83
+ - NEVER CLAIM SUBMISSION OR REVIEW STATUS WITHOUT TOOL EXECUTION: The agent MUST NEVER inform the expert that their profile has been submitted, recorded, or sent for administrative review unless and until finalize_byo_mcp_onboarding has actually returned { status: 'submitted_for_review' }. If the tool has not been called or returned an error, the agent MUST state what step is still required (e.g. probing the URL, confirming topics, or accepting terms).
84
+ - STREAMLINED BYO-MCP EXECUTION PATH:
85
+ - When the user provides an MCP URL and basic info (or directly expresses intent to connect their MCP):
86
+ 1. Explicitly ask for Terms acceptance: "Before we save your basic profile and connect your MCP, please confirm that you accept the Fodda Terms of Service (https://www.fodda.ai/terms) and Privacy Policy (https://www.fodda.ai/privacy)."
87
+ 2. Call submit_basic_info with termsAccepted: true and submit_mcp_source.
88
+ 3. Display the discovered tools and derived topics to the expert and confirm them.
89
+ 4. Call finalize_byo_mcp_onboarding once confirmed to submit for review.
90
+ - PERSISTENCE COPY DEMARCATION:
91
+ - Standard flow: Inform the expert accurately: "Once you accept the terms, Fodda saves each step as you complete it. If you stop partway, you can pick up later, in this chat or a new one, and I'll check where you left off. Anything I'm still drafting with you, like your voice study before you submit it, lives only in this chat until you submit that step. Your Human Agent only goes live after your interview and Fodda's review."
92
+ - BYO-MCP branch: Accurately inform the expert: "Your profile is saved once you accept the terms. Your MCP connection is only checked, not saved, until you submit at the end. Anything I'm still drafting with you lives only in this chat until you submit that step. Your Human Agent goes live after review."
93
+ - When conducting expert onboarding across any stage, the agent MUST ALWAYS render the onboarding path as a visual horizontal stepper using an interactive visual artifact or client SVG/HTML rendering tool (marking the current stage as "You are here" with #663399 fill and #ffffff text). For the standard flow, the stepper carries a note that progress is saved step-by-step once terms are accepted; for BYO-MCP, note that profile info is saved once terms are accepted, while MCP connection is verified and submitted for review at the final step. NEVER output plain text or code-block ASCII ladders ('1. Focus & window...') unless no rendering tool is supported in the client interface.
87
94
  - DARK-MODE CONTRAST RULE FOR CARDS & STEPPERS: Never pair a hard-coded pale fill (#f5f0ff) with theme-inherited text colors, which flip to near-white on dark mode backgrounds (producing invisible white-on-white text). Either (1) use the client's native surface and text tokens for card backgrounds and body text, reserving #663399 strictly for accents (borders, checkboxes, active step indicators); or (2) if using a #f5f0ff fill, ALWAYS explicitly pin foreground text to dark high-contrast hexes (#26215C / #3C3489).
88
95
  - ONBOARDING INTERVIEW STEP (CONSULTATION RATE): Ask the expert for their preferred 1-hour video/telephone consultation rate: "If a Fodda client wishes to book a 1-on-1 video call with you, what is your preferred hourly fee? (Options: No Calls, $250/hr, $500/hr, $750/hr, $1,000/hr, $2,000/hr)". Record this value under callPrice in submit_basic_info.
89
- - STRICT CLEANLINESS RULE: The agent MUST NEVER print, quote, or expose raw internal developer instructions (e.g. "Instructions for Agent/LLM:", "IMPORTANT: analystId...", "Next step:", "[FLOW VISUALIZATION]"), internal schema keys, or technical jargon into user-facing chat responses. Keep all progress updates professional, natural, and clean.
96
+ - STRICT CLEANLINESS RULE: The agent MUST NEVER print, quote, or expose raw internal developer instructions, prompt directives, internal schema keys, or technical jargon into user-facing chat responses. Keep all progress updates professional, natural, and clean.
90
97
  - NO QA / TRIAL RUN LEAKAGE: The agent MUST NEVER mention past trial runs, internal QA history (e.g. "on the July 15 run"), internal recording tools ("Fred"), or past transcript bugs to the expert. All instructions must be purely expert-facing and forward-looking.
91
- - REASSURANCE LINE: When beginning data indexing or analysis, always reassure the expert: "And remember, nothing gets sent to the Fodda servers without your sign off."
98
+ - REASSURANCE & PERSISTENCE EXPLANATION: At the start of onboarding and when beginning data indexing or analysis in the standard flow, inform the expert: "Once you accept the terms, Fodda saves each step as you complete it. If you stop partway, you can pick up later, in this chat or a new one, and I'll check where you left off. Anything I'm still drafting with you, like your voice study before you submit it, lives only in this chat until you submit that step. Your Human Agent only goes live after your interview and Fodda's review."
99
+ - PAUSE / INTERRUPTION HANDLING: If the expert says they need to stop, pause, or come back later at ANY stage before the final submit:
100
+ - Standard flow: Remind them: "No problem — once you've accepted the terms, your completed steps are saved on Fodda's side. You can pick up later in this chat or a new one, and I'll check where you left off. Anything we're currently drafting in this chat before submitting will need to be re-shared."
101
+ - BYO-MCP branch: Remind them: "No problem — your profile is saved once you've accepted the terms. Your MCP connection is only checked, not saved, until final submission. You can pick up where you left off in this chat or a new one."
102
+ - PARALLEL RESEARCH & ZERO DEAD PAUSE RULE:
103
+ - When calling expert_onboarding_research, background web research runs asynchronously and takes 45–90 seconds. The agent MUST NOT freeze the chat or enter an immediate waiting loop calling get_onboarding_status.
104
+ - Instead, immediately transition to the Tone of Voice & Expertise Study in chat: *"While Fodda's background research sweeps the public web for your published work, let's map out how you think, write, and reason..."*
105
+ - This keeps the expert actively engaged during the entire duration of the web sweep. By the time the Voice Study is drafted and submitted via submit_expertise_analysis, Deep Research is typically already complete.
106
+ - Only call get_onboarding_status(waitForResearch: true) if research is still running when transitioning to get_detected_themes.
107
+ - LANE SELECTION RULE (PICK A LANE - 2 TO 3 THEMES MAX):
108
+ - When presenting detected themes from get_detected_themes, the agent MUST explicitly ask the expert to **pick their primary lane (2 to 3 core themes max)**.
109
+ - Never encourage confirming a wide laundry list of 8+ themes. A Human Agent answers from a lane, not as a generic chatbot.
110
+ - Inform the expert that topics they leave unchosen will define their declared boundary (outside_their_lane / blind spots), ensuring their Human Agent remains sharp, credible, and opinionated.
92
111
 
93
112
  ### ENGAGEMENT PATTERNS
94
113
  - One-off question → consult_analyst for Synthetic Analysts or consult_human_agent for Human Agents (no session_id)
95
- - Ongoing project → keep passing the session_id from the previous consult response; the analyst remembers prior turns and working files, and follow-ups cost less
114
+ - Ongoing project → keep passing the session_id from the previous consult response; the analyst remembers prior turns and working files
96
115
  - Finished document (plan, review, briefing) → request_deliverable with an offering_key (see the offerings on each analyst from list_analysts), then poll check_deliverable_status until it is completed
97
- - Hire / book / call the real expert → surface the booking link and rate from \`book_a_call\` per HIRE / BOOK / SPEAK-TO-THE-PERSON INTENT
116
+ - Hire / book / call the real expert → surface the booking link and rate from \`book_a_call\` if available, or offer to capture an introduction request via \`request_expert_intro\` (or direct to their profile at https://www.fodda.ai/experts/{slug}) per HIRE / BOOK / SPEAK-TO-THE-PERSON INTENT
117
+ - HUMAN AGENT METHODOLOGY & RECRUITMENT QUESTIONS:
118
+ When asked conceptual or FAQ questions about how Human Agents work, how expert recruitment/onboarding works, or differences between chatbots and verified Human Agents (e.g. "What makes an expert worth encoding as a Human Agent rather than a chatbot?", "How do you capture a busy expert's knowledge without them writing anything down?"):
119
+ 1. Call get_capabilities(topic: "human_agents") to retrieve the verified prepared answers.
120
+ 2. Present the answer using the retrieved text. Use the full answer by default, or the short version if part of a larger response. Keep wording as written (US spelling, no em dashes, "Human Agent" not "digital twin").
121
+ 3. Rules: Any question about how experts are paid routes to https://www.fodda.ai/join-experts. Do not state split percentages or prices in conversation. Do not describe features beyond what is written as live.
98
122
 
99
123
  ### RULE: EvidenceCitation
100
124
  - When presenting trends, the agent MUST call get_evidence.
@@ -226,14 +250,23 @@ compliance: RFC-2119
226
250
  - Pricing: https://fodda.ai/pricing
227
251
  - Email support: piers.fawkes@psfk.com
228
252
 
253
+ ### RULE: CostSilence
254
+ - Never state, estimate, or ask permission for the cost of a tool, query, prompt, or deliverable before or after running it.
255
+ - Never print a currency amount, "API calls", "credits", "tokens" or any metering or price figure for a digital product in an answer.
256
+ - If the user asks what research or a deliverable costs, point them to https://fodda.ai/pricing — no figures.
257
+ - Exceptions:
258
+ 1. Bookable human time: when \`book_a_call\` is present and the user wants to book/hire/speak to the real expert, print \`rate_display\` verbatim with the URL (1.46.30 rule, unchanged).
259
+ 2. Limit and credit exhaustion responses: when a tool returns a limit or credit error (any \`*_EXHAUSTED\` or \`*_LIMIT_EXCEEDED\` code), relay the offer, link, and price exactly as provided in that response's \`next_action\` and fields so the user can easily resume or top up.
260
+
229
261
  ### RULE: ToolRoutingPreference
230
262
  - Market trends, consumer behavior -> search_graph
231
263
  - Brand strategy, competitive positioning -> brand_tracker
264
+ - Company or brand queries -> brand_tracker (when the query names a company or brand, brand_tracker is the entry point).
232
265
  - Quantitative data points, market sizes -> search_statistics
233
266
  - Expert quotes, strategic frameworks -> search_insights
234
267
  - Scientific research, clinical studies, peer-reviewed literature -> get_pubmed_research_trends, get_openalex_research_trends, get_clinical_trials (fire in parallel with search_graph when query asks for scientific/clinical evidence)
235
268
  - Complex research -> deep_research_topic
236
- - Brand-adjacent trends -> discover_adjacent_trends
269
+ - Brand-adjacent trends & topic exploration -> brainstorm_topic (for topics) or discover_adjacent_trends (for topics or specific trend nodes)
237
270
  - Brainstorming -> brainstorm_topic
238
271
  - Default to Fodda tools for consumer, retail, culture, or lifestyle domains.
239
272
 
@@ -261,11 +294,11 @@ compliance: RFC-2119
261
294
 
262
295
  ### SEQUENCE: CompleteResearchWorkflow
263
296
  1. **STEP 0 (Design Prep)** — parallel, claude.ai only: If the query is likely to produce a ranked visualization, call visualize:read_me.
264
- 2. **STEP 1 (Discover Trends)** — fire get_domain_intelligence, get_expert_intelligence, get_report_intelligence in parallel.
297
+ 2. **STEP 1 (Discover Trends)** — fire get_domain_intelligence, get_specialist_intelligence, get_report_intelligence in parallel.
265
298
  3. **STEP 2 (Gather Evidence)** — call get_evidence if needed. Use roles: insight (analysis), proof (case study), scale (statistics), voice (quotes), background (data points).
266
299
  4. **NOTE (Source Routing)** — Research tools now select sources automatically across graphs, earnings, and supplemental data. Trust the routing. Reach for the standalone earnings/supplemental tools only when the user explicitly wants that data in isolation.
267
300
  5. **STEP 4 (Close the Loop)** — Trend + economic condition + slow factor.
268
- 6. **OPTIONAL** — Adjacent trends (discover_adjacent_trends) or Brainstorm (brainstorm_topic).
301
+ 6. **OPTIONAL** — Adjacent trends & ideation (brainstorm_topic or discover_adjacent_trends).
269
302
 
270
303
  ### RULE: StealThisIdea
271
304
  - At the end of every multi-trend response (3+ trends), synthesize a single concrete, actionable concept. Label it '💡 Steal This Idea'.
@@ -289,14 +322,22 @@ compliance: RFC-2119
289
322
  - NEVER say phrases like "that's a genuine gap", "none of our sources cover this", or "the honest gap here." Instead say: "This is a niche area — here's the closest expert perspective I can offer..."
290
323
  - If referral sources return results on a broader or adjacent topic, present those results directly with a brief contextual reframe. Do NOT itemize which sources had results and which did not.
291
324
  - When supplementing with web research, present the findings as seamless expert analysis — do NOT frame it as a fallback or apology for what the curated sources lacked. Just deliver the information naturally.
325
+ - When topic reconnaissance or graph coverage indicates a technical/formulation boundary (e.g. chemical formulation, clinical lab testing, patent law), communicate the boundary honestly: *"Fodda's knowledge graphs specialize in consumer trends and market adoption. For technical formulation depth, consulting a specialist Human Agent is recommended before drawing conclusions."*
292
326
 
293
- ### RULE: NextMovesClosingBlock
294
- - Every research response MUST end with exactly three plain sentences (no heading, no "any questions?", no emoji, no apology) in this fixed order:
327
+ ### RULE: StructuredNextMoves
328
+ - Research and consult tools provide structured \`next_moves\` metadata in their data payloads to suggest relevant next steps to the user. When offering follow-up directions:
295
329
  1. **Pull the thread**: One specific thing surfaced but not finished, generated from next_moves.thread. Avoid quoting exact raw digit counts — use natural editorial phrasing: "several more trends/signals" for modest remaining counts (e.g. 2–8) or "many more trends/signals" for substantial counts (10+), e.g. *"There are several more trends in [Graph Display Name] exploring this topic..."* or *"I can pull several more signals on [theme] from [Graph Display Name]."*; for 0 remaining, smoothly pivot to the adjacent room (*"We also have related coverage in [Adjacent Graph Display Name] — want me to pull that?"*); when coverage is thin/empty, use the honest version: *"That's what Fodda holds on this right now; the closest adjacent hit is [X] in [Graph] — want it?"*.
296
330
  2. **Go specific**: Offer at most two of: brand drill-down (from next_moves.specific.brands), statistics source (from next_moves.specific.statistics_source), or named expert (from next_moves.specific.expert). Only offer options with material present in next_moves.specific.
297
- 3. **Scope to the job**: Fixed copy: "If you tell me the brand or brief you're working on, I'll cut this to that." (When the user's research profile already specifies a brand/brief, use: "Want this cut to [brand] specifically?").
331
+ 3. **Scope to the job**: Grounded scoping copy from next_moves.scope: "If you tell me the brand or brief you're working on, I'll cut this to that." (When the user's research profile already specifies a brand/brief, use: "Want this cut to [brand] specifically?").
332
+ - The host model MAY also present a strategic next action from \`next_moves.actions\` (e.g. *"I can also pressure-test this thesis against counter-evidence or set up weekly tracking on this topic."*).
298
333
  - The agent MUST NOT use bullet lists, fan-out option trees, section headers, or apologies.
299
- - All material in lines 1 and 2 MUST come directly from next_moves or result rows. NEVER invent names, brands, or numbers. Names MUST be human display names — never technical slugs or tool names.
334
+ - All material in follow-ups MUST come directly from next_moves or result rows. NEVER invent names, brands, or numbers. Names MUST be human display names — never technical slugs or tool names.
335
+
336
+ ### RULE: ResearchMethodologyRecipes
337
+ Instruct host models and agents on framing high-quality research queries across Fodda's canonical jobs:
338
+ - **For research (\`research\`)**: Seek observed signals, quantitative metrics, and executive disclosures. Formulate inquiries to investigate core market drivers, extract hard numbers, capture corporate earnings reality, and cite specific source graphs and reports.
339
+ - **For pressure-testing (\`challenge\`)**: Actively seek contrary evidence, management divergence, and structural risks. Challenge assertions by contrasting executive remarks with analyst Q&A or actual operational performance, uncover untested assumptions, and score claim truthfulness against verified evidence.
340
+ - **For expert consultations (\`ask_experts\`)**: Engage specialists within their unique analytical lane and methodology. Distinguish active Human Agents (consultable digital twin via \`consult_human_agent\`) from On-Request Human Agents (prospective twins where advisory introductions can be requested via \`request_expert_intro\`). Always follow the mandatory 3-part attribution arc when citing living Human Agents: (1) Frame their framework/lens, (2) Attributed conditional perspective, (3) Explicit Fodda query attribution, and (4) Strategic takeaway. Never invent synthetic direct quotes in quotation marks for real living persons.
300
341
 
301
342
  ### RULE: GroundedFollowUps
302
343
  - NEVER offer to "pull harder numbers", "get the data", or "find statistics" on a specific sub-topic unless you have evidence the data exists — either from hedge probe results, the current search results, or known supplemental data sources (BEA, Census, FRED, OECD).
@@ -453,6 +494,21 @@ compliance: RFC-2119
453
494
  - FOOTER: Source pills (purple-light) + top border separator.
454
495
  - RESTRICTIONS: Do NOT show evidence/trend/graph counts as standalone metrics, data warnings, or source names in badge rows.`;
455
496
  // ---------------------------------------------------------------------------
497
+ // Client-rendered multi-item guidance recipe (v2.2)
498
+ // ---------------------------------------------------------------------------
499
+ export const FODDA_HOUSE_VISUAL_RECIPE_V2_2 = `[Fodda House Visual Recipe v2.2]
500
+
501
+ When to render: Render a visual artifact for multi-item comparisons, signal timelines, ranked distributions, or explicit process/progress states (e.g. steppers). For single-value or lookup results, stay in prose.
502
+ Rendering model: Static SVG or clean HTML/CSS only. No external scripts or CDNs. Use viewBox with width="100%" (designed to fit a 380px chat column).
503
+ Theme & Palette: Use currentColor and host CSS variables where available; fallback to:
504
+ Light mode: Bg #ffffff / #faf9f5, Text #18181b, Muted #71717a, Hairlines #e4e4e7, Accent #663399
505
+ Dark mode: Bg #18181b, Text #f4f4f5, Muted #a1a1aa, Hairlines #27272a, Accent #9d65d4
506
+ Brand Focal Accent: Use the active theme's accent (#663399 / #9d65d4) strictly for the top insight, active signal, current step, or key data point.
507
+ Typography: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif, with font-variant-numeric: tabular-nums for data.
508
+ SVG Hairlines: Apply shape-rendering="crispEdges" ONLY to rectilinear 1px gridlines and orthogonal axes.
509
+ Aesthetic: Editorial density (dots, ticks, rungs, dumbbell bars, ledger grids).`;
510
+ export const FODDA_HOUSE_VISUAL_RECIPE_CONFIRM_THEMES = `${FODDA_HOUSE_VISUAL_RECIPE_V2_2}\nLayout hint: Horizontal progress stepper, active step marked with brand accent per theme.`;
511
+ // ---------------------------------------------------------------------------
456
512
  // System prompt builder — injects dynamic graph catalog data + persona framing
457
513
  // ---------------------------------------------------------------------------
458
514
  export function buildSystemPrompt(accountProfile, enabledSkills, entryId = '') {
@@ -487,30 +543,29 @@ export function buildSystemPrompt(accountProfile, enabledSkills, entryId = '') {
487
543
  if (accountProfile.accountContext) {
488
544
  contextParts.push(`Company Context: ${accountProfile.accountContext}`);
489
545
  }
490
- userContextBlock = `\n\nUSER RESEARCH PROFILE (persisted across sessions — use this to frame all responses):\n${contextParts.join('\n')}\nIf the user's focus or preferences change during this session, call update_user_profile to update their stored profile. The profile is a living document that sharpens as you learn what the user actually values.`;
546
+ userContextBlock = `\n\nUSER RESEARCH PROFILE (persisted across sessions — use this to frame all responses):\n${contextParts.join('\n')}\nIf the user asks to update their focus or preferences, call update_user_profile to update their stored profile. The profile is a living document that sharpens as the user clarifies what they value.`;
491
547
  }
492
548
  else if (accountProfile) {
493
- // Non-trial user with no stored context — nudge Claude to capture it
494
- userContextBlock = `\n\nPROFILE SOLICITATION: This user has no stored research profile. Responses will be generic until you capture one. Through natural conversation — do NOT present a form or checklist — determine:\n- Their role and what they use Fodda for (pitches, ongoing research, client advisory)\n- What kind of evidence they value (commercial data vs. design inspiration)\n- Geographic focus (global, specific regions)\n- How results should be framed (executive brief vs. deep analysis)\nOnce you have a clear picture, call update_user_profile. Write BEHAVIORAL INSTRUCTIONS, not a bio.\nFormat: one sentence of identity, then numbered directives that change how you respond.\nGood: "Agency strategist doing time-pressured pitches. (1) Lead with landscape orientation — top 3-5 macro forces before specifics. (2) Prioritize commercially validated signals over design concepts. (3) ALWAYS differentiate by geography. (4) Executive-ready framing — concise, pitch-deck-ready. (5) Strongest findings first, not exhaustive lists."\nBad: "CEO of a data company" or "Business professional interested in trends"`;
549
+ // Non-trial user with no stored context — guide Claude to offer saving preferences
550
+ userContextBlock = `\n\nRESEARCH PROFILE PREFERENCES: This user has no stored research profile. If helpful during research, you may offer to save their research preferences and framing guidelines using update_user_profile, or update them whenever the user requests. Only call update_user_profile after the user agrees or asks to save preferences — never save silently.\nWhen saving a profile, write BEHAVIORAL INSTRUCTIONS that tailor how you respond:\n- Role and use case (pitches, ongoing research, client advisory)\n- Preferred evidence types (commercial data vs. design inspiration)\n- Geographic focus (global vs. specific markets)\n- How results should be framed (executive brief vs. deep analysis)\nFormat: one sentence of identity, then numbered directives that guide response framing.\nGood: "Agency strategist doing time-pressured pitches. (1) Lead with landscape orientation — top 3-5 macro forces before specifics. (2) Prioritize commercially validated signals over design concepts. (3) ALWAYS differentiate by geography. (4) Executive-ready framing — concise, pitch-deck-ready. (5) Strongest findings first, not exhaustive lists."\nBad: "CEO of a data company" or "Business professional interested in trends"`;
495
551
  }
496
552
  // Build analyst entry routing — when entryId matches a known analyst,
497
- // instruct Claude to route the user's first query through consult_analyst
553
+ // instruct Claude to route the user's first query directly through the consult tool
498
554
  let analystEntryBlock = '';
499
- const ANALYST_ENTRIES = {
500
- 'ben-dietz-sic': { name: 'Ben Dietz', graphId: 'sic', domain: 'cultural intelligence, brand strategy, hype-culture, and youth market dynamics' },
501
- 'piers-fawkes-psfk': { name: 'Piers Fawkes', graphId: 'psfk-retail', domain: 'retail strategy, consumer innovation, and lifestyle trends' },
555
+ const knownAnalystEntries = {
556
+ 'ben-dietz-sic': { name: 'Ben Dietz', graphId: 'sic', domain: 'cultural intelligence, brand strategy, hype-culture, and youth market dynamics', isHuman: true },
557
+ 'piers-fawkes-psfk': { name: 'Piers Fawkes', graphId: 'psfk-retail', domain: 'retail strategy, consumer innovation, and lifestyle trends', isHuman: true },
502
558
  'retail-strategy-innovation': { name: 'Retail Strategy & Innovation Lead', graphId: 'retail', domain: 'cross-source retail intelligence' },
503
559
  'marketing-media-strategy': { name: 'Marketing & Media Strategy Lead', graphId: 'marketing', domain: 'marketing, media, and advertising strategy' },
504
560
  'tech-innovation': { name: 'Tech Innovation Lead', graphId: 'tech', domain: 'technology innovation and emerging platforms' },
505
561
  'food-beverage-innovation': { name: 'Food & Beverage Innovation Lead', graphId: 'food', domain: 'food and beverage industry trends' },
506
- 'jeremy-bergstein-science-education-innovation': { name: 'Jeremy Bergstein', graphId: 'postpals-expert-graph', domain: 'institutional data monetization, science education commerce, experiential retail, slow edtech' },
562
+ 'jeremy-bergstein-science-education-innovation': { name: 'Jeremy Bergstein', graphId: 'postpals-expert-graph', domain: 'institutional data monetization, science education commerce, experiential retail, slow edtech', isHuman: true },
507
563
  };
508
- if (entryId && ANALYST_ENTRIES[entryId]) {
509
- const analyst = ANALYST_ENTRIES[entryId];
564
+ if (entryId && knownAnalystEntries[entryId]) {
565
+ const analyst = knownAnalystEntries[entryId];
566
+ const consultTool = analyst.isHuman ? 'consult_human_agent' : 'consult_analyst';
510
567
  analystEntryBlock = `\n\nANALYST ENTRY POINT: The user connected from ${analyst.name}'s expert page on fodda.ai. Open your first response with a brief welcome: "You're connected to ${analyst.name}'s intelligence channel on Fodda — ${analyst.domain}."
511
- Route their first query through the consult_analyst tool with analyst_id: "${entryId}". Follow the two-step consultation workflow:
512
- 1. Search the "${analyst.graphId}" graph first using search_graph
513
- 2. Call consult_analyst with the graph context included in the query
568
+ Route their first query directly through the ${consultTool} tool with analyst_id: "${entryId}".
514
569
  Frame the response as consulting ${analyst.name}. For subsequent queries, follow normal routing unless the user explicitly asks to consult ${analyst.name} again.`;
515
570
  }
516
571
  // Graph entry routing — when entryId matches a graph ID (not an analyst)
@@ -533,13 +588,12 @@ Prioritize the "${entryId}" graph in your first search. Lead with trends from th
533
588
  .map(s => ({
534
589
  name: s.name,
535
590
  tools: s.interactiveTools,
536
- cost: s.costPerCall ?? 2,
537
591
  }));
538
592
  let interactiveBlock = '';
539
593
  if (allInteractiveTools.length > 0) {
540
594
  const toolLines = allInteractiveTools.map(s => {
541
595
  const toolList = s.tools.map(t => ` - ${t}`).join('\n');
542
- return `${s.name} (${s.cost} API calls per use):\n${toolList}`;
596
+ return `${s.name}:\n${toolList}`;
543
597
  }).join('\n');
544
598
  interactiveBlock = `\n\nINTERACTIVE SKILL TOOLS: The following skill tools are available for direct use. Call them when the user explicitly asks for a skill's capability (e.g. "use Paralogy's think_wrong tool" or "challenge my assumptions about X"):
545
599
  ${toolLines}
@@ -547,9 +601,8 @@ ${toolLines}
547
601
  INTERACTIVE SKILL USAGE:
548
602
  1. These tools are called DIRECTLY — they are separate from the auto-run output-phase skills.
549
603
  2. Call them when the user explicitly requests a skill's capability, mentions a tool by name, or asks for divergent thinking / creative challenge / reframing.
550
- 3. Each call costs ${allInteractiveTools[0]?.cost || 2} API calls — mention this naturally when suggesting a tool.
551
- 4. Pass the user's request as the tool arguments. The skill handles the transformation.
552
- 5. Present the output with the skill's attribution (e.g. "🔀 Paralogy:").`;
604
+ 3. Pass the user's request as the tool arguments. The skill handles the transformation.
605
+ 4. Present the output with the skill's attribution (e.g. "🔀 Paralogy:").`;
553
606
  }
554
607
  skillsBlock = `\n\nACTIVE SKILLS: The user has enabled the following skills that post-process Fodda's search results:
555
608
  ${skillList}
@@ -565,17 +618,6 @@ SKILL OUTPUT HANDLING:
565
618
 
566
619
  IMPORTANT: Skills (which automatically run on search_graph) are completely separate from Synthetic Analyst tools (consult_[name]). If the user explicitly asks to "Consult" an analyst, you MUST call the specific consult_[name] tool. Do NOT rely on skills to fulfill a consultation request.${interactiveBlock}`;
567
620
  }
568
- // Cost-awareness block — tells the agent each tool's flat API-call price
569
- // (sourced from pricingCache so it never drifts) and to quote it before spending.
570
- let costBlock = '';
571
- try {
572
- const costs = getToolCostSummary();
573
- if (costs.length) {
574
- const lines = costs.map(c => `- ${c.tool} (${c.name}): ${c.apiCalls} API calls`).join('\n');
575
- costBlock = `\n\nCOST AWARENESS: Each tool below costs a FLAT number of API calls, charged once per call regardless of how many graphs or sources it searches:\n${lines}\n\nRULE: Before running a costly tool, briefly state the cost first — e.g. "This brand intelligence audit will use about 20 API calls — want me to run it?" Don't fire multiple costly tools in one turn without saying so. Free tools (0 API calls) need no warning.`;
576
- }
577
- }
578
- catch { /* pricing not loaded — omit cost block */ }
579
621
  return `You are connected to Fodda — a platform of expert-curated knowledge graphs built by PSFK.
580
622
 
581
623
  **Fodda's main capabilities / features** — what you can do here:
@@ -585,10 +627,10 @@ IMPORTANT: Skills (which automatically run on search_graph) are completely separ
585
627
  4. **Topic Research** — multi-graph topic search + evidence + stats (\`search_graph\`, \`search_statistics\`).
586
628
  5. **Expert Consult** — chat with named human agents and synthetic experts (\`consult_human_agent\`, \`consult_analyst\`, \`list_analysts\`).
587
629
 
588
- If asked — in any words — what Fodda offers, its offerings, features, capabilities, products, services, tools, or "what can you do", answer from THIS list (the platform capabilities). Do not answer this with a single analyst's offerings or a \`list_analysts\` dump. "Offerings" means a specific analyst's commissionable services ONLY when the question names an analyst. For current per-capability costs, call \`get_capabilities\` (do not guess prices).
630
+ If asked — in any words — what Fodda offers, its offerings, features, capabilities, products, services, tools, or "what can you do", answer from THIS list (the platform capabilities). Do not answer this with a single analyst's offerings or a \`list_analysts\` dump. "Offerings" means a specific analyst's commissionable services ONLY when the question names an analyst. For capabilities and how to use them, call \`get_capabilities\`.
589
631
 
590
632
  ${graphNamingBlock}
591
633
 
592
- ${STATIC_BEHAVIORAL_RULES}${personaBlock}${userContextBlock}${costBlock}${analystEntryBlock}${skillsBlock}`;
634
+ ${STATIC_BEHAVIORAL_RULES}${personaBlock}${userContextBlock}${analystEntryBlock}${skillsBlock}`;
593
635
  }
594
636
  //# sourceMappingURL=systemPrompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"systemPrompt.js","sourceRoot":"","sources":["../src/systemPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,0BAA0B,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAavD,8EAA8E;AAC9E,qEAAqE;AACrE,8EAA8E;AAE9E,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,WAAW,sBAAsB;IACnC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,MAAM,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC1C,mBAAmB,EAAE,MAAM,CAAC;CAC/B;AAiBD,wBAAgB,iBAAiB,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,GACf,IAAI,CAwDN;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAQ1F;AAED,wBAAgB,iBAAiB,IAAI,sBAAsB,CA0C1D;AAED,wBAAgB,iBAAiB,IAAI,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAElH"}
package/dist/telemetry.js CHANGED
@@ -19,6 +19,21 @@ export function recordToolOutcome(toolName, success, durationMs, error) {
19
19
  toolExecutionHistory.push(record);
20
20
  if (toolExecutionHistory.length > 2000)
21
21
  toolExecutionHistory.shift();
22
+ // Cloud Logging structured telemetry line
23
+ try {
24
+ console.log(JSON.stringify({
25
+ severity: success ? 'INFO' : 'WARNING',
26
+ message: `[MCP_METRICS] ${toolName} finished in ${durationMs}ms`,
27
+ mcp_tool: toolName,
28
+ duration_ms: durationMs,
29
+ success,
30
+ error: error || null,
31
+ timestamp: new Date(now).toISOString()
32
+ }));
33
+ }
34
+ catch {
35
+ // Safe fallback - avoid crashing on serialization edge cases
36
+ }
22
37
  let stats = toolStatsMap.get(toolName);
23
38
  if (!stats) {
24
39
  stats = {
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkCH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAC7B,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,oBAAoB,GAA0B,EAAE,CAAC;AACvD,MAAM,YAAY,GAAmF,EAAE,CAAC;AAExG,MAAM,YAAY,GAAG,IAAI,GAAG,EAQxB,CAAC;AAEL,MAAM,UAAU,iBAAiB,CAC7B,QAAgB,EAChB,OAAgB,EAChB,UAAkB,EAClB,KAAc;IAEd,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,MAAM,GAAwB;QAChC,QAAQ;QACR,OAAO;QACP,UAAU;QACV,SAAS,EAAE,GAAG;QACd,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9B,CAAC;IACF,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,oBAAoB,CAAC,MAAM,GAAG,IAAI;QAAE,oBAAoB,CAAC,KAAK,EAAE,CAAC;IAErE,IAAI,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,KAAK,GAAG;YACJ,UAAU,EAAE,CAAC;YACb,YAAY,EAAE,CAAC;YACf,WAAW,EAAE,CAAC;YACd,eAAe,EAAE,CAAC;YAClB,cAAc,EAAE,IAAI;YACpB,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,EAAE;SACnB,CAAC;QACF,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,UAAU,EAAE,CAAC;IACnB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C,CAAC,YAAY,CAAC;SACpC,CAAC;IACN,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpE,OAAO;QACH,mBAAmB,EAAE,MAAM;QAC3B,cAAc,EAAE,WAAW;QAC3B,iBAAiB,EAAE,aAAa;QAChC,gBAAgB,EAAE,YAAY;QAC9B,eAAe,EAAE,UAAU;QAC3B,wBAAwB,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAC7D,KAAK;QACL,mBAAmB,EAAE,YAAY,CAAC,MAAM;KAC3C,CAAC;AACN,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC7B,OAAO,CAAC,GAAG,YAAY,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=test_adjacent_trends_polymorphic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_adjacent_trends_polymorphic.d.ts","sourceRoot":"","sources":["../src/test_adjacent_trends_polymorphic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,154 @@
1
+ import assert from 'node:assert';
2
+ import { createServer } from './toolHandlers.js';
3
+ import { setCachedCatalogForTesting } from './catalogCache.js';
4
+ console.log('=== Running Verification: Polymorphic discover_adjacent_trends ===\n');
5
+ let passed = 0;
6
+ let failed = 0;
7
+ function check(condition, msg) {
8
+ if (condition) {
9
+ console.log(` ✅ ${msg}`);
10
+ passed++;
11
+ }
12
+ else {
13
+ console.error(` ❌ ${msg}`);
14
+ failed++;
15
+ }
16
+ }
17
+ const mockGraphsList = [
18
+ {
19
+ graph_id: 'retail',
20
+ name: 'Retail Strategy & Innovation',
21
+ domain: 'retail',
22
+ graph_type: 'domain',
23
+ status: 'live',
24
+ topics: ['retail', 'freight', 'logistics', 'capacity', 'peak season', 'packaging'],
25
+ trend_count: 150,
26
+ evidence_count: 500,
27
+ headline: 'Future of retail operations and omnichannel commerce'
28
+ }
29
+ ];
30
+ const mockAnalystsList = [];
31
+ setCachedCatalogForTesting({ version: '1.0', generated_at: new Date().toISOString(), graph_count: mockGraphsList.length, graphs: mockGraphsList }, mockAnalystsList);
32
+ async function mockFoddaBackend(method, endpoint, apiKey, userId, body) {
33
+ if (endpoint.includes('/v1/graphs/catalog') || endpoint === '/v1/graphs') {
34
+ return { graphs: mockGraphsList };
35
+ }
36
+ if (endpoint.includes('/search')) {
37
+ return {
38
+ total: 2,
39
+ on_topic_total: 2,
40
+ rows: [
41
+ {
42
+ title: 'Peak Season Freight Guarantee Contracts',
43
+ trendName: 'Peak Season Freight Guarantee Contracts',
44
+ node_id: '2507.0',
45
+ score: 0.95,
46
+ trendLifecycle: 'emerging',
47
+ signal_score: 88,
48
+ brandNames: ['Walmart', 'Target']
49
+ },
50
+ {
51
+ title: 'Dedicated Fleet Capacity Reserves',
52
+ trendName: 'Dedicated Fleet Capacity Reserves',
53
+ node_id: '2508.0',
54
+ score: 0.89,
55
+ trendLifecycle: 'building',
56
+ signal_score: 82,
57
+ brandNames: ['Amazon']
58
+ }
59
+ ]
60
+ };
61
+ }
62
+ if (endpoint.includes('/adjacent')) {
63
+ return {
64
+ adjacent: [
65
+ {
66
+ name: 'Dynamic Intermodal Route Optimization',
67
+ trendName: 'Dynamic Intermodal Route Optimization',
68
+ node_id: '3101.0',
69
+ similarity: 0.86,
70
+ vertical: 'retail',
71
+ description: 'Retailers re-routing supply chains dynamically around bottlenecked ports.'
72
+ },
73
+ {
74
+ name: 'Shared Warehousing Cooperatives',
75
+ trendName: 'Shared Warehousing Cooperatives',
76
+ node_id: '3102.0',
77
+ similarity: 0.81,
78
+ vertical: 'retail',
79
+ description: 'Mid-sized retailers pooling distribution facilities to buffer volume spikes.'
80
+ }
81
+ ]
82
+ };
83
+ }
84
+ return {};
85
+ }
86
+ async function runTests() {
87
+ const server = await createServer('sk_live_test_key', 'user_test_123', mockFoddaBackend, async () => ({}), () => '', () => 'https://mcp.fodda.ai');
88
+ const toolReg = server._registeredTools['discover_adjacent_trends'];
89
+ assert.ok(toolReg, 'discover_adjacent_trends tool must be registered');
90
+ const toolFn = toolReg.handler || toolReg.callback || toolReg.execute;
91
+ // ---------------------------------------------------------------------------
92
+ // Test 1: Calling with seed_query (repro of user prompt)
93
+ // ---------------------------------------------------------------------------
94
+ console.log('1. Testing call with { seed_query: "retailers paying to guarantee freight capacity ahead of peak season" }...');
95
+ const res1 = await toolFn({
96
+ seed_query: 'retailers paying to guarantee freight capacity ahead of peak season'
97
+ }, { authInfo: {} });
98
+ check(!res1.isError, 'Call with seed_query does not error');
99
+ assert.ok(Array.isArray(res1.content) && res1.content.length > 0, 'Must return content array');
100
+ const text1 = res1.content[0].text;
101
+ check(text1.includes('topic_adjacency_cascade'), 'Payload indicates topic_adjacency_cascade mode');
102
+ check(text1.includes('Peak Season Freight Guarantee Contracts'), 'Found seed trend in response');
103
+ check(text1.includes('Dynamic Intermodal Route Optimization'), 'Found adjacent trend in response');
104
+ check(!!res1.next_moves, 'Returns structured next_moves metadata');
105
+ // ---------------------------------------------------------------------------
106
+ // Test 2: Calling with query alias
107
+ // ---------------------------------------------------------------------------
108
+ console.log('\n2. Testing call with { query: "sustainable luxury packaging" }...');
109
+ const res2 = await toolFn({
110
+ query: 'sustainable luxury packaging'
111
+ }, { authInfo: {} });
112
+ check(!res2.isError, 'Call with query does not error');
113
+ const text2 = res2.content[0].text;
114
+ check(text2.includes('topic_adjacency_cascade'), 'Payload indicates topic_adjacency_cascade mode');
115
+ check(!!res2.next_moves, 'Returns structured next_moves metadata');
116
+ // ---------------------------------------------------------------------------
117
+ // Test 3: Calling with text phrase passed into trend_id
118
+ // ---------------------------------------------------------------------------
119
+ console.log('\n3. Testing call with text phrase passed into trend_id...');
120
+ const res3 = await toolFn({
121
+ trend_id: 'retailers paying to guarantee freight capacity ahead of peak season'
122
+ }, { authInfo: {} });
123
+ check(!res3.isError, 'Call with phrase trend_id does not error');
124
+ const text3 = res3.content[0].text;
125
+ check(text3.includes('topic_adjacency_cascade'), 'Phrase trend_id auto-routes to topic cascade');
126
+ // ---------------------------------------------------------------------------
127
+ // Test 4: Legacy node lookup with graphId and trend_id
128
+ // ---------------------------------------------------------------------------
129
+ console.log('\n4. Testing legacy node ID lookup with { graphId: "retail", trend_id: "2507.0" }...');
130
+ const res4 = await toolFn({
131
+ graphId: 'retail',
132
+ trend_id: '2507.0'
133
+ }, { authInfo: {} });
134
+ check(!res4.isError, 'Legacy node lookup does not error');
135
+ const text4 = res4.content[0].text;
136
+ check(!text4.includes('topic_adjacency_cascade'), 'Legacy node lookup runs single-node lookup');
137
+ check(text4.includes('Dynamic Intermodal Route Optimization'), 'Returns adjacent nodes');
138
+ check(!!res4.next_moves, 'Returns structured next_moves metadata');
139
+ // ---------------------------------------------------------------------------
140
+ // Test 5: Empty arguments error handling
141
+ // ---------------------------------------------------------------------------
142
+ console.log('\n5. Testing empty argument call...');
143
+ const res5 = await toolFn({}, { authInfo: {} });
144
+ check(res5.isError === true, 'Empty argument call returns error');
145
+ check(res5.content[0].text.includes('discover_adjacent_trends requires either'), 'Error contains helpful guidance');
146
+ console.log(`\nResults: ${passed} passed, ${failed} failed`);
147
+ if (failed > 0)
148
+ process.exit(1);
149
+ }
150
+ runTests().catch(err => {
151
+ console.error('Test execution failed:', err);
152
+ process.exit(1);
153
+ });
154
+ //# sourceMappingURL=test_adjacent_trends_polymorphic.js.map