limixbot 0.3.29 → 0.3.31

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.
Files changed (136) hide show
  1. package/dist/assets/{ActivityPanel-Cv8SavDj.js → ActivityPanel-DPKaOxwD.js} +1 -1
  2. package/dist/assets/{App-ajUV-Eko.js → App-CXIAAQw4.js} +99 -99
  3. package/dist/assets/{AppEventEditor-BmuhU4di.js → AppEventEditor-BYUFU-RF.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-Djt5Z8_c.js → BotSettingsDialog-CNzHxE5T.js} +1 -1
  5. package/dist/assets/{BrowserPanel-cwjDpf3J.js → BrowserPanel-BvycPh9Q.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-CzNf4P8c.js → BrowserProfilesManager-C-DSmpiF.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-CuAJ_n8A.js → CloudAddDialog-C65BNNxP.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-CUwmhG4G.js → ComputerFilesPane-y6L4ZrAL.js} +1 -1
  9. package/dist/assets/ComputerPanel-C8ncdcmm.js +2 -0
  10. package/dist/assets/{DataPanel-LpZaOwFy.js → DataPanel-B42JmnxF.js} +1 -1
  11. package/dist/assets/{DesktopViewer-CO6rKDOC.js → DesktopViewer-DbEC8oPW.js} +1 -1
  12. package/dist/assets/{FilesView-BcPlXY2Z.js → FilesView-BWruPNny.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-DPhfPAAd.js → GrokMoveDialog-c5X1j8au.js} +1 -1
  14. package/dist/assets/{InspectorPanel-l3AppDb0.js → InspectorPanel-BjMcrEJ5.js} +1 -1
  15. package/dist/assets/{KeyboardShortcutsModal-D78LOnXx.js → KeyboardShortcutsModal-epRIaVPK.js} +1 -1
  16. package/dist/assets/{LiveDesktop-DCwjKpuh.js → LiveDesktop-B6kJJHn8.js} +1 -1
  17. package/dist/assets/LocalVmWorkspace-BiZhg9qH.js +1 -0
  18. package/dist/assets/{MacLocalControl-QdlFsN0H.js → MacLocalControl-D7ByxpUV.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-BQk1kEdI.js → MarkdownFilePreview-BIrbvZT_.js} +1 -1
  20. package/dist/assets/{MenuMotion-QoOXKNvf.js → MenuMotion-Dj4rtEj4.js} +1 -1
  21. package/dist/assets/{NewBotDialog-DxwobeWs.js → NewBotDialog-B9SBavIN.js} +1 -1
  22. package/dist/assets/{PhoneAppDialog-ht-Y64Q_.js → PhoneAppDialog-U09W36YX.js} +1 -1
  23. package/dist/assets/{PlacesRail-B0r2Van_.js → PlacesRail-bn7tEIBM.js} +1 -1
  24. package/dist/assets/{PluginsPanel-CUxVDpGZ.js → PluginsPanel-Cc7XMnL0.js} +1 -1
  25. package/dist/assets/{ProIntroduction-CE4vJUn2.js → ProIntroduction--tZnt9fj.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-3he4axXK.js → RemoteAgentSettingsPanel-lr4-06Ct.js} +1 -1
  27. package/dist/assets/{RoomPanel-By9zNgSd.js → RoomPanel-Dc2iAV1X.js} +1 -1
  28. package/dist/assets/{RoutinesPage-qN6QGEQA.js → RoutinesPage-0ilXXAQg.js} +1 -1
  29. package/dist/assets/SettingsModal-DOQo4UPP.js +19 -0
  30. package/dist/assets/{ShareTeamDialog-D2VGoot3.js → ShareTeamDialog-O9ZwVnKj.js} +1 -1
  31. package/dist/assets/{SignedInSites-UilEy8xN.js → SignedInSites-BlnZihVe.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-iXKP8bHg.js → TeamLibraryPanel-BLrCrURN.js} +1 -1
  33. package/dist/assets/{TeamMapPage-DXmzzK2K.js → TeamMapPage-DIVPsZwZ.js} +1 -1
  34. package/dist/assets/{TriggersPage-cCF8IoEn.js → TriggersPage-b2SXuCPa.js} +1 -1
  35. package/dist/assets/{VisibilitySection-BYBx_roX.js → VisibilitySection-BjcUdV_p.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-B3HjCzO1.js → WebhookTrigger-BBi06Y-c.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-Cb8HQTdi.js → WorksOnGrid-B5p2GXxB.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-D3RC58wh.js → abnfDiagram-YUKMZFIV-BcUIfOEe.js} +1 -1
  39. package/dist/assets/{activity-Dbl6UsX-.js → activity-BNFKxy1b.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-Z8fpyY75.js → architectureDiagram-47P4ROYG-C7ht62Bt.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-DvE9XpO8.js → blockDiagram-E7TT5TSB-CaczmOHs.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-BpGfeK2S.js → c4Diagram-CRA5TL53-DSPaJBwh.js} +1 -1
  43. package/dist/assets/{calendar-days-D_ADHCH2.js → calendar-days-DU-aFzFs.js} +1 -1
  44. package/dist/assets/channel-BXNHTVIL.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-D67vAX0H.js → chunk-2Q5K7J3B-D4erYHrR.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-CMFiNc6u.js → chunk-5VM5RSS4-D8syTc7K.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-CoFLZ60I.js → chunk-7TKQ45FW-qZ8vN88Y.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-gUfW5Adc.js → chunk-AW2ZBBNX-COZ0RY0p.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-D1Q069A2.js → chunk-FVRAUYC3-B9WP6gNL.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-D3ZZF79x.js → chunk-HTAEGDNF-DpLxKDYN.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-qcqhs_9A.js → chunk-JWPE2WC7-CyI6_v_4.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-ChtMO8fh.js → chunk-KQW6MTUR-C3xLM0DV.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-Bx_iNGRg.js → chunk-XXDRQBXY-C7oc9LKJ.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-BFNAyWC6.js → classDiagram-v2-K4WV4PDN-DtYcyxMZ.js} +1 -1
  55. package/dist/assets/{coins-DKr1YBNV.js → coins-C8BnHs7A.js} +1 -1
  56. package/dist/assets/{core-CncVixaG.js → core-8c5YWRlC.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-Bg8ti_oz.js → cose-bilkent-JH36ORCC-BACClH_n.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-AzIaeBzO.js → cynefin-EF2NZ3EQ-DZo-gx9_.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-DkvCNROf.js → cynefinDiagram-3GCD6N5R-CB9Tufy-.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-eHc7s4oU.js → dagre-W4DXFKR2-QmMefB-F.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-C7M1j1Z_.js → diagram-2UJZ2QOL-BB9UdSXb.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-CsI6LK_l.js → diagram-OVF4WLC6-BT1xV_u3.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-Cy-sdnqW.js → diagram-PFPMY2P6-Bb8Gcrwm.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-BUJZwO0b.js → diagram-UMYRVEAY-CuhVtw_K.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-W-jVXeaq.js → diagram-YEKJPTXX-BKeM2V-v.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-lriD7N0L.js → diagram-ZIFT7M5P-CWJdSX39.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-BsUEFVYI.js → ebnfDiagram-VR2GEFS7-CQt0qwgC.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-DaJpjkbS.js → elk-IJKZMXRS-DTpYboxu.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-BcNSWX_I.js → erDiagram-O2IAPWRE-CRmD7TiT.js} +1 -1
  70. package/dist/assets/{file-up-W9Ukts61.js → file-up-DA-MGVqh.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-C0yLQ4G-.js → flowDiagram-OXPTDLAJ-C3OIuz51.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-C8zJsAus.js → ganttDiagram-R7TSEDQI-DRztzQgb.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-CvM9Ff5h.js → gitGraphDiagram-XJZIOB7I-DljlrTI8.js} +1 -1
  74. package/dist/assets/{import-name-IKTfLDbm.js → import-name-BCsjPBcL.js} +1 -1
  75. package/dist/assets/{index-C5PxeCx7.js → index-CdcrwTp5.js} +2 -2
  76. package/dist/assets/{index-DXcH006d.js → index-DJmQoZKd.js} +1 -1
  77. package/dist/assets/{infoDiagram-5W2HQ5XZ-EFSHnQLZ.js → infoDiagram-5W2HQ5XZ-sZgtYSBR.js} +1 -1
  78. package/dist/assets/{ishikawaDiagram-K3B6WC7H-Do-25hEq.js → ishikawaDiagram-K3B6WC7H-C3hf18HZ.js} +1 -1
  79. package/dist/assets/{journeyDiagram-COXZFDF6-B2ghVJCI.js → journeyDiagram-COXZFDF6-Cx7iVI1Y.js} +1 -1
  80. package/dist/assets/{kanban-definition-P3RFRI5V-TkPbxRAY.js → kanban-definition-P3RFRI5V-BCfPOAwE.js} +1 -1
  81. package/dist/assets/{mcp-servers-CLBiWzWC.js → mcp-servers-Dz1aRDIp.js} +1 -1
  82. package/dist/assets/{mermaid.core-DO0Pzmu4.js → mermaid.core-u5mM9R6c.js} +4 -4
  83. package/dist/assets/{mindmap-definition-LZFPQGKD-nID_euLE.js → mindmap-definition-LZFPQGKD-Bl1ss-w7.js} +1 -1
  84. package/dist/assets/{minimize-BYioV8YM.js → minimize-CQhJEKJt.js} +1 -1
  85. package/dist/assets/{monitor-DGPG5gJh.js → monitor-DUalxLhV.js} +1 -1
  86. package/dist/assets/{new-bot-CzseIDJe.js → new-bot-CnIvjdzz.js} +1 -1
  87. package/dist/assets/{org-library-D736oTBO.js → org-library-BIflpykR.js} +1 -1
  88. package/dist/assets/{package-format-DVPcCWYU.js → package-format-BwQBEF2h.js} +1 -1
  89. package/dist/assets/{pegDiagram-BGZESJAR-BBY2tvO7.js → pegDiagram-BGZESJAR-DYVS4bK_.js} +1 -1
  90. package/dist/assets/{pieDiagram-CAPJLFHJ-DX04Xe_e.js → pieDiagram-CAPJLFHJ-Dd2OI03J.js} +1 -1
  91. package/dist/assets/{quadrantDiagram-GDMTTRAM-DaV-XRR2.js → quadrantDiagram-GDMTTRAM-DftvCum7.js} +1 -1
  92. package/dist/assets/{rail-B6Von-6v.js → rail-5xabqdtQ.js} +1 -1
  93. package/dist/assets/{railroadDiagram-SM67HX2B-BszaHa5J.js → railroadDiagram-SM67HX2B-CMUXYZoX.js} +1 -1
  94. package/dist/assets/{remote-desktop-panel-C_BqZvn5.js → remote-desktop-panel-Doj97m8r.js} +1 -1
  95. package/dist/assets/{requirementDiagram-X7JNWC4A-mBECwzIc.js → requirementDiagram-X7JNWC4A-TUFFobBi.js} +1 -1
  96. package/dist/assets/{sankeyDiagram-UM26HJRW-BVYWK2kU.js → sankeyDiagram-UM26HJRW-BoWUtM1O.js} +1 -1
  97. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-Cm1NiUC3.js → sequenceDiagram-ZO4K6R2Y-BJGhu1J3.js} +1 -1
  98. package/dist/assets/{sizeCapture-INFHLROL-By1WASi4.js → sizeCapture-INFHLROL-BjWOwFei.js} +1 -1
  99. package/dist/assets/{stateDiagram-v2-TBUQTH76-BC010wH6.js → stateDiagram-v2-TBUQTH76-BHnqACBE.js} +1 -1
  100. package/dist/assets/styles-BxpHDI63.css +1 -0
  101. package/dist/assets/{swimlanes-N4OXWK64-kzfE1u3G.js → swimlanes-N4OXWK64-w7Jh9mLp.js} +1 -1
  102. package/dist/assets/swimlanesDiagram-K3J5GTZL-zIHpuU63.js +8 -0
  103. package/dist/assets/{team-share-Cz-g0ol5.js → team-share-iEP9Zjr-.js} +1 -1
  104. package/dist/assets/{timeline-definition-YOQAKGHF-DaWipjgK.js → timeline-definition-YOQAKGHF-D0trOSBD.js} +1 -1
  105. package/dist/assets/{usecaseDiagram-VIAY4XPW-DAGDIl84.js → usecaseDiagram-VIAY4XPW-A_NiPbx_.js} +1 -1
  106. package/dist/assets/{vennDiagram-BLWOH2XV-DQpd7Brj.js → vennDiagram-BLWOH2XV-iEyMv06N.js} +1 -1
  107. package/dist/assets/{wardleyDiagram-YMQ3BMBF-CDz0yqs3.js → wardleyDiagram-YMQ3BMBF-yIcnyDG1.js} +1 -1
  108. package/dist/assets/{xychartDiagram-TAQBALBS-BjjtqaU2.js → xychartDiagram-TAQBALBS-BbKfuPA4.js} +1 -1
  109. package/dist/index.html +3 -3
  110. package/dist/rail.html +5 -5
  111. package/dist-server/container-mcp.js +3 -3
  112. package/dist-server/index.js +2200 -2186
  113. package/dist-server/openmausbot.js +311 -310
  114. package/dist-server/package.json +1 -1
  115. package/dist-server/pair-cli.js +311 -310
  116. package/dist-server/server/config.js +4 -0
  117. package/dist-server/server/container-computer.js +41 -3
  118. package/dist-server/server/harness/registry.js +8 -3
  119. package/dist-server/server/index.js +11 -8
  120. package/dist-server/server/limix-skill-requirements.js +31 -34
  121. package/dist-server/server/limix-vm-capacity.js +64 -0
  122. package/dist-server/server/local-vm-settings.js +10 -3
  123. package/dist-server/server/routes/bot-skills.js +7 -0
  124. package/dist-server/server/routes/computers.js +12 -13
  125. package/dist-server/server/routes/instances.js +12 -2
  126. package/dist-server/shared/limix-vm-capacity.js +1 -0
  127. package/dist-server/vps-container-mcp.js +3 -3
  128. package/dist-server/workspace-backup.worker.js +3 -3
  129. package/package.json +1 -1
  130. package/dist/assets/ComputerPanel-thbNTglI.js +0 -2
  131. package/dist/assets/LocalVmWorkspace-DRUmNe2b.js +0 -1
  132. package/dist/assets/SettingsModal-YpTplGBe.js +0 -19
  133. package/dist/assets/channel-D_u3gZnK.js +0 -1
  134. package/dist/assets/styles-D4XTB2mJ.css +0 -1
  135. package/dist/assets/swimlanesDiagram-K3J5GTZL-CsEp3kJM.js +0 -8
  136. /package/dist/assets/{styles-BynTeCUc.js → styles-DnwnyZpR.js} +0 -0
