@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
@@ -1,16 +1,16 @@
1
-
2
- function formatDeviceLabel(raw, lang = 'vi') {
3
- if (!raw) return null;
4
- const isVi = lang === 'vi';
5
- const s = String(raw).trim();
6
- if (/iphone/i.test(s)) return isVi ? 'Điện thoại iPhone' : 'iPhone';
7
- if (/ipad/i.test(s)) return isVi ? 'Máy tính bảng iPad' : 'iPad';
8
- if (/android/i.test(s)) return isVi ? 'Điện thoại Android' : 'Android phone';
9
- if (/mac/i.test(s)) return isVi ? 'Máy tính Mac' : 'Mac computer';
10
- if (/win/i.test(s)) return isVi ? 'Máy tính khác' : 'Another computer';
11
- if (/web/i.test(s)) return isVi ? 'Trình duyệt web' : 'Web browser';
12
- return s;
13
- }
1
+
2
+ function formatDeviceLabel(raw, lang = 'vi') {
3
+ if (!raw) return null;
4
+ const isVi = lang === 'vi';
5
+ const s = String(raw).trim();
6
+ if (/iphone/i.test(s)) return isVi ? 'Điện thoại iPhone' : 'iPhone';
7
+ if (/ipad/i.test(s)) return isVi ? 'Máy tính bảng iPad' : 'iPad';
8
+ if (/android/i.test(s)) return isVi ? 'Điện thoại Android' : 'Android phone';
9
+ if (/mac/i.test(s)) return isVi ? 'Máy tính Mac' : 'Mac computer';
10
+ if (/win/i.test(s)) return isVi ? 'Máy tính khác' : 'Another computer';
11
+ if (/web/i.test(s)) return isVi ? 'Trình duyệt web' : 'Web browser';
12
+ return s;
13
+ }
14
14
  import fs from 'fs';
15
15
  import path from 'path';
16
16
  import readline from 'readline';
@@ -47,7 +47,7 @@ export const MascotState = Object.freeze({
47
47
  });
48
48
  export const LogStatus = Object.freeze({ RUN: 'run', OK: 'ok', FAIL: 'fail', INFO: 'info', WARN: 'warn' });
49
49
  /** Lệnh gửi cửa sổ / sự kiện cửa sổ gửi về (một dòng JSON mỗi lệnh). */
50
- export const HostCommand = Object.freeze({ STATE: 'state', MAIN: 'main', LOG: 'log', GUI: 'gui', SHOW: 'show', QUIT: 'quit', OPEN_ASK: 'open_ask', QUICK_VOICE: 'quick_voice', VOICE_TOGGLE: 'voice_toggle', GESTURE: 'gesture', NOTIFY_FREQ: 'notify_freq' });
50
+ export const HostCommand = Object.freeze({ STATE: 'state', MAIN: 'main', LOG: 'log', GUI: 'gui', SHOW: 'show', QUIT: 'quit', OPEN_ASK: 'open_ask', QUICK_VOICE: 'quick_voice', VOICE_TOGGLE: 'voice_toggle', GESTURE: 'gesture', NOTIFY_FREQ: 'notify_freq', REMOTE_VIEW: 'remote_view' });
51
51
 
52
52
  /** `aivin ui` (terminal khác) chạm tệp này → daemon đang chạy hiện linh vật + mở ô hỏi (mascot/ui.mjs). */
53
53
  export const MASCOT_SHOW_FILE = path.join(REMOTE_CONFIG_DIR, 'mascot-show');
