@aivin-labs/cli 1.0.46 → 1.0.50

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 (38) hide show
  1. package/bin/cli.mjs +16 -5
  2. package/bin/lib/auth.mjs +24 -10
  3. package/bin/lib/projectEnv.mjs +27 -0
  4. package/bin/lib/remote/client.mjs +1412 -1162
  5. package/bin/lib/remote/confirmBarrier.mjs +45 -0
  6. package/bin/lib/remote/constants.mjs +7 -1
  7. package/bin/lib/remote/desktop/aivinIco.mjs +696 -0
  8. package/bin/lib/remote/desktop/castAuth.mjs +74 -69
  9. package/bin/lib/remote/desktop/castConsent.mjs +90 -0
  10. package/bin/lib/remote/desktop/castFileDrop.mjs +24 -0
  11. package/bin/lib/remote/desktop/castInput.mjs +89 -24
  12. package/bin/lib/remote/desktop/castTouchViewers.mjs +26 -0
  13. package/bin/lib/remote/desktop/desktopCast.mjs +28 -2
  14. package/bin/lib/remote/desktop/desktopCastSource.mjs +410 -121
  15. package/bin/lib/remote/desktop/desktopWebRtc.mjs +17 -1
  16. package/bin/lib/remote/desktop/index.mjs +5 -3
  17. package/bin/lib/remote/desktop/traySource.mjs +1289 -1274
  18. package/bin/lib/remote/desktop/webrtcWorker.mjs +3 -0
  19. package/bin/lib/remote/deviceProfile.mjs +2 -0
  20. package/bin/lib/remote/gui/index.mjs +485 -480
  21. package/bin/lib/remote/humanInput.mjs +117 -0
  22. package/bin/lib/remote/idempotency.mjs +19 -2
  23. package/bin/lib/remote/keepAwake.mjs +15 -9
  24. package/bin/lib/remote/localConfirm.mjs +26 -7
  25. package/bin/lib/remote/localPolicy.mjs +15 -2
  26. package/bin/lib/remote/mascot/ask.mjs +23 -4
  27. package/bin/lib/remote/mascot/askHostSource.mjs +10 -4
  28. package/bin/lib/remote/mascot/bot.mjs +5 -1
  29. package/bin/lib/remote/mascot/hostSource.mjs +8 -1
  30. package/bin/lib/remote/mascot/index.mjs +55 -51
  31. package/bin/lib/remote/mascot/rigSource.mjs +28 -2
  32. package/bin/lib/remote/policyCommand.mjs +16 -3
  33. package/bin/lib/remote/processes.mjs +231 -230
  34. package/bin/lib/remote/sandbox.mjs +6 -4
  35. package/bin/lib/remote/scheduler.mjs +164 -124
  36. package/bin/lib/remote/toolHandlers.mjs +3 -2
  37. package/bin/lib/remote/winTree.mjs +29 -0
  38. package/package.json +1 -1
@@ -12,6 +12,9 @@ const MAX_INPUT_MESSAGE_BYTES = 25 * 1024 * 1024;
12
12
  /** Kênh tệp người xem kéo thả / dán vào màn hình (castFileDrop.mjs): tin cậy + đúng thứ tự, tách khỏi kênh thao tác để tệp lớn không làm trễ chuột. */
13
13
  export const FILE_CHANNEL = 'aivin-desktop-files';
14
14
  const MAX_FILE_CHUNK_BYTES = 256 * 1024;
15
+ /** Kênh riêng cho vị trí chuột: không gửi lại, không giữ thứ tự — mất một gói thì gói sau đè lên, không bắt các thao tác sau xếp hàng chờ như kênh tin cậy. */
16
+ export const POINTER_CHANNEL = 'aivin-desktop-pointer';
17
+ const MAX_POINTER_MESSAGE_BYTES = 512;
15
18
 
16
19
  const MAX_CURSOR_SHAPES = 64;
17
20
  /** Thử nối lại khi peer hỏng hẳn (`failed`): dựng peer mới, cùng người xem; hết lượt thì ở lại JPEG. Peer nối được thì đặt lại. */
