@jeevanand/agent-browserbox-runtime 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +33 -2
- package/bin/serve.mjs +74 -0
- package/dist/assets/anthropic-S3ckT02t.js +17 -0
- package/dist/assets/bridge-DY2WnNx7.js +322 -0
- package/dist/assets/build-BNa5TW3M.js +2 -0
- package/dist/assets/bundle-8opp8__C.js +1 -0
- package/dist/assets/dev-impl-BRiXVAGb.js +4 -0
- package/dist/assets/embed-CMbAHE2J.js +3 -0
- package/dist/assets/github-Dwhv0h55.js +2 -0
- package/dist/assets/html-R2xYS1Rp.js +237 -0
- package/dist/assets/instance-CppC8T8t.js +2 -0
- package/dist/assets/kcore-COUztiEr.wasm +0 -0
- package/dist/assets/lib-aA6_aWm_.js +68 -0
- package/dist/assets/main-VEpSfsM_.js +482 -0
- package/dist/assets/node.browser-1OJr47If.js +1 -0
- package/dist/assets/node.browser-cOXEGsLT.js +1 -0
- package/dist/assets/npm-DF8ts_uH.js +1 -0
- package/dist/assets/openai-CThAXVqN.js +3 -0
- package/dist/assets/pkg-esbuild-BuQjm7dB.js +1 -0
- package/dist/assets/pkg-git-jawfIVoq.js +110 -0
- package/dist/assets/pkg-python-CoNK0IjJ.js +6 -0
- package/dist/assets/pkg-sqlite-BexM5lLo.js +4 -0
- package/dist/assets/pkg-zip-BdZ_Lkdk.js +1 -0
- package/dist/assets/publish-CHt_Qrq5.js +2 -0
- package/dist/assets/publish-impl-BqjdM7Ux.js +7 -0
- package/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/assets/server-C5Sd62CK.js +4 -0
- package/dist/assets/sql-wasm-CXIAVl5-.wasm +0 -0
- package/dist/assets/webllm-wsrhCAP4.js +11 -0
- package/dist/embed/index.html +15 -0
- package/dist/icon.svg +1 -0
- package/dist/kernel/bridge.html +13 -0
- package/dist/kernel/packages.json +1 -0
- package/dist/kernel/sandbox-net.html +18 -0
- package/dist/kernel/sandbox.html +18 -0
- package/dist/manifest.webmanifest +10 -0
- package/dist/preview/frame.html +27 -0
- package/dist/sw.js +73 -0
- package/index.d.ts +5 -0
- package/index.js +9 -0
- 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
|
-
#
|
|
1
|
+
# @jeevanand/agent-browserbox-runtime
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The runtime that [`@jeevanand/agent-browserbox-sdk`](../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-sdk'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 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
|
+
});
|