@azumag/opencode-rate-limit-fallback 1.57.0 → 1.59.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.
|
@@ -34,7 +34,12 @@ export class PatternLearner {
|
|
|
34
34
|
this.trackPattern(candidate);
|
|
35
35
|
}
|
|
36
36
|
// Process and potentially save patterns
|
|
37
|
-
|
|
37
|
+
// Fire-and-forget with proper error handling
|
|
38
|
+
this.processPatterns().catch((error) => {
|
|
39
|
+
this.logger.error('[PatternLearner] Failed to process patterns', {
|
|
40
|
+
error: error instanceof Error ? error.message : String(error),
|
|
41
|
+
});
|
|
42
|
+
});
|
|
38
43
|
}
|
|
39
44
|
catch (error) {
|
|
40
45
|
this.logger.error('[PatternLearner] Failed to learn from error', {
|
|
@@ -81,6 +81,10 @@ export declare class ErrorPatternRegistry {
|
|
|
81
81
|
* Learn a new pattern from an error
|
|
82
82
|
*/
|
|
83
83
|
addLearnedPattern(error: unknown): void;
|
|
84
|
+
/**
|
|
85
|
+
* Learn a new pattern from an error (async version)
|
|
86
|
+
*/
|
|
87
|
+
addLearnedPatternAsync(error: unknown): Promise<void>;
|
|
84
88
|
/**
|
|
85
89
|
* Get all learned patterns
|
|
86
90
|
*/
|
|
@@ -114,7 +114,7 @@ export class ErrorPatternRegistry {
|
|
|
114
114
|
// Common rate limit patterns (provider-agnostic)
|
|
115
115
|
this.register({
|
|
116
116
|
name: 'http-429',
|
|
117
|
-
patterns: [
|
|
117
|
+
patterns: [/\b429\b/gi], // HTTP 429 status code with word boundaries
|
|
118
118
|
priority: 100,
|
|
119
119
|
});
|
|
120
120
|
this.register({
|
|
@@ -296,6 +296,17 @@ export class ErrorPatternRegistry {
|
|
|
296
296
|
this.logger.warn('[ErrorPatternRegistry] Pattern learning is not enabled. Patterns must be manually registered via configuration.');
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Learn a new pattern from an error (async version)
|
|
301
|
+
*/
|
|
302
|
+
async addLearnedPatternAsync(error) {
|
|
303
|
+
if (this.patternLearner) {
|
|
304
|
+
this.patternLearner.learnFromError(error);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this.logger.warn('[ErrorPatternRegistry] Pattern learning is not enabled. Patterns must be manually registered via configuration.');
|
|
308
|
+
}
|
|
309
|
+
}
|
|
299
310
|
/**
|
|
300
311
|
* Get all learned patterns
|
|
301
312
|
*/
|
package/package.json
CHANGED