windows-development-sandbox 1.27.1 → 1.28.0

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 (121) hide show
  1. package/dist/app/context.d.ts +5 -0
  2. package/dist/app/context.js +13 -0
  3. package/dist/app/features/accounts/accounts.def.d.ts +16 -0
  4. package/dist/app/features/accounts/accounts.run.d.ts +4 -0
  5. package/dist/app/features/accounts/services.def.d.ts +15 -1
  6. package/dist/app/features/accounts/services.def.js +67 -31
  7. package/dist/app/features/accounts/services.run.d.ts +7 -2
  8. package/dist/app/features/accounts/services.run.js +25 -6
  9. package/dist/app/features/defs.d.ts +17 -0
  10. package/dist/app/registry.d.ts +1 -1
  11. package/dist/app/registry.js +15 -2
  12. package/dist/bin/agent-sandbox.js +2 -2
  13. package/dist/bin/{chunk-RSIX7C6D.js → chunk-CB44HTTN.js} +444 -175
  14. package/dist/bin/{chunk-4TLSWPG7.js → chunk-UZ5S3EMB.js} +1 -1
  15. package/dist/bin/{chunk-QUHNXHVG.js → chunk-ZMZI3625.js} +46 -41
  16. package/dist/bin/claude-host.js +2 -2
  17. package/dist/bin/claude-sbx.js +2 -2
  18. package/dist/bin/codex-sbx.js +2 -2
  19. package/dist/bin/gemini-sbx.js +2 -2
  20. package/dist/bin/sandbox.js +2 -2
  21. package/dist/bin/sbx-hide.js +2 -2
  22. package/dist/bin/sbx-show.js +2 -2
  23. package/dist/cli/menu/menu.js +6 -1
  24. package/dist/cli/menu/pages/accounts-page.js +9 -5
  25. package/dist/core/schema/sandbox.js +1 -1
  26. package/dist/guest/apps/app-installer.js +7 -5
  27. package/dist/guest/apps/comet-unpack.js +2 -2
  28. package/dist/guest/daemon/heartbeat.js +1 -0
  29. package/dist/guest/governor/core.d.ts +53 -1
  30. package/dist/guest/governor/core.js +95 -1
  31. package/dist/guest/governor/decide.d.ts +4 -0
  32. package/dist/guest/governor/decide.js +2 -0
  33. package/dist/guest/governor/governor.js +23 -9
  34. package/dist/guest/runtime/pools.d.ts +4 -4
  35. package/dist/guest/runtime/pools.js +4 -15
  36. package/dist/guest/runtime/process.d.ts +5 -2
  37. package/dist/guest/runtime/process.js +23 -3
  38. package/dist/guest/toolchains/engines/epic-launcher.d.ts +6 -0
  39. package/dist/guest/toolchains/engines/epic-launcher.js +19 -1
  40. package/dist/guest/toolchains/engines/unreal-engines.js +2 -1
  41. package/dist/guest/toolchains/installers.d.ts +3 -3
  42. package/dist/guest/toolchains/installers.js +5 -5
  43. package/dist/guest/toolchains/native/unreal.js +22 -3
  44. package/dist/guest/toolchains/native/vcruntime.js +2 -2
  45. package/dist/guest/toolchains/native/vs-persist.d.ts +2 -2
  46. package/dist/guest/toolchains/runtimes.js +7 -6
  47. package/dist/guest/toolchains/signature.d.ts +2 -0
  48. package/dist/guest/toolchains/signature.js +9 -2
  49. package/dist/guest/toolchains/step-scheduler.js +1 -1
  50. package/dist/host/accounts/deliver.js +15 -7
  51. package/dist/host/life/crash-report.d.ts +4 -0
  52. package/dist/host/life/crash-report.js +30 -1
  53. package/dist/host/life/last-end.js +1 -0
  54. package/dist/host/pc-installs/discover.js +5 -2
  55. package/dist/host/pc-installs/unreal.d.ts +3 -1
  56. package/dist/host/pc-installs/unreal.js +27 -1
  57. package/dist/host/tools/windows-terminal.d.ts +4 -1
  58. package/dist/host/tools/windows-terminal.js +25 -9
  59. package/dist/runtime/agent.js +39 -23
  60. package/dist/runtime/daemon.js +279 -121
  61. package/dist/runtime/db.js +37 -17
  62. package/dist/runtime/main.js +340 -109
  63. package/dist/runtime/netproxy.js +31 -13
  64. package/dist/runtime/tool.js +37 -16
  65. package/dist/runtime/view.js +150 -38
  66. package/dist/selftest/agent-paths.test.js +3 -1
  67. package/dist/selftest/app.test.js +20 -2
  68. package/dist/selftest/boot-runner.test.js +15 -1
  69. package/dist/selftest/channel.test.js +33 -0
  70. package/dist/selftest/engines.test.js +22 -1
  71. package/dist/selftest/heavy-load.test.js +116 -4
  72. package/dist/selftest/live-terminal.test.js +103 -0
  73. package/dist/selftest/menu-screens.js +52 -1
  74. package/dist/selftest/menu.test.js +29 -3
  75. package/dist/selftest/personalization.test.js +2 -1
  76. package/dist/selftest/service-accounts.test.js +77 -2
  77. package/dist/selftest/support/engine-golden.js +2 -0
  78. package/dist/selftest/ui-text.test.js +4 -0
  79. package/dist/shared/accounts/kinds.js +9 -9
  80. package/dist/shared/apps/catalogue-gamedev.js +1 -0
  81. package/dist/shared/apps/catalogue.d.ts +2 -0
  82. package/dist/shared/channel/schema.d.ts +2 -0
  83. package/dist/shared/channel/schema.js +4 -0
  84. package/dist/shared/concurrency/pools.js +1 -1
  85. package/dist/shared/download/archive.js +4 -2
  86. package/dist/shared/download/index.d.ts +1 -1
  87. package/dist/shared/download/index.js +1 -1
  88. package/dist/shared/download/spawn.d.ts +7 -1
  89. package/dist/shared/download/spawn.js +16 -1
  90. package/dist/shared/memory/index.d.ts +1 -0
  91. package/dist/shared/memory/index.js +1 -0
  92. package/dist/shared/memory/policy.d.ts +12 -0
  93. package/dist/shared/memory/policy.js +4 -0
  94. package/dist/shared/memory/unreal-build.d.ts +2 -0
  95. package/dist/shared/memory/unreal-build.js +21 -0
  96. package/dist/shared/paths/pc-installs.d.ts +8 -0
  97. package/dist/shared/pty/clipboard-watch.d.ts +4 -0
  98. package/dist/shared/pty/clipboard-watch.js +40 -0
  99. package/dist/shared/pty/ctrl-c.d.ts +13 -7
  100. package/dist/shared/pty/ctrl-c.js +35 -19
  101. package/dist/shared/pty/index.d.ts +1 -0
  102. package/dist/shared/pty/index.js +1 -0
  103. package/dist/shared/pty/terminal.d.ts +1 -1
  104. package/dist/shared/pty/terminal.js +16 -13
  105. package/dist/shared/unreal/launcher-files.d.ts +7 -0
  106. package/dist/shared/unreal/launcher-files.js +32 -1
  107. package/dist/shared/web/ctrl-c.d.ts +26 -0
  108. package/dist/shared/web/ctrl-c.js +64 -0
  109. package/dist/shared/web/index.d.ts +1 -0
  110. package/dist/shared/web/index.js +1 -0
  111. package/dist/web/index.html +1 -1
  112. package/dist/web/{main-VPMYTSUL.js → main-7NY4X6YU.js} +67 -67
  113. package/native/csharp/HcsHost/AssemblyInfo.cs +3 -3
  114. package/native/csharp/HostTools/AssemblyInfo.cs +3 -3
  115. package/native/csharp/StorageHelper/AssemblyInfo.cs +3 -3
  116. package/package.json +1 -1
  117. package/sandbox/csharp/ClipboardWatch.cs +59 -0
  118. package/sandbox/csharp/MemGov.cs +752 -7
  119. package/sandbox/scripts/watch-clipboard.ps1 +8 -0
  120. package/schemas/config.schema.json +10 -10
  121. package/schemas/sandbox-config.schema.json +9 -9