@@ -455,6 +455,8 @@ export function parseStoredConfig(value) {
455
455
  const parsed = storedAppConfigSchema.safeParse(value);
456
456
  if (!parsed.success)
457
457
  throw new Error(schemaIssue(parsed.error, "Invalid stored configuration"));
458
+ if (parsed.data.localVm && parsed.data.localVm.automaticCapacity === undefined)
459
+ parsed.data.localVm.automaticCapacity = true;
458
460
  return parsed.data;
459
461
  }
460
462
  export function loadBrowserProfileIdAliases() {
@@ -810,6 +812,8 @@ export function saveConfig(patch, options = {}) {
810
812
  if (key === "threads" && !current.success)
811
813
  merged.maxConcurrentPerBot = defaultBotThreads();
812
814
  Object.assign(merged, section, key === "browserEngine" && checkedPatch.browserEngine?.egress ? { egress: { ...jsonObjectSchema.safeParse(merged.egress).data, ...checkedPatch.browserEngine.egress } } : {}); // a partial egress patch keeps the stored allow-list
815
+ if (key === "localVm" && checkedPatch.localVm?.maxInstances !== undefined && checkedPatch.localVm.automaticCapacity === undefined)
816
+ merged.automaticCapacity = false;
813
817
  for (const [sectionKey, sectionValue] of Object.entries(section)) {
814
818
  if (sectionValue === null)
815
819
  delete merged[sectionKey];
@@ -12,6 +12,8 @@ import { DATA_DIR } from "./config.js";
12
12
  import { applyResourcesBeforeStart, DEFAULT_DESKTOP_RESOURCES, PIDS_LIMIT, raisePidsLimit, resourceArgs, } from "./container-limits.js";
13
13
  import { appleResourcesAreLimited, currentHostUser, DESKTOP_FLAGS_LABEL, DESKTOP_FLAGS_VERSION, desktopCapArgs, desktopRootIsHostRoot, dockerSecurityIsHardened, GUEST_UID, guestIdsCommand, guestIdsFor, podmanSecurityIsHardened, } from "./container-isolation.js";
14
14
  import { SPAWNED_PROXIES } from "./proxy-paths.js";
15
+ import { limixVmCapacity, refreshLimixVmCapacity, serializeLimixVmStart } from "./limix-vm-capacity.js";
16
+ import { lxs } from "./limix-lang.js";
15
17
  const run = promisify(execFile);
16
18
  const SCREENSHOT_STATUS_TTL_MS = 10_000;
17
19
  export const CUA_DRIVER_VERSION = "0.37.0";
@@ -199,6 +201,8 @@ export async function containerRuntimeStatus(runner = sh, platform = process.pla
199
201
  }
200
202
  }));
201
203
  const healthyIndex = healthy.indexOf(true);
