hypeframe 0.5.1 → 0.6.1

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 +6 -2
  2. package/dist/index.js +541 -295
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -220,6 +220,13 @@ var id = {
220
220
  "agent.webHint": "Mengobrol dengan agen dilakukan di HypeFrame Web, halaman Asisten, selama mesin menyala.",
221
221
  "agent.toolNoTab": "Agen memanggil alat HypeFrame, tapi tab HypeFrame Web tidak terbuka. Buka HypeFrame Web lalu kirim pesannya lagi.",
222
222
  "agent.toolNoAnswer": "Agen memanggil alat HypeFrame, tapi HypeFrame Web tidak menjawab. Pastikan tabnya terbuka.",
223
+ "agent.unpacking": "100% · membuka paket (di HP bisa sampai beberapa menit)...",
224
+ "linux.preparing": "Agen di HP berjalan di Linux mini (Ubuntu lewat proot). Menyiapkannya sekali saja, unduhan sekitar 100 MB...",
225
+ "linux.pkg": "Memasang proot-distro...",
226
+ "linux.distro": "Mengunduh Ubuntu...",
227
+ "linux.apt": "Menyiapkan Ubuntu (sertifikat dan curl)...",
228
+ "linux.ready": "Linux mini siap.",
229
+ "linux.openUrl": "Buka di browser HP: {url}",
223
230
  "agent.keyFromShellAsk": "Pakai {name} yang sudah ada di terminal ini?",
224
231
  "agent.keyFromShell": "Memakai {name} dari terminal ini (disimpan untuk agen ini saja).",
225
232
  "agent.own": "{name} sudah terpasang di komputer ini ({path}); yang itu dipakai, tidak diunduh lagi.",
@@ -387,6 +394,13 @@ var en = {
387
394
  "agent.webHint": "Chatting with agents happens in HypeFrame Web, on the Assistant page, while the engine runs.",
388
395
  "agent.toolNoTab": "An agent called a HypeFrame tool, but no HypeFrame Web tab is open. Open HypeFrame Web and send the message again.",
389
396
  "agent.toolNoAnswer": "An agent called a HypeFrame tool, but HypeFrame Web did not answer. Make sure its tab is open.",
397
+ "agent.unpacking": "100% · unpacking (this can take a few minutes on a phone)...",
398
+ "linux.preparing": "Agents on a phone run in a Linux mini (Ubuntu under proot). Setting it up once, about 100 MB to download...",
399
+ "linux.pkg": "Installing proot-distro...",
400
+ "linux.distro": "Downloading Ubuntu...",
401
+ "linux.apt": "Preparing Ubuntu (certificates and curl)...",
402
+ "linux.ready": "Linux mini ready.",
403
+ "linux.openUrl": "Open in the phone browser: {url}",
390
404
  "agent.keyFromShellAsk": "Use the {name} already set in this terminal?",
391
405
  "agent.keyFromShell": "Using {name} from this terminal (saved for this agent only).",
392
406
  "agent.own": "{name} is already installed on this computer ({path}); that copy is used, nothing is downloaded.",
@@ -563,7 +577,7 @@ var log = {
563
577
  };
564
578
 
565
579
  // src/cli/commands/start.ts
566
- import crypto7 from "node:crypto";
580
+ import crypto8 from "node:crypto";
567
581
 
568
582
  // ../protocol/src/index.ts
569
583
  var PROTOCOL_VERSION = 1;
@@ -589,13 +603,13 @@ var EngineError = {
589
603
  };
590
604
 
591
605
  // src/agent/service.ts
592
- import crypto2 from "node:crypto";
593
- import fs8 from "node:fs";
594
- import path5 from "node:path";
606
+ import crypto3 from "node:crypto";
607
+ import fs10 from "node:fs";
608
+ import path7 from "node:path";
595
609
  // package.json
596
610
  var package_default = {
597
611
  name: "hypeframe",
598
- version: "0.5.1",
612
+ version: "0.6.1",
599
613
  description: "Local engine for HypeFrame Web: code clips, video renders and AI agents run on your own machine; the web is just the view.",
600
614
  keywords: [
601
615
  "hypeframe",
@@ -693,10 +707,166 @@ async function fetchRegistry() {
693
707
  return (Array.isArray(j.agents) ? j.agents : []).filter(valid).map((a) => local ? a : { ...a, distribution: { ...a.distribution, local: undefined } });
694
708
  }
695
709
 
696
- // src/agent/session.ts
710
+ // src/agent/linux.ts
711
+ import { spawnSync as spawnSync2 } from "node:child_process";
697
712
  import crypto from "node:crypto";
713
+ import fs7 from "node:fs";
714
+ import path4 from "node:path";
715
+
716
+ // src/util/which.ts
698
717
  import fs6 from "node:fs";
699
718
  import path3 from "node:path";
719
+ function isAndroid() {
720
+ return process.platform === "android" || !!process.env.TERMUX_VERSION || (process.env.PREFIX ?? "").includes("/com.termux/");
721
+ }
722
+ function onPath(name) {
723
+ if (!/^[\w.@+-]{1,80}$/.test(name))
724
+ return null;
725
+ const file = process.platform === "win32" ? /\.exe$/i.test(name) ? name : `${name}.exe` : name;
726
+ for (const dir of (process.env.PATH || "").split(path3.delimiter).filter(Boolean)) {
727
+ const f = path3.join(dir, file);
728
+ try {
729
+ const st = fs6.statSync(f);
730
+ if (st.isFile() && (process.platform === "win32" || st.mode & 73))
731
+ return f;
732
+ } catch {}
733
+ }
734
+ return null;
735
+ }
736
+
737
+ // src/agent/linux.ts
738
+ var DISTRO = "ubuntu";
739
+ function linuxDir() {
740
+ const d = path4.join(dataDir(), "linux");
741
+ fs7.mkdirSync(path4.join(d, "bin"), { recursive: true });
742
+ return d;
743
+ }
744
+ var readyFile = () => path4.join(linuxDir(), "siap");
745
+ var openFile = () => path4.join(linuxDir(), "buka-url");
746
+ var bridgeScript = () => path4.join(linuxDir(), "bin", "hf-mcp-bridge");
747
+ function linuxReady() {
748
+ return !!onPath("proot-distro") && fs7.existsSync(readyFile());
749
+ }
750
+ var shQuote = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
751
+ var VAR = /^[A-Za-z_][A-Za-z0-9_]*$/;
752
+ function linuxCommand(cmd, args, env = {}) {
753
+ const hf = dataDir();
754
+ const bin = path4.join(linuxDir(), "bin");
755
+ const vars = {
756
+ HOME: "/root",
757
+ LANG: "C.UTF-8",
758
+ DISPLAY: ":0",
759
+ BROWSER: path4.join(bin, "xdg-open"),
760
+ PATH: `${bin}:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`,
761
+ ...env
762
+ };
763
+ const script = [
764
+ "#!/bin/bash",
765
+ "# HypeFrame: one command in the Linux mini (written by the engine)",
766
+ ...Object.entries(vars).filter(([k]) => VAR.test(k)).map(([k, v]) => `export ${k}=${shQuote(v)}`),
767
+ `exec ${[cmd, ...args].map(shQuote).join(" ")}`,
768
+ ""
769
+ ].join(`
770
+ `);
771
+ const dir = path4.join(linuxDir(), "jalan");
772
+ fs7.mkdirSync(dir, { recursive: true, mode: 448 });
773
+ const file = path4.join(dir, `${crypto.createHash("sha256").update(script).digest("hex").slice(0, 24)}.sh`);
774
+ if (!fs7.existsSync(file))
775
+ fs7.writeFileSync(file, script, { mode: 384 });
776
+ return ["proot-distro", ["login", DISTRO, "--shared-tmp", "--bind", `${hf}:${hf}`, "--", "/bin/bash", file]];
777
+ }
778
+ var BRIDGE_SH = `#!/bin/bash
779
+ # HypeFrame tools for an agent in the Linux mini: stdio MCP <-> the engine on 127.0.0.1 (HF_MCP_URL, HF_MCP_KUNCI)
780
+ while IFS= read -r line || [ -n "$line" ]; do
781
+ [ -z "$line" ] && continue
782
+ out=$(printf '%s' "$line" | curl -sS --max-time 600 -X POST -H "authorization: Bearer $HF_MCP_KUNCI" -H 'content-type: application/json' --data-binary @- "$HF_MCP_URL" 2>/dev/null)
783
+ if [ $? -ne 0 ]; then
784
+ id=$(printf '%s' "$line" | sed -nE 's/.*"id"[[:space:]]*:[[:space:]]*("[^"]*"|[0-9]+).*/\\1/p')
785
+ [ -n "$id" ] && printf '{"jsonrpc":"2.0","id":%s,"error":{"code":-32000,"message":"The HypeFrame engine is not running on this phone."}}\\n' "$id"
786
+ continue
787
+ fi
788
+ [ -n "$out" ] && printf '%s\\n' "$out"
789
+ done
790
+ `;
791
+ function writeHelpers() {
792
+ const bin = path4.join(linuxDir(), "bin");
793
+ const open = `#!/bin/sh
794
+ # HypeFrame: open a link in the phone's browser (the engine watches this file)
795
+ [ -n "$1" ] || exit 0
796
+ printf '%s\\n' "$1" >> "${openFile()}"
797
+ `;
798
+ fs7.writeFileSync(path4.join(bin, "xdg-open"), open, { mode: 493 });
799
+ for (const n of ["x-www-browser", "www-browser", "sensible-browser"])
800
+ fs7.writeFileSync(path4.join(bin, n), open, { mode: 493 });
801
+ fs7.writeFileSync(bridgeScript(), BRIDGE_SH, { mode: 493 });
802
+ }
803
+ var runShown = (cmd, args) => spawnSync2(cmd, args, { stdio: ["ignore", "inherit", "inherit"], env: { ...process.env, DEBIAN_FRONTEND: "noninteractive" } }).status === 0;
804
+ function prepareLinux(say = () => {
805
+ return;
806
+ }, run = runShown) {
807
+ writeHelpers();
808
+ if (linuxReady())
809
+ return;
810
+ say("linux.preparing");
811
+ if (!onPath("proot-distro")) {
812
+ say("linux.pkg");
813
+ if (!run("pkg", ["install", "-y", "proot-distro"]))
814
+ throw new Error("pkg install proot-distro");
815
+ }
816
+ const exists = () => run(...linuxCommand("/bin/true", []));
817
+ if (!exists()) {
818
+ say("linux.distro");
819
+ if (!run("proot-distro", ["install", DISTRO]) && !exists())
820
+ throw new Error(`proot-distro install ${DISTRO}`);
821
+ }
822
+ say("linux.apt");
823
+ if (!run(...linuxCommand("/bin/sh", ["-c", "apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get install -y -q ca-certificates curl"])))
824
+ throw new Error("apt-get install ca-certificates curl");
825
+ fs7.writeFileSync(readyFile(), `${DISTRO}
826
+ `);
827
+ say("linux.ready");
828
+ }
829
+ function runInLinux(script) {
830
+ const [cmd, args] = linuxCommand("/bin/bash", ["-c", script]);
831
+ return spawnSync2(cmd, args, { stdio: ["ignore", "inherit", "inherit"] }).status === 0;
832
+ }
833
+ function watchOpenRequests(open, everyMs = 1000) {
834
+ const f = openFile();
835
+ try {
836
+ fs7.writeFileSync(f, "");
837
+ } catch {}
838
+ let seen = 0;
839
+ const tick = () => {
840
+ let text = "";
841
+ try {
842
+ text = fs7.readFileSync(f, "utf8");
843
+ } catch {
844
+ return;
845
+ }
846
+ if (text.length < seen)
847
+ seen = 0;
848
+ const fresh = text.slice(seen);
849
+ const end = fresh.lastIndexOf(`
850
+ `);
851
+ if (end < 0)
852
+ return;
853
+ seen += end + 1;
854
+ for (const line of fresh.slice(0, end).split(`
855
+ `)) {
856
+ const url = line.trim();
857
+ if (/^https?:\/\/[^\s]{1,2000}$/.test(url))
858
+ open(url);
859
+ }
860
+ };
861
+ const timer = setInterval(tick, everyMs);
862
+ timer.unref?.();
863
+ return () => clearInterval(timer);
864
+ }
865
+
866
+ // src/agent/session.ts
867
+ import crypto2 from "node:crypto";
868
+ import fs8 from "node:fs";
869
+ import path5 from "node:path";
700
870
 
701
871
  // src/agent/acp.ts
702
872
  import { spawn } from "node:child_process";
@@ -711,6 +881,13 @@ class RpcError extends Error {
711
881
  this.data = data;
712
882
  }
713
883
  }
884
+ function agentSpawn(agent, env = {}, extraArgs = []) {
885
+ if (agent.launch.linux) {
886
+ const [cmd, args] = linuxCommand(agent.launch.cmd, [...agent.launch.args, ...extraArgs], { ...agent.launch.env, ...env });
887
+ return [cmd, args, { ...process.env }];
888
+ }
889
+ return [agent.launch.cmd, [...agent.launch.args, ...extraArgs], { ...process.env, ...agent.launch.env, ...env }];
890
+ }
714
891
 
715
892
  class AcpProcess extends EventEmitter {
716
893
  child;
@@ -730,7 +907,8 @@ class AcpProcess extends EventEmitter {
730
907
  return this.stderrTail;
731
908
  }
732
909
  async start(agent, cwd, env = {}, timeoutMs = 180000) {
733
- const child = spawn(agent.launch.cmd, agent.launch.args, { cwd, env: { ...process.env, ...agent.launch.env, ...env }, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
910
+ const [cmd, args, childEnv] = agentSpawn(agent, env);
911
+ const child = spawn(cmd, args, { cwd, env: childEnv, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
734
912
  this.child = child;
735
913
  child.stderr?.on("data", (d) => this.stderrTail = (this.stderrTail + d).slice(-4096));
736
914
  child.stdin?.on("error", () => {
@@ -846,7 +1024,7 @@ function splitId(id) {
846
1024
  }
847
1025
  var lexists = (p) => {
848
1026
  try {
849
- fs6.lstatSync(p);
1027
+ fs8.lstatSync(p);
850
1028
  return true;
851
1029
  } catch {
852
1030
  return false;
@@ -855,16 +1033,16 @@ var lexists = (p) => {
855
1033
  function insideFolder(folder, p) {
856
1034
  if (typeof p !== "string" || !p)
857
1035
  return false;
858
- const abs = path3.resolve(folder, p);
859
- const rel = path3.relative(folder, abs);
860
- if (rel.startsWith("..") || path3.isAbsolute(rel))
1036
+ const abs = path5.resolve(folder, p);
1037
+ const rel = path5.relative(folder, abs);
1038
+ if (rel.startsWith("..") || path5.isAbsolute(rel))
861
1039
  return false;
862
1040
  let probe = abs;
863
- while (!lexists(probe) && path3.dirname(probe) !== probe)
864
- probe = path3.dirname(probe);
1041
+ while (!lexists(probe) && path5.dirname(probe) !== probe)
1042
+ probe = path5.dirname(probe);
865
1043
  try {
866
- const r = path3.relative(fs6.realpathSync(folder), fs6.realpathSync(probe));
867
- return !(r.startsWith("..") || path3.isAbsolute(r));
1044
+ const r = path5.relative(fs8.realpathSync(folder), fs8.realpathSync(probe));
1045
+ return !(r.startsWith("..") || path5.isAbsolute(r));
868
1046
  } catch {
869
1047
  return false;
870
1048
  }
@@ -909,8 +1087,8 @@ class AgentSessions {
909
1087
  }
910
1088
  this.o.onExit(agentId, code);
911
1089
  });
912
- const cwd = path3.join(agentDir(), agentId, "kerja");
913
- fs6.mkdirSync(cwd, { recursive: true });
1090
+ const cwd = path5.join(agentDir(), agentId, "kerja");
1091
+ fs8.mkdirSync(cwd, { recursive: true });
914
1092
  const p = proc.start(agent, cwd, this.o.env?.(agentId) ?? {}, this.o.startTimeoutMs ?? 180000).then((init) => {
915
1093
  const entry = { proc, init };
916
1094
  this.procs.set(agentId, entry);
@@ -931,9 +1109,9 @@ class AgentSessions {
931
1109
  if (live)
932
1110
  return { sessionId: key(resume), init, raw: {}, dimuat: "hidup", routeId: live.routeId, opsi: live.opsi ?? {} };
933
1111
  const cwd = projectDir(projectId);
934
- fs6.writeFileSync(path3.join(cwd, "AGENTS.md"), AGENTS_MD);
935
- const routeId = crypto.randomBytes(9).toString("base64url");
936
- const params = { cwd, mcpServers: this.o.mcpServers(cwd, projectId, routeId) };
1112
+ fs8.writeFileSync(path5.join(cwd, "AGENTS.md"), AGENTS_MD);
1113
+ const routeId = crypto2.randomBytes(9).toString("base64url");
1114
+ const params = { cwd, mcpServers: this.o.mcpServers(cwd, projectId, routeId, this.o.agent(agentId)) };
937
1115
  const limit = this.o.sessionTimeoutMs ?? 90000;
938
1116
  let raw;
939
1117
  let dimuat = "baru";
@@ -1084,12 +1262,12 @@ class AgentSessions {
1084
1262
  if (method === "fs/read_text_file") {
1085
1263
  if (!insideFolder(s.cwd, p.path))
1086
1264
  throw new RpcError(-32602, OUTSIDE);
1087
- const st = fs6.statSync(path3.resolve(s.cwd, p.path), { throwIfNoEntry: false });
1265
+ const st = fs8.statSync(path5.resolve(s.cwd, p.path), { throwIfNoEntry: false });
1088
1266
  if (!st?.isFile())
1089
1267
  throw new RpcError(-32602, "Not a regular file");
1090
1268
  if (st.size > MAX_READ)
1091
1269
  throw new RpcError(-32602, "File too large (over 10 MB)");
1092
- let content = fs6.readFileSync(path3.resolve(s.cwd, p.path), "utf8");
1270
+ let content = fs8.readFileSync(path5.resolve(s.cwd, p.path), "utf8");
1093
1271
  if (p.line || p.limit) {
1094
1272
  const lines = content.split(`
1095
1273
  `);
@@ -1102,9 +1280,9 @@ class AgentSessions {
1102
1280
  if (method === "fs/write_text_file") {
1103
1281
  if (!insideFolder(s.cwd, p.path))
1104
1282
  throw new RpcError(-32602, OUTSIDE);
1105
- const f = path3.resolve(s.cwd, p.path);
1106
- fs6.mkdirSync(path3.dirname(f), { recursive: true });
1107
- fs6.writeFileSync(f, String(p.content ?? ""));
1283
+ const f = path5.resolve(s.cwd, p.path);
1284
+ fs8.mkdirSync(path5.dirname(f), { recursive: true });
1285
+ fs8.writeFileSync(f, String(p.content ?? ""));
1108
1286
  return null;
1109
1287
  }
1110
1288
  throw new RpcError(-32601, `Method not found: ${method}`);
@@ -1112,8 +1290,8 @@ class AgentSessions {
1112
1290
  }
1113
1291
 
1114
1292
  // src/agent/store.ts
1115
- import fs7 from "node:fs";
1116
- import path4 from "node:path";
1293
+ import fs9 from "node:fs";
1294
+ import path6 from "node:path";
1117
1295
  function setReady(id, ready) {
1118
1296
  const a = readInstalled().find((x) => x.id === id);
1119
1297
  if (a)
@@ -1123,15 +1301,15 @@ var AGENT_ID = /^[a-z0-9][a-z0-9-]{0,39}$/;
1123
1301
  var folder = (id) => {
1124
1302
  if (typeof id !== "string" || !AGENT_ID.test(id))
1125
1303
  throw new Error(`Invalid agent id: ${JSON.stringify(String(id)).slice(0, 60)}`);
1126
- return path4.join(agentDir(), id);
1304
+ return path6.join(agentDir(), id);
1127
1305
  };
1128
1306
  function readInstalled() {
1129
1307
  const out = [];
1130
- for (const id of fs7.readdirSync(agentDir())) {
1308
+ for (const id of fs9.readdirSync(agentDir())) {
1131
1309
  if (!AGENT_ID.test(id))
1132
1310
  continue;
1133
1311
  try {
1134
- const a = JSON.parse(fs7.readFileSync(path4.join(folder(id), "agent.json"), "utf8"));
1312
+ const a = JSON.parse(fs9.readFileSync(path6.join(folder(id), "agent.json"), "utf8"));
1135
1313
  if (a.id === id && a.launch?.cmd)
1136
1314
  out.push(a);
1137
1315
  } catch {}
@@ -1139,26 +1317,26 @@ function readInstalled() {
1139
1317
  return out;
1140
1318
  }
1141
1319
  function writeInstalled(a) {
1142
- fs7.mkdirSync(folder(a.id), { recursive: true });
1143
- const f = path4.join(folder(a.id), "agent.json");
1144
- fs7.writeFileSync(`${f}.tmp`, JSON.stringify(a, null, 2));
1145
- fs7.renameSync(`${f}.tmp`, f);
1320
+ fs9.mkdirSync(folder(a.id), { recursive: true });
1321
+ const f = path6.join(folder(a.id), "agent.json");
1322
+ fs9.writeFileSync(`${f}.tmp`, JSON.stringify(a, null, 2));
1323
+ fs9.renameSync(`${f}.tmp`, f);
1146
1324
  }
1147
1325
  function removeAgent(id) {
1148
- fs7.rmSync(folder(id), { recursive: true, force: true });
1326
+ fs9.rmSync(folder(id), { recursive: true, force: true });
1149
1327
  }
1150
1328
  function agentEnv(id) {
1151
1329
  try {
1152
- return JSON.parse(fs7.readFileSync(path4.join(folder(id), "env.json"), "utf8"));
1330
+ return JSON.parse(fs9.readFileSync(path6.join(folder(id), "env.json"), "utf8"));
1153
1331
  } catch {
1154
1332
  return {};
1155
1333
  }
1156
1334
  }
1157
1335
  function saveAgentEnv(id, env) {
1158
- fs7.mkdirSync(folder(id), { recursive: true });
1159
- const f = path4.join(folder(id), "env.json");
1160
- fs7.writeFileSync(`${f}.tmp`, JSON.stringify({ ...agentEnv(id), ...env }), { mode: 384 });
1161
- fs7.renameSync(`${f}.tmp`, f);
1336
+ fs9.mkdirSync(folder(id), { recursive: true });
1337
+ const f = path6.join(folder(id), "env.json");
1338
+ fs9.writeFileSync(`${f}.tmp`, JSON.stringify({ ...agentEnv(id), ...env }), { mode: 384 });
1339
+ fs9.renameSync(`${f}.tmp`, f);
1162
1340
  }
1163
1341
 
1164
1342
  // src/agent/service.ts
@@ -1265,29 +1443,38 @@ function commandText(req) {
1265
1443
  return c.map((a) => typeof a === "string" && /^[\w@%+=:,./-]+$/.test(a) ? a : JSON.stringify(String(a))).join(" ");
1266
1444
  return typeof c === "string" ? c : String(req.toolCall.title ?? "");
1267
1445
  }
1446
+ function mcpServerFor(agent, url, key, bridge) {
1447
+ const env = [
1448
+ { name: "HF_MCP_URL", value: url },
1449
+ { name: "HF_MCP_KUNCI", value: key }
1450
+ ];
1451
+ if (agent?.launch.linux)
1452
+ return { name: "hypeframe", command: bridgeScript(), args: [], env };
1453
+ return { name: "hypeframe", command: bridge.command, args: bridge.args, env: [...bridge.env, ...env] };
1454
+ }
1268
1455
  function historyFile(projectId, sessionId) {
1269
- return path5.join(projectDir(projectId), "riwayat", `${crypto2.createHash("sha256").update(sessionId).digest("hex").slice(0, 32)}.jsonl`);
1456
+ return path7.join(projectDir(projectId), "riwayat", `${crypto3.createHash("sha256").update(sessionId).digest("hex").slice(0, 32)}.jsonl`);
1270
1457
  }
1271
1458
  function record(file, updates) {
1272
1459
  if (!updates.length)
1273
1460
  return;
1274
1461
  try {
1275
- fs8.mkdirSync(path5.dirname(file), { recursive: true });
1276
- fs8.appendFileSync(file, `${updates.map((u) => JSON.stringify(u)).join(`
1462
+ fs10.mkdirSync(path7.dirname(file), { recursive: true });
1463
+ fs10.appendFileSync(file, `${updates.map((u) => JSON.stringify(u)).join(`
1277
1464
  `)}
1278
1465
  `);
1279
- if (fs8.statSync(file).size > MAX_HISTORY) {
1280
- const text = fs8.readFileSync(file, "utf8");
1466
+ if (fs10.statSync(file).size > MAX_HISTORY) {
1467
+ const text = fs10.readFileSync(file, "utf8");
1281
1468
  const from = text.indexOf(`
1282
1469
  `, text.length - MAX_HISTORY / 2);
1283
- fs8.writeFileSync(file, from >= 0 ? text.slice(from + 1) : "");
1470
+ fs10.writeFileSync(file, from >= 0 ? text.slice(from + 1) : "");
1284
1471
  }
1285
1472
  } catch {}
1286
1473
  }
1287
1474
  function readHistory(file) {
1288
1475
  let text = "";
1289
1476
  try {
1290
- text = fs8.readFileSync(file, "utf8");
1477
+ text = fs10.readFileSync(file, "utf8");
1291
1478
  } catch {
1292
1479
  return { update: [], potong: false };
1293
1480
  }
@@ -1306,7 +1493,7 @@ function readHistory(file) {
1306
1493
  return { update: out.reverse(), potong: false };
1307
1494
  }
1308
1495
  function createAgentService(o) {
1309
- const key = crypto2.randomBytes(24).toString("base64url");
1496
+ const key = crypto3.randomBytes(24).toString("base64url");
1310
1497
  const routes = new Map;
1311
1498
  const sessionRoute = new Map;
1312
1499
  const permissions = new Map;
@@ -1337,18 +1524,7 @@ function createAgentService(o) {
1337
1524
  const sessions = new AgentSessions({
1338
1525
  agent: (id) => readInstalled().find((a) => a.id === id),
1339
1526
  env: (id) => agentEnv(id),
1340
- mcpServers: (_cwd, projectId, routeId) => [
1341
- {
1342
- name: "hypeframe",
1343
- command: o.bridge.command,
1344
- args: o.bridge.args,
1345
- env: [
1346
- ...o.bridge.env,
1347
- { name: "HF_MCP_URL", value: `http://127.0.0.1:${o.port()}/agen/mcp/${projectId}/${routeId}` },
1348
- { name: "HF_MCP_KUNCI", value: key }
1349
- ]
1350
- }
1351
- ],
1527
+ mcpServers: (_cwd, projectId, routeId, agent) => [mcpServerFor(agent, `http://127.0.0.1:${o.port()}/agen/mcp/${projectId}/${routeId}`, key, o.bridge)],
1352
1528
  onUpdate: (sessionId, list, info) => {
1353
1529
  const p = pending.get(sessionId);
1354
1530
  if (p)
@@ -1360,7 +1536,7 @@ function createAgentService(o) {
1360
1536
  record(file, packUpdates(list).flat());
1361
1537
  },
1362
1538
  onPermission: (sessionId, req, info) => new Promise((ok) => {
1363
- const id = `i${crypto2.randomBytes(6).toString("hex")}`;
1539
+ const id = `i${crypto3.randomBytes(6).toString("hex")}`;
1364
1540
  const done = (v) => (permissions.delete(id), ok(v));
1365
1541
  permissions.set(id, done);
1366
1542
  setTimeout(() => permissions.has(id) && done(null), 5 * 60000).unref();
@@ -1439,19 +1615,19 @@ function createAgentService(o) {
1439
1615
  const folder = projectDir(projectId);
1440
1616
  if (!p || !insideFolder(folder, p))
1441
1617
  return fail(`Only files inside the HypeFrame project folder (${folder}) can be added.`);
1442
- const file = path5.resolve(folder, p);
1443
- const st = fs8.statSync(file, { throwIfNoEntry: false });
1618
+ const file = path7.resolve(folder, p);
1619
+ const st = fs10.statSync(file, { throwIfNoEntry: false });
1444
1620
  if (!st?.isFile())
1445
1621
  return fail(`${p} is not a file in the project folder.`);
1446
- const nama = path5.basename(file).slice(0, 120);
1447
- const mime = MEDIA[path5.extname(file).slice(1).toLowerCase()];
1622
+ const nama = path7.basename(file).slice(0, 120);
1623
+ const mime = MEDIA[path7.extname(file).slice(1).toLowerCase()];
1448
1624
  if (!mime)
1449
1625
  return fail(`${nama}: only images, audio, video, fonts and Lottie/JSON files can be added to a HypeFrame project.`);
1450
1626
  if (st.size > MAX_FILE2)
1451
1627
  return fail(`${nama} is ${(st.size / 1048576).toFixed(1)} MB; files up to 4 MB can be sent to HypeFrame Web. Make it smaller (lower resolution or bitrate) and try again.`);
1452
- const data = fs8.readFileSync(file).toString("base64");
1628
+ const data = fs10.readFileSync(file).toString("base64");
1453
1629
  const n = Math.max(1, Math.ceil(data.length / PIECE));
1454
- const id = crypto2.randomBytes(8).toString("hex");
1630
+ const id = crypto3.randomBytes(8).toString("hex");
1455
1631
  let last = {};
1456
1632
  for (let i = 0;i < n; i++) {
1457
1633
  last = await o.conn.request(target.dari, "alat", { nama: "_berkas", arg: { id, i, n, nama, mime, ukuran: st.size, data: data.slice(i * PIECE, (i + 1) * PIECE) } });
@@ -1474,7 +1650,7 @@ function createAgentService(o) {
1474
1650
  if (!m)
1475
1651
  return false;
1476
1652
  const auth = String(req.headers.authorization || "").replace(/^Bearer\s+/i, "");
1477
- if (req.method !== "POST" || auth.length !== key.length || !crypto2.timingSafeEqual(Buffer.from(auth), Buffer.from(key)))
1653
+ if (req.method !== "POST" || auth.length !== key.length || !crypto3.timingSafeEqual(Buffer.from(auth), Buffer.from(key)))
1478
1654
  return reply(res, 401, { error: "unauthorized" }), true;
1479
1655
  let s = "";
1480
1656
  for await (const d of req)
@@ -1525,15 +1701,15 @@ function createAgentService(o) {
1525
1701
  }
1526
1702
 
1527
1703
  // src/agent/mcp-bridge.ts
1528
- import fs10 from "node:fs";
1529
- import path7 from "node:path";
1704
+ import fs12 from "node:fs";
1705
+ import path9 from "node:path";
1530
1706
  import readline2 from "node:readline";
1531
1707
 
1532
1708
  // src/util/runtime.ts
1533
- import fs9 from "node:fs";
1534
- import path6 from "node:path";
1709
+ import fs11 from "node:fs";
1710
+ import path8 from "node:path";
1535
1711
  function isStandalone() {
1536
- return path6.basename(process.execPath).toLowerCase().startsWith("hypeframe");
1712
+ return path8.basename(process.execPath).toLowerCase().startsWith("hypeframe");
1537
1713
  }
1538
1714
  function runtimeLabel() {
1539
1715
  const bun = process.versions.bun;
@@ -1543,7 +1719,7 @@ function launchCommand() {
1543
1719
  if (isStandalone())
1544
1720
  return [process.execPath];
1545
1721
  try {
1546
- const script = fs9.realpathSync(process.argv[1] || "");
1722
+ const script = fs11.realpathSync(process.argv[1] || "");
1547
1723
  return /[\\/]_npx[\\/]/.test(script) ? null : [process.execPath, script];
1548
1724
  } catch {
1549
1725
  return null;
@@ -1579,13 +1755,13 @@ rl.on('line', (line) => {
1579
1755
  rl.on('close', () => Promise.all(busy).then(() => process.exit(0)));
1580
1756
  `;
1581
1757
  function bridgeLaunch() {
1582
- const file = path7.join(agentDir(), "mcp-bridge.mjs");
1758
+ const file = path9.join(agentDir(), "mcp-bridge.mjs");
1583
1759
  let now = "";
1584
1760
  try {
1585
- now = fs10.readFileSync(file, "utf8");
1761
+ now = fs12.readFileSync(file, "utf8");
1586
1762
  } catch {}
1587
1763
  if (now !== BRIDGE_SOURCE)
1588
- fs10.writeFileSync(file, BRIDGE_SOURCE);
1764
+ fs12.writeFileSync(file, BRIDGE_SOURCE);
1589
1765
  return { command: process.execPath, args: [file], env: isStandalone() ? [{ name: "BUN_BE_BUN", value: "1" }] : [] };
1590
1766
  }
1591
1767
  async function runMcpBridge() {
@@ -1631,7 +1807,7 @@ async function runMcpBridge() {
1631
1807
  }
1632
1808
 
1633
1809
  // src/config/lock.ts
1634
- import fs11 from "node:fs";
1810
+ import fs13 from "node:fs";
1635
1811
  class AlreadyRunning extends Error {
1636
1812
  code = "SUDAH_JALAN";
1637
1813
  }
@@ -1645,7 +1821,7 @@ var alive = (pid) => {
1645
1821
  };
1646
1822
  function runningPid() {
1647
1823
  try {
1648
- const pid = Number(fs11.readFileSync(lockFile(), "utf8"));
1824
+ const pid = Number(fs13.readFileSync(lockFile(), "utf8"));
1649
1825
  return Number.isInteger(pid) && pid > 0 && pid !== process.pid && alive(pid) ? pid : null;
1650
1826
  } catch {
1651
1827
  return null;
@@ -1655,13 +1831,13 @@ function singleInstance() {
1655
1831
  const f = lockFile();
1656
1832
  for (let attempt = 0;attempt < 2; attempt++) {
1657
1833
  try {
1658
- const fd = fs11.openSync(f, "wx");
1659
- fs11.writeSync(fd, String(process.pid));
1660
- fs11.closeSync(fd);
1834
+ const fd = fs13.openSync(f, "wx");
1835
+ fs13.writeSync(fd, String(process.pid));
1836
+ fs13.closeSync(fd);
1661
1837
  const release = () => {
1662
1838
  try {
1663
- if (fs11.readFileSync(f, "utf8") === String(process.pid))
1664
- fs11.rmSync(f, { force: true });
1839
+ if (fs13.readFileSync(f, "utf8") === String(process.pid))
1840
+ fs13.rmSync(f, { force: true });
1665
1841
  } catch {}
1666
1842
  process.off("exit", release);
1667
1843
  };
@@ -1670,17 +1846,17 @@ function singleInstance() {
1670
1846
  } catch (e) {
1671
1847
  if (e.code !== "EEXIST")
1672
1848
  throw e;
1673
- const pid = Number(fs11.readFileSync(f, "utf8"));
1849
+ const pid = Number(fs13.readFileSync(f, "utf8"));
1674
1850
  if (Number.isInteger(pid) && pid > 0 && alive(pid))
1675
1851
  throw new AlreadyRunning("engine already running");
1676
- fs11.rmSync(f, { force: true });
1852
+ fs13.rmSync(f, { force: true });
1677
1853
  }
1678
1854
  }
1679
1855
  throw new AlreadyRunning("engine already running");
1680
1856
  }
1681
1857
 
1682
1858
  // src/engine/connection.ts
1683
- import crypto3 from "node:crypto";
1859
+ import crypto4 from "node:crypto";
1684
1860
  import { EventEmitter as EventEmitter2 } from "node:events";
1685
1861
  import WebSocket from "ws";
1686
1862
  var SILENCE_MAX_MS = 70000;
@@ -1726,7 +1902,7 @@ class Connection extends EventEmitter2 {
1726
1902
  request(ke, kind, body, timeoutMs = 55000) {
1727
1903
  if (!this.connected)
1728
1904
  return Promise.resolve({ ok: false, error: "terputus" });
1729
- const id = `q${this.nextReq++}${crypto3.randomBytes(6).toString("hex")}`;
1905
+ const id = `q${this.nextReq++}${crypto4.randomBytes(6).toString("hex")}`;
1730
1906
  return new Promise((ok) => {
1731
1907
  const timer = setTimeout(() => (this.waiting.delete(id), ok({ ok: false, error: "waktu" })), timeoutMs);
1732
1908
  timer.unref?.();
@@ -1909,41 +2085,18 @@ async function pair(o) {
1909
2085
  }
1910
2086
 
1911
2087
  // src/render/chrome.ts
1912
- import fs13 from "node:fs";
2088
+ import fs14 from "node:fs";
1913
2089
  import http from "node:http";
1914
- import path9 from "node:path";
2090
+ import path10 from "node:path";
1915
2091
  import { Browser, detectBrowserPlatform, getInstalledBrowsers, install, resolveBuildId } from "@puppeteer/browsers";
1916
2092
  import puppeteer from "puppeteer-core";
1917
-
1918
- // src/util/which.ts
1919
- import fs12 from "node:fs";
1920
- import path8 from "node:path";
1921
- function isAndroid() {
1922
- return process.platform === "android" || !!process.env.TERMUX_VERSION || (process.env.PREFIX ?? "").includes("/com.termux/");
1923
- }
1924
- function onPath(name) {
1925
- if (!/^[\w.@+-]{1,80}$/.test(name))
1926
- return null;
1927
- const file = process.platform === "win32" ? /\.exe$/i.test(name) ? name : `${name}.exe` : name;
1928
- for (const dir of (process.env.PATH || "").split(path8.delimiter).filter(Boolean)) {
1929
- const f = path8.join(dir, file);
1930
- try {
1931
- const st = fs12.statSync(f);
1932
- if (st.isFile() && (process.platform === "win32" || st.mode & 73))
1933
- return f;
1934
- } catch {}
1935
- }
1936
- return null;
1937
- }
1938
-
1939
- // src/render/chrome.ts
1940
2093
  function chromePlatformArgs(android = isAndroid()) {
1941
2094
  return android ? ["--no-sandbox"] : [];
1942
2095
  }
1943
2096
  function candidates() {
1944
2097
  const e = process.env;
1945
2098
  if (process.platform === "win32") {
1946
- return [e.PROGRAMFILES, e["PROGRAMFILES(X86)"], e.LOCALAPPDATA].filter((d) => !!d).flatMap((d) => [path9.join(d, "Google", "Chrome", "Application", "chrome.exe"), path9.join(d, "Microsoft", "Edge", "Application", "msedge.exe")]);
2099
+ return [e.PROGRAMFILES, e["PROGRAMFILES(X86)"], e.LOCALAPPDATA].filter((d) => !!d).flatMap((d) => [path10.join(d, "Google", "Chrome", "Application", "chrome.exe"), path10.join(d, "Microsoft", "Edge", "Application", "msedge.exe")]);
1947
2100
  }
1948
2101
  if (process.platform === "darwin") {
1949
2102
  return ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/Applications/Chromium.app/Contents/MacOS/Chromium", "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"];
@@ -1953,13 +2106,13 @@ function candidates() {
1953
2106
  function findChrome() {
1954
2107
  const forced = process.env.HYPEFRAME_CHROME;
1955
2108
  if (forced)
1956
- return fs13.existsSync(forced) ? forced : null;
1957
- return candidates().find((p) => fs13.existsSync(p)) || null;
2109
+ return fs14.existsSync(forced) ? forced : null;
2110
+ return candidates().find((p) => fs14.existsSync(p)) || null;
1958
2111
  }
1959
2112
  async function cachedChrome(cacheDir) {
1960
2113
  try {
1961
- const all = await getInstalledBrowsers({ cacheDir: path9.join(cacheDir, "chrome") });
1962
- return all.find((b) => b.browser === Browser.CHROME && fs13.existsSync(b.executablePath))?.executablePath ?? null;
2114
+ const all = await getInstalledBrowsers({ cacheDir: path10.join(cacheDir, "chrome") });
2115
+ return all.find((b) => b.browser === Browser.CHROME && fs14.existsSync(b.executablePath))?.executablePath ?? null;
1963
2116
  } catch {
1964
2117
  return null;
1965
2118
  }
@@ -1975,7 +2128,7 @@ async function prepareChrome(cacheDir, progress = () => {
1975
2128
  const platform = detectBrowserPlatform();
1976
2129
  if (!platform)
1977
2130
  throw new Error("Sistem ini belum didukung untuk render (Chrome tidak tersedia).");
1978
- const dir = path9.join(cacheDir, "chrome");
2131
+ const dir = path10.join(cacheDir, "chrome");
1979
2132
  const buildId = await resolveBuildId(Browser.CHROME, platform, "stable");
1980
2133
  progress(0, `Chrome ${buildId}`);
1981
2134
  const r = await install({
@@ -2025,10 +2178,10 @@ async function checkChrome(chrome, { gpu = false } = {}) {
2025
2178
  }
2026
2179
 
2027
2180
  // src/render/ffmpeg.ts
2028
- import crypto4 from "node:crypto";
2029
- import fs14 from "node:fs";
2181
+ import crypto5 from "node:crypto";
2182
+ import fs15 from "node:fs";
2030
2183
  import fsp from "node:fs/promises";
2031
- import path10 from "node:path";
2184
+ import path11 from "node:path";
2032
2185
  import { pipeline } from "node:stream/promises";
2033
2186
  import { Readable } from "node:stream";
2034
2187
  import zlib from "node:zlib";
@@ -2042,22 +2195,22 @@ var FFMPEG_PINNED = {
2042
2195
  "darwin-arm64": { sha256: "6be74d6f449889c2e87a75873894f8520cad56c08ac76f2a628d85b0519daaca", size: 19253088 }
2043
2196
  };
2044
2197
  var exe = process.platform === "win32" ? "ffmpeg.exe" : "ffmpeg";
2045
- var cached2 = (cacheDir) => path10.join(cacheDir, "ffmpeg", FFMPEG_RELEASE, exe);
2198
+ var cached2 = (cacheDir) => path11.join(cacheDir, "ffmpeg", FFMPEG_RELEASE, exe);
2046
2199
  var thisPlatform = () => `${process.platform}-${process.arch}`;
2047
2200
  async function findFfmpeg(cacheDir, key = thisPlatform()) {
2048
2201
  const forced = process.env.HYPEFRAME_FFMPEG;
2049
2202
  if (forced)
2050
- return fs14.existsSync(forced) ? forced : null;
2203
+ return fs15.existsSync(forced) ? forced : null;
2051
2204
  if (!FFMPEG_PINNED[key])
2052
2205
  return onPath("ffmpeg");
2053
2206
  try {
2054
2207
  const mod = await import("ffmpeg-static");
2055
2208
  const p = typeof mod.default === "string" ? mod.default : null;
2056
- if (p && fs14.existsSync(p))
2209
+ if (p && fs15.existsSync(p))
2057
2210
  return p;
2058
2211
  } catch {}
2059
2212
  const c = cached2(cacheDir);
2060
- return fs14.existsSync(c) ? c : null;
2213
+ return fs15.existsSync(c) ? c : null;
2061
2214
  }
2062
2215
  async function downloadVerified(url, sha256, dest, progress = () => {
2063
2216
  return;
@@ -2066,9 +2219,9 @@ async function downloadVerified(url, sha256, dest, progress = () => {
2066
2219
  if (!r.ok || !r.body)
2067
2220
  throw new Error(`download ${r.status}`);
2068
2221
  const total = Number(r.headers.get("content-length")) || 0;
2069
- await fsp.mkdir(path10.dirname(dest), { recursive: true });
2222
+ await fsp.mkdir(path11.dirname(dest), { recursive: true });
2070
2223
  const tmp = `${dest}.download`;
2071
- const hash = crypto4.createHash("sha256");
2224
+ const hash = crypto5.createHash("sha256");
2072
2225
  let got = 0;
2073
2226
  let last = -10;
2074
2227
  const body = Readable.fromWeb(r.body).on("data", (c) => {
@@ -2078,13 +2231,13 @@ async function downloadVerified(url, sha256, dest, progress = () => {
2078
2231
  if (pct - last >= 10)
2079
2232
  last = pct, progress(pct);
2080
2233
  });
2081
- await pipeline(body, fs14.createWriteStream(tmp));
2234
+ await pipeline(body, fs15.createWriteStream(tmp));
2082
2235
  if (hash.digest("hex") !== sha256) {
2083
2236
  await fsp.rm(tmp, { force: true });
2084
2237
  throw new Error("ffmpeg: sidik unduhan tidak cocok, berkas ditolak.");
2085
2238
  }
2086
2239
  if (gunzip) {
2087
- await pipeline(fs14.createReadStream(tmp), zlib.createGunzip(), fs14.createWriteStream(`${tmp}.raw`));
2240
+ await pipeline(fs15.createReadStream(tmp), zlib.createGunzip(), fs15.createWriteStream(`${tmp}.raw`));
2088
2241
  await fsp.rm(tmp, { force: true });
2089
2242
  await fsp.rename(`${tmp}.raw`, dest);
2090
2243
  } else
@@ -2108,10 +2261,10 @@ async function prepareFfmpeg(cacheDir, progress = () => {
2108
2261
 
2109
2262
  // src/render/job.ts
2110
2263
  import { spawn as spawn2 } from "node:child_process";
2111
- import crypto5 from "node:crypto";
2112
- import fs15 from "node:fs";
2264
+ import crypto6 from "node:crypto";
2265
+ import fs16 from "node:fs";
2113
2266
  import fsp2 from "node:fs/promises";
2114
- import path11 from "node:path";
2267
+ import path12 from "node:path";
2115
2268
  import puppeteer2 from "puppeteer-core";
2116
2269
  var LIMIT_SECONDS = 1800;
2117
2270
  function run(cmd, args, limitSeconds = 600) {
@@ -2128,7 +2281,7 @@ function run(cmd, args, limitSeconds = 600) {
2128
2281
  function saveBody(req, to, max) {
2129
2282
  return new Promise((ok, fail) => {
2130
2283
  let n = 0;
2131
- const out = fs15.createWriteStream(to);
2284
+ const out = fs16.createWriteStream(to);
2132
2285
  req.on("data", (d) => {
2133
2286
  n += d.length;
2134
2287
  if (n > max)
@@ -2159,7 +2312,7 @@ function createJobRunner(o) {
2159
2312
  const renderer = async (task, { progress, signal }) => {
2160
2313
  if (task.kind === "klip" && task.transparent && !transparent)
2161
2314
  throw new Error(EngineError.NoTransparent);
2162
- const key = crypto5.randomBytes(16).toString("hex");
2315
+ const key = crypto6.randomBytes(16).toString("hex");
2163
2316
  let finish;
2164
2317
  const finished = new Promise((ok) => finish = ok);
2165
2318
  running.set(task.job, { key, task, progress, finish });
@@ -2170,9 +2323,9 @@ function createJobRunner(o) {
2170
2323
  let browser;
2171
2324
  try {
2172
2325
  progress(0, "Menyiapkan");
2173
- const profile = path11.join(task.dir, "profil");
2174
- await fsp2.mkdir(path11.join(profile, "Default"), { recursive: true });
2175
- await fsp2.writeFile(path11.join(profile, "Default", "Preferences"), JSON.stringify({ webkit: { webprefs: { fonts: { standard: { Zyyy: "Roboto" }, sansserif: { Zyyy: "Roboto" }, serif: { Zyyy: "Noto Serif" } } } } }));
2326
+ const profile = path12.join(task.dir, "profil");
2327
+ await fsp2.mkdir(path12.join(profile, "Default"), { recursive: true });
2328
+ await fsp2.writeFile(path12.join(profile, "Default", "Preferences"), JSON.stringify({ webkit: { webprefs: { fonts: { standard: { Zyyy: "Roboto" }, sansserif: { Zyyy: "Roboto" }, serif: { Zyyy: "Noto Serif" } } } } }));
2176
2329
  browser = await puppeteer2.launch({
2177
2330
  executablePath: chrome,
2178
2331
  headless: true,
@@ -2203,9 +2356,9 @@ function createJobRunner(o) {
2203
2356
  if (result.error)
2204
2357
  throw new Error(result.error);
2205
2358
  progress(99, clip ? "Menyelesaikan klip" : "Menyelesaikan video");
2206
- const raw = path11.join(task.dir, "mentah.mp4");
2359
+ const raw = path12.join(task.dir, "mentah.mp4");
2207
2360
  const webm = clip && task.transparent;
2208
- const file = path11.join(task.dir, webm ? "hasil.webm" : "hasil.mp4");
2361
+ const file = path12.join(task.dir, webm ? "hasil.webm" : "hasil.mp4");
2209
2362
  if (clip)
2210
2363
  await fsp2.rename(raw, file);
2211
2364
  else
@@ -2232,11 +2385,11 @@ function createJobRunner(o) {
2232
2385
  return res.writeHead(403), res.end(), true;
2233
2386
  const pkg = r.task.packageDir;
2234
2387
  if (m[2] === "proyek.json" || m[2] === "klip.json" || m[3]) {
2235
- const f = m[3] ? path11.join(pkg, "aset", m[3]) : path11.join(pkg, m[2]);
2236
- if (!fs15.existsSync(f))
2388
+ const f = m[3] ? path12.join(pkg, "aset", m[3]) : path12.join(pkg, m[2]);
2389
+ if (!fs16.existsSync(f))
2237
2390
  return res.writeHead(404), res.end(), true;
2238
2391
  res.writeHead(200, { "content-type": m[3] ? "application/octet-stream" : "application/json", "content-length": (await fsp2.stat(f)).size });
2239
- fs15.createReadStream(f).pipe(res);
2392
+ fs16.createReadStream(f).pipe(res);
2240
2393
  return true;
2241
2394
  }
2242
2395
  if (m[2] === "kemajuan") {
@@ -2253,7 +2406,7 @@ function createJobRunner(o) {
2253
2406
  r.finish({ error: String(b.pesan || "Render gagal.").slice(0, 300) });
2254
2407
  return res.writeHead(204), res.end(), true;
2255
2408
  }
2256
- await saveBody(req, path11.join(r.task.dir, "mentah.mp4"), 8 * 1073741824);
2409
+ await saveBody(req, path12.join(r.task.dir, "mentah.mp4"), 8 * 1073741824);
2257
2410
  r.finish({ audio: String(req.headers["x-kodek-audio"] || "") });
2258
2411
  res.writeHead(204);
2259
2412
  res.end();
@@ -2263,9 +2416,9 @@ function createJobRunner(o) {
2263
2416
  }
2264
2417
 
2265
2418
  // src/render/page.ts
2266
- import fs16 from "node:fs";
2419
+ import fs17 from "node:fs";
2267
2420
  import fsp3 from "node:fs/promises";
2268
- import path12 from "node:path";
2421
+ import path13 from "node:path";
2269
2422
  var TYPES = {
2270
2423
  ".html": "text/html; charset=utf-8",
2271
2424
  ".js": "text/javascript",
@@ -2286,13 +2439,13 @@ var SAFE_PATH = /^[\w@.+-]+(?:\/[\w@.+-]+)*$/;
2286
2439
  var VERSION_ID = /^[0-9a-f]{12}$/;
2287
2440
  function createPage({ web, cacheDir }) {
2288
2441
  const base = `${String(web || "").replace(/\/+$/, "")}/render/`;
2289
- const root = path12.join(cacheDir, "halaman");
2442
+ const root = path13.join(cacheDir, "halaman");
2290
2443
  let version = null;
2291
- const versionDir = () => path12.join(root, version);
2444
+ const versionDir = () => path13.join(root, version);
2292
2445
  const pending = new Map;
2293
2446
  async function download(rel) {
2294
- const target = path12.join(versionDir(), rel);
2295
- if (fs16.existsSync(target))
2447
+ const target = path13.join(versionDir(), rel);
2448
+ if (fs17.existsSync(target))
2296
2449
  return target;
2297
2450
  if (!pending.has(rel)) {
2298
2451
  pending.set(rel, (async () => {
@@ -2300,7 +2453,7 @@ function createPage({ web, cacheDir }) {
2300
2453
  if (!r.ok)
2301
2454
  throw Object.assign(new Error(`halaman ${rel}: ${r.status}`), { status: r.status });
2302
2455
  const body = Buffer.from(await r.arrayBuffer());
2303
- await fsp3.mkdir(path12.dirname(target), { recursive: true });
2456
+ await fsp3.mkdir(path13.dirname(target), { recursive: true });
2304
2457
  await fsp3.writeFile(`${target}.tmp`, body);
2305
2458
  await fsp3.rename(`${target}.tmp`, target);
2306
2459
  return target;
@@ -2324,10 +2477,10 @@ function createPage({ web, cacheDir }) {
2324
2477
  await download(f);
2325
2478
  if (old !== version) {
2326
2479
  const all = (await fsp3.readdir(root).catch(() => [])).filter((d) => VERSION_ID.test(d));
2327
- const dated = await Promise.all(all.map(async (d) => ({ d, t: (await fsp3.stat(path12.join(root, d))).mtimeMs })));
2480
+ const dated = await Promise.all(all.map(async (d) => ({ d, t: (await fsp3.stat(path13.join(root, d))).mtimeMs })));
2328
2481
  for (const { d } of dated.sort((a, b) => b.t - a.t).slice(2))
2329
2482
  if (d !== version)
2330
- await fsp3.rm(path12.join(root, d), { recursive: true, force: true });
2483
+ await fsp3.rm(path13.join(root, d), { recursive: true, force: true });
2331
2484
  }
2332
2485
  return { version };
2333
2486
  }
@@ -2344,8 +2497,8 @@ function createPage({ web, cacheDir }) {
2344
2497
  return res.writeHead(404), res.end(), true;
2345
2498
  try {
2346
2499
  const f = await download(rel);
2347
- res.writeHead(200, { "content-type": TYPES[path12.extname(f)] || "application/octet-stream", "cache-control": "no-store" });
2348
- fs16.createReadStream(f).pipe(res);
2500
+ res.writeHead(200, { "content-type": TYPES[path13.extname(f)] || "application/octet-stream", "cache-control": "no-store" });
2501
+ fs17.createReadStream(f).pipe(res);
2349
2502
  } catch (e) {
2350
2503
  res.writeHead(e.status === 404 ? 404 : 502);
2351
2504
  res.end();
@@ -2362,14 +2515,14 @@ function createPage({ web, cacheDir }) {
2362
2515
  }
2363
2516
 
2364
2517
  // src/render/service.ts
2365
- import crypto6 from "node:crypto";
2366
- import fs17 from "node:fs";
2518
+ import crypto7 from "node:crypto";
2519
+ import fs18 from "node:fs";
2367
2520
  import fsp4 from "node:fs/promises";
2368
2521
  import http2 from "node:http";
2369
- import path13 from "node:path";
2522
+ import path14 from "node:path";
2370
2523
  import yauzl from "yauzl";
2371
2524
  var ACTIVE = new Set(["unggah", "antre", "jalan"]);
2372
- var safeEqual = (a, b) => a.length === b.length && crypto6.timingSafeEqual(Buffer.from(a), Buffer.from(b));
2525
+ var safeEqual = (a, b) => a.length === b.length && crypto7.timingSafeEqual(Buffer.from(a), Buffer.from(b));
2373
2526
  var BAD_ENTRY = /relative path|absolute path|invalid characters/i;
2374
2527
  function listZip(f) {
2375
2528
  return new Promise((ok, fail) => {
@@ -2393,14 +2546,14 @@ function extractZip(f, to) {
2393
2546
  zip.on("entry", (en) => {
2394
2547
  if (en.fileName.endsWith("/"))
2395
2548
  return zip.readEntry();
2396
- const target = path13.join(to, en.fileName);
2397
- if (!target.startsWith(to + path13.sep))
2549
+ const target = path14.join(to, en.fileName);
2550
+ if (!target.startsWith(to + path14.sep))
2398
2551
  return fail(new Error(EngineError.BadPackage));
2399
- fs17.mkdirSync(path13.dirname(target), { recursive: true });
2552
+ fs18.mkdirSync(path14.dirname(target), { recursive: true });
2400
2553
  zip.openReadStream(en, (e2, s) => {
2401
2554
  if (e2 || !s)
2402
2555
  return fail(e2 ?? new Error("zip"));
2403
- const out = fs17.createWriteStream(target);
2556
+ const out = fs18.createWriteStream(target);
2404
2557
  s.pipe(out);
2405
2558
  out.on("finish", () => zip.readEntry());
2406
2559
  out.on("error", fail);
@@ -2415,13 +2568,13 @@ function extractZip(f, to) {
2415
2568
  function saveBody2(req, to, max) {
2416
2569
  return new Promise((ok, fail) => {
2417
2570
  let n = 0;
2418
- const out = fs17.createWriteStream(to);
2571
+ const out = fs18.createWriteStream(to);
2419
2572
  req.on("data", (d) => {
2420
2573
  n += d.length;
2421
2574
  if (n > max) {
2422
2575
  req.destroy();
2423
2576
  out.destroy();
2424
- fs17.rm(to, { force: true }, () => fail(new Error("terlalu besar")));
2577
+ fs18.rm(to, { force: true }, () => fail(new Error("terlalu besar")));
2425
2578
  }
2426
2579
  });
2427
2580
  req.pipe(out);
@@ -2449,8 +2602,8 @@ async function createRenderService(o) {
2449
2602
  return;
2450
2603
  } } = o;
2451
2604
  const origins = new Set([].concat(o.origin || []));
2452
- const sign = (kind, body) => crypto6.createHmac("sha256", key).update(`${kind}.${body}`).digest("base64url");
2453
- const dir = (job) => path13.join(folder, job);
2605
+ const sign = (kind, body) => crypto7.createHmac("sha256", key).update(`${kind}.${body}`).digest("base64url");
2606
+ const dir = (job) => path14.join(folder, job);
2454
2607
  await fsp4.mkdir(folder, { recursive: true });
2455
2608
  function readTicket(req) {
2456
2609
  const tk = String(req.headers.authorization || "").replace(/^Bearer\s+/i, "");
@@ -2472,7 +2625,7 @@ async function createRenderService(o) {
2472
2625
  const jobs = new Map;
2473
2626
  const queue = [];
2474
2627
  let current = null;
2475
- const persist = (t) => fsp4.writeFile(path13.join(dir(t.job), "status.json"), JSON.stringify(t)).catch(() => {
2628
+ const persist = (t) => fsp4.writeFile(path14.join(dir(t.job), "status.json"), JSON.stringify(t)).catch(() => {
2476
2629
  return;
2477
2630
  });
2478
2631
  const update = (t, patch) => (Object.assign(t, patch, { diperbarui: Date.now() }), void persist(t));
@@ -2491,19 +2644,19 @@ async function createRenderService(o) {
2491
2644
  });
2492
2645
  async function clearFiles(t, all = false) {
2493
2646
  for (const n of all ? ["."] : ["paket", "paket.zip", "profil", "mentah.mp4", "mentah.webm"])
2494
- await fsp4.rm(path13.join(dir(t.job), n), { recursive: true, force: true }).catch(() => {
2647
+ await fsp4.rm(path14.join(dir(t.job), n), { recursive: true, force: true }).catch(() => {
2495
2648
  return;
2496
2649
  });
2497
2650
  if (!all) {
2498
2651
  for (const f of await fsp4.readdir(dir(t.job)).catch(() => []))
2499
2652
  if (/^p\d+$/.test(f))
2500
- await fsp4.rm(path13.join(dir(t.job), f), { force: true });
2653
+ await fsp4.rm(path14.join(dir(t.job), f), { force: true });
2501
2654
  }
2502
2655
  }
2503
2656
  async function openPackage(t) {
2504
2657
  const d = dir(t.job);
2505
2658
  const main = t.tiket.jenis === "klip" ? "klip.json" : "proyek.json";
2506
- const entries = await listZip(path13.join(d, "paket.zip"));
2659
+ const entries = await listZip(path14.join(d, "paket.zip"));
2507
2660
  const names = entries.map((x) => x.name).filter((n) => !n.endsWith("/"));
2508
2661
  if (names.some((n) => n.startsWith("/") || n.includes("..") || n.includes("\\") || n !== main && !/^aset\/[\w-]+$/.test(n)))
2509
2662
  throw new Error(EngineError.BadPackage);
@@ -2511,10 +2664,10 @@ async function createRenderService(o) {
2511
2664
  throw new Error(`Paket tidak berisi ${main}.`);
2512
2665
  if (entries.reduce((a, x) => a + x.size, 0) > maxUnzippedMb * 1048576)
2513
2666
  throw new Error("Isi paket terlalu besar.");
2514
- await extractZip(path13.join(d, "paket.zip"), path13.join(d, "paket"));
2515
- await fsp4.rm(path13.join(d, "paket.zip"), { force: true });
2516
- const j = JSON.parse(await fsp4.readFile(path13.join(d, "paket", main), "utf8"));
2517
- const has = (id) => /^[\w-]+$/.test(id) && fs17.existsSync(path13.join(d, "paket", "aset", id));
2667
+ await extractZip(path14.join(d, "paket.zip"), path14.join(d, "paket"));
2668
+ await fsp4.rm(path14.join(d, "paket.zip"), { force: true });
2669
+ const j = JSON.parse(await fsp4.readFile(path14.join(d, "paket", main), "utf8"));
2670
+ const has = (id) => /^[\w-]+$/.test(id) && fs18.existsSync(path14.join(d, "paket", "aset", id));
2518
2671
  if (main === "klip.json") {
2519
2672
  const k = j.klip || {};
2520
2673
  const seconds = Number(k.durationInFrames) / Number(k.fps);
@@ -2562,7 +2715,7 @@ async function createRenderService(o) {
2562
2715
  job: t.job,
2563
2716
  kind: t.tiket.jenis,
2564
2717
  dir: dir(t.job),
2565
- packageDir: path13.join(dir(t.job), "paket"),
2718
+ packageDir: path14.join(dir(t.job), "paket"),
2566
2719
  transparent: !!t.transparan,
2567
2720
  persen: t.persen,
2568
2721
  width: t.tiket.w,
@@ -2582,7 +2735,7 @@ async function createRenderService(o) {
2582
2735
  const size = (await fsp4.stat(h.file)).size;
2583
2736
  if (size < 200)
2584
2737
  throw new Error(EngineError.EmptyResult);
2585
- update(t, { status: "selesai", persen: 100, tahap: "", selesaiPada: Date.now(), hasilUkuran: size, hasilBerkas: path13.basename(h.file), hasilJenis: h.type });
2738
+ update(t, { status: "selesai", persen: 100, tahap: "", selesaiPada: Date.now(), hasilUkuran: size, hasilBerkas: path14.basename(h.file), hasilJenis: h.type });
2586
2739
  onJob("done", t);
2587
2740
  } catch (e) {
2588
2741
  if (t.status !== "batal") {
@@ -2620,10 +2773,10 @@ async function createRenderService(o) {
2620
2773
  if (a > z)
2621
2774
  return res.writeHead(416, { ...h, "content-range": `bytes */${st.size}` }), res.end();
2622
2775
  res.writeHead(206, { ...h, "content-length": z - a + 1, "content-range": `bytes ${a}-${z}/${st.size}` });
2623
- return void fs17.createReadStream(f, { start: a, end: z }).pipe(res);
2776
+ return void fs18.createReadStream(f, { start: a, end: z }).pipe(res);
2624
2777
  }
2625
2778
  res.writeHead(200, { ...h, "content-length": st.size });
2626
- fs17.createReadStream(f).pipe(res);
2779
+ fs18.createReadStream(f).pipe(res);
2627
2780
  }
2628
2781
  const ROUTE = /^\/tugas(?:\/(r_[a-f0-9]{16})(\/potongan\/(\d{1,4})|\/mulai|\/hasil)?)?$/;
2629
2782
  const server = http2.createServer(async (req, res) => {
@@ -2662,13 +2815,13 @@ async function createRenderService(o) {
2662
2815
  if (t.status !== "unggah")
2663
2816
  return json(req, res, 409, { galat: "Unggahan sudah ditutup." });
2664
2817
  const n = Number(m[3]);
2665
- const f = path13.join(dir(job), `p${n}`);
2666
- const before = fs17.existsSync(f) ? (await fsp4.stat(f)).size : 0;
2818
+ const f = path14.join(dir(job), `p${n}`);
2819
+ const before = fs18.existsSync(f) ? (await fsp4.stat(f)).size : 0;
2667
2820
  const room = Number(ticket.maksMb) * 1048576 - (t.terunggah - before);
2668
2821
  const size = await saveBody2(req, f, Math.min(partMb * 1048576 + 1024, room));
2669
2822
  const expected = String(req.headers["x-sha256"] || "").toLowerCase();
2670
2823
  if (expected) {
2671
- const digest = crypto6.createHash("sha256").update(await fsp4.readFile(f)).digest("hex");
2824
+ const digest = crypto7.createHash("sha256").update(await fsp4.readFile(f)).digest("hex");
2672
2825
  if (digest !== expected) {
2673
2826
  await fsp4.rm(f, { force: true });
2674
2827
  update(t, { terunggah: t.terunggah - before });
@@ -2685,13 +2838,13 @@ async function createRenderService(o) {
2685
2838
  const count = Number(b.jumlah);
2686
2839
  if (!(count > 0 && count < 1e4))
2687
2840
  return json(req, res, 400, { galat: "Jumlah potongan tidak valid." });
2688
- const zip = path13.join(dir(job), "paket.zip");
2689
- const out = fs17.createWriteStream(zip);
2690
- const hash = crypto6.createHash("sha256");
2841
+ const zip = path14.join(dir(job), "paket.zip");
2842
+ const out = fs18.createWriteStream(zip);
2843
+ const hash = crypto7.createHash("sha256");
2691
2844
  let total = 0;
2692
2845
  for (let i = 0;i < count; i++) {
2693
- const f = path13.join(dir(job), `p${i}`);
2694
- if (!fs17.existsSync(f))
2846
+ const f = path14.join(dir(job), `p${i}`);
2847
+ if (!fs18.existsSync(f))
2695
2848
  return out.destroy(), json(req, res, 400, { galat: `Potongan ${i + 1} belum terunggah.` });
2696
2849
  const part = await fsp4.readFile(f);
2697
2850
  hash.update(part);
@@ -2721,8 +2874,8 @@ async function createRenderService(o) {
2721
2874
  return json(req, res, 200, summary(t));
2722
2875
  }
2723
2876
  if (m[2] === "/hasil" && (req.method === "GET" || req.method === "HEAD")) {
2724
- const f = t.hasilBerkas ? path13.join(dir(job), t.hasilBerkas) : "";
2725
- if (t.status !== "selesai" || !f || !fs17.existsSync(f))
2877
+ const f = t.hasilBerkas ? path14.join(dir(job), t.hasilBerkas) : "";
2878
+ if (t.status !== "selesai" || !f || !fs18.existsSync(f))
2726
2879
  return json(req, res, 409, { galat: "Video belum jadi." });
2727
2880
  const webm = t.hasilJenis === "video/webm";
2728
2881
  return sendFile(req, res, f, webm ? "video/webm" : "video/mp4", `hypeframe-${job}.${webm ? "webm" : "mp4"}`);
@@ -2753,7 +2906,7 @@ async function createRenderService(o) {
2753
2906
  if (!JOB_ID.test(job))
2754
2907
  continue;
2755
2908
  try {
2756
- const t = JSON.parse(await fsp4.readFile(path13.join(dir(job), "status.json"), "utf8"));
2909
+ const t = JSON.parse(await fsp4.readFile(path14.join(dir(job), "status.json"), "utf8"));
2757
2910
  if (t.status === "jalan" || t.status === "antre")
2758
2911
  update(t, { status: "gagal", galat: EngineError.Restarted });
2759
2912
  jobs.set(job, t);
@@ -2863,6 +3016,12 @@ function openUrl(url, allowed) {
2863
3016
  function openFolder(dir) {
2864
3017
  launch(dir, false);
2865
3018
  }
3019
+ function openOnPhone(url) {
3020
+ if (!/^https?:\/\/[^\s]{1,2000}$/.test(url))
3021
+ return false;
3022
+ launch(url, true);
3023
+ return true;
3024
+ }
2866
3025
 
2867
3026
  // src/cli/commands/start.ts
2868
3027
  async function pairDevice(s, noBrowser = false) {
@@ -2916,8 +3075,13 @@ async function start(args, { fromMenu = false } = {}) {
2916
3075
  bridge: bridgeLaunch(),
2917
3076
  onToolError: (e) => log.warn(t(e === "tab" ? "agent.toolNoTab" : "agent.toolNoAnswer"))
2918
3077
  });
3078
+ if (isAndroid())
3079
+ watchOpenRequests((url) => {
3080
+ log.info(t("linux.openUrl", { url }));
3081
+ openOnPhone(url);
3082
+ });
2919
3083
  const capabilities = { render: false, chrome: null, transparan: false, agen: agents.capabilities() };
2920
- const key = crypto7.randomBytes(32).toString("base64url");
3084
+ const key = crypto8.randomBytes(32).toString("base64url");
2921
3085
  const cache = cacheDir();
2922
3086
  const page = createPage({ web: s.web, cacheDir: cache });
2923
3087
  let runner = null;
@@ -3053,24 +3217,24 @@ function logout() {
3053
3217
  }
3054
3218
 
3055
3219
  // src/cli/commands/autostart.ts
3056
- import { spawnSync as spawnSync2 } from "node:child_process";
3057
- import fs18 from "node:fs";
3220
+ import { spawnSync as spawnSync3 } from "node:child_process";
3221
+ import fs19 from "node:fs";
3058
3222
  import os3 from "node:os";
3059
- import path14 from "node:path";
3223
+ import path15 from "node:path";
3060
3224
  function entryFile() {
3061
3225
  const home = os3.homedir();
3062
3226
  if (process.platform === "win32")
3063
- return path14.join(process.env.APPDATA || path14.join(home, "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "HypeFrame.cmd");
3227
+ return path15.join(process.env.APPDATA || path15.join(home, "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "HypeFrame.cmd");
3064
3228
  if (process.platform === "darwin")
3065
- return path14.join(home, "Library", "LaunchAgents", "com.hypeframe.engine.plist");
3229
+ return path15.join(home, "Library", "LaunchAgents", "com.hypeframe.engine.plist");
3066
3230
  if (hasSystemd())
3067
- return path14.join(home, ".config", "systemd", "user", "hypeframe.service");
3068
- return path14.join(home, ".config", "autostart", "hypeframe.desktop");
3231
+ return path15.join(home, ".config", "systemd", "user", "hypeframe.service");
3232
+ return path15.join(home, ".config", "autostart", "hypeframe.desktop");
3069
3233
  }
3070
3234
  function hasSystemd() {
3071
- return process.platform === "linux" && spawnSync2("systemctl", ["--user", "--version"], { stdio: "ignore" }).status === 0;
3235
+ return process.platform === "linux" && spawnSync3("systemctl", ["--user", "--version"], { stdio: "ignore" }).status === 0;
3072
3236
  }
3073
- var autostartEnabled = () => fs18.existsSync(entryFile());
3237
+ var autostartEnabled = () => fs19.existsSync(entryFile());
3074
3238
  var xml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3075
3239
  function autostart(mode) {
3076
3240
  const file = entryFile();
@@ -3081,8 +3245,8 @@ function autostart(mode) {
3081
3245
  }
3082
3246
  if (mode === "off") {
3083
3247
  if (process.platform === "linux" && file.endsWith(".service"))
3084
- spawnSync2("systemctl", ["--user", "disable", "hypeframe.service"], { stdio: "ignore" });
3085
- fs18.rmSync(file, { force: true });
3248
+ spawnSync3("systemctl", ["--user", "disable", "hypeframe.service"], { stdio: "ignore" });
3249
+ fs19.rmSync(file, { force: true });
3086
3250
  log.ok(t("autostart.off"));
3087
3251
  return;
3088
3252
  }
@@ -3097,14 +3261,14 @@ function autostart(mode) {
3097
3261
  return;
3098
3262
  }
3099
3263
  const quoted = cmd.map((c) => `"${c}"`).join(" ");
3100
- fs18.mkdirSync(path14.dirname(file), { recursive: true });
3264
+ fs19.mkdirSync(path15.dirname(file), { recursive: true });
3101
3265
  if (process.platform === "win32") {
3102
- fs18.writeFileSync(file, `@echo off\r
3266
+ fs19.writeFileSync(file, `@echo off\r
3103
3267
  start "HypeFrame" /min ${quoted} start --no-browser\r
3104
3268
  `);
3105
3269
  } else if (process.platform === "darwin") {
3106
- const out = path14.join(logDir(), "autostart.log");
3107
- fs18.writeFileSync(file, `<?xml version="1.0" encoding="UTF-8"?>
3270
+ const out = path15.join(logDir(), "autostart.log");
3271
+ fs19.writeFileSync(file, `<?xml version="1.0" encoding="UTF-8"?>
3108
3272
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3109
3273
  <plist version="1.0"><dict>
3110
3274
  <key>Label</key><string>com.hypeframe.engine</string>
@@ -3115,7 +3279,7 @@ start "HypeFrame" /min ${quoted} start --no-browser\r
3115
3279
  </dict></plist>
3116
3280
  `);
3117
3281
  } else if (file.endsWith(".service")) {
3118
- fs18.writeFileSync(file, `[Unit]
3282
+ fs19.writeFileSync(file, `[Unit]
3119
3283
  Description=HypeFrame engine
3120
3284
  After=network-online.target
3121
3285
 
@@ -3127,10 +3291,10 @@ RestartSec=60
3127
3291
  [Install]
3128
3292
  WantedBy=default.target
3129
3293
  `);
3130
- spawnSync2("systemctl", ["--user", "daemon-reload"], { stdio: "ignore" });
3131
- spawnSync2("systemctl", ["--user", "enable", "hypeframe.service"], { stdio: "ignore" });
3294
+ spawnSync3("systemctl", ["--user", "daemon-reload"], { stdio: "ignore" });
3295
+ spawnSync3("systemctl", ["--user", "enable", "hypeframe.service"], { stdio: "ignore" });
3132
3296
  } else {
3133
- fs18.writeFileSync(file, `[Desktop Entry]
3297
+ fs19.writeFileSync(file, `[Desktop Entry]
3134
3298
  Type=Application
3135
3299
  Name=HypeFrame engine
3136
3300
  Exec=${quoted} start --no-browser
@@ -3232,9 +3396,9 @@ async function bench(args) {
3232
3396
  import * as p from "@clack/prompts";
3233
3397
 
3234
3398
  // src/agent/install.ts
3235
- import fs19 from "node:fs";
3399
+ import fs20 from "node:fs";
3236
3400
  import fsp5 from "node:fs/promises";
3237
- import path15 from "node:path";
3401
+ import path16 from "node:path";
3238
3402
  import yauzl2 from "yauzl";
3239
3403
  function unzip(file, to) {
3240
3404
  return new Promise((ok, fail) => {
@@ -3242,16 +3406,16 @@ function unzip(file, to) {
3242
3406
  if (e || !zip)
3243
3407
  return fail(e ?? new Error("zip"));
3244
3408
  zip.on("entry", (en) => {
3245
- const target = path15.join(to, en.fileName);
3246
- if (!target.startsWith(to + path15.sep))
3409
+ const target = path16.join(to, en.fileName);
3410
+ if (!target.startsWith(to + path16.sep))
3247
3411
  return fail(new Error("archive path outside the agent folder"));
3248
3412
  if (en.fileName.endsWith("/"))
3249
- return fs19.mkdirSync(target, { recursive: true }), zip.readEntry();
3250
- fs19.mkdirSync(path15.dirname(target), { recursive: true });
3413
+ return fs20.mkdirSync(target, { recursive: true }), zip.readEntry();
3414
+ fs20.mkdirSync(path16.dirname(target), { recursive: true });
3251
3415
  zip.openReadStream(en, (e2, s) => {
3252
3416
  if (e2 || !s)
3253
3417
  return fail(e2 ?? new Error("zip"));
3254
- const out = fs19.createWriteStream(target);
3418
+ const out = fs20.createWriteStream(target);
3255
3419
  s.pipe(out);
3256
3420
  out.on("finish", () => zip.readEntry());
3257
3421
  out.on("error", fail);
@@ -3266,7 +3430,7 @@ function unzip(file, to) {
3266
3430
  async function untarGz(file, to) {
3267
3431
  const { gunzipSync } = await import("node:zlib");
3268
3432
  const data = gunzipSync(await fsp5.readFile(file));
3269
- const root = path15.resolve(to);
3433
+ const root = path16.resolve(to);
3270
3434
  const str = (b) => b.toString("utf8").replace(/\0[\s\S]*$/, "");
3271
3435
  const octal = (b) => Number.parseInt(str(b).trim() || "0", 8) || 0;
3272
3436
  let off = 0;
@@ -3297,8 +3461,8 @@ async function untarGz(file, to) {
3297
3461
  name = name.replace(/^\.\//, "");
3298
3462
  if (!name)
3299
3463
  continue;
3300
- const target = path15.resolve(root, name);
3301
- if (target !== root && !target.startsWith(root + path15.sep))
3464
+ const target = path16.resolve(root, name);
3465
+ if (target !== root && !target.startsWith(root + path16.sep))
3302
3466
  throw new Error("archive path outside the agent folder");
3303
3467
  if (type === "5") {
3304
3468
  await fsp5.mkdir(target, { recursive: true });
@@ -3306,22 +3470,22 @@ async function untarGz(file, to) {
3306
3470
  }
3307
3471
  if (type !== "0" && type !== "7")
3308
3472
  continue;
3309
- await fsp5.mkdir(path15.dirname(target), { recursive: true });
3473
+ await fsp5.mkdir(path16.dirname(target), { recursive: true });
3310
3474
  await fsp5.writeFile(target, body, { mode: octal(h.subarray(100, 108)) & 73 ? 493 : 420 });
3311
3475
  }
3312
3476
  }
3313
3477
  function npxRunner(pkg, extra = []) {
3314
3478
  if (isStandalone())
3315
3479
  return { cmd: process.execPath, args: ["x", pkg, ...extra], env: { BUN_BE_BUN: "1" } };
3316
- const npxCli = path15.join(path15.dirname(process.execPath), process.platform === "win32" ? "" : "..", process.platform === "win32" ? "node_modules" : "lib/node_modules", "npm", "bin", "npx-cli.js");
3317
- if (!fs19.existsSync(npxCli))
3480
+ const npxCli = path16.join(path16.dirname(process.execPath), process.platform === "win32" ? "" : "..", process.platform === "win32" ? "node_modules" : "lib/node_modules", "npm", "bin", "npx-cli.js");
3481
+ if (!fs20.existsSync(npxCli))
3318
3482
  throw new Error("npx was not found next to Node.js");
3319
3483
  return { cmd: process.execPath, args: [npxCli, "-y", pkg, ...extra], env: {} };
3320
3484
  }
3321
3485
  function ownCopy(a) {
3322
3486
  const bin = a.distribution.binary?.[platformKey()];
3323
3487
  if (bin) {
3324
- const cmd = onPath(path15.basename(bin.cmd).replace(/\.exe$/i, ""));
3488
+ const cmd = onPath(path16.basename(bin.cmd).replace(/\.exe$/i, ""));
3325
3489
  return cmd ? { cmd, args: bin.args ?? [], env: bin.env ?? {} } : null;
3326
3490
  }
3327
3491
  const npx = a.distribution.npx;
@@ -3332,6 +3496,106 @@ function ownCopy(a) {
3332
3496
  }
3333
3497
  return null;
3334
3498
  }
3499
+ async function unpackBinary(id, version, bin, progress) {
3500
+ if (!/^[0-9a-f]{64}$/i.test(bin.sha256 || ""))
3501
+ throw new Error(`Agent ${id}: the registry gives no sha256; not installed`);
3502
+ const dir = path16.join(agentDir(), id, version);
3503
+ const tmp = `${dir}.tmp`;
3504
+ await fsp5.rm(tmp, { recursive: true, force: true });
3505
+ await fsp5.mkdir(tmp, { recursive: true });
3506
+ try {
3507
+ const name = path16.basename(new URL(bin.archive).pathname);
3508
+ const cmdRel = bin.cmd.replace(/^\.\//, "");
3509
+ if (/\.zip$/i.test(name)) {
3510
+ const file = path16.join(tmp, ".download.zip");
3511
+ await downloadVerified(bin.archive, bin.sha256.toLowerCase(), file, progress);
3512
+ await unzip(file, tmp);
3513
+ await fsp5.rm(file, { force: true });
3514
+ } else if (/\.(tar\.gz|tgz)$/i.test(name)) {
3515
+ const file = path16.join(tmp, ".download.tar.gz");
3516
+ await downloadVerified(bin.archive, bin.sha256.toLowerCase(), file, progress);
3517
+ await untarGz(file, tmp);
3518
+ await fsp5.rm(file, { force: true });
3519
+ } else if (/\.gz$/i.test(name)) {
3520
+ await downloadVerified(bin.archive, bin.sha256.toLowerCase(), path16.join(tmp, cmdRel), progress, true);
3521
+ } else
3522
+ throw new Error(`Agent ${id}: unsupported archive ${name}`);
3523
+ const cmd = path16.join(tmp, cmdRel);
3524
+ if (!fs20.existsSync(cmd))
3525
+ throw new Error(`Agent ${id}: ${bin.cmd} is not in the download`);
3526
+ if (process.platform !== "win32")
3527
+ await fsp5.chmod(cmd, 493);
3528
+ await fsp5.rm(dir, { recursive: true, force: true });
3529
+ await fsp5.rename(tmp, dir);
3530
+ return { cmd: path16.join(dir, cmdRel), args: bin.args ?? [], env: bin.env ?? {} };
3531
+ } catch (e) {
3532
+ await fsp5.rm(tmp, { recursive: true, force: true });
3533
+ throw e;
3534
+ }
3535
+ }
3536
+ var codexAcpRelease = () => process.env.HYPEFRAME_CODEX_ACP_RELEASE || "https://api.github.com/repos/zed-industries/codex-acp/releases/latest";
3537
+ async function codexAcpBuild(arch) {
3538
+ const j = await (await fetch(codexAcpRelease(), { headers: { accept: "application/vnd.github+json", "user-agent": "hypeframe" }, signal: AbortSignal.timeout(20000) })).json();
3539
+ const triple = arch === "x64" ? "x86_64" : "aarch64";
3540
+ const asset = (j.assets ?? []).find((x) => new RegExp(`${triple}-unknown-linux-musl\\.tar\\.gz$`).test(String(x.name)));
3541
+ const sha256 = /^sha256:([0-9a-f]{64})$/i.exec(String(asset?.digest ?? ""))?.[1];
3542
+ const url = String(asset?.browser_download_url ?? "");
3543
+ if (!asset || !sha256 || !url)
3544
+ throw new Error("codex-acp: no checked Linux build for this phone");
3545
+ if (!process.env.HYPEFRAME_CODEX_ACP_RELEASE && !url.startsWith("https://github.com/"))
3546
+ throw new Error("codex-acp: unexpected download address");
3547
+ return { url, sha256: sha256.toLowerCase(), version: String(j.tag_name ?? "latest").replace(/^v/, "") };
3548
+ }
3549
+ var findFile = (dir, name) => {
3550
+ for (const n of fs20.readdirSync(dir)) {
3551
+ const f = path16.join(dir, n);
3552
+ const st = fs20.lstatSync(f);
3553
+ if (st.isFile() && n === name)
3554
+ return f;
3555
+ if (st.isDirectory()) {
3556
+ const inner = findFile(f, name);
3557
+ if (inner)
3558
+ return inner;
3559
+ }
3560
+ }
3561
+ return null;
3562
+ };
3563
+ async function installInLinux(a, id, progress, steps, arch) {
3564
+ steps.prepare();
3565
+ if (id === "antigravity-acp") {
3566
+ if (!steps.run("(test -x /root/.local/bin/agy || curl -fsSL https://antigravity.google/cli/install.sh | bash) && test -x /root/.local/bin/agy"))
3567
+ throw new Error("Antigravity: Google's installer did not finish in the Linux mini, or agy is not at /root/.local/bin/agy");
3568
+ return { launch: { cmd: "/root/.local/bin/agy", args: ["acp"], env: {}, linux: true }, version: a.version };
3569
+ }
3570
+ if (id === "codex-acp") {
3571
+ const b = await codexAcpBuild(arch);
3572
+ const dir = path16.join(agentDir(), id, b.version);
3573
+ const tmp = `${dir}.tmp`;
3574
+ await fsp5.rm(tmp, { recursive: true, force: true });
3575
+ await fsp5.mkdir(tmp, { recursive: true });
3576
+ try {
3577
+ const file = path16.join(tmp, ".download.tar.gz");
3578
+ await downloadVerified(b.url, b.sha256, file, progress);
3579
+ await untarGz(file, tmp);
3580
+ await fsp5.rm(file, { force: true });
3581
+ const found = findFile(tmp, "codex-acp");
3582
+ if (!found)
3583
+ throw new Error("codex-acp: the program is not in the download");
3584
+ const rel = path16.relative(tmp, found);
3585
+ await fsp5.chmod(found, 493);
3586
+ await fsp5.rm(dir, { recursive: true, force: true });
3587
+ await fsp5.rename(tmp, dir);
3588
+ return { launch: { cmd: path16.join(dir, rel), args: [], env: {}, linux: true }, version: b.version };
3589
+ } catch (e) {
3590
+ await fsp5.rm(tmp, { recursive: true, force: true });
3591
+ throw e;
3592
+ }
3593
+ }
3594
+ const bin = a.distribution.binary?.[`linux-${arch === "x64" ? "x86_64" : "aarch64"}`];
3595
+ if (!bin)
3596
+ throw new Error(`Agent ${id} has no Linux build to run on this phone`);
3597
+ return { launch: { ...await unpackBinary(id, a.version, bin, progress), linux: true }, version: a.version };
3598
+ }
3335
3599
  async function installAgent(id, progress = () => {
3336
3600
  return;
3337
3601
  }, opts = {}) {
@@ -3341,6 +3605,13 @@ async function installAgent(id, progress = () => {
3341
3605
  const local = a.distribution.local;
3342
3606
  if (!isSupported(id) && !local)
3343
3607
  throw new Error(`Agent ${id} is not supported`);
3608
+ if (!local && (opts.android ?? isAndroid())) {
3609
+ const steps = opts.linux ?? { prepare: () => prepareLinux(opts.say), run: runInLinux };
3610
+ const r = await installInLinux(a, id, progress, steps, opts.arch ?? process.arch);
3611
+ const installed = { id, name: a.name, version: r.version, launch: r.launch };
3612
+ writeInstalled(installed);
3613
+ return installed;
3614
+ }
3344
3615
  let launch;
3345
3616
  const bin = a.distribution.binary?.[platformKey()];
3346
3617
  const own = local || opts.download ? null : ownCopy(a);
@@ -3349,41 +3620,7 @@ async function installAgent(id, progress = () => {
3349
3620
  } else if (own) {
3350
3621
  launch = own;
3351
3622
  } else if (bin) {
3352
- if (!/^[0-9a-f]{64}$/i.test(bin.sha256 || ""))
3353
- throw new Error(`Agent ${id}: the registry gives no sha256; not installed`);
3354
- const dir = path15.join(agentDir(), id, a.version);
3355
- const tmp = `${dir}.tmp`;
3356
- await fsp5.rm(tmp, { recursive: true, force: true });
3357
- await fsp5.mkdir(tmp, { recursive: true });
3358
- try {
3359
- const name = path15.basename(new URL(bin.archive).pathname);
3360
- const cmdRel = bin.cmd.replace(/^\.\//, "");
3361
- if (/\.zip$/i.test(name)) {
3362
- const file = path15.join(tmp, ".download.zip");
3363
- await downloadVerified(bin.archive, bin.sha256.toLowerCase(), file, progress);
3364
- await unzip(file, tmp);
3365
- await fsp5.rm(file, { force: true });
3366
- } else if (/\.(tar\.gz|tgz)$/i.test(name)) {
3367
- const file = path15.join(tmp, ".download.tar.gz");
3368
- await downloadVerified(bin.archive, bin.sha256.toLowerCase(), file, progress);
3369
- await untarGz(file, tmp);
3370
- await fsp5.rm(file, { force: true });
3371
- } else if (/\.gz$/i.test(name)) {
3372
- await downloadVerified(bin.archive, bin.sha256.toLowerCase(), path15.join(tmp, cmdRel), progress, true);
3373
- } else
3374
- throw new Error(`Agent ${id}: unsupported archive ${name}`);
3375
- const cmd = path15.join(tmp, cmdRel);
3376
- if (!fs19.existsSync(cmd))
3377
- throw new Error(`Agent ${id}: ${bin.cmd} is not in the download`);
3378
- if (process.platform !== "win32")
3379
- await fsp5.chmod(cmd, 493);
3380
- await fsp5.rm(dir, { recursive: true, force: true });
3381
- await fsp5.rename(tmp, dir);
3382
- launch = { cmd: path15.join(dir, cmdRel), args: bin.args ?? [], env: bin.env ?? {} };
3383
- } catch (e) {
3384
- await fsp5.rm(tmp, { recursive: true, force: true });
3385
- throw e;
3386
- }
3623
+ launch = await unpackBinary(id, a.version, bin, progress);
3387
3624
  } else if (a.distribution.npx) {
3388
3625
  launch = { ...npxRunner(a.distribution.npx.package, a.distribution.npx.args), env: { ...a.distribution.npx.env ?? {} } };
3389
3626
  if (isStandalone())
@@ -3396,7 +3633,7 @@ async function installAgent(id, progress = () => {
3396
3633
  }
3397
3634
 
3398
3635
  // src/agent/login.ts
3399
- import { spawnSync as spawnSync3 } from "node:child_process";
3636
+ import { spawnSync as spawnSync4 } from "node:child_process";
3400
3637
  async function keyFromShell(name, io) {
3401
3638
  const value = process.env[name];
3402
3639
  if (!value)
@@ -3443,7 +3680,8 @@ async function loginAgent(id, io) {
3443
3680
  }
3444
3681
  if (method?.type === "terminal") {
3445
3682
  io.say(method.name || method.description || id);
3446
- const r = spawnSync3(a.launch.cmd, [...a.launch.args, ...method.args ?? []], { stdio: "inherit", env: { ...process.env, ...a.launch.env, ...agentEnv(id), ...method.env ?? {} } });
3683
+ const [cmd, args, env] = agentSpawn(a, { ...agentEnv(id), ...method.env ?? {} }, method.args ?? []);
3684
+ const r = spawnSync4(cmd, args, { stdio: "inherit", env });
3447
3685
  if (r.status !== 0)
3448
3686
  return setReady(id, false), false;
3449
3687
  } else if (method && isKey(method)) {
@@ -3500,9 +3738,11 @@ async function addAgent(id, download = false) {
3500
3738
  log.info(t("agent.installing", { name: agentName(id) }));
3501
3739
  let last = -10;
3502
3740
  const a = await installAgent(id, (pc) => {
3503
- if (pc - last >= 20)
3504
- last = pc, log.detail(`${pc}%`);
3505
- }, { download });
3741
+ if (pc - last >= 20 || pc >= 100 && last < 100) {
3742
+ last = pc;
3743
+ log.detail(pc >= 100 ? t("agent.unpacking") : `${pc}%`);
3744
+ }
3745
+ }, { download, say: (k) => log.info(t(k)) });
3506
3746
  if (a.own)
3507
3747
  log.ok(t("agent.own", { name: a.name, path: a.launch.cmd }));
3508
3748
  else
@@ -3514,7 +3754,13 @@ async function addAgent(id, download = false) {
3514
3754
  }
3515
3755
  async function loginOne(id) {
3516
3756
  log.info(t("agent.loggingIn", { name: agentName(id) }));
3517
- const ok = await loginAgent(id, io);
3757
+ const stop = isAndroid() ? watchOpenRequests((url) => {
3758
+ log.info(t("linux.openUrl", { url }));
3759
+ openOnPhone(url);
3760
+ }) : () => {
3761
+ return;
3762
+ };
3763
+ const ok = await loginAgent(id, io).finally(stop);
3518
3764
  if (ok)
3519
3765
  log.ok(t("agent.loggedIn", { name: agentName(id) }));
3520
3766
  else
@@ -3640,9 +3886,9 @@ async function config(args) {
3640
3886
  }
3641
3887
 
3642
3888
  // src/cli/commands/doctor.ts
3643
- import { spawnSync as spawnSync4 } from "node:child_process";
3644
- import fs20 from "node:fs";
3645
- import path16 from "node:path";
3889
+ import { spawnSync as spawnSync5 } from "node:child_process";
3890
+ import fs21 from "node:fs";
3891
+ import path17 from "node:path";
3646
3892
  var mark = { ok: color.ok(icon.ok), warn: color.warn(icon.warn), error: color.error(icon.error) };
3647
3893
  async function reach(url) {
3648
3894
  const t0 = Date.now();
@@ -3671,10 +3917,10 @@ async function doctor(args) {
3671
3917
  show({ label: "Node.js", result: maj > 20 || maj === 20 && min >= 3 ? "ok" : "error", detail: `${process.versions.node}${maj < 20 || maj === 20 && min < 3 ? ` ${t("doctor.nodeOld")}` : ""}` });
3672
3918
  }
3673
3919
  try {
3674
- const probe = path16.join(dataDir(), `.probe-${process.pid}`);
3675
- fs20.writeFileSync(probe, "x");
3676
- fs20.rmSync(probe);
3677
- const st = fs20.statfsSync(dataDir());
3920
+ const probe = path17.join(dataDir(), `.probe-${process.pid}`);
3921
+ fs21.writeFileSync(probe, "x");
3922
+ fs21.rmSync(probe);
3923
+ const st = fs21.statfsSync(dataDir());
3678
3924
  const free = st.bavail * st.bsize;
3679
3925
  show({ label: t("doctor.disk"), result: free > 2 * 1024 ** 3 ? "ok" : "warn", detail: `${dataDir()} ${color.muted(icon.dot)} ${t("doctor.free", { size: bytes2(free) })}` });
3680
3926
  } catch (e) {
@@ -3685,7 +3931,7 @@ async function doctor(args) {
3685
3931
  const canDownload = !!FFMPEG_PINNED[`${process.platform}-${process.arch}`];
3686
3932
  show({ label: "ffmpeg", result: canDownload ? "warn" : "error", detail: canDownload ? t("doctor.ffmpegLater") : t("doctor.noFfmpeg") });
3687
3933
  } else {
3688
- const r = spawnSync4(ff, ["-hide_banner", "-version"], { encoding: "utf8", timeout: 15000 });
3934
+ const r = spawnSync5(ff, ["-hide_banner", "-version"], { encoding: "utf8", timeout: 15000 });
3689
3935
  const v = /ffmpeg version (\S+)/.exec(r.stdout || "")?.[1];
3690
3936
  show({ label: "ffmpeg", result: v ? "ok" : "error", detail: v || t("doctor.noFfmpeg") });
3691
3937
  }
@@ -3718,21 +3964,21 @@ async function doctor(args) {
3718
3964
  }
3719
3965
 
3720
3966
  // src/cli/commands/history.ts
3721
- import fs21 from "node:fs";
3722
- import path17 from "node:path";
3967
+ import fs22 from "node:fs";
3968
+ import path18 from "node:path";
3723
3969
  function readHistory2(hours = 24) {
3724
3970
  const root = renderDir();
3725
3971
  const since = Date.now() - hours * 3600000;
3726
3972
  const out = [];
3727
- for (const name of fs21.readdirSync(root)) {
3973
+ for (const name of fs22.readdirSync(root)) {
3728
3974
  if (!JOB_ID.test(name))
3729
3975
  continue;
3730
3976
  try {
3731
- const j = JSON.parse(fs21.readFileSync(path17.join(root, name, "status.json"), "utf8"));
3977
+ const j = JSON.parse(fs22.readFileSync(path18.join(root, name, "status.json"), "utf8"));
3732
3978
  if ((j.diperbarui || j.dibuat) < since)
3733
3979
  continue;
3734
- const f = j.hasilBerkas ? path17.join(root, name, j.hasilBerkas) : null;
3735
- out.push({ job: j, file: f && fs21.existsSync(f) ? f : null });
3980
+ const f = j.hasilBerkas ? path18.join(root, name, j.hasilBerkas) : null;
3981
+ out.push({ job: j, file: f && fs22.existsSync(f) ? f : null });
3736
3982
  } catch {}
3737
3983
  }
3738
3984
  return out.sort((a, b) => (b.job.diperbarui || 0) - (a.job.diperbarui || 0));
@@ -3758,31 +4004,31 @@ function history() {
3758
4004
  }
3759
4005
 
3760
4006
  // src/cli/commands/maintenance.ts
3761
- import { spawnSync as spawnSync5 } from "node:child_process";
3762
- import fs22 from "node:fs";
4007
+ import { spawnSync as spawnSync6 } from "node:child_process";
4008
+ import fs23 from "node:fs";
3763
4009
  import os4 from "node:os";
3764
- import path18 from "node:path";
4010
+ import path19 from "node:path";
3765
4011
  async function clean() {
3766
4012
  if (runningPid()) {
3767
4013
  log.warn(t("clean.running"));
3768
4014
  return;
3769
4015
  }
3770
- const targets = [path18.join(cacheDir(), "chrome"), path18.join(cacheDir(), "halaman"), path18.join(logDir(), "hypeframe.log.1")];
3771
- for (const job of fs22.readdirSync(renderDir())) {
4016
+ const targets = [path19.join(cacheDir(), "chrome"), path19.join(cacheDir(), "halaman"), path19.join(logDir(), "hypeframe.log.1")];
4017
+ for (const job of fs23.readdirSync(renderDir())) {
3772
4018
  if (!JOB_ID.test(job))
3773
4019
  continue;
3774
4020
  try {
3775
- const s = JSON.parse(fs22.readFileSync(path18.join(renderDir(), job, "status.json"), "utf8")).status;
4021
+ const s = JSON.parse(fs23.readFileSync(path19.join(renderDir(), job, "status.json"), "utf8")).status;
3776
4022
  if (s === "gagal" || s === "batal" || s === "unggah")
3777
- targets.push(path18.join(renderDir(), job));
4023
+ targets.push(path19.join(renderDir(), job));
3778
4024
  } catch {
3779
- targets.push(path18.join(renderDir(), job));
4025
+ targets.push(path19.join(renderDir(), job));
3780
4026
  }
3781
4027
  }
3782
4028
  let freed = 0;
3783
4029
  for (const p of targets) {
3784
4030
  freed += await sizeOf(p);
3785
- fs22.rmSync(p, { recursive: true, force: true });
4031
+ fs23.rmSync(p, { recursive: true, force: true });
3786
4032
  }
3787
4033
  log.ok(t("clean.done", { size: bytes2(freed) }));
3788
4034
  }
@@ -3791,7 +4037,7 @@ function report() {
3791
4037
  const a = readAccount();
3792
4038
  let recent = "";
3793
4039
  try {
3794
- recent = fs22.readFileSync(path18.join(logDir(), "hypeframe.log"), "utf8").split(`
4040
+ recent = fs23.readFileSync(path19.join(logDir(), "hypeframe.log"), "utf8").split(`
3795
4041
  `).slice(-400).join(`
3796
4042
  `);
3797
4043
  } catch {
@@ -3812,8 +4058,8 @@ function report() {
3812
4058
  recent
3813
4059
  ];
3814
4060
  const stamp = new Date().toISOString().slice(0, 19).replace(/[-:T]/g, "");
3815
- const file = path18.join(dataDir(), `laporan-${stamp}.txt`);
3816
- fs22.writeFileSync(file, mask(lines.join(`
4061
+ const file = path19.join(dataDir(), `laporan-${stamp}.txt`);
4062
+ fs23.writeFileSync(file, mask(lines.join(`
3817
4063
  `)), { mode: 384 });
3818
4064
  log.ok(t("report.done", { file }));
3819
4065
  log.detail(t("report.hint"));
@@ -3834,7 +4080,7 @@ function update() {
3834
4080
  }
3835
4081
  log.info(t("update.running"));
3836
4082
  const [cmd, args, extra] = updateCommand({ standalone: isStandalone(), android: isAndroid(), windows: process.platform === "win32" });
3837
- const r = spawnSync5(cmd, args, { stdio: "inherit", ...extra });
4083
+ const r = spawnSync6(cmd, args, { stdio: "inherit", ...extra });
3838
4084
  if (r.status === 0)
3839
4085
  log.ok(t("update.done"));
3840
4086
  else
@@ -3849,13 +4095,13 @@ function openWeb(args) {
3849
4095
  }
3850
4096
 
3851
4097
  // src/cli/commands/status.ts
3852
- import fs23 from "node:fs";
3853
- import path19 from "node:path";
4098
+ import fs24 from "node:fs";
4099
+ import path20 from "node:path";
3854
4100
  function statusRows(args) {
3855
4101
  const s = resolveSettings(args?.flags);
3856
4102
  const a = readAccount();
3857
4103
  const pid = runningPid();
3858
- const chrome = findChrome() || fs23.existsSync(path19.join(cacheDir(), "chrome"));
4104
+ const chrome = findChrome() || fs24.existsSync(path20.join(cacheDir(), "chrome"));
3859
4105
  const recent = readHistory2();
3860
4106
  const k = (key) => color.muted(t(key));
3861
4107
  return [