@algosuite/vo-mcp 0.2.0-beta.49 → 0.2.0-beta.50

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.
@@ -187,6 +187,49 @@ async function mergeVerifiedPrRequest(req, prNumber, automationContext, onUnauth
187
187
  };
188
188
  }
189
189
 
190
+ // ../../scripts/virtual-office/code-runner/control-plane-weekly-tokens.mjs
191
+ async function postWeeklyTokensRequest(taskReq, { operatorId, runnerId: runnerId2, tokens, claudeWeeklyPct, claudeWeeklyResetsAt }, onUnauthorized = () => {
192
+ }) {
193
+ const body = {
194
+ operator_id: operatorId,
195
+ runner_id: runnerId2,
196
+ input_tokens: tokens.input_tokens,
197
+ output_tokens: tokens.output_tokens,
198
+ cache_creation_tokens: tokens.cache_creation_tokens,
199
+ cache_read_tokens: tokens.cache_read_tokens
200
+ };
201
+ if (typeof claudeWeeklyPct === "number") {
202
+ body.claude_weekly_pct = claudeWeeklyPct;
203
+ }
204
+ if (claudeWeeklyResetsAt !== void 0) {
205
+ body.claude_weekly_resets_at = claudeWeeklyResetsAt;
206
+ }
207
+ const res = await taskReq("POST", "/api/v1/weekly-tokens", body);
208
+ if (res.status === 401) {
209
+ onUnauthorized();
210
+ throw new Error("weekly-tokens unauthorized (401)");
211
+ }
212
+ if (!res.ok) throw new Error(`weekly-tokens failed: HTTP ${res.status}`);
213
+ return true;
214
+ }
215
+
216
+ // ../../scripts/virtual-office/code-runner/control-plane-telemetry-relay.mjs
217
+ var TELEMETRY_RELAY_TIMEOUT_MS = 3e4;
218
+ async function relayTelemetryEventsRequest(req, { events, source }, onUnauthorized = () => {
219
+ }) {
220
+ const res = await req("POST", "/api/v1/telemetry/relay", { events, ...source ? { source } : {} }, {
221
+ timeoutMs: TELEMETRY_RELAY_TIMEOUT_MS
222
+ });
223
+ if (res.status === 401) onUnauthorized();
224
+ let body = null;
225
+ try {
226
+ body = await res.json();
227
+ } catch {
228
+ body = null;
229
+ }
230
+ return { status: res.status, body };
231
+ }
232
+
190
233
  // ../../scripts/virtual-office/code-runner/claim-gate-notice.mjs
191
234
  var REASON_HELP = {
192
235
  daemon_version_below_floor: "this daemon is older than the approved release target \u2014 it idles until the governed updater brings it current (operator override: VO_RUNNER_CLAIM_MIN_DAEMON_VERSION / VO_RUNNER_CLAIM_VERSION_GATE=off on the control plane)",
@@ -431,38 +474,21 @@ function createControlPlaneClient({
431
474
  if (!res.ok) throw new Error(`knowledge-context failed: HTTP ${res.status}`);
432
475
  return res.json();
433
476
  },
477
+ /** Weekly Claude token usage report — see control-plane-weekly-tokens.mjs. */
478
+ async postWeeklyTokens(report) {
479
+ return postWeeklyTokensRequest(taskReq, report, () => {
480
+ cachedFirebaseToken = null;
481
+ });
482
+ },
434
483
  /**
435
- * Report this machine's rolling-7-day Claude Code token usage (the real
436
- * weekly-capacity gauge) PLUS the operator's real Claude weekly % (when
437
- * available). The daemon authenticates as admin, so the target `operatorId`
438
- * is named explicitly. Best-effort; throws on a non-2xx so the caller can
439
- * log + move on.
440
- *
441
- * `tokens` = { input_tokens, output_tokens, cache_creation_tokens, cache_read_tokens }.
442
- * Optional: `claudeWeeklyPct` (number) + `claudeWeeklyResetsAt` (ISO string | null).
484
+ * Relay a batch of this machine's local vo-mcp events to vo-telemetry via
485
+ * the control plane (telemetry-forwarder.mjs). Returns { status, body };
486
+ * the forwarder owns backoff/disable policy. See control-plane-telemetry-relay.mjs.
443
487
  */
444
- async postWeeklyTokens({ operatorId, runnerId: runnerId3, tokens, claudeWeeklyPct, claudeWeeklyResetsAt }) {
445
- const body = {
446
- operator_id: operatorId,
447
- runner_id: runnerId3,
448
- input_tokens: tokens.input_tokens,
449
- output_tokens: tokens.output_tokens,
450
- cache_creation_tokens: tokens.cache_creation_tokens,
451
- cache_read_tokens: tokens.cache_read_tokens
452
- };
453
- if (typeof claudeWeeklyPct === "number") {
454
- body.claude_weekly_pct = claudeWeeklyPct;
455
- }
456
- if (claudeWeeklyResetsAt !== void 0) {
457
- body.claude_weekly_resets_at = claudeWeeklyResetsAt;
458
- }
459
- const res = await taskReq("POST", "/api/v1/weekly-tokens", body);
460
- if (res.status === 401) {
488
+ async relayTelemetryEvents(batch) {
489
+ return relayTelemetryEventsRequest(req, batch, () => {
461
490
  cachedFirebaseToken = null;
462
- throw new Error("weekly-tokens unauthorized (401)");
463
- }
464
- if (!res.ok) throw new Error(`weekly-tokens failed: HTTP ${res.status}`);
465
- return true;
491
+ });
466
492
  },
467
493
  /**
468
494
  * Send a liveness heartbeat (M2). The control-plane upserts it under the