opencode-codebase-index 0.2.1 → 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 CHANGED
@@ -2811,6 +2811,22 @@ function float32ArrayToBuffer(arr) {
2811
2811
  function bufferToFloat32Array(buf) {
2812
2812
  return new Float32Array(buf.buffer, buf.byteOffset, buf.byteLength / 4);
2813
2813
  }
2814
+ function getErrorMessage(error) {
2815
+ if (error instanceof Error) {
2816
+ return error.message;
2817
+ }
2818
+ if (typeof error === "string") {
2819
+ return error;
2820
+ }
2821
+ if (error && typeof error === "object" && "message" in error) {
2822
+ return String(error.message);
2823
+ }
2824
+ return String(error);
2825
+ }
2826
+ function isRateLimitError(error) {
2827
+ const message = getErrorMessage(error);
2828
+ return message.includes("429") || message.toLowerCase().includes("rate limit") || message.toLowerCase().includes("too many requests");
2829
+ }
2814
2830
  var Indexer = class {
2815
2831
  config;
2816
2832
  projectRoot;
@@ -3168,10 +3184,20 @@ var Indexer = class {
3168
3184
  {
3169
3185
  retries: this.config.indexing.retries,
3170
3186
  minTimeout: this.config.indexing.retryDelayMs,
3187
+ maxTimeout: 3e4,
3188
+ factor: 2,
3171
3189
  onFailedAttempt: (error) => {
3172
- console.error(
3173
- `Embedding batch failed (attempt ${error.attemptNumber}): ${String(error)}`
3174
- );
3190
+ const message = getErrorMessage(error);
3191
+ if (isRateLimitError(error)) {
3192
+ queue.concurrency = 1;
3193
+ console.error(
3194
+ `Rate limited (attempt ${error.attemptNumber}/${error.retriesLeft + error.attemptNumber}): waiting before retry...`
3195
+ );
3196
+ } else {
3197
+ console.error(
3198
+ `Embedding batch failed (attempt ${error.attemptNumber}): ${message}`
3199
+ );
3200
+ }
3175
3201
  }
3176
3202
  }
3177
3203
  );
@@ -3204,8 +3230,8 @@ var Indexer = class {
3204
3230
  });
3205
3231
  } catch (error) {
3206
3232
  stats.failedChunks += batch.length;
3207
- this.addFailedBatch(batch, String(error));
3208
- console.error(`Failed to embed batch after retries: ${error}`);
3233
+ this.addFailedBatch(batch, getErrorMessage(error));
3234
+ console.error(`Failed to embed batch after retries: ${getErrorMessage(error)}`);
3209
3235
  }
3210
3236
  });
3211
3237
  }