agentic-flow 2.0.1-alpha.5 → 2.0.1-alpha.8

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 (197) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/agentdb/controllers/EmbeddingService.d.ts +37 -0
  4. package/dist/agentdb/controllers/EmbeddingService.d.ts.map +1 -0
  5. package/dist/agentdb/controllers/EmbeddingService.js +1 -0
  6. package/dist/agentdb/controllers/EmbeddingService.js.map +1 -0
  7. package/dist/billing/mcp/tools.d.ts.map +1 -1
  8. package/dist/billing/mcp/tools.js +2 -0
  9. package/dist/billing/mcp/tools.js.map +1 -1
  10. package/dist/cli/commands/hooks.d.ts +18 -0
  11. package/dist/cli/commands/hooks.d.ts.map +1 -0
  12. package/dist/cli/commands/hooks.js +750 -0
  13. package/dist/cli/commands/hooks.js.map +1 -0
  14. package/dist/cli-proxy.js +26 -1
  15. package/dist/cli-proxy.js.map +1 -1
  16. package/dist/core/agentdb-fast.js +3 -3
  17. package/dist/core/agentdb-fast.js.map +1 -1
  18. package/dist/core/agentdb-wrapper-enhanced.d.ts.map +1 -1
  19. package/dist/core/agentdb-wrapper-enhanced.js +32 -17
  20. package/dist/core/agentdb-wrapper-enhanced.js.map +1 -1
  21. package/dist/core/attention-native.d.ts +1 -0
  22. package/dist/core/attention-native.d.ts.map +1 -1
  23. package/dist/core/attention-native.js +6 -1
  24. package/dist/core/attention-native.js.map +1 -1
  25. package/dist/federation/integrations/supabase-adapter-debug.js +3 -3
  26. package/dist/federation/integrations/supabase-adapter-debug.js.map +1 -1
  27. package/dist/intelligence/RuVectorIntelligence.d.ts +362 -0
  28. package/dist/intelligence/RuVectorIntelligence.d.ts.map +1 -0
  29. package/dist/intelligence/RuVectorIntelligence.js +852 -0
  30. package/dist/intelligence/RuVectorIntelligence.js.map +1 -0
  31. package/dist/intelligence/index.d.ts +14 -0
  32. package/dist/intelligence/index.d.ts.map +1 -0
  33. package/dist/intelligence/index.js +14 -0
  34. package/dist/intelligence/index.js.map +1 -0
  35. package/dist/llm/RuvLLMOrchestrator.d.ts +184 -0
  36. package/dist/llm/RuvLLMOrchestrator.d.ts.map +1 -0
  37. package/dist/llm/RuvLLMOrchestrator.js +442 -0
  38. package/dist/llm/RuvLLMOrchestrator.js.map +1 -0
  39. package/dist/llm/index.d.ts +9 -0
  40. package/dist/llm/index.d.ts.map +1 -0
  41. package/dist/llm/index.js +8 -0
  42. package/dist/llm/index.js.map +1 -0
  43. package/dist/mcp/claudeFlowSdkServer.d.ts.map +1 -1
  44. package/dist/mcp/claudeFlowSdkServer.js +86 -21
  45. package/dist/mcp/claudeFlowSdkServer.js.map +1 -1
  46. package/dist/mcp/fastmcp/servers/hooks-server.d.ts +15 -0
  47. package/dist/mcp/fastmcp/servers/hooks-server.d.ts.map +1 -0
  48. package/dist/mcp/fastmcp/servers/hooks-server.js +63 -0
  49. package/dist/mcp/fastmcp/servers/hooks-server.js.map +1 -0
  50. package/dist/mcp/fastmcp/tools/hooks/benchmark.d.ts +20 -0
  51. package/dist/mcp/fastmcp/tools/hooks/benchmark.d.ts.map +1 -0
  52. package/dist/mcp/fastmcp/tools/hooks/benchmark.js +110 -0
  53. package/dist/mcp/fastmcp/tools/hooks/benchmark.js.map +1 -0
  54. package/dist/mcp/fastmcp/tools/hooks/build-agents.d.ts +7 -0
  55. package/dist/mcp/fastmcp/tools/hooks/build-agents.d.ts.map +1 -0
  56. package/dist/mcp/fastmcp/tools/hooks/build-agents.js +276 -0
  57. package/dist/mcp/fastmcp/tools/hooks/build-agents.js.map +1 -0
  58. package/dist/mcp/fastmcp/tools/hooks/explain.d.ts +6 -0
  59. package/dist/mcp/fastmcp/tools/hooks/explain.d.ts.map +1 -0
  60. package/dist/mcp/fastmcp/tools/hooks/explain.js +164 -0
  61. package/dist/mcp/fastmcp/tools/hooks/explain.js.map +1 -0
  62. package/dist/mcp/fastmcp/tools/hooks/index.d.ts +28 -0
  63. package/dist/mcp/fastmcp/tools/hooks/index.d.ts.map +1 -0
  64. package/dist/mcp/fastmcp/tools/hooks/index.js +59 -0
  65. package/dist/mcp/fastmcp/tools/hooks/index.js.map +1 -0
  66. package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.d.ts +91 -0
  67. package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.d.ts.map +1 -0
  68. package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js +269 -0
  69. package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js.map +1 -0
  70. package/dist/mcp/fastmcp/tools/hooks/intelligence-tools.d.ts +58 -0
  71. package/dist/mcp/fastmcp/tools/hooks/intelligence-tools.d.ts.map +1 -0
  72. package/dist/mcp/fastmcp/tools/hooks/intelligence-tools.js +416 -0
  73. package/dist/mcp/fastmcp/tools/hooks/intelligence-tools.js.map +1 -0
  74. package/dist/mcp/fastmcp/tools/hooks/metrics.d.ts +6 -0
  75. package/dist/mcp/fastmcp/tools/hooks/metrics.d.ts.map +1 -0
  76. package/dist/mcp/fastmcp/tools/hooks/metrics.js +137 -0
  77. package/dist/mcp/fastmcp/tools/hooks/metrics.js.map +1 -0
  78. package/dist/mcp/fastmcp/tools/hooks/post-command.d.ts +7 -0
  79. package/dist/mcp/fastmcp/tools/hooks/post-command.d.ts.map +1 -0
  80. package/dist/mcp/fastmcp/tools/hooks/post-command.js +91 -0
  81. package/dist/mcp/fastmcp/tools/hooks/post-command.js.map +1 -0
  82. package/dist/mcp/fastmcp/tools/hooks/post-edit.d.ts +12 -0
  83. package/dist/mcp/fastmcp/tools/hooks/post-edit.d.ts.map +1 -0
  84. package/dist/mcp/fastmcp/tools/hooks/post-edit.js +146 -0
  85. package/dist/mcp/fastmcp/tools/hooks/post-edit.js.map +1 -0
  86. package/dist/mcp/fastmcp/tools/hooks/pre-command.d.ts +7 -0
  87. package/dist/mcp/fastmcp/tools/hooks/pre-command.d.ts.map +1 -0
  88. package/dist/mcp/fastmcp/tools/hooks/pre-command.js +70 -0
  89. package/dist/mcp/fastmcp/tools/hooks/pre-command.js.map +1 -0
  90. package/dist/mcp/fastmcp/tools/hooks/pre-edit.d.ts +14 -0
  91. package/dist/mcp/fastmcp/tools/hooks/pre-edit.d.ts.map +1 -0
  92. package/dist/mcp/fastmcp/tools/hooks/pre-edit.js +121 -0
  93. package/dist/mcp/fastmcp/tools/hooks/pre-edit.js.map +1 -0
  94. package/dist/mcp/fastmcp/tools/hooks/pretrain.d.ts +7 -0
  95. package/dist/mcp/fastmcp/tools/hooks/pretrain.d.ts.map +1 -0
  96. package/dist/mcp/fastmcp/tools/hooks/pretrain.js +171 -0
  97. package/dist/mcp/fastmcp/tools/hooks/pretrain.js.map +1 -0
  98. package/dist/mcp/fastmcp/tools/hooks/route.d.ts +12 -0
  99. package/dist/mcp/fastmcp/tools/hooks/route.d.ts.map +1 -0
  100. package/dist/mcp/fastmcp/tools/hooks/route.js +267 -0
  101. package/dist/mcp/fastmcp/tools/hooks/route.js.map +1 -0
  102. package/dist/mcp/fastmcp/tools/hooks/shared.d.ts +46 -0
  103. package/dist/mcp/fastmcp/tools/hooks/shared.d.ts.map +1 -0
  104. package/dist/mcp/fastmcp/tools/hooks/shared.js +159 -0
  105. package/dist/mcp/fastmcp/tools/hooks/shared.js.map +1 -0
  106. package/dist/mcp/fastmcp/tools/hooks/transfer.d.ts +7 -0
  107. package/dist/mcp/fastmcp/tools/hooks/transfer.d.ts.map +1 -0
  108. package/dist/mcp/fastmcp/tools/hooks/transfer.js +151 -0
  109. package/dist/mcp/fastmcp/tools/hooks/transfer.js.map +1 -0
  110. package/dist/mcp/tools/agent-booster-tools.d.ts +10 -1
  111. package/dist/mcp/tools/agent-booster-tools.d.ts.map +1 -1
  112. package/dist/mcp/tools/agent-booster-tools.js.map +1 -1
  113. package/dist/mcp/tools/sona-tools.d.ts.map +1 -1
  114. package/dist/mcp/tools/sona-tools.js +15 -3
  115. package/dist/mcp/tools/sona-tools.js.map +1 -1
  116. package/dist/memory/SharedMemoryPool.d.ts +16 -3
  117. package/dist/memory/SharedMemoryPool.d.ts.map +1 -1
  118. package/dist/memory/SharedMemoryPool.js +33 -1
  119. package/dist/memory/SharedMemoryPool.js.map +1 -1
  120. package/dist/middleware/auth.middleware.d.ts +114 -0
  121. package/dist/middleware/auth.middleware.d.ts.map +1 -0
  122. package/dist/middleware/auth.middleware.js +222 -0
  123. package/dist/middleware/auth.middleware.js.map +1 -0
  124. package/dist/optimizations/agent-booster-migration.d.ts.map +1 -1
  125. package/dist/optimizations/agent-booster-migration.js.map +1 -1
  126. package/dist/proxy/anthropic-to-gemini.d.ts.map +1 -1
  127. package/dist/proxy/anthropic-to-gemini.js.map +1 -1
  128. package/dist/proxy/anthropic-to-openrouter.d.ts.map +1 -1
  129. package/dist/proxy/anthropic-to-openrouter.js.map +1 -1
  130. package/dist/proxy/anthropic-to-requesty.d.ts.map +1 -1
  131. package/dist/proxy/anthropic-to-requesty.js.map +1 -1
  132. package/dist/proxy/quic-proxy.d.ts +0 -1
  133. package/dist/proxy/quic-proxy.d.ts.map +1 -1
  134. package/dist/proxy/quic-proxy.js +2 -1
  135. package/dist/proxy/quic-proxy.js.map +1 -1
  136. package/dist/reasoningbank/AdvancedMemory.d.ts.map +1 -1
  137. package/dist/reasoningbank/AdvancedMemory.js +12 -1
  138. package/dist/reasoningbank/AdvancedMemory.js.map +1 -1
  139. package/dist/reasoningbank/HybridBackend.d.ts +9 -0
  140. package/dist/reasoningbank/HybridBackend.d.ts.map +1 -1
  141. package/dist/reasoningbank/HybridBackend.js +48 -4
  142. package/dist/reasoningbank/HybridBackend.js.map +1 -1
  143. package/dist/reasoningbank/backend-selector.d.ts +1 -1
  144. package/dist/reasoningbank/backend-selector.d.ts.map +1 -1
  145. package/dist/reasoningbank/backend-selector.js.map +1 -1
  146. package/dist/reasoningbank/index-new.d.ts +0 -6
  147. package/dist/reasoningbank/index-new.d.ts.map +1 -1
  148. package/dist/reasoningbank/index-new.js +9 -7
  149. package/dist/reasoningbank/index-new.js.map +1 -1
  150. package/dist/reasoningbank/index.d.ts +1 -6
  151. package/dist/reasoningbank/index.d.ts.map +1 -1
  152. package/dist/reasoningbank/index.js +10 -7
  153. package/dist/reasoningbank/index.js.map +1 -1
  154. package/dist/router/providers/onnx-local.d.ts.map +1 -1
  155. package/dist/router/providers/onnx-local.js +3 -1
  156. package/dist/router/providers/onnx-local.js.map +1 -1
  157. package/dist/routing/CircuitBreakerRouter.d.ts +187 -0
  158. package/dist/routing/CircuitBreakerRouter.d.ts.map +1 -0
  159. package/dist/routing/CircuitBreakerRouter.js +460 -0
  160. package/dist/routing/CircuitBreakerRouter.js.map +1 -0
  161. package/dist/routing/SemanticRouter.d.ts +164 -0
  162. package/dist/routing/SemanticRouter.d.ts.map +1 -0
  163. package/dist/routing/SemanticRouter.js +291 -0
  164. package/dist/routing/SemanticRouter.js.map +1 -0
  165. package/dist/routing/index.d.ts +12 -0
  166. package/dist/routing/index.d.ts.map +1 -0
  167. package/dist/routing/index.js +10 -0
  168. package/dist/routing/index.js.map +1 -0
  169. package/dist/services/embedding-service.d.ts.map +1 -1
  170. package/dist/services/embedding-service.js +5 -2
  171. package/dist/services/embedding-service.js.map +1 -1
  172. package/dist/services/sona-agent-training.js +1 -1
  173. package/dist/services/sona-agent-training.js.map +1 -1
  174. package/dist/services/sona-agentdb-integration.d.ts.map +1 -1
  175. package/dist/services/sona-agentdb-integration.js +10 -5
  176. package/dist/services/sona-agentdb-integration.js.map +1 -1
  177. package/dist/services/sona-service.d.ts +6 -6
  178. package/dist/services/sona-service.d.ts.map +1 -1
  179. package/dist/services/sona-service.js +3 -1
  180. package/dist/services/sona-service.js.map +1 -1
  181. package/dist/utils/audit-logger.d.ts +115 -0
  182. package/dist/utils/audit-logger.d.ts.map +1 -0
  183. package/dist/utils/audit-logger.js +228 -0
  184. package/dist/utils/audit-logger.js.map +1 -0
  185. package/dist/utils/cli.d.ts +1 -1
  186. package/dist/utils/cli.d.ts.map +1 -1
  187. package/dist/utils/cli.js +5 -0
  188. package/dist/utils/cli.js.map +1 -1
  189. package/dist/utils/input-validator.d.ts +116 -0
  190. package/dist/utils/input-validator.d.ts.map +1 -0
  191. package/dist/utils/input-validator.js +299 -0
  192. package/dist/utils/input-validator.js.map +1 -0
  193. package/dist/utils/rate-limiter.js +2 -2
  194. package/dist/utils/rate-limiter.js.map +1 -1
  195. package/package.json +5 -2
  196. package/wasm/reasoningbank/reasoningbank_wasm_bg.js +2 -2
  197. package/wasm/reasoningbank/reasoningbank_wasm_bg.wasm +0 -0
