@houtini/lm 1.0.12 → 2.0.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 (263) hide show
  1. package/README.md +5 -6
  2. package/dist/index.d.ts +5 -3
  3. package/dist/index.js +142 -213
  4. package/dist/index.js.map +1 -1
  5. package/package.json +10 -33
  6. package/CHANGELOG.md +0 -282
  7. package/dist/cache/analysis-cache.d.ts +0 -33
  8. package/dist/cache/analysis-cache.d.ts.map +0 -1
  9. package/dist/cache/analysis-cache.js +0 -56
  10. package/dist/cache/analysis-cache.js.map +0 -1
  11. package/dist/cache/cache-manager.d.ts +0 -29
  12. package/dist/cache/cache-manager.d.ts.map +0 -1
  13. package/dist/cache/cache-manager.js +0 -85
  14. package/dist/cache/cache-manager.js.map +0 -1
  15. package/dist/cache/index.d.ts +0 -16
  16. package/dist/cache/index.d.ts.map +0 -1
  17. package/dist/cache/index.js +0 -17
  18. package/dist/cache/index.js.map +0 -1
  19. package/dist/cache/prompt-cache.d.ts +0 -33
  20. package/dist/cache/prompt-cache.d.ts.map +0 -1
  21. package/dist/cache/prompt-cache.js +0 -61
  22. package/dist/cache/prompt-cache.js.map +0 -1
  23. package/dist/config.d.ts +0 -41
  24. package/dist/config.d.ts.map +0 -1
  25. package/dist/config.js +0 -71
  26. package/dist/config.js.map +0 -1
  27. package/dist/core/ThreeStagePromptManager.d.ts +0 -23
  28. package/dist/core/ThreeStagePromptManager.d.ts.map +0 -1
  29. package/dist/core/ThreeStagePromptManager.js +0 -118
  30. package/dist/core/ThreeStagePromptManager.js.map +0 -1
  31. package/dist/index.d.ts.map +0 -1
  32. package/dist/plugins/base-plugin.d.ts +0 -55
  33. package/dist/plugins/base-plugin.d.ts.map +0 -1
  34. package/dist/plugins/base-plugin.js +0 -120
  35. package/dist/plugins/base-plugin.js.map +0 -1
  36. package/dist/plugins/index.d.ts +0 -58
  37. package/dist/plugins/index.d.ts.map +0 -1
  38. package/dist/plugins/index.js +0 -162
  39. package/dist/plugins/index.js.map +0 -1
  40. package/dist/plugins/types.d.ts +0 -5
  41. package/dist/plugins/types.d.ts.map +0 -1
  42. package/dist/plugins/types.js +0 -5
  43. package/dist/plugins/types.js.map +0 -1
  44. package/dist/prompts/analyze/code-quality.d.ts +0 -116
  45. package/dist/prompts/analyze/code-quality.d.ts.map +0 -1
  46. package/dist/prompts/analyze/code-quality.js +0 -437
  47. package/dist/prompts/analyze/code-quality.js.map +0 -1
  48. package/dist/prompts/analyze/compare-integration.d.ts +0 -130
  49. package/dist/prompts/analyze/compare-integration.d.ts.map +0 -1
  50. package/dist/prompts/analyze/compare-integration.js +0 -547
  51. package/dist/prompts/analyze/compare-integration.js.map +0 -1
  52. package/dist/prompts/analyze/count-files.d.ts +0 -109
  53. package/dist/prompts/analyze/count-files.d.ts.map +0 -1
  54. package/dist/prompts/analyze/count-files.js +0 -403
  55. package/dist/prompts/analyze/count-files.js.map +0 -1
  56. package/dist/prompts/analyze/database-queries.d.ts +0 -156
  57. package/dist/prompts/analyze/database-queries.d.ts.map +0 -1
  58. package/dist/prompts/analyze/database-queries.js +0 -763
  59. package/dist/prompts/analyze/database-queries.js.map +0 -1
  60. package/dist/prompts/analyze/dependencies.d.ts +0 -97
  61. package/dist/prompts/analyze/dependencies.d.ts.map +0 -1
  62. package/dist/prompts/analyze/dependencies.js +0 -337
  63. package/dist/prompts/analyze/dependencies.js.map +0 -1
  64. package/dist/prompts/analyze/diff-signatures.d.ts +0 -139
  65. package/dist/prompts/analyze/diff-signatures.d.ts.map +0 -1
  66. package/dist/prompts/analyze/diff-signatures.js +0 -708
  67. package/dist/prompts/analyze/diff-signatures.js.map +0 -1
  68. package/dist/prompts/analyze/find-patterns.d.ts +0 -128
  69. package/dist/prompts/analyze/find-patterns.d.ts.map +0 -1
  70. package/dist/prompts/analyze/find-patterns.js +0 -524
  71. package/dist/prompts/analyze/find-patterns.js.map +0 -1
  72. package/dist/prompts/analyze/find-unused-css.d.ts +0 -151
  73. package/dist/prompts/analyze/find-unused-css.d.ts.map +0 -1
  74. package/dist/prompts/analyze/find-unused-css.js +0 -760
  75. package/dist/prompts/analyze/find-unused-css.js.map +0 -1
  76. package/dist/prompts/analyze/n8n-workflow.d.ts +0 -137
  77. package/dist/prompts/analyze/n8n-workflow.d.ts.map +0 -1
  78. package/dist/prompts/analyze/n8n-workflow.js +0 -533
  79. package/dist/prompts/analyze/n8n-workflow.js.map +0 -1
  80. package/dist/prompts/analyze/project-structure.d.ts +0 -126
  81. package/dist/prompts/analyze/project-structure.d.ts.map +0 -1
  82. package/dist/prompts/analyze/project-structure.js +0 -573
  83. package/dist/prompts/analyze/project-structure.js.map +0 -1
  84. package/dist/prompts/analyze/security-audit.d.ts +0 -142
  85. package/dist/prompts/analyze/security-audit.d.ts.map +0 -1
  86. package/dist/prompts/analyze/security-audit.js +0 -641
  87. package/dist/prompts/analyze/security-audit.js.map +0 -1
  88. package/dist/prompts/analyze/single-file.d.ts +0 -162
  89. package/dist/prompts/analyze/single-file.d.ts.map +0 -1
  90. package/dist/prompts/analyze/single-file.js +0 -669
  91. package/dist/prompts/analyze/single-file.js.map +0 -1
  92. package/dist/prompts/analyze/trace-execution.d.ts +0 -126
  93. package/dist/prompts/analyze/trace-execution.d.ts.map +0 -1
  94. package/dist/prompts/analyze/trace-execution.js +0 -613
  95. package/dist/prompts/analyze/trace-execution.js.map +0 -1
  96. package/dist/prompts/analyze/wordpress-plugin-audit.d.ts +0 -116
  97. package/dist/prompts/analyze/wordpress-plugin-audit.d.ts.map +0 -1
  98. package/dist/prompts/analyze/wordpress-plugin-audit.js +0 -456
  99. package/dist/prompts/analyze/wordpress-plugin-audit.js.map +0 -1
  100. package/dist/prompts/analyze/wordpress-plugin-readiness.d.ts +0 -103
  101. package/dist/prompts/analyze/wordpress-plugin-readiness.d.ts.map +0 -1
  102. package/dist/prompts/analyze/wordpress-plugin-readiness.js +0 -506
  103. package/dist/prompts/analyze/wordpress-plugin-readiness.js.map +0 -1
  104. package/dist/prompts/analyze/wordpress-security.d.ts +0 -146
  105. package/dist/prompts/analyze/wordpress-security.d.ts.map +0 -1
  106. package/dist/prompts/analyze/wordpress-security.js +0 -702
  107. package/dist/prompts/analyze/wordpress-security.js.map +0 -1
  108. package/dist/prompts/analyze/wordpress-theme-audit.d.ts +0 -114
  109. package/dist/prompts/analyze/wordpress-theme-audit.d.ts.map +0 -1
  110. package/dist/prompts/analyze/wordpress-theme-audit.js +0 -540
  111. package/dist/prompts/analyze/wordpress-theme-audit.js.map +0 -1
  112. package/dist/prompts/custom/custom-prompt.d.ts +0 -135
  113. package/dist/prompts/custom/custom-prompt.d.ts.map +0 -1
  114. package/dist/prompts/custom/custom-prompt.js +0 -421
  115. package/dist/prompts/custom/custom-prompt.js.map +0 -1
  116. package/dist/prompts/fun/arcade-game.d.ts +0 -152
  117. package/dist/prompts/fun/arcade-game.d.ts.map +0 -1
  118. package/dist/prompts/fun/arcade-game.js +0 -657
  119. package/dist/prompts/fun/arcade-game.js.map +0 -1
  120. package/dist/prompts/fun/create_text_adventure.d.ts +0 -100
  121. package/dist/prompts/fun/create_text_adventure.d.ts.map +0 -1
  122. package/dist/prompts/fun/create_text_adventure.js +0 -401
  123. package/dist/prompts/fun/create_text_adventure.js.map +0 -1
  124. package/dist/prompts/fun/css-art-generator.d.ts +0 -168
  125. package/dist/prompts/fun/css-art-generator.d.ts.map +0 -1
  126. package/dist/prompts/fun/css-art-generator.js +0 -831
  127. package/dist/prompts/fun/css-art-generator.js.map +0 -1
  128. package/dist/prompts/generate/project-documentation.d.ts +0 -137
  129. package/dist/prompts/generate/project-documentation.d.ts.map +0 -1
  130. package/dist/prompts/generate/project-documentation.js +0 -670
  131. package/dist/prompts/generate/project-documentation.js.map +0 -1
  132. package/dist/prompts/generate/refactoring.d.ts +0 -164
  133. package/dist/prompts/generate/refactoring.d.ts.map +0 -1
  134. package/dist/prompts/generate/refactoring.js +0 -625
  135. package/dist/prompts/generate/refactoring.js.map +0 -1
  136. package/dist/prompts/generate/responsive-component.d.ts +0 -147
  137. package/dist/prompts/generate/responsive-component.d.ts.map +0 -1
  138. package/dist/prompts/generate/responsive-component.js +0 -957
  139. package/dist/prompts/generate/responsive-component.js.map +0 -1
  140. package/dist/prompts/generate/typescript-conversion.d.ts +0 -144
  141. package/dist/prompts/generate/typescript-conversion.d.ts.map +0 -1
  142. package/dist/prompts/generate/typescript-conversion.js +0 -531
  143. package/dist/prompts/generate/typescript-conversion.js.map +0 -1
  144. package/dist/prompts/generate/unit-tests.d.ts +0 -139
  145. package/dist/prompts/generate/unit-tests.d.ts.map +0 -1
  146. package/dist/prompts/generate/unit-tests.js +0 -582
  147. package/dist/prompts/generate/unit-tests.js.map +0 -1
  148. package/dist/prompts/generate/wordpress-plugin.d.ts +0 -179
  149. package/dist/prompts/generate/wordpress-plugin.d.ts.map +0 -1
  150. package/dist/prompts/generate/wordpress-plugin.js +0 -767
  151. package/dist/prompts/generate/wordpress-plugin.js.map +0 -1
  152. package/dist/prompts/generate/wordpress-theme-from-static.d.ts +0 -177
  153. package/dist/prompts/generate/wordpress-theme-from-static.d.ts.map +0 -1
  154. package/dist/prompts/generate/wordpress-theme-from-static.js +0 -699
  155. package/dist/prompts/generate/wordpress-theme-from-static.js.map +0 -1
  156. package/dist/prompts/shared/cache-manager.d.ts +0 -45
  157. package/dist/prompts/shared/cache-manager.d.ts.map +0 -1
  158. package/dist/prompts/shared/cache-manager.js +0 -129
  159. package/dist/prompts/shared/cache-manager.js.map +0 -1
  160. package/dist/prompts/shared/helpers.d.ts +0 -39
  161. package/dist/prompts/shared/helpers.d.ts.map +0 -1
  162. package/dist/prompts/shared/helpers.js +0 -151
  163. package/dist/prompts/shared/helpers.js.map +0 -1
  164. package/dist/prompts/shared/templates.d.ts +0 -35
  165. package/dist/prompts/shared/templates.d.ts.map +0 -1
  166. package/dist/prompts/shared/templates.js +0 -77
  167. package/dist/prompts/shared/templates.js.map +0 -1
  168. package/dist/prompts/shared/types.d.ts +0 -112
  169. package/dist/prompts/shared/types.d.ts.map +0 -1
  170. package/dist/prompts/shared/types.js +0 -5
  171. package/dist/prompts/shared/types.js.map +0 -1
  172. package/dist/prompts/system/find-unused-files.d.ts +0 -106
  173. package/dist/prompts/system/find-unused-files.d.ts.map +0 -1
  174. package/dist/prompts/system/find-unused-files.js +0 -357
  175. package/dist/prompts/system/find-unused-files.js.map +0 -1
  176. package/dist/security/index.d.ts +0 -39
  177. package/dist/security/index.d.ts.map +0 -1
  178. package/dist/security/index.js +0 -46
  179. package/dist/security/index.js.map +0 -1
  180. package/dist/security/integration-helpers.d.ts +0 -121
  181. package/dist/security/integration-helpers.d.ts.map +0 -1
  182. package/dist/security/integration-helpers.js +0 -190
  183. package/dist/security/integration-helpers.js.map +0 -1
  184. package/dist/security/output-encoder.d.ts +0 -94
  185. package/dist/security/output-encoder.d.ts.map +0 -1
  186. package/dist/security/output-encoder.js +0 -295
  187. package/dist/security/output-encoder.js.map +0 -1
  188. package/dist/security/prompt-injection-guard.d.ts +0 -59
  189. package/dist/security/prompt-injection-guard.d.ts.map +0 -1
  190. package/dist/security/prompt-injection-guard.js +0 -249
  191. package/dist/security/prompt-injection-guard.js.map +0 -1
  192. package/dist/security/sanitisation.d.ts +0 -67
  193. package/dist/security/sanitisation.d.ts.map +0 -1
  194. package/dist/security/sanitisation.js +0 -398
  195. package/dist/security/sanitisation.js.map +0 -1
  196. package/dist/security/security-service.d.ts +0 -103
  197. package/dist/security/security-service.d.ts.map +0 -1
  198. package/dist/security/security-service.js +0 -303
  199. package/dist/security/security-service.js.map +0 -1
  200. package/dist/security-config.d.ts +0 -45
  201. package/dist/security-config.d.ts.map +0 -1
  202. package/dist/security-config.js +0 -63
  203. package/dist/security-config.js.map +0 -1
  204. package/dist/system/function-list.d.ts +0 -61
  205. package/dist/system/function-list.d.ts.map +0 -1
  206. package/dist/system/function-list.js +0 -111
  207. package/dist/system/function-list.js.map +0 -1
  208. package/dist/system/function-registry.d.ts +0 -23
  209. package/dist/system/function-registry.d.ts.map +0 -1
  210. package/dist/system/function-registry.js +0 -136
  211. package/dist/system/function-registry.js.map +0 -1
  212. package/dist/system/health-check.d.ts +0 -33
  213. package/dist/system/health-check.d.ts.map +0 -1
  214. package/dist/system/health-check.js +0 -98
  215. package/dist/system/health-check.js.map +0 -1
  216. package/dist/system/path-resolver.d.ts +0 -55
  217. package/dist/system/path-resolver.d.ts.map +0 -1
  218. package/dist/system/path-resolver.js +0 -90
  219. package/dist/system/path-resolver.js.map +0 -1
  220. package/dist/templates/plugin-template.d.ts +0 -121
  221. package/dist/templates/plugin-template.d.ts.map +0 -1
  222. package/dist/templates/plugin-template.js +0 -454
  223. package/dist/templates/plugin-template.js.map +0 -1
  224. package/dist/types/chunking-types.d.ts +0 -88
  225. package/dist/types/chunking-types.d.ts.map +0 -1
  226. package/dist/types/chunking-types.js +0 -18
  227. package/dist/types/chunking-types.js.map +0 -1
  228. package/dist/types/prompt-stages.d.ts +0 -30
  229. package/dist/types/prompt-stages.d.ts.map +0 -1
  230. package/dist/types/prompt-stages.js +0 -6
  231. package/dist/types/prompt-stages.js.map +0 -1
  232. package/dist/types.d.ts +0 -45
  233. package/dist/types.d.ts.map +0 -1
  234. package/dist/types.js +0 -6
  235. package/dist/types.js.map +0 -1
  236. package/dist/utils/css-parser.d.ts +0 -26
  237. package/dist/utils/css-parser.d.ts.map +0 -1
  238. package/dist/utils/css-parser.js +0 -117
  239. package/dist/utils/css-parser.js.map +0 -1
  240. package/dist/utils/path-resolver.d.ts +0 -13
  241. package/dist/utils/path-resolver.d.ts.map +0 -1
  242. package/dist/utils/path-resolver.js +0 -78
  243. package/dist/utils/path-resolver.js.map +0 -1
  244. package/dist/utils/plugin-utilities.d.ts +0 -176
  245. package/dist/utils/plugin-utilities.d.ts.map +0 -1
  246. package/dist/utils/plugin-utilities.js +0 -269
  247. package/dist/utils/plugin-utilities.js.map +0 -1
  248. package/dist/utils/streamHandler.d.ts +0 -3
  249. package/dist/utils/streamHandler.d.ts.map +0 -1
  250. package/dist/utils/streamHandler.js +0 -137
  251. package/dist/utils/streamHandler.js.map +0 -1
  252. package/dist/validation/output-validator.d.ts +0 -136
  253. package/dist/validation/output-validator.d.ts.map +0 -1
  254. package/dist/validation/output-validator.js +0 -262
  255. package/dist/validation/output-validator.js.map +0 -1
  256. package/dist/validation/response-factory.d.ts +0 -44
  257. package/dist/validation/response-factory.d.ts.map +0 -1
  258. package/dist/validation/response-factory.js +0 -202
  259. package/dist/validation/response-factory.js.map +0 -1
  260. package/dist/validation/schemas.d.ts +0 -519
  261. package/dist/validation/schemas.d.ts.map +0 -1
  262. package/dist/validation/schemas.js +0 -6
  263. package/dist/validation/schemas.js.map +0 -1
