hypeframe 0.5.0 → 0.5.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 +22 -7
  2. package/dist/index.js +204 -192
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -71,6 +71,17 @@ The installer downloads a single `hypeframe` program from
71
71
  `hypeframe`. To pick a version: `HYPEFRAME_VERSION=0.3.0` (bash: `curl … | HYPEFRAME_VERSION=0.3.0 bash`). To update
72
72
  later: `hypeframe update`.
73
73
 
74
+ **Android** (in [Termux from F-Droid](https://f-droid.org/packages/com.termux/); the Play Store build is outdated)
75
+
76
+ ```bash
77
+ pkg install -y curl && curl -fsSL https://hype-frame.com/install | bash
78
+ termux-wake-lock; hypeframe start
79
+ ```
80
+
81
+ On Termux the same installer sets everything up by itself with `pkg`: Node.js, ffmpeg and Chromium (for renders; a
82
+ large download, once; skip it with `--no-render`), then hypeframe from npm. `termux-wake-lock` keeps Android from
83
+ stopping the engine while the screen is off; keep Termux open.
84
+
74
85
  **With Node.js** (20.3 or newer), the npm package works the same:
75
86
 
76
87
  ```bash
@@ -81,7 +92,7 @@ npm i -g hypeframe # keep it installed
81
92
  | | |
82
93
  |---|---|
83
94
  | System | Windows 10/11 (x64; ARM64 through emulation), macOS (Apple Silicon or Intel), Linux x64 or arm64 (glibc or musl/Alpine) |
84
- | Android | Through Termux with Node.js (`pkg install nodejs`, then `npx hypeframe`); the installer switches to npm there. Rendering needs Chromium; the HypeFrame app (APK) is the easier route. |
95
+ | Android | Through Termux: the installer adds Node.js, ffmpeg and Chromium with `pkg`. Whether renders work depends on that Chromium build (`hypeframe doctor` tells); agents that ship only glibc programs cannot run there. |
85
96
  | iPhone / iPad | Cannot run the engine. Use HypeFrame Web with "In this browser" rendering. |
86
97
  | Chrome | Uses the installed Chrome or Edge. Without one, Chrome for Testing is downloaded once (about 150 MB). |
87
98
  | ffmpeg | Comes with the npm package. The standalone program downloads the same build once (about 28 MB) and checks its sha256. |
@@ -163,7 +174,7 @@ engine directly. Every menu item is also a command:
163
174
  | `hypeframe report` | Write a problem report (versions, settings, recent log) with tokens masked |
164
175
  | `hypeframe update` | Update to the latest version (runs the installer again, or `npm i -g hypeframe@latest` for an npm install) |
165
176
  | `hypeframe agent list` | AI agents on this machine and whether they are ready |
166
- | `hypeframe agent add\|login\|remove <id>` | Install an agent and log in (`claude-acp`, `antigravity-acp`, `codex-acp`, `opencode`), log in again, or remove it. An agent you already installed yourself is used as it is; `--download` takes the official download anyway |
177
+ | `hypeframe agent add\|login\|remove <id>` | Install an agent and log in with your own account (`antigravity-acp`, `codex-acp`, `opencode`), log in again, or remove it. An agent you already installed yourself is used as it is; `--download` takes the official download anyway |
167
178
 
168
179
  | Option | Meaning |
169
180
  |---|---|
@@ -217,12 +228,16 @@ Chat with an AI agent that runs on this machine, from the Assistant page of Hype
217
228
  phone or tablet while the engine runs). Set each agent up once in the terminal: run `hypeframe`, choose **✦ AI
218
229
  assistant**, pick the agent, then **Install** and **Log in** (or `hypeframe agent add <id>`).
219
230
 
231
+ Each agent signs in with **your own account and subscription**; HypeFrame pays for and passes on no AI service.
232
+
220
233
  | Agent | Id | Account |
221
234
  |---|---|---|
222
- | Claude Code | `claude-acp` | Anthropic API key (Anthropic allows subscription logins only in its own apps) |
223
- | Antigravity | `antigravity-acp` | its own login |
224
- | Codex | `codex-acp` | its own login |
225
- | OpenCode | `opencode` | its own login |
235
+ | Antigravity | `antigravity-acp` | your Google account (including Google AI plans) |
236
+ | Codex | `codex-acp` | your ChatGPT account (Plus, Pro…), through "Sign in with ChatGPT" |
237
+ | OpenCode | `opencode` | the providers you set up in OpenCode |
238
+
239
+ Claude Code is not offered: Anthropic does not allow Claude Pro/Max sign-in in other apps, only API keys. With a Claude
240
+ subscription, use Claude's own apps and connect HypeFrame over MCP (HypeFrame Web → Settings → MCP).
226
241
 
227
242
  - Agents are downloaded from the official [ACP Registry](https://agentclientprotocol.com) and checked against its
228
243
  sha256. They run unmodified; HypeFrame talks to them over the Agent Client Protocol. An agent you installed yourself
@@ -238,7 +253,7 @@ assistant**, pick the agent, then **Install** and **Log in** (or `hypeframe agen
238
253
  - permission requests that name a place outside it are rejected without asking;
239
254
  - requests that name no place, and every terminal command, wait for your approval on the web, whatever the
240
255
  permission setting;
241
- - agent modes that skip asking (such as Claude Code's "bypass permissions" or "accept edits" in your own Claude
256
+ - agent modes that skip asking (such as "bypass permissions", "accept edits" or "full access" in your own agent
242
257
  settings) are switched back to the normal mode for every chat.
243
258
  - An agent's own built-in tools that never ask (for example reading files) follow that agent's own settings, and
244
259
  HypeFrame does not sandbox the agent process. Keep each agent on its normal "ask" setting.
package/dist/index.js CHANGED
@@ -213,7 +213,6 @@ var id = {
213
213
  "agent.loggingIn": "Masuk akun {name}...",
214
214
  "agent.loggedIn": "{name} siap. Buka HypeFrame Web lalu pilih {name} di Asisten (mesin harus menyala).",
215
215
  "agent.loginFailed": "{name} belum bisa dipakai: masuk akun belum berhasil. Coba lagi dari menu Asisten AI.",
216
- "agent.claudeKey": "Claude Code di HypeFrame memakai kunci API Anthropic (console.anthropic.com). Langganan Pro/Max hanya boleh dipakai di aplikasi Anthropic sendiri.",
217
216
  "agent.askKey": "Tempel {name}",
218
217
  "agent.removed": "{name} dilepas dari mesin ini.",
219
218
  "agent.unknown": "Agen {id} tidak didukung. Pilihan: {list}",
@@ -302,7 +301,7 @@ var id = {
302
301
  "help.open": "buka HypeFrame Web di browser",
303
302
  "help.doctor": "periksa Node, Chrome, ffmpeg, koneksi, ruang disk",
304
303
  "help.bench": "ukur kecepatan render 720p dan 1080p",
305
- "help.agent": "pasang dan masuk akun agen AI (Claude Code, Antigravity, Codex, OpenCode)",
304
+ "help.agent": "pasang dan masuk akun agen AI dengan langgananmu sendiri (Antigravity, Codex, OpenCode)",
306
305
  "help.history": "render 24 jam terakhir",
307
306
  "help.autostart": "nyalakan mesin saat masuk ke komputer",
308
307
  "help.config": "nama perangkat, GPU, bahasa",
@@ -381,7 +380,6 @@ var en = {
381
380
  "agent.loggingIn": "Logging in to {name}...",
382
381
  "agent.loggedIn": "{name} is ready. Open HypeFrame Web and pick {name} in the Assistant (the engine must be running).",
383
382
  "agent.loginFailed": "{name} is not usable yet: the login did not succeed. Try again from the AI assistant menu.",
384
- "agent.claudeKey": "Claude Code in HypeFrame uses an Anthropic API key (console.anthropic.com). Pro/Max subscriptions may only be used in Anthropic’s own apps.",
385
383
  "agent.askKey": "Paste {name}",
386
384
  "agent.removed": "{name} removed from this machine.",
387
385
  "agent.unknown": "Agent {id} is not supported. Choices: {list}",
@@ -470,7 +468,7 @@ var en = {
470
468
  "help.open": "open HypeFrame Web in the browser",
471
469
  "help.doctor": "check Node, Chrome, ffmpeg, network, disk space",
472
470
  "help.bench": "measure render speed at 720p and 1080p",
473
- "help.agent": "install and log in AI agents (Claude Code, Antigravity, Codex, OpenCode)",
471
+ "help.agent": "install and log in AI agents with your own subscription (Antigravity, Codex, OpenCode)",
474
472
  "help.history": "renders from the last 24 hours",
475
473
  "help.autostart": "start the engine when you sign in",
476
474
  "help.config": "device name, GPU, language",
@@ -597,7 +595,7 @@ import path5 from "node:path";
597
595
  // package.json
598
596
  var package_default = {
599
597
  name: "hypeframe",
600
- version: "0.5.0",
598
+ version: "0.5.1",
601
599
  description: "Local engine for HypeFrame Web: code clips, video renders and AI agents run on your own machine; the web is just the view.",
602
600
  keywords: [
603
601
  "hypeframe",
@@ -666,7 +664,7 @@ You are running on the user's computer through the HypeFrame engine. The user ty
666
664
  // src/agent/registry.ts
667
665
  import { spawnSync } from "node:child_process";
668
666
  import fs5 from "node:fs";
669
- var SUPPORTED_AGENTS = ["claude-acp", "antigravity-acp", "codex-acp", "opencode"];
667
+ var SUPPORTED_AGENTS = ["antigravity-acp", "codex-acp", "opencode"];
670
668
  var isSupported = (id) => SUPPORTED_AGENTS.includes(id);
671
669
  var OFFICIAL_REGISTRY = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json";
672
670
  var registryUrl = () => process.env.HYPEFRAME_ACP_REGISTRY || OFFICIAL_REGISTRY;
@@ -1911,54 +1909,73 @@ async function pair(o) {
1911
1909
  }
1912
1910
 
1913
1911
  // src/render/chrome.ts
1914
- import { execFileSync } from "node:child_process";
1915
- import fs12 from "node:fs";
1912
+ import fs13 from "node:fs";
1916
1913
  import http from "node:http";
1917
- import path8 from "node:path";
1914
+ import path9 from "node:path";
1918
1915
  import { Browser, detectBrowserPlatform, getInstalledBrowsers, install, resolveBuildId } from "@puppeteer/browsers";
1919
1916
  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
+ function chromePlatformArgs(android = isAndroid()) {
1941
+ return android ? ["--no-sandbox"] : [];
1942
+ }
1920
1943
  function candidates() {
1921
1944
  const e = process.env;
1922
1945
  if (process.platform === "win32") {
1923
- return [e.PROGRAMFILES, e["PROGRAMFILES(X86)"], e.LOCALAPPDATA].filter((d) => !!d).flatMap((d) => [path8.join(d, "Google", "Chrome", "Application", "chrome.exe"), path8.join(d, "Microsoft", "Edge", "Application", "msedge.exe")]);
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")]);
1924
1947
  }
1925
1948
  if (process.platform === "darwin") {
1926
1949
  return ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/Applications/Chromium.app/Contents/MacOS/Chromium", "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"];
1927
1950
  }
1928
- const found = [];
1929
- for (const n of ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]) {
1930
- try {
1931
- const p = execFileSync("which", [n], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
1932
- if (p)
1933
- found.push(p);
1934
- } catch {}
1935
- }
1936
- return found;
1951
+ return ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"].map((n) => onPath(n)).filter((p) => !!p);
1937
1952
  }
1938
1953
  function findChrome() {
1939
1954
  const forced = process.env.HYPEFRAME_CHROME;
1940
1955
  if (forced)
1941
- return fs12.existsSync(forced) ? forced : null;
1942
- return candidates().find((p) => fs12.existsSync(p)) || null;
1956
+ return fs13.existsSync(forced) ? forced : null;
1957
+ return candidates().find((p) => fs13.existsSync(p)) || null;
1943
1958
  }
1944
1959
  async function cachedChrome(cacheDir) {
1945
1960
  try {
1946
- const all = await getInstalledBrowsers({ cacheDir: path8.join(cacheDir, "chrome") });
1947
- return all.find((b) => b.browser === Browser.CHROME && fs12.existsSync(b.executablePath))?.executablePath ?? null;
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;
1948
1963
  } catch {
1949
1964
  return null;
1950
1965
  }
1951
1966
  }
1952
1967
  async function prepareChrome(cacheDir, progress = () => {
1953
1968
  return;
1954
- }) {
1969
+ }, opts = {}) {
1955
1970
  const found = findChrome();
1956
1971
  if (found)
1957
1972
  return found;
1973
+ if (opts.android ?? isAndroid())
1974
+ throw new Error("Chromium belum terpasang. Di Termux jalankan: pkg install x11-repo && pkg install chromium");
1958
1975
  const platform = detectBrowserPlatform();
1959
1976
  if (!platform)
1960
1977
  throw new Error("Sistem ini belum didukung untuk render (Chrome tidak tersedia).");
1961
- const dir = path8.join(cacheDir, "chrome");
1978
+ const dir = path9.join(cacheDir, "chrome");
1962
1979
  const buildId = await resolveBuildId(Browser.CHROME, platform, "stable");
1963
1980
  progress(0, `Chrome ${buildId}`);
1964
1981
  const r = await install({
@@ -1989,7 +2006,7 @@ var TRY_ENCODER = `async (c) => {
1989
2006
  async function checkChrome(chrome, { gpu = false } = {}) {
1990
2007
  const srv = http.createServer((_q, r) => (r.writeHead(200, { "content-type": "text/html" }), r.end("<!doctype html><title>check</title>")));
1991
2008
  await new Promise((ok) => srv.listen(0, "127.0.0.1", ok));
1992
- const b = await puppeteer.launch({ executablePath: chrome, headless: true, protocolTimeout: 60000, args: ["--no-first-run", "--disable-extensions", ...gpu ? [] : softwareGpuArgs] });
2009
+ const b = await puppeteer.launch({ executablePath: chrome, headless: true, protocolTimeout: 60000, args: ["--no-first-run", "--disable-extensions", ...gpu ? [] : softwareGpuArgs, ...chromePlatformArgs()] });
1993
2010
  try {
1994
2011
  const p = await b.newPage();
1995
2012
  await p.goto(`http://127.0.0.1:${srv.address().port}/`);
@@ -2009,9 +2026,9 @@ async function checkChrome(chrome, { gpu = false } = {}) {
2009
2026
 
2010
2027
  // src/render/ffmpeg.ts
2011
2028
  import crypto4 from "node:crypto";
2012
- import fs13 from "node:fs";
2029
+ import fs14 from "node:fs";
2013
2030
  import fsp from "node:fs/promises";
2014
- import path9 from "node:path";
2031
+ import path10 from "node:path";
2015
2032
  import { pipeline } from "node:stream/promises";
2016
2033
  import { Readable } from "node:stream";
2017
2034
  import zlib from "node:zlib";
@@ -2025,19 +2042,22 @@ var FFMPEG_PINNED = {
2025
2042
  "darwin-arm64": { sha256: "6be74d6f449889c2e87a75873894f8520cad56c08ac76f2a628d85b0519daaca", size: 19253088 }
2026
2043
  };
2027
2044
  var exe = process.platform === "win32" ? "ffmpeg.exe" : "ffmpeg";
2028
- var cached2 = (cacheDir) => path9.join(cacheDir, "ffmpeg", FFMPEG_RELEASE, exe);
2029
- async function findFfmpeg(cacheDir) {
2045
+ var cached2 = (cacheDir) => path10.join(cacheDir, "ffmpeg", FFMPEG_RELEASE, exe);
2046
+ var thisPlatform = () => `${process.platform}-${process.arch}`;
2047
+ async function findFfmpeg(cacheDir, key = thisPlatform()) {
2030
2048
  const forced = process.env.HYPEFRAME_FFMPEG;
2031
2049
  if (forced)
2032
- return fs13.existsSync(forced) ? forced : null;
2050
+ return fs14.existsSync(forced) ? forced : null;
2051
+ if (!FFMPEG_PINNED[key])
2052
+ return onPath("ffmpeg");
2033
2053
  try {
2034
2054
  const mod = await import("ffmpeg-static");
2035
2055
  const p = typeof mod.default === "string" ? mod.default : null;
2036
- if (p && fs13.existsSync(p))
2056
+ if (p && fs14.existsSync(p))
2037
2057
  return p;
2038
2058
  } catch {}
2039
2059
  const c = cached2(cacheDir);
2040
- return fs13.existsSync(c) ? c : null;
2060
+ return fs14.existsSync(c) ? c : null;
2041
2061
  }
2042
2062
  async function downloadVerified(url, sha256, dest, progress = () => {
2043
2063
  return;
@@ -2046,7 +2066,7 @@ async function downloadVerified(url, sha256, dest, progress = () => {
2046
2066
  if (!r.ok || !r.body)
2047
2067
  throw new Error(`download ${r.status}`);
2048
2068
  const total = Number(r.headers.get("content-length")) || 0;
2049
- await fsp.mkdir(path9.dirname(dest), { recursive: true });
2069
+ await fsp.mkdir(path10.dirname(dest), { recursive: true });
2050
2070
  const tmp = `${dest}.download`;
2051
2071
  const hash = crypto4.createHash("sha256");
2052
2072
  let got = 0;
@@ -2058,13 +2078,13 @@ async function downloadVerified(url, sha256, dest, progress = () => {
2058
2078
  if (pct - last >= 10)
2059
2079
  last = pct, progress(pct);
2060
2080
  });
2061
- await pipeline(body, fs13.createWriteStream(tmp));
2081
+ await pipeline(body, fs14.createWriteStream(tmp));
2062
2082
  if (hash.digest("hex") !== sha256) {
2063
2083
  await fsp.rm(tmp, { force: true });
2064
2084
  throw new Error("ffmpeg: sidik unduhan tidak cocok, berkas ditolak.");
2065
2085
  }
2066
2086
  if (gunzip) {
2067
- await pipeline(fs13.createReadStream(tmp), zlib.createGunzip(), fs13.createWriteStream(`${tmp}.raw`));
2087
+ await pipeline(fs14.createReadStream(tmp), zlib.createGunzip(), fs14.createWriteStream(`${tmp}.raw`));
2068
2088
  await fsp.rm(tmp, { force: true });
2069
2089
  await fsp.rename(`${tmp}.raw`, dest);
2070
2090
  } else
@@ -2074,14 +2094,13 @@ async function downloadVerified(url, sha256, dest, progress = () => {
2074
2094
  }
2075
2095
  async function prepareFfmpeg(cacheDir, progress = () => {
2076
2096
  return;
2077
- }) {
2078
- const found = await findFfmpeg(cacheDir);
2097
+ }, key = thisPlatform()) {
2098
+ const found = await findFfmpeg(cacheDir, key);
2079
2099
  if (found)
2080
2100
  return found;
2081
- const key = `${process.platform}-${process.arch}`;
2082
2101
  const pin = FFMPEG_PINNED[key];
2083
2102
  if (!pin)
2084
- throw new Error(`ffmpeg tidak tersedia untuk ${key}`);
2103
+ throw new Error(key.startsWith("android") ? "ffmpeg belum terpasang. Di Termux jalankan: pkg install ffmpeg" : `ffmpeg tidak tersedia untuk ${key}`);
2085
2104
  progress(0);
2086
2105
  await downloadVerified(`${BASE}ffmpeg-${key}.gz`, pin.sha256, cached2(cacheDir), progress, true);
2087
2106
  return cached2(cacheDir);
@@ -2090,9 +2109,9 @@ async function prepareFfmpeg(cacheDir, progress = () => {
2090
2109
  // src/render/job.ts
2091
2110
  import { spawn as spawn2 } from "node:child_process";
2092
2111
  import crypto5 from "node:crypto";
2093
- import fs14 from "node:fs";
2112
+ import fs15 from "node:fs";
2094
2113
  import fsp2 from "node:fs/promises";
2095
- import path10 from "node:path";
2114
+ import path11 from "node:path";
2096
2115
  import puppeteer2 from "puppeteer-core";
2097
2116
  var LIMIT_SECONDS = 1800;
2098
2117
  function run(cmd, args, limitSeconds = 600) {
@@ -2109,7 +2128,7 @@ function run(cmd, args, limitSeconds = 600) {
2109
2128
  function saveBody(req, to, max) {
2110
2129
  return new Promise((ok, fail) => {
2111
2130
  let n = 0;
2112
- const out = fs14.createWriteStream(to);
2131
+ const out = fs15.createWriteStream(to);
2113
2132
  req.on("data", (d) => {
2114
2133
  n += d.length;
2115
2134
  if (n > max)
@@ -2151,9 +2170,9 @@ function createJobRunner(o) {
2151
2170
  let browser;
2152
2171
  try {
2153
2172
  progress(0, "Menyiapkan");
2154
- const profile = path10.join(task.dir, "profil");
2155
- await fsp2.mkdir(path10.join(profile, "Default"), { recursive: true });
2156
- await fsp2.writeFile(path10.join(profile, "Default", "Preferences"), JSON.stringify({ webkit: { webprefs: { fonts: { standard: { Zyyy: "Roboto" }, sansserif: { Zyyy: "Roboto" }, serif: { Zyyy: "Noto Serif" } } } } }));
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" } } } } }));
2157
2176
  browser = await puppeteer2.launch({
2158
2177
  executablePath: chrome,
2159
2178
  headless: true,
@@ -2171,7 +2190,8 @@ function createJobRunner(o) {
2171
2190
  "--enable-unsafe-webgpu",
2172
2191
  ...gpu ? [] : ["--use-webgpu-adapter=swiftshader"],
2173
2192
  "--enable-features=Vulkan",
2174
- "--host-resolver-rules=MAP * ~NOTFOUND , EXCLUDE 127.0.0.1"
2193
+ "--host-resolver-rules=MAP * ~NOTFOUND , EXCLUDE 127.0.0.1",
2194
+ ...chromePlatformArgs()
2175
2195
  ]
2176
2196
  });
2177
2197
  browser.on("disconnected", () => finish({ error: EngineError.ChromeStopped }));
@@ -2183,9 +2203,9 @@ function createJobRunner(o) {
2183
2203
  if (result.error)
2184
2204
  throw new Error(result.error);
2185
2205
  progress(99, clip ? "Menyelesaikan klip" : "Menyelesaikan video");
2186
- const raw = path10.join(task.dir, "mentah.mp4");
2206
+ const raw = path11.join(task.dir, "mentah.mp4");
2187
2207
  const webm = clip && task.transparent;
2188
- const file = path10.join(task.dir, webm ? "hasil.webm" : "hasil.mp4");
2208
+ const file = path11.join(task.dir, webm ? "hasil.webm" : "hasil.mp4");
2189
2209
  if (clip)
2190
2210
  await fsp2.rename(raw, file);
2191
2211
  else
@@ -2212,11 +2232,11 @@ function createJobRunner(o) {
2212
2232
  return res.writeHead(403), res.end(), true;
2213
2233
  const pkg = r.task.packageDir;
2214
2234
  if (m[2] === "proyek.json" || m[2] === "klip.json" || m[3]) {
2215
- const f = m[3] ? path10.join(pkg, "aset", m[3]) : path10.join(pkg, m[2]);
2216
- if (!fs14.existsSync(f))
2235
+ const f = m[3] ? path11.join(pkg, "aset", m[3]) : path11.join(pkg, m[2]);
2236
+ if (!fs15.existsSync(f))
2217
2237
  return res.writeHead(404), res.end(), true;
2218
2238
  res.writeHead(200, { "content-type": m[3] ? "application/octet-stream" : "application/json", "content-length": (await fsp2.stat(f)).size });
2219
- fs14.createReadStream(f).pipe(res);
2239
+ fs15.createReadStream(f).pipe(res);
2220
2240
  return true;
2221
2241
  }
2222
2242
  if (m[2] === "kemajuan") {
@@ -2233,7 +2253,7 @@ function createJobRunner(o) {
2233
2253
  r.finish({ error: String(b.pesan || "Render gagal.").slice(0, 300) });
2234
2254
  return res.writeHead(204), res.end(), true;
2235
2255
  }
2236
- await saveBody(req, path10.join(r.task.dir, "mentah.mp4"), 8 * 1073741824);
2256
+ await saveBody(req, path11.join(r.task.dir, "mentah.mp4"), 8 * 1073741824);
2237
2257
  r.finish({ audio: String(req.headers["x-kodek-audio"] || "") });
2238
2258
  res.writeHead(204);
2239
2259
  res.end();
@@ -2243,9 +2263,9 @@ function createJobRunner(o) {
2243
2263
  }
2244
2264
 
2245
2265
  // src/render/page.ts
2246
- import fs15 from "node:fs";
2266
+ import fs16 from "node:fs";
2247
2267
  import fsp3 from "node:fs/promises";
2248
- import path11 from "node:path";
2268
+ import path12 from "node:path";
2249
2269
  var TYPES = {
2250
2270
  ".html": "text/html; charset=utf-8",
2251
2271
  ".js": "text/javascript",
@@ -2266,13 +2286,13 @@ var SAFE_PATH = /^[\w@.+-]+(?:\/[\w@.+-]+)*$/;
2266
2286
  var VERSION_ID = /^[0-9a-f]{12}$/;
2267
2287
  function createPage({ web, cacheDir }) {
2268
2288
  const base = `${String(web || "").replace(/\/+$/, "")}/render/`;
2269
- const root = path11.join(cacheDir, "halaman");
2289
+ const root = path12.join(cacheDir, "halaman");
2270
2290
  let version = null;
2271
- const versionDir = () => path11.join(root, version);
2291
+ const versionDir = () => path12.join(root, version);
2272
2292
  const pending = new Map;
2273
2293
  async function download(rel) {
2274
- const target = path11.join(versionDir(), rel);
2275
- if (fs15.existsSync(target))
2294
+ const target = path12.join(versionDir(), rel);
2295
+ if (fs16.existsSync(target))
2276
2296
  return target;
2277
2297
  if (!pending.has(rel)) {
2278
2298
  pending.set(rel, (async () => {
@@ -2280,7 +2300,7 @@ function createPage({ web, cacheDir }) {
2280
2300
  if (!r.ok)
2281
2301
  throw Object.assign(new Error(`halaman ${rel}: ${r.status}`), { status: r.status });
2282
2302
  const body = Buffer.from(await r.arrayBuffer());
2283
- await fsp3.mkdir(path11.dirname(target), { recursive: true });
2303
+ await fsp3.mkdir(path12.dirname(target), { recursive: true });
2284
2304
  await fsp3.writeFile(`${target}.tmp`, body);
2285
2305
  await fsp3.rename(`${target}.tmp`, target);
2286
2306
  return target;
@@ -2304,10 +2324,10 @@ function createPage({ web, cacheDir }) {
2304
2324
  await download(f);
2305
2325
  if (old !== version) {
2306
2326
  const all = (await fsp3.readdir(root).catch(() => [])).filter((d) => VERSION_ID.test(d));
2307
- const dated = await Promise.all(all.map(async (d) => ({ d, t: (await fsp3.stat(path11.join(root, d))).mtimeMs })));
2327
+ const dated = await Promise.all(all.map(async (d) => ({ d, t: (await fsp3.stat(path12.join(root, d))).mtimeMs })));
2308
2328
  for (const { d } of dated.sort((a, b) => b.t - a.t).slice(2))
2309
2329
  if (d !== version)
2310
- await fsp3.rm(path11.join(root, d), { recursive: true, force: true });
2330
+ await fsp3.rm(path12.join(root, d), { recursive: true, force: true });
2311
2331
  }
2312
2332
  return { version };
2313
2333
  }
@@ -2324,8 +2344,8 @@ function createPage({ web, cacheDir }) {
2324
2344
  return res.writeHead(404), res.end(), true;
2325
2345
  try {
2326
2346
  const f = await download(rel);
2327
- res.writeHead(200, { "content-type": TYPES[path11.extname(f)] || "application/octet-stream", "cache-control": "no-store" });
2328
- fs15.createReadStream(f).pipe(res);
2347
+ res.writeHead(200, { "content-type": TYPES[path12.extname(f)] || "application/octet-stream", "cache-control": "no-store" });
2348
+ fs16.createReadStream(f).pipe(res);
2329
2349
  } catch (e) {
2330
2350
  res.writeHead(e.status === 404 ? 404 : 502);
2331
2351
  res.end();
@@ -2343,10 +2363,10 @@ function createPage({ web, cacheDir }) {
2343
2363
 
2344
2364
  // src/render/service.ts
2345
2365
  import crypto6 from "node:crypto";
2346
- import fs16 from "node:fs";
2366
+ import fs17 from "node:fs";
2347
2367
  import fsp4 from "node:fs/promises";
2348
2368
  import http2 from "node:http";
2349
- import path12 from "node:path";
2369
+ import path13 from "node:path";
2350
2370
  import yauzl from "yauzl";
2351
2371
  var ACTIVE = new Set(["unggah", "antre", "jalan"]);
2352
2372
  var safeEqual = (a, b) => a.length === b.length && crypto6.timingSafeEqual(Buffer.from(a), Buffer.from(b));
@@ -2373,14 +2393,14 @@ function extractZip(f, to) {
2373
2393
  zip.on("entry", (en) => {
2374
2394
  if (en.fileName.endsWith("/"))
2375
2395
  return zip.readEntry();
2376
- const target = path12.join(to, en.fileName);
2377
- if (!target.startsWith(to + path12.sep))
2396
+ const target = path13.join(to, en.fileName);
2397
+ if (!target.startsWith(to + path13.sep))
2378
2398
  return fail(new Error(EngineError.BadPackage));
2379
- fs16.mkdirSync(path12.dirname(target), { recursive: true });
2399
+ fs17.mkdirSync(path13.dirname(target), { recursive: true });
2380
2400
  zip.openReadStream(en, (e2, s) => {
2381
2401
  if (e2 || !s)
2382
2402
  return fail(e2 ?? new Error("zip"));
2383
- const out = fs16.createWriteStream(target);
2403
+ const out = fs17.createWriteStream(target);
2384
2404
  s.pipe(out);
2385
2405
  out.on("finish", () => zip.readEntry());
2386
2406
  out.on("error", fail);
@@ -2395,13 +2415,13 @@ function extractZip(f, to) {
2395
2415
  function saveBody2(req, to, max) {
2396
2416
  return new Promise((ok, fail) => {
2397
2417
  let n = 0;
2398
- const out = fs16.createWriteStream(to);
2418
+ const out = fs17.createWriteStream(to);
2399
2419
  req.on("data", (d) => {
2400
2420
  n += d.length;
2401
2421
  if (n > max) {
2402
2422
  req.destroy();
2403
2423
  out.destroy();
2404
- fs16.rm(to, { force: true }, () => fail(new Error("terlalu besar")));
2424
+ fs17.rm(to, { force: true }, () => fail(new Error("terlalu besar")));
2405
2425
  }
2406
2426
  });
2407
2427
  req.pipe(out);
@@ -2430,7 +2450,7 @@ async function createRenderService(o) {
2430
2450
  } } = o;
2431
2451
  const origins = new Set([].concat(o.origin || []));
2432
2452
  const sign = (kind, body) => crypto6.createHmac("sha256", key).update(`${kind}.${body}`).digest("base64url");
2433
- const dir = (job) => path12.join(folder, job);
2453
+ const dir = (job) => path13.join(folder, job);
2434
2454
  await fsp4.mkdir(folder, { recursive: true });
2435
2455
  function readTicket(req) {
2436
2456
  const tk = String(req.headers.authorization || "").replace(/^Bearer\s+/i, "");
@@ -2452,7 +2472,7 @@ async function createRenderService(o) {
2452
2472
  const jobs = new Map;
2453
2473
  const queue = [];
2454
2474
  let current = null;
2455
- const persist = (t) => fsp4.writeFile(path12.join(dir(t.job), "status.json"), JSON.stringify(t)).catch(() => {
2475
+ const persist = (t) => fsp4.writeFile(path13.join(dir(t.job), "status.json"), JSON.stringify(t)).catch(() => {
2456
2476
  return;
2457
2477
  });
2458
2478
  const update = (t, patch) => (Object.assign(t, patch, { diperbarui: Date.now() }), void persist(t));
@@ -2471,19 +2491,19 @@ async function createRenderService(o) {
2471
2491
  });
2472
2492
  async function clearFiles(t, all = false) {
2473
2493
  for (const n of all ? ["."] : ["paket", "paket.zip", "profil", "mentah.mp4", "mentah.webm"])
2474
- await fsp4.rm(path12.join(dir(t.job), n), { recursive: true, force: true }).catch(() => {
2494
+ await fsp4.rm(path13.join(dir(t.job), n), { recursive: true, force: true }).catch(() => {
2475
2495
  return;
2476
2496
  });
2477
2497
  if (!all) {
2478
2498
  for (const f of await fsp4.readdir(dir(t.job)).catch(() => []))
2479
2499
  if (/^p\d+$/.test(f))
2480
- await fsp4.rm(path12.join(dir(t.job), f), { force: true });
2500
+ await fsp4.rm(path13.join(dir(t.job), f), { force: true });
2481
2501
  }
2482
2502
  }
2483
2503
  async function openPackage(t) {
2484
2504
  const d = dir(t.job);
2485
2505
  const main = t.tiket.jenis === "klip" ? "klip.json" : "proyek.json";
2486
- const entries = await listZip(path12.join(d, "paket.zip"));
2506
+ const entries = await listZip(path13.join(d, "paket.zip"));
2487
2507
  const names = entries.map((x) => x.name).filter((n) => !n.endsWith("/"));
2488
2508
  if (names.some((n) => n.startsWith("/") || n.includes("..") || n.includes("\\") || n !== main && !/^aset\/[\w-]+$/.test(n)))
2489
2509
  throw new Error(EngineError.BadPackage);
@@ -2491,10 +2511,10 @@ async function createRenderService(o) {
2491
2511
  throw new Error(`Paket tidak berisi ${main}.`);
2492
2512
  if (entries.reduce((a, x) => a + x.size, 0) > maxUnzippedMb * 1048576)
2493
2513
  throw new Error("Isi paket terlalu besar.");
2494
- await extractZip(path12.join(d, "paket.zip"), path12.join(d, "paket"));
2495
- await fsp4.rm(path12.join(d, "paket.zip"), { force: true });
2496
- const j = JSON.parse(await fsp4.readFile(path12.join(d, "paket", main), "utf8"));
2497
- const has = (id) => /^[\w-]+$/.test(id) && fs16.existsSync(path12.join(d, "paket", "aset", id));
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));
2498
2518
  if (main === "klip.json") {
2499
2519
  const k = j.klip || {};
2500
2520
  const seconds = Number(k.durationInFrames) / Number(k.fps);
@@ -2542,7 +2562,7 @@ async function createRenderService(o) {
2542
2562
  job: t.job,
2543
2563
  kind: t.tiket.jenis,
2544
2564
  dir: dir(t.job),
2545
- packageDir: path12.join(dir(t.job), "paket"),
2565
+ packageDir: path13.join(dir(t.job), "paket"),
2546
2566
  transparent: !!t.transparan,
2547
2567
  persen: t.persen,
2548
2568
  width: t.tiket.w,
@@ -2562,7 +2582,7 @@ async function createRenderService(o) {
2562
2582
  const size = (await fsp4.stat(h.file)).size;
2563
2583
  if (size < 200)
2564
2584
  throw new Error(EngineError.EmptyResult);
2565
- update(t, { status: "selesai", persen: 100, tahap: "", selesaiPada: Date.now(), hasilUkuran: size, hasilBerkas: path12.basename(h.file), hasilJenis: h.type });
2585
+ update(t, { status: "selesai", persen: 100, tahap: "", selesaiPada: Date.now(), hasilUkuran: size, hasilBerkas: path13.basename(h.file), hasilJenis: h.type });
2566
2586
  onJob("done", t);
2567
2587
  } catch (e) {
2568
2588
  if (t.status !== "batal") {
@@ -2600,10 +2620,10 @@ async function createRenderService(o) {
2600
2620
  if (a > z)
2601
2621
  return res.writeHead(416, { ...h, "content-range": `bytes */${st.size}` }), res.end();
2602
2622
  res.writeHead(206, { ...h, "content-length": z - a + 1, "content-range": `bytes ${a}-${z}/${st.size}` });
2603
- return void fs16.createReadStream(f, { start: a, end: z }).pipe(res);
2623
+ return void fs17.createReadStream(f, { start: a, end: z }).pipe(res);
2604
2624
  }
2605
2625
  res.writeHead(200, { ...h, "content-length": st.size });
2606
- fs16.createReadStream(f).pipe(res);
2626
+ fs17.createReadStream(f).pipe(res);
2607
2627
  }
2608
2628
  const ROUTE = /^\/tugas(?:\/(r_[a-f0-9]{16})(\/potongan\/(\d{1,4})|\/mulai|\/hasil)?)?$/;
2609
2629
  const server = http2.createServer(async (req, res) => {
@@ -2642,8 +2662,8 @@ async function createRenderService(o) {
2642
2662
  if (t.status !== "unggah")
2643
2663
  return json(req, res, 409, { galat: "Unggahan sudah ditutup." });
2644
2664
  const n = Number(m[3]);
2645
- const f = path12.join(dir(job), `p${n}`);
2646
- const before = fs16.existsSync(f) ? (await fsp4.stat(f)).size : 0;
2665
+ const f = path13.join(dir(job), `p${n}`);
2666
+ const before = fs17.existsSync(f) ? (await fsp4.stat(f)).size : 0;
2647
2667
  const room = Number(ticket.maksMb) * 1048576 - (t.terunggah - before);
2648
2668
  const size = await saveBody2(req, f, Math.min(partMb * 1048576 + 1024, room));
2649
2669
  const expected = String(req.headers["x-sha256"] || "").toLowerCase();
@@ -2665,13 +2685,13 @@ async function createRenderService(o) {
2665
2685
  const count = Number(b.jumlah);
2666
2686
  if (!(count > 0 && count < 1e4))
2667
2687
  return json(req, res, 400, { galat: "Jumlah potongan tidak valid." });
2668
- const zip = path12.join(dir(job), "paket.zip");
2669
- const out = fs16.createWriteStream(zip);
2688
+ const zip = path13.join(dir(job), "paket.zip");
2689
+ const out = fs17.createWriteStream(zip);
2670
2690
  const hash = crypto6.createHash("sha256");
2671
2691
  let total = 0;
2672
2692
  for (let i = 0;i < count; i++) {
2673
- const f = path12.join(dir(job), `p${i}`);
2674
- if (!fs16.existsSync(f))
2693
+ const f = path13.join(dir(job), `p${i}`);
2694
+ if (!fs17.existsSync(f))
2675
2695
  return out.destroy(), json(req, res, 400, { galat: `Potongan ${i + 1} belum terunggah.` });
2676
2696
  const part = await fsp4.readFile(f);
2677
2697
  hash.update(part);
@@ -2701,8 +2721,8 @@ async function createRenderService(o) {
2701
2721
  return json(req, res, 200, summary(t));
2702
2722
  }
2703
2723
  if (m[2] === "/hasil" && (req.method === "GET" || req.method === "HEAD")) {
2704
- const f = t.hasilBerkas ? path12.join(dir(job), t.hasilBerkas) : "";
2705
- if (t.status !== "selesai" || !f || !fs16.existsSync(f))
2724
+ const f = t.hasilBerkas ? path13.join(dir(job), t.hasilBerkas) : "";
2725
+ if (t.status !== "selesai" || !f || !fs17.existsSync(f))
2706
2726
  return json(req, res, 409, { galat: "Video belum jadi." });
2707
2727
  const webm = t.hasilJenis === "video/webm";
2708
2728
  return sendFile(req, res, f, webm ? "video/webm" : "video/mp4", `hypeframe-${job}.${webm ? "webm" : "mp4"}`);
@@ -2733,7 +2753,7 @@ async function createRenderService(o) {
2733
2753
  if (!JOB_ID.test(job))
2734
2754
  continue;
2735
2755
  try {
2736
- const t = JSON.parse(await fsp4.readFile(path12.join(dir(job), "status.json"), "utf8"));
2756
+ const t = JSON.parse(await fsp4.readFile(path13.join(dir(job), "status.json"), "utf8"));
2737
2757
  if (t.status === "jalan" || t.status === "antre")
2738
2758
  update(t, { status: "gagal", galat: EngineError.Restarted });
2739
2759
  jobs.set(job, t);
@@ -2817,8 +2837,17 @@ function table(rows, indent = " ") {
2817
2837
  import { spawn as spawn3 } from "node:child_process";
2818
2838
  var PAIRING_LINK = new RegExp(`^https?://[A-Za-z0-9.-]+(:\\d+)?/sambung\\?kode=${PAIRING_CODE.source.slice(1, -1)}$`);
2819
2839
  var WEB_ORIGIN = /^https?:\/\/[A-Za-z0-9.-]+(:\d+)?\/?$/;
2820
- function launch(target) {
2821
- const [cmd, args] = process.platform === "win32" ? ["explorer.exe", [target]] : [process.platform === "darwin" ? "open" : "xdg-open", [target]];
2840
+ function openCommand(target, platform, url) {
2841
+ if (platform === "win32")
2842
+ return ["explorer.exe", [target]];
2843
+ if (platform === "darwin")
2844
+ return ["open", [target]];
2845
+ if (platform === "android")
2846
+ return [url ? "termux-open-url" : "termux-open", [target]];
2847
+ return ["xdg-open", [target]];
2848
+ }
2849
+ function launch(target, url) {
2850
+ const [cmd, args] = openCommand(target, isAndroid() ? "android" : process.platform, url);
2822
2851
  const p = spawn3(cmd, args, { stdio: "ignore", detached: true });
2823
2852
  p.on("error", () => {
2824
2853
  return;
@@ -2828,11 +2857,11 @@ function launch(target) {
2828
2857
  function openUrl(url, allowed) {
2829
2858
  if (!allowed.test(url))
2830
2859
  return false;
2831
- launch(url);
2860
+ launch(url, true);
2832
2861
  return true;
2833
2862
  }
2834
2863
  function openFolder(dir) {
2835
- launch(dir);
2864
+ launch(dir, false);
2836
2865
  }
2837
2866
 
2838
2867
  // src/cli/commands/start.ts
@@ -3025,23 +3054,23 @@ function logout() {
3025
3054
 
3026
3055
  // src/cli/commands/autostart.ts
3027
3056
  import { spawnSync as spawnSync2 } from "node:child_process";
3028
- import fs17 from "node:fs";
3057
+ import fs18 from "node:fs";
3029
3058
  import os3 from "node:os";
3030
- import path13 from "node:path";
3059
+ import path14 from "node:path";
3031
3060
  function entryFile() {
3032
3061
  const home = os3.homedir();
3033
3062
  if (process.platform === "win32")
3034
- return path13.join(process.env.APPDATA || path13.join(home, "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "HypeFrame.cmd");
3063
+ return path14.join(process.env.APPDATA || path14.join(home, "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "HypeFrame.cmd");
3035
3064
  if (process.platform === "darwin")
3036
- return path13.join(home, "Library", "LaunchAgents", "com.hypeframe.engine.plist");
3065
+ return path14.join(home, "Library", "LaunchAgents", "com.hypeframe.engine.plist");
3037
3066
  if (hasSystemd())
3038
- return path13.join(home, ".config", "systemd", "user", "hypeframe.service");
3039
- return path13.join(home, ".config", "autostart", "hypeframe.desktop");
3067
+ return path14.join(home, ".config", "systemd", "user", "hypeframe.service");
3068
+ return path14.join(home, ".config", "autostart", "hypeframe.desktop");
3040
3069
  }
3041
3070
  function hasSystemd() {
3042
3071
  return process.platform === "linux" && spawnSync2("systemctl", ["--user", "--version"], { stdio: "ignore" }).status === 0;
3043
3072
  }
3044
- var autostartEnabled = () => fs17.existsSync(entryFile());
3073
+ var autostartEnabled = () => fs18.existsSync(entryFile());
3045
3074
  var xml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3046
3075
  function autostart(mode) {
3047
3076
  const file = entryFile();
@@ -3053,7 +3082,7 @@ function autostart(mode) {
3053
3082
  if (mode === "off") {
3054
3083
  if (process.platform === "linux" && file.endsWith(".service"))
3055
3084
  spawnSync2("systemctl", ["--user", "disable", "hypeframe.service"], { stdio: "ignore" });
3056
- fs17.rmSync(file, { force: true });
3085
+ fs18.rmSync(file, { force: true });
3057
3086
  log.ok(t("autostart.off"));
3058
3087
  return;
3059
3088
  }
@@ -3068,14 +3097,14 @@ function autostart(mode) {
3068
3097
  return;
3069
3098
  }
3070
3099
  const quoted = cmd.map((c) => `"${c}"`).join(" ");
3071
- fs17.mkdirSync(path13.dirname(file), { recursive: true });
3100
+ fs18.mkdirSync(path14.dirname(file), { recursive: true });
3072
3101
  if (process.platform === "win32") {
3073
- fs17.writeFileSync(file, `@echo off\r
3102
+ fs18.writeFileSync(file, `@echo off\r
3074
3103
  start "HypeFrame" /min ${quoted} start --no-browser\r
3075
3104
  `);
3076
3105
  } else if (process.platform === "darwin") {
3077
- const out = path13.join(logDir(), "autostart.log");
3078
- fs17.writeFileSync(file, `<?xml version="1.0" encoding="UTF-8"?>
3106
+ const out = path14.join(logDir(), "autostart.log");
3107
+ fs18.writeFileSync(file, `<?xml version="1.0" encoding="UTF-8"?>
3079
3108
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3080
3109
  <plist version="1.0"><dict>
3081
3110
  <key>Label</key><string>com.hypeframe.engine</string>
@@ -3086,7 +3115,7 @@ start "HypeFrame" /min ${quoted} start --no-browser\r
3086
3115
  </dict></plist>
3087
3116
  `);
3088
3117
  } else if (file.endsWith(".service")) {
3089
- fs17.writeFileSync(file, `[Unit]
3118
+ fs18.writeFileSync(file, `[Unit]
3090
3119
  Description=HypeFrame engine
3091
3120
  After=network-online.target
3092
3121
 
@@ -3101,7 +3130,7 @@ WantedBy=default.target
3101
3130
  spawnSync2("systemctl", ["--user", "daemon-reload"], { stdio: "ignore" });
3102
3131
  spawnSync2("systemctl", ["--user", "enable", "hypeframe.service"], { stdio: "ignore" });
3103
3132
  } else {
3104
- fs17.writeFileSync(file, `[Desktop Entry]
3133
+ fs18.writeFileSync(file, `[Desktop Entry]
3105
3134
  Type=Application
3106
3135
  Name=HypeFrame engine
3107
3136
  Exec=${quoted} start --no-browser
@@ -3167,7 +3196,7 @@ async function bench(args) {
3167
3196
  executablePath: chrome,
3168
3197
  headless: true,
3169
3198
  protocolTimeout: 300000,
3170
- args: ["--no-first-run", "--disable-extensions", ...s.gpu ? [] : softwareGpuArgs]
3199
+ args: ["--no-first-run", "--disable-extensions", ...s.gpu ? [] : softwareGpuArgs, ...chromePlatformArgs()]
3171
3200
  });
3172
3201
  const rows = [];
3173
3202
  try {
@@ -3203,9 +3232,9 @@ async function bench(args) {
3203
3232
  import * as p from "@clack/prompts";
3204
3233
 
3205
3234
  // src/agent/install.ts
3206
- import fs18 from "node:fs";
3235
+ import fs19 from "node:fs";
3207
3236
  import fsp5 from "node:fs/promises";
3208
- import path14 from "node:path";
3237
+ import path15 from "node:path";
3209
3238
  import yauzl2 from "yauzl";
3210
3239
  function unzip(file, to) {
3211
3240
  return new Promise((ok, fail) => {
@@ -3213,16 +3242,16 @@ function unzip(file, to) {
3213
3242
  if (e || !zip)
3214
3243
  return fail(e ?? new Error("zip"));
3215
3244
  zip.on("entry", (en) => {
3216
- const target = path14.join(to, en.fileName);
3217
- if (!target.startsWith(to + path14.sep))
3245
+ const target = path15.join(to, en.fileName);
3246
+ if (!target.startsWith(to + path15.sep))
3218
3247
  return fail(new Error("archive path outside the agent folder"));
3219
3248
  if (en.fileName.endsWith("/"))
3220
- return fs18.mkdirSync(target, { recursive: true }), zip.readEntry();
3221
- fs18.mkdirSync(path14.dirname(target), { recursive: true });
3249
+ return fs19.mkdirSync(target, { recursive: true }), zip.readEntry();
3250
+ fs19.mkdirSync(path15.dirname(target), { recursive: true });
3222
3251
  zip.openReadStream(en, (e2, s) => {
3223
3252
  if (e2 || !s)
3224
3253
  return fail(e2 ?? new Error("zip"));
3225
- const out = fs18.createWriteStream(target);
3254
+ const out = fs19.createWriteStream(target);
3226
3255
  s.pipe(out);
3227
3256
  out.on("finish", () => zip.readEntry());
3228
3257
  out.on("error", fail);
@@ -3237,7 +3266,7 @@ function unzip(file, to) {
3237
3266
  async function untarGz(file, to) {
3238
3267
  const { gunzipSync } = await import("node:zlib");
3239
3268
  const data = gunzipSync(await fsp5.readFile(file));
3240
- const root = path14.resolve(to);
3269
+ const root = path15.resolve(to);
3241
3270
  const str = (b) => b.toString("utf8").replace(/\0[\s\S]*$/, "");
3242
3271
  const octal = (b) => Number.parseInt(str(b).trim() || "0", 8) || 0;
3243
3272
  let off = 0;
@@ -3268,8 +3297,8 @@ async function untarGz(file, to) {
3268
3297
  name = name.replace(/^\.\//, "");
3269
3298
  if (!name)
3270
3299
  continue;
3271
- const target = path14.resolve(root, name);
3272
- if (target !== root && !target.startsWith(root + path14.sep))
3300
+ const target = path15.resolve(root, name);
3301
+ if (target !== root && !target.startsWith(root + path15.sep))
3273
3302
  throw new Error("archive path outside the agent folder");
3274
3303
  if (type === "5") {
3275
3304
  await fsp5.mkdir(target, { recursive: true });
@@ -3277,36 +3306,22 @@ async function untarGz(file, to) {
3277
3306
  }
3278
3307
  if (type !== "0" && type !== "7")
3279
3308
  continue;
3280
- await fsp5.mkdir(path14.dirname(target), { recursive: true });
3309
+ await fsp5.mkdir(path15.dirname(target), { recursive: true });
3281
3310
  await fsp5.writeFile(target, body, { mode: octal(h.subarray(100, 108)) & 73 ? 493 : 420 });
3282
3311
  }
3283
3312
  }
3284
3313
  function npxRunner(pkg, extra = []) {
3285
3314
  if (isStandalone())
3286
3315
  return { cmd: process.execPath, args: ["x", pkg, ...extra], env: { BUN_BE_BUN: "1" } };
3287
- const npxCli = path14.join(path14.dirname(process.execPath), process.platform === "win32" ? "" : "..", process.platform === "win32" ? "node_modules" : "lib/node_modules", "npm", "bin", "npx-cli.js");
3288
- if (!fs18.existsSync(npxCli))
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))
3289
3318
  throw new Error("npx was not found next to Node.js");
3290
3319
  return { cmd: process.execPath, args: [npxCli, "-y", pkg, ...extra], env: {} };
3291
3320
  }
3292
- function onPath(name) {
3293
- if (!/^[\w.@+-]{1,80}$/.test(name))
3294
- return null;
3295
- const file = process.platform === "win32" ? /\.exe$/i.test(name) ? name : `${name}.exe` : name;
3296
- for (const dir of (process.env.PATH || "").split(path14.delimiter).filter(Boolean)) {
3297
- const f = path14.join(dir, file);
3298
- try {
3299
- const st = fs18.statSync(f);
3300
- if (st.isFile() && (process.platform === "win32" || st.mode & 73))
3301
- return f;
3302
- } catch {}
3303
- }
3304
- return null;
3305
- }
3306
3321
  function ownCopy(a) {
3307
3322
  const bin = a.distribution.binary?.[platformKey()];
3308
3323
  if (bin) {
3309
- const cmd = onPath(path14.basename(bin.cmd).replace(/\.exe$/i, ""));
3324
+ const cmd = onPath(path15.basename(bin.cmd).replace(/\.exe$/i, ""));
3310
3325
  return cmd ? { cmd, args: bin.args ?? [], env: bin.env ?? {} } : null;
3311
3326
  }
3312
3327
  const npx = a.distribution.npx;
@@ -3336,35 +3351,35 @@ async function installAgent(id, progress = () => {
3336
3351
  } else if (bin) {
3337
3352
  if (!/^[0-9a-f]{64}$/i.test(bin.sha256 || ""))
3338
3353
  throw new Error(`Agent ${id}: the registry gives no sha256; not installed`);
3339
- const dir = path14.join(agentDir(), id, a.version);
3354
+ const dir = path15.join(agentDir(), id, a.version);
3340
3355
  const tmp = `${dir}.tmp`;
3341
3356
  await fsp5.rm(tmp, { recursive: true, force: true });
3342
3357
  await fsp5.mkdir(tmp, { recursive: true });
3343
3358
  try {
3344
- const name = path14.basename(new URL(bin.archive).pathname);
3359
+ const name = path15.basename(new URL(bin.archive).pathname);
3345
3360
  const cmdRel = bin.cmd.replace(/^\.\//, "");
3346
3361
  if (/\.zip$/i.test(name)) {
3347
- const file = path14.join(tmp, ".download.zip");
3362
+ const file = path15.join(tmp, ".download.zip");
3348
3363
  await downloadVerified(bin.archive, bin.sha256.toLowerCase(), file, progress);
3349
3364
  await unzip(file, tmp);
3350
3365
  await fsp5.rm(file, { force: true });
3351
3366
  } else if (/\.(tar\.gz|tgz)$/i.test(name)) {
3352
- const file = path14.join(tmp, ".download.tar.gz");
3367
+ const file = path15.join(tmp, ".download.tar.gz");
3353
3368
  await downloadVerified(bin.archive, bin.sha256.toLowerCase(), file, progress);
3354
3369
  await untarGz(file, tmp);
3355
3370
  await fsp5.rm(file, { force: true });
3356
3371
  } else if (/\.gz$/i.test(name)) {
3357
- await downloadVerified(bin.archive, bin.sha256.toLowerCase(), path14.join(tmp, cmdRel), progress, true);
3372
+ await downloadVerified(bin.archive, bin.sha256.toLowerCase(), path15.join(tmp, cmdRel), progress, true);
3358
3373
  } else
3359
3374
  throw new Error(`Agent ${id}: unsupported archive ${name}`);
3360
- const cmd = path14.join(tmp, cmdRel);
3361
- if (!fs18.existsSync(cmd))
3375
+ const cmd = path15.join(tmp, cmdRel);
3376
+ if (!fs19.existsSync(cmd))
3362
3377
  throw new Error(`Agent ${id}: ${bin.cmd} is not in the download`);
3363
3378
  if (process.platform !== "win32")
3364
3379
  await fsp5.chmod(cmd, 493);
3365
3380
  await fsp5.rm(dir, { recursive: true, force: true });
3366
3381
  await fsp5.rename(tmp, dir);
3367
- launch = { cmd: path14.join(dir, cmdRel), args: bin.args ?? [], env: bin.env ?? {} };
3382
+ launch = { cmd: path15.join(dir, cmdRel), args: bin.args ?? [], env: bin.env ?? {} };
3368
3383
  } catch (e) {
3369
3384
  await fsp5.rm(tmp, { recursive: true, force: true });
3370
3385
  throw e;
@@ -3391,7 +3406,6 @@ async function keyFromShell(name, io) {
3391
3406
  io.say(t("agent.keyFromShell", { name }));
3392
3407
  return value;
3393
3408
  }
3394
- var API_KEY_ONLY = { "claude-acp": "ANTHROPIC_API_KEY" };
3395
3409
  async function checkReady(id) {
3396
3410
  const a = readInstalled().find((x) => x.id === id);
3397
3411
  if (!a)
@@ -3409,27 +3423,20 @@ async function checkReady(id) {
3409
3423
  await proc.stop();
3410
3424
  }
3411
3425
  }
3426
+ var isKey = (m) => m.type === "env_var" || !!m.varName;
3412
3427
  function pick(methods) {
3413
- return methods.find((m) => m.type === "terminal") ?? methods.find((m) => m.type === "env_var" || !!m.varName) ?? methods.find((m) => !m.type || m.type === "agent");
3428
+ return methods.find((m) => m.type === "terminal") ?? methods.find((m) => (!m.type || m.type === "agent") && !isKey(m)) ?? methods.find(isKey);
3414
3429
  }
3415
3430
  async function loginAgent(id, io) {
3416
3431
  const a = readInstalled().find((x) => x.id === id);
3417
3432
  if (!a)
3418
3433
  throw new Error(`Agent ${id} is not installed`);
3419
- const onlyKey = API_KEY_ONLY[id];
3420
- if (onlyKey) {
3421
- const value = await keyFromShell(onlyKey, io) || await io.ask(onlyKey);
3422
- if (!value)
3423
- return false;
3424
- saveAgentEnv(id, { [onlyKey]: value.trim() });
3425
- return checkReady(id);
3426
- }
3427
3434
  const proc = new AcpProcess;
3428
3435
  let method;
3429
3436
  try {
3430
3437
  const init = await proc.start(a, projectDir("_cek"), agentEnv(id));
3431
3438
  method = pick(init.authMethods ?? []);
3432
- if (method && (!method.type || method.type === "agent"))
3439
+ if (method && (!method.type || method.type === "agent") && !isKey(method))
3433
3440
  await proc.request("authenticate", { methodId: method.id }, 10 * 60000);
3434
3441
  } finally {
3435
3442
  await proc.stop();
@@ -3439,7 +3446,7 @@ async function loginAgent(id, io) {
3439
3446
  const r = spawnSync3(a.launch.cmd, [...a.launch.args, ...method.args ?? []], { stdio: "inherit", env: { ...process.env, ...a.launch.env, ...agentEnv(id), ...method.env ?? {} } });
3440
3447
  if (r.status !== 0)
3441
3448
  return setReady(id, false), false;
3442
- } else if (method && (method.type === "env_var" || method.varName)) {
3449
+ } else if (method && isKey(method)) {
3443
3450
  const name = method.varName || method.id;
3444
3451
  const value = await keyFromShell(name, io) || await io.ask(name);
3445
3452
  if (!value)
@@ -3450,7 +3457,7 @@ async function loginAgent(id, io) {
3450
3457
  }
3451
3458
 
3452
3459
  // src/cli/commands/agent.ts
3453
- var NAMES = { "claude-acp": "Claude Code", "antigravity-acp": "Antigravity", "codex-acp": "Codex", opencode: "OpenCode" };
3460
+ var NAMES = { "antigravity-acp": "Antigravity", "codex-acp": "Codex", opencode: "OpenCode" };
3454
3461
  var agentName = (id) => NAMES[id] ?? readInstalled().find((a) => a.id === id)?.name ?? id;
3455
3462
  function agentState(id) {
3456
3463
  const a = readInstalled().find((x) => x.id === id);
@@ -3506,8 +3513,6 @@ async function addAgent(id, download = false) {
3506
3513
  return ok;
3507
3514
  }
3508
3515
  async function loginOne(id) {
3509
- if (id === "claude-acp")
3510
- log.detail(t("agent.claudeKey"));
3511
3516
  log.info(t("agent.loggingIn", { name: agentName(id) }));
3512
3517
  const ok = await loginAgent(id, io);
3513
3518
  if (ok)
@@ -3636,8 +3641,8 @@ async function config(args) {
3636
3641
 
3637
3642
  // src/cli/commands/doctor.ts
3638
3643
  import { spawnSync as spawnSync4 } from "node:child_process";
3639
- import fs19 from "node:fs";
3640
- import path15 from "node:path";
3644
+ import fs20 from "node:fs";
3645
+ import path16 from "node:path";
3641
3646
  var mark = { ok: color.ok(icon.ok), warn: color.warn(icon.warn), error: color.error(icon.error) };
3642
3647
  async function reach(url) {
3643
3648
  const t0 = Date.now();
@@ -3666,10 +3671,10 @@ async function doctor(args) {
3666
3671
  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")}` : ""}` });
3667
3672
  }
3668
3673
  try {
3669
- const probe = path15.join(dataDir(), `.probe-${process.pid}`);
3670
- fs19.writeFileSync(probe, "x");
3671
- fs19.rmSync(probe);
3672
- const st = fs19.statfsSync(dataDir());
3674
+ const probe = path16.join(dataDir(), `.probe-${process.pid}`);
3675
+ fs20.writeFileSync(probe, "x");
3676
+ fs20.rmSync(probe);
3677
+ const st = fs20.statfsSync(dataDir());
3673
3678
  const free = st.bavail * st.bsize;
3674
3679
  show({ label: t("doctor.disk"), result: free > 2 * 1024 ** 3 ? "ok" : "warn", detail: `${dataDir()} ${color.muted(icon.dot)} ${t("doctor.free", { size: bytes2(free) })}` });
3675
3680
  } catch (e) {
@@ -3713,21 +3718,21 @@ async function doctor(args) {
3713
3718
  }
3714
3719
 
3715
3720
  // src/cli/commands/history.ts
3716
- import fs20 from "node:fs";
3717
- import path16 from "node:path";
3721
+ import fs21 from "node:fs";
3722
+ import path17 from "node:path";
3718
3723
  function readHistory2(hours = 24) {
3719
3724
  const root = renderDir();
3720
3725
  const since = Date.now() - hours * 3600000;
3721
3726
  const out = [];
3722
- for (const name of fs20.readdirSync(root)) {
3727
+ for (const name of fs21.readdirSync(root)) {
3723
3728
  if (!JOB_ID.test(name))
3724
3729
  continue;
3725
3730
  try {
3726
- const j = JSON.parse(fs20.readFileSync(path16.join(root, name, "status.json"), "utf8"));
3731
+ const j = JSON.parse(fs21.readFileSync(path17.join(root, name, "status.json"), "utf8"));
3727
3732
  if ((j.diperbarui || j.dibuat) < since)
3728
3733
  continue;
3729
- const f = j.hasilBerkas ? path16.join(root, name, j.hasilBerkas) : null;
3730
- out.push({ job: j, file: f && fs20.existsSync(f) ? f : null });
3734
+ const f = j.hasilBerkas ? path17.join(root, name, j.hasilBerkas) : null;
3735
+ out.push({ job: j, file: f && fs21.existsSync(f) ? f : null });
3731
3736
  } catch {}
3732
3737
  }
3733
3738
  return out.sort((a, b) => (b.job.diperbarui || 0) - (a.job.diperbarui || 0));
@@ -3754,30 +3759,30 @@ function history() {
3754
3759
 
3755
3760
  // src/cli/commands/maintenance.ts
3756
3761
  import { spawnSync as spawnSync5 } from "node:child_process";
3757
- import fs21 from "node:fs";
3762
+ import fs22 from "node:fs";
3758
3763
  import os4 from "node:os";
3759
- import path17 from "node:path";
3764
+ import path18 from "node:path";
3760
3765
  async function clean() {
3761
3766
  if (runningPid()) {
3762
3767
  log.warn(t("clean.running"));
3763
3768
  return;
3764
3769
  }
3765
- const targets = [path17.join(cacheDir(), "chrome"), path17.join(cacheDir(), "halaman"), path17.join(logDir(), "hypeframe.log.1")];
3766
- for (const job of fs21.readdirSync(renderDir())) {
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())) {
3767
3772
  if (!JOB_ID.test(job))
3768
3773
  continue;
3769
3774
  try {
3770
- const s = JSON.parse(fs21.readFileSync(path17.join(renderDir(), job, "status.json"), "utf8")).status;
3775
+ const s = JSON.parse(fs22.readFileSync(path18.join(renderDir(), job, "status.json"), "utf8")).status;
3771
3776
  if (s === "gagal" || s === "batal" || s === "unggah")
3772
- targets.push(path17.join(renderDir(), job));
3777
+ targets.push(path18.join(renderDir(), job));
3773
3778
  } catch {
3774
- targets.push(path17.join(renderDir(), job));
3779
+ targets.push(path18.join(renderDir(), job));
3775
3780
  }
3776
3781
  }
3777
3782
  let freed = 0;
3778
3783
  for (const p of targets) {
3779
3784
  freed += await sizeOf(p);
3780
- fs21.rmSync(p, { recursive: true, force: true });
3785
+ fs22.rmSync(p, { recursive: true, force: true });
3781
3786
  }
3782
3787
  log.ok(t("clean.done", { size: bytes2(freed) }));
3783
3788
  }
@@ -3786,7 +3791,7 @@ function report() {
3786
3791
  const a = readAccount();
3787
3792
  let recent = "";
3788
3793
  try {
3789
- recent = fs21.readFileSync(path17.join(logDir(), "hypeframe.log"), "utf8").split(`
3794
+ recent = fs22.readFileSync(path18.join(logDir(), "hypeframe.log"), "utf8").split(`
3790
3795
  `).slice(-400).join(`
3791
3796
  `);
3792
3797
  } catch {
@@ -3807,13 +3812,20 @@ function report() {
3807
3812
  recent
3808
3813
  ];
3809
3814
  const stamp = new Date().toISOString().slice(0, 19).replace(/[-:T]/g, "");
3810
- const file = path17.join(dataDir(), `laporan-${stamp}.txt`);
3811
- fs21.writeFileSync(file, mask(lines.join(`
3815
+ const file = path18.join(dataDir(), `laporan-${stamp}.txt`);
3816
+ fs22.writeFileSync(file, mask(lines.join(`
3812
3817
  `)), { mode: 384 });
3813
3818
  log.ok(t("report.done", { file }));
3814
3819
  log.detail(t("report.hint"));
3815
3820
  return file;
3816
3821
  }
3822
+ function updateCommand(o) {
3823
+ if (o.standalone && o.windows)
3824
+ return ["powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", `irm ${INSTALL_URL}.ps1 | iex`], {}];
3825
+ if (o.standalone || o.android)
3826
+ return ["bash", ["-c", `curl -fsSL ${INSTALL_URL} | bash`], {}];
3827
+ return ["npm", ["i", "-g", "hypeframe@latest"], { shell: o.windows }];
3828
+ }
3817
3829
  function update() {
3818
3830
  if (!launchCommand()) {
3819
3831
  log.info(t("update.npx"));
@@ -3821,8 +3833,8 @@ function update() {
3821
3833
  return;
3822
3834
  }
3823
3835
  log.info(t("update.running"));
3824
- const win = process.platform === "win32";
3825
- const r = isStandalone() ? win ? spawnSync5("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", `irm ${INSTALL_URL}.ps1 | iex`], { stdio: "inherit" }) : spawnSync5("bash", ["-c", `curl -fsSL ${INSTALL_URL} | bash`], { stdio: "inherit" }) : spawnSync5("npm", ["i", "-g", "hypeframe@latest"], { stdio: "inherit", shell: win });
3836
+ const [cmd, args, extra] = updateCommand({ standalone: isStandalone(), android: isAndroid(), windows: process.platform === "win32" });
3837
+ const r = spawnSync5(cmd, args, { stdio: "inherit", ...extra });
3826
3838
  if (r.status === 0)
3827
3839
  log.ok(t("update.done"));
3828
3840
  else
@@ -3837,13 +3849,13 @@ function openWeb(args) {
3837
3849
  }
3838
3850
 
3839
3851
  // src/cli/commands/status.ts
3840
- import fs22 from "node:fs";
3841
- import path18 from "node:path";
3852
+ import fs23 from "node:fs";
3853
+ import path19 from "node:path";
3842
3854
  function statusRows(args) {
3843
3855
  const s = resolveSettings(args?.flags);
3844
3856
  const a = readAccount();
3845
3857
  const pid = runningPid();
3846
- const chrome = findChrome() || fs22.existsSync(path18.join(cacheDir(), "chrome"));
3858
+ const chrome = findChrome() || fs23.existsSync(path19.join(cacheDir(), "chrome"));
3847
3859
  const recent = readHistory2();
3848
3860
  const k = (key) => color.muted(t(key));
3849
3861
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypeframe",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Local engine for HypeFrame Web: code clips, video renders and AI agents run on your own machine; the web is just the view.",
5
5
  "keywords": [
6
6
  "hypeframe",