@jeevanand/agent-browserbox-runtime 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -2
  3. package/bin/serve.mjs +74 -0
  4. package/dist/assets/anthropic-Cc12J4F-.js +17 -0
  5. package/dist/assets/bridge-Bqc3YIRQ.js +322 -0
  6. package/dist/assets/build-bryiJ-b6.js +2 -0
  7. package/dist/assets/bundle-rO6AXpFE.js +1 -0
  8. package/dist/assets/dev-impl-CfwRFPRf.js +4 -0
  9. package/dist/assets/embed-CMbAHE2J.js +3 -0
  10. package/dist/assets/github-CrzofUbV.js +2 -0
  11. package/dist/assets/html-DI-AyJM9.js +237 -0
  12. package/dist/assets/instance-CppC8T8t.js +2 -0
  13. package/dist/assets/kcore-COUztiEr.wasm +0 -0
  14. package/dist/assets/lib-aA6_aWm_.js +68 -0
  15. package/dist/assets/main-DBKsMgp-.js +482 -0
  16. package/dist/assets/node.browser-CCRW_leA.js +1 -0
  17. package/dist/assets/node.browser-D_wxWW2g.js +1 -0
  18. package/dist/assets/npm-DF8ts_uH.js +1 -0
  19. package/dist/assets/openai-D6_sZyaT.js +3 -0
  20. package/dist/assets/pkg-esbuild-DxKODBC3.js +1 -0
  21. package/dist/assets/pkg-git-Ds2ZjUJG.js +110 -0
  22. package/dist/assets/pkg-python-Cps4de9u.js +6 -0
  23. package/dist/assets/pkg-sqlite-BexM5lLo.js +4 -0
  24. package/dist/assets/pkg-zip-B_IjTDzR.js +1 -0
  25. package/dist/assets/publish-gZ8mQa6L.js +2 -0
  26. package/dist/assets/publish-impl-DV1nd6hh.js +7 -0
  27. package/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  28. package/dist/assets/server-CnIXpfUH.js +4 -0
  29. package/dist/assets/sql-wasm-CXIAVl5-.wasm +0 -0
  30. package/dist/assets/webllm-CGpOYyn6.js +11 -0
  31. package/dist/embed/index.html +15 -0
  32. package/dist/icon.svg +1 -0
  33. package/dist/kernel/bridge.html +13 -0
  34. package/dist/kernel/packages.json +1 -0
  35. package/dist/kernel/sandbox-net.html +18 -0
  36. package/dist/kernel/sandbox.html +18 -0
  37. package/dist/manifest.webmanifest +10 -0
  38. package/dist/preview/frame.html +27 -0
  39. package/dist/sw.js +73 -0
  40. package/index.d.ts +5 -0
  41. package/index.js +9 -0
  42. package/package.json +51 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jeevanand Maurya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,34 @@
