repowisestage 0.0.77 → 0.0.78

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.
@@ -8432,6 +8432,7 @@ async function startMcp(options) {
8432
8432
  sink: createHeartbeatSink({
8433
8433
  apiUrl: heartbeatApiUrl,
8434
8434
  getAuthToken: options.getAuthToken,
8435
+ ...options.getAuthTokenForceRefresh ? { getAuthTokenForceRefresh: options.getAuthTokenForceRefresh } : {},
8435
8436
  flagFilePath,
8436
8437
  ...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {}
8437
8438
  }),
@@ -8584,6 +8585,7 @@ async function startMcp(options) {
8584
8585
  }
8585
8586
  };
8586
8587
  }
8588
+ var HEARTBEAT_UPLOAD_TIMEOUT_MS = 3e4;
8587
8589
  function createHeartbeatSink(deps) {
8588
8590
  const fetchImpl = deps.fetchImpl ?? fetch;
8589
8591
  return {
@@ -8598,21 +8600,35 @@ function createHeartbeatSink(deps) {
8598
8600
  try {
8599
8601
  token = await deps.getAuthToken();
8600
8602
  } catch {
8601
- return;
8603
+ throw new Error("mcp-heartbeat: no auth token (transient \u2014 will retry)");
8602
8604
  }
8603
8605
  if (!token)
8604
- return;
8605
- const res = await fetchImpl(`${deps.apiUrl}/v1/listeners/mcp-heartbeat`, {
8606
+ throw new Error("mcp-heartbeat: no auth token (transient \u2014 will retry)");
8607
+ const doPost = (bearer) => fetchImpl(`${deps.apiUrl}/v1/listeners/mcp-heartbeat`, {
8606
8608
  method: "POST",
8607
8609
  headers: {
8608
8610
  "Content-Type": "application/json",
8609
- Authorization: `Bearer ${token}`
8611
+ Authorization: `Bearer ${bearer}`
8610
8612
  },
8611
- body: JSON.stringify(payload)
8613
+ body: JSON.stringify(payload),
8614
+ signal: AbortSignal.timeout(HEARTBEAT_UPLOAD_TIMEOUT_MS)
8612
8615
  });
8613
- if (res && !res.ok) {
8614
- console.warn(`[mcp-heartbeat] upload rejected (HTTP ${res.status}) \u2014 possible payload/contract drift`);
8616
+ let res = await doPost(token);
8617
+ if (res.status === 401 && deps.getAuthTokenForceRefresh) {
8618
+ try {
8619
+ const fresh = await deps.getAuthTokenForceRefresh();
8620
+ if (fresh)
8621
+ res = await doPost(fresh);
8622
+ } catch {
8623
+ }
8624
+ }
8625
+ if (res.ok)
8626
+ return;
8627
+ const retryable = res.status >= 500 || res.status === 401 || res.status === 408 || res.status === 429;
8628
+ if (retryable) {
8629
+ throw new Error(`mcp-heartbeat: upload failed (HTTP ${res.status.toString()}) \u2014 will retry`);
8615
8630
  }
8631
+ console.warn(`[mcp-heartbeat] upload rejected (HTTP ${res.status.toString()}) \u2014 dropping (payload/contract or permission drift)`);
8616
8632
  }
8617
8633
  };
8618
8634
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repowisestage",
3
- "version": "0.0.77",
3
+ "version": "0.0.78",
4
4
  "type": "module",
5
5
  "description": "AI-optimized codebase context generator",
6
6
  "bin": {