@agentconnect.md/computer 2.8.0-rc.23 → 2.8.0-rc.25

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.
@@ -87124,7 +87124,7 @@ var serviceEntry = () => managedEntry() ?? resolve2(process.argv[1]);
87124
87124
 
87125
87125
  // src/version.ts
87126
87126
  init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
87127
- var COMPUTER_DAEMON_VERSION = true ? "2.8.0-rc.23" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
87127
+ var COMPUTER_DAEMON_VERSION = true ? "2.8.0-rc.25" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
87128
87128
 
87129
87129
  // src/http-server.ts
87130
87130
  var CONTROL_HEADER = "x-agentconnect-computer";
@@ -87266,7 +87266,7 @@ import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "node:f
87266
87266
  import { join as join6 } from "node:path";
87267
87267
  var waylandSession = () => process.platform === "linux" && Boolean(process.env.WAYLAND_DISPLAY);
87268
87268
  var HELPER = String.raw`#!/usr/bin/env python3
87269
- # Usage: screencast.py TOKEN_FILE FPS [FRAMES]. Asks the ScreenCast portal for the monitor (persisting a restore
87269
+ # Usage: screencast.py TOKEN_FILE FPS CURSOR(1|0) [FRAMES]. Asks the ScreenCast portal for the monitor (persisting a restore
87270
87270
  # token so consent is asked once), then streams it as Y4M on stdout until killed.
87271
87271
  import os, signal, subprocess, sys
87272
87272
  import gi
@@ -87274,7 +87274,8 @@ gi.require_version('Gio', '2.0')
87274
87274
  from gi.repository import Gio, GLib
87275
87275
 
87276
87276
  token_path, fps = sys.argv[1], int(sys.argv[2])
87277
- frames = int(sys.argv[3]) if len(sys.argv) > 3 else 0
87277
+ show_cursor = sys.argv[3] == '1'
87278
+ frames = int(sys.argv[4]) if len(sys.argv) > 4 else 0
87278
87279
  NAME, PATH = 'org.freedesktop.portal.Desktop', '/org/freedesktop/portal/desktop'
87279
87280
  IFACE = 'org.freedesktop.portal.ScreenCast'
87280
87281
  bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
@@ -87306,7 +87307,8 @@ def request(method, build):
87306
87307
  modes = bus.call_sync(NAME, PATH, 'org.freedesktop.DBus.Properties', 'Get',
87307
87308
  GLib.Variant('(ss)', (IFACE, 'AvailableCursorModes')), None, Gio.DBusCallFlags.NONE, -1,
87308
87309
  None).unpack()[0]
87309
- cursor = 2 if modes & 2 else 1
87310
+ # 2 embeds the pointer in the frames, 1 hides it.
87311
+ cursor = 2 if show_cursor and modes & 2 else 1
87310
87312
  session = request('CreateSession', lambda t: GLib.Variant('(a{sv})', (
87311
87313
  {'handle_token': t, 'session_handle_token': GLib.Variant('s', 'acd%d' % os.getpid())},)))['session_handle']
87312
87314
  options = {'types': GLib.Variant('u', 1), 'multiple': GLib.Variant('b', False),
@@ -87440,19 +87442,20 @@ async function downloadFfmpeg(dataDir2, target, log40) {
87440
87442
  log40(`Installed ffmpeg ${build3.version} at ${target}`);
87441
87443
  return target;
87442
87444
  }
87443
- function captureInputs(fps, dataDir2, frames = 0) {
87445
+ function captureInputs(fps, dataDir2, frames = 0, cursor = true) {
87446
+ const mouse = cursor ? "1" : "0";
87444
87447
  const override = process.env.AGENTCONNECT_COMPUTER_CAPTURE;
87445
87448
  if (override) return [{ name: "override", args: override.split(" ").filter(Boolean), filters: [] }];
87446
87449
  if (process.platform === "win32") {
87447
87450
  return [
87448
87451
  {
87449
87452
  name: "ddagrab",
87450
- args: ["-f", "lavfi", "-i", `ddagrab=output_idx=0:framerate=${fps}:draw_mouse=1`],
87453
+ args: ["-f", "lavfi", "-i", `ddagrab=output_idx=0:framerate=${fps}:draw_mouse=${mouse}`],
87451
87454
  filters: ["hwdownload", "format=bgra"]
87452
87455
  },
87453
87456
  {
87454
87457
  name: "gdigrab",
87455
- args: ["-f", "gdigrab", "-framerate", String(fps), "-draw_mouse", "1", "-i", "desktop"],
87458
+ args: ["-f", "gdigrab", "-framerate", String(fps), "-draw_mouse", mouse, "-i", "desktop"],
87456
87459
  filters: []
87457
87460
  }
87458
87461
  ];
@@ -87461,7 +87464,16 @@ function captureInputs(fps, dataDir2, frames = 0) {
87461
87464
  return [
87462
87465
  {
87463
87466
  name: "avfoundation",
87464
- args: ["-f", "avfoundation", "-capture_cursor", "1", "-framerate", String(fps), "-i", "Capture screen 0:none"],
87467
+ args: [
87468
+ "-f",
87469
+ "avfoundation",
87470
+ "-capture_cursor",
87471
+ mouse,
87472
+ "-framerate",
87473
+ String(fps),
87474
+ "-i",
87475
+ "Capture screen 0:none"
87476
+ ],
87465
87477
  filters: []
87466
87478
  }
87467
87479
  ];
@@ -87473,7 +87485,7 @@ function captureInputs(fps, dataDir2, frames = 0) {
87473
87485
  name: "pipewire",
87474
87486
  producer: {
87475
87487
  command: "python3",
87476
- args: [helper, screencastTokenPath(dataDir2), String(fps), ...frames ? [String(frames)] : []]
87488
+ args: [helper, screencastTokenPath(dataDir2), String(fps), mouse, ...frames ? [String(frames)] : []]
87477
87489
  },
87478
87490
  args: ["-f", "yuv4mpegpipe", "-i", "pipe:0"],
87479
87491
  filters: []
@@ -87483,7 +87495,7 @@ function captureInputs(fps, dataDir2, frames = 0) {
87483
87495
  return [
87484
87496
  {
87485
87497
  name: "x11grab",
87486
- args: ["-f", "x11grab", "-framerate", String(fps), "-i", process.env.DISPLAY ?? ":0"],
87498
+ args: ["-f", "x11grab", "-draw_mouse", mouse, "-framerate", String(fps), "-i", process.env.DISPLAY ?? ":0"],
87487
87499
  filters: []
87488
87500
  }
87489
87501
  ];
@@ -109989,7 +110001,7 @@ var RtcSessions = class {
109989
110001
  session.connected = true;
109990
110002
  session.lastSeen = Date.now();
109991
110003
  this.options.log(`viewer ${client()}: WebRTC connected (${transport}${selectedPairType(pc)})`);
109992
- session.unsubscribe ??= this.options.stream.subscribe((packet) => track.writeRtp(packet));
110004
+ session.unsubscribe ??= this.options.stream.subscribe(continuous(track));
109993
110005
  }
109994
110006
  if (state === "failed" || state === "closed" || state === "disconnected") this.close(session.id);
109995
110007
  });
@@ -110096,6 +110108,15 @@ function selectedPairType(pc) {
110096
110108
  }
110097
110109
  var PAIR_STATES = ["frozen", "waiting", "in-progress", "succeeded", "failed"];
110098
110110
  var endpoint = (c) => `${c.type} ${c.host}:${c.port}`;
110111
+ function continuous(track) {
110112
+ let source;
110113
+ return (packet) => {
110114
+ const ssrc = packet.readUInt32BE(8);
110115
+ if (source !== void 0 && ssrc !== source) track.notifySourceChanged(RtpPacket.deSerialize(packet).header);
110116
+ source = ssrc;
110117
+ track.writeRtp(packet);
110118
+ };
110119
+ }
110099
110120
  function iceReport(pc, trickled) {
110100
110121
  const connection = pc.iceTransports[0]?.connection;
110101
110122
  if (!connection) return "no ICE transport";
@@ -110135,6 +110156,9 @@ var ScreenStream = class {
110135
110156
  socket;
110136
110157
  process;
110137
110158
  restart;
110159
+ // The running capture's pointer setting, and the process being replaced because that setting changed.
110160
+ cursor = true;
110161
+ swapping;
110138
110162
  inputIndex = 0;
110139
110163
  running = false;
110140
110164
  runs = 0;
@@ -110170,7 +110194,8 @@ var ScreenStream = class {
110170
110194
  }
110171
110195
  spawn() {
110172
110196
  if (!this.running || !this.socket) return;
110173
- const inputs = captureInputs(this.options.fps, this.options.dataDir);
110197
+ this.cursor = this.options.cursor?.() ?? true;
110198
+ const inputs = captureInputs(this.options.fps, this.options.dataDir, 0, this.cursor);
110174
110199
  const input2 = inputs[Math.min(this.inputIndex, inputs.length - 1)];
110175
110200
  const args = [
110176
110201
  "-hide_banner",
@@ -110203,7 +110228,9 @@ var ScreenStream = class {
110203
110228
  `)));
