@algosuite/vo-mcp 0.2.0-beta.55 → 0.2.0-beta.56

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.
@@ -202,8 +202,9 @@ async function mergeVerifiedPrRequest(req, prNumber, automationContext, onUnauth
202
202
  actionReceiptId: typeof json.action_receipt_id === "string" ? json.action_receipt_id : null
203
203
  };
204
204
  }
205
- if (res.status === 503 && json?.error === "verify_unavailable") {
206
- return { status: "retry", reason: json.reason || "verification unavailable" };
205
+ const captureStoreRetry = json?.action_status === "not_attempted" && (json?.error === "capture_preflight_unavailable" || json?.error === "decision_outcome_intent_failed");
206
+ if (res.status === 503 && (json?.error === "verify_unavailable" || json?.error === "merge_unavailable" || captureStoreRetry)) {
207
+ return { status: "retry", reason: json.reason || json.message || json.error || "verification unavailable" };
207
208
  }
208
209
  return {
209
210
  status: "blocked",
@@ -287,6 +288,58 @@ function makeClaimGateNotice({ log = () => {
287
288
  };
288
289
  }
289
290
 
291
+ // ../../scripts/virtual-office/code-runner/control-plane-knowledge-context.mjs
292
+ var MIN_KNOWLEDGE_CONTEXT_TIMEOUT_MS = 15e3;
293
+ var RETRY_DELAYS_MS = [2e3, 6e3];
294
+ var MAX_ATTEMPTS = RETRY_DELAYS_MS.length + 1;
295
+ function isRetryableStatus(status) {
296
+ return status >= 500 && status <= 599;
297
+ }
298
+ function defaultSleep(ms) {
299
+ return new Promise((resolve5) => {
300
+ setTimeout(resolve5, ms);
301
+ });
302
+ }
303
+ async function getTaskKnowledgeContextRequest(req, taskId, { query } = {}, {
304
+ taskRequestTimeoutMs,
305
+ invalidateToken = () => {
306
+ },
307
+ sleep: sleep2 = defaultSleep,
308
+ log = () => {
309
+ }
310
+ } = {}) {
311
+ const body = {};
312
+ if (typeof query === "string" && query.trim()) body.query = query;
313
+ const path2 = `/api/v1/code-task/${encodeURIComponent(taskId)}/knowledge-context`;
314
+ const timeoutMs = Math.max(Number(taskRequestTimeoutMs) || 0, MIN_KNOWLEDGE_CONTEXT_TIMEOUT_MS);
315
+ for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt += 1) {
316
+ let res;
317
+ let cause;
318
+ try {
319
+ res = await req("POST", path2, body, { timeoutMs });
320
+ } catch (err) {
321
+ cause = err;
322
+ }
323
+ if (!cause) {
324
+ if (res.status === 401) {
325
+ invalidateToken();
326
+ throw new Error("knowledge-context unauthorized (401)");
327
+ }
328
+ if (res.status === 404) return null;
329
+ if (res.ok) return res.json();
330
+ if (!isRetryableStatus(res.status)) {
331
+ throw new Error(`knowledge-context failed: HTTP ${res.status}`);
332
+ }
333
+ cause = new Error(`knowledge-context failed: HTTP ${res.status}`);
334
+ }
335
+ if (attempt === MAX_ATTEMPTS) throw cause;
336
+ const delayMs = RETRY_DELAYS_MS[attempt - 1];
337
+ log(`knowledge-context attempt ${attempt}/${MAX_ATTEMPTS} failed (${cause.message}); retrying in ${delayMs}ms`);
338
+ await sleep2(delayMs);
339
+ }
340
+ throw new Error("knowledge-context retry loop exited unexpectedly");
341
+ }
342
+
290
343
  // ../../scripts/virtual-office/code-runner/control-plane-client.mjs
291
344
  var cachedFirebaseToken = null;
292
345
  var ClaimAuthorityChangedError = class extends Error {
@@ -323,7 +376,8 @@ function createControlPlaneClient({
323
376
  6e4
324
377
  ),
325
378
  runnerId: runnerId2,
326
- runnerInstanceId
379
+ runnerInstanceId,
380
+ sleep: sleep2
327
381
  } = {}) {
328
382
  const resolvedBaseUrl = baseUrl ?? env.VO_CONTROL_PLANE_URL ?? "";
329
383
  if (!resolvedBaseUrl) throw new Error("VO_CONTROL_PLANE_URL is required for the code-runner daemon");
@@ -504,17 +558,16 @@ function createControlPlaneClient({
504
558
  if (!res.ok) throw new Error(`attachment download failed: HTTP ${res.status}`);
505
559
  return Buffer.from(await res.arrayBuffer());
506
560
  },
561
+ // Raised per-attempt timeout (>=15s) + bounded retry — see control-plane-knowledge-context.mjs.
507
562
  async getTaskKnowledgeContext(taskId, { query } = {}) {
508
- const body = {};
509
- if (typeof query === "string" && query.trim()) body.query = query;
510
- const res = await taskReq("POST", `/api/v1/code-task/${encodeURIComponent(taskId)}/knowledge-context`, body);
511
- if (res.status === 401) {
512
- cachedFirebaseToken = null;
513
- throw new Error("knowledge-context unauthorized (401)");
514
- }
515
- if (res.status === 404) return null;
516
- if (!res.ok) throw new Error(`knowledge-context failed: HTTP ${res.status}`);
517
- return res.json();
563
+ return getTaskKnowledgeContextRequest(req, taskId, { query }, {
564
+ taskRequestTimeoutMs,
565
+ invalidateToken: () => {
566
+ cachedFirebaseToken = null;
567
+ },
568
+ sleep: sleep2,
569
+ log: (m) => console.warn(`[code-runner ${(/* @__PURE__ */ new Date()).toISOString()}] ${m}`)
570
+ });
518
571
  },
519
572
  /** Weekly Claude token usage report — see control-plane-weekly-tokens.mjs. */
520
573
  async postWeeklyTokens(report) {