@aivin-labs/cli 1.0.8 → 1.0.13
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 +41 -0
- package/bin/assets/aivin-mascot.png +0 -0
- package/bin/cli.mjs +1979 -1780
- package/bin/lib/browserAutomation.mjs +232 -469
- package/bin/lib/localBrowser.mjs +345 -0
- package/bin/lib/remote/activityLog.mjs +1 -1
- package/bin/lib/remote/autoStart.mjs +174 -14
- package/bin/lib/remote/browserTunnel.mjs +187 -37
- package/bin/lib/remote/callLedger.mjs +74 -15
- package/bin/lib/remote/cdpPolicy.mjs +14 -1
- package/bin/lib/remote/client.mjs +174 -11
- package/bin/lib/remote/clipboard.mjs +138 -0
- package/bin/lib/remote/cloudFiles.mjs +53 -0
- package/bin/lib/remote/codingAgents.mjs +293 -0
- package/bin/lib/remote/constants.mjs +78 -0
- package/bin/lib/remote/dailyBrowser.mjs +9 -3
- package/bin/lib/remote/desktop/desktopCast.mjs +198 -0
- package/bin/lib/remote/desktop/desktopCastSource.mjs +514 -0
- package/bin/lib/remote/desktop/desktopWebRtc.mjs +95 -0
- package/bin/lib/remote/desktop/index.mjs +309 -0
- package/bin/lib/remote/desktop/linux.mjs +144 -0
- package/bin/lib/remote/desktop/linuxTraySource.mjs +434 -0
- package/bin/lib/remote/desktop/mac.mjs +187 -0
- package/bin/lib/remote/desktop/macTraySource.mjs +295 -0
- package/bin/lib/remote/desktop/strings.mjs +74 -0
- package/bin/lib/remote/desktop/traySource.mjs +541 -0
- package/bin/lib/remote/deviceProfile.mjs +1 -0
- package/bin/lib/remote/docText.mjs +86 -1
- package/bin/lib/remote/fileIndexer.mjs +757 -399
- package/bin/lib/remote/folderRules.mjs +140 -0
- package/bin/lib/remote/gui/index.mjs +208 -18
- package/bin/lib/remote/gui/windowsHost.mjs +9 -2
- package/bin/lib/remote/gui/windowsHostSource.mjs +444 -49
- package/bin/lib/remote/idempotency.mjs +50 -21
- package/bin/lib/remote/localPolicy.mjs +17 -4
- package/bin/lib/remote/mascot/adpcm.mjs +70 -0
- package/bin/lib/remote/mascot/ask.mjs +768 -0
- package/bin/lib/remote/mascot/askHostSource.mjs +530 -0
- package/bin/lib/remote/mascot/assets.mjs +825 -216
- package/bin/lib/remote/mascot/bot.mjs +397 -0
- package/bin/lib/remote/mascot/hostSource.mjs +500 -103
- package/bin/lib/remote/mascot/hotkey.mjs +66 -0
- package/bin/lib/remote/mascot/index.mjs +199 -28
- package/bin/lib/remote/mascot/labels.mjs +2 -3
- package/bin/lib/remote/mascot/rigSource.mjs +614 -0
- package/bin/lib/remote/mascot/strings.mjs +204 -18
- package/bin/lib/remote/mascot/ui.mjs +104 -0
- package/bin/lib/remote/mascot/voiceSource.mjs +584 -0
- package/bin/lib/remote/meeting/index.mjs +415 -0
- package/bin/lib/remote/meeting/recorder.mjs +109 -0
- package/bin/lib/remote/meeting/recorderSource.mjs +394 -0
- package/bin/lib/remote/meeting/transcribe.mjs +259 -0
- package/bin/lib/remote/osSearch.mjs +107 -0
- package/bin/lib/remote/sqliteDb.mjs +51 -0
- package/bin/lib/remote/tabGroups.mjs +209 -0
- package/bin/lib/remote/toolHandlers.mjs +788 -726
- package/bin/lib/remoteControl.mjs +26 -26
- package/docs/AIVIN_MASCOT.md +130 -0
- package/docs/CLI.md +1504 -1353
- package/docs/media/aivin-mascot-live.gif +0 -0
- package/docs/media/aivin-mascot-live.png +0 -0
- package/docs/media/aivin-remote-architecture.svg +102 -0
- package/package.json +71 -71
|
@@ -45,6 +45,67 @@ export const MascotText = Object.freeze({
|
|
|
45
45
|
CMD_STATUS_OFF: 'cmd_status_off',
|
|
46
46
|
CMD_UNSUPPORTED: 'cmd_unsupported',
|
|
47
47
|
CMD_USAGE: 'cmd_usage',
|
|
48
|
+
ASK_HINT: 'ask_hint',
|
|
49
|
+
ASK_LOG: 'ask_log',
|
|
50
|
+
ASK_SEND: 'ask_send',
|
|
51
|
+
ASK_MIC: 'ask_mic',
|
|
52
|
+
ASK_THINKING: 'ask_thinking',
|
|
53
|
+
ASK_NO_MIC: 'ask_no_mic',
|
|
54
|
+
VOICE_CONNECTING: 'voice_connecting',
|
|
55
|
+
VOICE_LISTENING: 'voice_listening',
|
|
56
|
+
VOICE_THINKING: 'voice_thinking',
|
|
57
|
+
VOICE_SPEAKING: 'voice_speaking',
|
|
58
|
+
VOICE_ENDED: 'voice_ended',
|
|
59
|
+
VOICE_TIMED_OUT: 'voice_timed_out',
|
|
60
|
+
VOICE_RECORDING: 'voice_recording',
|
|
61
|
+
VOICE_IDLE_ENDED: 'voice_idle_ended',
|
|
62
|
+
VOICE_MIC_BUSY: 'voice_mic_busy',
|
|
63
|
+
VOICE_HINT_END: 'voice_hint_end',
|
|
64
|
+
VOICE_HINT_INTERRUPT: 'voice_hint_interrupt',
|
|
65
|
+
VOICE_HINT_SEND: 'voice_hint_send',
|
|
66
|
+
ASK_TRANSCRIBING: 'ask_transcribing',
|
|
67
|
+
ASK_TOO_SHORT: 'ask_too_short',
|
|
68
|
+
ASK_OFFLINE: 'ask_offline',
|
|
69
|
+
ASK_ERR_BUSY: 'ask_err_busy',
|
|
70
|
+
ASK_BUSY_VOICE: 'ask_busy_voice',
|
|
71
|
+
ASK_QUEUED: 'ask_queued',
|
|
72
|
+
ASK_ERR_TOO_LONG: 'ask_err_too_long',
|
|
73
|
+
ASK_ERR_NOT_UNDERSTOOD: 'ask_err_not_understood',
|
|
74
|
+
ASK_ERR_DISABLED: 'ask_err_disabled',
|
|
75
|
+
ASK_ERR_FAILED: 'ask_err_failed',
|
|
76
|
+
ASK_ERR_UNSUPPORTED: 'ask_err_unsupported',
|
|
77
|
+
ASK_ERR_NO_QUESTION: 'ask_err_no_question',
|
|
78
|
+
ASK_ERR_INVALID_ANSWER: 'ask_err_invalid_answer',
|
|
79
|
+
ASK_ATTACHED: 'ask_attached',
|
|
80
|
+
ASK_FILES_LABEL: 'ask_files_label',
|
|
81
|
+
ASK_FILES_DEFAULT: 'ask_files_default',
|
|
82
|
+
DROP_ONE: 'drop_one',
|
|
83
|
+
DROP_MANY: 'drop_many',
|
|
84
|
+
DROP_FULL: 'drop_full',
|
|
85
|
+
AWAY_SUMMARY: 'away_summary',
|
|
86
|
+
AWAY_DONE: 'away_done',
|
|
87
|
+
AWAY_FAILED: 'away_failed',
|
|
88
|
+
AWAY_NEEDS: 'away_needs',
|
|
89
|
+
ASK_MORE: 'ask_more',
|
|
90
|
+
ASK_NO_REPLY: 'ask_no_reply',
|
|
91
|
+
ASK_STOP: 'ask_stop',
|
|
92
|
+
NEW_CHAT: 'new_chat',
|
|
93
|
+
NEW_CHAT_TIP: 'new_chat_tip',
|
|
94
|
+
ASK_NEW_CHAT_DONE: 'ask_new_chat_done',
|
|
95
|
+
ASK_CANCELLED: 'ask_cancelled',
|
|
96
|
+
ASK_ANSWERED_ELSEWHERE: 'ask_answered_elsewhere',
|
|
97
|
+
FORM_FIELD: 'form_field',
|
|
98
|
+
FORM_OPTIONAL: 'form_optional',
|
|
99
|
+
FORM_SKIP: 'form_skip',
|
|
100
|
+
ASK_CONFIRM: 'ask_confirm',
|
|
101
|
+
NOTIFY_DONE: 'notify_done',
|
|
102
|
+
NOTIFY_FAILED: 'notify_failed',
|
|
103
|
+
NOTIFY_NEEDS_YOU: 'notify_needs_you',
|
|
104
|
+
UI_SHOWN: 'ui_shown',
|
|
105
|
+
UI_STARTING: 'ui_starting',
|
|
106
|
+
UI_STARTED: 'ui_started',
|
|
107
|
+
UI_NOT_PAIRED: 'ui_not_paired',
|
|
108
|
+
UI_START_FAILED: 'ui_start_failed',
|
|
48
109
|
});
|
|
49
110
|
|
|
50
111
|
/** Động từ cho bước không có mục đích (bước chỉ đọc — Planner không ghi `purpose`). Khoá = tên công cụ hoặc tiền tố kết thúc bằng '.'. */
|
|
@@ -57,11 +118,11 @@ export const MascotVerb = Object.freeze({
|
|
|
57
118
|
const STRINGS = {
|
|
58
119
|
vi: {
|
|
59
120
|
[MascotText.WINDOW_TITLE]: 'Aivin trên máy này',
|
|
60
|
-
[MascotText.TOOLTIP]: 'Aivin — bấm để
|
|
121
|
+
[MascotText.TOOLTIP]: 'Aivin — bấm để hỏi, kéo để di chuyển, thả tệp vào để hỏi về tệp',
|
|
61
122
|
[MascotText.PANEL_TITLE]: 'Aivin trên máy này',
|
|
62
123
|
[MascotText.NOW_LABEL]: 'ĐANG LÀM',
|
|
63
124
|
[MascotText.LOG_LABEL]: 'NHẬT KÝ',
|
|
64
|
-
[MascotText.NOTHING_YET]: 'Chưa có việc nào
|
|
125
|
+
[MascotText.NOTHING_YET]: 'Chưa có việc nào.',
|
|
65
126
|
[MascotText.PAUSE]: 'Tạm dừng AI',
|
|
66
127
|
[MascotText.RESUME]: 'Cho AI làm tiếp',
|
|
67
128
|
[MascotText.HIDE]: 'Ẩn tới khi có việc',
|
|
@@ -77,14 +138,14 @@ const STRINGS = {
|
|
|
77
138
|
[MascotText.STATE_ERROR]: 'Có lỗi',
|
|
78
139
|
[MascotText.READY]: 'Sẵn sàng nhận việc',
|
|
79
140
|
[MascotText.CONNECTED]: 'Đã kết nối máy chủ Aivin',
|
|
80
|
-
[MascotText.DISCONNECTED]: 'Mất kết nối
|
|
81
|
-
[MascotText.PAUSED]: 'Đã tạm dừng
|
|
82
|
-
[MascotText.RESUMED]: 'AI làm
|
|
83
|
-
[MascotText.THINKING]: 'Đang
|
|
141
|
+
[MascotText.DISCONNECTED]: 'Mất kết nối, đang nối lại…',
|
|
142
|
+
[MascotText.PAUSED]: 'Đã tạm dừng AI',
|
|
143
|
+
[MascotText.RESUMED]: 'AI làm tiếp',
|
|
144
|
+
[MascotText.THINKING]: 'Đang nghĩ…',
|
|
84
145
|
[MascotText.DONE_ONE]: 'Xong',
|
|
85
146
|
[MascotText.DONE_MANY]: 'Xong {count} bước',
|
|
86
|
-
[MascotText.FAILED]: '
|
|
87
|
-
[MascotText.WAITING_CONFIRM]: '
|
|
147
|
+
[MascotText.FAILED]: 'Lỗi: {title}',
|
|
148
|
+
[MascotText.WAITING_CONFIRM]: 'Cần bạn duyệt: {title}',
|
|
88
149
|
[MascotText.CONFIRM_ALLOWED]: 'Bạn đã cho phép',
|
|
89
150
|
[MascotText.CONFIRM_REJECTED]: 'Không được cho phép',
|
|
90
151
|
[MascotText.TURNED_OFF]: 'Đã tắt linh vật — bật lại: aivin remote mascot on',
|
|
@@ -96,14 +157,75 @@ const STRINGS = {
|
|
|
96
157
|
[MascotText.CMD_STATUS_OFF]: 'Linh vật: tắt (bật: aivin remote mascot on)',
|
|
97
158
|
[MascotText.CMD_UNSUPPORTED]: 'Linh vật hiện mới có trên Windows.',
|
|
98
159
|
[MascotText.CMD_USAGE]: 'Dùng: aivin remote mascot [on | off]',
|
|
160
|
+
[MascotText.ASK_HINT]: "Hỏi hoặc nhờ Aivin…",
|
|
161
|
+
[MascotText.ASK_LOG]: "Nhật ký",
|
|
162
|
+
[MascotText.ASK_SEND]: "Gửi (Enter)",
|
|
163
|
+
[MascotText.ASK_MIC]: "Nói chuyện với Aivin — bấm để bắt đầu, bấm lần nữa để kết thúc",
|
|
164
|
+
[MascotText.ASK_THINKING]: "Đang xử lý…",
|
|
165
|
+
[MascotText.ASK_NO_MIC]: "Không mở được micro",
|
|
166
|
+
[MascotText.VOICE_CONNECTING]: "Đang kết nối…",
|
|
167
|
+
[MascotText.VOICE_LISTENING]: "Đang nghe…",
|
|
168
|
+
[MascotText.VOICE_THINKING]: "Đang nghĩ…",
|
|
169
|
+
[MascotText.VOICE_SPEAKING]: "Aivin đang nói…",
|
|
170
|
+
[MascotText.VOICE_ENDED]: "Đã kết thúc cuộc nói chuyện",
|
|
171
|
+
[MascotText.VOICE_TIMED_OUT]: "Đã tự kết thúc vì im lặng lâu",
|
|
172
|
+
[MascotText.VOICE_RECORDING]: "Đang ghi âm…",
|
|
173
|
+
[MascotText.VOICE_IDLE_ENDED]: "Đã kết thúc vì im lặng 1 phút",
|
|
174
|
+
[MascotText.VOICE_MIC_BUSY]: "Đang ghi biên bản họp — dừng ghi rồi hãy nói chuyện",
|
|
175
|
+
[MascotText.VOICE_HINT_END]: "Bấm mic để kết thúc",
|
|
176
|
+
[MascotText.VOICE_HINT_INTERRUPT]: "Bấm mic để ngắt lời",
|
|
177
|
+
[MascotText.VOICE_HINT_SEND]: "Nói xong bấm mic để gửi",
|
|
178
|
+
[MascotText.ASK_TRANSCRIBING]: "Đang chuyển giọng nói thành chữ…",
|
|
179
|
+
[MascotText.ASK_TOO_SHORT]: "Đoạn nói quá ngắn — nói lâu hơn một chút",
|
|
180
|
+
[MascotText.ASK_OFFLINE]: "Chưa nối được Aivin, thử lại sau",
|
|
181
|
+
[MascotText.ASK_ERR_BUSY]: "Đang làm việc trước, chờ chút",
|
|
182
|
+
[MascotText.ASK_BUSY_VOICE]: "Đang nói chuyện — kết thúc rồi hãy trả lời",
|
|
183
|
+
[MascotText.ASK_QUEUED]: "(còn {n} câu hỏi nữa)",
|
|
184
|
+
[MascotText.ASK_ERR_TOO_LONG]: "Dài quá, rút gọn nhé",
|
|
185
|
+
[MascotText.ASK_ERR_NOT_UNDERSTOOD]: "Không nghe rõ, nói lại nhé",
|
|
186
|
+
[MascotText.ASK_ERR_DISABLED]: "Chat từ máy đang tạm tắt trên Aivin",
|
|
187
|
+
[MascotText.ASK_ERR_FAILED]: "Chưa gửi được, thử lại sau",
|
|
188
|
+
[MascotText.ASK_ERR_UNSUPPORTED]: "Cần bản Aivin mới hơn",
|
|
189
|
+
[MascotText.ASK_ERR_NO_QUESTION]: "Câu hỏi đã hết hạn hoặc đã được trả lời",
|
|
190
|
+
[MascotText.ASK_ERR_INVALID_ANSWER]: "Chọn một nút hoặc trả lời đúng câu hỏi",
|
|
191
|
+
[MascotText.ASK_ATTACHED]: "📎 {names} — gõ việc cần làm với tệp",
|
|
192
|
+
[MascotText.ASK_FILES_LABEL]: "Tệp trên máy này:",
|
|
193
|
+
[MascotText.ASK_FILES_DEFAULT]: "Xem giúp tôi các tệp này",
|
|
194
|
+
[MascotText.DROP_ONE]: "Thả vào để hỏi về {name}",
|
|
195
|
+
[MascotText.DROP_MANY]: "Thả {n} mục vào để hỏi",
|
|
196
|
+
[MascotText.DROP_FULL]: "Thùng đầy rồi — gửi {n} tệp này trước nhé",
|
|
197
|
+
[MascotText.AWAY_SUMMARY]: "Lúc bạn vắng: {parts}",
|
|
198
|
+
[MascotText.AWAY_DONE]: "{n} việc xong",
|
|
199
|
+
[MascotText.AWAY_FAILED]: "{n} lỗi",
|
|
200
|
+
[MascotText.AWAY_NEEDS]: "{n} cần bạn",
|
|
201
|
+
[MascotText.ASK_MORE]: "(chi tiết trên Aivin)",
|
|
202
|
+
[MascotText.ASK_NO_REPLY]: "Chưa nghe Aivin trả lời — có kết quả sẽ hiện ở đây, hoặc xem trên Aivin",
|
|
203
|
+
[MascotText.ASK_STOP]: "Dừng việc này",
|
|
204
|
+
[MascotText.NEW_CHAT]: "Phiên chat mới",
|
|
205
|
+
[MascotText.NEW_CHAT_TIP]: "Bắt đầu phiên chat mới với Aivin (phiên cũ vẫn xem được trên Aivin)",
|
|
206
|
+
[MascotText.ASK_NEW_CHAT_DONE]: "Đã mở phiên chat mới",
|
|
207
|
+
[MascotText.ASK_CANCELLED]: "Đã dừng",
|
|
208
|
+
[MascotText.ASK_ANSWERED_ELSEWHERE]: "Câu hỏi này đã được trả lời ở nơi khác",
|
|
209
|
+
[MascotText.FORM_FIELD]: "{label} ({n}/{total})",
|
|
210
|
+
[MascotText.FORM_OPTIONAL]: "(không bắt buộc)",
|
|
211
|
+
[MascotText.FORM_SKIP]: "Bỏ qua",
|
|
212
|
+
[MascotText.ASK_CONFIRM]: "Xác nhận ({n})",
|
|
213
|
+
[MascotText.NOTIFY_DONE]: "Xong",
|
|
214
|
+
[MascotText.NOTIFY_FAILED]: "Lỗi",
|
|
215
|
+
[MascotText.NOTIFY_NEEDS_YOU]: "Cần bạn",
|
|
216
|
+
[MascotText.UI_SHOWN]: "Linh vật Aivin đã hiện trên màn hình — gõ hoặc bấm mic để hỏi.",
|
|
217
|
+
[MascotText.UI_STARTING]: "Đang bật Aivin trên máy này…",
|
|
218
|
+
[MascotText.UI_STARTED]: "Đã bật Aivin chạy nền — linh vật hiện trong giây lát.",
|
|
219
|
+
[MascotText.UI_NOT_PAIRED]: "Máy này chưa kết nối Aivin. Lấy mã trong Aivin (ô chat → Trình duyệt → Thêm máy tính này) rồi chạy: aivin remote start --code <mã>",
|
|
220
|
+
[MascotText.UI_START_FAILED]: "Chưa bật được Aivin chạy nền — chạy: aivin remote start",
|
|
99
221
|
},
|
|
100
222
|
en: {
|
|
101
223
|
[MascotText.WINDOW_TITLE]: 'Aivin on this computer',
|
|
102
|
-
[MascotText.TOOLTIP]: 'Aivin — click to
|
|
224
|
+
[MascotText.TOOLTIP]: 'Aivin — click to ask, drag to move, drop files to ask about them',
|
|
103
225
|
[MascotText.PANEL_TITLE]: 'Aivin on this computer',
|
|
104
226
|
[MascotText.NOW_LABEL]: 'NOW',
|
|
105
227
|
[MascotText.LOG_LABEL]: 'ACTIVITY',
|
|
106
|
-
[MascotText.NOTHING_YET]: 'Nothing yet
|
|
228
|
+
[MascotText.NOTHING_YET]: 'Nothing yet.',
|
|
107
229
|
[MascotText.PAUSE]: 'Pause AI',
|
|
108
230
|
[MascotText.RESUME]: 'Let AI continue',
|
|
109
231
|
[MascotText.HIDE]: 'Hide until work',
|
|
@@ -120,13 +242,13 @@ const STRINGS = {
|
|
|
120
242
|
[MascotText.READY]: 'Ready for work',
|
|
121
243
|
[MascotText.CONNECTED]: 'Connected to Aivin',
|
|
122
244
|
[MascotText.DISCONNECTED]: 'Connection lost — reconnecting…',
|
|
123
|
-
[MascotText.PAUSED]: '
|
|
124
|
-
[MascotText.RESUMED]: 'AI
|
|
125
|
-
[MascotText.THINKING]: 'Thinking
|
|
245
|
+
[MascotText.PAUSED]: 'AI paused',
|
|
246
|
+
[MascotText.RESUMED]: 'AI resumed',
|
|
247
|
+
[MascotText.THINKING]: 'Thinking…',
|
|
126
248
|
[MascotText.DONE_ONE]: 'Done',
|
|
127
249
|
[MascotText.DONE_MANY]: 'Done — {count} steps',
|
|
128
|
-
[MascotText.FAILED]: '
|
|
129
|
-
[MascotText.WAITING_CONFIRM]: '
|
|
250
|
+
[MascotText.FAILED]: 'Failed: {title}',
|
|
251
|
+
[MascotText.WAITING_CONFIRM]: 'Needs your OK: {title}',
|
|
130
252
|
[MascotText.CONFIRM_ALLOWED]: 'You allowed it',
|
|
131
253
|
[MascotText.CONFIRM_REJECTED]: 'Not allowed',
|
|
132
254
|
[MascotText.TURNED_OFF]: 'Mascot turned off — turn it back on: aivin remote mascot on',
|
|
@@ -138,6 +260,67 @@ const STRINGS = {
|
|
|
138
260
|
[MascotText.CMD_STATUS_OFF]: 'Mascot: off (turn on: aivin remote mascot on)',
|
|
139
261
|
[MascotText.CMD_UNSUPPORTED]: 'The mascot is only available on Windows for now.',
|
|
140
262
|
[MascotText.CMD_USAGE]: 'Usage: aivin remote mascot [on | off]',
|
|
263
|
+
[MascotText.ASK_HINT]: "Ask Aivin anything…",
|
|
264
|
+
[MascotText.ASK_LOG]: "Activity",
|
|
265
|
+
[MascotText.ASK_SEND]: "Send (Enter)",
|
|
266
|
+
[MascotText.ASK_MIC]: "Talk with Aivin — click to start, click again to end",
|
|
267
|
+
[MascotText.ASK_THINKING]: "Working on it…",
|
|
268
|
+
[MascotText.ASK_NO_MIC]: "Could not open the microphone",
|
|
269
|
+
[MascotText.VOICE_CONNECTING]: "Connecting…",
|
|
270
|
+
[MascotText.VOICE_LISTENING]: "Listening…",
|
|
271
|
+
[MascotText.VOICE_THINKING]: "Thinking…",
|
|
272
|
+
[MascotText.VOICE_SPEAKING]: "Aivin is talking…",
|
|
273
|
+
[MascotText.VOICE_ENDED]: "Conversation ended",
|
|
274
|
+
[MascotText.VOICE_TIMED_OUT]: "Ended after a long silence",
|
|
275
|
+
[MascotText.VOICE_RECORDING]: "Recording…",
|
|
276
|
+
[MascotText.VOICE_IDLE_ENDED]: "Ended after a minute of silence",
|
|
277
|
+
[MascotText.VOICE_MIC_BUSY]: "Recording a meeting — stop it first to talk",
|
|
278
|
+
[MascotText.VOICE_HINT_END]: "Click the mic to end",
|
|
279
|
+
[MascotText.VOICE_HINT_INTERRUPT]: "Click the mic to interrupt",
|
|
280
|
+
[MascotText.VOICE_HINT_SEND]: "Click the mic to send when done",
|
|
281
|
+
[MascotText.ASK_TRANSCRIBING]: "Turning your voice into text…",
|
|
282
|
+
[MascotText.ASK_TOO_SHORT]: "That was too short — talk a bit longer",
|
|
283
|
+
[MascotText.ASK_OFFLINE]: "Not connected to Aivin, try again soon",
|
|
284
|
+
[MascotText.ASK_ERR_BUSY]: "Still on the last one, hold on",
|
|
285
|
+
[MascotText.ASK_BUSY_VOICE]: "In a call — end it to answer",
|
|
286
|
+
[MascotText.ASK_QUEUED]: "({n} more waiting)",
|
|
287
|
+
[MascotText.ASK_ERR_TOO_LONG]: "Too long, please shorten it",
|
|
288
|
+
[MascotText.ASK_ERR_NOT_UNDERSTOOD]: "Could not make that out, try again",
|
|
289
|
+
[MascotText.ASK_ERR_DISABLED]: "Chatting from the computer is turned off on Aivin",
|
|
290
|
+
[MascotText.ASK_ERR_FAILED]: "Could not send, try again",
|
|
291
|
+
[MascotText.ASK_ERR_UNSUPPORTED]: "Needs a newer Aivin server",
|
|
292
|
+
[MascotText.ASK_ERR_NO_QUESTION]: "That question expired or was already answered",
|
|
293
|
+
[MascotText.ASK_ERR_INVALID_ANSWER]: "Pick a button or answer the question",
|
|
294
|
+
[MascotText.ASK_ATTACHED]: "📎 {names} — type what to do with them",
|
|
295
|
+
[MascotText.ASK_FILES_LABEL]: "Files on this computer:",
|
|
296
|
+
[MascotText.ASK_FILES_DEFAULT]: "Take a look at these files",
|
|
297
|
+
[MascotText.DROP_ONE]: "Drop to ask about {name}",
|
|
298
|
+
[MascotText.DROP_MANY]: "Drop {n} items to ask about them",
|
|
299
|
+
[MascotText.DROP_FULL]: "The box is full — send these {n} files first",
|
|
300
|
+
[MascotText.AWAY_SUMMARY]: "While you were away: {parts}",
|
|
301
|
+
[MascotText.AWAY_DONE]: "{n} done",
|
|
302
|
+
[MascotText.AWAY_FAILED]: "{n} failed",
|
|
303
|
+
[MascotText.AWAY_NEEDS]: "{n} need you",
|
|
304
|
+
[MascotText.ASK_MORE]: "(details in Aivin)",
|
|
305
|
+
[MascotText.ASK_NO_REPLY]: "No reply from Aivin yet — the result will show up here, or check Aivin",
|
|
306
|
+
[MascotText.ASK_STOP]: "Stop this",
|
|
307
|
+
[MascotText.NEW_CHAT]: "New chat session",
|
|
308
|
+
[MascotText.NEW_CHAT_TIP]: "Start a new chat with Aivin (the old one stays in Aivin)",
|
|
309
|
+
[MascotText.ASK_NEW_CHAT_DONE]: "Started a new chat",
|
|
310
|
+
[MascotText.ASK_CANCELLED]: "Stopped",
|
|
311
|
+
[MascotText.ASK_ANSWERED_ELSEWHERE]: "This question was already answered elsewhere",
|
|
312
|
+
[MascotText.FORM_FIELD]: "{label} ({n}/{total})",
|
|
313
|
+
[MascotText.FORM_OPTIONAL]: "(optional)",
|
|
314
|
+
[MascotText.FORM_SKIP]: "Skip",
|
|
315
|
+
[MascotText.ASK_CONFIRM]: "Confirm ({n})",
|
|
316
|
+
[MascotText.NOTIFY_DONE]: "Done",
|
|
317
|
+
[MascotText.NOTIFY_FAILED]: "Failed",
|
|
318
|
+
[MascotText.NOTIFY_NEEDS_YOU]: "Needs you",
|
|
319
|
+
[MascotText.UI_SHOWN]: "The Aivin mascot is on screen — type or click the mic to ask.",
|
|
320
|
+
[MascotText.UI_STARTING]: "Starting Aivin on this computer…",
|
|
321
|
+
[MascotText.UI_STARTED]: "Aivin is running in the background — the mascot shows up in a moment.",
|
|
322
|
+
[MascotText.UI_NOT_PAIRED]: "This computer is not connected to Aivin yet. Get a code in Aivin (chat box → Browser → Add this computer), then run: aivin remote start --code <code>",
|
|
323
|
+
[MascotText.UI_START_FAILED]: "Could not start Aivin in the background — run: aivin remote start",
|
|
141
324
|
},
|
|
142
325
|
};
|
|
143
326
|
|
|
@@ -162,9 +345,12 @@ const VERBS = {
|
|
|
162
345
|
|
|
163
346
|
export const SUPPORTED_LANGS = Object.keys(STRINGS);
|
|
164
347
|
|
|
165
|
-
/**
|
|
166
|
-
|
|
167
|
-
|
|
348
|
+
/**
|
|
349
|
+
* Ngôn ngữ của máy: AIVIN_LANG → LANG / LC_ALL (trừ Windows: ở đó chỉ shell kiểu Unix như Git Bash đặt, không phải người dùng chọn) →
|
|
350
|
+
* ngôn ngữ hệ điều hành (Intl); không có bản dịch → en.
|
|
351
|
+
*/
|
|
352
|
+
export function mascotLang(env = process.env, platform = process.platform) {
|
|
353
|
+
const candidates = [env.AIVIN_LANG, ...(platform === 'win32' ? [] : [env.LC_ALL, env.LANG])];
|
|
168
354
|
try { candidates.push(Intl.DateTimeFormat().resolvedOptions().locale); } catch { /* không có Intl */ }
|
|
169
355
|
for (const c of candidates) {
|
|
170
356
|
const code = String(c || '').toLowerCase().split(/[-_.]/)[0];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import readline from 'readline';
|
|
3
|
+
import { execFileSync, spawn } from 'child_process';
|
|
4
|
+
import { WINDOWS_TASK_NAME, cliLaunchCommand } from '../autoStart.mjs';
|
|
5
|
+
import { isDesktopInstalled, launchTray } from '../desktop/index.mjs';
|
|
6
|
+
import { loadDeviceCredentials } from '../credentials.mjs';
|
|
7
|
+
import { lockHolder } from '../daemonLock.mjs';
|
|
8
|
+
import { HostCommand, HostEvent, MASCOT_DIR, MascotState, loadMascotSettings, requestMascotShow, saveMascotSettings, writeHostFiles } from './index.mjs';
|
|
9
|
+
import { mascotLang } from './strings.mjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* `aivin ui` (29/10/2026): hiện linh vật Aivin + mở ô hỏi ngay. Linh vật sống trong daemon `aivin remote start` (cần socket của máy để
|
|
13
|
+
* chat), nên: bật lại nếu đã tắt, ghi yêu cầu hiện cho daemon; daemon chưa chạy → khởi động nó chạy nền (tác vụ Task Scheduler nếu đã
|
|
14
|
+
* `aivin remote enable` — có trình giữ chạy; không thì tiến trình tách rời) rồi chờ nó nhận việc.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const UiResult = Object.freeze({
|
|
18
|
+
SHOWN: 'shown', STARTED: 'started', DEMO: 'demo', NOT_PAIRED: 'not_paired', START_FAILED: 'start_failed', UNSUPPORTED: 'unsupported',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const MASCOT_DEMO_STATES = Object.freeze([
|
|
22
|
+
MascotState.IDLE, MascotState.WORKING, MascotState.THINKING, MascotState.WAITING,
|
|
23
|
+
MascotState.DONE, MascotState.ERROR, MascotState.PAUSED, MascotState.OFFLINE,
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const START_WAIT_MS = 20_000;
|
|
27
|
+
const POLL_MS = 500;
|
|
28
|
+
|
|
29
|
+
function windowsTaskExists() {
|
|
30
|
+
try {
|
|
31
|
+
execFileSync('schtasks', ['/Query', '/TN', WINDOWS_TASK_NAME], { stdio: 'ignore', windowsHide: true, timeout: 10_000 });
|
|
32
|
+
return true;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Daemon chạy nền: ứng dụng khay Aivin.exe / tác vụ tự khởi động cũ (có trình giữ chạy), không thì tiến trình tách rời, không cửa sổ. */
|
|
39
|
+
function startDaemon() {
|
|
40
|
+
if (isDesktopInstalled()) {
|
|
41
|
+
launchTray();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (windowsTaskExists()) {
|
|
45
|
+
execFileSync('schtasks', ['/Run', '/TN', WINDOWS_TASK_NAME], { stdio: 'ignore', windowsHide: true, timeout: 10_000 });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const [cmd, ...args] = cliLaunchCommand();
|
|
49
|
+
spawn(cmd, [...args, 'remote', 'start', '--quiet'], { detached: true, stdio: 'ignore', windowsHide: true }).unref();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function showMascotUi({ platform = process.platform, onStarting = () => {}, sleep = (ms) => new Promise((r) => setTimeout(r, ms)), deps = {} } = {}) {
|
|
53
|
+
const d = { lockHolder, loadDeviceCredentials, requestMascotShow, saveMascotSettings, startDaemon, ...deps };
|
|
54
|
+
if (platform !== 'win32') return UiResult.UNSUPPORTED;
|
|
55
|
+
d.saveMascotSettings({ enabled: true });
|
|
56
|
+
d.requestMascotShow();
|
|
57
|
+
if (d.lockHolder()) return UiResult.SHOWN;
|
|
58
|
+
if (!d.loadDeviceCredentials()) return UiResult.NOT_PAIRED;
|
|
59
|
+
onStarting();
|
|
60
|
+
try {
|
|
61
|
+
d.startDaemon();
|
|
62
|
+
} catch {
|
|
63
|
+
return UiResult.START_FAILED;
|
|
64
|
+
}
|
|
65
|
+
for (let waited = 0; waited < START_WAIT_MS; waited += POLL_MS) {
|
|
66
|
+
await sleep(POLL_MS);
|
|
67
|
+
if (d.lockHolder()) return UiResult.STARTED;
|
|
68
|
+
}
|
|
69
|
+
return UiResult.START_FAILED;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Preview all visual states without pairing or starting the remote listener. The child + interval keep Node alive until the window closes or Ctrl+C. */
|
|
73
|
+
export function showMascotDemo({ platform = process.platform, env = process.env, stateMs = 2600, deps = {} } = {}) {
|
|
74
|
+
if (platform !== 'win32') return UiResult.UNSUPPORTED;
|
|
75
|
+
const d = { spawn, writeHostFiles, loadMascotSettings, setInterval, clearInterval, ...deps };
|
|
76
|
+
let home;
|
|
77
|
+
try {
|
|
78
|
+
home = d.writeHostFiles({ dir: MASCOT_DIR, lang: mascotLang(env), settings: d.loadMascotSettings() });
|
|
79
|
+
const child = d.spawn('powershell.exe', ['-NoProfile', '-NonInteractive', '-STA', '-ExecutionPolicy', 'Bypass', '-File', path.join(home, 'host.ps1')], {
|
|
80
|
+
env: { ...env, AIVIN_MASCOT_DIR: home }, windowsHide: true, stdio: ['pipe', 'pipe', 'pipe'],
|
|
81
|
+
});
|
|
82
|
+
let timer = null;
|
|
83
|
+
let index = 0;
|
|
84
|
+
const send = (message) => {
|
|
85
|
+
try { child.stdin.write(`${JSON.stringify(message)}\n`); } catch { /* preview window closed */ }
|
|
86
|
+
};
|
|
87
|
+
const showState = () => {
|
|
88
|
+
const state = MASCOT_DEMO_STATES[index++ % MASCOT_DEMO_STATES.length];
|
|
89
|
+
send({ t: HostCommand.STATE, state });
|
|
90
|
+
send({ t: HostCommand.MAIN, text: `Demo: ${state}`, quiet: false });
|
|
91
|
+
};
|
|
92
|
+
readline.createInterface({ input: child.stdout }).on('line', (line) => {
|
|
93
|
+
let event;
|
|
94
|
+
try { event = JSON.parse(line); } catch { return; }
|
|
95
|
+
if (event.t === HostEvent.READY && !timer) { showState(); timer = d.setInterval(showState, stateMs); }
|
|
96
|
+
if (event.t === HostEvent.OFF) { send({ t: HostCommand.QUIT }); child.stdin.end(); }
|
|
97
|
+
});
|
|
98
|
+
child.on('close', () => { if (timer) d.clearInterval(timer); });
|
|
99
|
+
child.on('error', () => { if (timer) d.clearInterval(timer); });
|
|
100
|
+
return UiResult.DEMO;
|
|
101
|
+
} catch {
|
|
102
|
+
return UiResult.START_FAILED;
|
|
103
|
+
}
|
|
104
|
+
}
|