@@ -130,8 +130,8 @@ const VOICE_EVENTS = new Set([HostEvent.VOICE_START, HostEvent.VOICE_AUDIO, Host
130
130
 
131
131
  const THINK_MS = 8000;
132
132
  const RESULT_MS = 6000;
133
- const MAIN_THROTTLE_MS = 600;
134
- /** Chờ chừng này trước khi báo mất kết nối: rớt mạng thoáng qua vài giây rồi tự nối lại ngay thì giữ im lặng, không bật bong bóng. */
133
+ const MAIN_THROTTLE_MS = 600;
134
+ /** Chờ chừng này trước khi báo mất kết nối: rớt mạng thoáng qua vài giây rồi tự nối lại ngay thì giữ im lặng, không bật bong bóng. */
135
135
  const OFFLINE_GRACE_MS = 8000;
136
136
  const RESTART_DELAYS_MS = [5000, 30_000, 120_000];
137
137
  const QUEUE_LOGS = 40;
@@ -271,6 +271,7 @@ export function createMascot({
271
271
  let lastPin = null;
272
272
  // Tệp thả vào bot đang chờ: cửa sổ dựng lại vẫn ôm thùng có số tệp.
273
273
  let lastFiles = null;
274
+ let lastRemoteView = null;
274
275
  // Đang nói chuyện bằng giọng (cửa sổ báo voice_start … voice_stop / daemon gửi voice_end): đổi ngôn ngữ chờ tới khi xong mới dựng lại.
275
276
  let voiceOn = false;
276
277
  let langRebuild = false;
@@ -283,6 +284,7 @@ export function createMascot({
283
284
  if (msg.t === AskCommand.CHOICES) lastChoices = msg;
284
285
  if (msg.t === AskCommand.PIN) lastPin = msg;
285
286
  if (msg.t === AskCommand.FILES) lastFiles = msg;
287
+ if (msg.t === HostCommand.REMOTE_VIEW) lastRemoteView = msg;
286
288
  if (msg.t === VoiceCommand.END) { voiceOn = false; if (langRebuild) timers.setTimeout(rebuildForLang, 0); }
287
289
  if (ready) return write(msg);
288
290
  if (msg.t === HostCommand.LOG) {
@@ -324,6 +326,7 @@ export function createMascot({
324
326
  write(lastPin);
325
327
  }
326
328
  if (lastFiles?.files?.length) write(lastFiles);
329
+ if (lastRemoteView?.on) write(lastRemoteView);
327
330
  if (commandOnReady) { write({ t: commandOnReady }); commandOnReady = null; }
328
331
  };
329
332
 
@@ -512,7 +515,7 @@ export function createMascot({
512
515
  timers.clearTimeout(restartTimer);
513
516
  timers.clearTimeout(thinkTimer);
514
517
  timers.clearTimeout(resultTimer);
515
- timers.clearTimeout(mainTimer);
518
+ timers.clearTimeout(mainTimer);
516
519
  timers.clearTimeout(offlineTimer);
517
520
  quitHost();
518
521
  }
@@ -522,8 +525,8 @@ export function createMascot({
522
525
  const waiting = new Set();
523
526
  let guiActive = 0;
524
527
  let paused = false;
525
- let offline = false;
526
- let offlineTimer = null;
528
+ let offline = false;
529
+ let offlineTimer = null;
527
530
  let everConnected = false;
528
531
  let phase = MascotState.IDLE;
529
532
  let batchOk = 0;
@@ -613,11 +616,11 @@ export function createMascot({
613
616
  /** Lệnh của ô hỏi (ask.mjs: chat / chat_busy / ask_status) → cửa sổ. */
614
617
  chat(cmd) { send(cmd); },
615
618
  connected() {
616
- const hadBlip = offlineTimer !== null && !offline && everConnected;
617
- timers.clearTimeout(offlineTimer);
618
- offlineTimer = null;
619
- everConnected = true;
620
- if (hadBlip) return;
619
+ const hadBlip = offlineTimer !== null && !offline && everConnected;
620
+ timers.clearTimeout(offlineTimer);
621
+ offlineTimer = null;
622
+ everConnected = true;
623
+ if (hadBlip) return;
621
624
  offline = false;
622
625
  syncState();
623
626
  log({ status: LogStatus.INFO, title: t(MascotText.CONNECTED) });
@@ -625,17 +628,17 @@ export function createMascot({
625
628
  send({ t: HostCommand.MAIN, text: t(MascotText.READY), quiet: true });
626
629
  },
627
630
  disconnected() {
628
- if (offline || offlineTimer) return;
629
- const showOffline = () => {
630
- offlineTimer = null;
631
- if (offline || closed) return;
632
- offline = true;
633
- syncState();
634
- log({ status: LogStatus.WARN, title: t(MascotText.DISCONNECTED) });
635
- main(t(MascotText.DISCONNECTED));
636
- };
637
- if (offlineGraceMs <= 0) return showOffline();
638
- offlineTimer = timers.setTimeout(showOffline, offlineGraceMs);
631
+ if (offline || offlineTimer) return;
632
+ const showOffline = () => {
633
+ offlineTimer = null;
634
+ if (offline || closed) return;
635
+ offline = true;
636
+ syncState();
637
+ log({ status: LogStatus.WARN, title: t(MascotText.DISCONNECTED) });
638
+ main(t(MascotText.DISCONNECTED));
639
+ };
640
+ if (offlineGraceMs <= 0) return showOffline();
641
+ offlineTimer = timers.setTimeout(showOffline, offlineGraceMs);
639
642
  },
640
643
  paused(on) {
641
644
  if (paused === on) return;
@@ -645,22 +648,23 @@ export function createMascot({
645
648
  log({ status: on ? LogStatus.WARN : LogStatus.INFO, title: text });
646
649
  main(text);
647
650
  },
648
- /** Có người đang xem + điều khiển màn hình máy này từ web (Desktop Scenecast) — chủ máy luôn biết. */
649
- remoteView(on, { device } = {}) {
650
- if (on) {
651
- const devName = formatDeviceLabel(device, currentLang);
652
- const text = devName
653
- ? t(MascotText.CAST_VIEWING_DEVICE, { device: devName })
654
- : t(MascotText.CAST_VIEWING);
655
- log({ status: LogStatus.WARN, title: text });
656
- main(text);
657
- send({ t: HostCommand.GESTURE, g: 'startle', face: 'curious', sec: 4.5 });
658
- } else {
659
- const text = t(MascotText.CAST_ENDED);
660
- log({ status: LogStatus.INFO, title: text });
661
- main(text);
662
- send({ t: HostCommand.GESTURE, g: 'relief', face: 'relief', sec: 2.5 });
663
- }
651
+ /** Có người đang xem + điều khiển màn hình máy này từ web (Desktop Scenecast) — chủ máy luôn biết. */
652
+ remoteView(on, { device } = {}) {
653
+ send({ t: HostCommand.REMOTE_VIEW, on: !!on });
654
+ if (on) {
655
+ const devName = formatDeviceLabel(device, currentLang);
656
+ const text = devName
657
+ ? t(MascotText.CAST_VIEWING_DEVICE, { device: devName })
658
+ : t(MascotText.CAST_VIEWING);
659
+ log({ status: LogStatus.WARN, title: text });
660
+ main(text);
661
+ send({ t: HostCommand.GESTURE, g: 'startle', face: 'curious', sec: 4.5 });
662
+ } else {
663
+ const text = t(MascotText.CAST_ENDED);
664
+ log({ status: LogStatus.INFO, title: text });
665
+ main(text);
666
+ send({ t: HostCommand.GESTURE, g: 'relief', face: 'relief', sec: 2.5 });
667
+ }
664
668
  },
665
669
  callStarted(call, tool) {
666
670
  if (!call?.call_id || tool?.internal) return;
@@ -41,6 +41,8 @@ const SCREENS = BOT_RIG.screens;
41
41
  const SP = BOT_RIG.sparks;
42
42
  const TR = BOT_RIG.tray;
43
43
 
44
+ const WAVE = BOT_RIG.wave;
45
+
44
46
  export const RIG_CS = String.raw`
45
47
  public sealed class Motion {
46
48
  public readonly double Bob, BobHz, Breathe, Lean, HeadTilt, HeadY, Antenna, Glow, GlowPulse, GlowHz, Tint, TintPulse, TintHz, Scan, Scale, Opacity, LookX, LookY;
@@ -150,6 +152,10 @@ ${Object.entries(BOT_MOTION).map(motionCase).join('\n')}
150
152
  readonly Dictionary<string, System.Windows.UIElement> mouthEls = new Dictionary<string, System.Windows.UIElement>();
151
153
  readonly ScaleTransform eyeMorphL, eyeMorphR, mouthMorph;
152
154
  string eyesNow, eyesNext, mouthNow, mouthNext; double mouthAt;
155
+ readonly System.Windows.Shapes.Polyline waveL, waveR;
156
+ bool waveOn;
157
+ const double WAVE_HALF = ${n(WAVE.halfWidth)}, WAVE_AMP = ${n(WAVE.amp)}, WAVE_LEN = ${n(WAVE.length)}, WAVE_HZ = ${n(WAVE.hz)}, WAVE_EYE_DX = ${n(BOT_RIG.face.eyeDx)};
158
+ const int WAVE_SEGMENTS = ${WAVE.segments};
153
159
  readonly Spring eyeSq = new Spring(1), mouthSq = new Spring(1);
154
160
  const double MOUTH_LAG = 0.05;
155
161
  // Antenna light color: eases from the old state's color to the new one.
@@ -208,6 +214,7 @@ ${SCREENS.map((sc, i) => ` screens.Add(MakeScreen(${i}, ${n(sc.tilt)}, ${n(
208
214
  faceBase = faceScale.ScaleX;
209
215
  foreach (var name in new[] { ${BOT_EYES.map((e) => `"${e}"`).join(', ')} }) eyeEls[name] = new[] { Get<System.Windows.UIElement>("Eyes_" + name + "_L"), Get<System.Windows.UIElement>("Eyes_" + name + "_R") };
210
216
  foreach (var name in new[] { ${BOT_MOUTHS.map((e) => `"${e}"`).join(', ')} }) mouthEls[name] = Get<System.Windows.UIElement>("Mouth_" + name);
217
+ waveL = Get<System.Windows.Shapes.Polyline>("WaveL"); waveR = Get<System.Windows.Shapes.Polyline>("WaveR");
211
218
  eyeMorphL = Get<ScaleTransform>("EyeMorphL"); eyeMorphR = Get<ScaleTransform>("EyeMorphR"); mouthMorph = Get<ScaleTransform>("MouthMorph");
212
219
  tint.Fill = tintBrush; halo.Fill = tintBrush;
213
220
  tray = Get<System.Windows.UIElement>("Tray"); trayArrow = Get<System.Windows.UIElement>("TrayArrow"); trayBase = Get<System.Windows.UIElement>("TrayBase"); trayNo = Get<System.Windows.UIElement>("TrayNo");
@@ -243,12 +250,30 @@ ${SCREENS.map((sc, i) => ` screens.Add(MakeScreen(${i}, ${n(sc.tilt)}, ${n(
243
250
  public void SetFace(string eyes, string mouth) {
244
251
  if (!eyeEls.ContainsKey(eyes) || !mouthEls.ContainsKey(mouth)) return;
245
252
  if (eyesNow == null) { eyesNow = eyes; ShowEyes(eyes); }
253
+ else if (waveOn) { eyesNow = eyes; eyesNext = null; } // Remote viewer: the eyes stay a wave; only remember the face to restore when the session ends.
246
254
  else if (eyesNext != null || eyes != eyesNow) eyesNext = eyes;
247
255
  if (mouthNow == null) { mouthNow = mouth; ShowMouth(mouth); }
248
256
  else if (mouthNext != null || mouth != mouthNow) { if (mouthNext == null) mouthAt = Now + MOUTH_LAG; mouthNext = mouth; }
249
257
  }
250
258
  void ShowEyes(string name) {
251
- foreach (var kv in eyeEls) { var v = kv.Key == name ? Visibility.Visible : Visibility.Collapsed; foreach (var e in kv.Value) e.Visibility = v; }
259
+ string shown = waveOn ? "wave" : name;
260
+ foreach (var kv in eyeEls) { var v = kv.Key == shown ? Visibility.Visible : Visibility.Collapsed; foreach (var e in kv.Value) e.Visibility = v; }
261
+ }
262
+ /** Someone is viewing / controlling this computer: both eyes become one continuously moving sine wave, over any face, until the session ends. */
263
+ public void RemoteWave(bool on) {
264
+ if (on == waveOn) return;
265
+ if (on && dozing) Doze(false);
266
+ waveOn = on;
267
+ ShowEyes(eyesNow);
268
+ }
269
+ /** Phase follows the real position, so it reads as one wave running through both eyes. */
270
+ PointCollection WavePoints(double t, double eyeCenter) {
271
+ var points = new PointCollection(WAVE_SEGMENTS + 1);
272
+ for (int i = 0; i <= WAVE_SEGMENTS; i++) {
273
+ double x = -WAVE_HALF + 2 * WAVE_HALF * i / WAVE_SEGMENTS;
274
+ points.Add(new Point(x, WAVE_AMP * Math.Sin(2 * Math.PI * ((x + eyeCenter) / WAVE_LEN - WAVE_HZ * t))));
275
+ }
276
+ return points;
252
277
  }
253
278
  void ShowMouth(string name) {
254
279
  foreach (var kv in mouthEls) kv.Value.Visibility = kv.Key == name ? Visibility.Visible : Visibility.Collapsed;
@@ -272,7 +297,7 @@ ${SCREENS.map((sc, i) => ` screens.Add(MakeScreen(${i}, ${n(sc.tilt)}, ${n(
272
297
 
273
298
  /** Doze off (the window calls this after a long idle) or wake up: wake = perk up, antenna flick, a blink. */
274
299
  public void Doze(bool on) {
275
- if (on == dozing) return;
300
+ if (on == dozing || (on && waveOn)) return;
276
301
  dozing = on; m = Motion.For(on ? "doze" : state);
277
302
  if (on) nextJerk = Now + 6 + rnd.NextDouble() * 5;
278
303
  else { perkAt = Now; antA.V += 150; blinkAt = Now; }
@@ -580,6 +605,7 @@ ${SCREENS.map((sc, i) => ` screens.Add(MakeScreen(${i}, ${n(sc.tilt)}, ${n(
580
605
  double blink = 1;
581
606
  if (bu >= 0 && bu < 0.17) blink = bu < 0.06 ? 1 - 0.9 * (bu / 0.06) : (bu < 0.08 ? 0.1 : 0.1 + 0.9 * Math.Sin((bu - 0.08) / 0.09 * Math.PI / 2));
582
607
  foreach (var b in blinks) b.ScaleY = blink;
608
+ if (waveOn) { waveL.Points = WavePoints(t, -WAVE_EYE_DX); waveR.Points = WavePoints(t, WAVE_EYE_DX); }
583
609
  if (dz > 0) foreach (var r in spins) r.Angle = (dizU * 540) % 360;
584
610
 
585
611
  // 10) Face morph: eyes squash shut fast (~80 ms, no overshoot), swap kind while shut, spring open with a small overshoot (and a
@@ -1,6 +1,6 @@
1
1
  import chalk from 'chalk';
2
2
  import readline from 'readline/promises';
3
- import { CONFIRM_RANK, ConfirmMode, DEFAULT_LOCAL_POLICY, REMOTE_POLICY_FILE, saveLocalPolicy, stricterPolicy, verifyLocalPolicy } from './localPolicy.mjs';
3
+ import { CAST_CONSENT_RANK, CONFIRM_RANK, CastConsentMode, ConfirmMode, DEFAULT_LOCAL_POLICY, REMOTE_POLICY_FILE, saveLocalPolicy, stricterPolicy, verifyLocalPolicy } from './localPolicy.mjs';
4
4
 
5
5
  /**
6
6
  * `aivin remote policy [hành động] [giá trị]` — chủ máy đặt sàn luật tại máy (localPolicy.mjs). Siết luật chạy ngay; NỚI luật (bớt xác
@@ -14,12 +14,19 @@ const CONFIRM_TEXT = {
14
14
  [ConfirmMode.NEVER]: 'không hỏi trên máy — chỉ theo luật phía Aivin',
15
15
  };
16
16
 
17
+ const CAST_TEXT = {
18
+ [CastConsentMode.ASK]: 'mỗi phiên xem / điều khiển màn hình phải bấm "Cho phép" trên máy',
19
+ [CastConsentMode.UNATTENDED]: 'xem / điều khiển màn hình KHÔNG cần người ở máy',
20
+ [CastConsentMode.OFF]: 'tắt hẳn xem / điều khiển màn hình',
21
+ };
22
+
17
23
  function show(policy) {
18
24
  console.log(chalk.blue('🛡️ Luật tại máy này') + chalk.gray(` (${REMOTE_POLICY_FILE})`));
19
25
  console.log(` Xác nhận trên máy: ${chalk.cyan(policy.confirm)} — ${CONFIRM_TEXT[policy.confirm]} (chờ tối đa ${policy.confirm_timeout_sec} s)`);
26
+ console.log(` Xem màn hình: ${chalk.cyan(policy.cast_consent)} — ${CAST_TEXT[policy.cast_consent]}`);
20
27
  console.log(` Công cụ tắt: ${policy.deny_tools.length ? policy.deny_tools.join(', ') : chalk.gray('không')}`);
21
28
  console.log(` Lệnh chặn thêm: ${policy.blocked_commands.length ? policy.blocked_commands.map((r) => `/${r}/`).join(' ') : chalk.gray('không')}`);
22
- console.log(chalk.gray(' Đổi: aivin remote policy confirm <never|risky|always> · deny|allow <công cụ> · block|unblock "<regex>" · timeout <giây>'));
29
+ console.log(chalk.gray(' Đổi: aivin remote policy confirm <never|risky|always> · deny|allow <công cụ> · block|unblock "<regex>" · timeout <giây> · cast <ask|unattended|off>'));
23
30
  }
24
31
 
25
32
  /** Nới luật: chỉ người gõ trong terminal thật, và phải trả lời "có". */
@@ -84,8 +91,14 @@ export async function runPolicyCommand(action, value) {
84
91
  next.confirm_timeout_sec = Math.round(sec);
85
92
  break;
86
93
  }
94
+ case 'cast': {
95
+ if (!Object.hasOwn(CAST_CONSENT_RANK, v)) throw new Error('Dùng: aivin remote policy cast <ask|unattended|off>');
96
+ if (CAST_CONSENT_RANK[v] < CAST_CONSENT_RANK[policy.cast_consent]) await assertHumanLoosening(`Đổi xem màn hình từ "${policy.cast_consent}" sang "${v}": ${CAST_TEXT[v]}`);
97
+ next.cast_consent = v;
98
+ break;
99
+ }
87
100
  default:
88
- throw new Error(`Không hiểu "${action}". Dùng: confirm | deny | allow | block | unblock | timeout`);
101
+ throw new Error(`Không hiểu "${action}". Dùng: confirm | deny | allow | block | unblock | timeout | cast`);
89
102
  }
90
103
  const saved = saveLocalPolicy(next);
91
104
  console.log(chalk.green('✅ Đã lưu — có hiệu lực ngay (công cụ tắt / bật lại vào danh mục ở lần khởi động daemon kế tiếp).'));