1
- # Temporary Holding Version
1
+ # @jeevanand/agent-browserbox-runtime
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The runtime that [`@jeevanand/agent-browserbox`](../sdk) drives: BrowserBox's
4
+ kernel, filesystem, shell and sandboxes, as static files. Install it when you
5
+ want to serve the runtime yourself instead of using the hosted one.
6
+
7
+ ```sh
8
+ npx @jeevanand/agent-browserbox-runtime # serves it at http://127.0.0.1:4180/
9
+ npx @jeevanand/agent-browserbox-runtime --dir # prints the folder, to copy into your site
10
+ ```
11
+
12
+ ```ts
13
+ BrowserBox.boot({ runtimeUrl: 'http://127.0.0.1:4180/' });
14
+ ```
15
+
16
+ From Node, `import { runtimeDir } from '@jeevanand/agent-browserbox-runtime'`
17
+ gives the same folder, e.g. to copy it into your build output.
18
+
19
+ Serve it from **a different origin from your app** where you can: the box is
20
+ isolated by the origin boundary. Any static host works; no special headers are
21
+ required. Pages that use cross-origin isolation themselves should also send
22
+ `Cross-Origin-Resource-Policy: cross-origin` and
23
+ `Cross-Origin-Embedder-Policy: credentialless` for the runtime (the bundled
24
+ server does).
25
+
26
+ Origins that may use the runtime default to any: browsers partition each
27
+ embedding site's storage, so sites never see each other's boxes. To restrict
28
+ it, build from source with `VITE_EMBED_ORIGINS=https://a.example,https://b.example`.
29
+
30
+ Use the same version as the SDK.
31
+
32
+ ## License
33
+
34
+ MIT
package/bin/serve.mjs ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ // Serves the BrowserBox runtime locally, for @jeevanand/agent-browserbox's `runtimeUrl`.
3
+ //
4
+ // npx @jeevanand/agent-browserbox-runtime [--port 4180] [--host 127.0.0.1] [--dir]
5
+ import { createServer } from 'node:http';
6
+ import { readFile, stat } from 'node:fs/promises';
7
+ import { extname, join, normalize, sep } from 'node:path';
8
+ import { runtimeDir as DIST } from '../index.js';
9
+
10
+ const args = process.argv.slice(2);
11
+ const opt = (name, def) => {
12
+ const i = args.indexOf(name);
13
+ return i >= 0 && args[i + 1] && !args[i + 1].startsWith('--') ? args[i + 1] : def;
14
+ };
15
+ if (args.includes('-h') || args.includes('--help')) {
16
+ console.log(`Serves the BrowserBox runtime for the @jeevanand/agent-browserbox SDK.
17
+
18
+ Usage: agent-browserbox-runtime [options]
19
+ --port <n> port to listen on (default 4180, or the next free one)
20
+ --host <addr> address to bind (default 127.0.0.1)
21
+ --dir print the path of the runtime files (to host them elsewhere) and exit`);
22
+ process.exit(0);
23
+ }
24
+ if (args.includes('--dir')) {
25
+ console.log(DIST);
26
+ process.exit(0);
27
+ }
28
+
29
+ const TYPES = {
30
+ '.html': 'text/html; charset=utf-8', '.js': 'text/javascript', '.mjs': 'text/javascript', '.css': 'text/css',
31
+ '.json': 'application/json', '.wasm': 'application/wasm', '.svg': 'image/svg+xml', '.png': 'image/png',
32
+ '.webmanifest': 'application/manifest+json', '.txt': 'text/plain; charset=utf-8', '.map': 'application/json',
33
+ };
34
+ const HEADERS = {
35
+ // Lets the runtime frame be embedded by isolated pages too, and its files be fetched cross-origin.
36
+ 'Cross-Origin-Embedder-Policy': 'credentialless',
37
+ 'Cross-Origin-Resource-Policy': 'cross-origin',
38
+ };
39
+
40
+ const server = createServer(async (req, res) => {
41
+ try {
42
+ const path = decodeURIComponent(new URL(req.url, 'http://x').pathname);
43
+ let file = normalize(join(DIST, path));
44
+ if (file !== DIST && !file.startsWith(DIST + sep)) return res.writeHead(403).end();
45
+ let info = await stat(file).catch(() => null);
46
+ if (info?.isDirectory()) {
47
+ if (!path.endsWith('/')) return res.writeHead(301, { Location: path + '/' }).end();
48
+ file = join(file, 'index.html');
49
+ info = await stat(file).catch(() => null);
50
+ }
51
+ if (!info) return res.writeHead(404, { 'Content-Type': 'text/plain' }).end('not found');
52
+ const body = await readFile(file);
53
+ res.writeHead(200, {
54
+ ...HEADERS,
55
+ 'Content-Type': TYPES[extname(file)] ?? 'application/octet-stream',
56
+ 'Cache-Control': file.includes(`${sep}assets${sep}`) ? 'public, max-age=31536000, immutable' : 'no-cache',
57
+ });
58
+ res.end(req.method === 'HEAD' ? undefined : body);
59
+ } catch (e) {
60
+ res.writeHead(500).end(String(e));
61
+ }
62
+ });
63
+
64
+ const host = opt('--host', '127.0.0.1');
65
+ let port = Number(opt('--port', 4180));
66
+ server.on('error', (e) => {
67
+ if (e.code === 'EADDRINUSE' && !args.includes('--port')) return server.listen(++port, host);
68
+ console.error(e.message);
69
+ process.exit(1);
70
+ });
71
+ server.listen(port, host, () => {
72
+ const url = `http://${host === '0.0.0.0' ? 'localhost' : host}:${port}/`;
73
+ console.log(`BrowserBox runtime at ${url}\nUse it with: BrowserBox.boot({ runtimeUrl: '${url}' })\nPress Ctrl+C to stop.`);
74
+ });