204
+ if (runner === sh)
205
+ await refreshLimixVmCapacity(healthyIndex >= 0 ? available[healthyIndex] : null, runner);
202
206
  return {
203
207
  runtime: healthyIndex >= 0 ? available[healthyIndex] : (available[0] ?? null),
204
208
  available,
@@ -633,11 +637,12 @@ async function prepareManagedImage(runtime, runner) {
633
637
  await rm(context, { recursive: true, force: true });
634
638
  }
635
639
  }
636
- export async function containerComputerAction(action, runner = sh, platform = process.platform, target = SHARED_LOCAL_VM_TARGET, resources = DEFAULT_DESKTOP_RESOURCES) {
640
+ export async function containerComputerAction(action, runner = sh, platform = process.platform, target = SHARED_LOCAL_VM_TARGET, resources = DEFAULT_DESKTOP_RESOURCES, runningLimit) {
637
641
  if (runner === sh && platform === process.platform)
638
642
  screenshotStatusCache.delete(target.key);
639
643
  const before = await containerComputerStatus(runner, platform, target);
640
644
  const runtime = before.runtime;
645
+ let createdStopped = false;
641
646
  if (!runtime)
642
647
  throw Object.assign(new Error(before.problem ?? "No container runtime is installed"), { status: 409 });
643
648
  if (!before.daemonUp)
@@ -680,9 +685,42 @@ export async function containerComputerAction(action, runner = sh, platform = pr
680
685
  : action === "remove"
681
686
  ? ["rm", runtime === "container" ? "--force" : "-f", target.containerName]
682
687
  : [action, target.containerName];
683
- await runner(runtime, args, 2 * 60_000);
688
+ if ((action === "run" || action === "start") && (runner === sh || runningLimit !== undefined)) {
689
+ await serializeLimixVmStart(async () => {
690
+ const maximum = (typeof runningLimit === "function" ? runningLimit() : runningLimit) ?? limixVmCapacity(resources).limit;
691
+ const running = await runningLocalVmCount(runtime, runner);
692
+ if (running >= maximum) {
693
+ if (action === "run" && runtime !== "container") {
694
+ await runner(runtime, ["create", ...args.slice(2)], 2 * 60_000);
695
+ createdStopped = true;
696
+ return;
697
+ }
698
+ throw Object.assign(new Error(lxs(`Đã đạt giới hạn ${maximum} máy ảo đang chạy. Dừng một máy khác rồi bật lại máy này.`, `The limit of ${maximum} running desktops has been reached. Stop another desktop before starting this one.`)), { status: 409, code: "local_vm_capacity" });
699
+ }
700
+ await runner(runtime, args, 2 * 60_000);
701
+ });
702
+ }
703
+ else
704
+ await runner(runtime, args, 2 * 60_000);
705
+ }
706
+ const after = await containerComputerStatus(runner, platform, target);
707
+ if (createdStopped)
708
+ after.capacity_limited = true;
709
+ return after;
710
+ }
711
+ export async function runningLocalVmCount(runtime, runner = sh) {
712
+ if (runtime === "container") {
713
+ try {
714
+ const result = await runner(runtime, ["inspect", SHARED_LOCAL_VM_TARGET.containerName], 8000);
715
+ const rows = JSON.parse(result.stdout);
716
+ return rows.some((row) => row.status?.state === "running") ? 1 : 0;
717
+ }
718
+ catch {
719
+ return 0;
720
+ }
684
721
  }
685
- return containerComputerStatus(runner, platform, target);
722
+ const result = await runner(runtime, ["ps", "--filter", `label=${MANAGED_LABEL}=1`, "--format", "{{.Names}}"], 8000);
723
+ return result.stdout.split(/\r?\n/).filter((name) => name.trim()).length;
686
724
  }
687
725
  export async function containerComputerExists(runtime, target, runner = sh) {
688
726
  try {
@@ -1,6 +1,7 @@
1
1
  // Provider instance registry — port of upstream's ProviderInstanceRegistryLive behavior, minus Effect.
2
2
  import { findCliCandidates } from "../env-path.js";
3
- import { installNpmEngine, npmAvailable, serverInstallFor, standaloneLookupPath } from "../engine-install.js";
3
+ import { installNpmEngine, npmAvailable, npmLatestVersion, serverInstallFor, standaloneLookupPath, enginesBinDir } from "../engine-install.js";
4
+ import { join } from "node:path";
4
5
  import { installStandaloneEngine, isAppStandaloneCopy } from "../engine-standalone.js";
5
6
  import { pinnedNpmVersion } from "../engine-versions.js";
6
7
  import { withEngineMemory } from "../engine-memory.js";
@@ -296,7 +297,7 @@ export class ProviderRegistry {
296
297
  }
297
298
  return true;
298
299
  }
299
- async installRuntime(instanceId) {
300
+ async installRuntime(instanceId, options = {}) {
300
301
  const entry = this.byId.get(instanceId);
301
302
  if (!entry)
302
303
  return false;
@@ -315,7 +316,11 @@ export class ProviderRegistry {
315
316
  }
316
317
  if (!server?.package)
317
318
  return false;
318
- await installNpmEngine(server.package, { baseDir: this.enginesBaseDir, cli: cliDefaultOf(driver), version: driver ? pinnedNpmVersion(driver.driverKind) : undefined });
319
+ const updateCodex = options.update && driver?.driverKind === "codex";
320
+ const version = updateCodex ? await npmLatestVersion(server.package, this.enginesBaseDir) : driver ? pinnedNpmVersion(driver.driverKind) : undefined;
321
+ await installNpmEngine(server.package, { baseDir: this.enginesBaseDir, cli: cliDefaultOf(driver), version });
322
+ if (updateCodex)
323
+ return { useCli: join(enginesBinDir(this.enginesBaseDir), process.platform === "win32" ? "codex.cmd" : "codex"), expectedVersion: version };
319
324
  return true;
320
325
  }
321
326
  finally {
@@ -1,6 +1,9 @@
1
1
  // Import first: it reads a Cloud home's secrets off the launcher's pipe before any module can start a process.
2
2
  import { BOOT_CLOUD_SECRETS } from "./cloud-secrets-boot.js";
3
3
  import { startFailureText } from "./start-failure-text.js";
4
+ import { limixVmCapacity } from "./limix-vm-capacity.js";
5
+ import { localVmAutomaticCapacity } from "./local-vm-settings.js";
6
+ import { runningLocalVmCount } from "./container-computer.js";
4
7
  import { reserveGmailDrafts } from "./gmail-draft-policy.js";
5
8
  import { createGmailDrafts } from "./host/gmail-drafts.js";
6
9
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -5735,7 +5738,7 @@ let localVmProvisionBusy = false;
5735
5738
  let localVmModeChangeBusy = false;
5736
5739
  const localVmUpdates = createLocalVmUpdater({
5737
5740
  status: (target) => containerComputerStatus(undefined, undefined, target),
5738
- act: (action, target) => containerComputerAction(action, undefined, undefined, target, localVmResources(cfg)),
5741
+ act: (action, target) => containerComputerAction(action, undefined, undefined, target, localVmResources(cfg), () => localVmMaxInstances(cfg)),
5739
5742
  imageBusy: { get: () => localVmImageBusy, set: (busy) => { localVmImageBusy = busy; } },
5740
5743
  provisionBusy: { get: () => localVmProvisionBusy, set: (busy) => { localVmProvisionBusy = busy; } },
5741
5744
  lifecycleBusy: localVmLifecycleBusy,
@@ -11829,6 +11832,7 @@ const { fillLoginForTurn } = createFillLoginTurn({
11829
11832
  });
11830
11833
  async function localVmPayload(target, auth) {
11831
11834
  const status = localVmUpdates.describe(target, await containerComputerStatus(undefined, undefined, target));
11835
+ const running = status.runtime && status.daemonUp ? await runningLocalVmCount(status.runtime) : 0;
11832
11836
  return {
11833
11837
  ...localVmViewerStatus(status, auth),
11834
11838
  stop_reason: localVmStopReason(target.key, status),
@@ -11836,11 +11840,14 @@ async function localVmPayload(target, auth) {
11836
11840
  idle_timeout_ms: localVmIdleMs(),
11837
11841
  mode: localVmMode(cfg),
11838
11842
  max_instances: localVmMaxInstances(cfg),
11843
+ automatic_capacity: localVmAutomaticCapacity(cfg),
11844
+ capacity: limixVmCapacity(localVmResources(cfg)),
11845
+ running_instances: running,
11846
+ capacity_limited: status.container === "stopped" && running >= localVmMaxInstances(cfg),
11839
11847
  };
11840
11848
  }
11841
11849
  async function readyLocalVmForTurn(botId, target, isCurrent = () => true) {
11842
11850
  localVmLifecycleBusy.add(target.key);
11843
- // Fence before the first await, so two concurrent turns cannot both pass the per-bot limit between count and create.
11844
11851
  const pooled = target.key.startsWith("pool:");
11845
11852
  const ownsProvision = !pooled && !localVmProvisionBusy;
11846
11853
  if (ownsProvision)
@@ -11857,14 +11864,9 @@ async function readyLocalVmForTurn(botId, target, isCurrent = () => true) {
11857
11864
  return status;
11858
11865
  if (action === "run" && !pooled && !ownsProvision)
11859
11866
  return status;
11860
- if (action === "run" && target.key.startsWith("bot:")) {
11861
- const count = await existingPerBotLocalVmCount(status.runtime);
11862
- if (!isCurrent() || count >= localVmMaxInstances(cfg))
11863
- return status;
11864
- }
11865
11867
  broadcast({ kind: "computer", botId, state: "provisioning" });
11866
11868
  try {
11867
- status = await containerComputerAction(action, undefined, undefined, target, localVmResources(cfg));
11869
+ status = await containerComputerAction(action, undefined, undefined, target, localVmResources(cfg), () => localVmMaxInstances(cfg));
11868
11870
  }
11869
11871
  catch {
11870
11872
  // `run` can throw after the container exists, so arm the idle backstop anyway.
@@ -11956,6 +11958,7 @@ function configStatus() {
11956
11958
  localVm: {
11957
11959
  mode: localVmMode(cfg),
11958
11960
  maxInstances: localVmMaxInstances(cfg),
11961
+ automaticCapacity: localVmAutomaticCapacity(cfg),
11959
11962
  idleTimeoutMinutes: localVmIdleTimeoutMinutes(cfg),
11960
11963
  preserveInstalledApps: localVmPreservesInstalledApps(cfg),
11961
11964
  },
@@ -1,4 +1,4 @@
1
- import { readdirSync, readFileSync, statSync, realpathSync, existsSync } from "node:fs";
1
+ import { readdirSync, readFileSync, statSync, realpathSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { dirname, join, resolve, relative, isAbsolute, delimiter } from "node:path";
4
4
  import { execFile } from "node:child_process";
@@ -63,18 +63,38 @@ export function extractSkillRequirements(text) {
63
63
  add("review", "SKILL.md metadata", "Could not parse the requirements metadata");
64
64
  }
65
65
  }
66
- for (const match of body.matchAll(/\b(npm\s+(?:install|i)|pnpm\s+add|yarn\s+add|bun\s+add|pip3?\s+install|uv\s+(?:pip\s+install|add|tool\s+install))\s+([^\n`]+)/gi)) {
66
+ const requirementLines = [front?.[1] ?? "", ...body.split(/\r?\n/).filter((line) => /requires?|prerequisit|dependenc|compatibility|yêu cầu|cần cài/i.test(line))].join("\n");
67
+ for (const [pattern, name] of [[/\bffmpeg\b/i, "ffmpeg"], [/\bnode(?:\.js)?\b/i, "node"], [/\bdocker\b/i, "docker"], [/\bjava\b/i, "java"]]) {
68
+ if (pattern.test(requirementLines) && !out.some((r) => r.kind === "bin" && r.name === name))
69
+ add("bin", name, "Mentioned in requirements / compatibility; check version in source");
70
+ }
71
+ const commands = [...body.matchAll(/```[^\n]*\n([\s\S]*?)```/g), ...body.matchAll(/`([^`\n]+)`/g)].map((m) => m[1]).join("\n") + "\n" + body.split(/\r?\n/).filter((line) => /^\s*(?:\$\s*)?(?:npm|pnpm|yarn|bun|pip3?|uv|npx|bunx)\s/.test(line)).join("\n");
72
+ for (const match of commands.matchAll(/\b(npm\s+(?:install|i)|pnpm\s+add|yarn\s+add|bun\s+add|pip3?\s+install|uv\s+(?:pip\s+install|add|tool\s+install))\s+([^\n`]+)/gi)) {
67
73
  const kind = /pip|^uv/i.test(match[1]) ? "python" : "npm";
68
- for (const token of match[2].split(/\s+/))
69
- if (!token.startsWith("-") && !/^[;&|#]/.test(token))
70
- add(kind, token, match[0]);
74
+ for (const raw of match[2].match(/"[^"]*"|'[^']*'|\S+/g) ?? []) {
75
+ const token = raw.replace(/^["']|["']$/g, "");
76
+ if (/^[;&|#\\]/.test(token))
77
+ break;
78
+ if (token.startsWith("-")) {
79
+ if (["--save", "--save-dev", "--save-exact", "--no-audit", "--no-fund", "-D", "-g", "--global", "--user", "--upgrade", "-U"].includes(token))
80
+ continue;
81
+ add("review", match[0], "Install command needs review");
82
+ break;
83
+ }
84
+ if (!/^(?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*(?:(?:@|>=|<=|==|~=|>|<|=)[\w.^~*+<>=|,-]+)?$/i.test(token)) {
85
+ add("review", match[0], "Install command needs review");
86
+ break;
87
+ }
88
+ add(kind, token, match[0]);
89
+ }
71
90
  }
72
- for (const match of body.matchAll(/\b(?:npx|bunx|pnpm\s+(?:exec|dlx))\s+(?:--?[\w-]+(?:=[^\s]+)?\s+)*((?:@[\w.-]+\/)?[\w.-]+(?:@[\w.^~+-]+)?)/g)) {
91
+ for (const match of commands.matchAll(/\b(?:npx|bunx|pnpm\s+(?:exec|dlx))\s+(?:--?[\w-]+(?:=[^\s]+)?\s+)*((?:@[\w.-]+\/)?[\w.-]+(?:@[\w.^~+-]+)?)/g)) {
73
92
  add("npm", match[1] === "remotion" ? "@remotion/cli" : match[1], match[0]);
74
93
  }
75
94
  if (/\bremotion\b/i.test(text)) {
76
- add("npm", "remotion", "Remotion");
77
- add("npm", "@remotion/cli", "Remotion CLI");
95
+ for (const name of ["remotion", "@remotion/cli"])
96
+ if (!out.some((r) => r.kind === "npm" && r.name === name))
97
+ out.push({ kind: "npm", name, evidence: "Remotion code-rendering workflow", optional: true });
78
98
  }
79
99
  let section = false;
80
100
  for (const line of body.split(/\r?\n/)) {
@@ -151,7 +171,7 @@ export function findSkillPythonPackage(name, roots) {
151
171
  }
152
172
  return null;
153
173
  }
154
- export async function scanSkillRequirements(bots, mcpServers = {}) {
174
+ export async function scanSkillRequirements(bots, mcpServers = {}, projects = []) {
155
175
  const sources = new Map();
156
176
  const warnings = [];
157
177
  const add = (name, directory, projects = []) => {
@@ -179,29 +199,6 @@ export async function scanSkillRequirements(bots, mcpServers = {}) {
179
199
  add(`${skill.name} (${bot.name})`, skill.directory, [bot.cwd ?? workspaceDir(bot.id)]);
180
200
  }
181
201
  const home = homedir();
182
- const walkSkills = (root, depth = 0, projects = []) => {
183
- if (depth > 3 || !existsSync(root))
184
- return;
185
- try {
186
- if (statSync(join(root, "SKILL.md"), { throwIfNoEntry: false })?.isFile()) {
187
- add(root.split(/[\\/]/).at(-1), root, projects);
188
- return;
189
- }
190
- for (const entry of readdirSync(root, { withFileTypes: true }))
191
- if (entry.name !== "node_modules" && entry.name !== ".git" && (entry.isDirectory() || entry.isSymbolicLink()))
192
- walkSkills(join(root, entry.name), depth + 1, projects);
193
- }
194
- catch {
195
- warnings.push(`Could not enumerate ${root}`);
196
- }
197
- };
198
- for (const root of [join(home, ".agents", "skills"), join(process.env.CODEX_HOME ?? join(home, ".codex"), "skills"), join(process.env.CLAUDE_CONFIG_DIR ?? join(home, ".claude"), "skills"), join(home, ".gemini", "skills"), join(home, ".gemini", "antigravity", "skills")])
199
- walkSkills(root);
200
- for (const bot of bots.filter((b) => !b.computer || b.computer === "local")) {
201
- const cwd = bot.cwd ?? workspaceDir(bot.id);
202
- for (const folder of [".agents", ".claude", ".codex", ".gemini"])
203
- walkSkills(join(cwd, folder, "skills"), 0, [cwd]);
204
- }
205
202
  const dirs = `${process.env.OMB_EXTRA_PATH ?? ""}${delimiter}${process.env.PATH ?? ""}`.split(delimiter).filter(Boolean);
206
203
  if (process.platform === "win32") {
207
204
  try {
@@ -286,7 +283,7 @@ export async function scanSkillRequirements(bots, mcpServers = {}) {
286
283
  result.where = where;
287
284
  }
288
285
  else if (req.kind === "npm") {
289
- const pkg = findSkillNpmPackage(req.name, [source.directory, ...source.projects, ...bots.filter((b) => !b.computer || b.computer === "local").map((b) => b.cwd ?? workspaceDir(b.id)), join(process.env.APPDATA ?? home, "npm")]);
286
+ const pkg = findSkillNpmPackage(req.name, [source.directory, ...source.projects, ...projects, ...bots.filter((b) => !b.computer || b.computer === "local").map((b) => b.cwd ?? workspaceDir(b.id)), join(process.env.APPDATA ?? home, "npm")]);
290
287
  result.status = pkg ? req.required && req.required !== "*" ? "review" : "found" : "missing";
291
288
  if (pkg)
292
289
  Object.assign(result, pkg);
@@ -294,7 +291,7 @@ export async function scanSkillRequirements(bots, mcpServers = {}) {
294
291
  else if (req.kind === "env")
295
292
  result.status = process.env[req.name] ? "found" : "missing";
296
293
  else if (req.kind === "python") {
297
- const pkg = findSkillPythonPackage(req.name, [source.directory, ...source.projects, ...bots.filter((b) => !b.computer || b.computer === "local").map((b) => b.cwd ?? workspaceDir(b.id))]);
294
+ const pkg = findSkillPythonPackage(req.name, [source.directory, ...source.projects, ...projects, ...bots.filter((b) => !b.computer || b.computer === "local").map((b) => b.cwd ?? workspaceDir(b.id))]);
298
295
  if (pkg) {
299
296
  Object.assign(result, pkg);
300
297
  result.status = req.required ? "review" : "found";
@@ -0,0 +1,64 @@
1
+ import { availableParallelism, totalmem } from "node:os";
2
+ const GIB = 1024 ** 3;
3
+ const TTL_MS = 30_000;
4
+ let machine = null;
5
+ let cached = null;
6
+ let generation = 0;
7
+ let startQueue = Promise.resolve();
8
+ export function serializeLimixVmStart(work) {
9
+ const next = startQueue.then(work, work);
10
+ startQueue = next.catch(() => undefined);
11
+ return next;
12
+ }
13
+ export function calculateLimixVmCapacity(host, resources) {
14
+ const reservedMemoryGb = Math.min(host.memoryGb, Math.max(2, host.memoryGb * 0.2));
15
+ const reservedCpus = Math.min(host.cpus, Math.max(1, Math.ceil(host.cpus * 0.1)));
16
+ const memorySlots = Math.max(0, Math.floor((host.memoryGb - reservedMemoryGb) / resources.memoryGb));
17
+ const cpuSlots = Math.max(0, Math.floor((host.cpus - reservedCpus) / resources.cpus));
18
+ return {
19
+ limit: Math.min(memorySlots, cpuSlots), source: host.source,
20
+ memoryGb: host.memoryGb, cpus: host.cpus, reservedMemoryGb, reservedCpus,
21
+ perVmMemoryGb: resources.memoryGb, perVmCpus: resources.cpus,
22
+ constrainedBy: memorySlots <= cpuSlots ? "memory" : "cpu",
23
+ };
24
+ }
25
+ export function limixVmCapacity(resources) {
26
+ return calculateLimixVmCapacity(machine ?? { memoryGb: totalmem() / GIB, cpus: availableParallelism(), source: "host" }, resources);
27
+ }
28
+ export function parseLimixRuntimeResources(runtime, raw) {
29
+ try {
30
+ const info = JSON.parse(raw);
31
+ const memory = Number(runtime === "podman" ? info.host?.memTotal : info.MemTotal);
32
+ const cpus = Number(runtime === "podman" ? info.host?.cpus : info.NCPU);
33
+ if (!Number.isFinite(memory) || !Number.isFinite(cpus) || memory <= 0 || cpus < 1 || runtime === "container")
34
+ return null;
35
+ return { memoryGb: memory / GIB, cpus: Math.floor(cpus), source: runtime };
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ export async function refreshLimixVmCapacity(runtime, runner) {
42
+ if (!runtime) {
43
+ generation++;
44
+ machine = null;
45
+ cached = null;
46
+ return;
47
+ }
48
+ if (cached?.runtime === runtime && cached.expires > Date.now())
49
+ return cached.pending;
50
+ if (cached?.runtime !== runtime)
51
+ machine = null;
52
+ const current = ++generation;
53
+ const pending = (async () => {
54
+ try {
55
+ const result = await runner(runtime, ["info", "--format", runtime === "podman" ? "json" : "{{json .}}"], 5000);
56
+ const detected = parseLimixRuntimeResources(runtime, result.stdout);
57
+ if (detected && current === generation)
58
+ machine = detected;
59
+ }
60
+ catch { }
61
+ })();
62
+ cached = { runtime, expires: Date.now() + TTL_MS, pending };
63
+ await pending;
64
+ }
@@ -1,16 +1,18 @@
1
1
  // The Local VM's settings, read from the config the server loaded.
2
2
  import { z } from "zod";
3
+ import { limixVmCapacity } from "./limix-vm-capacity.js";
3
4
  import { DEFAULT_DESKTOP_RESOURCES, MAX_DESKTOP_CPUS, MAX_DESKTOP_MEMORY_GB, MIN_DESKTOP_CPUS, MIN_DESKTOP_MEMORY_GB, } from "./container-limits.js";
4
5
  export const DEFAULT_LOCAL_VM_MODE = "shared";
5
6
  export const DEFAULT_LOCAL_VM_MAX_INSTANCES = 2;
6
7
  export const MIN_LOCAL_VM_MAX_INSTANCES = 1;
7
- export const MAX_LOCAL_VM_MAX_INSTANCES = 8;
8
+ export const MAX_LOCAL_VM_MAX_INSTANCES = 1024;
8
9
  export const DEFAULT_LOCAL_VM_IDLE_TIMEOUT_MINUTES = 480;
9
10
  export const MIN_LOCAL_VM_IDLE_TIMEOUT_MINUTES = 5;
10
11
  export const MAX_LOCAL_VM_IDLE_TIMEOUT_MINUTES = 1_440;
11
- /** Bot desktop isolation, default "shared"; `maxInstances` caps per-bot desktops or pool seats. Switching modes cold-starts every desktop. */
12
+ /** Bot desktop isolation, default "shared"; `maxInstances` limits running desktops in manual mode. Created, stopped per-bot desktops do not consume a running slot. */
12
13
  export const localVmConfigSchema = z.object({
13
14
  mode: z.enum(["shared", "per-bot", "pool"]).optional(),
15
+ automaticCapacity: z.boolean().optional(),
14
16
  maxInstances: z
15
17
  .number()
16
18
  .int()
@@ -33,7 +35,12 @@ export function localVmMode(cfg) {
33
35
  return cfg.localVm?.mode ?? DEFAULT_LOCAL_VM_MODE;
34
36
  }
35
37
  export function localVmMaxInstances(cfg) {
36
- return cfg.localVm?.maxInstances ?? DEFAULT_LOCAL_VM_MAX_INSTANCES;
38
+ if (!localVmAutomaticCapacity(cfg))
39
+ return cfg.localVm.maxInstances ?? DEFAULT_LOCAL_VM_MAX_INSTANCES;
40
+ return limixVmCapacity(localVmResources(cfg)).limit;
41
+ }
42
+ export function localVmAutomaticCapacity(cfg) {
43
+ return cfg.localVm?.automaticCapacity ?? cfg.localVm?.maxInstances === undefined;
37
44
  }
38
45
  export function localVmIdleTimeoutMinutes(cfg) {
39
46
  return cfg.localVm?.idleTimeoutMinutes ?? DEFAULT_LOCAL_VM_IDLE_TIMEOUT_MINUTES;
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { isAbsolute } from "node:path";
2
3
  import { handleLimixBotLibrary } from "../limix-bot-library.js";
3
4
  import { setImportedSkillEnabled } from "../imported-skills.js";
4
5
  import { setNativeSkillEnabled } from "../native-skill-choices.js";
@@ -21,6 +22,12 @@ export function createBotSkillsRoutes(deps) {
21
22
  if (method === "GET" && path === "/api/limix/skill-requirements") {
22
23
  return json(res, 200, await scanSkillRequirements(store.bots, cfg.mcpServers));
23
24
  }
25
+ if (method === "POST" && path === "/api/limix/skill-requirements/scan") {
26
+ const input = z.object({ projects: z.array(z.string().max(4096).refine(isAbsolute)).max(200) }).safeParse(await readBody(req));
27
+ if (!input.success)
28
+ return json(res, 400, { error: "Choose valid project folders" });
29
+ return json(res, 200, await scanSkillRequirements(store.bots, cfg.mcpServers, input.data.projects));
30
+ }
24
31
  if (path.startsWith("/api/limix/gateway") && proxyLimixGateway(req, res, path))
25
32
  return;
26
33
  if (path.startsWith("/api/limix/bots")) {
@@ -1,7 +1,9 @@
1
1
  import { z } from "zod";
2
2
  import * as boat from "../boat.js";
3
+ import { limixVmCapacity } from "../limix-vm-capacity.js";
4
+ import { localVmAutomaticCapacity } from "../local-vm-settings.js";
3
5
  import { isValidSshAlias, localVmMaxInstances, localVmMode, localVmResources } from "../config.js";
4
- import { containerComputerAction, containerComputerExists, containerComputerScreenshot, containerComputerStatus, SHARED_LOCAL_VM_TARGET, setupCommands, } from "../container-computer.js";
6
+ import { containerComputerAction, containerComputerScreenshot, containerComputerStatus, runningLocalVmCount, SHARED_LOCAL_VM_TARGET, setupCommands, } from "../container-computer.js";
5
7
  import { viewerTargetId } from "../../shared/desktop-viewer.js";
6
8
  import { localVmViewerStatus } from "../desktop-viewer-targets.js";
7
9
  import { keepFirefoxProfileBeforeRemove } from "../local-vm-profiles.js";
@@ -19,7 +21,7 @@ async function keepSignInsBeforeRemove(target) {
19
21
  await keepFirefoxProfileBeforeRemove(target, before, () => containerComputerAction("stop", undefined, undefined, target));
20
22
  }
21
23
  export function createComputerRoutes(deps) {
22
- const { store, cfg, sessions, teamComputers, computerControl, controlLeaseIdSchema, boatLifecycleBusyBots, computerProviderConfigTransitions, localVmActiveThreads, localVmLifecycleBusy, localVmSeen, localVmImageBusy, localVmProvisionBusy, localVmModeChangeBusy, localVmOwnerBusy, localVmIdleMs, localVmLeaseFor, localVmIdleFor, localVmTargetForBot, localVmTargetForStatus, localVmPayload, localVmInventoryPayload, existingPerBotLocalVmCount, teamComputersPayload, teamComputerInUse, managedBoatOwners, providerTransitionMessage, botHasActiveTurn, botComputerControlKey, botComputerControlSnapshot, computerPreviewBot, computerPreviewSurface, claimTeamComputerLifecycle, claimBotComputerLifecycle, claimBoatInventoryRequest, claimManagedBoatMutation, claimManagedVpsMutation, cloudComputerUsed, } = deps;
24
+ const { store, cfg, sessions, teamComputers, computerControl, controlLeaseIdSchema, boatLifecycleBusyBots, computerProviderConfigTransitions, localVmActiveThreads, localVmLifecycleBusy, localVmSeen, localVmImageBusy, localVmProvisionBusy, localVmModeChangeBusy, localVmOwnerBusy, localVmIdleMs, localVmLeaseFor, localVmIdleFor, localVmTargetForBot, localVmTargetForStatus, localVmPayload, localVmInventoryPayload, teamComputersPayload, teamComputerInUse, managedBoatOwners, providerTransitionMessage, botHasActiveTurn, botComputerControlKey, botComputerControlSnapshot, computerPreviewBot, computerPreviewSurface, claimTeamComputerLifecycle, claimBotComputerLifecycle, claimBoatInventoryRequest, claimManagedBoatMutation, claimManagedVpsMutation, cloudComputerUsed, } = deps;
23
25
  const usage = createComputerUsageRoutes(deps);
24
26
  const frames = createComputerFramesRoutes(deps);
25
27
  return async (context) => {
@@ -263,7 +265,7 @@ export function createComputerRoutes(deps) {
263
265
  try {
264
266
  if (action === "remove")
265
267
  await keepSignInsBeforeRemove(SHARED_LOCAL_VM_TARGET);
266
- const status = await containerComputerAction(action, undefined, undefined, SHARED_LOCAL_VM_TARGET, localVmResources(cfg));
268
+ const status = await containerComputerAction(action, undefined, undefined, SHARED_LOCAL_VM_TARGET, localVmResources(cfg), () => localVmMaxInstances(cfg));
267
269
  if (action === "run" || action === "start") {
268
270
  localVmSeen.add(SHARED_LOCAL_VM_TARGET.key);
269
271
  localVmIdleFor(SHARED_LOCAL_VM_TARGET).touch();
@@ -276,6 +278,9 @@ export function createComputerRoutes(deps) {
276
278
  idle_timeout_ms: localVmIdleMs(),
277
279
  mode: localVmMode(cfg),
278
280
  max_instances: localVmMaxInstances(cfg),
281
+ automatic_capacity: localVmAutomaticCapacity(cfg),
282
+ capacity: limixVmCapacity(localVmResources(cfg)),
283
+ running_instances: status.runtime ? await runningLocalVmCount(status.runtime) : 0,
279
284
  });
280
285
  }
281
286
  finally {
@@ -327,7 +332,6 @@ export function createComputerRoutes(deps) {
327
332
  if ((action === "stop" || action === "remove") && (localVmActiveThreads.has(target.key) || localVmLifecycleBusy.has(target.key))) {
328
333
  return json(res, 409, { error: localVmActiveThreads.has(target.key) ? "this bot is using its Local VM — stop the turn first" : "this bot's Local VM setup action is still running" });
329
334
  }
330
- // Fenced before the first await, so two requests cannot both pass the limit.
331
335
  localVmLifecycleBusy.add(target.key);
332
336
  if (action === "run")
333
337
  localVmProvisionBusy.set(true);
@@ -336,18 +340,10 @@ export function createComputerRoutes(deps) {
336
340
  const before = await containerComputerStatus(undefined, undefined, target);
337
341
  if (!before.runtime)
338
342
  return json(res, 409, { error: before.problem ?? "No container runtime is installed" });
339
- if (!(await containerComputerExists(before.runtime, target))) {
340
- const count = await existingPerBotLocalVmCount(before.runtime);
341
- if (count >= localVmMaxInstances(cfg)) {
342
- return json(res, 409, {
343
- error: `The per-bot Local VM limit is ${localVmMaxInstances(cfg)} — delete an unused bot VM or raise the limit in App Settings`,
344
- });
345
- }
346
- }
347
343
  }
348
344
  if (action === "remove")
349
345
  await keepSignInsBeforeRemove(target);
350
- const status = await containerComputerAction(action, undefined, undefined, target, localVmResources(cfg));
346
+ const status = await containerComputerAction(action, undefined, undefined, target, localVmResources(cfg), () => localVmMaxInstances(cfg));
351
347
  if (action === "run" || action === "start") {
352
348
  localVmSeen.add(target.key);
353
349
  localVmIdleFor(target).touch();
@@ -360,6 +356,9 @@ export function createComputerRoutes(deps) {
360
356
  idle_timeout_ms: localVmIdleMs(),
361
357
  mode: localVmMode(cfg),
362
358
  max_instances: localVmMaxInstances(cfg),
359
+ automatic_capacity: localVmAutomaticCapacity(cfg),
360
+ capacity: limixVmCapacity(localVmResources(cfg)),
361
+ running_instances: status.runtime ? await runningLocalVmCount(status.runtime) : 0,
363
362
  });
364
363
  }
365
364
  finally {
@@ -349,11 +349,21 @@ export function createInstanceRoutes(deps) {
349
349
  return json(res, 200, { instances: await describeInstances() });
350
350
  }
351
351
  if (action === "install") {
352
- const installed = await registry.installRuntime(instanceId);
352
+ const updating = url.searchParams.get("update") === "1";
353
+ const installed = await registry.installRuntime(instanceId, { update: updating });
353
354
  if (!installed)
354
355
  return json(res, 404, { error: "Installing this engine from Settings is not available on this server. Use the install command on the machine running Limix Bot." });
355
356
  const usingAppCopy = installed !== true && await useAppCopy(instanceId, installed.useCli);
356
- return json(res, 200, { instances: await describeInstances(), ...(usingAppCopy ? { usingAppCopy: true } : {}) });
357
+ if (updating && installed !== true && !usingAppCopy)
358
+ return json(res, 409, { error: "The new CLI was installed, but this engine is busy. Wait for its current task to finish, then retry the update to switch to the new copy." });
359
+ const instances = await describeInstances();
360
+ if (installed !== true && installed.expectedVersion) {
361
+ const active = await registry.get(instanceId)?.snapshot();
362
+ if (active?.state !== "available" || active.version?.match(/\b\d+\.\d+\.\d+(?:-[\w.-]+)?\b/)?.[0] !== installed.expectedVersion) {
363
+ return json(res, 502, { error: `The new CLI was downloaded, but its active version could not be verified as ${installed.expectedVersion}. Current version: ${active?.version ?? "unknown"}.` });
364
+ }
365
+ }
366
+ return json(res, 200, { instances, ...(usingAppCopy ? { usingAppCopy: true } : {}) });
357
367
  }
358
368
  if (action === "auth/start") {
359
369
  const instance = registry.get(instanceId);
@@ -0,0 +1 @@
1
+ export {};
@@ -1472,8 +1472,8 @@ let address=raw.split("%",1)[0];return isIP(address)!==0&&list.check(address,fam
1472
1472
  let match=/^\[([^\]]+)\](?:\/(\d{1,3}))?(?::(\d{1,5}))?$/.exec(entry)??(entry.split(":").length>2?/^([^/]+)(?:\/(\d{1,3}))?()$/.exec(entry):/^([^/:]+)(?:\/(\d{1,3}))?(?::(\d{1,5}))?$/.exec(entry));if(!match)return null;let[,network="",prefixText,portText]=match,kind=isIP2(network);if(!kind)return null;let max=kind===6?128:32,prefix=prefixText===void 0?max:Number(prefixText),port=portText?Number(portText):null;return!Number.isInteger(prefix)||prefix<0||prefix>max||port!==null&&(!Number.isInteger(
1473
1473
  port)||port<1||port>65535)?null:{network,prefix,port}}async function refusalFor(target,addresses,rules,own2=ownAddresses()){let{host,port}=target;for(let{address}of addresses){let kind=addressClass(address,own2);if(kind==="reserved"&&rules.host==="desktop"&&listed(FAKE_IP,address)){if(rules.ownPort(port))return"omb";kind=listed(own2,address)?"this-machine":"private"}if(kind!=="public"){if(kind==="metadata"||kind==="link-local"||kind==="reserved")return kind;if(kind==="private"){if(rules.host==="desktop"?rules.localNetwork:rules.host==="server"&&rules.
1474
1474
  allowed(address,port))continue;if(rules.host==="server"&&rules.localNetwork){if(rules.ownPort(port))return"omb";continue}return"local-network"}if(rules.ownPort(port))return"omb";if(rules.host==="desktop"){if(namesThisMachine(host))continue;return"rebinding"}if(!(rules.host==="server"&&rules.localNetwork&&(kind==="this-machine"||namesThisMachine(host)))&&!(rules.host==="server"&&rules.allowed(address,port))&&!await rules.botPort(port))return"this-computer"}}return null}var CDP_PORT=/^[0-9]{1,5}$/,CDP_URL=/^(https?|wss?):\/\/\S+$/i;function isValidCdpTarget(value){if(typeof value!="string"||value==="")return!1;if(CDP_PORT.test(value)){let port=Number(value);return port>=1&&port<=65535}return CDP_URL.test(value)}var browserEngineConfigSchema=external_exports.object({attachCdpUrl:external_exports.string().trim().max(2048).refine(value=>value===""||isValidCdpTarget(value),{message:"browserEngine.attachCdpUrl must be a CDP port (1-65535) or an http(s)/ws(s) URL"}).
1475
- optional(),idleTimeoutMinutes:external_exports.number().int().min(1).max(60).optional(),egress:browserEgressConfigSchema.optional(),engine:external_exports.enum(["agent-browser","chrome"]).optional()});var roomContextSettings={roomCompactAt:external_exports.number().positive().max(1e7).optional(),roomSessions:external_exports.boolean().optional()};var MIN_DESKTOP_MEMORY_GB=2,MAX_DESKTOP_MEMORY_GB=128,MIN_DESKTOP_CPUS=1,MAX_DESKTOP_CPUS=64;var MIN_LOCAL_VM_MAX_INSTANCES=1,MAX_LOCAL_VM_MAX_INSTANCES=8;var MIN_LOCAL_VM_IDLE_TIMEOUT_MINUTES=5,MAX_LOCAL_VM_IDLE_TIMEOUT_MINUTES=1440,localVmConfigSchema=external_exports.object({mode:external_exports.enum(["shared","per-bot","pool"]).optional(),maxInstances:external_exports.number().int().min(MIN_LOCAL_VM_MAX_INSTANCES).max(MAX_LOCAL_VM_MAX_INSTANCES).optional(),idleTimeoutMinutes:external_exports.number().int().min(MIN_LOCAL_VM_IDLE_TIMEOUT_MINUTES).max(MAX_LOCAL_VM_IDLE_TIMEOUT_MINUTES).optional(),preserveInstalledApps:external_exports.boolean().
1476
- optional(),memoryGb:external_exports.number().int().min(MIN_DESKTOP_MEMORY_GB).max(MAX_DESKTOP_MEMORY_GB).optional(),cpus:external_exports.number().int().min(MIN_DESKTOP_CPUS).max(MAX_DESKTOP_CPUS).optional()});var optionalText2=external_exports.string().optional(),SSH_ALIAS=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/,LEGACY_BROWSER_PROFILE_ID=/^[A-Za-z0-9_-]{1,40}$/,BROWSER_PROFILE_ID=/^[a-z0-9_-]{1,40}$/,FISH_TTS_MODELS=["s2.1-pro","s2.1-pro-free"];var MIN_ROOM_TURN_TIMEOUT_MINUTES=1,MAX_ROOM_TURN_TIMEOUT_MINUTES=1440;var MIN_MCP_CALL_TIMEOUT_MINUTES=1,MAX_MCP_CALL_TIMEOUT_MINUTES=60,MIN_THREAD_EVENT_LOG_BYTES=256*1024,MAX_THREAD_EVENT_LOG_BYTES=4*1024*1024*1024;function isValidSshAlias(value){return typeof value=="string"&&SSH_ALIAS.test(value)}var vpsConfigSchema=external_exports.object({sshAlias:external_exports.string().refine(value=>value===""||isValidSshAlias(value),{message:"must be a simple SSH config alias"}).optional()}),roomConfigSchema=external_exports.object({turnTimeoutMinutes:external_exports.number().int().min(MIN_ROOM_TURN_TIMEOUT_MINUTES).max(MAX_ROOM_TURN_TIMEOUT_MINUTES)}),mcpConfigSchema=external_exports.object({callTimeoutMinutes:external_exports.number().int().min(MIN_MCP_CALL_TIMEOUT_MINUTES).max(MAX_MCP_CALL_TIMEOUT_MINUTES).
1475
+ optional(),idleTimeoutMinutes:external_exports.number().int().min(1).max(60).optional(),egress:browserEgressConfigSchema.optional(),engine:external_exports.enum(["agent-browser","chrome"]).optional()});var roomContextSettings={roomCompactAt:external_exports.number().positive().max(1e7).optional(),roomSessions:external_exports.boolean().optional()};var GIB=1024**3;var startQueue=Promise.resolve();var MIN_DESKTOP_MEMORY_GB=2,MAX_DESKTOP_MEMORY_GB=128,MIN_DESKTOP_CPUS=1,MAX_DESKTOP_CPUS=64;var MIN_LOCAL_VM_MAX_INSTANCES=1,MAX_LOCAL_VM_MAX_INSTANCES=1024;var MIN_LOCAL_VM_IDLE_TIMEOUT_MINUTES=5,MAX_LOCAL_VM_IDLE_TIMEOUT_MINUTES=1440,localVmConfigSchema=external_exports.object({mode:external_exports.enum(["shared","per-bot","pool"]).optional(),automaticCapacity:external_exports.boolean().optional(),maxInstances:external_exports.number().int().min(MIN_LOCAL_VM_MAX_INSTANCES).max(MAX_LOCAL_VM_MAX_INSTANCES).optional(),idleTimeoutMinutes:external_exports.number().int().min(MIN_LOCAL_VM_IDLE_TIMEOUT_MINUTES).max(MAX_LOCAL_VM_IDLE_TIMEOUT_MINUTES).optional(),
1476
+ preserveInstalledApps:external_exports.boolean().optional(),memoryGb:external_exports.number().int().min(MIN_DESKTOP_MEMORY_GB).max(MAX_DESKTOP_MEMORY_GB).optional(),cpus:external_exports.number().int().min(MIN_DESKTOP_CPUS).max(MAX_DESKTOP_CPUS).optional()});var optionalText2=external_exports.string().optional(),SSH_ALIAS=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/,LEGACY_BROWSER_PROFILE_ID=/^[A-Za-z0-9_-]{1,40}$/,BROWSER_PROFILE_ID=/^[a-z0-9_-]{1,40}$/,FISH_TTS_MODELS=["s2.1-pro","s2.1-pro-free"];var MIN_ROOM_TURN_TIMEOUT_MINUTES=1,MAX_ROOM_TURN_TIMEOUT_MINUTES=1440;var MIN_MCP_CALL_TIMEOUT_MINUTES=1,MAX_MCP_CALL_TIMEOUT_MINUTES=60,MIN_THREAD_EVENT_LOG_BYTES=256*1024,MAX_THREAD_EVENT_LOG_BYTES=4*1024*1024*1024;function isValidSshAlias(value){return typeof value=="string"&&SSH_ALIAS.test(value)}var vpsConfigSchema=external_exports.object({sshAlias:external_exports.string().refine(value=>value===""||isValidSshAlias(value),{message:"must be a simple SSH config alias"}).optional()}),roomConfigSchema=external_exports.object({turnTimeoutMinutes:external_exports.number().int().min(MIN_ROOM_TURN_TIMEOUT_MINUTES).max(MAX_ROOM_TURN_TIMEOUT_MINUTES)}),mcpConfigSchema=external_exports.object({callTimeoutMinutes:external_exports.number().int().min(MIN_MCP_CALL_TIMEOUT_MINUTES).max(MAX_MCP_CALL_TIMEOUT_MINUTES).
1477
1477
  optional()}).strict(),browserProfileSchema=external_exports.object({id:external_exports.string().regex(BROWSER_PROFILE_ID).refine(id=>id!=="guest","guest is reserved"),name:external_exports.string().trim().min(1).max(40),browser:external_exports.literal("chrome").optional()}).strict(),legacyBrowserProfileSchema=external_exports.object({id:external_exports.string().regex(LEGACY_BROWSER_PROFILE_ID).refine(id=>id!=="guest","guest is reserved"),name:external_exports.string().trim().min(1).max(40),partitionId:external_exports.
1478
1478
  string().regex(LEGACY_BROWSER_PROFILE_ID).refine(id=>id!=="guest","guest is reserved").optional(),browser:external_exports.literal("chrome").optional()}).strict();function suffixedBrowserProfileId(base,unavailable){for(let suffix=2;;suffix+=1){let ending=`-${suffix}`,candidate=`${base.slice(0,40-ending.length)}${ending}`;if(candidate!=="guest"&&!unavailable.has(candidate))return candidate}}function migrateStoredBrowserProfiles(profiles){let requestedPartitions=profiles.map(profile=>profile.partitionId??
1479
1479
  profile.id),rawBases=profiles.map(profile=>profile.id.toLowerCase()),canonicalIds=Array(profiles.length).fill(void 0),used=new Set,baseOwner=new Map;rawBases.forEach((base,index)=>{if(base==="guest")return;let current=baseOwner.get(base);(current===void 0||profiles[index].id===base&&profiles[current].id!==base)&&baseOwner.set(base,index)});for(let[base,index]of baseOwner)canonicalIds[index]=base,used.add(base);let reserved=new Set(["guest",...rawBases,...requestedPartitions.map(partitionId=>partitionId.
@@ -1501,7 +1501,7 @@ computerName:external_exports.string().trim().max(63).optional(),rooms:roomConfi
1501
1501
  0).max(23).optional()}).strict().optional(),threads:threadsConfigSchema.optional(),burst:external_exports.object({maxParallel:external_exports.number().int().min(1).max(100).optional()}).strict().optional(),decisions:external_exports.object({retentionDays:external_exports.number().int().min(1).max(3650).optional()}).strict().optional(),loopGuard:loopGuardConfigSchema.optional(),safetyFloor:external_exports.object({enabled:external_exports.boolean().optional()}).strict().optional(),localVm:localVmConfigSchema.
1502
1502
  optional(),features:featureConfigSchema.optional(),onboarding:onboardingConfigSchema.optional(),browserEngine:browserEngineConfigSchema.optional(),browserProfiles:browserProfilesSchema.optional(),instances:instanceConfigMapSchema.optional(),mcpServers:external_exports.record(external_exports.string(),external_exports.unknown()).optional()}),storedAppConfigSchema=appConfigSchema.extend(helperStoredShape).extend({browserProfiles:storedBrowserProfilesSchema.optional(),opencodeGo:external_exports.object(
1503
1503
  {apiKey:optionalText2,providerKeys:external_exports.record(external_exports.string(),external_exports.unknown()).catch({}).transform(keys=>Object.fromEntries(Object.entries(keys).filter(entry=>typeof entry[1]=="string"))).optional()}).optional()}),appConfigPatchSchema=appConfigSchema.omit({instances:!0,mcpServers:!0,cliStartup:!0,customDomain:!0}).extend({threads:threadsPatchSchema.optional(),newBots:newBotsPatchSchema.optional(),imageGen:imageGenPatchSchema.optional()}),jsonObjectSchema2=external_exports.
1504
- record(external_exports.string(),external_exports.json());function parseStoredConfig(value){let parsed=storedAppConfigSchema.safeParse(value);if(!parsed.success)throw new Error(schemaIssue(parsed.error,"Invalid stored configuration"));return parsed.data}var DEFAULT_CAPTURE_QUIET_MS=2*6e4;var DATA_DIR=process.env.OMB_DATA_DIR||join5(dataHome(),".limixbot"),LEGACY_DATA_DIR=join5(dataHome(),".opengrokbot"),EVENTS_DIR=join5(DATA_DIR,"events"),NATIVE_DIR=join5(DATA_DIR,"native");var storedConfig=settledFileCache(()=>join5(DATA_DIR,"config.json"),()=>parseStoredConfig(parseJson(readFileSync3(join5(DATA_DIR,"config.json"),"utf8"))));var GIB=1024*1024*1024;var SUPERVISOR_CAPS=["SETGID","SETUID"],PACKAGE_INSTALL_CAPS=["CHOWN","DAC_OVERRIDE","FOWNER","FSETID",...SUPERVISOR_CAPS];var SUPERVISORD="/usr/bin/supervisord -c /etc/supervisor/supervisord.conf",GUEST_IDS_SCRIPT=["set -eu",'uid="$1"; gid="$2"; old_uid="$(id -u cua)"; old_gid="$(id -g cua)"','if [ "$old_uid:$old_gid" != "$uid:$gid" ]; then',' find / -xdev -uid "$old_uid" -exec chown -h "$uid" {} +',' find / -xdev -gid "$old_gid" -exec chgrp -h "$gid" {} +',' sed -i "s/^cua:x:$old_uid:$old_gid:/cua:x:$uid:$gid:/" /etc/passwd',' sed -i "s/^cua:x:$old_gid:/cua:x:$gid:/" /etc/group',' [ "$(id -u cua):$(id -g cua)\
1504
+ record(external_exports.string(),external_exports.json());function parseStoredConfig(value){let parsed=storedAppConfigSchema.safeParse(value);if(!parsed.success)throw new Error(schemaIssue(parsed.error,"Invalid stored configuration"));return parsed.data.localVm&&parsed.data.localVm.automaticCapacity===void 0&&(parsed.data.localVm.automaticCapacity=!0),parsed.data}var DEFAULT_CAPTURE_QUIET_MS=2*6e4;var DATA_DIR=process.env.OMB_DATA_DIR||join5(dataHome(),".limixbot"),LEGACY_DATA_DIR=join5(dataHome(),".opengrokbot"),EVENTS_DIR=join5(DATA_DIR,"events"),NATIVE_DIR=join5(DATA_DIR,"native");var storedConfig=settledFileCache(()=>join5(DATA_DIR,"config.json"),()=>parseStoredConfig(parseJson(readFileSync3(join5(DATA_DIR,"config.json"),"utf8"))));var GIB2=1024*1024*1024;var SUPERVISOR_CAPS=["SETGID","SETUID"],PACKAGE_INSTALL_CAPS=["CHOWN","DAC_OVERRIDE","FOWNER","FSETID",...SUPERVISOR_CAPS];var SUPERVISORD="/usr/bin/supervisord -c /etc/supervisor/supervisord.conf",GUEST_IDS_SCRIPT=["set -eu",'uid="$1"; gid="$2"; old_uid="$(id -u cua)"; old_gid="$(id -g cua)"','if [ "$old_uid:$old_gid" != "$uid:$gid" ]; then',' find / -xdev -uid "$old_uid" -exec chown -h "$uid" {} +',' find / -xdev -gid "$old_gid" -exec chgrp -h "$gid" {} +',' sed -i "s/^cua:x:$old_uid:$old_gid:/cua:x:$uid:$gid:/" /etc/passwd',' sed -i "s/^cua:x:$old_gid:/cua:x:$gid:/" /etc/group',' [ "$(id -u cua):$(id -g cua)\
1505
1505
  " = "$uid:$gid" ] || { echo "cua did not take uid $uid gid $gid" >&2; exit 1; }',"fi",`exec ${SUPERVISORD}`].join(`
1506
1506
  `);import{existsSync as existsSync4}from"node:fs";import{dirname as dirname3,join as join6}from"node:path";import{fileURLToPath}from"node:url";var SERVER_ROOT=dirname3(fileURLToPath(import.meta.url));function resolveProxy(relative5){let source=join6(SERVER_ROOT,`${relative5}.ts`);return existsSync4(source)?source:join6(SERVER_ROOT,`${relative5}.js`)}var SPAWNED_PROXIES={harnessMcp:resolveProxy("harness-mcp-proxy"),localComputer:resolveProxy("local-computer-proxy"),permission:resolveProxy("permissio\
1507
1507
  n-proxy"),containerMcp:resolveProxy("container-mcp"),vpsContainerMcp:resolveProxy("vps-container-mcp"),agents:resolveProxy("drivers/agents-proxy"),dweb:resolveProxy("drivers/dweb-proxy"),connectors:resolveProxy("connector-proxy"),mcpGate:resolveProxy("mcp-gate"),mcpRemote:resolveProxy("mcp-remote-proxy"),phone:resolveProxy("drivers/phone-proxy"),chatgptPlanToken:resolveProxy("drivers/chatgpt-plan-token-command"),hook:resolveProxy("hooks/omb-hook"),piMcpExtension:resolveProxy("drivers/pi-mcp-exte\