110204
110229
  feeder.once("exit", () => this.children.delete(feeder));
110205
110230
  }
110206
- this.options.log(`screen stream: ffmpeg started (${input2.name}, ${this.options.fps} fps)`);
110231
+ this.options.log(
110232
+ `screen stream: ffmpeg started (${input2.name}, ${this.options.fps} fps${this.cursor ? "" : ", no pointer"})`
110233
+ );
110207
110234
  child2.once("error", (error63) => {
110208
110235
  this.lastError = `ffmpeg could not start: ${error63.message}`;
110209
110236
  this.options.log(`screen stream: ${this.lastError}`);
@@ -110213,6 +110240,10 @@ var ScreenStream = class {
110213
110240
  producer?.kill();
110214
110241
  if (this.process === child2) this.process = void 0;
110215
110242
  if (!this.running) return;
110243
+ if (this.swapping === child2) {
110244
+ this.swapping = void 0;
110245
+ return this.spawn();
110246
+ }
110216
110247
  const detail = stderr.trim().split("\n").slice(-3).join(" | ");
110217
110248
  this.lastError = `ffmpeg (${input2.name}) exited with ${code}: ${detail}`;
110218
110249
  this.options.log(`screen stream: ${this.lastError}`);
@@ -110220,6 +110251,13 @@ var ScreenStream = class {
110220
110251
  this.restart = setTimeout(() => this.spawn(), RESTART_DELAY_MS);
110221
110252
  });
110222
110253
  }
110254
+ // Restarts the capture when the pointer setting changed; the next keyframe carries the new frames.
110255
+ refresh() {
110256
+ const child2 = this.process;
110257
+ if (!child2 || this.swapping || (this.options.cursor?.() ?? true) === this.cursor) return;
110258
+ this.swapping = child2;
110259
+ terminate(child2);
110260
+ }
110223
110261
  get bytesPerMs() {
110224
110262
  return this.options.bitrateKbps * PACE_FACTOR / 8;
110225
110263
  }
@@ -110252,16 +110290,19 @@ var ScreenStream = class {
110252
110290
  this.queue.length = 0;
110253
110291
  this.queuedBytes = 0;
110254
110292
  clearTimeout(this.restart);
110293
+ this.swapping = void 0;
110255
110294
  const child2 = this.process;
110256
110295
  this.process = void 0;
110257
- child2?.kill();
110258
- if (child2)
110259
- setTimeout(() => child2.exitCode === null && child2.signalCode === null && child2.kill("SIGKILL"), 2e3).unref();
110296
+ if (child2) terminate(child2);
110260
110297
  this.socket?.close();
110261
110298
  this.socket = void 0;
110262
110299
  this.options.log("screen stream: stopped (no viewers)");
110263
110300
  }
110264
110301
  };
