project-graph-mcp 2.3.2 → 2.4.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 (279) hide show
  1. package/package.json +3 -2
  2. package/src/analysis/analysis-cache.ctx +9 -0
  3. package/src/analysis/analysis-cache.js +1 -1
  4. package/src/analysis/complexity.ctx +6 -0
  5. package/src/analysis/complexity.js +1 -1
  6. package/src/analysis/custom-rules.ctx +14 -0
  7. package/src/analysis/custom-rules.js +1 -1
  8. package/src/analysis/db-analysis.ctx +7 -0
  9. package/src/analysis/db-analysis.js +1 -1
  10. package/src/analysis/dead-code.ctx +6 -0
  11. package/src/analysis/dead-code.js +1 -1
  12. package/src/analysis/full-analysis.ctx +9 -0
  13. package/src/analysis/full-analysis.js +1 -1
  14. package/src/analysis/jsdoc-checker.ctx +10 -0
  15. package/src/analysis/jsdoc-checker.js +1 -1
  16. package/src/analysis/jsdoc-generator.ctx +9 -0
  17. package/src/analysis/jsdoc-generator.js +1 -1
  18. package/src/analysis/large-files.ctx +6 -0
  19. package/src/analysis/large-files.js +1 -1
  20. package/src/analysis/outdated-patterns.ctx +7 -0
  21. package/src/analysis/outdated-patterns.js +1 -1
  22. package/src/analysis/similar-functions.ctx +6 -0
  23. package/src/analysis/similar-functions.js +1 -1
  24. package/src/analysis/test-annotations.ctx +11 -0
  25. package/src/analysis/test-annotations.js +1 -1
  26. package/src/analysis/type-checker.ctx +6 -0
  27. package/src/analysis/type-checker.js +1 -1
  28. package/src/analysis/undocumented.ctx +8 -0
  29. package/src/analysis/undocumented.js +1 -1
  30. package/src/cli/cli-handlers.ctx +7 -0
  31. package/src/cli/cli-handlers.js +1 -1
  32. package/src/cli/cli.ctx +6 -0
  33. package/src/cli/cli.js +1 -1
  34. package/src/compact/ai-context.ctx +6 -0
  35. package/src/compact/ai-context.js +1 -1
  36. package/src/compact/compact-migrate.ctx +8 -0
  37. package/src/compact/compact-migrate.js +1 -1
  38. package/src/compact/compact.ctx +11 -0
  39. package/src/compact/compact.js +1 -1
  40. package/src/compact/compress.ctx +7 -0
  41. package/src/compact/compress.js +1 -1
  42. package/src/compact/ctx-resolver.ctx +2 -0
  43. package/src/compact/ctx-resolver.js +1 -1
  44. package/src/compact/ctx-to-jsdoc.ctx +11 -0
  45. package/src/compact/ctx-to-jsdoc.js +1 -1
  46. package/src/compact/doc-dialect.ctx +11 -0
  47. package/src/compact/doc-dialect.js +2 -2
  48. package/src/compact/expand.ctx +14 -0
  49. package/src/compact/expand.js +1 -1
  50. package/src/compact/framework-references.ctx +7 -0
  51. package/src/compact/framework-references.js +1 -1
  52. package/src/compact/instructions.ctx +6 -0
  53. package/src/compact/instructions.js +1 -1
  54. package/src/compact/jsdoc-builder.ctx +4 -0
  55. package/src/compact/jsdoc-builder.js +1 -1
  56. package/src/compact/mode-config.ctx +8 -0
  57. package/src/compact/mode-config.js +1 -1
  58. package/src/compact/split-declarations.ctx +6 -0
  59. package/src/compact/split-declarations.js +1 -1
  60. package/src/compact/validate-pipeline.ctx +12 -0
  61. package/src/compact/validate-pipeline.js +1 -1
  62. package/src/core/event-bus.ctx +9 -0
  63. package/src/core/event-bus.js +1 -1
  64. package/src/core/file-walker.ctx +1 -0
  65. package/src/core/file-walker.js +1 -1
  66. package/src/core/filters.ctx +12 -0
  67. package/src/core/filters.js +1 -1
  68. package/src/core/graph-builder.ctx +7 -0
  69. package/src/core/graph-builder.js +1 -1
  70. package/src/core/parser.ctx +12 -0
  71. package/src/core/parser.js +1 -1
  72. package/src/core/utils.ctx +1 -0
  73. package/src/core/utils.js +1 -1
  74. package/src/core/workspace.ctx +7 -0
  75. package/src/core/workspace.js +1 -1
  76. package/src/lang/lang-go.ctx +8 -0
  77. package/src/lang/lang-go.js +1 -1
  78. package/src/lang/lang-python.ctx +5 -0
  79. package/src/lang/lang-python.js +1 -1
  80. package/src/lang/lang-sql.ctx +10 -0
  81. package/src/lang/lang-sql.js +1 -1
  82. package/src/lang/lang-typescript.ctx +6 -0
  83. package/src/lang/lang-typescript.js +1 -1
  84. package/src/lang/lang-utils.ctx +5 -0
  85. package/src/lang/lang-utils.js +1 -1
  86. package/src/mcp/mcp-server.ctx +6 -0
  87. package/src/mcp/mcp-server.js +1 -1
  88. package/src/mcp/tool-defs.ctx +2 -0
  89. package/src/mcp/tool-defs.js +1 -1
  90. package/src/mcp/tools.ctx +13 -0
  91. package/src/mcp/tools.js +1 -1
  92. package/src/network/backend-lifecycle.ctx +10 -0
  93. package/src/network/backend-lifecycle.js +1 -1
  94. package/src/network/backend.ctx +5 -0
  95. package/src/network/backend.js +1 -1
  96. package/src/network/local-gateway.ctx +9 -0
  97. package/src/network/local-gateway.js +1 -1
  98. package/src/network/mdns.ctx +6 -0
  99. package/src/network/mdns.js +1 -1
  100. package/src/network/server.ctx +2 -0
  101. package/src/network/server.js +2 -2
  102. package/src/network/web-server.ctx +17 -0
  103. package/src/network/web-server.js +2 -2
  104. package/web/follow-controller.js +94 -25
  105. package/web/panels/dep-graph.js +207 -21
  106. package/project-graph-mcp-2.3.0.tgz +0 -0
  107. package/vendor/symbiote-node/CHANGELOG.md +0 -31
  108. package/vendor/symbiote-node/LICENSE +0 -21
  109. package/vendor/symbiote-node/README.md +0 -206
  110. package/vendor/symbiote-node/canvas/AutoLayout.js +0 -725
  111. package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.css.js +0 -73
  112. package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.js +0 -93
  113. package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.tpl.js +0 -9
  114. package/vendor/symbiote-node/canvas/CanvasConnectionRenderer.js +0 -962
  115. package/vendor/symbiote-node/canvas/ConnectionRenderer.js +0 -1468
  116. package/vendor/symbiote-node/canvas/FlowSimulator.js +0 -323
  117. package/vendor/symbiote-node/canvas/ForceLayout.js +0 -189
  118. package/vendor/symbiote-node/canvas/ForceWorker.js +0 -1325
  119. package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.css.js +0 -97
  120. package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.js +0 -176
  121. package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.tpl.js +0 -12
  122. package/vendor/symbiote-node/canvas/LODManager.js +0 -88
  123. package/vendor/symbiote-node/canvas/Minimap/Minimap.css.js +0 -71
  124. package/vendor/symbiote-node/canvas/Minimap/Minimap.js +0 -207
  125. package/vendor/symbiote-node/canvas/Minimap/Minimap.tpl.js +0 -9
  126. package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.css.js +0 -261
  127. package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.js +0 -1840
  128. package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.tpl.js +0 -22
  129. package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.css.js +0 -97
  130. package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.js +0 -132
  131. package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.tpl.js +0 -21
  132. package/vendor/symbiote-node/canvas/NodeViewManager.js +0 -584
  133. package/vendor/symbiote-node/canvas/PinExpansion.js +0 -131
  134. package/vendor/symbiote-node/canvas/PseudoConnection.js +0 -80
  135. package/vendor/symbiote-node/canvas/SubgraphManager.js +0 -201
  136. package/vendor/symbiote-node/canvas/SubgraphRouter.js +0 -443
  137. package/vendor/symbiote-node/canvas/ViewportActions.js +0 -446
  138. package/vendor/symbiote-node/core/Connection.js +0 -45
  139. package/vendor/symbiote-node/core/Editor.js +0 -451
  140. package/vendor/symbiote-node/core/Frame.js +0 -31
  141. package/vendor/symbiote-node/core/GraphMermaid.js +0 -348
  142. package/vendor/symbiote-node/core/GraphText.js +0 -210
  143. package/vendor/symbiote-node/core/Node.js +0 -143
  144. package/vendor/symbiote-node/core/Portal.js +0 -104
  145. package/vendor/symbiote-node/core/Socket.js +0 -185
  146. package/vendor/symbiote-node/core/SubgraphNode.js +0 -125
  147. package/vendor/symbiote-node/engine/AgentUICommands.js +0 -100
  148. package/vendor/symbiote-node/engine/Executor.js +0 -371
  149. package/vendor/symbiote-node/engine/Graph.js +0 -314
  150. package/vendor/symbiote-node/engine/GraphServer.js +0 -353
  151. package/vendor/symbiote-node/engine/HandlerLoader.js +0 -145
  152. package/vendor/symbiote-node/engine/History.js +0 -83
  153. package/vendor/symbiote-node/engine/Lifecycle.js +0 -118
  154. package/vendor/symbiote-node/engine/Persistence.js +0 -84
  155. package/vendor/symbiote-node/engine/Registry.js +0 -264
  156. package/vendor/symbiote-node/engine/SocketTypes.js +0 -79
  157. package/vendor/symbiote-node/engine/cli.js +0 -404
  158. package/vendor/symbiote-node/engine/index.js +0 -56
  159. package/vendor/symbiote-node/engine/nanoid.js +0 -28
  160. package/vendor/symbiote-node/engine/package.json +0 -26
  161. package/vendor/symbiote-node/engine/packs/ai/beat-detect.handler.js +0 -215
  162. package/vendor/symbiote-node/engine/packs/ai/content-adapt.handler.js +0 -238
  163. package/vendor/symbiote-node/engine/packs/ai/face-detect.handler.js +0 -287
  164. package/vendor/symbiote-node/engine/packs/ai/grok-generate.handler.js +0 -565
  165. package/vendor/symbiote-node/engine/packs/ai/kling-lipsync.handler.js +0 -414
  166. package/vendor/symbiote-node/engine/packs/ai/lesson-generate.handler.js +0 -343
  167. package/vendor/symbiote-node/engine/packs/ai/opencode.handler.js +0 -164
  168. package/vendor/symbiote-node/engine/packs/ai/replicate-lipsync.handler.js +0 -341
  169. package/vendor/symbiote-node/engine/packs/ai/tts.handler.js +0 -241
  170. package/vendor/symbiote-node/engine/packs/ai/whisper.handler.js +0 -191
  171. package/vendor/symbiote-node/engine/packs/data/db-query.handler.js +0 -67
  172. package/vendor/symbiote-node/engine/packs/data/news-accumulate.handler.js +0 -281
  173. package/vendor/symbiote-node/engine/packs/data/personas.handler.js +0 -160
  174. package/vendor/symbiote-node/engine/packs/data/prompt-loader.handler.js +0 -193
  175. package/vendor/symbiote-node/engine/packs/data/roles.handler.js +0 -216
  176. package/vendor/symbiote-node/engine/packs/data/rss-feed.handler.js +0 -244
  177. package/vendor/symbiote-node/engine/packs/debug/inject.handler.js +0 -52
  178. package/vendor/symbiote-node/engine/packs/flow/agent.handler.js +0 -73
  179. package/vendor/symbiote-node/engine/packs/flow/if.handler.js +0 -107
  180. package/vendor/symbiote-node/engine/packs/flow/loop.handler.js +0 -58
  181. package/vendor/symbiote-node/engine/packs/flow/merge.handler.js +0 -60
  182. package/vendor/symbiote-node/engine/packs/flow/retry.handler.js +0 -65
  183. package/vendor/symbiote-node/engine/packs/flow/switch.handler.js +0 -64
  184. package/vendor/symbiote-node/engine/packs/flow/wait-all.handler.js +0 -39
  185. package/vendor/symbiote-node/engine/packs/io/http-request.handler.js +0 -82
  186. package/vendor/symbiote-node/engine/packs/io/read-file.handler.js +0 -60
  187. package/vendor/symbiote-node/engine/packs/io/write-file.handler.js +0 -63
  188. package/vendor/symbiote-node/engine/packs/transform/anchor-match.handler.js +0 -494
  189. package/vendor/symbiote-node/engine/packs/transform/effects-skeleton.handler.js +0 -417
  190. package/vendor/symbiote-node/engine/packs/transform/json-parse.handler.js +0 -43
  191. package/vendor/symbiote-node/engine/packs/transform/lipsync-select.handler.js +0 -339
  192. package/vendor/symbiote-node/engine/packs/transform/riopla-adapt.handler.js +0 -432
  193. package/vendor/symbiote-node/engine/packs/transform/set.handler.js +0 -57
  194. package/vendor/symbiote-node/engine/packs/transform/template-builder.handler.js +0 -134
  195. package/vendor/symbiote-node/engine/packs/transform/template.handler.js +0 -79
  196. package/vendor/symbiote-node/engine/packs/transform/timeline-build.handler.js +0 -399
  197. package/vendor/symbiote-node/engine/packs/util/delay.handler.js +0 -39
  198. package/vendor/symbiote-node/engine/packs/util/log.handler.js +0 -44
  199. package/vendor/symbiote-node/engine/packs/video-pack.js +0 -323
  200. package/vendor/symbiote-node/index.js +0 -103
  201. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.css.js +0 -361
  202. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.js +0 -332
  203. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.tpl.js +0 -96
  204. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.css.js +0 -104
  205. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.js +0 -133
  206. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.tpl.js +0 -33
  207. package/vendor/symbiote-node/interactions/ConnectFlow.js +0 -307
  208. package/vendor/symbiote-node/interactions/Drag.js +0 -102
  209. package/vendor/symbiote-node/interactions/Selector.js +0 -132
  210. package/vendor/symbiote-node/interactions/SnapGrid.js +0 -65
  211. package/vendor/symbiote-node/interactions/Zoom.js +0 -140
  212. package/vendor/symbiote-node/layout/ActionZone/ActionZone.css.js +0 -88
  213. package/vendor/symbiote-node/layout/ActionZone/ActionZone.js +0 -254
  214. package/vendor/symbiote-node/layout/ActionZone/ActionZone.tpl.js +0 -11
  215. package/vendor/symbiote-node/layout/Layout/Layout.css.js +0 -88
  216. package/vendor/symbiote-node/layout/Layout/Layout.js +0 -622
  217. package/vendor/symbiote-node/layout/Layout/Layout.tpl.js +0 -25
  218. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.css.js +0 -293
  219. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.js +0 -467
  220. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.tpl.js +0 -33
  221. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.css.js +0 -46
  222. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.js +0 -102
  223. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.tpl.js +0 -6
  224. package/vendor/symbiote-node/layout/LayoutRouter/LayoutRouter.js +0 -156
  225. package/vendor/symbiote-node/layout/LayoutRouter/routerSync.js +0 -250
  226. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.css.js +0 -379
  227. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.js +0 -263
  228. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.tpl.js +0 -20
  229. package/vendor/symbiote-node/layout/LayoutSidebar/SidebarSection.js +0 -183
  230. package/vendor/symbiote-node/layout/LayoutTree.js +0 -246
  231. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.css.js +0 -43
  232. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.js +0 -89
  233. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.tpl.js +0 -14
  234. package/vendor/symbiote-node/layout/index.js +0 -16
  235. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.css.js +0 -61
  236. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.js +0 -79
  237. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.tpl.js +0 -19
  238. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.css.js +0 -41
  239. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.js +0 -24
  240. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.tpl.js +0 -16
  241. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.css.js +0 -65
  242. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.js +0 -29
  243. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.tpl.js +0 -13
  244. package/vendor/symbiote-node/node/GraphNode/GraphNode.css.js +0 -683
  245. package/vendor/symbiote-node/node/GraphNode/GraphNode.js +0 -92
  246. package/vendor/symbiote-node/node/GraphNode/GraphNode.tpl.js +0 -17
  247. package/vendor/symbiote-node/node/NodeSocket/NodeSocket.js +0 -25
  248. package/vendor/symbiote-node/node/NodeSocket/NodeSocket.tpl.js +0 -7
  249. package/vendor/symbiote-node/node/PortItem/PortItem.css.js +0 -90
  250. package/vendor/symbiote-node/node/PortItem/PortItem.js +0 -87
  251. package/vendor/symbiote-node/node/PortItem/PortItem.tpl.js +0 -10
  252. package/vendor/symbiote-node/package.json +0 -59
  253. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.css.js +0 -143
  254. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.js +0 -131
  255. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.tpl.js +0 -16
  256. package/vendor/symbiote-node/plugins/History.js +0 -384
  257. package/vendor/symbiote-node/plugins/Readonly.js +0 -59
  258. package/vendor/symbiote-node/shapes/CircleShape.js +0 -80
  259. package/vendor/symbiote-node/shapes/CommentShape.js +0 -35
  260. package/vendor/symbiote-node/shapes/DiamondShape.js +0 -115
  261. package/vendor/symbiote-node/shapes/NodeShape.js +0 -80
  262. package/vendor/symbiote-node/shapes/PillShape.js +0 -91
  263. package/vendor/symbiote-node/shapes/RectShape.js +0 -72
  264. package/vendor/symbiote-node/shapes/SVGShape.js +0 -494
  265. package/vendor/symbiote-node/shapes/index.js +0 -53
  266. package/vendor/symbiote-node/themes/Palette.js +0 -32
  267. package/vendor/symbiote-node/themes/Skin.js +0 -113
  268. package/vendor/symbiote-node/themes/Theme.js +0 -84
  269. package/vendor/symbiote-node/themes/carbon.js +0 -137
  270. package/vendor/symbiote-node/themes/dark.js +0 -137
  271. package/vendor/symbiote-node/themes/ebook.js +0 -138
  272. package/vendor/symbiote-node/themes/grey.js +0 -137
  273. package/vendor/symbiote-node/themes/light.js +0 -137
  274. package/vendor/symbiote-node/themes/neon.js +0 -138
  275. package/vendor/symbiote-node/themes/pcb.js +0 -273
  276. package/vendor/symbiote-node/themes/synthwave.js +0 -137
  277. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.css.js +0 -86
  278. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.js +0 -128
  279. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.tpl.js +0 -29