@@ -0,0 +1,37 @@
1
+ /**
2
+ * EmbeddingService - Text Embedding Generation
3
+ *
4
+ * Handles text-to-vector embedding generation using various models.
5
+ * Supports both local (transformers.js) and remote (OpenAI, etc.) embeddings.
6
+ */
7
+ export interface EmbeddingConfig {
8
+ model: string;
9
+ dimension: number;
10
+ provider: 'transformers' | 'openai' | 'local';
11
+ apiKey?: string;
12
+ }
13
+ export declare class EmbeddingService {
14
+ private config;
15
+ private pipeline;
16
+ private cache;
17
+ constructor(config: EmbeddingConfig);
18
+ /**
19
+ * Initialize the embedding service
20
+ */
21
+ initialize(): Promise<void>;
22
+ /**
23
+ * Generate embedding for text
24
+ */
25
+ embed(text: string): Promise<Float32Array>;
26
+ /**
27
+ * Batch embed multiple texts
28
+ */
29
+ embedBatch(texts: string[]): Promise<Float32Array[]>;
30
+ /**
31
+ * Clear embedding cache
32
+ */
33
+ clearCache(): void;
34
+ private embedOpenAI;
35
+ private mockEmbedding;
36
+ }
37
+ //# sourceMappingURL=EmbeddingService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbeddingService.d.ts","sourceRoot":"","sources":["../../../src/agentdb/controllers/EmbeddingService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,cAAc,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,KAAK,CAA4B;gBAE7B,MAAM,EAAE,eAAe;IAKnC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAajC;;OAEG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAgChD;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAI1D;;OAEG;IACH,UAAU,IAAI,IAAI;YAQJ,WAAW;IAiBzB,OAAO,CAAC,aAAa;CA8BtB"}
@@ -116,3 +116,4 @@ export class EmbeddingService {
116
116
  return embedding;
117
117
  }