@@ -5743,7 +5743,7 @@ var OutputFilter = class {
5743
5743
  }
5744
5744
  };
5745
5745
 
5746
- // src/shared/pty/console-input.ts
5746
+ // src/shared/pty/clipboard-watch.ts
5747
5747
  import { spawn } from "node:child_process";
5748
5748
 
5749
5749
  // src/shared/system.ts
@@ -5796,7 +5796,36 @@ function scriptArgs(name, args = []) {
5796
5796
  ];
5797
5797
  }
5798
5798
 
5799
+ // src/shared/pty/clipboard-watch.ts
5800
+ var MAX_PENDING = 1024;
5801
+ function watchClipboard(onChange) {
5802
+ if (process.platform !== "win32") return { stop: () => void 0 };
5803
+ let child = null;
5804
+ try {
5805
+ child = spawn(SYSTEM.powershell(), scriptArgs("watch-clipboard.ps1", ["-ProcessId", String(process.pid)]), {
5806
+ stdio: ["ignore", "pipe", "ignore"],
5807
+ windowsHide: true
5808
+ });
5809
+ } catch {
5810
+ return { stop: () => void 0 };
5811
+ }
5812
+ let pending = "";
5813
+ child.stdout?.setEncoding("latin1");
5814
+ child.stdout?.on("data", (text) => {
5815
+ const lines = (pending + text).split("\n");
5816
+ pending = (lines.pop() ?? "").slice(-MAX_PENDING);
5817
+ for (const line of lines) if (line.trim() === "changed") onChange();
5818
+ });
5819
+ child.on("error", () => void 0);
5820
+ return {
5821
+ stop: () => {
5822
+ if (child && child.exitCode === null && child.signalCode === null) child.kill();
5823
+ }
5824
+ };
5825
+ }
5826
+
5799
5827
  // src/shared/pty/console-input.ts
