@agentconnect.md/computer 2.8.0-rc.12 → 2.8.0-rc.15

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.
@@ -1364,7 +1364,7 @@ var require_cross_spawn = __commonJS({
1364
1364
  var cp = __require("child_process");
1365
1365
  var parse3 = require_parse();
1366
1366
  var enoent = require_enoent();
1367
- function spawn10(command, args, options) {
1367
+ function spawn11(command, args, options) {
1368
1368
  const parsed = parse3(command, args, options);
1369
1369
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
1370
1370
  enoent.hookChildProcess(spawned, parsed);
@@ -1376,8 +1376,8 @@ var require_cross_spawn = __commonJS({
1376
1376
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
1377
1377
  return result;
1378
1378
  }
1379
- module.exports = spawn10;
1380
- module.exports.spawn = spawn10;
1379
+ module.exports = spawn11;
1380
+ module.exports.spawn = spawn11;
1381
1381
  module.exports.sync = spawnSync11;
1382
1382
  module.exports._parse = parse3;
1383
1383
  module.exports._enoent = enoent;
@@ -86299,13 +86299,26 @@ var ADMIN_PROMPT_LABELS = {
86299
86299
  approve: "Always Approve",
86300
86300
  deny: "Always Deny"
86301
86301
  };
86302
- var windowsRows = ({ service, adminPrompts }, busy) => {
86302
+ var FIREWALL_PROBLEM = {
86303
+ missing: "no rule for direct video",
86304
+ blocked: "blocks direct video",
86305
+ uncovered: "blocks direct video on this network"
86306
+ };
86307
+ var firewallRow = (state, busy) => busy ? { title: "Windows Firewall: adding the rule\u2026", mark: "progress", enabled: false } : state === "allowed" ? { title: "Windows Firewall: direct video allowed", mark: "ok", enabled: false } : state === void 0 ? { title: "Windows Firewall: cannot read the rules", mark: "warn", enabled: false } : {
86308
+ id: "firewall",
86309
+ title: `Windows Firewall: ${FIREWALL_PROBLEM[state]}, click to allow`,
86310
+ mark: "fail"
86311
+ };
86312
+ var windowsRows = ({ service, adminPrompts, firewall }, busy) => {
86303
86313
  if (!service)
86304
86314
  return [
86305
86315
  { title: "Service: not installed, run agentconnect computer setup", mark: "warn", enabled: false },
86306
86316
  { title: "Administrator prompts: out of reach without the service", mark: "warn", enabled: false }
86307
86317
  ];
86308
- const rows = [{ title: "Service: running as SYSTEM", mark: "ok", enabled: false }];
86318
+ const rows = [
86319
+ { title: "Service: running as SYSTEM", mark: "ok", enabled: false },
86320
+ firewallRow(firewall, busy.has("firewall"))
86321
+ ];
86309
86322
  if (!adminPrompts) return rows;
86310
86323
  if (adminPrompts.problem)
86311
86324
  rows.push({ title: `Administrator prompts: ${adminPrompts.problem}`, mark: "fail", enabled: false });
@@ -86313,13 +86326,13 @@ var windowsRows = ({ service, adminPrompts }, busy) => {
86313
86326
  rows.push({ title: `Administrator prompt waiting: ${adminPrompts.pending}`, mark: "warn", enabled: false });
86314
86327
  const modes = Object.entries(ADMIN_PROMPT_LABELS);
86315
86328
  rows.push({
86316
- title: `Administrator Prompts: ${busy ? "saving\u2026" : ADMIN_PROMPT_LABELS[adminPrompts.mode]}`,
86329
+ title: `Administrator Prompts: ${busy.has("admin-prompts") ? "saving\u2026" : ADMIN_PROMPT_LABELS[adminPrompts.mode]}`,
86317
86330
  items: [
86318
86331
  ...modes.map(([mode, title]) => ({
86319
86332
  id: `admin-prompts:${mode}`,
86320
86333
  title,
86321
86334
  checked: mode === adminPrompts.mode,
86322
- enabled: adminPrompts.editable && !busy
86335
+ enabled: adminPrompts.editable && !busy.has("admin-prompts")
86323
86336
  })),
86324
86337
  ...adminPrompts.locked ? [
86325
86338
  { title: "", separator: true },
@@ -86348,7 +86361,7 @@ function menuBarMenu(tray, facts, busy = /* @__PURE__ */ new Set()) {
86348
86361
  mark: cpMark,
86349
86362
  enabled: cpMark === "fail" && facts.controlPlane.state !== "revoked"
86350
86363
  },
86351
- ...windows ? windowsRows(windows, busy.has("admin-prompts")) : [
86364
+ ...windows ? windowsRows(windows, busy) : [
86352
86365
  grant("Screen Recording", facts.screenRecording, "screen-recording"),
86353
86366
  grant("Device Control (Accessibility)", facts.accessibility, "accessibility")
86354
86367
  ],
@@ -86440,6 +86453,8 @@ function startMenuBar(helper, host, initial, start = HelperTray.start) {
86440
86453
  return task("driver", () => host.installDriver());
86441
86454
  case "ffmpeg":
86442
86455
  return task("ffmpeg", () => host.installFfmpeg());
86456
+ case "firewall":
86457
+ return host.allowFirewall && task("firewall", () => host.allowFirewall());
86443
86458
  case "start-at-login":
86444
86459
  host.setStartAtLogin(!(facts?.startAtLogin ?? true));
86445
86460
  return void refresh();
@@ -86691,7 +86706,7 @@ var serviceEntry = () => managedEntry() ?? resolve(process.argv[1]);
86691
86706
 
86692
86707
  // src/version.ts
86693
86708
  init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
86694
- var COMPUTER_DAEMON_VERSION = true ? "2.8.0-rc.12" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
86709
+ var COMPUTER_DAEMON_VERSION = true ? "2.8.0-rc.15" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
86695
86710
 
86696
86711
  // src/http-server.ts
86697
86712
  var CONTROL_HEADER = "x-agentconnect-computer";
@@ -111318,7 +111333,7 @@ function consoleStopHandler(computer, changed) {
111318
111333
 
111319
111334
  // src/menu-bar-host.ts
111320
111335
  init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
111321
- import { spawn as spawn9, spawnSync as spawnSync8 } from "node:child_process";
111336
+ import { spawn as spawn10, spawnSync as spawnSync8 } from "node:child_process";
111322
111337
  import { chmodSync as chmodSync2, existsSync as existsSync8, readFileSync as readFileSync6, rmSync as rmSync7, writeFileSync as writeFileSync10 } from "node:fs";
111323
111338
  import { tmpdir as tmpdir2 } from "node:os";
111324
111339
  import { join as join12 } from "node:path";
@@ -111410,7 +111425,7 @@ function setStartAtLogin(on) {
111410
111425
 
111411
111426
  // src/setup.ts
111412
111427
  init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
111413
- import { spawn as spawn8, spawnSync as spawnSync7 } from "node:child_process";
111428
+ import { spawn as spawn9, spawnSync as spawnSync7 } from "node:child_process";
111414
111429
  import { existsSync as existsSync7 } from "node:fs";
111415
111430
  import { basename, dirname as dirname4, isAbsolute, join as join11 } from "node:path";
111416
111431
  import { createInterface as createInterface3 } from "node:readline";
@@ -111793,6 +111808,74 @@ async function registerOrKeep(dir, cpUrl, register3) {
111793
111808
  }
111794
111809
  }
111795
111810
 
111811
+ // src/windows-firewall.ts
111812
+ init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
111813
+ import { spawn as spawn8 } from "node:child_process";
111814
+ var FIREWALL_RULE = "AgentConnect Computer (Node.js)";
111815
+ var psQuote2 = (value) => `'${value.replace(/'/g, "''")}'`;
111816
+ var profileCovered = (profile, category) => profile === "Any" || profile.split(/,\s*/).includes(category === "DomainAuthenticated" ? "Domain" : category);
111817
+ function firewallVerdict(rules) {
111818
+ if (rules.block.length > 0) return { state: "blocked", rules: rules.block.map((rule) => rule.name) };
111819
+ if (rules.allow.length === 0) return { state: "missing" };
111820
+ const networks = rules.activeProfiles.filter(
111821
+ (category) => !rules.allow.some((rule) => profileCovered(rule.profile, category))
111822
+ );
111823
+ if (networks.length > 0) return { state: "uncovered", networks };
111824
+ return { state: "allowed", profiles: rules.allow.map((rule) => rule.profile) };
111825
+ }
111826
+ var readScript = (program) => `$ErrorActionPreference = 'SilentlyContinue'
111827
+ $p = ${psQuote2(program)}
111828
+ $rules = @(Get-NetFirewallApplicationFilter | Where-Object { [Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p } | Get-NetFirewallRule | Where-Object { "$($_.Enabled)" -eq 'True' -and "$($_.Direction)" -eq 'Inbound' } | ForEach-Object { [pscustomobject]@{ name = $_.DisplayName; action = "$($_.Action)"; profile = "$($_.Profile)" } })
111829
+ $profiles = @(Get-NetConnectionProfile | ForEach-Object { "$($_.NetworkCategory)" })
111830
+ ConvertTo-Json -Compress -InputObject @{ rules = $rules; profiles = $profiles }`;
111831
+ function parseFirewallRules(stdout) {
111832
+ try {
111833
+ const parsed = JSON.parse(stdout.trim());
111834
+ const rules = parsed.rules ?? [];
111835
+ return {
111836
+ allow: rules.filter((rule) => rule.action === "Allow"),
111837
+ block: rules.filter((rule) => rule.action === "Block"),
111838
+ activeProfiles: [...new Set(parsed.profiles ?? [])]
111839
+ };
111840
+ } catch {
111841
+ return void 0;
111842
+ }
111843
+ }
111844
+ var allowScript = (program) => `$p = ${psQuote2(program)}
111845
+ Get-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -ErrorAction SilentlyContinue | Remove-NetFirewallRule
111846
+ Get-NetFirewallApplicationFilter | Where-Object { [Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p } | Get-NetFirewallRule | Where-Object { "$($_.Action)" -eq 'Block' -and "$($_.Direction)" -eq 'Inbound' } | Disable-NetFirewallRule
111847
+ New-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -Direction Inbound -Program $p -Action Allow -Profile Any | Out-Null`;
111848
+ function powershell(script, timeoutMs) {
111849
+ return new Promise((resolve3) => {
111850
+ const child2 = spawn8("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
111851
+ stdio: ["ignore", "pipe", "ignore"],
111852
+ windowsHide: true
111853
+ });
111854
+ let stdout = "";
111855
+ child2.stdout.setEncoding("utf8").on("data", (chunk) => stdout += chunk);
111856
+ const timer = setTimeout(() => child2.kill(), timeoutMs);
111857
+ child2.on("error", () => resolve3({ ok: false, stdout }));
111858
+ child2.on("close", (code) => {
111859
+ clearTimeout(timer);
111860
+ resolve3({ ok: code === 0, stdout });
111861
+ });
111862
+ });
111863
+ }
111864
+ async function readFirewall(program) {
111865
+ const result = await powershell(readScript(program), 3e4);
111866
+ const rules = result.ok ? parseFirewallRules(result.stdout) : void 0;
111867
+ return rules && firewallVerdict(rules);
111868
+ }
111869
+ async function allowFirewall(program, elevated) {
111870
+ if (elevated) return (await powershell(allowScript(program), 6e4)).ok;
111871
+ const encoded2 = Buffer.from(allowScript(program), "utf16le").toString("base64");
111872
+ const result = await powershell(
111873
+ `Start-Process powershell.exe -Verb RunAs -Wait -WindowStyle Hidden -ArgumentList '-NoProfile','-NonInteractive','-EncodedCommand','${encoded2}'`,
111874
+ 18e4
111875
+ );
111876
+ return result.ok;
111877
+ }
111878
+
111796
111879
  // src/setup.ts
111797
111880
  var localizeChecks = (checks, command = selfCommand()) => {
111798
111881
  const rename = (text) => text.replace(/(?<![\w/.-])agentconnect-computer(?= |$)/g, command);
@@ -111803,7 +111886,6 @@ var localizeChecks = (checks, command = selfCommand()) => {
111803
111886
  }));
111804
111887
  };
111805
111888
  var ICON = { ok: "\u2705", info: "\u2139\uFE0F ", warn: "\u26A0\uFE0F ", fail: "\u274C" };
111806
- var FIREWALL_RULE = "AgentConnect Computer (Node.js)";
111807
111889
  var MAC_PANES = {
111808
111890
  accessibility: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility",
111809
111891
  screenRecording: "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"
@@ -111837,36 +111919,6 @@ async function macPermissions(driver, prompt = false) {
111837
111919
  directCapture: typeof meta3.direct_capture_status === "string" ? meta3.direct_capture_status : "not_checked"
111838
111920
  };
111839
111921
  }
111840
- function powershell(script, timeoutMs = 3e4) {
111841
- const result = spawnSync7("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
111842
- encoding: "utf8",
111843
- windowsHide: true,
111844
- timeout: timeoutMs
111845
- });
111846
- return { ok: result.status === 0, stdout: result.stdout ?? "" };
111847
- }
111848
- var psQuote2 = (value) => `'${value.replace(/'/g, "''")}'`;
111849
- function firewallState(program) {
111850
- const script = `$ErrorActionPreference = 'SilentlyContinue'
111851
- $p = ${psQuote2(program)}
111852
- $rules = @(Get-NetFirewallApplicationFilter | Where-Object { [Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p } | Get-NetFirewallRule | Where-Object { "$($_.Enabled)" -eq 'True' -and "$($_.Direction)" -eq 'Inbound' } | ForEach-Object { [pscustomobject]@{ name = $_.DisplayName; action = "$($_.Action)"; profile = "$($_.Profile)" } })
111853
- $profiles = @(Get-NetConnectionProfile | ForEach-Object { "$($_.NetworkCategory)" })
111854
- ConvertTo-Json -Compress -InputObject @{ rules = $rules; profiles = $profiles }`;
111855
- const result = powershell(script);
111856
- if (!result.ok) return void 0;
111857
- try {
111858
- const parsed = JSON.parse(result.stdout.trim());
111859
- const rules = parsed.rules ?? [];
111860
- return {
111861
- allow: rules.filter((rule) => rule.action === "Allow"),
111862
- block: rules.filter((rule) => rule.action === "Block"),
111863
- activeProfiles: [...new Set(parsed.profiles ?? [])]
111864
- };
111865
- } catch {
111866
- return void 0;
111867
- }
111868
- }
111869
- var profileCovered = (profile, category) => profile === "Any" || profile.split(/,\s*/).includes(category === "DomainAuthenticated" ? "Domain" : category);
111870
111922
  async function doctor(ctx, captureTimeoutMs = 15e3) {
111871
111923
  const checks = [];
111872
111924
  const { config: config2 } = ctx;
@@ -111919,7 +111971,7 @@ async function doctor(ctx, captureTimeoutMs = 15e3) {
111919
111971
  }
111920
111972
  checks.push(displayCheck(config2));
111921
111973
  checks.push(...ffmpegChecks(ctx, captureTimeoutMs));
111922
- if (process.platform === "win32") checks.push(firewallCheck(config2));
111974
+ if (process.platform === "win32") checks.push(await firewallCheck());
111923
111975
  if (process.platform === "linux") checks.push(...linuxChecks(ctx));
111924
111976
  checks.push(await daemonCheck(config2));
111925
111977
  return checks;
@@ -112148,37 +112200,35 @@ function ffmpegChecks(ctx, timeoutMs) {
112148
112200
  }
112149
112201
  ];
112150
112202
  }
112151
- function firewallCheck(config2) {
112152
- if (isLoopbackHost(config2.host)) {
112153
- return { name: "firewall", status: "info", detail: `listening on ${config2.host} only; no inbound rule needed` };
112154
- }
112155
- const state = firewallState(process.execPath);
112156
- if (!state) return { name: "firewall", status: "warn", detail: "could not read Windows Firewall rules" };
112157
- const fix = `run: ${selfCommand()} setup (asks for administrator approval once)`;
112158
- if (state.block.length > 0) {
112159
- return {
112160
- name: "firewall",
112161
- status: "fail",
112162
- detail: `inbound block rule(s) for ${process.execPath}: ${state.block.map((rule) => rule.name).join(", ")}`,
112163
- fix
112164
- };
112165
- }
112166
- const uncovered = state.activeProfiles.filter(
112167
- (category) => !state.allow.some((rule) => profileCovered(rule.profile, category))
112168
- );
112169
- if (state.allow.length === 0 || uncovered.length > 0) {
112170
- return {
112171
- name: "firewall",
112172
- status: "warn",
112173
- detail: state.allow.length === 0 ? "no inbound allow rule for Node.js: remote MCP and WebRTC will be blocked or prompt" : `Node.js is not allowed on active ${uncovered.join("/")} network(s)`,
112174
- fix
112175
- };
112203
+ async function firewallCheck() {
112204
+ const verdict = await readFirewall(process.execPath);
112205
+ const fix = `run: ${selfCommand()} setup, or click Windows Firewall in the taskbar menu`;
112206
+ if (!verdict) return { name: "firewall", status: "warn", detail: "could not read Windows Firewall rules" };
112207
+ switch (verdict.state) {
112208
+ case "blocked":
112209
+ return {
112210
+ name: "firewall",
112211
+ status: "fail",
112212
+ detail: `inbound block rule(s) for ${process.execPath}: ${verdict.rules.join(", ")}`,
112213
+ fix
112214
+ };
112215
+ case "missing":
112216
+ return {
112217
+ name: "firewall",
112218
+ status: "warn",
112219
+ detail: "no inbound allow rule for Node.js: direct WebRTC video falls back to TURN or screenshots",
112220
+ fix
112221
+ };
112222
+ case "uncovered":
112223
+ return {
112224
+ name: "firewall",
112225
+ status: "warn",
112226
+ detail: `Node.js is not allowed on active ${verdict.networks.join("/")} network(s)`,
112227
+ fix
112228
+ };
112229
+ case "allowed":
112230
+ return { name: "firewall", status: "ok", detail: `Node.js allowed inbound (${verdict.profiles.join(", ")})` };
112176
112231
  }
112177
- return {
112178
- name: "firewall",
112179
- status: "ok",
112180
- detail: `Node.js allowed inbound (${state.allow.map((rule) => rule.profile).join(", ")})`
112181
- };
112182
112232
  }
112183
112233
  async function daemonCheck(config2) {
112184
112234
  const running = await fetch(`${controlBaseUrl(config2)}/healthz`, { signal: AbortSignal.timeout(2e3) }).then((response) => response.ok).catch(() => false);
@@ -112293,33 +112343,16 @@ async function waitForGrants(ctx, app, initial) {
112293
112343
  return state;
112294
112344
  }
112295
112345
  function open2(url2) {
112296
- spawn8("open", [url2], { stdio: "ignore", detached: true }).unref();
112346
+ spawn9("open", [url2], { stdio: "ignore", detached: true }).unref();
112297
112347
  }
112298
- function setupWindowsFirewall(ctx, program = process.execPath) {
112299
- if (isLoopbackHost(ctx.config.host)) {
112300
- ctx.log(`Listening on ${ctx.config.host} only, so no Windows Firewall rule is needed.`);
112301
- return;
112302
- }
112303
- const state = firewallState(program);
112304
- const uncovered = state?.activeProfiles.filter(
112305
- (category) => !state.allow.some((rule) => profileCovered(rule.profile, category))
112306
- );
112307
- if (state && state.block.length === 0 && state.allow.length > 0 && uncovered?.length === 0) {
112348
+ async function setupWindowsFirewall(ctx, program = process.execPath) {
112349
+ if ((await readFirewall(program))?.state === "allowed") {
112308
112350
  ctx.log("Windows Firewall already allows Node.js inbound.");
112309
112351
  return;
112310
112352
  }
112311
112353
  ctx.log(`Adding a Windows Firewall rule "${FIREWALL_RULE}" for ${program} (approve the administrator prompt).`);
112312
- const elevated = `$p = ${psQuote2(program)}
112313
- Get-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -ErrorAction SilentlyContinue | Remove-NetFirewallRule
112314
- Get-NetFirewallApplicationFilter | Where-Object { [Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p } | Get-NetFirewallRule | Where-Object { "$($_.Action)" -eq 'Block' -and "$($_.Direction)" -eq 'Inbound' } | Disable-NetFirewallRule
112315
- New-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -Direction Inbound -Program $p -Action Allow -Profile Any | Out-Null`;
112316
- const encoded2 = Buffer.from(elevated, "utf16le").toString("base64");
112317
- const result = powershell(
112318
- `Start-Process powershell.exe -Verb RunAs -Wait -WindowStyle Hidden -ArgumentList '-NoProfile','-NonInteractive','-EncodedCommand','${encoded2}'`,
112319
- 18e4
112320
- );
112321
112354
  ctx.log(
112322
- result.ok ? "Firewall rule added; any Node.js block rules were disabled." : "Firewall rule not added (administrator prompt declined?); Windows will ask on first connection instead."
112355
+ await allowFirewall(program, false) ? "Firewall rule added; any Node.js block rules were disabled." : "Firewall rule not added (administrator prompt declined?); click Windows Firewall in the taskbar menu to add it later."
112323
112356
  );
112324
112357
  }
112325
112358
 
@@ -112433,7 +112466,7 @@ function macMenuBarHost(deps) {
112433
112466
  },
112434
112467
  openLogs() {
112435
112468
  const file2 = join12(dir, "daemon.log");
112436
- spawn9("open", existsSync8(file2) ? ["-a", "Console", file2] : [dir], { stdio: "ignore", detached: true }).unref();
112469
+ spawn10("open", existsSync8(file2) ? ["-a", "Console", file2] : [dir], { stdio: "ignore", detached: true }).unref();
112437
112470
  },
112438
112471
  uninstall() {
112439
112472
  let channel;
@@ -112446,7 +112479,7 @@ function macMenuBarHost(deps) {
112446
112479
  writeFileSync10(script, uninstallScript(channel));
112447
112480
  chmodSync2(script, 493);
112448
112481
  log40("uninstall requested from the menu bar; running it in Terminal");
112449
- spawn9("open", ["-a", "Terminal", script], { stdio: "ignore", detached: true }).unref();
112482
+ spawn10("open", ["-a", "Terminal", script], { stdio: "ignore", detached: true }).unref();
112450
112483
  },
112451
112484
  quit() {
112452
112485
  log40("quit from the menu bar; the service starts again at the next login");
@@ -112462,6 +112495,7 @@ import { existsSync as existsSync9, readFileSync as readFileSync7, rmSync as rmS
112462
112495
  import { join as join13 } from "node:path";
112463
112496
  var RECONNECT_WAIT_MS2 = 1e4;
112464
112497
  var DRIVER_TIMEOUT_MS = 5e3;
112498
+ var FIREWALL_TTL_MS = 5 * 6e4;
112465
112499
  var within2 = (promise2, ms) => Promise.race([promise2, new Promise((_, reject) => setTimeout(() => reject(new Error("timed out")), ms).unref())]);
112466
112500
  function uninstallCommand(channel) {
112467
112501
  const cli = `@agentconnect.md/cli${channel === "rc" ? "@rc" : ""}`;
@@ -112470,6 +112504,12 @@ function uninstallCommand(channel) {
112470
112504
  function windowsMenuBarHost(deps) {
112471
112505
  const { dir, driver, log: log40 } = deps;
112472
112506
  const host = deps.registration ? new URL(deps.registration.channelUrl).host : void 0;
112507
+ let firewall;
112508
+ const firewallState = async () => {
112509
+ if (!firewall || Date.now() - firewall.at > FIREWALL_TTL_MS)
112510
+ firewall = { at: Date.now(), state: (await readFirewall(process.execPath))?.state };
112511
+ return firewall.state;
112512
+ };
112473
112513
  return {
112474
112514
  async facts() {
112475
112515
  const running = await within2(driver.call("get_screen_size", {}), DRIVER_TIMEOUT_MS).then(
@@ -112478,6 +112518,7 @@ function windowsMenuBarHost(deps) {
112478
112518
  );
112479
112519
  const name = deps.name();
112480
112520
  const service = serviceHost() !== void 0;
112521
+ const firewallNow = service ? await firewallState() : void 0;
112481
112522
  return {
112482
112523
  ...name ? { name } : {},
112483
112524
  version: COMPUTER_DAEMON_VERSION,
@@ -112490,7 +112531,11 @@ function windowsMenuBarHost(deps) {
112490
112531
  installing: ffmpegInstalling(dir)
112491
112532
  },
112492
112533
  startAtLogin: service && startsAtLogin2(),
112493
- windows: { service, ...deps.adminPrompts ? { adminPrompts: deps.adminPrompts.facts() } : {} }
112534
+ windows: {
112535
+ service,
112536
+ ...firewallNow ? { firewall: firewallNow } : {},
112537
+ ...deps.adminPrompts ? { adminPrompts: deps.adminPrompts.facts() } : {}
112538
+ }
112494
112539
  };
112495
112540
  },
112496
112541
  async reconnect() {
@@ -112515,6 +112560,14 @@ function windowsMenuBarHost(deps) {
112515
112560
  await deps.adminPrompts.set(mode);
112516
112561
  log40(`administrator prompts set to ${mode} from the taskbar`);
112517
112562
  },
112563
+ // The service runs as SYSTEM, so the rule goes in without a UAC prompt.
112564
+ async allowFirewall() {
112565
+ firewall = void 0;
112566
+ if (!await allowFirewall(process.execPath, serviceHost() !== void 0))
112567
+ throw new Error("could not add the Windows Firewall rule");
112568
+ log40("Windows Firewall rule added from the taskbar");
112569
+ deps.onFirewallChanged?.();
112570
+ },
112518
112571
  // macOS grants: not shown on Windows.
112519
112572
  openSettings: () => void 0,
112520
112573
  resetGrant: () => void 0,
@@ -113708,7 +113761,7 @@ async function main() {
113708
113761
  return;
113709
113762
  }
113710
113763
  case "service":
113711
- return serviceCommand(dir, loadConfig(dir), rest[0], Boolean(values.purge));
113764
+ return await serviceCommand(dir, loadConfig(dir), rest[0], Boolean(values.purge));
113712
113765
  case "autostart": {
113713
113766
  const action = rest[0];
113714
113767
  if (action === "enable") enableAutostart(dir, serviceEntry());
@@ -114162,6 +114215,7 @@ async function run3(dir, initial, clientName) {
114162
114215
  // The service host starts the daemon again after a non-zero exit and waits for the next sign-in after zero.
114163
114216
  shutdown: (code) => void shutdown(code),
114164
114217
  onFfmpegInstalled: () => live2.channel?.refreshDoctor(),
114218
+ onFirewallChanged: () => live2.channel?.refreshDoctor(),
114165
114219
  ...adminPromptHelper ? {
114166
114220
  adminPrompts: {
114167
114221
  facts: () => {
@@ -114368,7 +114422,7 @@ async function setupMacApp(dir, config2) {
114368
114422
  console.log(`Checking from inside ${app} (if macOS asks to let it bypass the window picker, click Allow):`);
114369
114423
  return await daemonDoctor(config2, 12e4) ?? doctor(setupContext(dir, config2));
114370
114424
  }
114371
- function serviceCommand(dir, config2, action, purge) {
114425
+ async function serviceCommand(dir, config2, action, purge) {
114372
114426
  if (process.platform === "linux") return linuxServiceCommand(dir, config2, action);
114373
114427
  if (process.platform === "win32") return windowsServiceCommand(dir, config2, action, purge);
114374
114428
  if (process.platform !== "darwin") throw new Error("service is only implemented for macOS, Linux and Windows");
@@ -114411,9 +114465,9 @@ function linuxServiceCommand(dir, config2, action) {
114411
114465
  )
114412
114466
  );
114413
114467
  }
114414
- function windowsServiceCommand(dir, config2, action, purge) {
114468
+ async function windowsServiceCommand(dir, config2, action, purge) {
114415
114469
  const say = (line) => console.error(line);
114416
- if (action === "install") installWindowsService(dir, config2, say);
114470
+ if (action === "install") await installWindowsService(dir, config2, say);
114417
114471
  else if (action === "uninstall") uninstallService2(windowsServiceHome(), purge, say);
114418
114472
  else if (action === "start") startService2();
114419
114473
  else if (action === "stop") stopService2();
@@ -114434,13 +114488,13 @@ function windowsServiceCommand(dir, config2, action, purge) {
114434
114488
  )
114435
114489
  );
114436
114490
  }
114437
- function installWindowsService(dir, config2, log40) {
114491
+ async function installWindowsService(dir, config2, log40) {
114438
114492
  installService2({ entry: serviceEntry(), node: process.execPath, home: dir, log: log40 });
114439
114493
  const installedNode2 = join15(installDir(), "node.exe");
114440
- setupWindowsFirewall({ ...setupContext(dir, config2), log: log40 }, installedNode2);
114494
+ await setupWindowsFirewall({ ...setupContext(dir, config2), log: log40 }, installedNode2);
114441
114495
  }
114442
114496
  async function setupWindowsService(dir, config2) {
114443
- installWindowsService(dir, config2, (line) => console.log(line));
114497
+ await installWindowsService(dir, config2, (line) => console.log(line));
114444
114498
  if (!await waitForDaemon(config2, 9e4)) {
114445
114499
  console.log(`The service did not come up; see ${join15(dir, "daemon.log")}`);
114446
114500
  return doctor(setupContext(dir, config2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentconnect.md/computer",
3
- "version": "2.8.0-rc.12",
3
+ "version": "2.8.0-rc.15",
4
4
  "description": "AgentConnect computer daemon: drives a desktop through Cua Driver and serves the computer_* tools over MCP; installed and upgraded by agentconnect computer",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {