@dianshuv/copilot-api 0.7.2 → 0.7.3

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 (2) hide show
  1. package/dist/main.mjs +18 -5
  2. package/package.json +1 -1
package/dist/main.mjs CHANGED
@@ -1213,7 +1213,7 @@ const patchClaude = defineCommand({
1213
1213
 
1214
1214
  //#endregion
1215
1215
  //#region package.json
1216
- var version = "0.7.2";
1216
+ var version = "0.7.3";
1217
1217
 
1218
1218
  //#endregion
1219
1219
  //#region src/lib/adaptive-rate-limiter.ts
@@ -3696,10 +3696,23 @@ function completeTracking(trackingId, inputTokens, outputTokens, queueWaitMs, re
3696
3696
  stopReason: analytics.stopReason
3697
3697
  });
3698
3698
  }
3699
+ function formatError(error) {
3700
+ if (error instanceof Error) return error.message || error.name;
3701
+ if (typeof error === "string") return error;
3702
+ try {
3703
+ const s = JSON.stringify(error);
3704
+ if (s && s !== "{}") return s;
3705
+ } catch {}
3706
+ try {
3707
+ return String(error);
3708
+ } catch {
3709
+ return "Unknown error";
3710
+ }
3711
+ }
3699
3712
  /** Fail TUI tracking */
3700
3713
  function failTracking(trackingId, error) {
3701
3714
  if (!trackingId) return;
3702
- requestTracker.failRequest(trackingId, error instanceof Error ? error.message : "Stream error");
3715
+ requestTracker.failRequest(trackingId, formatError(error));
3703
3716
  }
3704
3717
  /**
3705
3718
  * Create a marker to prepend to responses indicating auto-truncation occurred.
@@ -3722,7 +3735,7 @@ function recordStreamError(opts) {
3722
3735
  input_tokens: 0,
3723
3736
  output_tokens: 0
3724
3737
  },
3725
- error: error instanceof Error ? error.message : "Stream error",
3738
+ error: formatError(error),
3726
3739
  content: null
3727
3740
  }, Date.now() - ctx.startTime);
3728
3741
  }
@@ -7644,7 +7657,7 @@ async function handleDirectAnthropicStreamingResponse(opts) {
7644
7657
  toolCount: anthropicPayload.tools?.length ?? 0
7645
7658
  });
7646
7659
  } catch (error) {
7647
- consola.error("Direct Anthropic stream error:", error);
7660
+ consola.error("Direct Anthropic stream error:", formatError(error), error);
7648
7661
  recordStreamError({
7649
7662
  acc,
7650
7663
  fallbackModel: anthropicPayload.model,
@@ -7830,7 +7843,7 @@ async function handleStreamingResponse(opts) {
7830
7843
  toolCount: anthropicPayload.tools?.length ?? 0
7831
7844
  });
7832
7845
  } catch (error) {
7833
- consola.error("Stream error:", error);
7846
+ consola.error("Stream error:", formatError(error), error);
7834
7847
  recordStreamError({
7835
7848
  acc,
7836
7849
  fallbackModel: anthropicPayload.model,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dianshuv/copilot-api",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Turn GitHub Copilot into OpenAI/Anthropic API compatible server. Usable with Claude Code!",
5
5
  "author": "dianshuv",
6
6
  "type": "module",