@yasserkhanorg/e2e-agents 0.3.2

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 (221) hide show
  1. package/LICENSE +168 -0
  2. package/README.md +620 -0
  3. package/dist/agent/analysis.d.ts +62 -0
  4. package/dist/agent/analysis.d.ts.map +1 -0
  5. package/dist/agent/analysis.js +292 -0
  6. package/dist/agent/blast_radius.d.ts +4 -0
  7. package/dist/agent/blast_radius.d.ts.map +1 -0
  8. package/dist/agent/blast_radius.js +37 -0
  9. package/dist/agent/cache_utils.d.ts +38 -0
  10. package/dist/agent/cache_utils.d.ts.map +1 -0
  11. package/dist/agent/cache_utils.js +67 -0
  12. package/dist/agent/config.d.ts +148 -0
  13. package/dist/agent/config.d.ts.map +1 -0
  14. package/dist/agent/config.js +640 -0
  15. package/dist/agent/dependency_graph.d.ts +14 -0
  16. package/dist/agent/dependency_graph.d.ts.map +1 -0
  17. package/dist/agent/dependency_graph.js +227 -0
  18. package/dist/agent/feedback.d.ts +55 -0
  19. package/dist/agent/feedback.d.ts.map +1 -0
  20. package/dist/agent/feedback.js +257 -0
  21. package/dist/agent/flags.d.ts +23 -0
  22. package/dist/agent/flags.d.ts.map +1 -0
  23. package/dist/agent/flags.js +171 -0
  24. package/dist/agent/flow_catalog.d.ts +25 -0
  25. package/dist/agent/flow_catalog.d.ts.map +1 -0
  26. package/dist/agent/flow_catalog.js +106 -0
  27. package/dist/agent/flow_mapping.d.ts +10 -0
  28. package/dist/agent/flow_mapping.d.ts.map +1 -0
  29. package/dist/agent/flow_mapping.js +84 -0
  30. package/dist/agent/framework.d.ts +13 -0
  31. package/dist/agent/framework.d.ts.map +1 -0
  32. package/dist/agent/framework.js +149 -0
  33. package/dist/agent/gap_suggestions.d.ts +14 -0
  34. package/dist/agent/gap_suggestions.d.ts.map +1 -0
  35. package/dist/agent/gap_suggestions.js +101 -0
  36. package/dist/agent/generator.d.ts +10 -0
  37. package/dist/agent/generator.d.ts.map +1 -0
  38. package/dist/agent/generator.js +115 -0
  39. package/dist/agent/git.d.ts +11 -0
  40. package/dist/agent/git.d.ts.map +1 -0
  41. package/dist/agent/git.js +90 -0
  42. package/dist/agent/handoff.d.ts +22 -0
  43. package/dist/agent/handoff.d.ts.map +1 -0
  44. package/dist/agent/handoff.js +180 -0
  45. package/dist/agent/impact-analyzer.d.ts +114 -0
  46. package/dist/agent/impact-analyzer.d.ts.map +1 -0
  47. package/dist/agent/impact-analyzer.js +557 -0
  48. package/dist/agent/index.d.ts +21 -0
  49. package/dist/agent/index.d.ts.map +1 -0
  50. package/dist/agent/index.js +38 -0
  51. package/dist/agent/model-router.d.ts +57 -0
  52. package/dist/agent/model-router.d.ts.map +1 -0
  53. package/dist/agent/model-router.js +154 -0
  54. package/dist/agent/operational_insights.d.ts +41 -0
  55. package/dist/agent/operational_insights.d.ts.map +1 -0
  56. package/dist/agent/operational_insights.js +126 -0
  57. package/dist/agent/pipeline.d.ts +23 -0
  58. package/dist/agent/pipeline.d.ts.map +1 -0
  59. package/dist/agent/pipeline.js +609 -0
  60. package/dist/agent/plan.d.ts +91 -0
  61. package/dist/agent/plan.d.ts.map +1 -0
  62. package/dist/agent/plan.js +331 -0
  63. package/dist/agent/playwright_report.d.ts +8 -0
  64. package/dist/agent/playwright_report.d.ts.map +1 -0
  65. package/dist/agent/playwright_report.js +126 -0
  66. package/dist/agent/report-generator.d.ts +24 -0
  67. package/dist/agent/report-generator.d.ts.map +1 -0
  68. package/dist/agent/report-generator.js +250 -0
  69. package/dist/agent/report.d.ts +81 -0
  70. package/dist/agent/report.d.ts.map +1 -0
  71. package/dist/agent/report.js +147 -0
  72. package/dist/agent/runner.d.ts +7 -0
  73. package/dist/agent/runner.d.ts.map +1 -0
  74. package/dist/agent/runner.js +576 -0
  75. package/dist/agent/selectors.d.ts +10 -0
  76. package/dist/agent/selectors.d.ts.map +1 -0
  77. package/dist/agent/selectors.js +75 -0
  78. package/dist/agent/spec-bridge.d.ts +101 -0
  79. package/dist/agent/spec-bridge.d.ts.map +1 -0
  80. package/dist/agent/spec-bridge.js +273 -0
  81. package/dist/agent/spec-builder.d.ts +102 -0
  82. package/dist/agent/spec-builder.d.ts.map +1 -0
  83. package/dist/agent/spec-builder.js +273 -0
  84. package/dist/agent/subsystem_risk.d.ts +23 -0
  85. package/dist/agent/subsystem_risk.d.ts.map +1 -0
  86. package/dist/agent/subsystem_risk.js +207 -0
  87. package/dist/agent/telemetry.d.ts +84 -0
  88. package/dist/agent/telemetry.d.ts.map +1 -0
  89. package/dist/agent/telemetry.js +220 -0
  90. package/dist/agent/test_path.d.ts +2 -0
  91. package/dist/agent/test_path.d.ts.map +1 -0
  92. package/dist/agent/test_path.js +23 -0
  93. package/dist/agent/tests.d.ts +18 -0
  94. package/dist/agent/tests.d.ts.map +1 -0
  95. package/dist/agent/tests.js +106 -0
  96. package/dist/agent/traceability.d.ts +22 -0
  97. package/dist/agent/traceability.d.ts.map +1 -0
  98. package/dist/agent/traceability.js +183 -0
  99. package/dist/agent/traceability_capture.d.ts +18 -0
  100. package/dist/agent/traceability_capture.d.ts.map +1 -0
  101. package/dist/agent/traceability_capture.js +313 -0
  102. package/dist/agent/traceability_ingest.d.ts +21 -0
  103. package/dist/agent/traceability_ingest.d.ts.map +1 -0
  104. package/dist/agent/traceability_ingest.js +237 -0
  105. package/dist/agent/utils.d.ts +13 -0
  106. package/dist/agent/utils.d.ts.map +1 -0
  107. package/dist/agent/utils.js +152 -0
  108. package/dist/agent/validators/selector-validator.d.ts +74 -0
  109. package/dist/agent/validators/selector-validator.d.ts.map +1 -0
  110. package/dist/agent/validators/selector-validator.js +165 -0
  111. package/dist/anthropic_provider.d.ts +65 -0
  112. package/dist/anthropic_provider.d.ts.map +1 -0
  113. package/dist/anthropic_provider.js +332 -0
  114. package/dist/api.d.ts +48 -0
  115. package/dist/api.d.ts.map +1 -0
  116. package/dist/api.js +113 -0
  117. package/dist/base_provider.d.ts +53 -0
  118. package/dist/base_provider.d.ts.map +1 -0
  119. package/dist/base_provider.js +81 -0
  120. package/dist/cli.d.ts +3 -0
  121. package/dist/cli.d.ts.map +1 -0
  122. package/dist/cli.js +843 -0
  123. package/dist/custom_provider.d.ts +20 -0
  124. package/dist/custom_provider.d.ts.map +1 -0
  125. package/dist/custom_provider.js +276 -0
  126. package/dist/e2e-test-gen/index.d.ts +51 -0
  127. package/dist/e2e-test-gen/index.d.ts.map +1 -0
  128. package/dist/e2e-test-gen/index.js +57 -0
  129. package/dist/e2e-test-gen/spec_parser.d.ts +142 -0
  130. package/dist/e2e-test-gen/spec_parser.d.ts.map +1 -0
  131. package/dist/e2e-test-gen/spec_parser.js +786 -0
  132. package/dist/e2e-test-gen/types.d.ts +185 -0
  133. package/dist/e2e-test-gen/types.d.ts.map +1 -0
  134. package/dist/e2e-test-gen/types.js +4 -0
  135. package/dist/esm/agent/analysis.js +287 -0
  136. package/dist/esm/agent/blast_radius.js +34 -0
  137. package/dist/esm/agent/cache_utils.js +63 -0
  138. package/dist/esm/agent/config.js +637 -0
  139. package/dist/esm/agent/dependency_graph.js +224 -0
  140. package/dist/esm/agent/feedback.js +253 -0
  141. package/dist/esm/agent/flags.js +160 -0
  142. package/dist/esm/agent/flow_catalog.js +103 -0
  143. package/dist/esm/agent/flow_mapping.js +81 -0
  144. package/dist/esm/agent/framework.js +145 -0
  145. package/dist/esm/agent/gap_suggestions.js +98 -0
  146. package/dist/esm/agent/generator.js +112 -0
  147. package/dist/esm/agent/git.js +87 -0
  148. package/dist/esm/agent/handoff.js +177 -0
  149. package/dist/esm/agent/impact-analyzer.js +548 -0
  150. package/dist/esm/agent/index.js +22 -0
  151. package/dist/esm/agent/model-router.js +150 -0
  152. package/dist/esm/agent/operational_insights.js +123 -0
  153. package/dist/esm/agent/pipeline.js +605 -0
  154. package/dist/esm/agent/plan.js +324 -0
  155. package/dist/esm/agent/playwright_report.js +123 -0
  156. package/dist/esm/agent/report-generator.js +247 -0
  157. package/dist/esm/agent/report.js +144 -0
  158. package/dist/esm/agent/runner.js +572 -0
  159. package/dist/esm/agent/selectors.js +71 -0
  160. package/dist/esm/agent/spec-bridge.js +267 -0
  161. package/dist/esm/agent/spec-builder.js +267 -0
  162. package/dist/esm/agent/subsystem_risk.js +204 -0
  163. package/dist/esm/agent/telemetry.js +216 -0
  164. package/dist/esm/agent/test_path.js +20 -0
  165. package/dist/esm/agent/tests.js +101 -0
  166. package/dist/esm/agent/traceability.js +180 -0
  167. package/dist/esm/agent/traceability_capture.js +310 -0
  168. package/dist/esm/agent/traceability_ingest.js +234 -0
  169. package/dist/esm/agent/utils.js +138 -0
  170. package/dist/esm/agent/validators/selector-validator.js +160 -0
  171. package/dist/esm/anthropic_provider.js +324 -0
  172. package/dist/esm/api.js +105 -0
  173. package/dist/esm/base_provider.js +77 -0
  174. package/dist/esm/cli.js +841 -0
  175. package/dist/esm/custom_provider.js +272 -0
  176. package/dist/esm/e2e-test-gen/index.js +50 -0
  177. package/dist/esm/e2e-test-gen/spec_parser.js +782 -0
  178. package/dist/esm/e2e-test-gen/types.js +3 -0
  179. package/dist/esm/index.js +16 -0
  180. package/dist/esm/logger.js +89 -0
  181. package/dist/esm/mcp-server.js +465 -0
  182. package/dist/esm/ollama_provider.js +300 -0
  183. package/dist/esm/openai_provider.js +242 -0
  184. package/dist/esm/package.json +3 -0
  185. package/dist/esm/plan-and-test-constants.js +126 -0
  186. package/dist/esm/provider_factory.js +336 -0
  187. package/dist/esm/provider_interface.js +23 -0
  188. package/dist/esm/provider_utils.js +96 -0
  189. package/dist/index.d.ts +31 -0
  190. package/dist/index.d.ts.map +1 -0
  191. package/dist/index.js +41 -0
  192. package/dist/logger.d.ts +23 -0
  193. package/dist/logger.d.ts.map +1 -0
  194. package/dist/logger.js +93 -0
  195. package/dist/mcp-server.d.ts +35 -0
  196. package/dist/mcp-server.d.ts.map +1 -0
  197. package/dist/mcp-server.js +469 -0
  198. package/dist/ollama_provider.d.ts +65 -0
  199. package/dist/ollama_provider.d.ts.map +1 -0
  200. package/dist/ollama_provider.js +308 -0
  201. package/dist/openai_provider.d.ts +23 -0
  202. package/dist/openai_provider.d.ts.map +1 -0
  203. package/dist/openai_provider.js +250 -0
  204. package/dist/plan-and-test-constants.d.ts +110 -0
  205. package/dist/plan-and-test-constants.d.ts.map +1 -0
  206. package/dist/plan-and-test-constants.js +132 -0
  207. package/dist/provider_factory.d.ts +99 -0
  208. package/dist/provider_factory.d.ts.map +1 -0
  209. package/dist/provider_factory.js +341 -0
  210. package/dist/provider_interface.d.ts +358 -0
  211. package/dist/provider_interface.d.ts.map +1 -0
  212. package/dist/provider_interface.js +28 -0
  213. package/dist/provider_utils.d.ts +39 -0
  214. package/dist/provider_utils.d.ts.map +1 -0
  215. package/dist/provider_utils.js +103 -0
  216. package/package.json +101 -0
  217. package/schemas/gap.schema.json +18 -0
  218. package/schemas/impact.schema.json +418 -0
  219. package/schemas/plan.schema.json +285 -0
  220. package/schemas/subsystem-risk-map.schema.json +62 -0
  221. package/schemas/traceability-input.schema.json +122 -0