@@ -1,121 +0,0 @@
1
- /**
2
- * Security Integration Helpers
3
- *
4
- * Provides easy-to-use wrapper functions and decorators for integrating
5
- * security into existing plugins with minimal code changes.
6
- */
7
- import { type PluginInterface } from './security-service.js';
8
- /**
9
- * Simple wrapper function that can be added to any plugin's execute method
10
- *
11
- * Usage in any plugin:
12
- * import { withSecurity } from '../security/integration-helpers.js';
13
- *
14
- * async execute(params: any, llmClient: any) {
15
- * return await withSecurity(this, params, llmClient, async (secureParams) => {
16
- * // Your existing plugin logic here
17
- * return await this.originalLogic(secureParams, llmClient);
18
- * });
19
- * }
20
- */
21
- export declare function withSecurity<T>(plugin: PluginInterface, params: any, llmClient: any, originalLogic: (secureParams: any) => Promise<T>): Promise<T>;
22
- /**
23
- * Quick parameter validation helper
24
- *
25
- * Usage:
26
- * const safePath = await secureParam(params.filePath, 'file-path');
27
- * const safeCode = await secureParam(params.code, 'code');
28
- */
29
- export declare function secureParam(value: any, context?: 'file-path' | 'code' | 'prompt' | 'general'): Promise<any>;
30
- /**
31
- * File path validation helper
32
- *
33
- * Usage:
34
- * const safePath = await validatePath(params.filePath);
35
- * const content = await readFileContent(safePath);
36
- */
37
- export declare function validatePath(filePath: string): Promise<string>;
38
- /**
39
- * Output encoding helper
40
- *
41
- * Usage:
42
- * const safeHtml = encodeForContext(userContent, 'html');
43
- * const safeJson = encodeForContext(responseData, 'json');
44
- */
45
- export declare function encodeForContext(content: any, context: 'html' | 'json' | 'markdown' | 'plain-text' | 'code' | 'xml'): any;
46
- /**
47
- * Plugin wrapper class for complete security integration
48
- *
49
- * Usage:
50
- * class MyPlugin extends SecurePlugin {
51
- * // Your plugin implementation
52
- * }
53
- */
54
- export declare abstract class SecurePlugin implements PluginInterface {
55
- abstract name: string;
56
- abstract category: 'analyze' | 'generate' | 'multifile' | 'custom' | 'system';
57
- abstract executeSecurely(params: any, llmClient: any): Promise<any>;
58
- execute(params: any, llmClient: any): Promise<any>;
59
- executeOriginal(params: any, llmClient: any): Promise<any>;
60
- }
61
- /**
62
- * Utility function to wrap existing plugin execute methods
63
- *
64
- * Usage in plugin files:
65
- * const originalExecute = plugin.execute.bind(plugin);
66
- * plugin.execute = wrapPluginExecution(plugin, originalExecute);
67
- */
68
- export declare function wrapPluginExecution(plugin: PluginInterface, originalExecute: (params: any, llmClient: any) => Promise<any>): (params: any, llmClient: any) => Promise<any>;
69
- /**
70
- * Batch security processing for multiple parameters
71
- *
72
- * Usage:
73
- * const secureParams = await secureMultipleParams({
74
- * filePath: params.filePath,
75
- * code: params.code,
76
- * userInput: params.userInput
77
- * }, {
78
- * filePath: 'file-path',
79
- * code: 'code',
80
- * userInput: 'general'
81
- * });
82
- */
83
- export declare function secureMultipleParams(params: Record<string, any>, contexts: Record<string, 'file-path' | 'code' | 'prompt' | 'general'>): Promise<Record<string, any>>;
84
- /**
85
- * Security configuration helper
86
- */
87
- export declare const SecurityConfig: {
88
- /**
89
- * Enable/disable security features globally
90
- */
91
- setGlobal(config: {
92
- sanitisation?: boolean;
93
- injectionDetection?: boolean;
94
- outputEncoding?: boolean;
95
- logEvents?: boolean;
96
- }): void;
97
- /**
98
- * Get current security status
99
- */
100
- getStatus(): {
101
- enabled: boolean;
102
- features: Record<string, boolean>;
103
- diagnostics: any;
104
- };
105
- /**
106
- * Run security diagnostics
107
- */
108
- runTests(): {
109
- sanitisation: boolean;
110
- injection: {
111
- passed: number;
112
- failed: number;
113
- };
114
- encoding: {
115
- passed: boolean;
116
- errors: string[];
117
- };
118
- serviceHealth: boolean;
119
- };
120
- };
121
- //# sourceMappingURL=integration-helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integration-helpers.d.ts","sourceRoot":"","sources":["../../src/security/integration-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoC,KAAK,eAAe,EAAuB,MAAM,uBAAuB,CAAC;AAEpH;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,GAAG,EACX,SAAS,EAAE,GAAG,EACd,aAAa,EAAE,CAAC,YAAY,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,GAAG,EACV,OAAO,GAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAqB,GAC/D,OAAO,CAAC,GAAG,CAAC,CAgBd;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQpE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,KAAK,GACpE,GAAG,CAQL;AAED;;;;;;;GAOG;AACH,8BAAsB,YAAa,YAAW,eAAe;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAG9E,QAAQ,CAAC,eAAe,CAAC,MAAM,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- * Provides easy-to-use wrapper functions and decorators for integrating
5
- * security into existing plugins with minimal code changes.
6
- */
7
- import { securityService } from './security-service.js';
8
- /**
9
- * Simple wrapper function that can be added to any plugin's execute method
10
- *
11
- * Usage in any plugin:
12
- * import { withSecurity } from '../security/integration-helpers.js';
13
- *
14
- * async execute(params: any, llmClient: any) {
15
- * return await withSecurity(this, params, llmClient, async (secureParams) => {
16
- * // Your existing plugin logic here
17
- * return await this.originalLogic(secureParams, llmClient);
18
- * });
19
- * }
20
- */
21
- export async function withSecurity(plugin, params, llmClient, originalLogic) {
22
- // Use the singleton security service
23
- const securityResult = await securityService.secureParameters(params, plugin.name);
24
- if (securityResult.blocked) {
25
- throw new Error(`Security violation: ${securityResult.warnings.join(', ')}`);
26
- }
27
- // Execute original logic with secured parameters
28
- const result = await originalLogic(securityResult.sanitised);
29
- // Secure the output
30
- return await securityService.secureOutput(result, plugin.category);
31
- }
32
- /**
33
- * Quick parameter validation helper
34
- *
35
- * Usage:
36
- * const safePath = await secureParam(params.filePath, 'file-path');
37
- * const safeCode = await secureParam(params.code, 'code');
38
- */
39
- export async function secureParam(value, context = 'general') {
40
- if (typeof value !== 'string') {
41
- return value; // Non-string values pass through
42
- }
43
- const result = await securityService.quickCheck(value, 'parameter');
44
- if (result.blocked) {
45
- throw new Error(`Parameter blocked: ${result.warnings.join(', ')}`);
46
- }
47
- if (result.warnings.length > 0) {
48
- console.warn('Parameter security warnings:', result.warnings);
49
- }
50
- return result.sanitised;
51
- }
52
- /**
53
- * File path validation helper
54
- *
55
- * Usage:
56
- * const safePath = await validatePath(params.filePath);
57
- * const content = await readFileContent(safePath);
58
- */
59
- export async function validatePath(filePath) {
60
- const result = await securityService.validateFilePath(filePath);
61
- if (result.blocked) {
62
- throw new Error(`File path blocked: ${result.warnings.join(', ')}`);
63
- }
64
- return result.sanitised;
65
- }
66
- /**
67
- * Output encoding helper
68
- *
69
- * Usage:
70
- * const safeHtml = encodeForContext(userContent, 'html');
71
- * const safeJson = encodeForContext(responseData, 'json');
72
- */
73
- export function encodeForContext(content, context) {
74
- const result = securityService.encodeOutput(content, context);
75
- if (result.warnings.length > 0) {
76
- console.warn('Output encoding warnings:', result.warnings);
77
- }
78
- return result.encoded;
79
- }
80
- /**
81
- * Plugin wrapper class for complete security integration
82
- *
83
- * Usage:
84
- * class MyPlugin extends SecurePlugin {
85
- * // Your plugin implementation
86
- * }
87
- */
88
- export class SecurePlugin {
89
- // This is called by the MCP system
90
- async execute(params, llmClient) {
91
- return await securityService.executeSecurely(this, params, llmClient);
92
- }
93
- // Redirect to executeSecurely for the security service
94
- async executeOriginal(params, llmClient) {
95
- return await this.executeSecurely(params, llmClient);
96
- }
97
- }
98
- /**
99
- * Utility function to wrap existing plugin execute methods
100
- *
101
- * Usage in plugin files:
102
- * const originalExecute = plugin.execute.bind(plugin);
103
- * plugin.execute = wrapPluginExecution(plugin, originalExecute);
104
- */
105
- export function wrapPluginExecution(plugin, originalExecute) {
106
- return async (params, llmClient) => {
107
- // Create a temporary plugin interface for the security service
108
- const wrappedPlugin = {
109
- name: plugin.name,
110
- category: plugin.category,
111
- execute: originalExecute
112
- };
113
- return await securityService.executeSecurely(wrappedPlugin, params, llmClient);
114
- };
115
- }
116
- /**
117
- * Batch security processing for multiple parameters
118
- *
119
- * Usage:
120
- * const secureParams = await secureMultipleParams({
121
- * filePath: params.filePath,
122
- * code: params.code,
123
- * userInput: params.userInput
124
- * }, {
125
- * filePath: 'file-path',
126
- * code: 'code',
127
- * userInput: 'general'
128
- * });
129
- */
130
- export async function secureMultipleParams(params, contexts) {
131
- const secured = {};
132
- const warnings = [];
133
- for (const [key, value] of Object.entries(params)) {
134
- if (typeof value === 'string' && contexts[key]) {
135
- try {
136
- secured[key] = await secureParam(value, contexts[key]);
137
- }
138
- catch (error) {
139
- throw new Error(`Security violation in parameter '${key}': ${error.message}`);
140
- }
141
- }
142
- else {
143
- secured[key] = value;
144
- }
145
- }
146
- if (warnings.length > 0) {
147
- console.warn('Batch security warnings:', warnings);
148
- }
149
- return secured;
150
- }
151
- /**
152
- * Security configuration helper
153
- */
154
- export const SecurityConfig = {
155
- /**
156
- * Enable/disable security features globally
157
- */
158
- setGlobal(config) {
159
- securityService.updateConfig({
160
- enableSanitisation: config.sanitisation,
161
- enableInjectionDetection: config.injectionDetection,
162
- enableOutputEncoding: config.outputEncoding,
163
- logSecurityEvents: config.logEvents
164
- });
165
- },
166
- /**
167
- * Get current security status
168
- */
169
- getStatus() {
170
- const config = securityService.getConfig();
171
- const diagnostics = securityService.runDiagnostics();
172
- return {
173
- enabled: config.enableSanitisation || config.enableInjectionDetection || config.enableOutputEncoding,
174
- features: {
175
- sanitisation: config.enableSanitisation || false,
176
- injectionDetection: config.enableInjectionDetection || false,
177
- outputEncoding: config.enableOutputEncoding || false,
178
- logging: config.logSecurityEvents || false
179
- },
180
- diagnostics
181
- };
182
- },
183
- /**
184
- * Run security diagnostics
185
- */
186
- runTests() {
187
- return securityService.runDiagnostics();
188
- }
189
- };
190
- //# sourceMappingURL=integration-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integration-helpers.js","sourceRoot":"","sources":["../../src/security/integration-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAmB,eAAe,EAA6C,MAAM,uBAAuB,CAAC;AAEpH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,MAAW,EACX,SAAc,EACd,aAAgD;IAEhD,qCAAqC;IACrC,MAAM,cAAc,GAAG,MAAM,eAAe,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAEnF,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,uBAAuB,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,iDAAiD;IACjD,MAAM,MAAM,GAAG,M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,kBAAkB,IAAI,KAAK;gBAChD,kBAAkB,EAAE,MAAM,CAAC,wBAAwB,IAAI,KAAK;gBAC5D,cAAc,EAAE,MAAM,CAAC,oBAAoB,IAAI,KAAK;gBACpD,OAAO,EAAE,MAAM,CAAC,iBAAiB,IAAI,KAAK;aAC3C;YACD,WAAW;SACZ,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,eAAe,CAAC,cAAc,EAAE,CAAC;IAC1C,CAAC;CACF,CAAC"}
@@ -1,94 +0,0 @@
1
- /**
2
- * Output Encoding and Sanitisation
3
- *
4
- * Provides safe encoding of LLM outputs for different contexts
5
- * preventing XSS and other injection attacks in responses
6
- */
7
- export type OutputContext = 'html' | 'json' | 'markdown' | 'plain-text' | 'code' | 'xml';
8
- export interface EncodingOptions {
9
- context: OutputContext;
10
- preserveFormatting?: boolean;
11
- allowedTags?: string[];
12
- maxLength?: number;
13
- }
14
- export interface EncodingResult {
15
- encoded: string;
16
- truncated: boolean;
17
- removedElements: string[];
18
- warnings: string[];
19
- }
20
- export declare class OutputEncoder {
21
- private static readonly HTML_ENTITIES;
22
- private static readonly SAFE_HTML_TAGS;
23
- private static readonly DANGEROUS_PATTERNS;
24
- /**
25
- * Encode output based on context
26
- */
27
- static encode(content: any, options: EncodingOptions): EncodingResult;
28
- /**
29
- * Encode for HTML context
30
- */
31
- private static encodeForHtml;
32
- /**
33
- * Encode for JSON context
34
- */
35
- private static encodeForJson;
36
- /**
37
- * Encode for Markdown context
38
- */
39
- private static encodeForMarkdown;
40
- /**
41
- * Encode for code context
42
- */
43
- private static encodeForCode;
44
- /**
45
- * Encode for XML context
46
- */
47
- private static encodeForXml;
48
- /**
49
- * Encode for plain text context
50
- */
51
- private static encodeForPlainText;
52
- /**
53
- * Escape HTML entities
54
- */
55
- private static escapeHtmlEntities;
56
- /**
57
- * Sanitise HTML while preserving whitelisted tags
58
- */
59
- private static sanitiseHtmlWithWhitelist;
60
- /**
61
- * Encode streaming response chunks safely
62
- */
63
- static encodeStreamChunk(chunk: string, context: OutputContext, chunkIndex: number): {
64
- encoded: string;
65
- safe: boolean;
66
- warnings: string[];
67
- };
68
- /**
69
- * Batch encode multiple outputs
70
- */
71
- static encodeBatch(contents: string[], options: EncodingOptions): EncodingResult[];
72
- /**
73
- * Create safe output object for API responses
74
- */
75
- static createSafeResponse(data: any, context?: OutputContext): {
76
- data: any;
77
- metadata: {
78
- encoded: boolean;
79
- warnings: string[];
80
- };
81
- };
82
- /**
83
- * Recursively encode object properties
84
- */
85
- private static encodeObjectRecursively;
86
- /**
87
- * Validate encoding is working correctly
88
- */
89
- static validateEncoding(): {
90
- passed: boolean;
91
- errors: string[];
92
- };
93
- }
94
- //# sourceMappingURL=output-encoder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"output-encoder.d.ts","sourceRoot":"","sources":["../../src/security/output-encoder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;AAEzF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,aAAa,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,qBAAa,aAAa;IAGxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CASnC;IAGF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAGpC;IAIF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAaxC;IAEF;;OAEG;I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