118
118
  }
119
+ //# sourceMappingURL=EmbeddingService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbeddingService.js","sourceRoot":"","sources":["../../../src/agentdb/controllers/EmbeddingService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAkB;IACxB,QAAQ,CAAM,CAAC,2BAA2B;IAC1C,KAAK,CAA4B;IAEzC,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;YAC5C,2CAA2C;YAC3C,IAAI,CAAC;gBACH,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;gBAC1D,IAAI,CAAC,QAAQ,GAAG,MAAM,QAAQ,CAAC,oBA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C;YAC1C,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QACvB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/**\n * EmbeddingService - Text Embedding Generation\n *\n * Handles text-to-vector embedding generation using various models.\n * Supports both local (transformers.js) and remote (OpenAI, etc.) embeddings.\n */\n\nexport interface EmbeddingConfig {\n model: string;\n dimension: number;\n provider: 'transformers' | 'openai' | 'local';\n apiKey?: string;\n}\n\nexport class EmbeddingService {\n private config: EmbeddingConfig;\n private pipeline: any; // transformers.js pipeline\n private cache: Map<string, Float32Array>;\n\n constructor(config: EmbeddingConfig) {\n this.config = config;\n this.cache = new Map();\n }\n\n /**\n * Initialize the embedding service\n */\n async initialize(): Promise<void> {\n if (this.config.provider === 'transformers') {\n // Use transformers.js for local embeddings\n try {\n const { pipeline } = await import('@xenova/transformers');\n this.pipeline = await pipeline('feature-extraction', this.config.model);\n } catch (error) {\n console.warn('Transformers.js not available, falling back to mock embeddings');\n this.pipeline = null;\n }\n }\n }\n\n /**\n * Generate embedding for text\n */\n async embed(text: string): Promise<Float32Array> {\n // Check cache\n const cacheKey = `${this.config.model}:${text}`;\n if (this.cache.has(cacheKey)) {\n return this.cache.get(cacheKey)!;\n }\n\n let embedding: Float32Array;\n\n if (this.config.provider === 'transformers' && this.pipeline) {\n // Use transformers.js\n const output = await this.pipeline(text, { pooling: 'mean', normalize: true });\n embedding = new Float32Array(output.data);\n } else if (this.config.provider === 'openai' && this.config.apiKey) {\n // Use OpenAI API\n embedding = await this.embedOpenAI(text);\n } else {\n // Mock embedding for testing\n embedding = this.mockEmbedding(text);\n }\n\n // Cache result\n if (this.cache.size > 10000) {\n // Simple LRU: clear half the cache\n const keysToDelete = Array.from(this.cache.keys()).slice(0, 5000);\n keysToDelete.forEach(k => this.cache.delete(k));\n }\n this.cache.set(cacheKey, embedding);\n\n return embedding;\n }\n\n /**\n * Batch embed multiple texts\n */\n async embedBatch(texts: string[]): Promise<Float32Array[]> {\n return Promise.all(texts.map(text => this.embed(text)));\n }\n\n /**\n * Clear embedding cache\n */\n clearCache(): void {\n this.cache.clear();\n }\n\n // ========================================================================\n // Private Methods\n // ========================================================================\n\n private async embedOpenAI(text: string): Promise<Float32Array> {\n const response = await fetch('https://api.openai.com/v1/embeddings', {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.config.apiKey}`,\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n model: this.config.model,\n input: text\n })\n });\n\n const data = await response.json();\n return new Float32Array(data.data[0].embedding);\n }\n\n private mockEmbedding(text: string): Float32Array {\n // Simple deterministic mock embedding for testing\n const embedding = new Float32Array(this.config.dimension);\n\n // Use simple hash-based generation\n let hash = 0;\n for (let i = 0; i < text.length; i++) {\n hash = ((hash << 5) - hash) + text.charCodeAt(i);\n hash = hash & hash; // Convert to 32bit integer\n }\n\n // Fill embedding with pseudo-random values based on hash\n for (let i = 0; i < this.config.dimension; i++) {\n const seed = hash + i * 31;\n embedding[i] = Math.sin(seed) * Math.cos(seed * 0.5);\n }\n\n // Normalize\n let norm = 0;\n for (let i = 0; i < embedding.length; i++) {\n norm += embedding[i] * embedding[i];\n }\n norm = Math.sqrt(norm);\n\n for (let i = 0; i < embedding.length; i++) {\n embedding[i] /= norm;\n }\n\n return embedding;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/billing/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,GAAG,CAAC;IACjB,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACxC;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAgB;IAC/B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CAQ3D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,eAAe,CAE7E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAY9E"}
@@ -2,6 +2,8 @@
2
2
  * MCP Tools for Billing System
