@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
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Rào xác nhận (09/11/2026): khi có hộp "Cho phép / Từ chối" đang chờ trên máy, lời gọi CÓ TÁC DỤNG khác chưa được bắt đầu. Trước đây lời
3
+ * gọi rủi ro A đứng chờ người bấm còn lời gọi B cùng lô vẫn chạy — B (`gui.do` bấm "Cho phép", hay `shell.exec` chạy script UIAutomation)
4
+ * tự duyệt được A, vô hiệu cả sàn xác nhận tại máy. Lời gọi chỉ đọc vẫn chạy (không bấm / gõ được gì).
5
+ *
6
+ * `hold()` → hàm thả (gọi nhiều lần vô hại); `waitClear(signal)` → `true` khi không còn hộp nào, `false` khi bị huỷ lúc chờ.
7
+ */
8
+ export function createConfirmBarrier() {
9
+ let pending = 0;
10
+ let waiters = [];
11
+
12
+ const wake = () => {
13
+ const list = waiters;
14
+ waiters = [];
15
+ list.forEach((fn) => fn());
16
+ };
17
+
18
+ return {
19
+ hold() {
20
+ pending++;
21
+ let released = false;
22
+ return () => {
23
+ if (released) return;
24
+ released = true;
25
+ pending--;
26
+ if (pending === 0) wake();
27
+ };
28
+ },
29
+ pending: () => pending,
30
+ async waitClear(signal) {
31
+ while (pending > 0) {
32
+ if (signal?.aborted) return false;
33
+ await new Promise((resolve) => {
34
+ const done = () => {
35
+ signal?.removeEventListener('abort', done);
36
+ resolve();
37
+ };
38
+ waiters.push(done);
39
+ signal?.addEventListener('abort', done, { once: true });
40
+ });
41
+ }
42
+ return !signal?.aborted;
43
+ },
44
+ };
45
+ }
@@ -84,6 +84,8 @@ export const DeviceEvent = Object.freeze({
84
84
  NOTIFY_ACK: 'device:notify_ack',
85
85
  /** CLI → BE: câu hỏi còn ghim đã đóng chưa `{ items: [{ session_id, reply_id }] }` — ack `{ ok, closed: reply_id[] }`. */
86
86
  QUESTIONS: 'device:questions',
87
+ /** BE → CLI (09/11/2026): câu hỏi ghim đã xử lý ở nơi khác (duyệt trên web / máy khác) `{ reply_ids }` → bỏ nút ngay. */
88
+ QUESTION_CLOSED: 'device:question_closed',
87
89
  /** CLI → BE: dừng lượt chat đang chạy `{ request_id }` — lượt kết thúc bằng `error` mã `cancelled`. */
88
90
  CHAT_CANCEL: 'device:chat_cancel',
89
91
  WEBVIEW: 'device:webview',
@@ -103,11 +105,13 @@ export const DeviceEvent = Object.freeze({
103
105
  DESKTOP_CAST_STATUS: 'device:desktop_cast_status',
104
106
  /** CLI → BE: ô có tiêu điểm sau cú nhấp có phải ô nhập chữ — cho người xem đường JPEG (WebRTC đi kênh thao tác). */
105
107
  DESKTOP_CAST_INPUT_FOCUS: 'device:desktop_cast_input_focus',
108
+ /** BE → CLI: người xem tạm cầm lái khi AI đang chạy / trả lại — `{ session_id, active, idle_ms, max_wait_ms }`. */
109
+ DESKTOP_CAST_TAKEOVER: 'device:desktop_cast_takeover',
106
110
  });
107
111
 
108
112
  /** Trạng thái phiên xem màn hình gửi BE (`device:desktop_cast_status`) — khớp BE `DesktopCastState`. */
109
113
  export const CastState = Object.freeze({
110
- READY: 'ready', CONNECTED: 'connected', DEGRADED: 'degraded', STOPPED: 'stopped', REFUSED: 'refused', INPUT_BLOCKED: 'input_blocked',
114
+ READY: 'ready', CONNECTED: 'connected', DEGRADED: 'degraded', STOPPED: 'stopped', REFUSED: 'refused', INPUT_BLOCKED: 'input_blocked', AWAITING_CONSENT: 'awaiting_consent', PASTE_FAILED: 'paste_failed', DROP_REFUSED: 'drop_refused',
111
115
  });
112
116
 
113
117
  /** Loại báo chủ động (`device:notify`). */
@@ -212,6 +216,8 @@ export const DeviceErrorCode = Object.freeze({
212
216
  CANCELLED: 'CANCELLED',
213
217
  /** Bước có tác dụng đã bắt đầu thì daemon khởi động lại — không biết đã làm tới đâu, không tự làm lại. */
214
218
  INTERRUPTED: 'INTERRUPTED',
219
+ /** Bước CHƯA chạy (vd người đang tạm cầm lái từ web tới hết hạn chờ) — gửi lại an toàn. */
220
+ NOT_STARTED: 'NOT_STARTED',
215
221
  TOOL_UNKNOWN: 'TOOL_UNKNOWN',
216
222
  INVALID_ARGS: 'INVALID_ARGS',
217
223
  NOT_FOUND: 'NOT_FOUND',