@@ -1,215 +0,0 @@
1
- /**
2
- * ai/beat-detect — Audio beat detection via librosa (SSH)
3
- *
4
- * Analyzes audio files to extract:
5
- * - Beat timestamps and tempo (BPM)
6
- * - Waveform peaks (configurable resolution)
7
- * - Energy contour
8
- * - Quiet zones (silence detection)
9
- * - Strong onsets (transient detection)
10
- *
11
- * Uses Python librosa library on remote server via SSH.
12
- * Based on Mr-Computer/modules/ai-music-video beat-detector-ssh.js
13
- *
14
- * Remote: mr-agent@mr-agent.rnd-pro.com
15
- * Script: beat-detection.py (uploaded automatically)
16
- * Venv: /home/mr-agent/automations/argentine-spanish-bot/venv
17
- *
18
- * @module agi-graph/packs/ai/beat-detect
19
- */
20
-
21
- import { execSync } from 'child_process';
22
- import { promises as fs } from 'fs';
23
- import path from 'path';
24
- import os from 'os';
25
-
26
- export default {
27
- type: 'ai/beat-detect',
28
- category: 'ai',
29
- icon: 'graphic_eq',
30
-
31
- driver: {
32
- description: 'Audio beat detection via librosa — beats, tempo, peaks, energy',
33
- inputs: [
34
- { name: 'audioPath', type: 'string' },
35
- ],
36
- outputs: [
37
- { name: 'beats', type: 'any' },
38
- { name: 'tempo', type: 'number' },
39
- { name: 'peaks', type: 'any' },
40
- { name: 'energy', type: 'any' },
41
- { name: 'quietZones', type: 'any' },
42
- { name: 'strongOnsets', type: 'any' },
43
- { name: 'duration', type: 'number' },
44
- { name: 'error', type: 'string' },
45
- ],
46
- params: {
47
- mode: { type: 'string', default: 'ssh', description: 'ssh | http' },
48
- peaksPerSecond: { type: 'int', default: 10, description: 'Waveform peaks resolution' },
49
- sampleRate: { type: 'int', default: 22050, description: 'Audio sample rate for analysis' },
50
- hopLength: { type: 'int', default: 512, description: 'Hop length for beat tracking' },
51
- // SSH params
52
- remoteHost: { type: 'string', default: 'mr-agent@mr-agent.rnd-pro.com', description: 'SSH host' },
53
- remotePath: { type: 'string', default: '/home/mr-agent/automations/argentine-spanish-bot', description: 'Remote project path' },
54
- remoteVenv: { type: 'string', default: '/home/mr-agent/automations/argentine-spanish-bot/venv', description: 'Remote Python venv' },
55
- scriptPath: { type: 'string', default: '', description: 'Local path to beat-detection.py (auto-resolved)' },
56
- // HTTP params
57
- endpoint: { type: 'string', default: 'http://localhost:5009', description: 'Beat detection HTTP endpoint' },
58
- timeout: { type: 'int', default: 180000, description: 'Max wait time (ms)' },
59
- },
60
- },
61
-
62
- lifecycle: {
63
- validate: (inputs) => {
64
- if (!inputs.audioPath) return false;
65
- return true;
66
- },
67
-
68
- cacheKey: (inputs, params) =>
69
- `beat:${params.mode}:${inputs.audioPath}:${params.peaksPerSecond}:${params.sampleRate}`,
70
-
71
- execute: async (inputs, params) => {
72
- const { audioPath } = inputs;
73
- const mode = params.mode || 'ssh';
74
-
75
- if (mode === 'http') {
76
- return executeHTTP(audioPath, params);
77
- }
78
- return executeSSH(audioPath, params);
79
- },
80
- },
81
- };
82
-
83
- /** @type {Object} Empty result template */
84
- const EMPTY = {
85
- beats: null, tempo: 0, peaks: null, energy: null,
86
- quietZones: null, strongOnsets: null, duration: 0, error: null,
87
- };
88
-
89
- /**
90
- * SSH mode: upload audio → run librosa beat detection → parse JSON result
91
- * @param {string} audioPath - Local path to audio file
92
- * @param {Object} params - Node params
93
- * @returns {Promise<Object>}
94
- */
95
- async function executeSSH(audioPath, params) {
96
- const host = params.remoteHost || process.env.WHISPER_REMOTE_HOST || 'mr-agent@mr-agent.rnd-pro.com';
97
- const remotePath = params.remotePath || process.env.WHISPER_REMOTE_PATH || '/home/mr-agent/automations/argentine-spanish-bot';
98
- const venv = params.remoteVenv || process.env.WHISPER_REMOTE_VENV || `${remotePath}/venv`;
99
- const sr = params.sampleRate || parseInt(process.env.BEAT_SAMPLE_RATE, 10) || 22050;
100
- const hop = params.hopLength || parseInt(process.env.BEAT_HOP_LENGTH, 10) || 512;
101
- const pps = params.peaksPerSecond || 10;
102
- const remoteTmpDir = '/tmp/agi-graph-beat';
103
-
104
- try {
105
- // Verify local file exists
106
- await fs.access(audioPath);
107
-
108
- const filename = path.basename(audioPath);
109
- const remoteAudio = `${remoteTmpDir}/${filename}`;
110
-
111
- // Setup remote directory
112
- execSync(`ssh ${host} "mkdir -p ${remoteTmpDir}"`, {
113
- encoding: 'utf-8', stdio: 'pipe', timeout: 10000,
114
- });
115
-
116
- // Upload audio
117
- execSync(`scp "${audioPath}" "${host}:${remoteAudio}"`, {
118
- encoding: 'utf-8', stdio: 'pipe', timeout: 60000,
119
- });
120
-
121
- // Upload or locate beat detection script
122
- let remoteScript = `${remoteTmpDir}/beat-detection.py`;
123
- const localScript = params.scriptPath
124
- || path.join(process.cwd(), 'utils/beat-detection.py');
125
-
126
- try {
127
- await fs.access(localScript);
128
- execSync(`scp "${localScript}" "${host}:${remoteScript}"`, {
129
- encoding: 'utf-8', stdio: 'pipe', timeout: 10000,
130
- });
131
- } catch {
132
- // Script might already be on remote, try using module path
133
- remoteScript = `${remotePath}/utils/beat-detection.py`;
134
- }
135
-
136
- try {
137
- // Run beat detection
138
- const pythonCmd = `${venv}/bin/python3`;
139
- const cmd = `"${pythonCmd}" "${remoteScript}" "${remoteAudio}" --sr ${sr} --hop ${hop} --pps ${pps}`;
140
- const fullCmd = `ssh ${host} '${cmd}'`;
141
-
142
- const output = execSync(fullCmd, {
143
- encoding: 'utf-8',
144
- maxBuffer: 50 * 1024 * 1024,
145
- timeout: params.timeout || 180000,
146
- });
147
-
148
- const result = JSON.parse(output);
149
-
150
- return {
151
- beats: result.beats,
152
- tempo: result.tempo,
153
- peaks: result.peaks,
154
- energy: result.energy,
155
- quietZones: result.quiet_zones,
156
- strongOnsets: result.strong_onsets,
157
- duration: result.duration,
158
- error: null,
159
- };
160
- } finally {
161
- // Cleanup remote audio
162
- execSync(`ssh ${host} "rm -f ${remoteAudio}"`, {
163
- encoding: 'utf-8', stdio: 'pipe', timeout: 5000,
164
- }).toString();
165
- }
166
- } catch (err) {
167
- return { ...EMPTY, error: err.message };
168
- }
169
- }
170
-
171
- /**
172
- * HTTP mode: POST audio to beat detection API
173
- * @param {string} audioPath - Local path to audio file
174
- * @param {Object} params - Node params
175
- * @returns {Promise<Object>}
176
- */
177
- async function executeHTTP(audioPath, params) {
178
- const endpoint = params.endpoint || 'http://localhost:5009';
179
-
180
- try {
181
- const audioBuffer = await fs.readFile(audioPath);
182
- const blob = new Blob([audioBuffer], { type: 'audio/wav' });
183
-
184
- const formData = new FormData();
185
- formData.append('file', blob, path.basename(audioPath));
186
- formData.append('sample_rate', String(params.sampleRate || 22050));
187
- formData.append('hop_length', String(params.hopLength || 512));
188
- formData.append('peaks_per_second', String(params.peaksPerSecond || 10));
189
-
190
- const response = await fetch(`${endpoint}/analyze`, {
191
- method: 'POST',
192
- body: formData,
193
- signal: AbortSignal.timeout(params.timeout || 180000),
194
- });
195
-
196
- if (!response.ok) {
197
- return { ...EMPTY, error: `Beat API error: ${response.status}` };
198
- }
199
-
200
- const result = await response.json();
201
-
202
- return {
203
- beats: result.beats,
204
- tempo: result.tempo,
205
- peaks: result.peaks,
206
- energy: result.energy,
207
- quietZones: result.quiet_zones,
208
- strongOnsets: result.strong_onsets,
209
- duration: result.duration,
210
- error: null,
211
- };
212
- } catch (err) {
213
- return { ...EMPTY, error: err.message };
214
- }
215
- }
@@ -1,238 +0,0 @@
1
- /**
2
- * ai/content-adapt — AI Content Adaptation
3
- *
4
- * Adapts content to target language levels using AI (OpenRouter).
5
- * Supports news adaptation, trending topic adaptation, and generic
6
- * content adaptation with vocabulary extraction and grammar notes.
7
- *
8
- * Ported from Mr-Computer/automations/argentine-spanish-bot/src/services/contentAdaptationService.js
9
- *
10
- * @module agi-graph/packs/ai/content-adapt
11
- */
12
-
13
- /**
14
- * Simple in-memory cache
15
- * @type {Map<string, {data: any, timestamp: number}>}
16
- */
17
- const cache = new Map();
18
-
19
- /**
20
- * Simple hash for caching
21
- * @param {string} str
22
- * @returns {string}
23
- */
24
- function hashStr(str) {
25
- let hash = 0;
26
- for (let i = 0; i < str.length; i++) {
27
- hash = ((hash << 5) - hash) + str.charCodeAt(i);
28
- hash |= 0;
29
- }
30
- return Math.abs(hash).toString(36);
31
- }
32
-
33
- /**
34
- * Create adaptation prompt for AI
35
- * @param {string} content
36
- * @param {string} contentType
37
- * @param {string} targetLevel
38
- * @param {Object} options
39
- * @returns {string}
40
- */
41
- function createAdaptationPrompt(content, contentType, targetLevel, options) {
42
- const typeLabels = {
43
- news: 'a news article',
44
- trending: 'a trending topic',
45
- general: 'educational content',
46
- };
47
-
48
- let prompt = `You are a language adaptation specialist. Adapt the following ${typeLabels[contentType] || 'content'} to ${targetLevel} level Spanish (Rioplatense dialect).\n\n`;
49
-
50
- prompt += `ORIGINAL CONTENT:\n${content}\n\n`;
51
-
52
- prompt += `REQUIREMENTS:\n`;
53
- prompt += `- Adapt vocabulary and grammar to ${targetLevel} level\n`;
54
- prompt += `- Use Rioplatense Spanish (vos instead of tú, local vocabulary)\n`;
55
- prompt += `- Keep the essential information\n`;
56
- prompt += `- Maximum 350-550 characters for the adapted text\n`;
57
-
58
- if (options.includeVocabulary !== false) {
59
- prompt += `- Extract 10 key vocabulary items with translations (es→ru)\n`;
60
- }
61
- if (options.includeGrammarNotes !== false) {
62
- prompt += `- Include 1-2 grammar notes relevant to the content\n`;
63
- }
64
- if (options.includeLesson !== false) {
65
- prompt += `- Create a micro-lesson (A1 level) inspired by the content\n`;
66
- }
67
-
68
- prompt += `\nOUTPUT FORMAT: JSON object with fields: adaptedContent, vocabulary (array of {es, ru}), grammarNotes (array of {concept, explanation}), lesson (object with title_es, focus, examples)\n`;
69
-
70
- return prompt;
71
- }
72
-
73
- /**
74
- * Parse structured AI response
75
- * @param {string} responseText
76
- * @returns {Object}
77
- */
78
- function parseAiResponse(responseText) {
79
- // Try to extract JSON from response
80
- const jsonMatch = responseText.match(/\{[\s\S]*\}/);
81
- if (jsonMatch) {
82
- try {
83
- return JSON.parse(jsonMatch[0]);
84
- } catch { /* fallback */ }
85
- }
86
- return { adaptedContent: responseText, vocabulary: [], grammarNotes: [] };
87
- }
88
-
89
- /**
90
- * Calculate complexity score for content
91
- * @param {string} content
92
- * @returns {number}
93
- */
94
- function calculateComplexity(content) {
95
- const words = content.split(/\s+/);
96
- const avgWordLength = words.reduce((sum, w) => sum + w.length, 0) / words.length;
97
- const sentenceCount = content.split(/[.!?]+/).filter(Boolean).length;
98
- const avgSentenceLength = words.length / sentenceCount;
99
-
100
- // Simple score 0-1 based on word and sentence length
101
- const score = Math.min(1, (avgWordLength / 10 + avgSentenceLength / 30) / 2);
102
- return Math.round(score * 100) / 100;
103
- }
104
-
105
- // ─── Handler Definition ────────────────────────────────────────────────
106
-
107
- export default {
108
- type: 'ai/content-adapt',
109
- category: 'ai',
110
- icon: 'auto_fix_high',
111
-
112
- driver: {
113
- description: 'AI-powered content adaptation to target language levels with vocabulary extraction',
114
- inputs: [
115
- { name: 'content', type: 'string' },
116
- ],
117
- outputs: [
118
- { name: 'result', type: 'any' },
119
- { name: 'error', type: 'string' },
120
- ],
121
- params: {
122
- operation: { type: 'string', default: 'adapt', description: 'Operation: adapt | adapt-news | adapt-trending' },
123
- apiKey: { type: 'string', default: null, description: 'OpenRouter API key (or OPENROUTER_API_KEY env)' },
124
- model: { type: 'string', default: 'anthropic/claude-sonnet-4', description: 'AI model to use' },
125
- targetLevel: { type: 'string', default: 'A1', description: 'Target language level (A1, A2, B1, B2)' },
126
- // Content metadata
127
- title: { type: 'string', default: null, description: 'Content title (for news/trending)' },
128
- sourceUrl: { type: 'string', default: null, description: 'Source URL' },
129
- // Options
130
- includeVocabulary: { type: 'boolean', default: true, description: 'Include vocabulary extraction' },
131
- includeGrammarNotes: { type: 'boolean', default: true, description: 'Include grammar notes' },
132
- includeLesson: { type: 'boolean', default: true, description: 'Include micro-lesson' },
133
- // Rate limiting
134
- maxRetries: { type: 'int', default: 3, description: 'Maximum retry attempts' },
135
- },
136
- },
137
-
138
- lifecycle: {
139
- validate: (inputs, params) => {
140
- if (typeof inputs.content !== 'string' || inputs.content.length === 0) return false;
141
- const apiKey = params.apiKey || process.env.OPENROUTER_API_KEY;
142
- if (!apiKey) return false;
143
- return true;
144
- },
145
-
146
- cacheKey: (inputs, params) => {
147
- return `content-adapt:${params.operation}:${params.targetLevel}:${hashStr(inputs.content.slice(0, 200))}`;
148
- },
149
-
150
- execute: async (inputs, params) => {
151
- const { content } = inputs;
152
- const { operation, model, targetLevel, maxRetries } = params;
153
- const apiKey = params.apiKey || process.env.OPENROUTER_API_KEY;
154
-
155
- try {
156
- // Check cache
157
- const cacheKey = `${operation}:${hashStr(content.slice(0, 200))}`;
158
- const cached = cache.get(cacheKey);
159
- if (cached && Date.now() - cached.timestamp < 3600000) {
160
- return { result: { ...cached.data, cached: true } };
161
- }
162
-
163
- // Determine content type
164
- const contentType = operation === 'adapt-news' ? 'news'
165
- : operation === 'adapt-trending' ? 'trending'
166
- : 'general';
167
-
168
- const fullContent = params.title
169
- ? `Title: ${params.title}\n\n${content}`
170
- : content;
171
-
172
- const prompt = createAdaptationPrompt(fullContent, contentType, targetLevel, {
173
- includeVocabulary: params.includeVocabulary,
174
- includeGrammarNotes: params.includeGrammarNotes,
175
- includeLesson: params.includeLesson,
176
- });
177
-
178
- // Make API request with retry
179
- let lastError;
180
- for (let attempt = 0; attempt < maxRetries; attempt++) {
181
- try {
182
- const response = await fetch('https://openrouter.ai/api/v1/chat/completions', {
183
- method: 'POST',
184
- headers: {
185
- 'Content-Type': 'application/json',
186
- 'Authorization': `Bearer ${apiKey}`,
187
- },
188
- body: JSON.stringify({
189
- model,
190
- messages: [{ role: 'user', content: prompt }],
191
- temperature: 0.7,
192
- }),
193
- });
194
-
195
- if (!response.ok) {
196
- lastError = `API error: HTTP ${response.status}`;
197
- if (attempt < maxRetries - 1) {
198
- await new Promise(r => setTimeout(r, 1000 * (attempt + 1)));
199
- continue;
200
- }
201
- return { error: lastError };
202
- }
203
-
204
- const data = await response.json();
205
- const aiResponse = data.choices?.[0]?.message?.content || '';
206
-
207
- const parsed = parseAiResponse(aiResponse);
208
- const complexity = calculateComplexity(content);
209
-
210
- const result = {
211
- original: content,
212
- adapted: parsed,
213
- contentType,
214
- targetLevel,
215
- complexity,
216
- model,
217
- sourceUrl: params.sourceUrl,
218
- };
219
-
220
- // Update cache
221
- cache.set(cacheKey, { data: result, timestamp: Date.now() });
222
-
223
- return { result };
224
- } catch (err) {
225
- lastError = err.message;
226
- if (attempt < maxRetries - 1) {
227
- await new Promise(r => setTimeout(r, 1000 * (attempt + 1)));
228
- }
229
- }
230
- }
231
-
232
- return { error: `content-adapt failed after ${maxRetries} attempts: ${lastError}` };
233
- } catch (err) {
234
- return { error: `content-adapt ${operation} failed: ${err.message}` };
235
- }
236
- },
237
- },
238
- };