opencode-codebase-index 0.2.0 → 0.2.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.
- package/dist/index.cjs +31 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -5
- package/dist/index.js.map +1 -1
- package/native/codebase-index-native.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2805,6 +2805,22 @@ function float32ArrayToBuffer(arr) {
|
|
|
2805
2805
|
function bufferToFloat32Array(buf) {
|
|
2806
2806
|
return new Float32Array(buf.buffer, buf.byteOffset, buf.byteLength / 4);
|
|
2807
2807
|
}
|
|
2808
|
+
function getErrorMessage(error) {
|
|
2809
|
+
if (error instanceof Error) {
|
|
2810
|
+
return error.message;
|
|
2811
|
+
}
|
|
2812
|
+
if (typeof error === "string") {
|
|
2813
|
+
return error;
|
|
2814
|
+
}
|
|
2815
|
+
if (error && typeof error === "object" && "message" in error) {
|
|
2816
|
+
return String(error.message);
|
|
2817
|
+
}
|
|
2818
|
+
return String(error);
|
|
2819
|
+
}
|
|
2820
|
+
function isRateLimitError(error) {
|
|
2821
|
+
const message = getErrorMessage(error);
|
|
2822
|
+
return message.includes("429") || message.toLowerCase().includes("rate limit") || message.toLowerCase().includes("too many requests");
|
|
2823
|
+
}
|
|
2808
2824
|
var Indexer = class {
|
|
2809
2825
|
config;
|
|
2810
2826
|
projectRoot;
|
|
@@ -3162,10 +3178,20 @@ var Indexer = class {
|
|
|
3162
3178
|
{
|
|
3163
3179
|
retries: this.config.indexing.retries,
|
|
3164
3180
|
minTimeout: this.config.indexing.retryDelayMs,
|
|
3181
|
+
maxTimeout: 3e4,
|
|
3182
|
+
factor: 2,
|
|
3165
3183
|
onFailedAttempt: (error) => {
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3184
|
+
const message = getErrorMessage(error);
|
|
3185
|
+
if (isRateLimitError(error)) {
|
|
3186
|
+
queue.concurrency = 1;
|
|
3187
|
+
console.error(
|
|
3188
|
+
`Rate limited (attempt ${error.attemptNumber}/${error.retriesLeft + error.attemptNumber}): waiting before retry...`
|
|
3189
|
+
);
|
|
3190
|
+
} else {
|
|
3191
|
+
console.error(
|
|
3192
|
+
`Embedding batch failed (attempt ${error.attemptNumber}): ${message}`
|
|
3193
|
+
);
|
|
3194
|
+
}
|
|
3169
3195
|
}
|
|
3170
3196
|
}
|
|
3171
3197
|
);
|
|
@@ -3198,8 +3224,8 @@ var Indexer = class {
|
|
|
3198
3224
|
});
|
|
3199
3225
|
} catch (error) {
|
|
3200
3226
|
stats.failedChunks += batch.length;
|
|
3201
|
-
this.addFailedBatch(batch,
|
|
3202
|
-
console.error(`Failed to embed batch after retries: ${error}`);
|
|
3227
|
+
this.addFailedBatch(batch, getErrorMessage(error));
|
|
3228
|
+
console.error(`Failed to embed batch after retries: ${getErrorMessage(error)}`);
|
|
3203
3229
|
}
|
|
3204
3230
|
});
|
|
3205
3231
|
}
|