hypeframe 0.6.1 → 0.8.0

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 (3) hide show
  1. package/README.md +15 -15
  2. package/dist/index.js +726 -126
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -187,10 +187,10 @@ var id = {
187
187
  "menu.open": "Buka HypeFrame Web",
188
188
  "menu.bench": "Tes kecepatan render",
189
189
  "menu.history": "Riwayat render",
190
- "menu.agent": "Asisten AI di mesin",
190
+ "menu.agent": "Asisten AI",
191
191
  "menu.soon": "segera hadir",
192
192
  "menu.autostart": "Nyala otomatis",
193
- "menu.config": "Pengaturan",
193
+ "menu.config": "Nama, bahasa, dan GPU",
194
194
  "menu.doctor": "Periksa perangkat",
195
195
  "menu.clean": "Bersihkan ruang",
196
196
  "menu.report": "Buat laporan masalah",
@@ -199,14 +199,78 @@ var id = {
199
199
  "menu.logout": "Lepas perangkat dari akun",
200
200
  "menu.exit": "Keluar",
201
201
  "menu.bye": "Sampai jumpa.",
202
+ "relay.fetching": "Render dari perangkat lain: mengambil project ({size})...",
203
+ "relay.sending": "Render dari perangkat lain: mengirim video kembali...",
204
+ "relay.done": "Render dari perangkat lain selesai, video terkirim ({size}).",
205
+ "relay.failed": "Render dari perangkat lain gagal: {reason}",
206
+ "relay.cancelled": "Render dari perangkat lain dibatalkan di sana.",
207
+ "agentLog.starting": "✦ Menyalakan {agent}...",
208
+ "agentLog.ready": "✦ {agent} siap ({sec})",
209
+ "agentLog.chat": "✦ {agent}: obrolan dibuka dari HypeFrame Web",
210
+ "agentLog.chatResumed": "✦ {agent}: obrolan lama dilanjutkan",
211
+ "agentLog.message": "✦ {agent} menerima pesan: “{text}”",
212
+ "agentLog.done": "✦ {agent} selesai menjawab ({sec})",
213
+ "agentLog.cancelled": "{agent} dihentikan dari web",
214
+ "agentLog.error": "✦ {agent} gagal: {message}",
215
+ "agentLog.tool": "{agent} memakai alat HypeFrame: {tool}",
216
+ "agentLog.toolFailed": "✦ {agent}: alat {tool} gagal",
217
+ "agentLog.permission": "✦ {agent} minta izin: {title}. Jawab di HypeFrame Web.",
218
+ "agentLog.permissionCmd": "✦ {agent} minta izin menjalankan: {command}. Jawab di HypeFrame Web.",
219
+ "agentLog.allowed": "diizinkan",
220
+ "agentLog.refused": "ditolak",
221
+ "agentLog.option": "{agent}: {what} diganti ke {value}",
222
+ "agentLog.stopped": "✦ {agent} berhenti (kode {code}). Obrolan baru menyalakannya lagi.",
223
+ "engine.agentsReady": "Asisten AI siap: {list}",
224
+ "engine.agentsNone": "Belum ada asisten AI. Pasang dari menu hypeframe > Asisten AI.",
225
+ "engine.statusHint": "Tekan Enter kapan saja untuk melihat status.",
226
+ "statusNow.title": "Status sekarang",
227
+ "statusNow.connection": "Sambungan",
228
+ "statusNow.connected": "tersambung ke akun",
229
+ "statusNow.offline": "terputus, menyambung lagi...",
230
+ "statusNow.render": "Render",
231
+ "statusNow.renderReady": "siap · Chrome {chrome}",
232
+ "statusNow.renderNot": "belum siap",
233
+ "statusNow.renders": "Render sejak menyala",
234
+ "statusNow.rendersValue": "{done} selesai · {failed} gagal · {running} berjalan",
235
+ "statusNow.agents": "Asisten AI",
236
+ "statusNow.none": "belum ada",
237
+ "statusNow.chats": "Obrolan",
238
+ "statusNow.chatsValue": "{chats} terbuka · {working} sedang bekerja",
239
+ "menu.runningHint": "sedang menyala",
240
+ "menu.agentNone": "belum ada agen",
241
+ "menu.settings": "Pengaturan",
242
+ "menu.settingsHint": "nama, bahasa, nyala otomatis, akun",
243
+ "menu.help": "Bantuan & perawatan",
244
+ "menu.helpHint": "periksa, perbarui, panduan awal",
245
+ "menu.guide": "Panduan awal (langkah demi langkah)",
246
+ "menu.doctorHint": "cari tahu kenapa ada yang tidak jalan",
247
+ "menu.now": "sekarang",
248
+ "menu.cleanHint": "hapus unduhan dan sisa render",
249
+ "menu.reportHint": "untuk dikirim ke tim HypeFrame",
250
+ "menu.configHint": "nama perangkat, bahasa, GPU",
251
+ "guide.title": "Panduan awal",
252
+ "guide.intro": `Beberapa langkah singkat: bahasa, akun HypeFrame, asisten AI, lalu menyalakan mesin.
253
+ Tekan Esc untuk melewati satu langkah. Panduan ini bisa dibuka lagi dari Bantuan & perawatan.`,
254
+ "guide.account": "Sambungkan perangkat ini ke akun HypeFrame sekarang?",
255
+ "guide.agent": "Pilih asisten AI (masuk dengan akunmu sendiri)",
256
+ "guide.later": "Nanti saja",
257
+ "guide.android": "Di HP: biarkan Termux terbuka, dan jalankan termux-wake-lock agar mesin tetap menyala saat layar mati.",
258
+ "guide.start": "Nyalakan mesin sekarang?",
259
+ "agent.accountGoogle": "akun Google",
260
+ "agent.accountChatgpt": "akun ChatGPT (Plus/Pro)",
261
+ "agent.accountOpencode": "penyedia pilihanmu",
262
+ "agent.loginNow": "Masuk akun",
263
+ "agent.removeAsk": "Hapus {name} dari perangkat ini?",
264
+ "agent.nextStart": "Langkah berikutnya: nyalakan mesin, lalu buka HypeFrame Web > Asisten dan pilih {name}.",
265
+ "agent.nextRunning": "Buka HypeFrame Web > Asisten dan pilih {name} (muncul dalam setengah menit).",
202
266
  "agent.soon": "Asisten AI yang bekerja langsung di perangkatmu sedang disiapkan.",
203
267
  "agent.menuQuestion": "Pilih agen. Pasang dan masuk akun sekali di sini, lalu mengobrol dari HypeFrame Web.",
204
268
  "agent.ready": "siap dipakai dari web",
205
269
  "agent.needLogin": "perlu masuk akun",
206
270
  "agent.notInstalled": "belum dipasang",
207
271
  "agent.add": "Pasang dan masuk akun",
208
- "agent.login": "Masuk akun lagi",
209
- "agent.remove": "Lepas dari mesin ini",
272
+ "agent.login": "Masuk akun lagi (ganti akun)",
273
+ "agent.remove": "Hapus dari perangkat ini",
210
274
  "agent.back": "Kembali",
211
275
  "agent.installing": "Memasang {name} dari daftar resmi ACP...",
212
276
  "agent.installed": "{name} {version} terpasang.",
@@ -226,7 +290,16 @@ var id = {
226
290
  "linux.distro": "Mengunduh Ubuntu...",
227
291
  "linux.apt": "Menyiapkan Ubuntu (sertifikat dan curl)...",
228
292
  "linux.ready": "Linux mini siap.",
229
- "linux.openUrl": "Buka di browser HP: {url}",
293
+ "linux.openUrl": "Browser HP dibuka untuk masuk: pilih akunmu di sana, lalu kembali ke Termux. (Kalau tidak terbuka: {url})",
294
+ "agent.loginLink": "Kalau browser tidak terbuka sendiri, buka link ini: {url}",
295
+ "chromium.notNeeded": "Di komputer ini Chrome dipakai langsung (atau diunduh otomatis saat render pertama). Perintah ini untuk HP Android.",
296
+ "chromium.preparing": "Menyiapkan Chromium untuk render di Linux mini (Debian lewat proot). Sekali saja, unduhan sekitar 300 MB...",
297
+ "chromium.distro": "Mengunduh Debian...",
298
+ "chromium.apt": "Memasang Chromium dan font di Debian (bisa beberapa menit)...",
299
+ "chromium.ready": "Chromium siap untuk render.",
300
+ "chromium.restart": "Kalau mesin sedang menyala, matikan lalu jalankan lagi: hypeframe start",
301
+ "chromium.failed": "Chromium belum terpasang: {reason}. Pastikan internet lancar lalu jalankan lagi: hypeframe chromium",
302
+ "help.chromium": "HP Android: pasang Chromium untuk render (untuk Termux dari Google Play)",
230
303
  "agent.keyFromShellAsk": "Pakai {name} yang sudah ada di terminal ini?",
231
304
  "agent.keyFromShell": "Memakai {name} dari terminal ini (disimpan untuk agen ini saja).",
232
305
  "agent.own": "{name} sudah terpasang di komputer ini ({path}); yang itu dipakai, tidak diunduh lagi.",
@@ -361,10 +434,10 @@ var en = {
361
434
  "menu.open": "Open HypeFrame Web",
362
435
  "menu.bench": "Render speed test",
363
436
  "menu.history": "Render history",
364
- "menu.agent": "AI assistant on this machine",
437
+ "menu.agent": "AI assistant",
365
438
  "menu.soon": "coming soon",
366
439
  "menu.autostart": "Start automatically",
367
- "menu.config": "Settings",
440
+ "menu.config": "Name, language and GPU",
368
441
  "menu.doctor": "Check this machine",
369
442
  "menu.clean": "Free up space",
370
443
  "menu.report": "Create a problem report",
@@ -373,14 +446,78 @@ var en = {
373
446
  "menu.logout": "Disconnect this device",
374
447
  "menu.exit": "Exit",
375
448
  "menu.bye": "See you.",
449
+ "relay.fetching": "Render from another device: fetching the project ({size})...",
450
+ "relay.sending": "Render from another device: sending the video back...",
451
+ "relay.done": "Render from another device done, video sent ({size}).",
452
+ "relay.failed": "Render from another device failed: {reason}",
453
+ "relay.cancelled": "Render from another device was cancelled over there.",
454
+ "agentLog.starting": "✦ Starting {agent}...",
455
+ "agentLog.ready": "✦ {agent} is ready ({sec})",
456
+ "agentLog.chat": "✦ {agent}: chat opened from HypeFrame Web",
457
+ "agentLog.chatResumed": "✦ {agent}: earlier chat continued",
458
+ "agentLog.message": "✦ {agent} got a message: “{text}”",
459
+ "agentLog.done": "✦ {agent} finished answering ({sec})",
460
+ "agentLog.cancelled": "{agent} stopped from the web",
461
+ "agentLog.error": "✦ {agent} failed: {message}",
462
+ "agentLog.tool": "{agent} used a HypeFrame tool: {tool}",
463
+ "agentLog.toolFailed": "✦ {agent}: tool {tool} failed",
464
+ "agentLog.permission": "✦ {agent} asks permission: {title}. Answer in HypeFrame Web.",
465
+ "agentLog.permissionCmd": "✦ {agent} asks to run: {command}. Answer in HypeFrame Web.",
466
+ "agentLog.allowed": "allowed",
467
+ "agentLog.refused": "refused",
468
+ "agentLog.option": "{agent}: {what} changed to {value}",
469
+ "agentLog.stopped": "✦ {agent} stopped (code {code}). A new chat starts it again.",
470
+ "engine.agentsReady": "AI assistants ready: {list}",
471
+ "engine.agentsNone": "No AI assistant yet. Add one from the hypeframe menu > AI assistant.",
472
+ "engine.statusHint": "Press Enter at any time to see the status.",
473
+ "statusNow.title": "Status now",
474
+ "statusNow.connection": "Connection",
475
+ "statusNow.connected": "connected to the account",
476
+ "statusNow.offline": "offline, reconnecting...",
477
+ "statusNow.render": "Render",
478
+ "statusNow.renderReady": "ready · Chrome {chrome}",
479
+ "statusNow.renderNot": "not ready",
480
+ "statusNow.renders": "Renders since start",
481
+ "statusNow.rendersValue": "{done} done · {failed} failed · {running} running",
482
+ "statusNow.agents": "AI assistants",
483
+ "statusNow.none": "none yet",
484
+ "statusNow.chats": "Chats",
485
+ "statusNow.chatsValue": "{chats} open · {working} working",
486
+ "menu.runningHint": "running",
487
+ "menu.agentNone": "no agent yet",
488
+ "menu.settings": "Settings",
489
+ "menu.settingsHint": "name, language, start automatically, account",
490
+ "menu.help": "Help & maintenance",
491
+ "menu.helpHint": "check, update, first-run guide",
492
+ "menu.guide": "First-run guide (step by step)",
493
+ "menu.doctorHint": "find out why something does not work",
494
+ "menu.now": "now",
495
+ "menu.cleanHint": "remove downloads and leftover renders",
496
+ "menu.reportHint": "to send to the HypeFrame team",
497
+ "menu.configHint": "device name, language, GPU",
498
+ "guide.title": "First-run guide",
499
+ "guide.intro": `A few short steps: language, HypeFrame account, AI assistant, then starting the engine.
500
+ Press Esc to skip a step. You can open this guide again from Help & maintenance.`,
501
+ "guide.account": "Connect this device to your HypeFrame account now?",
502
+ "guide.agent": "Pick an AI assistant (it signs in with your own account)",
503
+ "guide.later": "Later",
504
+ "guide.android": "On a phone: keep Termux open, and run termux-wake-lock so the engine keeps running when the screen is off.",
505
+ "guide.start": "Start the engine now?",
506
+ "agent.accountGoogle": "Google account",
507
+ "agent.accountChatgpt": "ChatGPT account (Plus/Pro)",
508
+ "agent.accountOpencode": "a provider you choose",
509
+ "agent.loginNow": "Log in",
510
+ "agent.removeAsk": "Remove {name} from this device?",
511
+ "agent.nextStart": "Next: start the engine, then open HypeFrame Web > Assistant and pick {name}.",
512
+ "agent.nextRunning": "Open HypeFrame Web > Assistant and pick {name} (it shows up within half a minute).",
376
513
  "agent.soon": "An AI assistant that works right on your device is on the way.",
377
514
  "agent.menuQuestion": "Pick an agent. Install and log in once here, then chat from HypeFrame Web.",
378
515
  "agent.ready": "ready to use from the web",
379
516
  "agent.needLogin": "needs login",
380
517
  "agent.notInstalled": "not installed",
381
518
  "agent.add": "Install and log in",
382
- "agent.login": "Log in again",
383
- "agent.remove": "Remove from this machine",
519
+ "agent.login": "Log in again (switch account)",
520
+ "agent.remove": "Remove from this device",
384
521
  "agent.back": "Back",
385
522
  "agent.installing": "Installing {name} from the official ACP registry...",
386
523
  "agent.installed": "{name} {version} installed.",
@@ -400,7 +537,16 @@ var en = {
400
537
  "linux.distro": "Downloading Ubuntu...",
401
538
  "linux.apt": "Preparing Ubuntu (certificates and curl)...",
402
539
  "linux.ready": "Linux mini ready.",
403
- "linux.openUrl": "Open in the phone browser: {url}",
540
+ "linux.openUrl": "Opening the phone browser to sign in: pick your account there, then come back to Termux. (If it does not open: {url})",
541
+ "agent.loginLink": "If no browser opened by itself, open this link: {url}",
542
+ "chromium.notNeeded": "On this computer Chrome is used as it is (or downloaded automatically on the first render). This command is for Android phones.",
543
+ "chromium.preparing": "Setting up Chromium for renders in the Linux mini (Debian under proot). Once only, about 300 MB to download...",
544
+ "chromium.distro": "Downloading Debian...",
545
+ "chromium.apt": "Installing Chromium and fonts in Debian (this can take a few minutes)...",
546
+ "chromium.ready": "Chromium is ready for renders.",
547
+ "chromium.restart": "If the engine is running, stop it and start it again: hypeframe start",
548
+ "chromium.failed": "Chromium is not installed: {reason}. Check the internet connection and run again: hypeframe chromium",
549
+ "help.chromium": "Android phones: install Chromium for renders (for Termux from Google Play)",
404
550
  "agent.keyFromShellAsk": "Use the {name} already set in this terminal?",
405
551
  "agent.keyFromShell": "Using {name} from this terminal (saved for this agent only).",
406
552
  "agent.own": "{name} is already installed on this computer ({path}); that copy is used, nothing is downloaded.",
@@ -577,11 +723,12 @@ var log = {
577
723
  };
578
724
 
579
725
  // src/cli/commands/start.ts
580
- import crypto8 from "node:crypto";
726
+ import crypto9 from "node:crypto";
727
+ import readline3 from "node:readline";
581
728
 
582
729
  // ../protocol/src/index.ts
583
730
  var PROTOCOL_VERSION = 1;
584
- var ALLOWED_KINDS = ["status", "kunci", "agen.mulai", "agen.kirim", "agen.izin", "agen.batal", "agen.opsi", "agen.riwayat"];
731
+ var ALLOWED_KINDS = ["status", "kunci", "agen.mulai", "agen.kirim", "agen.izin", "agen.batal", "agen.opsi", "agen.riwayat", "render.relai"];
585
732
  var CloseCode = {
586
733
  BadHello: 4001,
587
734
  Replaced: 4002,
@@ -609,7 +756,7 @@ import path7 from "node:path";
609
756
  // package.json
610
757
  var package_default = {
611
758
  name: "hypeframe",
612
- version: "0.6.1",
759
+ version: "0.8.0",
613
760
  description: "Local engine for HypeFrame Web: code clips, video renders and AI agents run on your own machine; the web is just the view.",
614
761
  keywords: [
615
762
  "hypeframe",
@@ -749,7 +896,7 @@ function linuxReady() {
749
896
  }
750
897
  var shQuote = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
751
898
  var VAR = /^[A-Za-z_][A-Za-z0-9_]*$/;
752
- function linuxCommand(cmd, args, env = {}) {
899
+ function linuxCommand(cmd, args, env = {}, distro = DISTRO) {
753
900
  const hf = dataDir();
754
901
  const bin = path4.join(linuxDir(), "bin");
755
902
  const vars = {
@@ -773,7 +920,60 @@ function linuxCommand(cmd, args, env = {}) {
773
920
  const file = path4.join(dir, `${crypto.createHash("sha256").update(script).digest("hex").slice(0, 24)}.sh`);
774
921
  if (!fs7.existsSync(file))
775
922
  fs7.writeFileSync(file, script, { mode: 384 });
776
- return ["proot-distro", ["login", DISTRO, "--shared-tmp", "--bind", `${hf}:${hf}`, "--", "/bin/bash", file]];
923
+ return ["proot-distro", ["login", distro, "--shared-tmp", "--bind", `${hf}:${hf}`, "--", "/bin/bash", file]];
924
+ }
925
+ var CHROMIUM_DISTRO = "debian";
926
+ var chromiumReadyFile = () => path4.join(linuxDir(), "chromium-siap");
927
+ var chromiumWrapper = () => (writeChromiumWrapper(), path4.join(linuxDir(), "bin", "chromium-mini"));
928
+ var linuxChromiumReady = () => fs7.existsSync(chromiumReadyFile());
929
+ function writeChromiumWrapper() {
930
+ const hf = dataDir();
931
+ const dir = linuxDir();
932
+ const shell = process.env.PREFIX ? `${process.env.PREFIX}/bin/sh` : "/bin/sh";
933
+ const inner = path4.join(dir, "bin", "chromium-dalam");
934
+ const outer = `#!${shell}
935
+ # HypeFrame: Chromium in the Linux mini (Debian) for renders. Arguments go through a file (see linux.ts).
936
+ f="${path4.join(dir, "jalan")}/chromium-$$.args"
937
+ mkdir -p "${path4.join(dir, "jalan")}"
938
+ : > "$f"
939
+ for a in "$@"; do printf '%s\\0' "$a" >> "$f"; done
940
+ exec proot-distro login ${CHROMIUM_DISTRO} --shared-tmp --bind "${hf}:${hf}" -- /bin/bash "${inner}" "$f"
941
+ `;
942
+ const innerScript = `#!/bin/bash
943
+ # HypeFrame: start Debian's chromium with the arguments the engine passed (one per NUL in the file)
944
+ args=()
945
+ while IFS= read -r -d '' a; do args+=("$a"); done < "$1"
946
+ rm -f "$1"
947
+ exec "\${HF_CHROMIUM:-/usr/bin/chromium}" --no-sandbox --disable-dev-shm-usage "\${args[@]}"
948
+ `;
949
+ fs7.mkdirSync(path4.join(dir, "bin"), { recursive: true });
950
+ fs7.writeFileSync(path4.join(dir, "bin", "chromium-mini"), outer, { mode: 493 });
951
+ fs7.writeFileSync(inner, innerScript, { mode: 493 });
952
+ }
953
+ function prepareLinuxChromium(say = () => {
954
+ return;
955
+ }, run = runShown) {
956
+ writeChromiumWrapper();
957
+ if (linuxChromiumReady())
958
+ return;
959
+ say("chromium.preparing");
960
+ if (!onPath("proot-distro")) {
961
+ say("linux.pkg");
962
+ if (!run("pkg", ["install", "-y", "proot-distro"]))
963
+ throw new Error("pkg install proot-distro");
964
+ }
965
+ const exists = () => run(...linuxCommand("/bin/true", [], {}, CHROMIUM_DISTRO));
966
+ if (!exists()) {
967
+ say("chromium.distro");
968
+ if (!run("proot-distro", ["install", CHROMIUM_DISTRO]) && !exists())
969
+ throw new Error(`proot-distro install ${CHROMIUM_DISTRO}`);
970
+ }
971
+ say("chromium.apt");
972
+ if (!run(...linuxCommand("/bin/sh", ["-c", "apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get install -y -q chromium fonts-noto-core fonts-noto-color-emoji"], {}, CHROMIUM_DISTRO)))
973
+ throw new Error("apt-get install chromium");
974
+ fs7.writeFileSync(chromiumReadyFile(), `${CHROMIUM_DISTRO}
975
+ `);
976
+ say("chromium.ready");
777
977
  }
778
978
  var BRIDGE_SH = `#!/bin/bash
779
979
  # HypeFrame tools for an agent in the Linux mini: stdio MCP <-> the engine on 127.0.0.1 (HF_MCP_URL, HF_MCP_KUNCI)
@@ -910,7 +1110,10 @@ class AcpProcess extends EventEmitter {
910
1110
  const [cmd, args, childEnv] = agentSpawn(agent, env);
911
1111
  const child = spawn(cmd, args, { cwd, env: childEnv, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
912
1112
  this.child = child;
913
- child.stderr?.on("data", (d) => this.stderrTail = (this.stderrTail + d).slice(-4096));
1113
+ child.stderr?.on("data", (d) => {
1114
+ this.stderrTail = (this.stderrTail + d).slice(-4096);
1115
+ this.emit("stderr", String(d));
1116
+ });
914
1117
  child.stdin?.on("error", () => {
915
1118
  return;
916
1119
  });
@@ -1061,6 +1264,12 @@ class AgentSessions {
1061
1264
  running() {
1062
1265
  return [...this.procs.keys()];
1063
1266
  }
1267
+ count() {
1268
+ return this.sessions.size;
1269
+ }
1270
+ working() {
1271
+ return this.prompting.size;
1272
+ }
1064
1273
  process(agentId) {
1065
1274
  const ada = this.procs.get(agentId);
1066
1275
  if (ada?.proc.alive)
@@ -1497,6 +1706,14 @@ function createAgentService(o) {
1497
1706
  const routes = new Map;
1498
1707
  const sessionRoute = new Map;
1499
1708
  const permissions = new Map;
1709
+ let stopping = false;
1710
+ const emit = (e) => {
1711
+ if (!stopping)
1712
+ o.onEvent?.(e);
1713
+ };
1714
+ const nameOf = (agentId) => agentId ? readInstalled().find((a) => a.id === agentId)?.name ?? agentId : "?";
1715
+ const turnStart = new Map;
1716
+ const asked = new Map;
1500
1717
  const histories = new Map;
1501
1718
  const pending = new Map;
1502
1719
  let turn = 0;
@@ -1537,12 +1754,15 @@ function createAgentService(o) {
1537
1754
  },
1538
1755
  onPermission: (sessionId, req, info) => new Promise((ok) => {
1539
1756
  const id = `i${crypto3.randomBytes(6).toString("hex")}`;
1540
- const done = (v) => (permissions.delete(id), ok(v));
1757
+ const done = (v) => (permissions.delete(id), asked.delete(id), ok(v));
1541
1758
  permissions.set(id, done);
1759
+ const agent = nameOf(sessions.agentOf(sessionId));
1760
+ asked.set(id, { agent, options: req.options });
1761
+ emit({ type: "permission", agent, title: String(req.toolCall.title ?? ""), ...commandText(req) ? { command: commandText(req) } : {} });
1542
1762
  setTimeout(() => permissions.has(id) && done(null), 5 * 60000).unref();
1543
1763
  control(sessionId, { izin: { id, judul: String(req.toolCall.title ?? ""), jenis: String(req.toolCall.kind ?? ""), perintah: commandText(req), wajibTanya: info.mustAsk, opsi: req.options } });
1544
1764
  }),
1545
- onExit: (agentId, code) => o.conn.news("agen", { agentId, berhenti: code }),
1765
+ onExit: (agentId, code) => (o.conn.news("agen", { agentId, berhenti: code }), emit({ type: "stopped", agent: nameOf(agentId), code })),
1546
1766
  flushMs: o.flushMs ?? 100
1547
1767
  });
1548
1768
  const text = (c, k) => typeof c[k] === "string" ? c[k] : "";
@@ -1556,11 +1776,19 @@ function createAgentService(o) {
1556
1776
  throw new Error("Agen belum dipasang di mesin ini.");
1557
1777
  if (!a.ready)
1558
1778
  throw new Error("Agen belum masuk akun di mesin ini.");
1779
+ const fresh = !sessions.running().includes(agentId);
1780
+ const t0 = Date.now();
1781
+ if (fresh)
1782
+ emit({ type: "starting", agent: a.name });
1559
1783
  const { sessionId, dimuat, routeId, opsi } = await sessions.open({ agentId, projectId, resumeId: text(c, "resume") || undefined });
1784
+ if (fresh)
1785
+ emit({ type: "ready", agent: a.name, ms: Date.now() - t0 });
1786
+ if (dimuat !== "hidup")
1787
+ emit({ type: "chat", agent: a.name, resumed: dimuat === "load" });
1560
1788
  const alat = Array.isArray(c.alat) ? c.alat : undefined;
1561
1789
  const r = routes.get(routeId);
1562
1790
  if (!r)
1563
- routes.set(routeId, { dari: c.dari, tab, alat: alat ?? [], projectId });
1791
+ routes.set(routeId, { dari: c.dari, tab, alat: alat ?? [], projectId, agentId });
1564
1792
  else {
1565
1793
  if (tab && r.tab === tab)
1566
1794
  r.dari = c.dari;
@@ -1584,11 +1812,20 @@ function createAgentService(o) {
1584
1812
  const file = histories.get(sessionId);
1585
1813
  if (file)
1586
1814
  record(file, packUpdates([{ sessionUpdate: "user_message_chunk", content: { type: "text", text: text(c, "teks") } }]).flat());
1587
- sessions.prompt(sessionId, text(c, "teks")).then((res) => control(sessionId, { selesai: res.stopReason }), (e) => control(sessionId, { galat: e.message.slice(0, 300) }));
1815
+ const agent = nameOf(sessions.agentOf(sessionId));
1816
+ emit({ type: "message", agent, text: text(c, "teks").slice(0, 200) });
1817
+ turnStart.set(sessionId, Date.now());
1818
+ const took = () => Date.now() - (turnStart.get(sessionId) ?? Date.now());
1819
+ sessions.prompt(sessionId, text(c, "teks")).then((res) => (emit({ type: "done", agent, reason: String(res.stopReason), ms: took() }), control(sessionId, { selesai: res.stopReason })), (e) => (emit({ type: "error", agent, message: e.message.slice(0, 300) }), control(sessionId, { galat: e.message.slice(0, 300) })));
1588
1820
  return {};
1589
1821
  },
1590
1822
  "agen.izin": async (c) => {
1591
- permissions.get(text(c, "izinId"))?.(typeof c.optionId === "string" ? c.optionId : null);
1823
+ const izinId = text(c, "izinId");
1824
+ const optionId = typeof c.optionId === "string" ? c.optionId : null;
1825
+ const q = asked.get(izinId);
1826
+ if (q && permissions.has(izinId))
1827
+ emit({ type: "answer", agent: q.agent, allowed: !!q.options.find((x) => x.optionId === optionId)?.kind?.startsWith("allow") });
1828
+ permissions.get(izinId)?.(optionId);
1592
1829
  return {};
1593
1830
  },
1594
1831
  "agen.batal": async (c) => {
@@ -1599,7 +1836,9 @@ function createAgentService(o) {
1599
1836
  const macam = text(c, "macam");
1600
1837
  if (!["model", "mode", "opsi"].includes(macam))
1601
1838
  throw new Error("Pilihan tidak dikenal.");
1602
- return sessions.setOption(text(c, "sessionId"), { jenis: macam, id: text(c, "id"), nilai: text(c, "nilai") });
1839
+ const r = await sessions.setOption(text(c, "sessionId"), { jenis: macam, id: text(c, "id"), nilai: text(c, "nilai") });
1840
+ emit({ type: "option", agent: nameOf(sessions.agentOf(text(c, "sessionId"))), what: macam === "opsi" ? text(c, "id") : macam, value: text(c, "nilai") });
1841
+ return r;
1603
1842
  },
1604
1843
  "agen.riwayat": async (c) => {
1605
1844
  try {
@@ -1677,18 +1916,21 @@ function createAgentService(o) {
1677
1916
  case "tools/call": {
1678
1917
  if (!target)
1679
1918
  return o.onToolError?.("tab"), ok({ isError: true, content: [{ type: "text", text: NOT_OPEN }] }), true;
1680
- if (msg.params?.name === FILE_TOOL.name)
1681
- return ok(await sendFile(target, target.projectId, msg.params?.arguments)), true;
1682
- const body = { nama: String(msg.params?.name ?? ""), arg: msg.params?.arguments ?? {} };
1919
+ const tool = String(msg.params?.name ?? "");
1920
+ const agent = nameOf(target.agentId);
1921
+ const answered = (result) => (emit({ type: "tool", agent, tool, ok: !result.isError }), ok(result), true);
1922
+ if (tool === FILE_TOOL.name)
1923
+ return answered(await sendFile(target, target.projectId, msg.params?.arguments));
1924
+ const body = { nama: tool, arg: msg.params?.arguments ?? {} };
1683
1925
  if (bytes(body) > MAX_TOOL_ARGS)
1684
- return ok({ isError: true, content: [{ type: "text", text: `The arguments of ${body.nama} are too large to send to HypeFrame Web (over 200 KB). Split the work into smaller steps.` }] }), true;
1926
+ return answered({ isError: true, content: [{ type: "text", text: `The arguments of ${body.nama} are too large to send to HypeFrame Web (over 200 KB). Split the work into smaller steps.` }] });
1685
1927
  const a = await o.conn.request(target.dari, "alat", body);
1686
1928
  if (a.ok === false) {
1687
1929
  const error = String(a.error) in ERRORS ? String(a.error) : "tab";
1688
1930
  o.onToolError?.(error);
1689
- return ok({ isError: true, content: [{ type: "text", text: ERRORS[error] }] }), true;
1931
+ return answered({ isError: true, content: [{ type: "text", text: ERRORS[error] }] });
1690
1932
  }
1691
- return ok({ isError: !!a.isError, content: Array.isArray(a.content) ? a.content : [] }), true;
1933
+ return answered({ isError: !!a.isError, content: Array.isArray(a.content) ? a.content : [] });
1692
1934
  }
1693
1935
  default:
1694
1936
  return reply(res, 200, { jsonrpc: "2.0", id: msg.id, error: { code: -32601, message: `Method not found: ${msg.method}` } }), true;
@@ -1697,7 +1939,10 @@ function createAgentService(o) {
1697
1939
  function capabilities() {
1698
1940
  return readInstalled().filter((a) => isSupported(a.id) || process.env.HYPEFRAME_ACP_REGISTRY).slice(0, 8).map((a) => ({ id: a.id, nama: a.name, siap: a.ready === true }));
1699
1941
  }
1700
- return { work, route, capabilities, key, stop: () => (clearInterval(ticker), sessions.stopAll()) };
1942
+ function activity() {
1943
+ return { chats: sessions.count(), working: sessions.working(), agents: sessions.running().map((id) => nameOf(id)) };
1944
+ }
1945
+ return { work, route, capabilities, activity, key, stop: () => (stopping = true, clearInterval(ticker), sessions.stopAll()) };
1701
1946
  }
1702
1947
 
1703
1948
  // src/agent/mcp-bridge.ts
@@ -2123,8 +2368,11 @@ async function prepareChrome(cacheDir, progress = () => {
2123
2368
  const found = findChrome();
2124
2369
  if (found)
2125
2370
  return found;
2126
- if (opts.android ?? isAndroid())
2127
- throw new Error("Chromium belum terpasang. Di Termux jalankan: pkg install x11-repo && pkg install chromium");
2371
+ if (opts.android ?? isAndroid()) {
2372
+ if (linuxChromiumReady())
2373
+ return chromiumWrapper();
2374
+ throw new Error("Chromium belum terpasang. Jalankan: hypeframe chromium (atau di Termux: pkg install x11-repo && pkg install chromium)");
2375
+ }
2128
2376
  const platform = detectBrowserPlatform();
2129
2377
  if (!platform)
2130
2378
  throw new Error("Sistem ini belum didukung untuk render (Chrome tidak tersedia).");
@@ -2514,15 +2762,132 @@ function createPage({ web, cacheDir }) {
2514
2762
  };
2515
2763
  }
2516
2764
 
2517
- // src/render/service.ts
2765
+ // src/render/relay.ts
2518
2766
  import crypto7 from "node:crypto";
2767
+ var sha = (b) => crypto7.createHash("sha256").update(b).digest("hex");
2768
+ var sleep2 = (ms) => new Promise((ok) => setTimeout(ok, ms));
2769
+ async function runRelayJob(j, o) {
2770
+ const step = o.onStep ?? (() => {
2771
+ return;
2772
+ });
2773
+ let base;
2774
+ try {
2775
+ base = new URL(j.alamat);
2776
+ if (base.origin !== new URL(o.gateway).origin || base.pathname !== `/relai-mesin/${j.job}` || !/^r_[a-f0-9]{16}$/.test(j.job))
2777
+ throw new Error;
2778
+ } catch {
2779
+ return { ok: false, error: "not the gateway address" };
2780
+ }
2781
+ const gw = (p, init = {}) => fetch(`${base.href}${p}`, { ...init, headers: { ...init.headers, authorization: `Bearer ${o.token}` }, signal: AbortSignal.timeout(120000) });
2782
+ const local = (p, init = {}) => fetch(`${o.localUrl}${p}`, { ...init, headers: { ...init.headers, authorization: `Bearer ${j.tiket}` }, signal: AbortSignal.timeout(120000) });
2783
+ const report = async (body) => {
2784
+ try {
2785
+ const r = await gw("/status", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
2786
+ return ((await r.json().catch(() => ({}))).batal ?? false) === true;
2787
+ } catch {
2788
+ return false;
2789
+ }
2790
+ };
2791
+ const fail = async (error) => {
2792
+ await report({ status: "gagal", galat: error });
2793
+ step("failed", error);
2794
+ return { ok: false, error };
2795
+ };
2796
+ try {
2797
+ step("fetching", `${(j.ukuran / 1048576).toFixed(1)} MB`);
2798
+ const made = await local("/tugas", { method: "POST" });
2799
+ if (made.status !== 200 && made.status !== 201)
2800
+ return fail(String((await made.json().catch(() => ({}))).galat || `Render service refused the job (${made.status}).`));
2801
+ for (let i = 0;i < j.jumlah; i++) {
2802
+ const r = await gw(`/potongan/${i}`);
2803
+ if (!r.ok)
2804
+ return fail(`Part ${i + 1} could not be fetched from the gateway (${r.status}).`);
2805
+ const part = new Uint8Array(await r.arrayBuffer());
2806
+ const put = await local(`/tugas/${j.job}/potongan/${i}`, { method: "PUT", headers: { "x-sha256": sha(part) }, body: part });
2807
+ if (!put.ok)
2808
+ return fail(String((await put.json().catch(() => ({}))).galat || `Part ${i + 1} was refused (${put.status}).`));
2809
+ }
2810
+ const start = await local(`/tugas/${j.job}/mulai`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ jumlah: j.jumlah, ukuran: j.ukuran, sha256: j.sha256 }) });
2811
+ if (!start.ok)
2812
+ return fail(String((await start.json().catch(() => ({}))).galat || `The render did not start (${start.status}).`));
2813
+ step("rendering");
2814
+ for (;; ) {
2815
+ const s = await (await local(`/tugas/${j.job}`)).json();
2816
+ if (s.status === "gagal" || s.status === "batal")
2817
+ return fail(s.galat || "The render on this engine failed.");
2818
+ if (s.status === "selesai")
2819
+ break;
2820
+ const cancelled = await report({ status: s.status === "jalan" ? "jalan" : "antre", persen: s.persen ?? 0, antrean: s.antrean ?? null, tahap: s.tahap ?? "" });
2821
+ if (cancelled) {
2822
+ await local(`/tugas/${j.job}`, { method: "DELETE" }).catch(() => {
2823
+ return;
2824
+ });
2825
+ step("cancelled");
2826
+ return { ok: false, cancelled: true, error: "cancelled" };
2827
+ }
2828
+ await sleep2(o.everyMs ?? 1000);
2829
+ }
2830
+ step("sending");
2831
+ const r = await local(`/tugas/${j.job}/hasil`);
2832
+ if (!r.ok || !r.body)
2833
+ return fail(`The finished video could not be read (${r.status}).`);
2834
+ const type = r.headers.get("content-type") === "video/webm" ? "video/webm" : "video/mp4";
2835
+ const size = Math.max(1, o.resultPartMb ?? 32) * 1048576;
2836
+ const total = crypto7.createHash("sha256");
2837
+ let sent = 0;
2838
+ let n = 0;
2839
+ let buf = [];
2840
+ let buffered = 0;
2841
+ const flush = async () => {
2842
+ if (!buffered)
2843
+ return true;
2844
+ const part = Buffer.concat(buf, buffered);
2845
+ buf = [];
2846
+ buffered = 0;
2847
+ for (let attempt = 1;; attempt++) {
2848
+ const put = await gw(`/hasil/${n}`, { method: "PUT", headers: { "x-sha256": sha(part) }, body: part }).catch(() => null);
2849
+ if (put?.ok)
2850
+ break;
2851
+ if (attempt >= 3)
2852
+ return false;
2853
+ await sleep2(1000 * attempt);
2854
+ }
2855
+ n++;
2856
+ return true;
2857
+ };
2858
+ const reader = r.body.getReader();
2859
+ for (;; ) {
2860
+ const { done, value } = await reader.read();
2861
+ if (done)
2862
+ break;
2863
+ total.update(value);
2864
+ sent += value.length;
2865
+ buf.push(value);
2866
+ buffered += value.length;
2867
+ if (buffered >= size && !await flush())
2868
+ return fail("The video could not be sent back to the gateway.");
2869
+ }
2870
+ if (!await flush())
2871
+ return fail("The video could not be sent back to the gateway.");
2872
+ const fin = await gw("/hasil-selesai", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ jumlah: n, ukuran: sent, sha256: total.digest("hex"), jenis: type }) });
2873
+ if (!fin.ok)
2874
+ return fail(`The gateway did not take the video (${fin.status}).`);
2875
+ step("done", `${(sent / 1048576).toFixed(1)} MB`);
2876
+ return { ok: true };
2877
+ } catch (e) {
2878
+ return fail(String(e.message || e).slice(0, 300));
2879
+ }
2880
+ }
2881
+
2882
+ // src/render/service.ts
2883
+ import crypto8 from "node:crypto";
2519
2884
  import fs18 from "node:fs";
2520
2885
  import fsp4 from "node:fs/promises";
2521
2886
  import http2 from "node:http";
2522
2887
  import path14 from "node:path";
2523
2888
  import yauzl from "yauzl";
2524
2889
  var ACTIVE = new Set(["unggah", "antre", "jalan"]);
2525
- var safeEqual = (a, b) => a.length === b.length && crypto7.timingSafeEqual(Buffer.from(a), Buffer.from(b));
2890
+ var safeEqual = (a, b) => a.length === b.length && crypto8.timingSafeEqual(Buffer.from(a), Buffer.from(b));
2526
2891
  var BAD_ENTRY = /relative path|absolute path|invalid characters/i;
2527
2892
  function listZip(f) {
2528
2893
  return new Promise((ok, fail) => {
@@ -2602,7 +2967,7 @@ async function createRenderService(o) {
2602
2967
  return;
2603
2968
  } } = o;
2604
2969
  const origins = new Set([].concat(o.origin || []));
2605
- const sign = (kind, body) => crypto7.createHmac("sha256", key).update(`${kind}.${body}`).digest("base64url");
2970
+ const sign = (kind, body) => crypto8.createHmac("sha256", key).update(`${kind}.${body}`).digest("base64url");
2606
2971
  const dir = (job) => path14.join(folder, job);
2607
2972
  await fsp4.mkdir(folder, { recursive: true });
2608
2973
  function readTicket(req) {
@@ -2821,7 +3186,7 @@ async function createRenderService(o) {
2821
3186
  const size = await saveBody2(req, f, Math.min(partMb * 1048576 + 1024, room));
2822
3187
  const expected = String(req.headers["x-sha256"] || "").toLowerCase();
2823
3188
  if (expected) {
2824
- const digest = crypto7.createHash("sha256").update(await fsp4.readFile(f)).digest("hex");
3189
+ const digest = crypto8.createHash("sha256").update(await fsp4.readFile(f)).digest("hex");
2825
3190
  if (digest !== expected) {
2826
3191
  await fsp4.rm(f, { force: true });
2827
3192
  update(t, { terunggah: t.terunggah - before });
@@ -2840,7 +3205,7 @@ async function createRenderService(o) {
2840
3205
  return json(req, res, 400, { galat: "Jumlah potongan tidak valid." });
2841
3206
  const zip = path14.join(dir(job), "paket.zip");
2842
3207
  const out = fs18.createWriteStream(zip);
2843
- const hash = crypto7.createHash("sha256");
3208
+ const hash = crypto8.createHash("sha256");
2844
3209
  let total = 0;
2845
3210
  for (let i = 0;i < count; i++) {
2846
3211
  const f = path14.join(dir(job), `p${i}`);
@@ -3024,6 +3389,39 @@ function openOnPhone(url) {
3024
3389
  }
3025
3390
 
3026
3391
  // src/cli/commands/start.ts
3392
+ var preview = (s) => {
3393
+ const one = s.replace(/\s+/g, " ").trim();
3394
+ return one.length > 80 ? `${one.slice(0, 79)}…` : one;
3395
+ };
3396
+ function logAgentEvent(e) {
3397
+ const a = color.ai(e.agent);
3398
+ switch (e.type) {
3399
+ case "starting":
3400
+ return log.info(t("agentLog.starting", { agent: a }));
3401
+ case "ready":
3402
+ return log.ok(t("agentLog.ready", { agent: a, sec: seconds(e.ms) }));
3403
+ case "chat":
3404
+ return log.info(t(e.resumed ? "agentLog.chatResumed" : "agentLog.chat", { agent: a }));
3405
+ case "message":
3406
+ return log.info(t("agentLog.message", { agent: a, text: preview(e.text) }));
3407
+ case "done":
3408
+ if (e.reason === "cancelled")
3409
+ return log.detail(t("agentLog.cancelled", { agent: a }));
3410
+ return log.ok(t("agentLog.done", { agent: a, sec: seconds(e.ms) }));
3411
+ case "error":
3412
+ return log.warn(t("agentLog.error", { agent: a, message: e.message }));
3413
+ case "tool":
3414
+ return e.ok ? log.detail(t("agentLog.tool", { agent: e.agent, tool: e.tool })) : log.warn(t("agentLog.toolFailed", { agent: a, tool: e.tool }));
3415
+ case "permission":
3416
+ return log.info(e.command ? t("agentLog.permissionCmd", { agent: a, command: preview(e.command) }) : t("agentLog.permission", { agent: a, title: preview(e.title) }));
3417
+ case "answer":
3418
+ return log.detail(t(e.allowed ? "agentLog.allowed" : "agentLog.refused"));
3419
+ case "option":
3420
+ return log.detail(t("agentLog.option", { agent: e.agent, what: e.what, value: e.value }));
3421
+ case "stopped":
3422
+ return log.warn(t("agentLog.stopped", { agent: a, code: String(e.code) }));
3423
+ }
3424
+ }
3027
3425
  async function pairDevice(s, noBrowser = false) {
3028
3426
  const a = await pair({
3029
3427
  gateway: s.gateway,
@@ -3073,7 +3471,8 @@ async function start(args, { fromMenu = false } = {}) {
3073
3471
  conn: { news: (k, b) => conn?.news(k, b), request: (ke, kind, body, ms) => conn?.request(ke, kind, body, ms) ?? Promise.resolve({ ok: false, error: "terputus" }) },
3074
3472
  port: () => servicePort,
3075
3473
  bridge: bridgeLaunch(),
3076
- onToolError: (e) => log.warn(t(e === "tab" ? "agent.toolNoTab" : "agent.toolNoAnswer"))
3474
+ onToolError: (e) => log.warn(t(e === "tab" ? "agent.toolNoTab" : "agent.toolNoAnswer")),
3475
+ onEvent: (e) => logAgentEvent(e)
3077
3476
  });
3078
3477
  if (isAndroid())
3079
3478
  watchOpenRequests((url) => {
@@ -3081,11 +3480,12 @@ async function start(args, { fromMenu = false } = {}) {
3081
3480
  openOnPhone(url);
3082
3481
  });
3083
3482
  const capabilities = { render: false, chrome: null, transparan: false, agen: agents.capabilities() };
3084
- const key = crypto8.randomBytes(32).toString("base64url");
3483
+ const key = crypto9.randomBytes(32).toString("base64url");
3085
3484
  const cache = cacheDir();
3086
3485
  const page = createPage({ web: s.web, cacheDir: cache });
3087
3486
  let runner = null;
3088
3487
  const started = new Map;
3488
+ const renders = { done: 0, failed: 0 };
3089
3489
  const service = await createRenderService({
3090
3490
  folder: renderDir(),
3091
3491
  key,
@@ -3099,9 +3499,11 @@ async function start(args, { fromMenu = false } = {}) {
3099
3499
  } else if (event === "done") {
3100
3500
  log.ok(t("render.jobDone", { sec: seconds(Date.now() - (started.get(j.job) ?? Date.now())), size: bytes2(j.hasilUkuran ?? 0) }));
3101
3501
  started.delete(j.job);
3502
+ renders.done++;
3102
3503
  } else if (event === "failed") {
3103
3504
  log.warn(t("render.jobFailed", { reason: j.galat || "?" }));
3104
3505
  started.delete(j.job);
3506
+ renders.failed++;
3105
3507
  } else if (event === "cancelled") {
3106
3508
  log.detail(t("render.jobCancelled"));
3107
3509
  started.delete(j.job);
@@ -3116,7 +3518,29 @@ async function start(args, { fromMenu = false } = {}) {
3116
3518
  throw new Error(EngineError.NotReady);
3117
3519
  return { port: service.port, kunci: key, versi: VERSION };
3118
3520
  },
3119
- ...agents.work
3521
+ ...agents.work,
3522
+ "render.relai": async (c) => {
3523
+ const str = (k) => typeof c[k] === "string" ? c[k] : "";
3524
+ const job = { job: str("job"), tiket: str("tiket"), jumlah: Number(c.jumlah) || 0, ukuran: Number(c.ukuran) || 0, sha256: str("sha256"), alamat: str("alamat") };
3525
+ runRelayJob(job, {
3526
+ localUrl: `http://127.0.0.1:${service.port}`,
3527
+ token: account.token,
3528
+ gateway: s.gateway,
3529
+ onStep: (stepName, detail) => {
3530
+ if (stepName === "fetching")
3531
+ log.info(t("relay.fetching", { size: detail ?? "" }));
3532
+ else if (stepName === "sending")
3533
+ log.info(t("relay.sending"));
3534
+ else if (stepName === "done")
3535
+ log.ok(t("relay.done", { size: detail ?? "" }));
3536
+ else if (stepName === "failed")
3537
+ log.warn(t("relay.failed", { reason: detail ?? "?" }));
3538
+ else if (stepName === "cancelled")
3539
+ log.detail(t("relay.cancelled"));
3540
+ }
3541
+ });
3542
+ return {};
3543
+ }
3120
3544
  });
3121
3545
  const engineConn = new Connection({ gateway: s.gateway, token: account.token, info: { versi: VERSION, os: osName(), nama: s.name, kemampuan: capabilities, portLokal: service.port }, handler });
3122
3546
  conn = engineConn;
@@ -3129,15 +3553,40 @@ async function start(args, { fromMenu = false } = {}) {
3129
3553
  conn?.news("status", { kemampuan: capabilities });
3130
3554
  }, 30000).unref();
3131
3555
  let connectedBefore = false;
3556
+ let renderNote = "";
3132
3557
  engineConn.on("connected", () => {
3133
3558
  if (connectedBefore)
3134
3559
  log.ok(t("engine.reconnected"));
3135
3560
  else {
3136
3561
  log.ok(t("engine.ready"));
3562
+ const ready = (capabilities.agen ?? []).filter((a) => a.siap).map((a) => a.nama);
3563
+ if (ready.length)
3564
+ log.ok(t("engine.agentsReady", { list: ready.join(", ") }));
3565
+ else
3566
+ log.detail(t("engine.agentsNone"));
3137
3567
  log.detail(t("engine.stopHint"));
3568
+ if (process.stdin.isTTY)
3569
+ log.detail(t("engine.statusHint"));
3138
3570
  }
3139
3571
  connectedBefore = true;
3140
3572
  });
3573
+ if (process.stdin.isTTY) {
3574
+ const rl = readline3.createInterface({ input: process.stdin, terminal: false });
3575
+ rl.on("line", () => {
3576
+ const act = agents.activity();
3577
+ const ready = (capabilities.agen ?? []).filter((a) => a.siap).map((a) => a.nama);
3578
+ console.log("");
3579
+ console.log(` ${color.bold(t("statusNow.title"))}`);
3580
+ console.log(table([
3581
+ [color.muted(t("statusNow.connection")), engineConn.connected ? color.ok(t("statusNow.connected")) : color.warn(t("statusNow.offline"))],
3582
+ [color.muted(t("statusNow.render")), capabilities.render ? color.ok(t("statusNow.renderReady", { chrome: capabilities.chrome ?? "" })) : color.warn(`${t("statusNow.renderNot")}${renderNote ? ` · ${renderNote}` : ""}`)],
3583
+ [color.muted(t("statusNow.renders")), t("statusNow.rendersValue", { done: renders.done, failed: renders.failed, running: started.size })],
3584
+ [color.muted(t("statusNow.agents")), ready.length ? ready.join(", ") : color.muted(t("statusNow.none"))],
3585
+ [color.muted(t("statusNow.chats")), t("statusNow.chatsValue", { chats: act.chats, working: act.working })]
3586
+ ]));
3587
+ console.log("");
3588
+ });
3589
+ }
3141
3590
  engineConn.on("disconnected", () => log.warn(t("engine.lost")));
3142
3591
  engineConn.on("revoked", () => {
3143
3592
  log.warn(t("engine.revoked"));
@@ -3178,6 +3627,7 @@ async function start(args, { fromMenu = false } = {}) {
3178
3627
  engineConn.news("status", { kemampuan: capabilities });
3179
3628
  log.ok(t("render.ready", { chrome: info.version, extra: info.transparent ? "" : t("render.noAlpha") }));
3180
3629
  } catch (e) {
3630
+ renderNote = e.message.slice(0, 120);
3181
3631
  log.warn(t("render.notYet", { reason: e.message }));
3182
3632
  setTimeout(prepareRender, 10 * 60000).unref();
3183
3633
  }
@@ -3633,7 +4083,32 @@ async function installAgent(id, progress = () => {
3633
4083
  }
3634
4084
 
3635
4085
  // src/agent/login.ts
3636
- import { spawnSync as spawnSync4 } from "node:child_process";
4086
+ import { spawn as spawn4 } from "node:child_process";
4087
+ var SIGN_IN = /https?:\/\/[^\s"'<>]{8,2000}/g;
4088
+ var looksLikeSignIn = (u) => /oauth|auth|login|signin|sign-in|device|accounts\./i.test(u);
4089
+ function linkScanner(found) {
4090
+ const seen = new Set;
4091
+ let rest = "";
4092
+ return (text) => {
4093
+ rest += text;
4094
+ const end = rest.lastIndexOf(`
4095
+ `);
4096
+ if (end < 0)
4097
+ return void (rest = rest.slice(-4096));
4098
+ const lines = rest.slice(0, end);
4099
+ rest = rest.slice(end + 1);
4100
+ for (const u of lines.match(SIGN_IN) ?? [])
4101
+ if (looksLikeSignIn(u) && !seen.has(u))
4102
+ seen.add(u), found(u);
4103
+ };
4104
+ }
4105
+ function runAttached(cmd, args, env) {
4106
+ return new Promise((done) => {
4107
+ const child = spawn4(cmd, args, { stdio: "inherit", env });
4108
+ child.on("error", () => done(-1));
4109
+ child.on("exit", (code) => done(code));
4110
+ });
4111
+ }
3637
4112
  async function keyFromShell(name, io) {
3638
4113
  const value = process.env[name];
3639
4114
  if (!value)
@@ -3670,6 +4145,8 @@ async function loginAgent(id, io) {
3670
4145
  throw new Error(`Agent ${id} is not installed`);
3671
4146
  const proc = new AcpProcess;
3672
4147
  let method;
4148
+ if (io.link)
4149
+ proc.on("stderr", linkScanner(io.link));
3673
4150
  try {
3674
4151
  const init = await proc.start(a, projectDir("_cek"), agentEnv(id));
3675
4152
  method = pick(init.authMethods ?? []);
@@ -3681,8 +4158,7 @@ async function loginAgent(id, io) {
3681
4158
  if (method?.type === "terminal") {
3682
4159
  io.say(method.name || method.description || id);
3683
4160
  const [cmd, args, env] = agentSpawn(a, { ...agentEnv(id), ...method.env ?? {} }, method.args ?? []);
3684
- const r = spawnSync4(cmd, args, { stdio: "inherit", env });
3685
- if (r.status !== 0)
4161
+ if (await runAttached(cmd, args, env) !== 0)
3686
4162
  return setReady(id, false), false;
3687
4163
  } else if (method && isKey(method)) {
3688
4164
  const name = method.varName || method.id;
@@ -3697,11 +4173,19 @@ async function loginAgent(id, io) {
3697
4173
  // src/cli/commands/agent.ts
3698
4174
  var NAMES = { "antigravity-acp": "Antigravity", "codex-acp": "Codex", opencode: "OpenCode" };
3699
4175
  var agentName = (id) => NAMES[id] ?? readInstalled().find((a) => a.id === id)?.name ?? id;
4176
+ var ALIASES = { codex: "codex-acp", antigravity: "antigravity-acp", agy: "antigravity-acp", gemini: "antigravity-acp", opencode: "opencode" };
4177
+ var resolveAgentId = (name) => ALIASES[name.trim().toLowerCase()] ?? name.trim();
4178
+ var ACCOUNT = { "antigravity-acp": "agent.accountGoogle", "codex-acp": "agent.accountChatgpt", opencode: "agent.accountOpencode" };
3700
4179
  function agentState(id) {
3701
4180
  const a = readInstalled().find((x) => x.id === id);
3702
4181
  return !a ? "none" : a.ready ? "ready" : "login";
3703
4182
  }
3704
4183
  var stateText = (s) => s === "ready" ? color.ok(t("agent.ready")) : s === "login" ? color.warn(t("agent.needLogin")) : color.muted(t("agent.notInstalled"));
4184
+ function agentHint(id, s) {
4185
+ const mark = s === "ready" ? "✔" : s === "login" ? "▲" : "○";
4186
+ const state = t(s === "ready" ? "agent.ready" : s === "login" ? "agent.needLogin" : "agent.notInstalled");
4187
+ return `${mark} ${state}${ACCOUNT[id] ? ` · ${t(ACCOUNT[id])}` : ""}`;
4188
+ }
3705
4189
  var io = {
3706
4190
  ask: async (label) => {
3707
4191
  if (!process.stdin.isTTY)
@@ -3726,7 +4210,7 @@ function listAgents() {
3726
4210
  const a = readInstalled().find((x) => x.id === id);
3727
4211
  return a ? color.muted(` ${icon.dot} ${a.own ? t("agent.ownTag") : a.version}`) : "";
3728
4212
  };
3729
- console.log(table(ids().map((id) => [color.muted(agentName(id)), `${stateText(agentState(id))}${info(id)}`])));
4213
+ console.log(table(ids().map((id) => [color.muted(agentName(id)), `${stateText(agentState(id))}${info(id)}${ACCOUNT[id] ? color.muted(` ${icon.dot} ${t(ACCOUNT[id])}`) : ""}`])));
3730
4214
  console.log(`
3731
4215
  ${color.muted(t("agent.webHint"))}
3732
4216
  `);
@@ -3734,7 +4218,7 @@ function listAgents() {
3734
4218
  async function addAgent(id, download = false) {
3735
4219
  const known = isSupported(id) || (await fetchRegistry()).some((a) => a.id === id && a.distribution.local);
3736
4220
  if (!known)
3737
- return log.error(t("agent.unknown", { id, list: SUPPORTED_AGENTS.join(", ") })), false;
4221
+ return log.error(t("agent.unknown", { id, list: "codex, antigravity, opencode" })), false;
3738
4222
  log.info(t("agent.installing", { name: agentName(id) }));
3739
4223
  let last = -10;
3740
4224
  const a = await installAgent(id, (pc) => {
@@ -3754,21 +4238,30 @@ async function addAgent(id, download = false) {
3754
4238
  }
3755
4239
  async function loginOne(id) {
3756
4240
  log.info(t("agent.loggingIn", { name: agentName(id) }));
3757
- const stop = isAndroid() ? watchOpenRequests((url) => {
3758
- log.info(t("linux.openUrl", { url }));
3759
- openOnPhone(url);
3760
- }) : () => {
4241
+ const shown = new Set;
4242
+ const link = (url) => {
4243
+ if (shown.has(url))
4244
+ return;
4245
+ shown.add(url);
4246
+ if (isAndroid() && openOnPhone(url))
4247
+ log.info(t("linux.openUrl", { url }));
4248
+ else
4249
+ log.detail(t("agent.loginLink", { url }));
4250
+ };
4251
+ const stop = isAndroid() ? watchOpenRequests(link) : () => {
3761
4252
  return;
3762
4253
  };
3763
- const ok = await loginAgent(id, io).finally(stop);
3764
- if (ok)
4254
+ const ok = await loginAgent(id, { ...io, link }).finally(stop);
4255
+ if (ok) {
3765
4256
  log.ok(t("agent.loggedIn", { name: agentName(id) }));
3766
- else
4257
+ log.detail(t(runningPid() ? "agent.nextRunning" : "agent.nextStart", { name: agentName(id) }));
4258
+ } else
3767
4259
  log.warn(t("agent.loginFailed", { name: agentName(id) }));
3768
4260
  return ok;
3769
4261
  }
3770
4262
  async function agentCommand(args) {
3771
- const [sub, id] = args.rest;
4263
+ const [sub, raw] = args.rest;
4264
+ const id = raw ? resolveAgentId(raw) : raw;
3772
4265
  if (!sub || sub === "list")
3773
4266
  return listAgents();
3774
4267
  if (!id)
@@ -3784,22 +4277,23 @@ async function agentCommand(args) {
3784
4277
  removeAgent(id);
3785
4278
  return log.ok(t("agent.removed", { name: agentName(id) }));
3786
4279
  }
3787
- log.error("hypeframe agent list|add|login|remove <id>");
4280
+ log.error("hypeframe agent list|add|login|remove codex|antigravity|opencode");
3788
4281
  }
3789
4282
  async function agentMenu() {
3790
4283
  for (;; ) {
3791
4284
  const choice = await p.select({
3792
4285
  message: t("agent.menuQuestion"),
3793
- options: [...ids().map((id) => ({ value: id, label: agentName(id), hint: t(agentState(id) === "ready" ? "agent.ready" : agentState(id) === "login" ? "agent.needLogin" : "agent.notInstalled") })), { value: "", label: color.muted(t("agent.back")) }]
4286
+ options: [...ids().map((id) => ({ value: id, label: agentName(id), hint: agentHint(id, agentState(id)) })), { value: "", label: color.muted(t("agent.back")) }]
3794
4287
  });
3795
4288
  if (p.isCancel(choice) || !choice)
3796
4289
  return;
3797
4290
  const state = agentState(choice);
3798
4291
  const action = await p.select({
3799
- message: agentName(choice),
4292
+ message: `${agentName(choice)} · ${agentHint(choice, state)}`,
3800
4293
  options: [
3801
4294
  ...state === "none" ? [{ value: "add", label: t("agent.add") }] : [],
3802
- ...state !== "none" ? [{ value: "login", label: t("agent.login") }] : [],
4295
+ ...state === "login" ? [{ value: "login", label: t("agent.loginNow") }] : [],
4296
+ ...state === "ready" ? [{ value: "login", label: t("agent.login") }] : [],
3803
4297
  ...state !== "none" ? [{ value: "remove", label: t("agent.remove") }] : [],
3804
4298
  { value: "", label: color.muted(t("agent.back")) }
3805
4299
  ]
@@ -3811,8 +4305,11 @@ async function agentMenu() {
3811
4305
  await addAgent(choice);
3812
4306
  if (action === "login")
3813
4307
  await loginOne(choice);
3814
- if (action === "remove")
3815
- removeAgent(choice), log.ok(t("agent.removed", { name: agentName(choice) }));
4308
+ if (action === "remove") {
4309
+ const sure = await p.confirm({ message: t("agent.removeAsk", { name: agentName(choice) }), initialValue: false });
4310
+ if (sure === true)
4311
+ removeAgent(choice), log.ok(t("agent.removed", { name: agentName(choice) }));
4312
+ }
3816
4313
  } catch (e) {
3817
4314
  log.error(e.message);
3818
4315
  }
@@ -3886,7 +4383,7 @@ async function config(args) {
3886
4383
  }
3887
4384
 
3888
4385
  // src/cli/commands/doctor.ts
3889
- import { spawnSync as spawnSync5 } from "node:child_process";
4386
+ import { spawnSync as spawnSync4 } from "node:child_process";
3890
4387
  import fs21 from "node:fs";
3891
4388
  import path17 from "node:path";
3892
4389
  var mark = { ok: color.ok(icon.ok), warn: color.warn(icon.warn), error: color.error(icon.error) };
@@ -3931,7 +4428,7 @@ async function doctor(args) {
3931
4428
  const canDownload = !!FFMPEG_PINNED[`${process.platform}-${process.arch}`];
3932
4429
  show({ label: "ffmpeg", result: canDownload ? "warn" : "error", detail: canDownload ? t("doctor.ffmpegLater") : t("doctor.noFfmpeg") });
3933
4430
  } else {
3934
- const r = spawnSync5(ff, ["-hide_banner", "-version"], { encoding: "utf8", timeout: 15000 });
4431
+ const r = spawnSync4(ff, ["-hide_banner", "-version"], { encoding: "utf8", timeout: 15000 });
3935
4432
  const v = /ffmpeg version (\S+)/.exec(r.stdout || "")?.[1];
3936
4433
  show({ label: "ffmpeg", result: v ? "ok" : "error", detail: v || t("doctor.noFfmpeg") });
3937
4434
  }
@@ -4004,7 +4501,7 @@ function history() {
4004
4501
  }
4005
4502
 
4006
4503
  // src/cli/commands/maintenance.ts
4007
- import { spawnSync as spawnSync6 } from "node:child_process";
4504
+ import { spawnSync as spawnSync5 } from "node:child_process";
4008
4505
  import fs23 from "node:fs";
4009
4506
  import os4 from "node:os";
4010
4507
  import path19 from "node:path";
@@ -4080,7 +4577,7 @@ function update() {
4080
4577
  }
4081
4578
  log.info(t("update.running"));
4082
4579
  const [cmd, args, extra] = updateCommand({ standalone: isStandalone(), android: isAndroid(), windows: process.platform === "win32" });
4083
- const r = spawnSync6(cmd, args, { stdio: "inherit", ...extra });
4580
+ const r = spawnSync5(cmd, args, { stdio: "inherit", ...extra });
4084
4581
  if (r.status === 0)
4085
4582
  log.ok(t("update.done"));
4086
4583
  else
@@ -4121,36 +4618,165 @@ function status(args) {
4121
4618
 
4122
4619
  // src/cli/menu.ts
4123
4620
  import * as p3 from "@clack/prompts";
4621
+ function mainChoices(s) {
4622
+ return [
4623
+ { value: "start", label: color.brand(t("menu.start")), hint: s.running ? t("menu.runningHint") : s.paired ? undefined : t("menu.startPair") },
4624
+ { value: "open", label: t("menu.open") },
4625
+ { value: "agent", label: `${color.ai("✦")} ${t("menu.agent")}`, hint: s.agentsReady ? t("menu.agentReady", { n: s.agentsReady }) : t("menu.agentNone") },
4626
+ { value: "settings", label: t("menu.settings"), hint: t("menu.settingsHint") },
4627
+ { value: "help", label: t("menu.help"), hint: t("menu.helpHint") },
4628
+ { value: "exit", label: color.muted(t("menu.exit")) }
4629
+ ];
4630
+ }
4631
+ function helpChoices() {
4632
+ return [
4633
+ { value: "guide", label: t("menu.guide") },
4634
+ { value: "doctor", label: t("menu.doctor"), hint: t("menu.doctorHint") },
4635
+ { value: "update", label: t("menu.update"), hint: `${t("menu.now")} ${VERSION}` },
4636
+ { value: "bench", label: t("menu.bench") },
4637
+ { value: "history", label: t("menu.history") },
4638
+ { value: "clean", label: t("menu.clean"), hint: t("menu.cleanHint") },
4639
+ { value: "report", label: t("menu.report"), hint: t("menu.reportHint") },
4640
+ { value: "back", label: color.muted(t("agent.back")) }
4641
+ ];
4642
+ }
4643
+ function settingsChoices(s) {
4644
+ return [
4645
+ { value: "config", label: t("menu.config"), hint: t("menu.configHint") },
4646
+ { value: "autostart", label: t("menu.autostart"), hint: autostartEnabled() ? t("status.on") : t("status.off") },
4647
+ s.paired ? { value: "logout", label: t("menu.logout") } : { value: "login", label: t("menu.login") },
4648
+ { value: "back", label: color.muted(t("agent.back")) }
4649
+ ];
4650
+ }
4651
+ var needsGuide = (s, tty) => tty && !s.guided;
4652
+ async function guide(args) {
4653
+ p3.note(t("guide.intro"), t("guide.title"));
4654
+ const language = await p3.select({
4655
+ message: "Bahasa / Language",
4656
+ initialValue: readSettings().language && readSettings().language !== "auto" ? readSettings().language : "id",
4657
+ options: [
4658
+ { value: "id", label: "Bahasa Indonesia" },
4659
+ { value: "en", label: "English" }
4660
+ ]
4661
+ });
4662
+ if (!p3.isCancel(language)) {
4663
+ saveSettings({ language });
4664
+ resetLang();
4665
+ }
4666
+ const s = resolveSettings(args.flags);
4667
+ if (!(readAccount() && readAccount()?.gateway === s.gateway)) {
4668
+ const go = await p3.confirm({ message: t("guide.account"), initialValue: true });
4669
+ if (go === true)
4670
+ await login(args);
4671
+ }
4672
+ const agent = await p3.select({
4673
+ message: t("guide.agent"),
4674
+ options: [...SUPPORTED_AGENTS.map((id) => ({ value: id, label: agentName(id), hint: agentHint(id, agentState(id)) })), { value: "", label: color.muted(t("guide.later")) }]
4675
+ });
4676
+ if (!p3.isCancel(agent) && agent && agentState(agent) !== "ready") {
4677
+ try {
4678
+ await addAgent(agent);
4679
+ } catch (e) {
4680
+ p3.log.error(`${icon.error} ${e.message}`);
4681
+ }
4682
+ }
4683
+ if (isAndroid())
4684
+ p3.log.info(t("guide.android"));
4685
+ else if (!autostartEnabled()) {
4686
+ const on = await p3.confirm({ message: t("autostart.question"), initialValue: true });
4687
+ if (on === true)
4688
+ autostart("on");
4689
+ }
4690
+ saveSettings({ guided: true });
4691
+ if (runningPid())
4692
+ return false;
4693
+ const go = await p3.confirm({ message: t("guide.start"), initialValue: true });
4694
+ if (go !== true)
4695
+ return false;
4696
+ await start(args, { fromMenu: true });
4697
+ return true;
4698
+ }
4699
+ async function helpMenu(args) {
4700
+ const choice = await p3.select({ message: t("menu.help"), options: helpChoices() });
4701
+ if (p3.isCancel(choice) || choice === "back")
4702
+ return false;
4703
+ switch (choice) {
4704
+ case "guide":
4705
+ return guide(args);
4706
+ case "doctor":
4707
+ await doctor(args);
4708
+ break;
4709
+ case "update":
4710
+ update();
4711
+ break;
4712
+ case "bench":
4713
+ await bench(args);
4714
+ break;
4715
+ case "history": {
4716
+ const items = history();
4717
+ if (items.some((i) => i.file)) {
4718
+ const go = await p3.confirm({ message: t("history.openFolder"), initialValue: false });
4719
+ if (go === true)
4720
+ openFolder(renderDir());
4721
+ }
4722
+ break;
4723
+ }
4724
+ case "clean": {
4725
+ const ok = await p3.confirm({ message: t("clean.question"), initialValue: true });
4726
+ if (ok === true)
4727
+ await clean();
4728
+ break;
4729
+ }
4730
+ case "report":
4731
+ report();
4732
+ break;
4733
+ }
4734
+ return false;
4735
+ }
4736
+ async function settingsMenu(args, paired) {
4737
+ const choice = await p3.select({ message: t("menu.settings"), options: settingsChoices({ paired }) });
4738
+ if (p3.isCancel(choice) || choice === "back")
4739
+ return;
4740
+ switch (choice) {
4741
+ case "config":
4742
+ await config({ ...args, flags: {} });
4743
+ break;
4744
+ case "autostart": {
4745
+ const on = await p3.confirm({ message: t("autostart.question"), initialValue: !autostartEnabled() });
4746
+ if (!p3.isCancel(on))
4747
+ autostart(on ? "on" : "off");
4748
+ break;
4749
+ }
4750
+ case "login":
4751
+ await login(args);
4752
+ break;
4753
+ case "logout": {
4754
+ const ok = await p3.confirm({ message: t("confirm.logout"), initialValue: false });
4755
+ if (ok === true)
4756
+ logout();
4757
+ break;
4758
+ }
4759
+ }
4760
+ }
4124
4761
  async function menu(args) {
4125
4762
  process.stdout.write(banner());
4126
4763
  console.log("");
4127
4764
  console.log(table(statusRows(args)));
4128
4765
  console.log("");
4766
+ if (needsGuide(readSettings(), !!process.stdin.isTTY)) {
4767
+ try {
4768
+ if (await guide(args))
4769
+ return;
4770
+ } catch (e) {
4771
+ p3.log.error(`${icon.error} ${e.message}`);
4772
+ }
4773
+ }
4129
4774
  for (;; ) {
4130
4775
  const s = resolveSettings(args.flags);
4131
4776
  const paired = !!readAccount() && readAccount()?.gateway === s.gateway;
4132
4777
  const running = !!runningPid();
4133
- const choice = await p3.select({
4134
- message: t("menu.question"),
4135
- options: [
4136
- { value: "start", label: color.brand(t("menu.start")), hint: running ? t("status.running", { pid: runningPid() ?? "" }) : paired ? undefined : t("menu.startPair") },
4137
- { value: "open", label: t("menu.open"), hint: s.web.replace(/^https?:\/\//, "") },
4138
- { value: "bench", label: t("menu.bench") },
4139
- { value: "history", label: t("menu.history") },
4140
- { value: "agent", label: `${color.ai("✦")} ${t("menu.agent")}`, hint: (() => {
4141
- const n = readInstalled().filter((a) => a.ready).length;
4142
- return n ? t("menu.agentReady", { n }) : undefined;
4143
- })() },
4144
- { value: "autostart", label: t("menu.autostart"), hint: autostartEnabled() ? t("status.on") : t("status.off") },
4145
- { value: "config", label: t("menu.config") },
4146
- { value: "doctor", label: t("menu.doctor") },
4147
- { value: "clean", label: t("menu.clean") },
4148
- { value: "report", label: t("menu.report") },
4149
- { value: "update", label: t("menu.update") },
4150
- paired ? { value: "logout", label: t("menu.logout") } : { value: "login", label: t("menu.login") },
4151
- { value: "exit", label: color.muted(t("menu.exit")) }
4152
- ]
4153
- });
4778
+ const agentsReady = readInstalled().filter((a) => a.ready).length;
4779
+ const choice = await p3.select({ message: t("menu.question"), options: mainChoices({ paired, running, agentsReady }) });
4154
4780
  if (p3.isCancel(choice) || choice === "exit") {
4155
4781
  p3.outro(color.muted(t("menu.bye")));
4156
4782
  return;
@@ -4167,54 +4793,16 @@ async function menu(args) {
4167
4793
  case "open":
4168
4794
  openWeb(args);
4169
4795
  break;
4170
- case "bench":
4171
- await bench(args);
4172
- break;
4173
- case "history": {
4174
- const items = history();
4175
- if (items.some((i) => i.file)) {
4176
- const go = await p3.confirm({ message: t("history.openFolder"), initialValue: false });
4177
- if (go === true)
4178
- openFolder(renderDir());
4179
- }
4180
- break;
4181
- }
4182
4796
  case "agent":
4183
4797
  await agentMenu();
4184
4798
  break;
4185
- case "autostart": {
4186
- const on = await p3.confirm({ message: t("autostart.question"), initialValue: !autostartEnabled() });
4187
- if (!p3.isCancel(on))
4188
- autostart(on ? "on" : "off");
4189
- break;
4190
- }
4191
- case "config":
4192
- await config({ ...args, flags: {} });
4193
- break;
4194
- case "doctor":
4195
- await doctor(args);
4196
- break;
4197
- case "clean": {
4198
- const ok = await p3.confirm({ message: t("clean.question"), initialValue: true });
4199
- if (ok === true)
4200
- await clean();
4799
+ case "settings":
4800
+ await settingsMenu(args, paired);
4201
4801
  break;
4202
- }
4203
- case "report":
4204
- report();
4205
- break;
4206
- case "update":
4207
- update();
4208
- break;
4209
- case "login":
4210
- await login(args);
4211
- break;
4212
- case "logout": {
4213
- const ok = await p3.confirm({ message: t("confirm.logout"), initialValue: false });
4214
- if (ok === true)
4215
- logout();
4802
+ case "help":
4803
+ if (await helpMenu(args))
4804
+ return;
4216
4805
  break;
4217
- }
4218
4806
  }
4219
4807
  } catch (e) {
4220
4808
  p3.log.error(`${icon.error} ${e.message}`);
@@ -4233,6 +4821,7 @@ function help() {
4233
4821
  ["doctor", t("help.doctor")],
4234
4822
  ["bench", t("help.bench")],
4235
4823
  ["agent list|add|login|remove", t("help.agent")],
4824
+ ["chromium", t("help.chromium")],
4236
4825
  ["history", t("help.history")],
4237
4826
  ["autostart on|off", t("help.autostart")],
4238
4827
  ["config", t("help.config")],
@@ -4275,6 +4864,17 @@ var COMMANDS = {
4275
4864
  },
4276
4865
  bench: (a) => bench(a),
4277
4866
  agent: (a) => agentCommand(a),
4867
+ chromium: () => {
4868
+ if (!isAndroid())
4869
+ return log.info(t("chromium.notNeeded"));
4870
+ try {
4871
+ prepareLinuxChromium((k) => log.info(t(k)));
4872
+ log.detail(t("chromium.restart"));
4873
+ } catch (e) {
4874
+ log.error(t("chromium.failed", { reason: e.message }));
4875
+ process.exitCode = 1;
4876
+ }
4877
+ },
4278
4878
  "mcp-bridge": () => runMcpBridge(),
4279
4879
  history: () => history(),
4280
4880
  autostart: (a) => autostart(a.rest[0]),