diff --git a/README.md b/README.md index b14632e793baa90f6c362da5b72908346ea79c00..863e4f33e0b66fc5efbaf25955188f579545d2eb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ --- -title: MiniCPM5-2B WebGPU Pi +title: MiniCPM5-2B Pi HTTP experiment emoji: 🥧 colorFrom: green colorTo: blue @@ -7,86 +7,37 @@ sdk: static app_file: index.html pinned: false license: apache-2.0 -short_description: A coding agent running entirely in your browser -thumbnail: https://huggingface.co/spaces/townbox/MiniCPM5-2B-WebGPU-Pi/resolve/main/social-thumbnail-v3.png +short_description: Browser coding agent with HTTP requests (experimental) models: - openbmb/MiniCPM5-2B - Mike0021/MiniCPM5-2B-ONNX tags: - transformers.js - - onnx - webgpu - - text-generation - agents - pi - just-bash --- -# Pi browser workspace · MiniCPM5-2B +# Pi browser HTTP experiment -Run **Pi's real agent core**, **just-bash**, and **MiniCPM5-2B** entirely in your browser. Chat with Pi, inspect and edit files, and execute shell commands in a persistent virtual workspace. A browser worker runs the agent loop, local WebGPU inference, and every tool. No inference API, API key, or shell server is involved. +An independent duplicate of [victor/MiniCPM5-2B-WebGPU-Pi](https://huggingface.co/spaces/victor/MiniCPM5-2B-WebGPU-Pi) at revision `959e272adeb7931e32d3eb2177dc1d5e96c3e967`. The original Space is unchanged. -Send your first message. If the complete verified model is already cached in this browser, Pi restores it and sends your message automatically, without a confirmation dialog. Otherwise, a **Load model & send** dialog explains the download. Confirming closes the dialog and shows progress in the top bar, then sends your message automatically. Cancel or Stop keeps your unsent draft; loading errors offer a retry. If the cache is incomplete or has changed, downloading missing files requires confirmation. You can also click **Load model** ahead of time. The first download is about **1.84 GB**; files are SHA-256 verified and cached in OPFS. The loader uses bounded byte ranges, retries, cancellation, and separate download / GPU setup / warm-up phases. Chat and virtual files are saved in IndexedDB on this site. Cached weights can be reused after reloading. The entire workspace uses a dark theme. +MiniCPM5-2B inference and just-bash run in a browser worker. This copy adds real `curl`/`wget` requests through browser `fetch`, with no backend or proxy. The first model download is about 1.84 GB, verified and cached locally. WebGPU with shader-f16 is required for inference; the Shell can run HTTP commands without loading the model. -If your browser blocks storage inside Hugging Face's embedded view, use the app's **Open workspace in a new tab** button or [open the app directly](https://townbox-minicpm5-2b-webgpu-pi.static.hf.space/). This keeps inference and files in your browser and does not require changing browser privacy settings. +Try in Shell: -Requires WebGPU with FP16 (`shader-f16`) in a browser worker, OPFS, and sufficient storage and device memory. There is an 8,192-token prompt-plus-output budget, up to 2,048 generated tokens per model call, and a 12-turn limit per request. Desktop and narrow-screen layouts are included. Physical Android/iOS devices have not been tested. +```bash +curl -fsS https://jsonplaceholder.typicode.com/todos/1 -o todo.json +jq '{id, title, completed}' todo.json +``` -Try: **What's our total sales revenue?** +Or ask Pi: **Fetch https://jsonplaceholder.typicode.com/todos/1, save it as todo.json, and tell me its title and whether it is completed.** -Pi has `bash`, `read`, `write`, and `edit` tools. just-bash supports shell scripts, pipes, redirects, `awk`, `jq`, `sed`, `grep`, and other text commands. Node.js, Python, npm, native binaries, SQLite, and network commands are unavailable. The left column uses xterm.js with Pi's actual terminal renderer, editor, and message components. MiniCPM and the tools run in the browser worker. This reuses Pi's TUI; the full Node CLI and its extensions are not included. Files are virtual and remain on your device. Export work you want to keep. +Allowed HTTPS hosts: `api.github.com`, `raw.githubusercontent.com`, `huggingface.co`, `jsonplaceholder.typicode.com`, and `httpbin.org`. GET, HEAD, and POST are enabled, with an 8-second deadline and 1 MiB response limit. Use `set -o pipefail` before pipelines to retain download failures. -The top bar shows the model, its load status, and a live token-speed sparkline labeled **WebGPU** for inference or **JavaScript** for tool execution. Speed is measured from generated tokens, including thinking; prompt processing and tool execution have their own statuses. The chart clears when generation stops. Successful file reads open the corresponding workspace file while preserving unsaved edits. Common file types have Seti icons. The shell includes live Bash syntax coloring, multiline commands, session history, colored errors/exit states, and a resizable output area. Panels use background shading and rounded corners sized to their nested spacing throughout the dark workspace. +Browser CORS applies. Redirects require the final URL directly: browsers hide redirect destinations, so this copy reports an error instead of silently returning empty output or following unchecked hosts. Cookies are omitted. Explicit request URLs, headers, and bodies are sent to the destination; inference and workspace storage remain local. Node.js, Python, npm, and native programs remain unavailable. -The terminal uses Pi's dark palette and native message/editor padding. Recent checks cover seven viewport sizes, Unicode alignment, long tool output, a simulated 60-turn transcript, twelve keyboard interactions, five actual-model workflows, and a ten-turn conversation with twelve tool results. Mobile sizes were simulated on desktop Chromium. +Source is under `app/`. Rebuild with `cd app && npm ci && npm test && npm run build`, then `python3 scripts/stage.py`. The HTTP implementation is in `app/src/browser-http.mjs`; it uses just-bash's existing curl/wget commands and custom transport hook. Tests and results are in `validation/`. -## Our conversion - -The included `q4f16` model was converted directly from the official [OpenBMB MiniCPM5-2B BF16 checkpoint](https://huggingface.co/openbmb/MiniCPM5-2B/tree/abe115e887989b14f05e64a3b260648329324c3f), not from community-converted weights. - -- Source revision: `abe115e887989b14f05e64a3b260648329324c3f`. -- Official weight SHA-256, verified before conversion: `14fb8e7f0a18d53d1f239773758bf581cee7e456a4523a54622c3a245b64402c`. -- ONNX Runtime GenAI 0.15.2; symmetric int4, block size 32; FP16 activations and KV cache. -- Fused QKV, GQA, RoPE, and normalization operations. -- Last-position logits selected before the output projection. -- Lossless splitting of the 510 MiB embedding allocation into four 127.5 MiB tensors. -- Seven external-data shards; corrected tool-history serialization and Jinja compatibility. - -The [package manifest](https://huggingface.co/Mike0021/MiniCPM5-2B-ONNX/blob/04a6c49fcba3a65a0351c92644c3a7e9d4343059/manifest.json) contains file sizes and SHA-256 hashes. The weights are hosted in the companion [model repository](https://huggingface.co/Mike0021/MiniCPM5-2B-ONNX). The app pins model revision `04a6c49fcba3a65a0351c92644c3a7e9d4343059`; the Space hosts the app and browser runtime. - -## Validation - -Six prompts with prefill and cached decoding give 41 tested prediction positions. These are scoped conversion checks, not a broad quality evaluation. - -| Comparison | Top-token agreement | Mean KL divergence | -|---|---:|---:| -| FP16 ONNX vs FP16 PyTorch | 41/41 | 0.00000815 | -| Int4 ONNX vs official BF16 PyTorch | 36/41 | 0.125916 | -| Packaged int4 vs our original int4 export | 41/41; all logits bit-identical | 0 | -| Browser WebGPU vs native packaged ONNX | 41/41 | 0.002517 | - -Local Chromium tests on an AMD Radeon 8060S covered streaming, stopping, thinking mode, XML tool-call generation, and one retrieval fixture at 3,888 prompt tokens. Inference also passed with the GPU device capped at a 128 MiB storage binding limit and 256 MiB buffer limit. This desktop allocation test does not emulate a phone's memory pressure or thermals. - -Warm local benchmark medians were about 35–42 decode tokens/s. At 1,890 prompt tokens, first-token latency improved about 9.5% against our own identical-weight control with all-position logits and unsplit embeddings. Timings depend on device, browser, prompt, and thermal state. - -Four-bit quantization has measurable quality loss. A multi-turn audit reproduced ineffective HTML/CDN edits and long, inconclusive reasoning with this export, while the original BF16 model completed the reference workflow. The base model also makes mistakes: one Chinese arithmetic prompt produced an incorrect answer in both the official BF16 model and the conversion. Pi translates validated XML tool calls into actions in the virtual filesystem. Integration tests do not establish broad coding-agent reliability. - -The agent now uses the 2B model's supported thinking mode and actual nucleus sampling (temperature 1, top-p .95, no top-k/min-p filter, repetition penalty 1). Completed thinking is retained separately in history and collapsed in the UI. The audit documents the earlier configuration mistakes, exact-prompt comparisons, parser/sampling corrections, and unresolved quality limits. It does not claim the 4-bit model matches BF16 or that multi-turn inference is fully optimized. - -## Browser-agent verification - -The production browser bundle passed five real-model agent workflows with networking disabled: reading an unseen random file value, computing CSV revenue and writing a report, creating and executing a shell script, editing that script, and recovering from a missing-file error. It made zero network requests during these tasks. Tests also cover generation cancellation, editor/import/shell controls, persisted files and chat, and cached reloads with zero weight requests. Eight unit tests cover XML/CDATA, tool-shaped code examples, context/history conversion, filesystem restoration, and inert Markdown. - -The same workflows passed with an actual desktop GPU capped at 128 MiB storage bindings and 256 MiB buffers. This is not mobile hardware emulation. Public-Hub download cancellation/retry was tested locally; cached reloads took about 1.8–1.9 seconds on the tested desktop. - -The deployed browser agent also passed all five workflows from the public Space URL, with zero requests during offline tasks and zero weight downloads on reload. The actual Hugging Face embedded page successfully loaded the model and used Pi's bash and file tools to produce and verify the $144 report. - -The xterm.js terminal build also passed all 12 terminal interaction checks from the public app URL, including keyboard editing, search, history, Unicode/large clipboard paste, shell execution, and a 390px layout. In the actual Hugging Face embed, it loaded MiniCPM from cache in 3.644 seconds on the tested desktop and created a fresh, verified $144 sales report through Pi's tools. - -## Runtime - -Browser runtime versions: Pi Agent / Pi AI **0.85.1**, just-bash **3.4.2**, Transformers.js **4.2.0**, and ONNX Runtime Web **1.26.0-dev.20260416-b7804b056c**. JavaScript/WASM assets are hosted in this Space. Model caching is keyed to the pinned model revision and per-file verification receipts. - -## Attribution - -Base model: **OpenBMB**, Apache-2.0. Agent: **Pi / earendil-works**. Shell: **just-bash / Vercel**. Inference: **Hugging Face Transformers.js** and **Microsoft ONNX Runtime**. Bundled license texts and notices are in [licenses](licenses). This Space contains an independently converted and quantized derivative; no weights were retrained. +The small 4-bit model can make mistakes. Shell transport checks and actual-model trials are reported separately; they do not establish general agent reliability or physical-phone performance. diff --git a/app/README.md b/app/README.md new file mode 100644 index 0000000000000000000000000000000000000000..df52fbe45c06e76809ab8f72712ad66ba9422fbd --- /dev/null +++ b/app/README.md @@ -0,0 +1,137 @@ +# Pi in the browser + +A static web app running **Pi’s actual terminal UI in xterm.js**, **the real Pi Agent**, **just-bash**, and **our verified MiniCPM5-2B q4f16 conversion** in the browser. A dedicated worker owns the agent loop, WebGPU inference, and virtual shell. No inference API, API key, shell server, or Pi RPC server is involved. + +```sh +cd app +npm ci +npm run build +npm run preview +``` + +Open the printed localhost URL and send your first message. If the complete verified model is already cached, Pi restores it and sends your message automatically without a confirmation dialog. Otherwise, a **Load model & send** dialog explains the download and closes immediately on confirmation. Progress appears in the top bar while your message stays visible as queued; it sends automatically once the model is ready. Closing the dialog or pressing Stop returns the unsent message to the editor. Loading errors reopen the dialog for retry. Automatic restoration never downloads missing model files: an incomplete or changed cache requires confirmation. You can also load ahead of time with **Load model**. The default downloads our pinned model from Hugging Face. The app needs a secure context (HTTPS or localhost), WebGPU with `shader-f16` in a worker, and OPFS storage. Allow about 2 GB of free browser storage plus device memory for inference. Actual memory availability matters on phones. + +For development, use `npm run dev`. To use the already converted weights on this computer instead of downloading them, run `python scripts/serve.py` from the repository root in another terminal, then open `http://127.0.0.1:5173/?source=local`. The development and preview servers forward `/models` to that static file server. The local source option is accepted only on localhost/127.0.0.1. + +## Features + +- Pi’s upstream fullscreen renderer, multiline editor, user/assistant message components, Markdown, prompt history, and autocomplete. xterm.js renders their ANSI output. +- `/load`, `/help`, `/new`, and `!command` browser commands. Enter sends, Shift+Enter inserts a newline, Escape/Ctrl+C stops, Ctrl+O expands tools. Ctrl+P/N recalls prompts; Ctrl+Shift+F searches the transcript. The Send and Newline buttons also support touch input. +- Streaming conversation with genuine `@earendil-works/pi-agent-core` tool execution and automatic follow-up turns. +- `bash`, `read`, `write`, and exact-match `edit` tools connected to the same just-bash filesystem. +- File editor with Prism syntax colors for HTML/XML/SVG, CSS, JavaScript/TypeScript (including JSX/TSX), Python, Bash, JSON, Markdown, YAML, TOML, SQL, CSV, C/C++, C#, Java, Go, Rust, Dockerfiles, and diffs. Highlighting runs in a separate, lazily started worker and is debounced while typing. Native textarea editing, selection, undo, and scrolling are preserved. Unknown formats, files above 200,000 characters or 5,000 lines, excessive token output, and grammar work exceeding 1.5 seconds fall back to plain text. Text-file import, workspace export, and an interactive command entry are also included. +- The starter workspace pairs `sales.csv` (products and units sold) with `products.json` (product prices). Both are needed for total sales revenue. The cat suggests “What's our total sales revenue?” without naming files or tools; the workspace README contains no calculation instructions. Only an untouched earlier pair is upgraded together; custom data and prior deletions are preserved. +- Successful `read` tool calls open and highlight the resolved file in the workspace, including relative paths and symlinks. Following waits for newly created files, preserves unsaved edits, and keeps the conversation’s focus and page scroll position. Common file types use a local subset of 18 Seti icons from VS Code’s built-in theme, totaling about 12 KB of SVGs. +- The shell highlights Bash as you type, accepts multiline commands (Shift+Enter), recalls session history (↑/↓), and separates command/output blocks with colored exit states and errors. Clear or Ctrl+L clears the output. Its output area can be resized vertically. +- Model name, loading progress, and loaded status live in a rounded, inset top bar aligned with the workspace width. New chat sits at the bottom left of the terminal, opposite the send controls. Panels use background shading and rounded corners instead of separator borders. +- The top bar’s activity indicator labels model inference **WebGPU** and tool execution **JavaScript**. It shows loading, prompt processing, tool execution, and live generation speed. Its sparkline uses actual generated-token counts, including thinking, over a rolling second; prompt-processing time is excluded. Rates refresh four times per second and clear when generation stops. The capsule fits its current contents with a 220ms width transition, disabled when reduced motion is preferred. Nested corner radii account for their insets: the header uses a 16px radius around 8px-radius controls with 8px padding. +- The first-message dialog explains that the model, inference, and shell run entirely in the browser. Pi’s input receives focus when the workspace starts; cancelling setup returns focus and the unsent draft to Pi. +- The download dialog has a matching peeking cat with transparent paws over its top edge. The sprite preloads and decodes on page startup, stays decorative for keyboard/screen-reader users, and shrinks on short screens to keep the download note and actions visible. Subtle paw prints appear around the overlay whenever the dialog is open, including before confirmation and on retry. They do not intercept clicks, pause in hidden tabs, and stay still with reduced motion. +- After 7 seconds of inactivity, a faint paw trail occasionally crosses Pi’s transcript, with 45–60 seconds between trails. Typing, clicking, or scrolling clears it immediately; pointer movement neither resets the delay nor stops the trail. It stays above the input, never takes focus, and pauses during model activity, open dialogs, hidden or unfocused tabs, and reduced motion. +- An empty chat has a small blocky cat with a clickable starter prompt. The bubble and cat appear together once the image is decoded. The suggestion fills Pi’s editor without sending, adapts to the workspace files, and disappears after the first user message. The 104px mascot makes one gentle hop shortly after appearing, then occasionally blinks; clicking or tapping the cat replays the hop and a short meow. Both cats are decorative and never take keyboard focus. Motion pauses while hidden and is disabled for reduced-motion preferences. Its paws align with the input divider, with room reserved beside it for the status text. Its position follows the terminal’s available blank rows, keeping the input and transcript unobstructed; short viewports omit it when there is no room. +- IndexedDB persistence for chat, file bytes, executable modes, directories, and symbolic links. New chat keeps the workspace. +- Verified model downloading: six concurrent files, 32 MiB byte ranges, three attempts per chunk, cancellation, incremental SHA-256 checks, and atomic OPFS writes. Completed files survive an interrupted load; an incomplete file restarts on retry. +- Cached reloads use file size, modification time, and the stored verification receipt. Model files are hashed during download; they are not rehashed on every reload. +- Visible download / WebGPU setup / shader warm-up phases. No image requests from model-generated Markdown. +- MiniCPM5-2B's supported thinking mode, with completed reasoning retained separately in conversation history. Thoughts are collapsed in the terminal; click to expand. Tool-shaped text inside reasoning is never executed. +- Temperature 1, actual top-p 0.95 sampling, no top-k/min-p filtering, and repetition penalty 1. A tested adapter applies nucleus filtering because Transformers.js 4.2.0 does not implement its exposed `top_p` option in generation. +- An 8,192-token combined prompt/output budget, up to 2,048 generated tokens (reasoning plus answer/tool XML) per model call, and a 12-turn limit per user request. Older complete user turns can be omitted from inference context; the full saved conversation is retained. An oversized current turn produces an explicit error. +- The terminal footer shows used/total context tokens and remaining capacity for the latest model call. It includes the formatted prompt (instructions, tool definitions, and retained history) plus generated tokens, updates during streaming, survives reloads, and resets with New chat. Unsent draft text is counted when submitted; saved turns excluded from the model context are not counted. On narrow screens the counter gets its own line. + +## Model quality + +The [September 14 multi-turn audit](../research/multiturn-audit/REPORT.md) found that the previous no-thinking/greedy profile was not faithful to the model's documented configuration. The corrected adapter handles reasoning and sampling, but the current 4-bit conversion still fails some HTML/CDN follow-ups that the original BF16 model completed. It can produce ineffective edits or exhaust its reasoning budget. Numerical conversion checks and basic tool tests do not establish general coding reliability. Cross-call KV reuse and physical-phone validation remain outstanding. +- Responsive desktop and mobile layouts. The file workspace follows the chat on narrow screens. +- A consistent dark theme across the terminal, header, model controls, file editor, shell, and setup dialog, including native form controls and scrollbars. + +## Runtime boundaries + +This uses Pi's actual TUI and agent core with browser host adapters. The npm `pi-tui` package supplies the renderer, editor, input parser, layout, Markdown, search, and keybindings. Unmodified CLI presentation components are in [vendor/pi-coding-agent](vendor/pi-coding-agent/README.md), with provenance checksums and the upstream dark palette. Secondary text colors are lifted for legibility at small sizes. [The build adapter](scripts/pi-browser.mjs) replaces terminal host services; [the terminal adapter](src/pi/xterm-terminal.mjs) connects xterm input/output/resize to Pi. Browser command dispatch and just-bash tool cards are app code. + +Message padding follows Pi 0.85.1 defaults: one column of output padding, one inner row above/below user and tool boxes, one separator row between turns, and zero editor column padding. The browser panel adds an 8px outer inset, with no right padding on desktop. Pi owns transcript scrolling, so xterm's unused native scrollbar gutter is disabled. The pinned `@xterm/addon-unicode-graphemes@0.4.0` addon matches Pi's grapheme widths for CJK, emoji sequences and combining accents. It uses xterm's proposed Unicode API and is covered by rendering assertions. + +The full Node CLI, host filesystem, OAuth providers, extensions, package installation, and RPC server are not included. xterm.js is the terminal emulator; it does not add Node.js or a native shell. Model inference and tool execution remain in the browser worker. Terminal control sequences from model/file output are stripped before rendering, and Markdown images do not trigger downloads. + +just-bash is a simulated shell, not a Linux VM. Shell scripts, pipes, redirects, `awk`, `jq`, `sed`, `grep`, `find`, and other supported text commands execute in JavaScript. Node.js, Python, npm, native executables, and SQLite are unavailable. This HTTP experiment enables curl/wget for selected HTTPS APIs through a browser fetch adapter; see public/http-help.html for hosts, examples, and limits. The installed browser bundle also excludes working gzip/zlib commands. Shell cwd and variables reset between commands; filesystem changes persist. Commands have a 10-second deadline, 3,000-command cap, 16 MiB filesystem budget, and 256 KiB output budget. Tool output passed to the model is capped at 6,000 characters. + +Local model and filesystem tool calls can run with the browser network disabled after loading. HTTP commands require a connection and CORS permission from the destination. Reopening the app itself still requires its static HTML/JS/WASM assets; there is no offline service worker. Browser storage belongs to this site's origin and may be evicted by the browser. Export important work. + +The small 4-bit model can make mistakes. These tests establish working integration on the tested device, not broad coding-agent reliability or support for every mobile browser. No physical phone has been tested. + +## Verification + +```sh +npm test +npm run build +# Start npm run preview, then run the terminal checks (no model needed): +node tests/terminal.mjs +# Deterministic presentation fixtures, including narrow and short viewports: +npm run test:render +# Ten consecutive actual-model turns (local model server required): +npm run test:conversation +# First message, modal cancellation/retry, and actual model auto-send: +npm run test:first-message +# Download confirmation, top-bar progress, queued messages and cancellation (controlled worker fixtures): +npm run test:load-flow +# Cached auto-start, invalidated cache, Stop and GPU failure recovery: +npm run test:cached-start +# Live token speed, generation/tool/idle phases and eight header layouts: +npm run test:runtime-meter +# Automatic read following, unsaved edits, file icons and mobile layout: +npm run test:follow-read +# File highlighting, native editing, saving, scrolling and large-file fallback: +npm run test:editor +# Companion product data and preserving existing workspaces during its addition: +npm run test:starter-products +# Opt-in real WebGPU model evaluation; requires the dedicated cached test profile: +npm run test:sales-demo +# Syntax-colored command input, actual shell execution, history and layouts: +npm run test:shell +# Actual token usage, streaming, cancellation, reload and input focus: +npm run test:context +# Start npm run preview -- --port 4173 and the root static model server first: +npm run test:browser +``` + +The terminal suite checks real keyboard events, multiline editing, autocomplete, history, Unicode and large clipboard pastes, shell execution, and live resize. The browser suite uses real Chromium, the actual model, and the production bundle; prompts are submitted through xterm and Pi’s editor. It disables networking while Pi reads a random value from an unseen file, calculates CSV revenue, writes and verifies a report, creates and executes a shell script, edits it, and recovers from a missing-file tool error. It also checks stopping generation, file import/edit/save, manual shell execution, workspace persistence, cached reloads, and a 390 px layout. + +To exercise the public Hugging Face download in a separate browser profile: + +```sh +APP_URL=http://127.0.0.1:4173/ \ +BROWSER_PROFILE=../validation/agent-browser-profile/remote \ +TEST_LABEL=agent-browser-hub TEST_CANCEL_LOAD=1 npm run test:browser +``` + +To exercise smaller GPU buffer allocations on the desktop GPU: + +```sh +APP_URL='http://127.0.0.1:4173/?source=local&limit128' \ +TEST_LABEL=agent-browser-limit128 npm run test:browser +``` + +`limit128` sets the actual WebGPU device to 128 MiB storage bindings and 256 MiB buffers. It is an allocation compatibility test; viewport resizing and GPU limits do not emulate mobile hardware performance. + +Results and screenshots are in the repository's `validation/agent-browser*` files. Test logs include complete model tool calls and results. The browser profile and downloaded weights are ignored by Git. + +## Static hosting + +Upload **the contents of `app/dist`** to an HTTPS static host. It contains the app and local ONNX Runtime assets; weights are fetched from the pinned public Hugging Face repository and cached in OPFS. No build or inference server is needed after deployment. + +The public deployment is [townbox/MiniCPM5-2B-WebGPU-Pi](https://huggingface.co/spaces/townbox/MiniCPM5-2B-WebGPU-Pi). From the repository root, `python scripts/prepare_space.py` stages the built app, source, licenses, and selected validation files in `.space-agent/` for upload. + +Browsers that deny storage in third-party embeds get an **Open workspace in a new tab** link. The top-level Space app can then use its own storage without changing browser privacy settings. Embedded-page tests restore normal Chromium storage partitioning because Playwright 1.58 disables it by default; the restricted-storage path is tested separately. + +## Pinned components + +| Component | Version / revision | +|---|---| +| Pi agent core and Pi AI types/event stream | `@earendil-works/*` 0.85.1 | +| Pi TUI / CLI presentation components | 0.85.1 | +| xterm.js / fit addon | 6.0.0 / 0.11.0 | +| just-bash | 3.4.2, explicit `just-bash/browser` import | +| Transformers.js | 4.2.0 | +| Model | `Mike0021/MiniCPM5-2B-ONNX` at `04a6c49fcba3a65a0351c92644c3a7e9d4343059` | +| Model provenance | official OpenBMB weights; see root README and package manifest | + +Architecture decisions and primary-source research are in [the investigation](../research/browser-agent/REPORT.md). diff --git a/app/index.html b/app/index.html new file mode 100644 index 0000000000000000000000000000000000000000..a91b5619c76cf1bd96c0311d2861420e56936031 --- /dev/null +++ b/app/index.html @@ -0,0 +1,100 @@ + + +
+ + + + + + + + + + + + + + + + + + + +One download, about 1.84 GB. Cached in this browser for next time.
+ + +This experimental copy enables real curl and wget requests. The model and shell run on your device. Requests go directly from your browser to the destination; there is no proxy. Request URLs, headers, and bodies are sent to that service.
Allowed HTTPS hosts: api.github.com, raw.githubusercontent.com, huggingface.co, jsonplaceholder.typicode.com, and httpbin.org. GET, HEAD, and POST are enabled. Cookies are omitted. Requests have an 8-second deadline and a 1 MiB response limit.
curl -fsS https://jsonplaceholder.typicode.com/todos/1 -o todo.json
+jq '{id, title, completed}' todo.json
+set -o pipefail
+curl -fsS https://api.github.com/repos/huggingface/transformers.js | jq '{full_name, stargazers_count}'
+“Fetch https://jsonplaceholder.typicode.com/todos/1, save it as todo.json, and tell me its title and whether it is completed.”
+The destination must allow browser access with CORS. Redirects are reported as errors: use the final URL directly, with the exact capitalization. A plain curl pipeline can hide an error unless you enable set -o pipefail. Python, Node.js, npm, and native binaries remain unavailable.
Back to the workspace · Original Space
+ diff --git a/app/public/library-icons/huggingface.svg b/app/public/library-icons/huggingface.svg new file mode 100644 index 0000000000000000000000000000000000000000..43c5d3c0c97a9150b19d10bc68f4c9042c5034cd --- /dev/null +++ b/app/public/library-icons/huggingface.svg @@ -0,0 +1,37 @@ + diff --git a/app/public/library-icons/onnxruntime.ico b/app/public/library-icons/onnxruntime.ico new file mode 100644 index 0000000000000000000000000000000000000000..b47880019f3c20d814a6cb40bc5523e5d48f8e88 Binary files /dev/null and b/app/public/library-icons/onnxruntime.ico differ diff --git a/app/public/licenses/library-icons-NOTICE.txt b/app/public/licenses/library-icons-NOTICE.txt new file mode 100644 index 0000000000000000000000000000000000000000..a059f382dc2334c86c9b846c198f56acd527baf2 --- /dev/null +++ b/app/public/licenses/library-icons-NOTICE.txt @@ -0,0 +1,12 @@ +Library credits icons, obtained 2026-09-14. + +Hugging Face logo (unmodified): +https://huggingface.co/front/assets/huggingface_logo-noborder.svg + +ONNX Runtime favicon (unmodified): +https://onnxruntime.ai/favicon.ico + +Pi mark: official paths reused from the header; see pi-logo-NOTICE.txt. +The terminal beside just-bash is an app-drawn generic shell icon. + +Names and marks identify the upstream projects used by this independent demo. diff --git a/app/public/licenses/onnxruntime-LICENSE b/app/public/licenses/onnxruntime-LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..48bc6bb4996ac924359e8e28b9ae88970e5ed3fc --- /dev/null +++ b/app/public/licenses/onnxruntime-LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/app/public/licenses/onnxruntime-ThirdPartyNotices.txt b/app/public/licenses/onnxruntime-ThirdPartyNotices.txt new file mode 100644 index 0000000000000000000000000000000000000000..fbd9f9a95f6013d8ecaef81e02b0033e5882a675 --- /dev/null +++ b/app/public/licenses/onnxruntime-ThirdPartyNotices.txt @@ -0,0 +1,6121 @@ +THIRD PARTY SOFTWARE NOTICES AND INFORMATION + +Do Not Translate or Localize + +This software incorporates material from third parties. Microsoft makes certain +open source code available at http://3rdpartysource.microsoft.com, or you may +send a check or money order for US $5.00, including the product name, the open +source component name, and version number, to: + +Source Code Compliance Team +Microsoft Corporation +One Microsoft Way +Redmond, WA 98052 +USA + +Notwithstanding any other terms, you may reverse engineer this software to the +extent required to debug changes to any libraries licensed under the GNU Lesser +General Public License. + +_____ + +Intel Math Kernel Library (Intel MKL) + +Intel Simplified Software License (Version April 2018) + +Copyright (c) 2018 Intel Corporation. + +Use and Redistribution. You may use and redistribute the software (the “Software”), without modification, +provided the following conditions are met: + +* Redistributions must reproduce the above copyright notice and the following terms of use in the Software +and in the documentation and/or other materials provided with the distribution. + +* Neither the name of Intel nor the names of its suppliers may be used to endorse or promote products +derived from this Software without specific prior written permission. + +* No reverse engineering, decompilation, or disassembly of this Software is permitted. + +Limited patent license. Intel grants you a world-wide, royalty-free, non-exclusive license under patents it now +or hereafter owns or controls to make, have made, use, import, offer to sell and sell (“Utilize”) this Software, +but solely to the extent that any such patent is necessary to Utilize the Software alone. The patent license +shall not apply to any combinations which include this software. No hardware per se is licensed hereunder. + +Third party and other Intel programs. “Third Party Programs” are the files listed in the “third-party-programs.txt” +text file that is included with the Software and may include Intel programs under separate license terms. +Third Party Programs, even if included with the distribution of the Materials, are governed by +separate license terms and those license terms solely govern your use of those programs. + +DISCLAIMER. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED. THIS SOFTWARE IS +NOT INTENDED FOR USE IN SYSTEMS OR APPLICATIONS WHERE FAILURE OF THE SOFTWARE +MAY CAUSE PERSONAL INJURY OR DEATH AND YOU AGREE THAT YOU ARE FULLY RESPONSIBLE FOR ANY +CLAIMS, COSTS, DAMAGES, EXPENSES, AND ATTORNEYS’ FEES ARISING OUT OF ANY SUCH USE, +EVEN IF ANY CLAIM ALLEGES THAT INTEL WAS NEGLIGENT REGARDING THE DESIGN OR MANUFACTURE OF +THE MATERIALS. + +LIMITATION OF LIABILITY. IN NO EVENT WILL INTEL BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGE. YOU AGREE TO INDEMNIFY AND HOLD INTEL HARMLESS AGAINST ANY CLAIMS +AND EXPENSES RESULTING FROM YOUR USE OR UNAUTHORIZED USE OF THE SOFTWARE. + +No support. Intel may make changes to the Software, at any time without notice, and is not obligated to +support, update or provide training for the Software. + +Termination. Intel may terminate your right to use the Software in the event of your breach of this Agreement +and you fail to cure the breach within a reasonable period of time. + +Feedback. Should you provide Intel with comments, modifications, corrections, enhancements or other input +(“Feedback”) related to the Software Intel will be free to use, disclose, reproduce, license or otherwise +distribute or exploit the Feedback in its sole discretion without any obligations or restrictions of any kind, +including without limitation, intellectual property rights or licensing obligations. + +Compliance with laws. You agree to comply with all relevant laws and regulations governing your use, +transfer, import or export (or prohibition thereof) of the Software. + +Governing law. All disputes will be governed by the laws of the United States of America and the State of +Delaware without reference to conflict of law principles and subject to the exclusive jurisdiction of the state or +federal courts sitting in the State of Delaware, and each party agrees that it submits to the personal +jurisdiction and venue of those courts and waives any objections. The United Nations Convention on +Contracts for the International Sale of Goods (1980) is specifically excluded and will not apply to the +Software. + +*Other names and brands may be claimed as the property of others. + +_____ + +protocolbuffers/protobuf + +Copyright 2008 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +_____ + +madler/zlib + +The deflate format used by zlib was defined by Phil Katz. The deflate and +zlib specifications were written by L. Peter Deutsch. Thanks to all the +people who reported problems and suggested various improvements in zlib; they +are too numerous to cite here. + +Copyright notice: + + (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* receiving +lengthy legal documents to sign. The sources are provided for free but without +warranty of any kind. The library has been entirely written by Jean-loup +Gailly and Mark Adler; it does not include third-party code. + +If you redistribute modified sources, we would appreciate that you include in +the file ChangeLog history information documenting your changes. Please read +the FAQ for more information on the distribution of modified source versions. + +_____ + +pybind/pybind11 + +Copyright (c) 2016 Wenzel Jakob