@@ -107,6 +110,7 @@ export function createDesktopWebRtc({ emitSignal = () => {}, emitStatus = () =>
107
110
  const channel = pc.createDataChannel('aivin-desktop-frames', { ordered: false, maxRetransmits: 0 });
108
111
  const inputChannel = pc.createDataChannel(INPUT_CHANNEL, { ordered: true });
109
112
  const fileChannel = pc.createDataChannel(FILE_CHANNEL, { ordered: true });
113
+ const pointerChannel = pc.createDataChannel(POINTER_CHANNEL, { ordered: false, maxRetransmits: 0 });
110
114
  const VideoSource = wrtc?.nonstandard?.RTCVideoSource || wrtc?.default?.nonstandard?.RTCVideoSource;
111
115
  const AudioSource = wrtc?.nonstandard?.RTCAudioSource || wrtc?.default?.nonstandard?.RTCAudioSource;
112
116
  const MediaStream = wrtc?.MediaStream || wrtc?.default?.MediaStream;
@@ -118,7 +122,7 @@ export function createDesktopWebRtc({ emitSignal = () => {}, emitStatus = () =>
118
122
  if (track) stream ? pc.addTrack(track, stream) : pc.addTrack(track);
119
123
  if (audioTrack) stream ? pc.addTrack(audioTrack, stream) : pc.addTrack(audioTrack);
120
124
  const peer = {
121
- pc, channel, inputChannel, fileChannel,
125
+ pc, channel, inputChannel, fileChannel, pointerChannel, pointerSeq: 0,
122
126
  track, video: !!track,
123
127
  audioTrack, audio: !!audioTrack, audioEnabled: audio !== false,
124
128
  sessionId, viewerId, iceServers, videoBitrate, attempt, retryTimer: null, open: false, dropped: 0,
@@ -162,6 +166,17 @@ export function createDesktopWebRtc({ emitSignal = () => {}, emitStatus = () =>
162
166
  // Mã phiên lấy từ peer (đã gắn lúc BE mời), không tin mã trong gói.
163
167
  onInput({ ...msg, session_id: peer.sessionId }, viewerId);
164
168
  };
169
+ pointerChannel.onmessage = ({ data }) => {
170
+ const text = typeof data === 'string' ? data : Buffer.from(data).toString('utf8');
171
+ if (text.length > MAX_POINTER_MESSAGE_BYTES) return;
172
+ let msg;
173
+ try { msg = JSON.parse(text); } catch { return; }
174
+ // Chỉ nhận di chuột: nhấn, nhả, phím phải đi kênh tin cậy. Gói đến muộn hơn gói mới nhất thì bỏ.
175
+ if (msg?.action !== 'move' || !(msg.n > peer.pointerSeq)) return;
176
+ peer.pointerSeq = msg.n;
177
+ const { n: _n, ...cmd } = msg;
178
+ onInput({ ...cmd, session_id: peer.sessionId }, viewerId);
179
+ };
165
180
  peers.set(viewerId, peer);
166
181
  channel.binaryType = 'arraybuffer';
167
182
  const markConnected = () => {
@@ -352,6 +367,7 @@ export function createDesktopWebRtc({ emitSignal = () => {}, emitStatus = () =>
352
367
  try { peer.channel.close(); } catch { /* already closed */ }
353
368
  try { peer.inputChannel?.close(); } catch { /* already closed */ }
354
369
  try { peer.fileChannel?.close(); } catch { /* already closed */ }
370
+ try { peer.pointerChannel?.close(); } catch { /* already closed */ }
355
371
  try { peer.track?.stop(); } catch { /* already stopped */ }
356
372
  try { peer.audioTrack?.stop(); } catch { /* already stopped */ }
357
373
  try { peer.pc.close(); } catch { /* already closed */ }
@@ -6,6 +6,7 @@ import { execFileSync, spawn } from 'child_process';
6
6
  import { REMOTE_CONFIG_DIR } from '../constants.mjs';
7
7
  import { lockHolder } from '../daemonLock.mjs';
8
8
  import { AIVIN_LOGO_PNG_BASE64 } from '../brand.mjs';
9
+ import { AIVIN_ICO_BASE64 } from './aivinIco.mjs';
9
10
  import { TRAY_CS } from './traySource.mjs';
10
11
  import { trayStrings } from './strings.mjs';
11
12
  import { associationStamp, ensureFileAssociations, ensureUninstallEntry, registerFileAssociations, registerUninstallEntry, unregisterFileAssociations, unregisterUninstallEntry } from './fileAssociation.mjs';
@@ -205,8 +206,9 @@ function cleanupOldLaunchers(exe) {
205
206
  */
206
207
  export function ensureLauncher({ exe = launcherExePath(), home = REMOTE_CONFIG_DIR, dir = DESKTOP_DIR, force = false } = {}) {
207
208
  const source = launcherSource(home);
208
- const png = Buffer.from(AIVIN_LOGO_PNG_BASE64, 'base64');
209
- const hash = createHash('sha256').update(source).update(png).digest('hex');
209
+ // .ico nhiều cỡ (16…256): một ảnh 64×64 duy nhất bị Windows co giãn → nhoè trên taskbar / Start (09/11/2026).
210
+ const icoBytes = Buffer.from(AIVIN_ICO_BASE64, 'base64');
211
+ const hash = createHash('sha256').update(source).update(icoBytes).digest('hex');
210
212
  fs.mkdirSync(dir, { recursive: true });
211
213
  const hashFile = path.join(dir, path.basename(SOURCE_HASH_FILE));
212
214
  let current = null;
@@ -218,7 +220,7 @@ export function ensureLauncher({ exe = launcherExePath(), home = REMOTE_CONFIG_D
218
220
  const src = path.join(dir, 'tray.cs');
219
221
  const ico = path.join(dir, 'aivin.ico');
220
222
  fs.writeFileSync(src, source);
221
- fs.writeFileSync(ico, pngToIco(png));
223
+ fs.writeFileSync(ico, icoBytes);
222
224
  const out = `${exe}.new`;
223
225
  fs.rmSync(out, { force: true });
224
226
  runSetup({ Src: src, Ico: ico, Out: out }, dir);