@algosuite/vo-mcp 0.2.0-beta.58 → 0.2.0-beta.59

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.
@@ -340,6 +340,87 @@ async function getTaskKnowledgeContextRequest(req, taskId, { query } = {}, {
340
340
  throw new Error("knowledge-context retry loop exited unexpectedly");
341
341
  }
342
342
 
343
+ // ../../scripts/virtual-office/code-runner/control-plane-prepared-job.mjs
344
+ var PREPARED_JOB_ENV_QUERY_KEYS = [
345
+ "VO_CODE_RUNNER_NO_WEB",
346
+ "VO_CODE_RUNNER_NO_WORKFLOW",
347
+ "VO_CODE_RUNNER_NO_CONSENSUS",
348
+ "VO_CODE_RUNNER_PERMISSION_MODE",
349
+ "VO_CODE_RUNNER_DEFAULT_BUDGET_USD",
350
+ "VO_CODE_RUNNER_META_REASONING_EFFORT",
351
+ "VO_CODE_RUNNER_ALLOW_MISSING_KNOWLEDGE_CONTEXT",
352
+ "VO_ENABLE_CONTEXT7"
353
+ ];
354
+ var PREPARED_JOB_ENV_VALUE_MAX = 64;
355
+ function preparedJobQuery({ agent = "claude", env = {} } = {}) {
356
+ const params = new URLSearchParams();
357
+ params.set("agent", String(agent));
358
+ const sent = [];
359
+ const dropped = [];
360
+ for (const key of PREPARED_JOB_ENV_QUERY_KEYS) {
361
+ const raw = env?.[key];
362
+ if (typeof raw !== "string" || raw.length === 0) continue;
363
+ if (raw.length > PREPARED_JOB_ENV_VALUE_MAX) {
364
+ dropped.push(key);
365
+ continue;
366
+ }
367
+ params.set(key, raw);
368
+ sent.push(key);
369
+ }
370
+ return { query: params.toString(), sent, dropped };
371
+ }
372
+ async function refusalCode(res) {
373
+ try {
374
+ const body = await res.json();
375
+ return typeof body?.error === "string" && body.error ? body.error : null;
376
+ } catch {
377
+ return null;
378
+ }
379
+ }
380
+ async function getPreparedJobRequest(req, taskId, options = {}, invalidateToken = () => {
381
+ }) {
382
+ const { agent = "claude", env = {}, timeoutMs = 15e3 } = options;
383
+ const { query, sent, dropped } = preparedJobQuery({ agent, env });
384
+ const envMeta = { envSent: sent, envDropped: dropped };
385
+ if (typeof taskId !== "string" || taskId.length === 0) {
386
+ return { ok: false, reason: "missing_task_id", status: 0, ...envMeta };
387
+ }
388
+ const path2 = `/api/v1/code-task/${encodeURIComponent(taskId)}/prepared-job?${query}`;
389
+ let res;
390
+ try {
391
+ res = await req("GET", path2, void 0, { timeoutMs });
392
+ } catch (err) {
393
+ return { ok: false, reason: `transport: ${err?.message || String(err)}`, status: 0, ...envMeta };
394
+ }
395
+ if (res?.status === 401) {
396
+ try {
397
+ invalidateToken();
398
+ } catch {
399
+ }
400
+ return { ok: false, reason: "unauthorized", status: 401, ...envMeta };
401
+ }
402
+ if (!res?.ok) {
403
+ const code = await refusalCode(res);
404
+ return { ok: false, reason: code || `http_${res?.status ?? "unknown"}`, status: res?.status ?? 0, ...envMeta };
405
+ }
406
+ let body;
407
+ try {
408
+ body = await res.json();
409
+ } catch (err) {
410
+ return { ok: false, reason: `unreadable_body: ${err?.message || String(err)}`, status: res.status, ...envMeta };
411
+ }
412
+ const job = body?.prepared_job;
413
+ if (!job || typeof job !== "object") {
414
+ return { ok: false, reason: "no_prepared_job_in_body", status: res.status, ...envMeta };
415
+ }
416
+ return {
417
+ ok: true,
418
+ job,
419
+ composition: body?.composition && typeof body.composition === "object" ? body.composition : {},
420
+ ...envMeta
421
+ };
422
+ }
423
+
343
424
  // ../../scripts/virtual-office/code-runner/control-plane-client.mjs
344
425
  var cachedFirebaseToken = null;
345
426
  var ClaimAuthorityChangedError = class extends Error {
@@ -569,6 +650,10 @@ function createControlPlaneClient({
569
650
  log: (m) => console.warn(`[code-runner ${(/* @__PURE__ */ new Date()).toISOString()}] ${m}`)
570
651
  });
571
652
  },
653
+ /** ADR-004 § 11.1b: the plane's prepared job, for SHADOW comparison. Never throws. */
654
+ getPreparedJob: (taskId, options) => getPreparedJobRequest(req, taskId, options, () => {
655
+ cachedFirebaseToken = null;
656
+ }),
572
657
  /** Weekly Claude token usage report — see control-plane-weekly-tokens.mjs. */
573
658
  async postWeeklyTokens(report) {
574
659
  return postWeeklyTokensRequest(taskReq, report, () => {
@@ -590,8 +675,8 @@ function createControlPlaneClient({
590
675
  * authenticated operator so the web shows a TRUE "runner online" signal.
591
676
  * Best-effort caller; throws on 401/non-ok so the daemon can log + retry.
592
677
  */
593
- async postHeartbeat({ runnerId: runnerId3, runnerInstanceId: runnerInstanceId2, operatorId, uptimeSec, activeTasks, maxConcurrency, effectiveConcurrency, measuredTaskSlots, measuredCpuSlots, measuredMemorySlots, version, daemonVersion, defaultAgent, supervisorInstanceId: supervisorInstanceId2, supervisorVersion: supervisorVersion2, supervisorCapabilities, servedRepos, servedOperators, availableAgents, accountUsage, availableLocalModels }) {
594
- const body = { runner_id: runnerId3 };
678
+ async postHeartbeat({ runnerId: runnerId3, runnerInstanceId: runnerInstanceId2, operatorId, uptimeSec, activeTasks, maxConcurrency, effectiveConcurrency, measuredTaskSlots, measuredCpuSlots, measuredMemorySlots, version, daemonVersion, defaultAgent, supervisorInstanceId: supervisorInstanceId2, supervisorVersion: supervisorVersion2, supervisorCapabilities, servedRepos, servedOperators, availableAgents, accountUsage, availableLocalModels, prepared_job_shadow: preparedJobShadow }) {
679
+ const body = { runner_id: runnerId3, ...preparedJobShadow ? { prepared_job_shadow: preparedJobShadow } : {} };
595
680
  if (runnerInstanceId2) body.runner_instance_id = runnerInstanceId2;
596
681
  if (operatorId) body.operator_id = operatorId;
597
682
  if (typeof uptimeSec === "number") body.uptime_sec = uptimeSec;