testchimp-runner-core 0.0.35 → 0.0.37

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 (81) hide show
  1. package/dist/orchestrator/orchestrator-agent.d.ts.map +1 -1
  2. package/dist/orchestrator/orchestrator-agent.js +7 -4
  3. package/dist/orchestrator/orchestrator-agent.js.map +1 -1
  4. package/dist/orchestrator/orchestrator-prompts.d.ts.map +1 -1
  5. package/dist/orchestrator/orchestrator-prompts.js +73 -15
  6. package/dist/orchestrator/orchestrator-prompts.js.map +1 -1
  7. package/dist/orchestrator/page-som-handler.d.ts +1 -2
  8. package/dist/orchestrator/page-som-handler.d.ts.map +1 -1
  9. package/dist/orchestrator/page-som-handler.js +51 -25
  10. package/dist/orchestrator/page-som-handler.js.map +1 -1
  11. package/package.json +6 -1
  12. package/plandocs/BEFORE_AFTER_VERIFICATION.md +0 -148
  13. package/plandocs/COORDINATE_MODE_DIAGNOSIS.md +0 -144
  14. package/plandocs/CREDIT_CALLBACK_ARCHITECTURE.md +0 -253
  15. package/plandocs/HUMAN_LIKE_IMPROVEMENTS.md +0 -642
  16. package/plandocs/IMPLEMENTATION_STATUS.md +0 -108
  17. package/plandocs/INTEGRATION_COMPLETE.md +0 -322
  18. package/plandocs/MULTI_AGENT_ARCHITECTURE_REVIEW.md +0 -844
  19. package/plandocs/ORCHESTRATOR_MVP_SUMMARY.md +0 -539
  20. package/plandocs/PHASE1_ABSTRACTION_COMPLETE.md +0 -241
  21. package/plandocs/PHASE1_FINAL_STATUS.md +0 -210
  22. package/plandocs/PHASE_1_COMPLETE.md +0 -165
  23. package/plandocs/PHASE_1_SUMMARY.md +0 -184
  24. package/plandocs/PLANNING_SESSION_SUMMARY.md +0 -372
  25. package/plandocs/PROMPT_OPTIMIZATION_ANALYSIS.md +0 -120
  26. package/plandocs/PROMPT_SANITY_CHECK.md +0 -120
  27. package/plandocs/SCRIPT_CLEANUP_FEATURE.md +0 -201
  28. package/plandocs/SCRIPT_GENERATION_ARCHITECTURE.md +0 -364
  29. package/plandocs/SELECTOR_IMPROVEMENTS.md +0 -139
  30. package/plandocs/SESSION_SUMMARY_v0.0.33.md +0 -151
  31. package/plandocs/TROUBLESHOOTING_SESSION.md +0 -72
  32. package/plandocs/VISION_DIAGNOSTICS_IMPROVEMENTS.md +0 -336
  33. package/plandocs/VISUAL_AGENT_EVOLUTION_PLAN.md +0 -396
  34. package/plandocs/WHATS_NEW_v0.0.33.md +0 -183
  35. package/plandocs/exploratory-mode-support-v2.plan.md +0 -953
  36. package/plandocs/exploratory-mode-support.plan.md +0 -928
  37. package/plandocs/journey-id-tracking-addendum.md +0 -227
  38. package/releasenotes/RELEASE_0.0.26.md +0 -165
  39. package/releasenotes/RELEASE_0.0.27.md +0 -236
  40. package/releasenotes/RELEASE_0.0.28.md +0 -286
  41. package/src/auth-config.ts +0 -84
  42. package/src/credit-usage-service.ts +0 -188
  43. package/src/env-loader.ts +0 -103
  44. package/src/execution-service.ts +0 -996
  45. package/src/file-handler.ts +0 -104
  46. package/src/index.ts +0 -432
  47. package/src/llm-facade.ts +0 -821
  48. package/src/llm-provider.ts +0 -53
  49. package/src/model-constants.ts +0 -35
  50. package/src/orchestrator/decision-parser.ts +0 -139
  51. package/src/orchestrator/index.ts +0 -58
  52. package/src/orchestrator/orchestrator-agent.ts +0 -1282
  53. package/src/orchestrator/orchestrator-prompts.ts +0 -786
  54. package/src/orchestrator/page-som-handler.ts +0 -1565
  55. package/src/orchestrator/som-types.ts +0 -188
  56. package/src/orchestrator/tool-registry.ts +0 -184
  57. package/src/orchestrator/tools/check-page-ready.ts +0 -75
  58. package/src/orchestrator/tools/extract-data.ts +0 -92
  59. package/src/orchestrator/tools/index.ts +0 -15
  60. package/src/orchestrator/tools/inspect-page.ts +0 -42
  61. package/src/orchestrator/tools/recall-history.ts +0 -72
  62. package/src/orchestrator/tools/refresh-som-markers.ts +0 -69
  63. package/src/orchestrator/tools/take-screenshot.ts +0 -128
  64. package/src/orchestrator/tools/verify-action-result.ts +0 -159
  65. package/src/orchestrator/tools/view-previous-screenshot.ts +0 -103
  66. package/src/orchestrator/types.ts +0 -291
  67. package/src/playwright-mcp-service.ts +0 -224
  68. package/src/progress-reporter.ts +0 -144
  69. package/src/prompts.ts +0 -842
  70. package/src/providers/backend-proxy-llm-provider.ts +0 -91
  71. package/src/providers/local-llm-provider.ts +0 -38
  72. package/src/scenario-service.ts +0 -252
  73. package/src/scenario-worker-class.ts +0 -1110
  74. package/src/script-utils.ts +0 -203
  75. package/src/types.ts +0 -239
  76. package/src/utils/browser-utils.ts +0 -348
  77. package/src/utils/coordinate-converter.ts +0 -162
  78. package/src/utils/page-info-retry.ts +0 -65
  79. package/src/utils/page-info-utils.ts +0 -285
  80. package/testchimp-runner-core-0.0.35.tgz +0 -0
  81. package/tsconfig.json +0 -19