110302
+ function terminate(child2) {
110303
+ child2.kill();
110304
+ setTimeout(() => child2.exitCode === null && child2.signalCode === null && child2.kill("SIGKILL"), 2e3).unref();
110305
+ }
110265
110306
 
110266
110307
  // src/tools.ts
110267
110308
  init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
@@ -110620,7 +110661,7 @@ var VIEWER_PAGE = `<!doctype html>
110620
110661
  #screen.ctl { outline: 2px solid #4ade80; }
110621
110662
  video, img { max-width: 100vw; max-height: calc(100vh - 48px); display: block; }
110622
110663
  #surface { position: absolute; inset: 0; outline: none; }
110623
- #screen.ctl #surface { cursor: crosshair; }
110664
+ #screen.ctl #surface { cursor: default; }
110624
110665
  #login { display: none; gap: 8px; }
110625
110666
  #error { color: #f87171; }
110626
110667
  </style>
@@ -114528,6 +114569,8 @@ function buildViewer(dir, config2, computer, refusal, consoleViewer, advertiseAd
114528
114569
  fps: config2.streamFps,
114529
114570
  maxWidth: config2.streamMaxWidth,
114530
114571
  bitrateKbps: config2.streamBitrateKbps,
114572
+ // A person driving sees their browser's pointer at once, so the delayed one in the frames would be a second cursor.
114573
+ cursor: () => computer.liveStatus() !== "human_in_control",
114531
114574
  log: log39
114532
114575
  });
114533
114576
  const rtc = config2.webrtc ? new RtcSessions({
@@ -114550,7 +114593,7 @@ function buildViewer(dir, config2, computer, refusal, consoleViewer, advertiseAd
114550
114593
  streamError: () => stream.lastError,
114551
114594
  ...refusal ? { refusal } : {}
114552
114595
  });
114553
- return viewer;
114596
+ return { ...viewer, statusChanged: () => stream.refresh() };
114554
114597
  }
114555
114598
  async function loadDriverTools(driver, config2) {
114556
114599
  if (!config2.exposeDriverTools) return [];
@@ -114656,6 +114699,7 @@ async function run3(dir, initial, clientName) {
114656
114699
  setTitle(status);
114657
114700
  live2.channel?.client.beat();
114658
114701
  live2.local?.update();
114702
+ live2.viewer?.statusChanged();
114659
114703
  void live2.computer?.adminPromptChanged();
114660
114704
  },
114661
114705
  () => authority.refusal(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentconnect.md/computer",
3
- "version": "2.8.0-rc.23",
3
+ "version": "2.8.0-rc.25",
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": {