@aivin-labs/cli 1.0.30 → 1.0.31
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.
package/README.md
CHANGED
|
@@ -123,7 +123,7 @@ curl -fsSL https://get.aivin.vn/install.sh | sh
|
|
|
123
123
|
| **Linux glibc x64 / arm64** | `aivin-linux-x64` / `aivin-linux-arm64` |
|
|
124
124
|
| **Linux musl (Alpine)** | `aivin-linux-x64-musl` / `aivin-linux-arm64-musl` |
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
On Windows, open Aivin from the system tray and choose **Sign in to connect** to link this computer through the usual browser login. You can also pair from Aivin Web with a one-time code (`aivin remote start --code <code>`).
|
|
127
127
|
|
|
128
128
|
---
|
|
129
129
|
|
|
@@ -230,8 +230,8 @@ export function ensureLauncher({ exe = launcherExePath(), home = REMOTE_CONFIG_D
|
|
|
230
230
|
return { exe, built: true };
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
export function ensureStartMenuShortcut({ exe = launcherExePath(), lnk = startMenuShortcutPath(), lang = 'en', dir = DESKTOP_DIR } = {}) {
|
|
234
|
-
runSetup({ Lnk: lnk, Target: exe, Desc: trayStrings(lang).shortcut }, dir);
|
|
233
|
+
export function ensureStartMenuShortcut({ exe = launcherExePath(), lnk = startMenuShortcutPath(), lang = 'en', args = '--platform', dir = DESKTOP_DIR } = {}) {
|
|
234
|
+
runSetup({ Lnk: lnk, Target: exe, LnkArgs: args, Desc: trayStrings(lang).shortcut }, dir);
|
|
235
235
|
return lnk;
|
|
236
236
|
}
|
|
237
237
|
|
|
@@ -239,9 +239,9 @@ export function desktopShortcutName() {
|
|
|
239
239
|
return `${DISPLAY_NAME}.lnk`;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
export function ensureDesktopShortcut({ exe = launcherExePath(), lang = 'en', dir = DESKTOP_DIR } = {}) {
|
|
242
|
+
export function ensureDesktopShortcut({ exe = launcherExePath(), lang = 'en', args = '--platform', dir = DESKTOP_DIR } = {}) {
|
|
243
243
|
const name = desktopShortcutName();
|
|
244
|
-
runSetup({ DesktopLnkName: name, Target: exe, Desc: trayStrings(lang).shortcut }, dir);
|
|
244
|
+
runSetup({ DesktopLnkName: name, Target: exe, LnkArgs: args, Desc: trayStrings(lang).shortcut }, dir);
|
|
245
245
|
return name;
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -277,6 +277,8 @@ export function refreshDesktopIntegration({ lang = 'en' } = {}) {
|
|
|
277
277
|
const done = [];
|
|
278
278
|
const { exe, built } = ensureLauncher();
|
|
279
279
|
if (built) done.push('launcher');
|
|
280
|
+
if (built || !fs.existsSync(startMenuShortcutPath())) ensureStartMenuShortcut({ exe, lang, args: '--platform' });
|
|
281
|
+
if (built) ensureDesktopShortcut({ exe, lang, args: '--platform' });
|
|
280
282
|
if (ensureFileAssociations({ exe, lang, stampFile: ASSOCIATION_STAMP_FILE })) done.push('associations');
|
|
281
283
|
if (built || !fs.existsSync(sendToShortcutPath())) { ensureSendToShortcut({ exe, lang }); done.push('send_to'); }
|
|
282
284
|
if (ensureUninstallEntry({ ...uninstallEntryOptions(exe), stampFile: UNINSTALL_STAMP_FILE })) done.push('uninstall_entry');
|
|
@@ -343,8 +345,8 @@ export function installDesktop({ argv, rollback = null, lang = 'en', autostart =
|
|
|
343
345
|
const { exe, built } = ensureLauncher();
|
|
344
346
|
const lnk = startMenuShortcutPath();
|
|
345
347
|
for (const p of legacyStartMenuShortcutPaths()) fs.rmSync(p, { force: true });
|
|
346
|
-
|
|
347
|
-
const desktopShortcut = ensureDesktopShortcut({ exe, lang });
|
|
348
|
+
ensureStartMenuShortcut({ exe, lnk, lang, args: '--platform' });
|
|
349
|
+
const desktopShortcut = ensureDesktopShortcut({ exe, lang, args: '--platform' });
|
|
348
350
|
if (autostart) registerStartup(exe);
|
|
349
351
|
const openWith = registerOpenWith(exe, lang);
|
|
350
352
|
if (launch && built) quitRunningTray({ exe });
|
|
@@ -30,12 +30,20 @@ export const TRAY_STRINGS = Object.freeze({
|
|
|
30
30
|
updateUpdating: 'Đang tải bản cập nhật...',
|
|
31
31
|
quit: 'Thoát Aivin',
|
|
32
32
|
firstRun: 'Aivin đang chạy ở khay hệ thống — bấm biểu tượng để mở.',
|
|
33
|
-
connectHint: 'Aivin
|
|
33
|
+
connectHint: 'Aivin đang ở khay hệ thống — bấm biểu tượng rồi chọn “Đăng nhập để kết nối”.',
|
|
34
34
|
connected: 'Đã kết nối máy này với Aivin.',
|
|
35
35
|
pairFailed: 'Không kết nối được — mã sai hoặc đã hết hạn. Tạo mã mới trong Aivin rồi thử lại.',
|
|
36
36
|
pairPrompt: 'Nhập mã kết nối từ Aivin (khung chat → Browser ▾ → Thêm máy tính này):',
|
|
37
37
|
pairOk: 'Kết nối',
|
|
38
38
|
pairCancel: 'Huỷ',
|
|
39
|
+
connectTitle: 'Kết nối máy tính này với Aivin Cloud',
|
|
40
|
+
connectPrompt: 'Đăng nhập tài khoản Aivin để liên kết máy tính này và nhận việc từ Aivin Cloud.',
|
|
41
|
+
connectSignIn: 'Đăng nhập để kết nối',
|
|
42
|
+
connectCode: 'Tôi có mã kết nối',
|
|
43
|
+
connectWorking: 'Đang mở trang đăng nhập…',
|
|
44
|
+
connectPairing: 'Đăng nhập thành công. Đang liên kết máy tính…',
|
|
45
|
+
connectFailed: 'Chưa kết nối được. Hãy thử lại hoặc dùng mã kết nối.',
|
|
46
|
+
connectDone: 'Đã kết nối máy tính này với Aivin Cloud.',
|
|
39
47
|
shortcut: 'Aivin — cho các agent Aivin làm việc trên máy tính này',
|
|
40
48
|
openWith: 'Mở bằng AIVIN Bot',
|
|
41
49
|
share: 'Gửi cho AIVIN Bot',
|
|
@@ -74,12 +82,20 @@ export const TRAY_STRINGS = Object.freeze({
|
|
|
74
82
|
updateUpdating: 'Downloading update...',
|
|
75
83
|
quit: 'Quit Aivin',
|
|
76
84
|
firstRun: 'Aivin is running in the system tray — click the icon to open it.',
|
|
77
|
-
connectHint: 'Aivin is in the system tray — click the icon
|
|
85
|
+
connectHint: 'Aivin is in the system tray — click the icon, then choose “Sign in to connect”.',
|
|
78
86
|
connected: 'This computer is now connected to Aivin.',
|
|
79
87
|
pairFailed: 'Could not connect — the code is wrong or expired. Create a new code in Aivin and try again.',
|
|
80
88
|
pairPrompt: 'Enter the connect code from Aivin (chat box → Browser ▾ → Add this computer):',
|
|
81
89
|
pairOk: 'Connect',
|
|
82
90
|
pairCancel: 'Cancel',
|
|
91
|
+
connectTitle: 'Connect this computer to Aivin Cloud',
|
|
92
|
+
connectPrompt: 'Sign in to your Aivin account to link this computer and receive work from Aivin Cloud.',
|
|
93
|
+
connectSignIn: 'Sign in to connect',
|
|
94
|
+
connectCode: 'I have a connect code',
|
|
95
|
+
connectWorking: 'Opening sign-in…',
|
|
96
|
+
connectPairing: 'Signed in. Linking this computer…',
|
|
97
|
+
connectFailed: 'Could not connect. Try again or use a connect code.',
|
|
98
|
+
connectDone: 'This computer is connected to Aivin Cloud.',
|
|
83
99
|
shortcut: 'Aivin — lets your Aivin agents work on this computer',
|
|
84
100
|
openWith: 'Open with AIVIN Bot',
|
|
85
101
|
share: 'Share with AIVIN Bot',
|
|
@@ -96,13 +112,13 @@ const PLATFORM_STRINGS = Object.freeze({
|
|
|
96
112
|
vi: {
|
|
97
113
|
startup: 'Mở khi đăng nhập',
|
|
98
114
|
firstRun: 'Aivin đang chạy trên thanh menu — bấm biểu tượng để xem.',
|
|
99
|
-
|
|
115
|
+
connectHint: 'Aivin đang ở khay hệ thống — bấm biểu tượng rồi chọn “Đăng nhập để kết nối”.',
|
|
100
116
|
folder: 'Mở thư mục Aivin trong Finder',
|
|
101
117
|
},
|
|
102
118
|
en: {
|
|
103
119
|
startup: 'Open at login',
|
|
104
120
|
firstRun: 'Aivin is running in the menu bar — click its icon to see it.',
|
|
105
|
-
connectHint: 'Aivin is in the
|
|
121
|
+
connectHint: 'Aivin is in the system tray — click its icon, then choose “Sign in to connect”.',
|
|
106
122
|
folder: 'Show Aivin folder in Finder',
|
|
107
123
|
},
|
|
108
124
|
},
|
|
@@ -53,6 +53,7 @@ namespace AivinDesktop {
|
|
|
53
53
|
if (workAt >= 0) return SendRequest(args, workAt + 1, id, ".workdir");
|
|
54
54
|
bool autostart = Array.IndexOf(args, "--autostart") >= 0;
|
|
55
55
|
bool installed = Array.IndexOf(args, "--installed") >= 0;
|
|
56
|
+
bool openPlatform = Array.IndexOf(args, "--platform") >= 0;
|
|
56
57
|
bool quit = Array.IndexOf(args, "--quit") >= 0;
|
|
57
58
|
bool created;
|
|
58
59
|
using (EventWaitHandle platformLaunch = new EventWaitHandle(false, EventResetMode.AutoReset, "Local\\AivinTrayPlatform-" + id)) {
|
|
@@ -60,6 +61,7 @@ namespace AivinDesktop {
|
|
|
60
61
|
if (!created) {
|
|
61
62
|
// Double-click Aivin.exe / Start menu mở platform; lệnh nội bộ vẫn chỉ đánh thức linh vật.
|
|
62
63
|
if (quit) Signal("Local\\AivinTrayQuit-" + id);
|
|
64
|
+
else if (openPlatform) TrayApp.OpenPlatformNow();
|
|
63
65
|
else if (args.Length == 0) platformLaunch.Set();
|
|
64
66
|
else if (!autostart && !installed) Signal("Local\\AivinTrayOpen-" + id);
|
|
65
67
|
return 0;
|
|
@@ -68,7 +70,7 @@ namespace AivinDesktop {
|
|
|
68
70
|
try { SetProcessDPIAware(); } catch { }
|
|
69
71
|
Application.EnableVisualStyles();
|
|
70
72
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
71
|
-
Application.Run(new TrayApp(id, !autostart && !installed, installed));
|
|
73
|
+
Application.Run(new TrayApp(id, !autostart && (!installed || openPlatform), installed));
|
|
72
74
|
GC.KeepAlive(mutex);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
@@ -873,6 +875,8 @@ namespace AivinDesktop {
|
|
|
873
875
|
try { Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); } catch { }
|
|
874
876
|
}
|
|
875
877
|
|
|
878
|
+
internal static void OpenPlatformNow() { LaunchPlatformApp(); }
|
|
879
|
+
|
|
876
880
|
/** Gửi yêu cầu cho daemon qua tệp đánh dấu (mascot-show = mở ô hỏi, mascot-voice = nói chuyện); daemon đang dừng thì chạy lại để nó nhận. */
|
|
877
881
|
void RequestMascot(string requestFile) {
|
|
878
882
|
if (quitting) return;
|
|
@@ -988,6 +992,102 @@ namespace AivinDesktop {
|
|
|
988
992
|
}
|
|
989
993
|
|
|
990
994
|
void ShowPair() {
|
|
995
|
+
if (pairForm != null) { pairForm.Activate(); return; }
|
|
996
|
+
Form f = new Form();
|
|
997
|
+
f.Text = cfg.T("connectTitle");
|
|
998
|
+
f.Icon = colorIcon;
|
|
999
|
+
f.Font = SystemFonts.MessageBoxFont;
|
|
1000
|
+
f.AutoScaleDimensions = new SizeF(96F, 96F);
|
|
1001
|
+
f.AutoScaleMode = AutoScaleMode.Dpi;
|
|
1002
|
+
f.FormBorderStyle = FormBorderStyle.FixedDialog;
|
|
1003
|
+
f.MaximizeBox = false;
|
|
1004
|
+
f.MinimizeBox = false;
|
|
1005
|
+
f.StartPosition = FormStartPosition.CenterScreen;
|
|
1006
|
+
f.TopMost = true;
|
|
1007
|
+
f.ClientSize = new Size(420, 194);
|
|
1008
|
+
bool[] connectCancelled = new bool[] { false };
|
|
1009
|
+
f.FormClosing += delegate { connectCancelled[0] = true; };
|
|
1010
|
+
Label label = new Label();
|
|
1011
|
+
label.Text = cfg.T("connectPrompt");
|
|
1012
|
+
label.SetBounds(16, 16, 388, 52);
|
|
1013
|
+
Label statusLabel = new Label();
|
|
1014
|
+
statusLabel.SetBounds(16, 76, 388, 24);
|
|
1015
|
+
statusLabel.ForeColor = Color.FromArgb(80, 90, 105);
|
|
1016
|
+
Button signIn = new Button();
|
|
1017
|
+
signIn.Text = cfg.T("connectSignIn");
|
|
1018
|
+
signIn.SetBounds(16, 128, 190, 32);
|
|
1019
|
+
signIn.BackColor = Color.FromArgb(33, 98, 230);
|
|
1020
|
+
signIn.ForeColor = Color.White;
|
|
1021
|
+
signIn.FlatStyle = FlatStyle.Flat;
|
|
1022
|
+
Button code = new Button();
|
|
1023
|
+
code.Text = cfg.T("connectCode");
|
|
1024
|
+
code.SetBounds(212, 128, 128, 32);
|
|
1025
|
+
Button cancel = new Button();
|
|
1026
|
+
cancel.Text = cfg.T("pairCancel");
|
|
1027
|
+
cancel.SetBounds(346, 128, 58, 32);
|
|
1028
|
+
cancel.DialogResult = DialogResult.Cancel;
|
|
1029
|
+
f.Controls.AddRange(new Control[] { label, statusLabel, signIn, code, cancel });
|
|
1030
|
+
f.CancelButton = cancel;
|
|
1031
|
+
pairForm = f;
|
|
1032
|
+
signIn.Click += delegate {
|
|
1033
|
+
signIn.Enabled = false;
|
|
1034
|
+
code.Enabled = false;
|
|
1035
|
+
statusLabel.Text = cfg.T("connectWorking");
|
|
1036
|
+
ThreadPool.QueueUserWorkItem(delegate {
|
|
1037
|
+
int loginResult = RunCliAndWait("login");
|
|
1038
|
+
if (loginResult != 0) {
|
|
1039
|
+
UI(delegate { if (!quitting && pairForm == f) { statusLabel.Text = cfg.T("connectFailed"); signIn.Enabled = code.Enabled = true; } });
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
if (connectCancelled[0]) return;
|
|
1043
|
+
UI(delegate { if (!quitting && pairForm == f) statusLabel.Text = cfg.T("connectPairing"); });
|
|
1044
|
+
int pairResult = RunCliAndWait("remote pair");
|
|
1045
|
+
UI(delegate {
|
|
1046
|
+
if (quitting || pairForm != f) return;
|
|
1047
|
+
if (pairResult == 0 && HasPairedServer()) {
|
|
1048
|
+
statusLabel.Text = cfg.T("connectDone");
|
|
1049
|
+
f.Close();
|
|
1050
|
+
} else {
|
|
1051
|
+
statusLabel.Text = cfg.T("connectFailed");
|
|
1052
|
+
signIn.Enabled = code.Enabled = true;
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
};
|
|
1057
|
+
code.Click += delegate { f.DialogResult = DialogResult.Retry; f.Close(); };
|
|
1058
|
+
DialogResult r = f.ShowDialog();
|
|
1059
|
+
pairForm = null;
|
|
1060
|
+
f.Dispose();
|
|
1061
|
+
if (r == DialogResult.Retry && !quitting) { ShowPairWithCode(); return; }
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
int RunCliAndWait(string command) {
|
|
1065
|
+
try {
|
|
1066
|
+
cfg = Config.Load(CfgFile);
|
|
1067
|
+
if (string.IsNullOrEmpty(cfg.Exe)) return 1;
|
|
1068
|
+
List<string> args = new List<string>();
|
|
1069
|
+
foreach (string a in cfg.Args) { if (a == "remote") break; args.Add(a); }
|
|
1070
|
+
foreach (string a in command.Split(' ')) args.Add(a);
|
|
1071
|
+
StringBuilder line = new StringBuilder();
|
|
1072
|
+
foreach (string a in args) { if (line.Length > 0) line.Append(' '); line.Append(Quote(a)); }
|
|
1073
|
+
ProcessStartInfo psi = new ProcessStartInfo(cfg.Exe, line.ToString());
|
|
1074
|
+
psi.UseShellExecute = false;
|
|
1075
|
+
psi.CreateNoWindow = true;
|
|
1076
|
+
psi.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
|
1077
|
+
psi.EnvironmentVariables.Remove("AIVIN_SUPERVISOR");
|
|
1078
|
+
psi.RedirectStandardOutput = true;
|
|
1079
|
+
psi.RedirectStandardError = true;
|
|
1080
|
+
Process p = Process.Start(psi);
|
|
1081
|
+
p.BeginOutputReadLine();
|
|
1082
|
+
p.BeginErrorReadLine();
|
|
1083
|
+
p.WaitForExit();
|
|
1084
|
+
int result = p.ExitCode;
|
|
1085
|
+
p.Dispose();
|
|
1086
|
+
return result;
|
|
1087
|
+
} catch { return 1; }
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
void ShowPairWithCode() {
|
|
991
1091
|
if (pairForm != null) { pairForm.Activate(); return; }
|
|
992
1092
|
Form f = new Form();
|
|
993
1093
|
f.Text = "AIVIN Bot";
|
|
@@ -1020,12 +1120,12 @@ namespace AivinDesktop {
|
|
|
1020
1120
|
f.CancelButton = cancel;
|
|
1021
1121
|
pairForm = f;
|
|
1022
1122
|
DialogResult r = f.ShowDialog();
|
|
1023
|
-
string
|
|
1123
|
+
string pairingCode = box.Text.Trim();
|
|
1024
1124
|
pairForm = null;
|
|
1025
1125
|
f.Dispose();
|
|
1026
|
-
if (r != DialogResult.OK ||
|
|
1126
|
+
if (r != DialogResult.OK || pairingCode.Length == 0 || quitting) return;
|
|
1027
1127
|
KillChild();
|
|
1028
|
-
StartChild(
|
|
1128
|
+
StartChild(pairingCode);
|
|
1029
1129
|
Refresh();
|
|
1030
1130
|
}
|
|
1031
1131
|
|
|
@@ -282,7 +282,7 @@ const STRINGS = {
|
|
|
282
282
|
[MascotText.UI_SHOWN]: "Linh vật Aivin đã hiện trên màn hình — gõ hoặc bấm mic để hỏi.",
|
|
283
283
|
[MascotText.UI_STARTING]: "Đang bật Aivin trên máy này…",
|
|
284
284
|
[MascotText.UI_STARTED]: "Đã bật Aivin chạy nền — linh vật hiện trong giây lát.",
|
|
285
|
-
[MascotText.UI_NOT_PAIRED]: "Máy này chưa kết nối Aivin.
|
|
285
|
+
[MascotText.UI_NOT_PAIRED]: "Máy này chưa kết nối Aivin. Bấm biểu tượng Aivin ở khay hệ thống rồi chọn ‘Đăng nhập để kết nối’.",
|
|
286
286
|
[MascotText.UI_START_FAILED]: "Chưa bật được Aivin chạy nền — chạy: aivin remote start",
|
|
287
287
|
},
|
|
288
288
|
en: {
|
|
@@ -418,7 +418,7 @@ const STRINGS = {
|
|
|
418
418
|
[MascotText.UI_SHOWN]: "The Aivin mascot is on screen — type or click the mic to ask.",
|
|
419
419
|
[MascotText.UI_STARTING]: "Starting Aivin on this computer…",
|
|
420
420
|
[MascotText.UI_STARTED]: "Aivin is running in the background — the mascot shows up in a moment.",
|
|
421
|
-
[MascotText.UI_NOT_PAIRED]: "This computer is not connected to Aivin
|
|
421
|
+
[MascotText.UI_NOT_PAIRED]: "This computer is not connected to Aivin. Click the Aivin system tray icon and choose ‘Sign in to connect’.",
|
|
422
422
|
[MascotText.UI_START_FAILED]: "Could not start Aivin in the background — run: aivin remote start",
|
|
423
423
|
},
|
|
424
424
|
};
|
package/docs/AIVIN_MASCOT.md
CHANGED
|
@@ -34,7 +34,7 @@ To show the mascot and open its ask box directly, run:
|
|
|
34
34
|
aivin ui
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
If the listener is not running, `aivin ui` starts it in the background. If the computer has not been paired, the
|
|
37
|
+
If the listener is not running, `aivin ui` starts it in the background. If the computer has not been paired, click the Aivin system tray icon and choose **Sign in to connect**. Aivin opens the usual browser sign-in, links this computer, then starts the listener. The one-time pairing code remains available as a fallback from Aivin Web.
|
|
38
38
|
|
|
39
39
|
## Using the mascot
|
|
40
40
|
|