@aivin-labs/cli 1.0.31 → 1.0.34
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 +2 -0
- package/bin/cli.mjs +10 -3
- package/bin/lib/remote/desktop/fileAssociation.mjs +4 -1
- package/bin/lib/remote/desktop/strings.mjs +4 -4
- package/bin/lib/remote/desktop/traySource.mjs +57 -5
- package/bin/lib/remote/mascot/hostSource.mjs +1 -1
- package/docs/CLI.md +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,6 +111,8 @@ Self-contained standalone single-file binaries are available for every major ope
|
|
|
111
111
|
irm https://get.aivin.vn/install.ps1 | iex
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
Reinstalling selects the matching Aivin server from the download domain (`get.aivin.vn` → `api.aivin.vn`). To keep a previously selected server instead, run `$env:AIVIN_PRESERVE_SERVER='1'; irm https://get.aivin.vn/install.ps1 | iex`.
|
|
115
|
+
|
|
114
116
|
```bash
|
|
115
117
|
# macOS (Intel / Apple Silicon) and Linux (x64 / arm64)
|
|
116
118
|
curl -fsSL https://get.aivin.vn/install.sh | sh
|
package/bin/cli.mjs
CHANGED
|
@@ -833,8 +833,10 @@ mcpCommand
|
|
|
833
833
|
program
|
|
834
834
|
.command('server [target]')
|
|
835
835
|
.description('Show or switch the active Aivin server (cloud, vn, local, or a URL)')
|
|
836
|
-
.
|
|
836
|
+
.option('--force', 'Switch servers without asking before stopping the current remote connection')
|
|
837
|
+
.action(async (target, command) => {
|
|
837
838
|
try {
|
|
839
|
+
const options = command.opts();
|
|
838
840
|
const current = normalizeServerUrl(process.env.AIVIN_BASE_URL || readActiveServer() || DEFAULT_AIVIN_BASE_URL);
|
|
839
841
|
if (!target) {
|
|
840
842
|
console.log(`Máy chủ đang chọn: ${serverLabel(current)} (${current})`);
|
|
@@ -842,9 +844,14 @@ program
|
|
|
842
844
|
return;
|
|
843
845
|
}
|
|
844
846
|
const next = normalizeServerUrl(target);
|
|
845
|
-
if (next === current)
|
|
847
|
+
if (next === current) {
|
|
848
|
+
// An explicit selection should persist even when the value currently comes only from
|
|
849
|
+
// AIVIN_BASE_URL or the built-in default; desktop launchers read server.json themselves.
|
|
850
|
+
if (!readActiveServer()) setActiveServer(next);
|
|
851
|
+
return console.log(`Đang dùng ${serverLabel(next)} (${next}).`);
|
|
852
|
+
}
|
|
846
853
|
const holder = lockHolder();
|
|
847
|
-
if (holder) {
|
|
854
|
+
if (holder && !options.force) {
|
|
848
855
|
const { proceed } = await inquirer.prompt([{
|
|
849
856
|
type: 'confirm', name: 'proceed', default: false,
|
|
850
857
|
message: `Đổi sang ${serverLabel(next)} sẽ dừng daemon PID ${holder} và huỷ việc đang chạy. Tiếp tục?`,
|
|
@@ -16,7 +16,8 @@ export const OPEN_WITH_PROGID = 'Aivin.OpenFile';
|
|
|
16
16
|
const VERB = 'AivinOpen';
|
|
17
17
|
const HKCU_SOFTWARE = 'HKCU\\Software';
|
|
18
18
|
const CAPABILITIES_PATH = 'AivinLabs\\AIVIN Bot\\Capabilities';
|
|
19
|
-
const REGISTERED_APP_NAME = 'AIVIN
|
|
19
|
+
const REGISTERED_APP_NAME = 'AIVIN Office Suite';
|
|
20
|
+
const LEGACY_REGISTERED_APP_NAME = 'AIVIN Bot';
|
|
20
21
|
|
|
21
22
|
/** Đuôi Drive nhận và mở được bằng trình soạn / trình xem (OfficeUploadExtensionHelper.ts phía be). */
|
|
22
23
|
export const OPEN_WITH_EXTENSIONS = Object.freeze([
|
|
@@ -158,6 +159,7 @@ export function associationStamp({ exe, lang = 'en', extensions = OPEN_WITH_EXTE
|
|
|
158
159
|
export function registerFileAssociations({ exe, lang = 'en', extensions = OPEN_WITH_EXTENSIONS } = {}) {
|
|
159
160
|
if (process.platform !== 'win32') return { registered: false };
|
|
160
161
|
for (const args of associationRegCommands({ exe, lang, extensions })) reg(args);
|
|
162
|
+
regDelete([`${HKCU_SOFTWARE}\\RegisteredApplications`, '/v', LEGACY_REGISTERED_APP_NAME]);
|
|
161
163
|
return { registered: true, extensions: [...extensions] };
|
|
162
164
|
}
|
|
163
165
|
|
|
@@ -180,6 +182,7 @@ export function unregisterFileAssociations({ extensions = OPEN_WITH_EXTENSIONS,
|
|
|
180
182
|
if (process.platform !== 'win32') return;
|
|
181
183
|
const CLASSES = `${root}\\Classes`;
|
|
182
184
|
regDelete([`${root}\\RegisteredApplications`, '/v', REGISTERED_APP_NAME]);
|
|
185
|
+
regDelete([`${root}\\RegisteredApplications`, '/v', LEGACY_REGISTERED_APP_NAME]);
|
|
183
186
|
regDelete([`${root}\\AivinLabs`]);
|
|
184
187
|
for (const ext of extensions) {
|
|
185
188
|
regDelete([`${CLASSES}\\.${ext}\\OpenWithProgids`, '/v', OPEN_WITH_PROGID]);
|
|
@@ -45,12 +45,12 @@ export const TRAY_STRINGS = Object.freeze({
|
|
|
45
45
|
connectFailed: 'Chưa kết nối được. Hãy thử lại hoặc dùng mã kết nối.',
|
|
46
46
|
connectDone: 'Đã kết nối máy tính này với Aivin Cloud.',
|
|
47
47
|
shortcut: 'Aivin — cho các agent Aivin làm việc trên máy tính này',
|
|
48
|
-
openWith: 'Mở bằng AIVIN
|
|
48
|
+
openWith: 'Mở bằng AIVIN Office Suite',
|
|
49
49
|
share: 'Gửi cho AIVIN Bot',
|
|
50
50
|
workHere: 'Làm việc ở đây với AIVIN Bot',
|
|
51
51
|
uninstallPrompt: 'Gỡ AIVIN Bot khỏi máy này?\n\nỨng dụng, lệnh aivin và kết nối của máy với tài khoản sẽ bị xoá.\nCó xoá luôn dữ liệu (ghi nhớ của bot, bản sao tệp để hoàn tác, phiên đăng nhập trình duyệt)? Xoá rồi không lấy lại được.\n\nYes = gỡ và xoá dữ liệu\nNo = gỡ, giữ dữ liệu\nCancel = không gỡ',
|
|
52
52
|
uninstallFailed: 'Không gỡ tự động được. Mở Terminal và chạy: aivin uninstall',
|
|
53
|
-
fileType: 'Tài liệu mở bằng AIVIN
|
|
53
|
+
fileType: 'Tài liệu mở bằng AIVIN Office Suite',
|
|
54
54
|
},
|
|
55
55
|
en: {
|
|
56
56
|
running: 'Running — ready for work',
|
|
@@ -97,12 +97,12 @@ export const TRAY_STRINGS = Object.freeze({
|
|
|
97
97
|
connectFailed: 'Could not connect. Try again or use a connect code.',
|
|
98
98
|
connectDone: 'This computer is connected to Aivin Cloud.',
|
|
99
99
|
shortcut: 'Aivin — lets your Aivin agents work on this computer',
|
|
100
|
-
openWith: 'Open with AIVIN
|
|
100
|
+
openWith: 'Open with AIVIN Office Suite',
|
|
101
101
|
share: 'Share with AIVIN Bot',
|
|
102
102
|
workHere: 'Work here with AIVIN Bot',
|
|
103
103
|
uninstallPrompt: 'Remove AIVIN Bot from this computer?\n\nThe app, the aivin command and this computer\'s connection to your account will be removed.\nAlso delete your data (the bot\'s memory, file copies kept for undo, browser sign-ins)? This cannot be undone.\n\nYes = remove and delete data\nNo = remove, keep data\nCancel = do not remove',
|
|
104
104
|
uninstallFailed: 'Could not remove it automatically. Open a terminal and run: aivin uninstall',
|
|
105
|
-
fileType: 'Document opened with AIVIN
|
|
105
|
+
fileType: 'Document opened with AIVIN Office Suite',
|
|
106
106
|
},
|
|
107
107
|
});
|
|
108
108
|
|
|
@@ -61,7 +61,10 @@ namespace AivinDesktop {
|
|
|
61
61
|
if (!created) {
|
|
62
62
|
// Double-click Aivin.exe / Start menu mở platform; lệnh nội bộ vẫn chỉ đánh thức linh vật.
|
|
63
63
|
if (quit) Signal("Local\\AivinTrayQuit-" + id);
|
|
64
|
-
else if (openPlatform)
|
|
64
|
+
else if (openPlatform) {
|
|
65
|
+
TrayApp.OpenPlatformNow();
|
|
66
|
+
Signal("Local\\AivinTrayOpen-" + id);
|
|
67
|
+
}
|
|
65
68
|
else if (args.Length == 0) platformLaunch.Set();
|
|
66
69
|
else if (!autostart && !installed) Signal("Local\\AivinTrayOpen-" + id);
|
|
67
70
|
return 0;
|
|
@@ -88,7 +91,11 @@ namespace AivinDesktop {
|
|
|
88
91
|
*/
|
|
89
92
|
static int OpenFiles(string[] args, int from) {
|
|
90
93
|
Config cfg = Config.Load(Path.Combine(Path.Combine(Home, "desktop"), "launch.cfg"));
|
|
91
|
-
if (
|
|
94
|
+
if (from >= args.Length) return 1;
|
|
95
|
+
if (string.IsNullOrEmpty(cfg.Exe)) {
|
|
96
|
+
MessageBox.Show("The launch configuration is missing. Run aivin desktop install to repair AIVIN Office Suite.", "AIVIN Office Suite", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
97
|
+
return 1;
|
|
98
|
+
}
|
|
92
99
|
StringBuilder line = new StringBuilder();
|
|
93
100
|
foreach (string a in cfg.Args) {
|
|
94
101
|
if (a == "remote") break;
|
|
@@ -101,7 +108,11 @@ namespace AivinDesktop {
|
|
|
101
108
|
psi.CreateNoWindow = true;
|
|
102
109
|
psi.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
|
103
110
|
psi.EnvironmentVariables["AIVIN_OPEN_UI"] = "toast";
|
|
104
|
-
try { Process.Start(psi); return 0; }
|
|
111
|
+
try { Process.Start(psi); return 0; }
|
|
112
|
+
catch (Exception ex) {
|
|
113
|
+
MessageBox.Show("AIVIN Office Suite could not start the file handler.\n\n" + ex.Message, "AIVIN Office Suite", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
114
|
+
return 1;
|
|
115
|
+
}
|
|
105
116
|
}
|
|
106
117
|
|
|
107
118
|
/**
|
|
@@ -670,6 +681,14 @@ namespace AivinDesktop {
|
|
|
670
681
|
});
|
|
671
682
|
}
|
|
672
683
|
|
|
684
|
+
static int CompareVersions(string left, string right) {
|
|
685
|
+
string a = (left ?? "").Trim().TrimStart('v', 'V').Split('-')[0].Split('+')[0];
|
|
686
|
+
string b = (right ?? "").Trim().TrimStart('v', 'V').Split('-')[0].Split('+')[0];
|
|
687
|
+
Version av, bv;
|
|
688
|
+
if (Version.TryParse(a, out av) && Version.TryParse(b, out bv)) return av.CompareTo(bv);
|
|
689
|
+
return string.Compare(left, right, StringComparison.OrdinalIgnoreCase);
|
|
690
|
+
}
|
|
691
|
+
|
|
673
692
|
void Refresh() {
|
|
674
693
|
bool paired = HasPairedServer();
|
|
675
694
|
bool paused = File.Exists(PausedFile);
|
|
@@ -700,10 +719,14 @@ namespace AivinDesktop {
|
|
|
700
719
|
if (isUpdating) {
|
|
701
720
|
updateItem.Text = cfg.T("updateUpdating");
|
|
702
721
|
updateItem.Enabled = false;
|
|
703
|
-
} else if (!string.IsNullOrEmpty(siteLatest) &&
|
|
722
|
+
} else if (!string.IsNullOrEmpty(siteLatest) && CompareVersions(siteLatest, ver) > 0) {
|
|
704
723
|
updateItem.Text = "★ " + cfg.T("updateAvailable").Replace("{version}", siteLatest);
|
|
705
724
|
updateItem.Font = new Font(updateItem.Font, FontStyle.Bold);
|
|
706
725
|
updateItem.Enabled = true;
|
|
726
|
+
} else if (!string.IsNullOrEmpty(siteLatest)) {
|
|
727
|
+
updateItem.Text = "✓ " + cfg.T("updateUpToDate") + " (" + ver + ")";
|
|
728
|
+
updateItem.Font = new Font(updateItem.Font, FontStyle.Regular);
|
|
729
|
+
updateItem.Enabled = true;
|
|
707
730
|
} else {
|
|
708
731
|
updateItem.Text = cfg.T("updateCheckNow") + " (" + ver + ")";
|
|
709
732
|
updateItem.Font = new Font(updateItem.Font, FontStyle.Regular);
|
|
@@ -831,6 +854,9 @@ namespace AivinDesktop {
|
|
|
831
854
|
}
|
|
832
855
|
}
|
|
833
856
|
} catch { }
|
|
857
|
+
if (api == "https://api.aivin.vn") return "https://brain.aivin.vn";
|
|
858
|
+
if (api == "https://beta-api.aivin.vn") return "https://beta.aivin.vn";
|
|
859
|
+
if (api == "https://api.aivin.cloud") return "https://brain.aivin.cloud";
|
|
834
860
|
return "https://brain.aivin.cloud";
|
|
835
861
|
}
|
|
836
862
|
|
|
@@ -866,15 +892,41 @@ namespace AivinDesktop {
|
|
|
866
892
|
// Unknown default browsers keep their own profile/session via the normal URL handler.
|
|
867
893
|
if (exe == null && progId.Length == 0) exe = BrowserPath("edge") ?? BrowserPath("chrome");
|
|
868
894
|
if (exe != null) {
|
|
869
|
-
ProcessStartInfo app = new ProcessStartInfo(exe, "--app=\"" + url + "\"");
|
|
895
|
+
ProcessStartInfo app = new ProcessStartInfo(exe, "--app=\"" + url + "\" --start-maximized");
|
|
870
896
|
app.UseShellExecute = false;
|
|
897
|
+
IntPtr before = GetForegroundWindow();
|
|
871
898
|
Process.Start(app);
|
|
899
|
+
MaximizeLaunchedBrowser(exe, before);
|
|
872
900
|
return;
|
|
873
901
|
}
|
|
874
902
|
} catch { }
|
|
875
903
|
try { Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); } catch { }
|
|
876
904
|
}
|
|
877
905
|
|
|
906
|
+
[DllImport("user32.dll")] static extern IntPtr GetForegroundWindow();
|
|
907
|
+
[DllImport("user32.dll")] static extern bool ShowWindowAsync(IntPtr window, int command);
|
|
908
|
+
[DllImport("user32.dll")] static extern uint GetWindowThreadProcessId(IntPtr window, out uint processId);
|
|
909
|
+
|
|
910
|
+
static void MaximizeLaunchedBrowser(string exe, IntPtr previousWindow) {
|
|
911
|
+
string expectedProcess = Path.GetFileNameWithoutExtension(exe);
|
|
912
|
+
for (int i = 0; i < 30; i++) {
|
|
913
|
+
IntPtr window = GetForegroundWindow();
|
|
914
|
+
if (window != IntPtr.Zero && window != previousWindow) {
|
|
915
|
+
uint processId;
|
|
916
|
+
GetWindowThreadProcessId(window, out processId);
|
|
917
|
+
try {
|
|
918
|
+
using (Process owner = Process.GetProcessById((int)processId)) {
|
|
919
|
+
if (string.Equals(owner.ProcessName, expectedProcess, StringComparison.OrdinalIgnoreCase)) {
|
|
920
|
+
ShowWindowAsync(window, 3); // SW_MAXIMIZE
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
} catch { }
|
|
925
|
+
}
|
|
926
|
+
Thread.Sleep(100);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
878
930
|
internal static void OpenPlatformNow() { LaunchPlatformApp(); }
|
|
879
931
|
|
|
880
932
|
/** 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. */
|
|
@@ -563,7 +563,7 @@ $script:topTimer.Start()
|
|
|
563
563
|
# change: the bot sits at the anchor inside it, the boxes (ask box, bubble, activity panel) are laid out around the bot (ArrangeBoxes).
|
|
564
564
|
$wa = [Windows.SystemParameters]::WorkArea
|
|
565
565
|
$script:cx = if ($cfg.x -ne $null) { [double]$cfg.x } else { $wa.Right - 76 }
|
|
566
|
-
$script:cy = if ($cfg.y -ne $null) { [double]$cfg.y } else { $
|
|
566
|
+
$script:cy = if ($cfg.y -ne $null) { [double]$cfg.y } else { [Windows.SystemParameters]::PrimaryScreenHeight - ${MASCOT_BOX.h - MASCOT_CENTER.y} }
|
|
567
567
|
# Bot center inside the window (DIPs).
|
|
568
568
|
$script:mx = ${WINDOW.w / 2}; $script:my = ${WINDOW.h - ROOT_MARGIN - (MASCOT_BOX.h - MASCOT_CENTER.y)}
|
|
569
569
|
function DeviceScale {
|
package/docs/CLI.md
CHANGED
|
@@ -1008,6 +1008,8 @@ aivin server local:3247 # localhost on a custom port
|
|
|
1008
1008
|
aivin server https://host # self-hosted server
|
|
1009
1009
|
```
|
|
1010
1010
|
|
|
1011
|
+
`aivin server <target> --force` skips the confirmation before stopping a running remote connection. Installers use this when applying the environment selected by their download domain. Reinstalling from a different Aivin domain can require pairing the computer again on that server. Set `AIVIN_PRESERVE_SERVER=1` before reinstalling to keep the current server.
|
|
1012
|
+
|
|
1011
1013
|
Aivin-owned `*.aivin.cloud` and `*.aivin.vn` hosts resolve to their API host, while explicit API hosts are retained. Only localhost accepts HTTP. The tray menu also has Cloud, VN, and Local choices. Switching servers with a running daemon asks before stopping its current work; the tray then reconnects using that server?s saved pairing, or asks to pair if none exists. Pairing codes are server-specific, so include `--server` when a code was created on a non-default server.
|
|
1012
1014
|
## `aivin whoami`
|
|
1013
1015
|
|