@aivin-labs/cli 1.0.32 → 1.0.35
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
|
@@ -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,7 +833,8 @@ 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, options) => {
|
|
837
838
|
try {
|
|
838
839
|
const current = normalizeServerUrl(process.env.AIVIN_BASE_URL || readActiveServer() || DEFAULT_AIVIN_BASE_URL);
|
|
839
840
|
if (!target) {
|
|
@@ -849,7 +850,7 @@ program
|
|
|
849
850
|
return console.log(`Đang dùng ${serverLabel(next)} (${next}).`);
|
|
850
851
|
}
|
|
851
852
|
const holder = lockHolder();
|
|
852
|
-
if (holder) {
|
|
853
|
+
if (holder && !options.force) {
|
|
853
854
|
const { proceed } = await inquirer.prompt([{
|
|
854
855
|
type: 'confirm', name: 'proceed', default: false,
|
|
855
856
|
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
|
/**
|
|
@@ -883,13 +894,39 @@ namespace AivinDesktop {
|
|
|
883
894
|
if (exe != null) {
|
|
884
895
|
ProcessStartInfo app = new ProcessStartInfo(exe, "--app=\"" + url + "\" --start-maximized");
|
|
885
896
|
app.UseShellExecute = false;
|
|
897
|
+
IntPtr before = GetForegroundWindow();
|
|
886
898
|
Process.Start(app);
|
|
899
|
+
MaximizeLaunchedBrowser(exe, before);
|
|
887
900
|
return;
|
|
888
901
|
}
|
|
889
902
|
} catch { }
|
|
890
903
|
try { Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); } catch { }
|
|
891
904
|
}
|
|
892
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
|
+
|
|
893
930
|
internal static void OpenPlatformNow() { LaunchPlatformApp(); }
|
|
894
931
|
|
|
895
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. */
|
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
|
|