Spaces:
Running
Running
v0.10.0: installable as a Progressive Web App
Browse filesSource: github.com/erinoooo/LocalWebAgent@598c33c
- README.md +2 -0
- css/app.css +4 -0
- icons/apple-touch-icon.png +0 -0
- icons/icon-192.png +0 -0
- icons/icon-512.png +0 -0
- icons/maskable-192.png +0 -0
- icons/maskable-512.png +0 -0
- index.html +17 -0
- js/config.js +1 -1
- js/main.js +39 -1
- manifest.webmanifest +61 -0
- sw.js +3 -2
README.md
CHANGED
|
@@ -36,6 +36,8 @@ An AI agent with its own Linux computer, entirely inside one web page.
|
|
| 36 |
- **Model Manager:** download, remove and switch local models, and save any number of API models from 15 providers, all in one place.
|
| 37 |
- **Offline:** setup installs only the Linux machine (about 440 MB to download and to store). Local models are downloaded separately in the Model Manager. Once downloaded, everything works with no internet connection.
|
| 38 |
|
|
|
|
|
|
|
| 39 |
**Getting started:** open the app, install Linux, and the Model Manager opens. Download a local model or add an API model, press **Use**, and start a task. Open the Model Manager again any time from the chip icon in the title bar, the model name next to the logo, or **Settings → Model**.
|
| 40 |
|
| 41 |
**Requirements for local models:** desktop Chrome or Edge with WebGPU, about 2.5 GB of free disk space, and 8 GB or more RAM. Open the app at its own URL (`https://<owner>-localwebagent.static.hf.space`), because the embedded view on huggingface.co can't enable the cross-origin isolation CheerpX needs.
|
|
|
|
| 36 |
- **Model Manager:** download, remove and switch local models, and save any number of API models from 15 providers, all in one place.
|
| 37 |
- **Offline:** setup installs only the Linux machine (about 440 MB to download and to store). Local models are downloaded separately in the Model Manager. Once downloaded, everything works with no internet connection.
|
| 38 |
|
| 39 |
+
**Install as an app:** LocalWebAgent is a Progressive Web App. Use the **Install** button (setup screen, title bar or Settings → App), or your browser's "Install app" / "Add to Home Screen". It then opens in its own window with a launcher icon and works offline; right-click the icon for a Model Manager shortcut.
|
| 40 |
+
|
| 41 |
**Getting started:** open the app, install Linux, and the Model Manager opens. Download a local model or add an API model, press **Use**, and start a task. Open the Model Manager again any time from the chip icon in the title bar, the model name next to the logo, or **Settings → Model**.
|
| 42 |
|
| 43 |
**Requirements for local models:** desktop Chrome or Edge with WebGPU, about 2.5 GB of free disk space, and 8 GB or more RAM. Open the app at its own URL (`https://<owner>-localwebagent.static.hf.space`), because the embedded view on huggingface.co can't enable the cross-origin isolation CheerpX needs.
|
css/app.css
CHANGED
|
@@ -728,3 +728,7 @@ code, pre, kbd, .mono, .tool-label, .crumbs, .vw-path, .hex, #terminal * { font-
|
|
| 728 |
.embed-gate-inner p { margin: 0; color: var(--text-2); line-height: 1.55; }
|
| 729 |
.embed-gate-btn { height: 44px; padding: 0 22px; font-size: 14px; border-radius: 12px; text-decoration: none; margin-top: 6px; }
|
| 730 |
.embed-gate-note { font-size: 12.5px; color: var(--text-3) !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 728 |
.embed-gate-inner p { margin: 0; color: var(--text-2); line-height: 1.55; }
|
| 729 |
.embed-gate-btn { height: 44px; padding: 0 22px; font-size: 14px; border-radius: 12px; text-decoration: none; margin-top: 6px; }
|
| 730 |
.embed-gate-note { font-size: 12.5px; color: var(--text-3) !important; }
|
| 731 |
+
|
| 732 |
+
/* Install as an app */
|
| 733 |
+
.install-btn { margin-right: 4px; height: 30px; }
|
| 734 |
+
@media (max-width: 560px) { .install-btn span { display: none; } }
|
icons/apple-touch-icon.png
ADDED
|
|
icons/icon-192.png
ADDED
|
|
icons/icon-512.png
ADDED
|
|
icons/maskable-192.png
ADDED
|
|
icons/maskable-512.png
ADDED
|
|
index.html
CHANGED
|
@@ -7,6 +7,14 @@
|
|
| 7 |
<meta name="description" content="An AI agent (LFM3-1.7B on WebGPU) operating a real Linux machine (CheerpX), entirely in your browser and offline.">
|
| 8 |
<meta name="color-scheme" content="dark light">
|
| 9 |
<link rel="icon" href="icon.svg" type="image/svg+xml">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
<link rel="preload" href="vendor/fonts/inter-latin.woff2" as="font" type="font/woff2" crossorigin>
|
| 11 |
<link rel="stylesheet" href="vendor/xterm/xterm.css">
|
| 12 |
<link rel="stylesheet" href="css/app.css">
|
|
@@ -66,6 +74,7 @@
|
|
| 66 |
<span class="status-item" data-status="offline" data-state="idle"><i></i><span class="status-text">Offline</span></span>
|
| 67 |
</div>
|
| 68 |
<div class="titlebar-actions">
|
|
|
|
| 69 |
<button class="icon-btn" id="open-models" title="Model Manager" aria-label="Model Manager"><svg><use href="#i-cpu"/></svg></button>
|
| 70 |
<button class="icon-btn" id="new-chat" title="New conversation" aria-label="New conversation"><svg><use href="#i-new"/></svg></button>
|
| 71 |
<button class="icon-btn" id="open-settings" title="Settings" aria-label="Settings"><svg><use href="#i-sliders"/></svg></button>
|
|
@@ -177,6 +186,7 @@
|
|
| 177 |
</div>
|
| 178 |
|
| 179 |
<button class="btn primary block" id="install" disabled>Install</button>
|
|
|
|
| 180 |
<p class="note" id="setup-note"></p>
|
| 181 |
<p class="fine">
|
| 182 |
Language models are added afterwards and load straight from their Hugging Face repositories under their own licenses.
|
|
@@ -221,6 +231,13 @@
|
|
| 221 |
<input type="number" class="num" id="set-timeout" min="5" max="600">
|
| 222 |
</label>
|
| 223 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
<div class="dlg-section">
|
| 225 |
<div class="section-label">Data</div>
|
| 226 |
<div class="row-setting">
|
|
|
|
| 7 |
<meta name="description" content="An AI agent (LFM3-1.7B on WebGPU) operating a real Linux machine (CheerpX), entirely in your browser and offline.">
|
| 8 |
<meta name="color-scheme" content="dark light">
|
| 9 |
<link rel="icon" href="icon.svg" type="image/svg+xml">
|
| 10 |
+
<link rel="manifest" href="manifest.webmanifest">
|
| 11 |
+
<meta name="theme-color" content="#fafafa" media="(prefers-color-scheme: light)">
|
| 12 |
+
<meta name="theme-color" content="#0c0c0e" media="(prefers-color-scheme: dark)">
|
| 13 |
+
<link rel="apple-touch-icon" href="icons/apple-touch-icon.png">
|
| 14 |
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
| 15 |
+
<meta name="mobile-web-app-capable" content="yes">
|
| 16 |
+
<meta name="apple-mobile-web-app-title" content="LocalWebAgent">
|
| 17 |
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
| 18 |
<link rel="preload" href="vendor/fonts/inter-latin.woff2" as="font" type="font/woff2" crossorigin>
|
| 19 |
<link rel="stylesheet" href="vendor/xterm/xterm.css">
|
| 20 |
<link rel="stylesheet" href="css/app.css">
|
|
|
|
| 74 |
<span class="status-item" data-status="offline" data-state="idle"><i></i><span class="status-text">Offline</span></span>
|
| 75 |
</div>
|
| 76 |
<div class="titlebar-actions">
|
| 77 |
+
<button class="btn small install-btn" id="install-app" type="button" hidden title="Install LocalWebAgent as an app"><svg><use href="#i-download"/></svg><span>Install</span></button>
|
| 78 |
<button class="icon-btn" id="open-models" title="Model Manager" aria-label="Model Manager"><svg><use href="#i-cpu"/></svg></button>
|
| 79 |
<button class="icon-btn" id="new-chat" title="New conversation" aria-label="New conversation"><svg><use href="#i-new"/></svg></button>
|
| 80 |
<button class="icon-btn" id="open-settings" title="Settings" aria-label="Settings"><svg><use href="#i-sliders"/></svg></button>
|
|
|
|
| 186 |
</div>
|
| 187 |
|
| 188 |
<button class="btn primary block" id="install" disabled>Install</button>
|
| 189 |
+
<button class="btn block secondary" id="setup-install-app" type="button" hidden><svg><use href="#i-download"/></svg>Also install LocalWebAgent as an app</button>
|
| 190 |
<p class="note" id="setup-note"></p>
|
| 191 |
<p class="fine">
|
| 192 |
Language models are added afterwards and load straight from their Hugging Face repositories under their own licenses.
|
|
|
|
| 231 |
<input type="number" class="num" id="set-timeout" min="5" max="600">
|
| 232 |
</label>
|
| 233 |
</div>
|
| 234 |
+
<div class="dlg-section">
|
| 235 |
+
<div class="section-label">App</div>
|
| 236 |
+
<div class="row-setting">
|
| 237 |
+
<span><span class="rs-title">Install as an app</span><span class="rs-desc" id="set-install-desc">Opens in its own window, with an icon in your launcher, and works offline.</span></span>
|
| 238 |
+
<button type="button" class="btn" id="set-install">Install</button>
|
| 239 |
+
</div>
|
| 240 |
+
</div>
|
| 241 |
<div class="dlg-section">
|
| 242 |
<div class="section-label">Data</div>
|
| 243 |
<div class="row-setting">
|
js/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
// Central configuration. Everything that pins a version or a location lives here.
|
| 2 |
-
export const APP_VERSION = "0.
|
| 3 |
|
| 4 |
// --- Local language models (loaded from the Hugging Face Hub, cached in Cache Storage) ---
|
| 5 |
// Each runs on WebGPU through transformers.js. `chunks` is how many external weight files
|
|
|
|
| 1 |
// Central configuration. Everything that pins a version or a location lives here.
|
| 2 |
+
export const APP_VERSION = "0.10.0";
|
| 3 |
|
| 4 |
// --- Local language models (loaded from the Hugging Face Hub, cached in Cache Storage) ---
|
| 5 |
// Each runs on WebGPU through transformers.js. `chunks` is how many external weight files
|
js/main.js
CHANGED
|
@@ -163,7 +163,12 @@ async function init() {
|
|
| 163 |
$("#setup-note").textContent = "Downloading the new Linux machine. Keep this tab open.";
|
| 164 |
return install({ replacing: disk?.id });
|
| 165 |
}
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
else { status("offline", "warn", "Not installed"); showSetup(true); }
|
| 168 |
}
|
| 169 |
|
|
@@ -872,6 +877,39 @@ $("#uninstall").addEventListener("click", async () => {
|
|
| 872 |
});
|
| 873 |
|
| 874 |
window.addEventListener("online", () => { if (!$("#setup").hidden) showSetup(true); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 875 |
document.body.dataset.tab = "chat";
|
| 876 |
$(".side").dataset.view = "term";
|
| 877 |
init().catch((err) => {
|
|
|
|
| 163 |
$("#setup-note").textContent = "Downloading the new Linux machine. Keep this tab open.";
|
| 164 |
return install({ replacing: disk?.id });
|
| 165 |
}
|
| 166 |
+
const openModels = new URLSearchParams(location.search).get("open") === "models";
|
| 167 |
+
if (installed.cx && installed.disk) {
|
| 168 |
+
updateOfflineStatus();
|
| 169 |
+
if (openModels) models.open();
|
| 170 |
+
start().then(checkForNewImage);
|
| 171 |
+
}
|
| 172 |
else { status("offline", "warn", "Not installed"); showSetup(true); }
|
| 173 |
}
|
| 174 |
|
|
|
|
| 877 |
});
|
| 878 |
|
| 879 |
window.addEventListener("online", () => { if (!$("#setup").hidden) showSetup(true); });
|
| 880 |
+
|
| 881 |
+
// ---------- install as an app (PWA) ----------
|
| 882 |
+
let installPrompt = null;
|
| 883 |
+
const runningAsApp = () => matchMedia("(display-mode: standalone)").matches || navigator.standalone === true;
|
| 884 |
+
function syncInstallUi() {
|
| 885 |
+
const canPrompt = !!installPrompt && !runningAsApp();
|
| 886 |
+
$("#install-app").hidden = !canPrompt;
|
| 887 |
+
$("#setup-install-app").hidden = !canPrompt;
|
| 888 |
+
$("#set-install").hidden = runningAsApp();
|
| 889 |
+
$("#set-install-desc").textContent = runningAsApp()
|
| 890 |
+
? "Installed: you're using the app now."
|
| 891 |
+
: canPrompt ? "Opens in its own window, with an icon in your launcher, and works offline."
|
| 892 |
+
: /iPhone|iPad/.test(navigator.userAgent) ? "In Safari: Share, then Add to Home Screen."
|
| 893 |
+
: "Use your browser's menu: Install app (or Add to Home Screen).";
|
| 894 |
+
$("#set-install").disabled = !canPrompt;
|
| 895 |
+
}
|
| 896 |
+
async function promptInstall() {
|
| 897 |
+
if (!installPrompt) return;
|
| 898 |
+
installPrompt.prompt();
|
| 899 |
+
await installPrompt.userChoice.catch(() => null);
|
| 900 |
+
installPrompt = null; // a prompt can only be used once
|
| 901 |
+
syncInstallUi();
|
| 902 |
+
}
|
| 903 |
+
window.addEventListener("beforeinstallprompt", (e) => {
|
| 904 |
+
e.preventDefault(); // show our own button instead of the browser's mini-infobar
|
| 905 |
+
installPrompt = e;
|
| 906 |
+
syncInstallUi();
|
| 907 |
+
});
|
| 908 |
+
window.addEventListener("appinstalled", () => { installPrompt = null; syncInstallUi(); });
|
| 909 |
+
$("#install-app").addEventListener("click", promptInstall);
|
| 910 |
+
$("#setup-install-app").addEventListener("click", promptInstall);
|
| 911 |
+
$("#set-install").addEventListener("click", promptInstall);
|
| 912 |
+
syncInstallUi();
|
| 913 |
document.body.dataset.tab = "chat";
|
| 914 |
$(".side").dataset.view = "term";
|
| 915 |
init().catch((err) => {
|
manifest.webmanifest
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "./",
|
| 3 |
+
"name": "LocalWebAgent",
|
| 4 |
+
"short_name": "LocalWebAgent",
|
| 5 |
+
"description": "An AI agent with its own Linux computer, running in your browser. Works offline with local models.",
|
| 6 |
+
"start_url": "./?source=pwa",
|
| 7 |
+
"scope": "./",
|
| 8 |
+
"display": "standalone",
|
| 9 |
+
"orientation": "any",
|
| 10 |
+
"background_color": "#0c0c0e",
|
| 11 |
+
"theme_color": "#0c0c0e",
|
| 12 |
+
"categories": [
|
| 13 |
+
"developer",
|
| 14 |
+
"productivity",
|
| 15 |
+
"utilities"
|
| 16 |
+
],
|
| 17 |
+
"icons": [
|
| 18 |
+
{
|
| 19 |
+
"src": "icons/icon-192.png",
|
| 20 |
+
"sizes": "192x192",
|
| 21 |
+
"type": "image/png",
|
| 22 |
+
"purpose": "any"
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"src": "icons/icon-512.png",
|
| 26 |
+
"sizes": "512x512",
|
| 27 |
+
"type": "image/png",
|
| 28 |
+
"purpose": "any"
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"src": "icons/maskable-192.png",
|
| 32 |
+
"sizes": "192x192",
|
| 33 |
+
"type": "image/png",
|
| 34 |
+
"purpose": "maskable"
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"src": "icons/maskable-512.png",
|
| 38 |
+
"sizes": "512x512",
|
| 39 |
+
"type": "image/png",
|
| 40 |
+
"purpose": "maskable"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"src": "icon.svg",
|
| 44 |
+
"sizes": "any",
|
| 45 |
+
"type": "image/svg+xml",
|
| 46 |
+
"purpose": "any"
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"shortcuts": [
|
| 50 |
+
{
|
| 51 |
+
"name": "Model Manager",
|
| 52 |
+
"url": "./?open=models",
|
| 53 |
+
"icons": [
|
| 54 |
+
{
|
| 55 |
+
"src": "icons/icon-192.png",
|
| 56 |
+
"sizes": "192x192"
|
| 57 |
+
}
|
| 58 |
+
]
|
| 59 |
+
}
|
| 60 |
+
]
|
| 61 |
+
}
|
sw.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
// (__vm__/disk.ext2), backed by the chunks the setup screen stored in Cache Storage.
|
| 7 |
// 4. Adds the cross-origin isolation headers (COOP/COEP) that SharedArrayBuffer,
|
| 8 |
// CheerpX and multi-threaded WASM need, even when a host forgets to send them.
|
| 9 |
-
const SHELL_VERSION = "lwa-shell-0.
|
| 10 |
const CX_ORIGIN = "https://cxrtnc.leaningtech.com";
|
| 11 |
const CX_CACHE_PREFIX = "lwa-cheerpx-";
|
| 12 |
const DISK_CACHE = "lwa-disk";
|
|
@@ -16,7 +16,8 @@ const MANIFEST_KEY = SCOPE + "__vm__/manifest.json";
|
|
| 16 |
const chunkKey = (i) => SCOPE + "__vm__/chunk/" + i;
|
| 17 |
|
| 18 |
const SHELL_FILES = [
|
| 19 |
-
"./", "index.html", "css/app.css", "icon.svg",
|
|
|
|
| 20 |
"js/config.js", "js/config-defaults.js", "js/main.js", "js/setup.js", "js/vm.js", "js/agent.js", "js/llm.js",
|
| 21 |
"js/llm-worker.js", "js/llm-engine.js", "js/lazy-weights.js", "js/remote-llm.js", "js/model-manager.js", "js/fast-download.js", "js/hf-auth.js", "js/oauth-callback.js", "oauth.html", "js/prompts.js", "js/toolcalls.js", "js/markdown.js", "js/files.js",
|
| 22 |
"vendor/transformers.min.js", "vendor/highlight.min.js",
|
|
|
|
| 6 |
// (__vm__/disk.ext2), backed by the chunks the setup screen stored in Cache Storage.
|
| 7 |
// 4. Adds the cross-origin isolation headers (COOP/COEP) that SharedArrayBuffer,
|
| 8 |
// CheerpX and multi-threaded WASM need, even when a host forgets to send them.
|
| 9 |
+
const SHELL_VERSION = "lwa-shell-0.10.0";
|
| 10 |
const CX_ORIGIN = "https://cxrtnc.leaningtech.com";
|
| 11 |
const CX_CACHE_PREFIX = "lwa-cheerpx-";
|
| 12 |
const DISK_CACHE = "lwa-disk";
|
|
|
|
| 16 |
const chunkKey = (i) => SCOPE + "__vm__/chunk/" + i;
|
| 17 |
|
| 18 |
const SHELL_FILES = [
|
| 19 |
+
"./", "index.html", "css/app.css", "icon.svg", "manifest.webmanifest",
|
| 20 |
+
"icons/icon-192.png", "icons/icon-512.png", "icons/maskable-192.png", "icons/maskable-512.png", "icons/apple-touch-icon.png",
|
| 21 |
"js/config.js", "js/config-defaults.js", "js/main.js", "js/setup.js", "js/vm.js", "js/agent.js", "js/llm.js",
|
| 22 |
"js/llm-worker.js", "js/llm-engine.js", "js/lazy-weights.js", "js/remote-llm.js", "js/model-manager.js", "js/fast-download.js", "js/hf-auth.js", "js/oauth-callback.js", "oauth.html", "js/prompts.js", "js/toolcalls.js", "js/markdown.js", "js/files.js",
|
| 23 |
"vendor/transformers.min.js", "vendor/highlight.min.js",
|