@@ -0,0 +1,358 @@
1
+ /**
2
+ * LLM Provider Interface - Core abstraction for pluggable AI models
3
+ *
4
+ * Enables the autonomous testing system to work with any LLM:
5
+ * - Ollama (free, local)
6
+ * - Anthropic Claude (premium, vision support)
7
+ * - OpenAI (premium)
8
+ * - Custom providers (any OpenAI-compatible API)
9
+ *
10
+ * Design Philosophy:
11
+ * - Provider-agnostic: Switch LLMs without changing test logic
12
+ * - Capability-aware: System adapts based on provider features
13
+ * - Cost-conscious: Track token usage and costs
14
+ * - Hybrid-friendly: Mix free and premium providers
15
+ */
16
+ /**
17
+ * Core LLM provider interface - all providers must implement this
18
+ */
19
+ export interface LLMProvider {
20
+ /**
21
+ * Unique identifier for this provider
22
+ * Examples: 'anthropic', 'ollama', 'openai', 'custom'
23
+ */
24
+ name: string;
25
+ /**
26
+ * Generate text from a prompt
27
+ * Primary method for most LLM operations
28
+ */
29
+ generateText(prompt: string, options?: GenerateOptions): Promise<LLMResponse>;
30
+ /**
31
+ * Analyze images with vision models (optional - not all providers support)
32
+ * Used for spec screenshot comparison and visual bug detection
33
+ */
34
+ analyzeImage?(images: ImageInput[], prompt: string, options?: GenerateOptions): Promise<LLMResponse>;
35
+ /**
36
+ * Stream text generation (optional - for real-time UI feedback)
37
+ * Yields text chunks as they're generated
38
+ */
39
+ streamText?(prompt: string, options?: GenerateOptions): AsyncGenerator<string, void, unknown>;
40
+ /**
41
+ * Provider capabilities - what this LLM can do
42
+ */
43
+ capabilities: ProviderCapabilities;
44
+ /**
45
+ * Get usage statistics for cost tracking and monitoring
46
+ */
47
+ getUsageStats(): ProviderUsageStats;
48
+ /**
49
+ * Reset usage statistics (typically called at start of new cycle)
50
+ */
51
+ resetUsageStats(): void;
52
+ }
53
+ /**
54
+ * Options for text generation
55
+ */
56
+ export interface GenerateOptions {
57
+ /**
58
+ * Maximum tokens to generate in response
59
+ * Helps control costs and response length
60
+ */
61
+ maxTokens?: number;
62
+ /**
63
+ * Temperature (0.0 - 1.0)
64
+ * Lower = more focused/deterministic, Higher = more creative/random
65
+ */
66
+ temperature?: number;
67
+ /**
68
+ * System prompt to set context/behavior
69
+ */
70
+ systemPrompt?: string;
71
+ /**
72
+ * Stop sequences - generation stops when these are encountered
73
+ */
74
+ stopSequences?: string[];
75
+ /**
76
+ * Top-p sampling (0.0 - 1.0)
77
+ * Alternative to temperature for controlling randomness
78
+ */
79
+ topP?: number;
80
+ /**
81
+ * Timeout for request in milliseconds
82
+ */
83
+ timeout?: number;
84
+ }
85
+ /**
86
+ * Image input for vision analysis
87
+ * Also supports PDF documents for specification parsing
88
+ */
89
+ export interface ImageInput {
90
+ /**
91
+ * Base64-encoded image or document data
92
+ */
93
+ data?: string;
94
+ base64?: string;
95
+ /**
96
+ * Media type (e.g., 'image/png', 'image/jpeg', 'application/pdf')
97
+ */
98
+ mimeType?: 'image/png' | 'image/jpeg' | 'image/webp' | 'application/pdf';
99
+ mediaType?: 'image/png' | 'image/jpeg' | 'image/webp';
100
+ /**
101
+ * Optional description of what the image shows
102
+ */
103
+ description?: string;
104
+ }
105
+ /**
106
+ * Response from LLM generation
107
+ */
108
+ export interface LLMResponse {
109
+ /**
110
+ * Generated text content
111
+ */
112
+ text: string;
113
+ /**
114
+ * Token usage for this request
115
+ */
116
+ usage: TokenUsage;
117
+ /**
118
+ * Calculated cost in USD
119
+ */
120
+ cost: number;
121
+ /**
122
+ * Optional confidence score (0.0 - 1.0) if provider supports it
123
+ */
124
+ confidence?: number;
125
+ /**
126
+ * Raw response metadata from provider (for debugging)
127
+ */
128
+ metadata?: Record<string, unknown>;
129
+ }
130
+ /**
131
+ * Token usage information
132
+ */
133
+ export interface TokenUsage {
134
+ /**
135
+ * Tokens in the prompt/input
136
+ */
137
+ inputTokens: number;
138
+ /**
139
+ * Tokens in the generated output
140
+ */
141
+ outputTokens: number;
142
+ /**
143
+ * Total tokens (input + output)
144
+ */
145
+ totalTokens: number;
146
+ /**
147
+ * Cached tokens (if provider supports caching)
148
+ */
149
+ cachedTokens?: number;
150
+ }
151
+ /**
152
+ * Provider capabilities - what features this LLM supports
153
+ */
154
+ export interface ProviderCapabilities {
155
+ /**
156
+ * Supports image analysis (vision models)
157
+ */
158
+ vision: boolean;
159
+ /**
160
+ * Supports streaming responses
161
+ */
162
+ streaming: boolean;
163
+ /**
164
+ * Maximum context window in tokens
165
+ */
166
+ maxTokens: number;
167
+ /**
168
+ * Cost per 1 million input tokens (USD)
169
+ */
170
+ costPer1MInputTokens: number;
171
+ /**
172
+ * Cost per 1 million output tokens (USD)
173
+ */
174
+ costPer1MOutputTokens: number;
175
+ /**
176
+ * Supports function/tool calling
177
+ */
178
+ supportsTools: boolean;
179
+ /**
180
+ * Supports prompt caching to reduce costs
181
+ */
182
+ supportsPromptCaching: boolean;
183
+ /**
184
+ * Typical response time in milliseconds
185
+ */
186
+ typicalResponseTimeMs: number;
187
+ }
188
+ /**
189
+ * Cumulative usage statistics for a provider
190
+ */
191
+ export interface ProviderUsageStats {
192
+ /**
193
+ * Total number of requests made
194
+ */
195
+ requestCount: number;
196
+ /**
197
+ * Total input tokens used
198
+ */
199
+ totalInputTokens: number;
200
+ /**
201
+ * Total output tokens generated
202
+ */
203
+ totalOutputTokens: number;
204
+ /**
205
+ * Total tokens (input + output)
206
+ */
207
+ totalTokens: number;
208
+ /**
209
+ * Total cost in USD
210
+ */
211
+ totalCost: number;
212
+ /**
213
+ * Average response time in milliseconds
214
+ */
215
+ averageResponseTimeMs: number;
216
+ /**
217
+ * Number of failed requests
218
+ */
219
+ failedRequests: number;
220
+ /**
221
+ * When stats tracking started
222
+ */
223
+ startTime: Date;
224
+ /**
225
+ * When stats were last updated
226
+ */
227
+ lastUpdated: Date;
228
+ }
229
+ /**
230
+ * Configuration for creating a provider
231
+ */
232
+ export interface ProviderConfig {
233
+ /**
234
+ * Provider type
235
+ */
236
+ type: 'anthropic' | 'ollama' | 'openai' | 'custom';
237
+ /**
238
+ * Provider-specific configuration
239
+ */
240
+ config: AnthropicConfig | OllamaConfig | OpenAIConfig | CustomConfig;
241
+ }
242
+ /**
243
+ * Anthropic (Claude) provider configuration
244
+ */
245
+ export interface AnthropicConfig {
246
+ /**
247
+ * Anthropic API key
248
+ */
249
+ apiKey: string;
250
+ /**
251
+ * Model to use (default: claude-sonnet-4-5-20250929)
252
+ */
253
+ model?: string;
254
+ /**
255
+ * API base URL (for testing/proxies)
256
+ */
257
+ baseUrl?: string;
258
+ /**
259
+ * Default max tokens for requests
260
+ */
261
+ defaultMaxTokens?: number;
262
+ }
263
+ /**
264
+ * Ollama (local/free) provider configuration
265
+ */
266
+ export interface OllamaConfig {
267
+ /**
268
+ * Ollama API base URL (default: http://localhost:11434, normalized to /v1)
269
+ */
270
+ baseUrl?: string;
271
+ /**
272
+ * Model to use (default: deepseek-r1:7b)
273
+ * Other options: llama4:13b, deepseek-r1:14b
274
+ */
275
+ model?: string;
276
+ /**
277
+ * Request timeout in milliseconds
278
+ */
279
+ timeout?: number;
280
+ }
281
+ /**
282
+ * OpenAI provider configuration
283
+ */
284
+ export interface OpenAIConfig {
285
+ /**
286
+ * OpenAI API key
287
+ */
288
+ apiKey: string;
289
+ /**
290
+ * Model to use (default: gpt-4)
291
+ */
292
+ model?: string;
293
+ /**
294
+ * API base URL (for custom endpoints)
295
+ */
296
+ baseUrl?: string;
297
+ /**
298
+ * Organization ID (optional)
299
+ */
300
+ organizationId?: string;
301
+ /**
302
+ * Optional max context window in tokens (for capability reporting)
303
+ */
304
+ maxTokens?: number;
305
+ /**
306
+ * Optional cost per 1M input tokens (for cost tracking)
307
+ */
308
+ costPer1MInputTokens?: number;
309
+ /**
310
+ * Optional cost per 1M output tokens (for cost tracking)
311
+ */
312
+ costPer1MOutputTokens?: number;
313
+ }
314
+ /**
315
+ * Custom provider configuration
316
+ */
317
+ export interface CustomConfig {
318
+ /**
319
+ * API endpoint URL
320
+ */
321
+ baseUrl: string;
322
+ /**
323
+ * Authentication headers
324
+ */
325
+ auth: Record<string, string>;
326
+ /**
327
+ * Model identifier
328
+ */
329
+ model: string;
330
+ /**
331
+ * Request format ('openai' | 'anthropic' | 'custom')
332
+ */
333
+ requestFormat: 'openai' | 'anthropic' | 'custom';
334
+ /**
335
+ * Custom request transformer (if format is 'custom')
336
+ */
337
+ transformRequest?: (prompt: string, options?: GenerateOptions) => unknown;
338
+ /**
339
+ * Custom response transformer (if format is 'custom')
340
+ */
341
+ transformResponse?: (response: unknown) => LLMResponse;
342
+ }
343
+ /**
344
+ * Error thrown by LLM providers
345
+ */
346
+ export declare class LLMProviderError extends Error {
347
+ readonly provider: string;
348
+ readonly statusCode?: number | undefined;
349
+ readonly cause?: unknown | undefined;
350
+ constructor(message: string, provider: string, statusCode?: number | undefined, cause?: unknown | undefined);
351
+ }
352
+ /**
353
+ * Error thrown when a required capability is not supported
354
+ */
355
+ export declare class UnsupportedCapabilityError extends LLMProviderError {
356
+ constructor(provider: string, capability: string);
357
+ }
358
+ //# sourceMappingURL=provider_interface.d.ts.map
@@ -0,0 +1 @@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CAAC;IAE9B;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,aAAa,EAAE,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;IAEjD;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;IAE1E;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,WAAW,CAAC;CAC1D;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;aAGnB,QAAQ,EAAE,MAAM;aAChB,UAAU,CAAC,EAAE,MAAM;aACnB,KAAK,CAAC,EAAE,OAAO;gBAH/B,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,KAAK,CAAC,EAAE,OAAO,YAAA;CAKtC;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,gBAAgB;gBAChD,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAInD"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
3
+ // See LICENSE.txt for license information.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.UnsupportedCapabilityError = exports.LLMProviderError = void 0;
6
+ /**
7
+ * Error thrown by LLM providers
8
+ */
9
+ class LLMProviderError extends Error {
10
+ constructor(message, provider, statusCode, cause) {
11
+ super(message);
12
+ this.provider = provider;
13
+ this.statusCode = statusCode;
14
+ this.cause = cause;
15
+ this.name = 'LLMProviderError';
16
+ }
17
+ }
18
+ exports.LLMProviderError = LLMProviderError;
19
+ /**
20
+ * Error thrown when a required capability is not supported
21
+ */
22
+ class UnsupportedCapabilityError extends LLMProviderError {
23
+ constructor(provider, capability) {
24
+ super(`Provider '${provider}' does not support capability: ${capability}`, provider);
25
+ this.name = 'UnsupportedCapabilityError';
26
+ }
27
+ }
28
+ exports.UnsupportedCapabilityError = UnsupportedCapabilityError;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * SECURITY: Shared utility functions for all LLM providers
3
+ * Eliminates code duplication and ensures consistent error handling
4
+ */
5
+ /**
6
+ * Pre-compiled regex patterns for API key validation
7
+ * Compiled once and reused to avoid repeated regex compilation
8
+ */
9
+ export declare const API_KEY_PATTERNS: {
10
+ anthropic: RegExp;
11
+ openai: RegExp;
12
+ };
13
+ /**
14
+ * SECURITY: Sanitize error messages to prevent information leakage
15
+ * Maps specific API errors to safe, user-friendly messages
16
+ * Prevents leaking stack traces, API keys, or internal details
17
+ */
18
+ export declare function sanitizeErrorMessage(error: unknown, context: string): string;
19
+ /**
20
+ * Generic timeout wrapper for promises
21
+ * Rejects with timeout error if promise doesn't resolve in time
22
+ */
23
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, context: string): Promise<T>;
24
+ /**
25
+ * Check if a hostname is localhost
26
+ * Used by URL validation to allow HTTP for local development
27
+ */
28
+ export declare function isLocalhost(hostname: string | undefined): boolean;
29
+ /**
30
+ * SECURITY: Validate and enforce HTTPS for remote URLs
31
+ * Allows HTTP only for localhost development
32
+ * Returns validation result with optional warning message
33
+ */
34
+ export declare function validateAndSanitizeUrl(baseUrl: string | undefined): {
35
+ valid: boolean;
36
+ url?: string;
37
+ warning?: string;
38
+ };
39
+ //# sourceMappingURL=provider_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider_utils.d.ts","sourceRoot":"","sources":["../src/provider_utils.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAyB5E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EACzB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,CAAC,CAkBZ;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAKjE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,GAAG,SAAS,GAC5B;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,CAoBlD"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
3
+ // See LICENSE.txt for license information.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.API_KEY_PATTERNS = void 0;
6
+ exports.sanitizeErrorMessage = sanitizeErrorMessage;
7
+ exports.withTimeout = withTimeout;
8
+ exports.isLocalhost = isLocalhost;
9
+ exports.validateAndSanitizeUrl = validateAndSanitizeUrl;
10
+ /**
11
+ * SECURITY: Shared utility functions for all LLM providers
12
+ * Eliminates code duplication and ensures consistent error handling
13
+ */
14
+ /**
15
+ * Pre-compiled regex patterns for API key validation
16
+ * Compiled once and reused to avoid repeated regex compilation
17
+ */
18
+ exports.API_KEY_PATTERNS = {
19
+ anthropic: /^sk-ant-[a-zA-Z0-9_\-]{20,}$/,
20
+ openai: /^sk-[a-zA-Z0-9_\-]{20,}$/,
21
+ };
22
+ /**
23
+ * SECURITY: Sanitize error messages to prevent information leakage
24
+ * Maps specific API errors to safe, user-friendly messages
25
+ * Prevents leaking stack traces, API keys, or internal details
26
+ */
27
+ function sanitizeErrorMessage(error, context) {
28
+ if (error instanceof Error) {
29
+ const msg = error.message.toLowerCase();
30
+ // Map specific API errors to safe messages
31
+ if (msg.includes('401') || msg.includes('authentication')) {
32
+ return `Authentication failed (${context})`;
33
+ }
34
+ if (msg.includes('429') || msg.includes('rate')) {
35
+ return `Rate limit exceeded (${context})`;
36
+ }
37
+ if (msg.includes('timeout') || msg.includes('etimedout')) {
38
+ return `Request timeout (${context})`;
39
+ }
40
+ if (msg.includes('network') || msg.includes('econnrefused')) {
41
+ return `Connection failed (${context})`;
42
+ }
43
+ if (msg.includes('enotfound') || msg.includes('getaddrinfo')) {
44
+ return `Host not found (${context})`;
45
+ }
46
+ // Don't leak stack traces, API keys, or internal details
47
+ return `Operation failed (${context})`;
48
+ }
49
+ return 'An unexpected error occurred';
50
+ }
51
+ /**
52
+ * Generic timeout wrapper for promises
53
+ * Rejects with timeout error if promise doesn't resolve in time
54
+ */
55
+ function withTimeout(promise, timeoutMs, context) {
56
+ if (!timeoutMs) {
57
+ return promise;
58
+ }
59
+ return new Promise((resolve, reject) => {
60
+ const timer = setTimeout(() => reject(new Error(`Request timeout (${context})`)), timeoutMs);
61
+ promise.then((value) => {
62
+ clearTimeout(timer);
63
+ resolve(value);
64
+ }, (error) => {
65
+ clearTimeout(timer);
66
+ reject(error);
67
+ });
68
+ });
69
+ }
70
+ /**
71
+ * Check if a hostname is localhost
72
+ * Used by URL validation to allow HTTP for local development
73
+ */
74
+ function isLocalhost(hostname) {
75
+ if (!hostname) {
76
+ return false;
77
+ }
78
+ return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1';
79
+ }
80
+ /**
81
+ * SECURITY: Validate and enforce HTTPS for remote URLs
82
+ * Allows HTTP only for localhost development
83
+ * Returns validation result with optional warning message
84
+ */
85
+ function validateAndSanitizeUrl(baseUrl) {
86
+ if (!baseUrl) {
87
+ return { valid: true };
88
+ }
89
+ try {
90
+ const url = new URL(baseUrl);
91
+ // For non-localhost URLs, require HTTPS
92
+ if (!isLocalhost(url.hostname) && url.protocol !== 'https:') {
93
+ return {
94
+ valid: false,
95
+ warning: `HTTPS required for remote URLs. Got: ${url.protocol}//${url.hostname}`,
96
+ };
97
+ }
98
+ return { valid: true, url: baseUrl };
99
+ }
100
+ catch {
101
+ return { valid: false };
102
+ }
103
+ }
package/package.json ADDED
@@ -0,0 +1,101 @@
1
+ {
2
+ "name": "@yasserkhanorg/e2e-agents",
3
+ "version": "0.3.2",
4
+ "description": "Pluggable LLM provider library for AI-powered test automation. Use Claude, Ollama, or your own LLM. Integrate with Playwright, Jest, or any test framework. MCP server for test agents, cost tracking, and hybrid provider mode.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "license": "Apache-2.0",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "require": "./dist/index.js",
13
+ "import": "./dist/esm/index.js"
14
+ },
15
+ "./mcp": {
16
+ "types": "./dist/mcp-server.d.ts",
17
+ "require": "./dist/mcp-server.js",
18
+ "import": "./dist/esm/mcp-server.js"
19
+ },
20
+ "./schemas/impact": "./schemas/impact.schema.json",
21
+ "./schemas/gap": "./schemas/gap.schema.json",
22
+ "./schemas/plan": "./schemas/plan.schema.json",
23
+ "./schemas/traceability-input": "./schemas/traceability-input.schema.json",
24
+ "./schemas/subsystem-risk-map": "./schemas/subsystem-risk-map.schema.json",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "bin": {
28
+ "e2e-ai-agents": "./dist/cli.js"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "schemas",
33
+ "README.md",
34
+ "LICENSE"
35
+ ],
36
+ "scripts": {
37
+ "build": "npm run build:cjs && npm run build:esm",
38
+ "build:cjs": "tsc -p tsconfig.json",
39
+ "build:esm": "tsc -p tsconfig.esm.json && node scripts/write-esm-package.js",
40
+ "clean": "rm -rf dist",
41
+ "prebuild": "npm run clean",
42
+ "pretest": "npm run build",
43
+ "test": "node --test test/*.js",
44
+ "lint": "tsc -p tsconfig.json --noEmit",
45
+ "mcp:server": "node dist/mcp-server.js"
46
+ },
47
+ "dependencies": {
48
+ "@anthropic-ai/sdk": "^0.73.0",
49
+ "glob": "^11.0.0",
50
+ "marked": "^15.0.6",
51
+ "openai": "^4.73.0",
52
+ "pdf-parse": "^1.1.1"
53
+ },
54
+ "devDependencies": {
55
+ "@types/node": "^22.0.0",
56
+ "@types/pdf-parse": "^1.1.4",
57
+ "typescript": "^5.6.0"
58
+ },
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/yasserfaraazkhan/e2e-agents.git"
62
+ },
63
+ "keywords": [
64
+ "llm",
65
+ "ai",
66
+ "testing",
67
+ "test-automation",
68
+ "e2e",
69
+ "playwright",
70
+ "jest",
71
+ "mocha",
72
+ "cypress",
73
+ "anthropic",
74
+ "claude",
75
+ "ollama",
76
+ "openai",
77
+ "mcp",
78
+ "model-context-protocol",
79
+ "test-agents",
80
+ "ai-testing",
81
+ "autonomous-testing",
82
+ "test-generation",
83
+ "ai-agents",
84
+ "provider-abstraction",
85
+ "framework-agnostic",
86
+ "cost-tracking",
87
+ "hybrid-mode",
88
+ "vision-analysis",
89
+ "screenshot-analysis",
90
+ "test-discovery",
91
+ "test-healing"
92
+ ],
93
+ "engines": {
94
+ "node": ">=20.0.0"
95
+ },
96
+ "author": "Yasser Khan",
97
+ "homepage": "https://github.com/yasserfaraazkhan/e2e-agents",
98
+ "publishConfig": {
99
+ "access": "public"
100
+ }
101
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://mattermost.com/schemas/e2e-agents/gap.schema.json",
4
+ "title": "GapReport",
5
+ "allOf": [
6
+ {
7
+ "$ref": "./impact.schema.json"
8
+ },
9
+ {
10
+ "type": "object",
11
+ "properties": {
12
+ "mode": {
13
+ "const": "gap"
14
+ }
15
+ }
16
+ }
17
+ ]
18
+ }