3
3
  * Expose billing operations as MCP tools for Claude integration
4
4
  */
5
+ // Use regular imports for enums (not type imports) since they're used as runtime values
6
+ import { SubscriptionTier, BillingCycle, UsageMetric, CouponType } from '../types.js';
5
7
  export class BillingMCPTools {
6
8
  billing;
7
9
  tools = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/billing/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,MAAM,OAAO,eAAe;IAClB,OAAO,CAAgB;IACvB,KAAK,GAAyB,IAAI,GAAG,EAAE,CAAC;IAEhD,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAEO,aAAa;QACnB,qBAAqB;QACrB,IAAI,CAAC,OAAO,CAAC;YACX,IAAI,EAAE,6BAA6B;YACnC,WAAW,EAAE,sCAAsC;YACnD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE;oBAClD,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;oBAC/D,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;oBACnE,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACnC,UAAU,EAAE,EAA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":["/**\n * MCP Tools for Billing System\n * Expose billing operations as MCP tools for Claude integration\n */\n\nimport { BillingSystem } from '../index.js';\nimport type { SubscriptionTier, BillingCycle, UsageMetric, CouponType } from '../types.js';\n\nexport interface MCPTool {\n name: string;\n description: string;\n inputSchema: any;\n handler: (params: any) => Promise<any>;\n}\n\nexport class BillingMCPTools {\n private billing: BillingSystem;\n private tools: Map<string, MCPTool> = new Map();\n\n constructor(billing: BillingSystem) {\n this.billing = billing;\n this.registerTools();\n }\n\n private registerTools(): void {\n // Subscription tools\n this.addTool({\n name: 'billing_subscription_create',\n description: 'Create a new subscription for a user',\n inputSchema: {\n type: 'object',\n properties: {\n userId: { type: 'string', description: 'User ID' },\n tier: { type: 'string', enum: Object.values(SubscriptionTier) },\n billingCycle: { type: 'string', enum: Object.values(BillingCycle) },\n paymentMethodId: { type: 'string' },\n couponCode: { type: 'string', optional: true }\n },\n required: ['userId', 'tier', 'billingCycle', 'paymentMethodId']\n },\n handler: async (params) => {\n return await this.billing.subscribe(params);\n }\n });\n\n this.addTool({\n name: 'billing_subscription_upgrade',\n description: 'Upgrade a subscription to a higher tier',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' },\n newTier: { type: 'string', enum: Object.values(SubscriptionTier) }\n },\n required: ['subscriptionId', 'newTier']\n },\n handler: async (params) => {\n return await this.billing.upgrade(params.subscriptionId, params.newTier);\n }\n });\n\n this.addTool({\n name: 'billing_subscription_cancel',\n description: 'Cancel a subscription',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' },\n immediate: { type: 'boolean', optional: true, default: false }\n },\n required: ['subscriptionId']\n },\n handler: async (params) => {\n return await this.billing.cancel(params.subscriptionId, params.immediate);\n }\n });\n\n this.addTool({\n name: 'billing_subscription_get',\n description: 'Get subscription details',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' }\n },\n required: ['subscriptionId']\n },\n handler: async (params) => {\n return await this.billing.subscriptions.getSubscription(params.subscriptionId);\n }\n });\n\n // Usage tools\n this.addTool({\n name: 'billing_usage_record',\n description: 'Record usage for a subscription',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' },\n userId: { type: 'string' },\n metric: { type: 'string', enum: Object.values(UsageMetric) },\n amount: { type: 'number' },\n unit: { type: 'string' }\n },\n required: ['subscriptionId', 'userId', 'metric', 'amount', 'unit']\n },\n handler: async (params) => {\n await this.billing.recordUsage(params);\n return { success: true };\n }\n });\n\n this.addTool({\n name: 'billing_usage_summary',\n description: 'Get usage summary for a subscription',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' }\n },\n required: ['subscriptionId']\n },\n handler: async (params) => {\n return await this.billing.getUsageSummary(params.subscriptionId);\n }\n });\n\n this.addTool({\n name: 'billing_quota_check',\n description: 'Check if subscription is within quota',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' },\n metric: { type: 'string', enum: Object.values(UsageMetric) }\n },\n required: ['subscriptionId', 'metric']\n },\n handler: async (params) => {\n const allowed = await this.billing.checkQuota(params.subscriptionId, params.metric);\n return { allowed, metric: params.metric };\n }\n });\n\n // Pricing tools\n this.addTool({\n name: 'billing_pricing_tiers',\n description: 'List all pricing tiers',\n inputSchema: {\n type: 'object',\n properties: {}\n },\n handler: async () => {\n return this.billing.pricing.getAllTiers();\n }\n });\n\n this.addTool({\n name: 'billing_pricing_calculate',\n description: 'Calculate price for a tier and cycle',\n inputSchema: {\n type: 'object',\n properties: {\n tier: { type: 'string', enum: Object.values(SubscriptionTier) },\n cycle: { type: 'string', enum: ['monthly', 'yearly', 'quarterly'] }\n },\n required: ['tier', 'cycle']\n },\n handler: async (params) => {\n const price = this.billing.pricing.calculatePrice(params.tier, params.cycle);\n return { tier: params.tier, cycle: params.cycle, price };\n }\n });\n\n // Coupon tools\n this.addTool({\n name: 'billing_coupon_create',\n description: 'Create a new coupon',\n inputSchema: {\n type: 'object',\n properties: {\n code: { type: 'string' },\n type: { type: 'string', enum: Object.values(CouponType) },\n value: { type: 'number' },\n description: { type: 'string', optional: true },\n maxRedemptions: { type: 'number', optional: true },\n validUntil: { type: 'string', optional: true }\n },\n required: ['code', 'type', 'value']\n },\n handler: async (params) => {\n return await this.billing.coupons.createCoupon(params);\n }\n });\n\n this.addTool({\n name: 'billing_coupon_validate',\n description: 'Validate a coupon code',\n inputSchema: {\n type: 'object',\n properties: {\n code: { type: 'string' },\n tier: { type: 'string', enum: Object.values(SubscriptionTier) },\n amount: { type: 'number' }\n },\n required: ['code', 'tier', 'amount']\n },\n handler: async (params) => {\n return await this.billing.coupons.validateCoupon(params.code, params.tier, params.amount);\n }\n });\n }\n\n private addTool(tool: MCPTool): void {\n this.tools.set(tool.name, tool);\n }\n\n /**\n * Get all tools for MCP registration\n */\n getAllTools(): MCPTool[] {\n return Array.from(this.tools.values());\n }\n\n /**\n * Get tool by name\n */\n getTool(name: string): MCPTool | undefined {\n return this.tools.get(name);\n }\n\n /**\n * Execute a tool\n */\n async executeTool(name: string, params: any): Promise<any> {\n const tool = this.tools.get(name);\n if (!tool) {\n throw new Error(`Tool not found: ${name}`);\n }\n\n return await tool.handler(params);\n }\n}\n\n/**\n * Create MCP tools for a billing system\n */\nexport function createBillingMCPTools(billing: BillingSystem): BillingMCPTools {\n return new BillingMCPTools(billing);\n}\n\n/**\n * Export tools for fastMCP registration\n */\nexport function registerBillingTools(server: any, billing: BillingSystem): void {\n const mcpTools = new BillingMCPTools(billing);\n const tools = mcpTools.getAllTools();\n\n tools.forEach(tool => {\n server.addTool({\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema,\n handler: tool.handler\n });\n });\n}\n"]}
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/billing/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,wFAAwF;AACxF,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAStF,MAAM,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,IAAI,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAsB;IAC1D,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAW,EAAE,OAAsB;IACtE,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAErC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,MAAM,CAAC,OAAO,CAAC;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * MCP Tools for Billing System\n * Expose billing operations as MCP tools for Claude integration\n */\n\nimport { BillingSystem } from '../index.js';\n// Use regular imports for enums (not type imports) since they're used as runtime values\nimport { SubscriptionTier, BillingCycle, UsageMetric, CouponType } from '../types.js';\n\nexport interface MCPTool {\n name: string;\n description: string;\n inputSchema: any;\n handler: (params: any) => Promise<any>;\n}\n\nexport class BillingMCPTools {\n private billing: BillingSystem;\n private tools: Map<string, MCPTool> = new Map();\n\n constructor(billing: BillingSystem) {\n this.billing = billing;\n this.registerTools();\n }\n\n private registerTools(): void {\n // Subscription tools\n this.addTool({\n name: 'billing_subscription_create',\n description: 'Create a new subscription for a user',\n inputSchema: {\n type: 'object',\n properties: {\n userId: { type: 'string', description: 'User ID' },\n tier: { type: 'string', enum: Object.values(SubscriptionTier) },\n billingCycle: { type: 'string', enum: Object.values(BillingCycle) },\n paymentMethodId: { type: 'string' },\n couponCode: { type: 'string', optional: true }\n },\n required: ['userId', 'tier', 'billingCycle', 'paymentMethodId']\n },\n handler: async (params) => {\n return await this.billing.subscribe(params);\n }\n });\n\n this.addTool({\n name: 'billing_subscription_upgrade',\n description: 'Upgrade a subscription to a higher tier',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' },\n newTier: { type: 'string', enum: Object.values(SubscriptionTier) }\n },\n required: ['subscriptionId', 'newTier']\n },\n handler: async (params) => {\n return await this.billing.upgrade(params.subscriptionId, params.newTier);\n }\n });\n\n this.addTool({\n name: 'billing_subscription_cancel',\n description: 'Cancel a subscription',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' },\n immediate: { type: 'boolean', optional: true, default: false }\n },\n required: ['subscriptionId']\n },\n handler: async (params) => {\n return await this.billing.cancel(params.subscriptionId, params.immediate);\n }\n });\n\n this.addTool({\n name: 'billing_subscription_get',\n description: 'Get subscription details',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' }\n },\n required: ['subscriptionId']\n },\n handler: async (params) => {\n return await this.billing.subscriptions.getSubscription(params.subscriptionId);\n }\n });\n\n // Usage tools\n this.addTool({\n name: 'billing_usage_record',\n description: 'Record usage for a subscription',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' },\n userId: { type: 'string' },\n metric: { type: 'string', enum: Object.values(UsageMetric) },\n amount: { type: 'number' },\n unit: { type: 'string' }\n },\n required: ['subscriptionId', 'userId', 'metric', 'amount', 'unit']\n },\n handler: async (params) => {\n await this.billing.recordUsage(params);\n return { success: true };\n }\n });\n\n this.addTool({\n name: 'billing_usage_summary',\n description: 'Get usage summary for a subscription',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' }\n },\n required: ['subscriptionId']\n },\n handler: async (params) => {\n return await this.billing.getUsageSummary(params.subscriptionId);\n }\n });\n\n this.addTool({\n name: 'billing_quota_check',\n description: 'Check if subscription is within quota',\n inputSchema: {\n type: 'object',\n properties: {\n subscriptionId: { type: 'string' },\n metric: { type: 'string', enum: Object.values(UsageMetric) }\n },\n required: ['subscriptionId', 'metric']\n },\n handler: async (params) => {\n const allowed = await this.billing.checkQuota(params.subscriptionId, params.metric);\n return { allowed, metric: params.metric };\n }\n });\n\n // Pricing tools\n this.addTool({\n name: 'billing_pricing_tiers',\n description: 'List all pricing tiers',\n inputSchema: {\n type: 'object',\n properties: {}\n },\n handler: async () => {\n return this.billing.pricing.getAllTiers();\n }\n });\n\n this.addTool({\n name: 'billing_pricing_calculate',\n description: 'Calculate price for a tier and cycle',\n inputSchema: {\n type: 'object',\n properties: {\n tier: { type: 'string', enum: Object.values(SubscriptionTier) },\n cycle: { type: 'string', enum: ['monthly', 'yearly', 'quarterly'] }\n },\n required: ['tier', 'cycle']\n },\n handler: async (params) => {\n const price = this.billing.pricing.calculatePrice(params.tier, params.cycle);\n return { tier: params.tier, cycle: params.cycle, price };\n }\n });\n\n // Coupon tools\n this.addTool({\n name: 'billing_coupon_create',\n description: 'Create a new coupon',\n inputSchema: {\n type: 'object',\n properties: {\n code: { type: 'string' },\n type: { type: 'string', enum: Object.values(CouponType) },\n value: { type: 'number' },\n description: { type: 'string', optional: true },\n maxRedemptions: { type: 'number', optional: true },\n validUntil: { type: 'string', optional: true }\n },\n required: ['code', 'type', 'value']\n },\n handler: async (params) => {\n return await this.billing.coupons.createCoupon(params);\n }\n });\n\n this.addTool({\n name: 'billing_coupon_validate',\n description: 'Validate a coupon code',\n inputSchema: {\n type: 'object',\n properties: {\n code: { type: 'string' },\n tier: { type: 'string', enum: Object.values(SubscriptionTier) },\n amount: { type: 'number' }\n },\n required: ['code', 'tier', 'amount']\n },\n handler: async (params) => {\n return await this.billing.coupons.validateCoupon(params.code, params.tier, params.amount);\n }\n });\n }\n\n private addTool(tool: MCPTool): void {\n this.tools.set(tool.name, tool);\n }\n\n /**\n * Get all tools for MCP registration\n */\n getAllTools(): MCPTool[] {\n return Array.from(this.tools.values());\n }\n\n /**\n * Get tool by name\n */\n getTool(name: string): MCPTool | undefined {\n return this.tools.get(name);\n }\n\n /**\n * Execute a tool\n */\n async executeTool(name: string, params: any): Promise<any> {\n const tool = this.tools.get(name);\n if (!tool) {\n throw new Error(`Tool not found: ${name}`);\n }\n\n return await tool.handler(params);\n }\n}\n\n/**\n * Create MCP tools for a billing system\n */\nexport function createBillingMCPTools(billing: BillingSystem): BillingMCPTools {\n return new BillingMCPTools(billing);\n}\n\n/**\n * Export tools for fastMCP registration\n */\nexport function registerBillingTools(server: any, billing: BillingSystem): void {\n const mcpTools = new BillingMCPTools(billing);\n const tools = mcpTools.getAllTools();\n\n tools.forEach(tool => {\n server.addTool({\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema,\n handler: tool.handler\n });\n });\n}\n"]}
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI Hooks Commands
4
+ * Provides CLI interface for agentic-flow hook tools
5
+ *
6
+ * NOW WITH FULL RUVECTOR INTELLIGENCE:
7
+ * - @ruvector/sona: Micro-LoRA (~0.05ms), EWC++, Trajectory tracking
8
+ * - @ruvector/attention: MoE, Flash, Hyperbolic, Graph attention
9
+ * - ruvector core: HNSW indexing (150x faster)
10
+ *
11
+ * Available as BOTH:
12
+ * 1. CLI Commands (agentic-flow hooks ...)
13
+ * 2. MCP Tools (via hooks-server.ts)
14
+ */
15
+ import { Command } from 'commander';
16
+ export declare function createHooksCommand(): Command;
17
+ export default createHooksCommand;
18
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/hooks.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoCpC,wBAAgB,kBAAkB,IAAI,OAAO,CA40B5C;AAED,eAAe,kBAAkB,CAAC"}