@algosuite/vo-mcp 0.2.0-beta.20 → 0.2.0-beta.22

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.
@@ -36,6 +36,31 @@ import { createRequire } from "node:module";
36
36
  import { fileURLToPath as fileURLToPath3 } from "node:url";
37
37
  import { dirname as dirname4, join as join5 } from "node:path";
38
38
 
39
+ // ../../scripts/virtual-office/code-runner/installation-token.mjs
40
+ var READ_TOKEN_TIMEOUT_MS = 15e3;
41
+ async function fetchInstallationToken({ req, required = false, readOnly = false, repo = null }) {
42
+ const fail = (reason) => {
43
+ if (required) throw new Error(`installation-token required: ${reason}`);
44
+ return null;
45
+ };
46
+ try {
47
+ const res = await req(
48
+ "POST",
49
+ "/api/v1/github/installation-token",
50
+ readOnly ? { scope: "read", ...repo ? { repo } : {} } : {},
51
+ readOnly ? { timeoutMs: READ_TOKEN_TIMEOUT_MS } : {}
52
+ );
53
+ if (!res.ok) return fail(`HTTP ${res.status}`);
54
+ const json = await res.json();
55
+ if (!json || !json.token) return fail("missing token");
56
+ if (readOnly && json.scope !== "read") return fail("control plane did not confirm a read-only grant");
57
+ return { token: json.token, expiresAt: json.expires_at || null };
58
+ } catch (err) {
59
+ if (required) throw err;
60
+ return null;
61
+ }
62
+ }
63
+
39
64
  // ../../scripts/virtual-office/code-runner/control-plane-client.mjs
40
65
  var cachedFirebaseToken = null;
41
66
  async function resolveBearer(env) {
@@ -258,7 +283,7 @@ function createControlPlaneClient({
258
283
  * authenticated operator so the web shows a TRUE "runner online" signal.
259
284
  * Best-effort caller; throws on 401/non-ok so the daemon can log + retry.
260
285
  */
261
- async postHeartbeat({ runnerId: runnerId2, runnerInstanceId, operatorId, uptimeSec, activeTasks, maxConcurrency, effectiveConcurrency, measuredTaskSlots, measuredCpuSlots, measuredMemorySlots, version, daemonVersion, defaultAgent, supervisorInstanceId: supervisorInstanceId2, supervisorVersion: supervisorVersion2, supervisorCapabilities, servedRepos, servedOperators, availableAgents, accountUsage }) {
286
+ async postHeartbeat({ runnerId: runnerId2, runnerInstanceId, operatorId, uptimeSec, activeTasks, maxConcurrency, effectiveConcurrency, measuredTaskSlots, measuredCpuSlots, measuredMemorySlots, version, daemonVersion, defaultAgent, supervisorInstanceId: supervisorInstanceId2, supervisorVersion: supervisorVersion2, supervisorCapabilities, servedRepos, servedOperators, availableAgents, accountUsage, availableLocalModels }) {
262
287
  const body = { runner_id: runnerId2 };
263
288
  if (runnerInstanceId) body.runner_instance_id = runnerInstanceId;
264
289
  if (operatorId) body.operator_id = operatorId;
@@ -287,6 +312,9 @@ function createControlPlaneClient({
287
312
  if (Array.isArray(accountUsage) && accountUsage.length > 0) {
288
313
  body.account_usage = accountUsage;
289
314
  }
315
+ if (Array.isArray(availableLocalModels) && availableLocalModels.length > 0) {
316
+ body.available_local_models = availableLocalModels;
317
+ }
290
318
  const res = await req("POST", "/api/v1/runner/heartbeat", body, {
291
319
  timeoutMs: heartbeatTimeoutMs
292
320
  });
@@ -342,37 +370,9 @@ function createControlPlaneClient({
342
370
  const json = await res.json();
343
371
  return json?.action || null;
344
372
  },
345
- /**
346
- * Mint a short-lived (~1h), repo-scoped GitHub App installation token for
347
- * THIS runner's operator (M3). The control-plane keys the mint on the
348
- * authenticated operator (ctx.operator_id), so the token covers only that
349
- * operator's installation.
350
- *
351
- * Returns { token, expiresAt } on success. In legacy/admin mode it returns
352
- * null on a miss so the caller may use ambient `gh`. In scoped-operator mode
353
- * callers pass `{ required: true }`, which fails closed instead of letting a
354
- * missing/mis-scoped installation fall through to the runner machine's `gh`.
355
- *
356
- * The minted token is only usable for push + PR if the GitHub App grants
357
- * BOTH `Contents: write` (git push) AND `Pull requests: write` (gh pr
358
- * create) — see docs/vo/github-app-setup-2026-06-18.md. A token missing
359
- * either scope fails at push (→ ambient fallback) or at `gh pr create`.
360
- */
361
- async getInstallationToken({ required = false } = {}) {
362
- const fail = (reason) => {
363
- if (required) throw new Error(`installation-token required: ${reason}`);
364
- return null;
365
- };
366
- try {
367
- const res = await req("POST", "/api/v1/github/installation-token", {});
368
- if (!res.ok) return fail(`HTTP ${res.status}`);
369
- const json = await res.json();
370
- if (!json || !json.token) return fail("missing token");
371
- return { token: json.token, expiresAt: json.expires_at || null };
372
- } catch (err) {
373
- if (required) throw err;
374
- return null;
375
- }
373
+ /** Mint a GitHub App installation token — see installation-token.mjs. */
374
+ async getInstallationToken({ required = false, readOnly = false, repo = null } = {}) {
375
+ return fetchInstallationToken({ req, required, readOnly, repo });
376
376
  },
377
377
  /**
378
378
  * Read the operator's dispatch-mode config (Fast→Ultracode effort setting).