@@ -1,253 +0,0 @@
1
- # Credit Usage Callback Architecture
2
-
3
- ## Summary
4
- Added callback-based credit usage reporting to allow server-side integration to update DB directly without axios calls, while client-side continues using axios calls to backend API.
5
-
6
- ## Architecture
7
-
8
- ### Callback-First Approach
9
-
10
- ```typescript
11
- export interface CreditUsage {
12
- credits: number;
13
- usageReason: CreditUsageReason;
14
- jobId?: string;
15
- timestamp: number;
16
- }
17
-
18
- export type CreditUsageCallback = (usage: CreditUsage) => void | Promise<void>;
19
- ```
20
-
21
- ### Behavior
22
-
23
- ```typescript
24
- async reportCreditUsage(credits, usageReason, jobId) {
25
- const creditUsage = { credits, usageReason, jobId, timestamp: Date.now() };
26
-
27
- // 1. If callback provided: Use callback (SERVER-SIDE)
28
- if (this.creditUsageCallback) {
29
- await this.creditUsageCallback(creditUsage);
30
- return {}; // No axios call needed
31
- }
32
-
33
- // 2. No callback but auth configured: Use axios (CLIENT-SIDE)
34
- if (this.authConfig) {
35
- await axios.post(`${backend}/localagent/insert_credit_usage`, ...);
36
- return response.data;
37
- }
38
-
39
- // 3. No callback and no auth: Development mode
40
- return {};
41
- }
42
- ```
43
-
44
- ## Usage Scenarios
45
-
46
- ### Server-Side (scriptservice)
47
-
48
- ```typescript
49
- import { TestChimpService, CreditUsage, CreditUsageReason } from 'testchimp-runner-core';
50
-
51
- const service = new TestChimpService(
52
- fileHandler,
53
- undefined, // NO auth config
54
- backendUrl,
55
- maxWorkers,
56
- llmProvider,
57
- progressReporter,
58
- orchestratorOptions,
59
- async (creditUsage: CreditUsage) => {
60
- // Update DB directly - NO axios calls
61
- await db.insertCreditUsage({
62
- credits: creditUsage.credits,
63
- usageReason: creditUsage.usageReason,
64
- jobId: creditUsage.jobId,
65
- timestamp: creditUsage.timestamp
66
- });
67
- }
68
- );
69
- ```
70
-
71
- **Result:**
72
- - ✅ Callback called → DB updated directly
73
- - ❌ No axios calls (no auth configured)
74
- - ✅ Full control over DB updates
75
-
76
- ### Client-Side (vs-extension, github-action)
77
-
78
- ```typescript
79
- import { TestChimpService } from 'testchimp-runner-core';
80
-
81
- const service = new TestChimpService(
82
- fileHandler,
83
- authConfig, // Auth configured
84
- backendUrl,
85
- maxWorkers,
86
- llmProvider,
87
- progressReporter,
88
- orchestratorOptions
89
- // NO callback - uses axios
90
- );
91
- ```
92
-
93
- **Result:**
94
- - ❌ No callback provided
95
- - ✅ Axios call made to backend API (because auth configured)
96
- - ✅ Backend handles DB update
97
-
98
- ### Development Mode (local testing)
99
-
100
- ```typescript
101
- const service = new TestChimpService(
102
- fileHandler
103
- // No auth, no callback
104
- );
105
- ```
106
-
107
- **Result:**
108
- - ❌ No callback
109
- - ❌ No auth
110
- - ⚠️ Warning logged: "Credit usage not tracked"
111
- - ✅ Continues without error
112
-
113
- ## API
114
-
115
- ### Constructor
116
- ```typescript
117
- new TestChimpService(
118
- fileHandler?,
119
- authConfig?,
120
- backendUrl?,
121
- maxWorkers?,
122
- llmProvider?,
123
- progressReporter?,
124
- orchestratorOptions?,
125
- creditUsageCallback? // NEW
126
- )
127
- ```
128
-
129
- ### Method
130
- ```typescript
131
- service.setCreditUsageCallback((creditUsage) => {
132
- // Handle credit usage in your system
133
- console.log(`Used ${creditUsage.credits} credits for ${creditUsage.usageReason}`);
134
- });
135
- ```
136
-
137
- ## Exported Types
138
-
139
- ```typescript
140
- export {
141
- CreditUsageCallback, // Type for callback function
142
- CreditUsage, // Interface for usage data
143
- CreditUsageReason // Enum: SCRIPT_GENERATE, TEST_REPAIR, etc.
144
- };
145
- ```
146
-
147
- ## Benefits
148
-
149
- ### For Server-Side
150
- 1. **No Network Calls** - Direct DB updates via callback
151
- 2. **Full Control** - Custom logic for credit tracking
152
- 3. **Performance** - No HTTP round-trip overhead
153
- 4. **Reliability** - No network failures
154
-
155
- ### For Client-Side
156
- 1. **Backward Compatible** - Existing code works unchanged
157
- 2. **Centralized** - Backend API handles all credit logic
158
- 3. **Simple** - Just configure auth, no callback needed
159
-
160
- ### For Both
161
- 1. **Flexible** - Each consumer decides how to handle credits
162
- 2. **Testable** - Can mock callbacks easily
163
- 3. **Observable** - Callback provides visibility into credit usage
164
-
165
- ## Implementation Notes
166
-
167
- ### Preservation Across Service Recreations
168
-
169
- Credit callback is stored and reapplied when services are recreated:
170
-
171
- ```typescript
172
- // Store in TestChimpService
173
- private creditUsageCallback?: CreditUsageCallback;
174
-
175
- // Pass to CreditUsageService on every recreation
176
- this.creditUsageService = new CreditUsageService(
177
- this.authConfig,
178
- this.backendUrl,
179
- this.creditUsageCallback // Always preserved
180
- );
181
- ```
182
-
183
- ### Error Handling
184
-
185
- **Callback-based (server-side):**
186
- - Callback error → Throws (critical for DB updates)
187
-
188
- **Axios-based (client-side):**
189
- - Axios error → Throws (critical for credit tracking)
190
-
191
- **Development mode:**
192
- - No tracking → Logs warning, continues
193
-
194
- ## Example: Server-Side Integration
195
-
196
- ```typescript
197
- // In scriptservice
198
- import { TestChimpService, CreditUsage, CreditUsageReason } from 'testchimp-runner-core';
199
-
200
- class ScriptService {
201
- private testChimpService: TestChimpService;
202
-
203
- constructor() {
204
- this.testChimpService = new TestChimpService(
205
- new CustomFileHandler(),
206
- undefined, // No auth - server-side doesn't need it
207
- 'http://localhost:3000', // Internal backend URL
208
- 5,
209
- new CustomLLMProvider(), // Server has its own LLM provider
210
- customProgressReporter,
211
- { useOrchestrator: true },
212
- async (creditUsage: CreditUsage) => {
213
- // Direct DB update - no HTTP calls
214
- await this.creditRepository.insert({
215
- userId: this.getCurrentUserId(),
216
- credits: creditUsage.credits,
217
- reason: creditUsage.usageReason,
218
- jobId: creditUsage.jobId,
219
- timestamp: new Date(creditUsage.timestamp)
220
- });
221
- }
222
- );
223
- }
224
- }
225
- ```
226
-
227
- ## Files Modified
228
-
229
- 1. `/src/credit-usage-service.ts` - Added callback support, callback-first logic
230
- 2. `/src/index.ts` - Accept credit callback in constructor, expose `setCreditUsageCallback()`, preserve across recreations
231
- 3. Exported types: `CreditUsage`, `CreditUsageCallback`, `CreditUsageReason`
232
-
233
- ## Testing
234
-
235
- ### Server-Side
236
- 1. Set credit callback
237
- 2. Generate script
238
- 3. Verify callback called with correct credit data
239
- 4. Verify NO axios calls made
240
-
241
- ### Client-Side
242
- 1. Configure auth (no callback)
243
- 2. Generate script
244
- 3. Verify axios call made to backend
245
- 4. Verify backend receives credit data
246
-
247
- ## Backward Compatibility
248
-
249
- ✅ Fully backward compatible
250
- - Existing consumers work unchanged
251
- - Optional callback parameter
252
- - Existing axios behavior preserved for client-side
253
-