5828
+ import { spawn as spawn2 } from "node:child_process";
5800
5829
  function enableVtInput() {
5801
5830
  if (process.platform !== "win32" || !process.stdin.isTTY)
5802
5831
  return { ready: Promise.resolve(false), stop: () => Promise.resolve() };
@@ -5804,7 +5833,7 @@ function enableVtInput() {
5804
5833
  let exited = Promise.resolve();
5805
5834
  const ready = new Promise((resolve) => {
5806
5835
  try {
5807
- child = spawn(SYSTEM.powershell(), scriptArgs("enable-vt-input.ps1", ["-ProcessId", String(process.pid)]), {
5836
+ child = spawn2(SYSTEM.powershell(), scriptArgs("enable-vt-input.ps1", ["-ProcessId", String(process.pid)]), {
5808
5837
  stdio: "ignore",
5809
5838
  windowsHide: true
5810
5839
  });
@@ -5863,30 +5892,94 @@ function unfinishedSequence(data) {
5863
5892
  return data.length;
5864
5893
  }
5865
5894
 
5866
- // src/shared/pty/ctrl-c.ts
5895
+ // src/shared/web/protocol.ts
5896
+ var MAX_CLIENT_MESSAGE_BYTES = 256 * 1024;
5897
+
5898
+ // src/shared/web/ctrl-c.ts
5867
5899
  var CTRL_C_CONFIRM_MS = 1500;
5868
5900
  var CTRL_C_HINT = "Ctrl+C again to send it to the program (Esc stops an agent)";
5869
- var OSC_TITLE = /\x1b\][02];([^\x07\x1b]{0,256})(?:\x07|\x1b\\)/g;
5870
- var CtrlCGuard = class {
5901
+ var CTRL_C_COPY_HINT = "Copied: Ctrl+C after selecting text is not sent to the program (Esc stops an agent)";
5902
+ var CtrlCDecider = class {
5903
+ constructor(confirm = true) {
5904
+ this.confirm = confirm;
5905
+ }
5906
+ confirm;
5871
5907
  armedAt = Number.NEGATIVE_INFINITY;
5872
- lastTitle = "";
5873
- /** What to send for one read from the keyboard: a lone Ctrl+C only when another came just before. */
5874
- push(chunk, nowMs) {
5875
- if (chunk.length !== 1 || chunk[0] !== 3) return { send: chunk, held: false };
5908
+ selected = false;
5909
+ /** Text was selected in the program: Ctrl+C is "copy" from now on. */
5910
+ selection() {
5911
+ this.selected = true;
5912
+ this.armedAt = Number.NEGATIVE_INFINITY;
5913
+ }
5914
+ /** Any other key or a click: Ctrl+C is an interrupt again. */
5915
+ otherInput() {
5916
+ this.selected = false;
5917
+ }
5918
+ /** What to do with a lone Ctrl+C pressed at `nowMs`. */
5919
+ ctrlC(nowMs) {
5920
+ if (this.selected) return "copy";
5921
+ if (!this.confirm) return "send";
5876
5922
  if (nowMs - this.armedAt <= CTRL_C_CONFIRM_MS) {
5877
5923
  this.armedAt = Number.NEGATIVE_INFINITY;
5878
- return { send: chunk, held: false };
5924
+ return "send";
5879
5925
  }
5880
5926
  this.armedAt = nowMs;
5881
- return { send: Buffer.alloc(0), held: true };
5927
+ return "hold";
5928
+ }
5929
+ };
5930
+ var MOUSE_REPORT = /\x1b\[<(\d{1,4});\d{1,5};\d{1,5}([Mm])|\x1b\[M([\s\S])[\s\S]{2}/g;
5931
+ function classifyInput(text) {
5932
+ let drag = false;
5933
+ let click = false;
5934
+ for (const m of text.matchAll(MOUSE_REPORT)) {
5935
+ const sgr = m[1] !== void 0;
5936
+ const b = sgr ? Number(m[1]) : (m[3] ?? " ").charCodeAt(0) - 32;
5937
+ if (b & 64) continue;
5938
+ if (b & 32) {
5939
+ if ((b & 3) !== 3) drag = true;
5940
+ } else if (sgr ? m[2] === "M" : (b & 3) !== 3) click = true;
5941
+ }
5942
+ return { mouse: drag ? "drag" : click ? "click" : null, keys: text.replace(MOUSE_REPORT, "").length > 0 };
5943
+ }
5944
+ function hasClipboardWrite(text) {
5945
+ return /\x1b\]0{0,2}52;/.test(text) || /\u009d0{0,2}52;/.test(text);
5946
+ }
5947
+
5948
+ // src/shared/pty/ctrl-c.ts
5949
+ var OSC_TITLE = /\x1b\][02];([^\x07\x1b]{0,256})(?:\x07|\x1b\\)/g;
5950
+ var CtrlCGuard = class {
5951
+ decider;
5952
+ lastTitle = "";
5953
+ constructor(options = {}) {
5954
+ this.decider = new CtrlCDecider(options.confirm !== false);
5955
+ }
5956
+ /** What to send for one read from the keyboard: a lone Ctrl+C only when it is not held back or taken as "copy". */
5957
+ push(chunk, nowMs) {
5958
+ if (chunk.length === 1 && chunk[0] === 3) {
5959
+ const action = this.decider.ctrlC(nowMs);
5960
+ if (action === "send") return { send: chunk, held: false, copied: false };
5961
+ return { send: Buffer.alloc(0), held: action === "hold", copied: action === "copy" };
5962
+ }
5963
+ const c = classifyInput(chunk.toString("latin1"));
5964
+ if (c.keys || c.mouse === "click") this.decider.otherInput();
5965
+ else if (c.mouse === "drag") this.decider.selection();
5966
+ return { send: chunk, held: false, copied: false };
5967
+ }
5968
+ /** The clipboard changed since the last key: you just copied. */
5969
+ clipboardChanged() {
5970
+ this.decider.selection();
5971
+ }
5972
+ /** The program wrote to the clipboard: that is a selection too. */
5973
+ watchClipboard(raw) {
5974
+ if (hasClipboardWrite(raw)) this.decider.selection();
5882
5975
  }
5883
5976
  /** Remembers the title the program last set (from its output), to put it back after the hint. */
5884
5977
  watchOutput(text) {
5885
5978
  for (const m of text.matchAll(OSC_TITLE)) this.lastTitle = m[1];
5886
5979
  }
5887
5980
  /** The escape sequence that shows the hint, and the one that puts the program's title back. */
5888
- hintTitle() {
5889
- return "\x1B]0;" + CTRL_C_HINT + "\x07";
5981
+ hintTitle(kind = "hold") {
5982
+ return "\x1B]0;" + (kind === "copy" ? CTRL_C_COPY_HINT : CTRL_C_HINT) + "\x07";
5890
5983
  }
5891
5984
  restoreTitle() {
5892
5985
  return "\x1B]0;" + this.lastTitle.replace(/[\x00-\x1f\x7f]/g, "") + "\x07";
@@ -6090,6 +6183,7 @@ function runTerminalClient(socket, token, options = {}) {
6090
6183
  clearTimeout(joinTimer);
6091
6184
  clearTimeout(hintTimer);
6092
6185
  clearTimeout(vtTimer);
6186
+ clipboard.stop();
6093
6187
  socket.destroy();
6094
6188
  const tracked = mouse.tracking();
6095
6189
  const reset = "\x1B[0m\x1B[?25h" + MOUSE_OFF + (mouse.has(2004) ? "\x1B[?2004l" : "") + "\r\n";
@@ -6107,23 +6201,22 @@ function runTerminalClient(socket, token, options = {}) {
6107
6201
  if (data.length && !done) socket.write(encodeFrame(FrameType.Input, data));
6108
6202
  };
6109
6203
  const sendInput = (data) => write(keys.push(passthrough ? mouse.filter(data) : data));
6110
- const guard = options.confirmCtrlC ? new CtrlCGuard() : null;
6204
+ const guard = new CtrlCGuard({ confirm: options.confirmCtrlC !== false });
6111
6205
  let hintTimer;
6206
+ const clipboard = watchClipboard(() => guard.clipboardChanged());
6112
6207
  const onInput = (chunk) => {
6113
6208
  if (options.detachKey !== void 0 && chunk.includes(options.detachKey)) {
6114
6209
  finish({ reason: "detach" });
6115
6210
  return;
6116
6211
  }
6117
- if (guard) {
6118
- const decided = guard.push(chunk, Date.now());
6119
- clearTimeout(hintTimer);
6120
- if (decided.held) {
6121
- stdout.write(guard.hintTitle());
6122
- hintTimer = setTimeout(() => stdout.write(guard.restoreTitle()), CTRL_C_CONFIRM_MS);
6123
- return;
6124
- }
6125
- if (decided.send.length === 1 && decided.send[0] === 3) stdout.write(guard.restoreTitle());
6212
+ const decided = guard.push(chunk, Date.now());
6213
+ clearTimeout(hintTimer);
6214
+ if (decided.held || decided.copied) {
6215
+ stdout.write(guard.hintTitle(decided.copied ? "copy" : "hold"));
6216
+ hintTimer = setTimeout(() => stdout.write(guard.restoreTitle()), CTRL_C_CONFIRM_MS);
6217
+ return;
6126
6218
  }
6219
+ if (decided.send.length === 1 && decided.send[0] === 3) stdout.write(guard.restoreTitle());
6127
6220
  clearTimeout(joinTimer);
6128
6221
  sendInput(joiner.push(chunk));
6129
6222
  if (joiner.holding()) joinTimer = setTimeout(() => sendInput(joiner.flush()), JOIN_MS);
@@ -6156,9 +6249,10 @@ function runTerminalClient(socket, token, options = {}) {
6156
6249
  }
6157
6250
  for (const frame of frames) {
6158
6251
  if (frame.type === FrameType.Output) {
6252
+ guard.watchClipboard(frame.payload.toString("latin1"));
6159
6253
  const out = filter.push(frame.payload);
6160
6254
  mouse.watch(out);
6161
- guard?.watchOutput(out.toString("latin1"));
6255
+ guard.watchOutput(out.toString("latin1"));
6162
6256
  stdout.write(out);
6163
6257
  } else if (frame.type === FrameType.Console) passthrough = frame.payload.toString("latin1") === "conpty.dll";
6164
6258
  else if (frame.type === FrameType.Restarting) {
@@ -26106,7 +26200,7 @@ var SandboxSchema = external_exports.strictObject({
26106
26200
  'The last resort that keeps the sandbox up, in MB below its commit limit (RAM plus paging file): builds are slowed down long before (sandbox.pressureResponse); only if everything the agents start together would take the sandbox to the very edge of its memory, where Windows inside it would start failing, is a build refused memory instead of Windows. "auto" = the larger of 1536 MB and 3 % of the commit limit; "none" = no backstop. Yours only: a project file cannot change it.'
26107
26201
  ),
26108
26202
  pressureResponse: external_exports.boolean().describe(
26109
- "When the sandbox (or this PC) runs low on memory, slow builds down in steps, like a PC that gets slower instead of failing: build programs get lower CPU and memory priority, then less CPU, then compilers take turns (the waiting ones briefly suspended and trimmed to the paging file). Nothing is stopped or killed, and the agents themselves are never touched. Yours only: a project file cannot change it."
26203
+ "When the sandbox (or this PC) runs low on memory, slow builds down in steps, like a PC that gets slower instead of failing: build programs get lower CPU and memory priority, then less CPU, then compilers take turns (the waiting ones briefly suspended and trimmed to the paging file). Nothing is stopped or killed, and the agents themselves are never touched. A memory gate also holds new compilers and linkers for a moment when the memory of the build programs grows faster than 4 GB in 3 seconds (3 GB with vGPU), and lets them go one at a time. Yours only: a project file cannot change it."
26110
26204
  ),
26111
26205
  vGpu: external_exports.boolean().describe(
26112
26206
  "Virtual GPU. Off by default: Microsoft notes it widens the sandbox attack surface. The sandbox then uses this PC's graphics card, and with some graphics drivers heavy use can freeze the whole PC: turn it on only when a program in the sandbox needs the GPU (the mesa toolchain gives software OpenGL without it). Browsers in the sandbox never use it (they draw in software)."
@@ -26697,6 +26791,7 @@ var GAMEDEV_APPS = [
26697
26791
  size: "100 MB",
26698
26792
  source: { github: "f3d-app/f3d", asset: "^F3D-[\\d.]+-Windows-x86_64\\.zip$" },
26699
26793
  exe: "f3d.exe",
26794
+ onPath: true,
26700
26795
  needs: ["mesa"]
26701
26796
  },
26702
26797
  {
@@ -27796,7 +27891,7 @@ var SERVICE_SPECS = {
27796
27891
  },
27797
27892
  steam: {
27798
27893
  kind: "steam",
27799
- label: "Steam (SteamCMD)",
27894
+ label: "Steam",
27800
27895
  usedBy: ["steam"],
27801
27896
  sources: ["file", "sandbox"],
27802
27897
  singleHolder: true,
@@ -27832,7 +27927,7 @@ var SERVICE_SPECS = {
27832
27927
  },
27833
27928
  cfx: {
27834
27929
  kind: "cfx",
27835
- label: "Cfx.re (FiveM / RedM server key)",
27930
+ label: "FiveM key",
27836
27931
  usedBy: ["fivem"],
27837
27932
  sources: ["typed", "file"],
27838
27933
  singleHolder: false,
@@ -27861,7 +27956,7 @@ var SERVICE_SPECS = {
27861
27956
  },
27862
27957
  keystore: {
27863
27958
  kind: "keystore",
27864
- label: "Android upload keystore",
27959
+ label: "Android keystore",
27865
27960
  usedBy: ["android"],
27866
27961
  sources: ["file"],
27867
27962
  singleHolder: false,
@@ -27876,7 +27971,7 @@ var SERVICE_SPECS = {
27876
27971
  },
27877
27972
  play: {
27878
27973
  kind: "play",
27879
- label: "Google Play (service account)",
27974
+ label: "Google Play",
27880
27975
  usedBy: ["android"],
27881
27976
  sources: ["file"],
27882
27977
  singleHolder: false,
@@ -27887,7 +27982,7 @@ var SERVICE_SPECS = {
27887
27982
  },
27888
27983
  expo: {
27889
27984
  kind: "expo",
27890
- label: "Expo (EAS)",
27985
+ label: "Expo",
27891
27986
  usedBy: ["reactNative"],
27892
27987
  sources: ["typed"],
27893
27988
  singleHolder: false,
@@ -27898,7 +27993,7 @@ var SERVICE_SPECS = {
27898
27993
  },
27899
27994
  appstore: {
27900
27995
  kind: "appstore",
27901
- label: "App Store Connect API key",
27996
+ label: "App Store Connect",
27902
27997
  usedBy: ["reactNative", "flutter"],
27903
27998
  sources: ["file", "typed"],
27904
27999
  singleHolder: false,
@@ -27912,7 +28007,7 @@ var SERVICE_SPECS = {
27912
28007
  },
27913
28008
  perplexity: {
27914
28009
  kind: "perplexity",
27915
- label: "Perplexity API key",
28010
+ label: "Perplexity API",
27916
28011
  usedBy: ["perplexity"],
27917
28012
  sources: ["pc", "file", "typed"],
27918
28013
  singleHolder: false,
@@ -27936,7 +28031,7 @@ var SERVICE_SPECS = {
27936
28031
  },
27937
28032
  comet: {
27938
28033
  kind: "comet",
27939
- label: "Comet (Perplexity browser)",
28034
+ label: "Comet",
27940
28035
  usedBy: ["comet"],
27941
28036
  sources: ["sandbox"],
27942
28037
  singleHolder: false,
@@ -27952,7 +28047,7 @@ var SERVICE_SPECS = {
27952
28047
  },
27953
28048
  perplexityapp: {
27954
28049
  kind: "perplexityapp",
27955
- label: "Perplexity desktop app",
28050
+ label: "Perplexity app",
27956
28051
  usedBy: ["perplexityapp"],
27957
28052
  sources: ["sandbox"],
27958
28053
  singleHolder: false,
@@ -28303,6 +28398,8 @@ var PressureStatusSchema = external_exports.object({
28303
28398
  lowered: external_exports.number().int().min(0).max(1024),
28304
28399
  /** Compilers waiting their turn right now (name, process id, seconds until they may go on). */
28305
28400
  paused: external_exports.array(external_exports.object({ name: Text(64), pid: external_exports.number().int(), seconds: external_exports.number().int().min(0).max(60) })).max(8),
28401
+ /** Build programs the memory gate holds right now (let go one at a time). */
28402
+ held: external_exports.number().int().min(0).max(1024).optional(),
28306
28403
  /** The CPU share the compilers get together (percent; 100 = no cap). */
28307
28404
  cpuPercent: external_exports.number().int().min(0).max(100).optional(),
28308
28405
  /** The PC itself asked for slowing down (its memory or CPU is low). */
@@ -28323,6 +28420,8 @@ var HeartbeatSchema = external_exports.object({
28323
28420
  topProcesses: external_exports.array(external_exports.object({ name: Text(64), privateMb: external_exports.number().int().min(0).max(1e7) })).max(5),
28324
28421
  /** The disk queue this PC last reported while asking the sandbox to slow down. */
28325
28422
  diskQueueReported: external_exports.number().min(0).max(1e5).optional(),
28423
+ /** Build programs the memory gate holds right now (let go one at a time). */
28424
+ held: external_exports.number().int().min(0).max(1024).optional(),
28326
28425
  /** "ending": the sandbox is shutting down in order (idle shutdown, sandbox stop, Windows shutting down). */
28327
28426
  phase: external_exports.enum(["ready", "working", "ending"])
28328
28427
  });
@@ -28650,10 +28749,20 @@ import path7 from "node:path";
28650
28749
  import crypto from "node:crypto";
28651
28750
 
28652
28751
  // src/shared/download/spawn.ts
28653
- import { spawn as spawn2 } from "node:child_process";
28752
+ import os3 from "node:os";
28753
+ import { spawn as spawn3 } from "node:child_process";
28754
+ function lowerPriority(pid) {
28755
+ if (pid === void 0) return;
28756
+ try {
28757
+ os3.setPriority(pid, os3.constants.priority.PRIORITY_BELOW_NORMAL);
28758
+ } catch {
28759
+ }
28760
+ }
28654
28761
  function spawnAsync(file2, args, options = {}) {
28762
+ const { lowPriority, ...spawnOptions } = options;
28655
28763
  return new Promise((resolve, reject) => {
28656
- const child = spawn2(file2, args, { stdio: "ignore", windowsHide: true, ...options });
28764
+ const child = spawn3(file2, args, { stdio: "ignore", windowsHide: true, ...spawnOptions });
28765
+ if (lowPriority) lowerPriority(child.pid);
28657
28766
  child.once("error", reject);
28658
28767
  child.once("close", (code) => resolve(code ?? -1));
28659
28768
  });
@@ -28674,13 +28783,16 @@ function extractArchive(archive, destination, members2 = []) {
28674
28783
  }
28675
28784
  async function extract(archive, destination, members2) {
28676
28785
  fs6.mkdirSync(destination, { recursive: true });
28677
- let status = await spawnAsync(SYSTEM.tar(), ["-xf", archive, "-C", destination, ...members2]);
28786
+ let status = await spawnAsync(SYSTEM.tar(), ["-xf", archive, "-C", destination, ...members2], {
28787
+ lowPriority: true
28788
+ });
28678
28789
  if (status !== 0 && /\.(zip|nupkg)$/i.test(archive)) {
28679
28790
  const zip = archive.endsWith(".zip") ? archive : archive + ".zip";
28680
28791
  if (zip !== archive) fs6.copyFileSync(archive, zip);
28681
28792
  status = await spawnAsync(
28682
28793
  SYSTEM.powershell(),
28683
- scriptArgs("expand-archive.ps1", ["-Archive", zip, "-Destination", destination])
28794
+ scriptArgs("expand-archive.ps1", ["-Archive", zip, "-Destination", destination]),
28795
+ { lowPriority: true }
28684
28796
  );
28685
28797
  }
28686
28798
  if (status !== 0) throw new Error("Could not extract " + archive);
@@ -7,7 +7,7 @@ import { isWin } from '../core/util/index.js';
7
7
  import { SYSTEM } from '../shared/system.js';
8
8
  import { agentCommand, agentShims, bootResetPaths, isCopyableDatabaseFile, isDatabaseFile, localStateEntries, shimText, } from '../guest/agents/agent-files.js';
9
9
  import { appendMissing, expandVars, installedToolPaths, isGitUsrBin, isMsvcToolsDir, isPinnedNodeDir, msvcBeforeGitUsr, parseRegPath, pathKey, planPath, rebuildPath, sessionPath, splitPath, } from '../guest/setup/path-plan.js';
10
- import { withReloadEnvironment } from '../host/tools/index.js';
10
+ import { withCopyOnSelect, withReloadEnvironment } from '../host/tools/index.js';
11
11
  import { HarnessSchema } from '../core/schema/index.js';
12
12
  export const agentPathsSuite = {
13
13
  name: 'agent-paths',
@@ -136,6 +136,8 @@ export const agentPathsSuite = {
136
136
  t.section('Windows Terminal reloads the environment');
137
137
  t.equal(withReloadEnvironment({ compatibility: { reloadEnvironmentVariables: true } }), null, 'already set: unchanged');
138
138
  t.equal(withReloadEnvironment({ theme: 'dark', compatibility: { other: 1 } })?.compatibility, { other: 1, reloadEnvironmentVariables: true }, 'set without touching the rest of compatibility');
139
+ t.equal(withCopyOnSelect({ theme: 'dark' })?.copyOnSelect, true, 'copy on select is added when the key is missing');
140
+ t.equal(withCopyOnSelect({ copyOnSelect: false }), null, 'a copy-on-select value the user set stays');
139
141
  if (!isWin)
140
142
  return;
141
143
  t.section('shell start-up (pathsync.exe and the start-up files)');
@@ -7,13 +7,13 @@ import path from 'node:path';
7
7
  import { z } from 'zod';
8
8
  import { agentNameProblem, agentsPage, agentsView } from '../app/features/agents/index.js';
9
9
  import { DEFINITIONS, NAV, navSections, navViews, QUERIES, VIEWS, viewById } from '../app/features/defs.js';
10
- import { accountsPage, agentPage, listAccounts } from '../app/features/accounts/index.js';
10
+ import { accountsPage, agentPage, listAccounts, listServices, } from '../app/features/accounts/index.js';
11
11
  import { addProject, projectRoots, projectsPage } from '../app/features/projects/index.js';
12
12
  import { cleanData, dataPage, showData } from '../app/features/data/index.js';
13
13
  import { showStorage, storagePage, storageView, } from '../app/features/storage/index.js';
14
14
  import { insideSandbox, isSandboxRunning } from '../host/sandbox/index.js';
15
15
  import { CRASH, listLogs, logsPage, tailLog } from '../app/features/logs/index.js';
16
- import { DEFAULTS } from '../core/config/index.js';
16
+ import { DEFAULTS, loadConfig } from '../core/config/index.js';
17
17
  import { sandboxPage } from '../app/features/sandbox/index.js';
18
18
  import { closeSession, sessionsPage, startShell, } from '../app/features/sessions/index.js';
19
19
  import { APP_GROUPS, appsPage, listApps } from '../app/features/apps/index.js';
@@ -460,6 +460,24 @@ export const appSuite = {
460
460
  storageRoot: t.at('app-apps', 'storage'),
461
461
  dataPath: t.dir('app-apps', 'data'),
462
462
  };
463
+ t.section('a page read after an action shows what the action saved');
464
+ const freshConfig = t.writeJson(t.at('app-fresh', 'config.json'), {
465
+ storage: { root: t.dir('app-fresh', 'storage') },
466
+ });
467
+ const freshCtx = {
468
+ loaded: loadConfig(freshConfig),
469
+ options: {},
470
+ storageRoot: t.at('app-fresh', 'storage'),
471
+ dataPath: t.dir('app-fresh', 'data'),
472
+ };
473
+ const shareOf = async () => (await readQuery(listServices, freshCtx, { name: 'comet' })).services[0]?.share;
474
+ t.check((await shareOf()) === false, 'a service starts not shared');
475
+ await runDefinition('settings.set', freshCtx, { scope: 'user', key: 'accounts.comet.share', value: true }, quiet);
476
+ t.check((await shareOf()) === true, 'after the share toggle runs, the service page reads it as shared');
477
+ await runDefinition('settings.set', freshCtx, { scope: 'user', key: 'accounts.comet.share', value: false }, quiet);
478
+ t.check((await shareOf()) === false, 'and as not shared again after the next toggle');
479
+ await runDefinition('apps.toggle', freshCtx, { id: 'perplexity-desktop', on: true }, quiet);
480
+ t.check(freshCtx.loaded.config.apps.install.includes('perplexity-desktop'), 'an app turned on in Apps is in the settings every page reads next');
463
481
  await runDefinition('apps.toggle', appsCtx, { id: 'lazygit', on: true }, quiet);
464
482
  const onText = fs.readFileSync(appsConfig, 'utf8');
465
483
  await runDefinition('apps.toggle', appsCtx, { id: 'lazygit', on: false }, quiet);
@@ -4,7 +4,9 @@ import { BootRunner, checkGraph, duration } from '../guest/boot/runner.js';
4
4
  import { BOOT_TASKS, STAGES, stageTitle } from '../guest/boot/graph.js';
5
5
  import { backgroundNames, mergeParts, runSplit } from '../guest/toolchains/split.js';
6
6
  import { StepScheduler } from '../guest/toolchains/step-scheduler.js';
7
- import { Limiter, asBackground, installerRetry, INSTALLER_RETRIES } from '../shared/concurrency/index.js';
7
+ import os from 'node:os';
8
+ import { Limiter, asBackground, installerRetry, INSTALLER_RETRIES, net, heavy, installer, } from '../shared/concurrency/index.js';
9
+ import { spawnAsync } from '../shared/download/index.js';
8
10
  const deferred = () => {
9
11
  let resolve = () => undefined;
10
12
  let reject = (_) => undefined;
@@ -288,6 +290,18 @@ export const bootRunnerSuite = {
288
290
  t.check(message.includes('nested pool') && again.includes('nested pool'), 'taking a second pool (or the same one) while holding one throws "nested pool"', message);
289
291
  t.check((await a.run(() => 7)) === 7 && a.running === 0, 'the slot is free again after a nested-pool error');
290
292
  }
293
+ {
294
+ // At most 3 downloads + 2 unpacks + 1 installer run at once, whatever the boot tasks, steps and apps ask for.
295
+ const busy = async (pool) => {
296
+ await Promise.all(Array.from({ length: 12 }, () => pool.run(() => sleep(5))));
297
+ return pool.peak;
298
+ };
299
+ t.check((await busy(net)) <= 3 && (await busy(heavy)) <= 2 && (await busy(installer)) <= 1, 'the shared pools cap at net 3, heavy 2 and installer 1', 'net ' + net.peak + ', heavy ' + heavy.peak + ', installer ' + installer.peak);
300
+ const script = 'setTimeout(() => process.exit(require("os").getPriority() > 0 ? 0 : 3), 400)';
301
+ const low = await spawnAsync(process.execPath, ['-e', script], { lowPriority: true });
302
+ const normal = await spawnAsync(process.execPath, ['-e', script]);
303
+ t.check(low === 0 && normal === 3 && os.getPriority() <= 0, 'lowPriority starts a program below normal priority; the default stays normal', 'low ' + low + ', normal ' + normal);
304
+ }
291
305
  t.check(installerRetry(1618, 1) &&
292
306
  installerRetry(1618, INSTALLER_RETRIES) &&
293
307
  !installerRetry(1618, INSTALLER_RETRIES + 1) &&
@@ -4,6 +4,7 @@ import { safeId } from '../shared/channel/index.js';
4
4
  import { GuestRequestSchema, SandboxStatusSchema, SessionStatusSchema } from '../shared/channel/index.js';
5
5
  import { bootLine, firstStartNotice, pendingDownloads, readyIn, stillWorking } from '../cli/commands/launch/index.js';
6
6
  import { CTRL_C_CONFIRM_MS, CTRL_C_HINT, CtrlCGuard, encodeFrame, FrameReader, FrameType, fixWindowsKeys, helloFrame, InputJoiner, KeyGate, MAX_FRAME_BYTES, MOUSE_OFF, MouseModes, OutputFilter, } from '../shared/pty/index.js';
7
+ import { classifyInput } from '../shared/web/index.js';
7
8
  import { bootSilent, FIRST_STATUS_MS } from '../host/channel/index.js';
8
9
  export const channelSuite = {
9
10
  name: 'channel',
@@ -251,6 +252,38 @@ export const channelSuite = {
251
252
  !g.push(Buffer.from('x'), 6000).held, 'a lone Ctrl+C is held back, a second one soon after is sent, a late second one is held again, other input passes');
252
253
  g.watchOutput('\x1b]0;claude: working\x07more \x1b]2;\u0001evil\x07');
253
254
  t.check(g.hintTitle().includes(CTRL_C_HINT) && g.restoreTitle() === '\x1b]0;evil\x07', "the hint shows in the title, and the program's last title comes back without control characters");
255
+ const drag = Buffer.from('\x1b[<32;10;5M');
256
+ const release = Buffer.from('\x1b[<0;12;5m');
257
+ const copyG = new CtrlCGuard();
258
+ copyG.push(drag, 0);
259
+ copyG.push(release, 10);
260
+ const copies = [100, 200, 300].map((at) => copyG.push(ctrlC, at));
261
+ t.check(copies.every((c) => c.send.length === 0 && c.copied && !c.held), 'after a mouse drag in the program every Ctrl+C is copied and never sent, however often it is pressed');
262
+ copyG.push(Buffer.from('x'), 400);
263
+ t.check(copyG.push(ctrlC, 500).held, 'after another key a lone Ctrl+C is held back again');
264
+ const clickG = new CtrlCGuard();
265
+ clickG.push(drag, 0);
266
+ clickG.push(Buffer.from('\x1b[<0;3;3M'), 10);
267
+ t.check(clickG.push(ctrlC, 20).held, 'a mouse click after a drag ends copy mode');
268
+ const quietG = new CtrlCGuard();
269
+ quietG.push(Buffer.from('\x1b[<64;3;3M'), 0);
270
+ quietG.push(Buffer.from('\x1b[<35;3;3M'), 1);
271
+ t.check(quietG.push(ctrlC, 2).held, 'mouse wheel and hover reports do not start copy mode');
272
+ const clipG = new CtrlCGuard();
273
+ clipG.watchClipboard('\x1b]52;c;aGk=');
274
+ t.check(clipG.push(ctrlC, 0).copied, 'the program writing the clipboard (OSC 52) starts copy mode');
275
+ const copiedG = new CtrlCGuard();
276
+ copiedG.clipboardChanged();
277
+ const afterCopy = copiedG.push(ctrlC, 0);
278
+ copiedG.push(Buffer.from('x'), 1);
279
+ t.check(afterCopy.copied && !afterCopy.held && afterCopy.send.length === 0 && copiedG.push(ctrlC, 2).held, 'after the clipboard changed a lone Ctrl+C is copied (not sent, not held) until another key is pressed');
280
+ const noConfirm = new CtrlCGuard({ confirm: false });
281
+ const sentAtOnce = noConfirm.push(ctrlC, 0);
282
+ noConfirm.push(drag, 1);
283
+ t.check(sentAtOnce.send.equals(ctrlC) && noConfirm.push(ctrlC, 2).copied, 'without confirmation a lone Ctrl+C is sent at once, but after a drag it is still copied');
284
+ const x10 = classifyInput('\x1b[M' + String.fromCharCode(32 + 32) + '!!');
285
+ const arrow = classifyInput('\x1b[A');
286
+ t.check(x10.mouse === 'drag' && !x10.keys && arrow.mouse === null && arrow.keys, 'an X10 drag is a drag without keys, and an arrow key is a key without a mouse report');
254
287
  t.section('typed input keeps escape sequences whole');
255
288
  const joined = (...chunks) => {
256
289
  const j = new InputJoiner();
@@ -12,7 +12,7 @@ import { isWin } from '../core/util/index.js';
12
12
  import { ConfigSchema } from '../core/schema/index.js';
13
13
  import { decodeText, encodeText, readBoundedFile } from '../shared/io/index.js';
14
14
  import { SYSTEM } from '../shared/system.js';
15
- import { chooseEngine, ddcVars, enginePlaceProblem, ENGINE_NEED_BYTES, engineAt, engineExtraDirs, engineToolDirs, engineVars, entriesUnder, fileAssociationPlan, findEngines, findUproject, hasMcpPlugin, incompleteDirs, isBuildId, installLocationOf, itemSizes, launcherEntriesFor, launcherEntry, launcherInstallations, mergeLauncherInstalled, parseBuildVersion, parseEngineAssociation, preferredInstalled, registryPlan, restoreItems, saveItems, setLauncherInstallLocation, stableBuildId, UNREAL_STATUS_FILE, unrealGuideLines, unrealSummaryLine, uprojectAssociation, vaultDirsFromIni, vaultPacks, vsVerdict, VsSetupReportSchema, withInstallLocation, } from '../shared/unreal/index.js';
15
+ import { chooseEngine, ddcVars, enginePlaceProblem, ENGINE_NEED_BYTES, engineAt, engineExtraDirs, engineToolDirs, engineVars, entriesUnder, fileAssociationPlan, findEngines, findUproject, hasMcpPlugin, incompleteDirs, isBuildId, installLocationOf, itemSizes, launcherEntriesFor, launcherEntry, launcherInstallations, mergeLauncherInstalled, parseBuildVersion, parseEngineAssociation, preferredInstalled, registryPlan, relocateItem, restoreItems, saveItems, setLauncherInstallLocation, stableBuildId, UNREAL_STATUS_FILE, unrealGuideLines, unrealSummaryLine, uprojectAssociation, vaultDirsFromIni, vaultPacks, vsVerdict, VsSetupReportSchema, withInstallLocation, } from '../shared/unreal/index.js';
16
16
  import { discoverPcInstalls } from '../host/pc-installs/index.js';
17
17
  import { findEngineFolders, findUnrealInstalls, pcSourceBuilds, regValues } from '../host/pc-installs/unreal.js';
18
18
  import { findEpicGames } from '../host/pc-installs/epic.js';
@@ -436,6 +436,25 @@ export const enginesSuite = {
436
436
  'relative',
437
437
  ]);
438
438
  t.equal(folders.map((f) => [f.id, f.writable]), [['dir-UnrealEngine', true]], 'a registered folder is mapped writable; one without an engine is left out');
439
+ const pcManifests = t.dir('pc-pcManifests');
440
+ const itemText = JSON.stringify({
441
+ AppName: 'UE_5.4',
442
+ InstallLocation: pcLauncher.replace(/\\/g, '/'),
443
+ ManifestLocation: pcLauncher + '/.egstore',
444
+ StagingLocation: 'D:\\Elsewhere\\bps',
445
+ InstallSize: 123,
446
+ });
447
+ fs.writeFileSync(path.join(pcManifests, 'ABCDEF0123.item'), itemText);
448
+ fs.writeFileSync(path.join(pcManifests, 'notes.txt'), 'not a manifest');
449
+ const pcRegistered = findEngineFolders({ read: DISK.read, builds: '', launcherInstalled: dat, manifests: pcManifests, list: DISK.list }, [pcLauncher])[0];
450
+ t.check(pcRegistered?.launcher?.itemId === 'item54' && pcRegistered.launcherItem?.name === 'ABCDEF0123.item', 'a pcRegistered folder the launcher installed keeps its ids and its manifest');
451
+ const moved = relocateItem(itemText, pcLauncher, 'C:\\PcInstalls\\unreal\\dir-UE_5.4');
452
+ const movedItem = JSON.parse(moved ?? '{}');
453
+ t.check(movedItem.InstallLocation === 'C:\\PcInstalls\\unreal\\dir-UE_5.4' &&
454
+ movedItem.ManifestLocation === 'C:\\PcInstalls\\unreal\\dir-UE_5.4\\.egstore' &&
455
+ !('StagingLocation' in movedItem) &&
456
+ movedItem.InstallSize === 123, "the manifest names the sandbox's folder; a path elsewhere on this PC is dropped");
457
+ t.equal(relocateItem(itemText, path.join(pcRoot, 'other'), 'C:\\x'), null, 'a manifest of another folder: none');
439
458
  t.equal(findEpicGames(dat, true).map((g) => g.id), ['Fortnite'], "the launcher's games are the epic-game installs (engines and the Fab plugin in one are not)");
440
459
  t.equal(findEpicGames(dat, ['nothing']), [], 'a list maps only those games');
441
460
  t.check(engineFolderProblem(pcSource, DISK.read) === null, 'Register an engine folder accepts an engine folder');
@@ -470,6 +489,8 @@ export const enginesSuite = {
470
489
  t.check(new Set(ids).size === ids.length, 'every app id is used once');
471
490
  t.equal(GAMEDEV_APPS.map((a) => a.id), ['krita', 'inkscape', 'audacity', 'renderdoc', 'f3d', 'imagemagick', 'nomacs', 'unity-mcp', 'openupm-cli'], 'Krita, Inkscape, Audacity, RenderDoc, F3D, ImageMagick, nomacs, then the Unity add-ons (Blender was there)');
472
491
  t.check(ids.includes('blender'), 'Blender is in the catalogue');
492
+ const f3d = GAMEDEV_APPS.find((a) => a.id === 'f3d');
493
+ t.check(f3d.onPath === true && !f3d.cli, 'F3D is on PATH (the preview guide runs `f3d`) and keeps its shortcut');
473
494
  t.check(GAMEDEV_APPS.every((a) => (a.category === 'gamedev' || a.id === 'unity-mcp') && a.exe && a.about.length > 20), 'each is a game-development app with its program');
474
495
  const audacity = new RegExp(GAMEDEV_APPS.find((a) => a.id === 'audacity').source.asset);
475
496
  t.check(audacity.test('audacity-win-4.0.2-x86_64.7z') &&