@b3os/cli 0.2.0 → 0.2.2
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/README.md +87 -7
- package/assets/b3os-run.py +137 -0
- package/assets/skill/b3os/SKILL.md +111 -0
- package/dist/commands/_agents.d.ts +14 -0
- package/dist/commands/_agents.js +33 -0
- package/dist/commands/_agents.js.map +1 -0
- package/dist/commands/_common.js +6 -2
- package/dist/commands/_common.js.map +1 -1
- package/dist/commands/_context.d.ts +49 -0
- package/dist/commands/_context.js +260 -0
- package/dist/commands/_context.js.map +1 -0
- package/dist/commands/_next.d.ts +39 -0
- package/dist/commands/_next.js +77 -0
- package/dist/commands/_next.js.map +1 -0
- package/dist/commands/agent.d.ts +42 -0
- package/dist/commands/agent.js +218 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/app.d.ts +2 -0
- package/dist/commands/app.js +559 -54
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/auth.d.ts +88 -2
- package/dist/commands/auth.js +354 -44
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/docs.d.ts +54 -0
- package/dist/commands/docs.js +202 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/commands/doctor.d.ts +23 -0
- package/dist/commands/doctor.js +313 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +38 -1
- package/dist/commands/init.js +259 -60
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/listen.d.ts +30 -0
- package/dist/commands/listen.js +194 -0
- package/dist/commands/listen.js.map +1 -0
- package/dist/commands/manifest.d.ts +13 -1
- package/dist/commands/manifest.js +81 -18
- package/dist/commands/manifest.js.map +1 -1
- package/dist/commands/mcp.d.ts +25 -2
- package/dist/commands/mcp.js +120 -11
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/sandbox.d.ts +35 -6
- package/dist/commands/sandbox.js +208 -9
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/setup.d.ts +39 -0
- package/dist/commands/setup.js +203 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/tool.d.ts +154 -0
- package/dist/commands/tool.js +785 -0
- package/dist/commands/tool.js.map +1 -0
- package/dist/config.d.ts +30 -6
- package/dist/config.js +39 -8
- package/dist/config.js.map +1 -1
- package/dist/ctx.d.ts +5 -45
- package/dist/ctx.js +25 -160
- package/dist/ctx.js.map +1 -1
- package/dist/docs/index.json +1 -0
- package/dist/docs/pages/actions/call.md +300 -0
- package/dist/docs/pages/actions/catalog/airtable.md +737 -0
- package/dist/docs/pages/actions/catalog/arxiv.md +166 -0
- package/dist/docs/pages/actions/catalog/chainalysis-sanctions.md +125 -0
- package/dist/docs/pages/actions/catalog/coingecko.md +1558 -0
- package/dist/docs/pages/actions/catalog/deps-dev.md +465 -0
- package/dist/docs/pages/actions/catalog/dexscreener.md +568 -0
- package/dist/docs/pages/actions/catalog/discord.md +784 -0
- package/dist/docs/pages/actions/catalog/finnhub.md +776 -0
- package/dist/docs/pages/actions/catalog/frankfurter.md +438 -0
- package/dist/docs/pages/actions/catalog/github.md +1853 -0
- package/dist/docs/pages/actions/catalog/gmail.md +575 -0
- package/dist/docs/pages/actions/catalog/google-calendar.md +654 -0
- package/dist/docs/pages/actions/catalog/google-drive.md +502 -0
- package/dist/docs/pages/actions/catalog/google-sheets.md +700 -0
- package/dist/docs/pages/actions/catalog/hacker-news.md +542 -0
- package/dist/docs/pages/actions/catalog/http.md +824 -0
- package/dist/docs/pages/actions/catalog/hyperliquid.md +942 -0
- package/dist/docs/pages/actions/catalog/jira.md +920 -0
- package/dist/docs/pages/actions/catalog/kalshi.md +917 -0
- package/dist/docs/pages/actions/catalog/linear.md +1030 -0
- package/dist/docs/pages/actions/catalog/markets.md +21 -0
- package/dist/docs/pages/actions/catalog/morpho.md +247 -0
- package/dist/docs/pages/actions/catalog/notion.md +1077 -0
- package/dist/docs/pages/actions/catalog/nws.md +485 -0
- package/dist/docs/pages/actions/catalog/open-meteo.md +559 -0
- package/dist/docs/pages/actions/catalog/polymarket.md +1523 -0
- package/dist/docs/pages/actions/catalog/pushbullet.md +220 -0
- package/dist/docs/pages/actions/catalog/resend.md +307 -0
- package/dist/docs/pages/actions/catalog/s3.md +513 -0
- package/dist/docs/pages/actions/catalog/sec-edgar.md +487 -0
- package/dist/docs/pages/actions/catalog/slack.md +2629 -0
- package/dist/docs/pages/actions/catalog/stripe.md +1405 -0
- package/dist/docs/pages/actions/catalog/wikipedia.md +379 -0
- package/dist/docs/pages/actions/catalog.md +46 -0
- package/dist/docs/pages/actions/limits.md +50 -0
- package/dist/docs/pages/actions/model-tools.md +225 -0
- package/dist/docs/pages/actions/packs.md +148 -0
- package/dist/docs/pages/actions/settings.md +69 -0
- package/dist/docs/pages/actions/tools.md +244 -0
- package/dist/docs/pages/actions/triggers.md +149 -0
- package/dist/docs/pages/actions.md +88 -0
- package/dist/docs/pages/compat/anthropic.md +168 -0
- package/dist/docs/pages/compat/e2b.md +194 -0
- package/dist/docs/pages/compat/firecrawl.md +138 -0
- package/dist/docs/pages/compat/openai.md +168 -0
- package/dist/docs/pages/concepts/auth.md +151 -0
- package/dist/docs/pages/concepts/beta.md +55 -0
- package/dist/docs/pages/concepts/glossary.md +71 -0
- package/dist/docs/pages/concepts/ids.md +98 -0
- package/dist/docs/pages/concepts/jobs.md +229 -0
- package/dist/docs/pages/concepts/latency.md +138 -0
- package/dist/docs/pages/concepts/limits.md +191 -0
- package/dist/docs/pages/concepts/stack.md +59 -0
- package/dist/docs/pages/concepts/timing.md +86 -0
- package/dist/docs/pages/concepts/usage.md +110 -0
- package/dist/docs/pages/design/b3os-yaml.md +370 -0
- package/dist/docs/pages/design/deploy-from-github.md +122 -0
- package/dist/docs/pages/design/observability.md +134 -0
- package/dist/docs/pages/errors.md +1824 -0
- package/dist/docs/pages/infer/chat.md +570 -0
- package/dist/docs/pages/infer/limits.md +55 -0
- package/dist/docs/pages/infer/messages.md +185 -0
- package/dist/docs/pages/infer/responses.md +173 -0
- package/dist/docs/pages/infer/settings.md +154 -0
- package/dist/docs/pages/infer/speech.md +323 -0
- package/dist/docs/pages/infer.md +154 -0
- package/dist/docs/pages/introduction.md +162 -0
- package/dist/docs/pages/platform/addresses.md +174 -0
- package/dist/docs/pages/platform/call-log.md +99 -0
- package/dist/docs/pages/platform/custom-domains.md +104 -0
- package/dist/docs/pages/platform/keys.md +79 -0
- package/dist/docs/pages/platform/limits.md +57 -0
- package/dist/docs/pages/platform/members.md +101 -0
- package/dist/docs/pages/platform/requests.md +116 -0
- package/dist/docs/pages/platform/settings.md +129 -0
- package/dist/docs/pages/platform/webhooks.md +68 -0
- package/dist/docs/pages/platform.md +67 -0
- package/dist/docs/pages/quickstart/mcp.md +94 -0
- package/dist/docs/pages/quickstart/sandbox-agent.md +205 -0
- package/dist/docs/pages/quickstart/scrape.md +134 -0
- package/dist/docs/pages/quickstart.md +45 -0
- package/dist/docs/pages/render/inspections.md +162 -0
- package/dist/docs/pages/render/limits.md +72 -0
- package/dist/docs/pages/render/screenshots.md +179 -0
- package/dist/docs/pages/render/settings.md +431 -0
- package/dist/docs/pages/render/styles.md +342 -0
- package/dist/docs/pages/render/videos.md +272 -0
- package/dist/docs/pages/render.md +118 -0
- package/dist/docs/pages/routines/callables.md +174 -0
- package/dist/docs/pages/routines/definitions.md +361 -0
- package/dist/docs/pages/routines/limits.md +117 -0
- package/dist/docs/pages/routines/runs.md +328 -0
- package/dist/docs/pages/routines/settings.md +104 -0
- package/dist/docs/pages/routines/triggers.md +339 -0
- package/dist/docs/pages/routines.md +216 -0
- package/dist/docs/pages/sandboxes/agents.md +217 -0
- package/dist/docs/pages/sandboxes/commands.md +272 -0
- package/dist/docs/pages/sandboxes/images.md +166 -0
- package/dist/docs/pages/sandboxes/limits.md +143 -0
- package/dist/docs/pages/sandboxes/ports.md +260 -0
- package/dist/docs/pages/sandboxes/settings.md +358 -0
- package/dist/docs/pages/sandboxes/snapshots.md +423 -0
- package/dist/docs/pages/sandboxes/swarms.md +146 -0
- package/dist/docs/pages/sandboxes/volumes.md +131 -0
- package/dist/docs/pages/sandboxes.md +231 -0
- package/dist/docs/pages/sdks/cli.md +121 -0
- package/dist/docs/pages/sdks/mcp.md +169 -0
- package/dist/docs/pages/sdks/python.md +146 -0
- package/dist/docs/pages/sdks/typescript.md +202 -0
- package/dist/docs/pages/sdks.md +282 -0
- package/dist/docs/pages/settings.md +33 -0
- package/dist/docs/pages/vault/limits.md +46 -0
- package/dist/docs/pages/vault.md +133 -0
- package/dist/docs/pages/vision/agent-browser.md +115 -0
- package/dist/docs/pages/vision/crawl.md +333 -0
- package/dist/docs/pages/vision/extract.md +152 -0
- package/dist/docs/pages/vision/fetcher.md +15 -0
- package/dist/docs/pages/vision/limits.md +79 -0
- package/dist/docs/pages/vision/profiles.md +111 -0
- package/dist/docs/pages/vision/proxy.md +131 -0
- package/dist/docs/pages/vision/scrape.md +356 -0
- package/dist/docs/pages/vision/sessions.md +311 -0
- package/dist/docs/pages/vision/settings.md +656 -0
- package/dist/docs/pages/vision.md +175 -0
- package/dist/errors.d.ts +129 -0
- package/dist/errors.js +326 -0
- package/dist/errors.js.map +1 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.js +26 -13
- package/dist/main.js.map +1 -1
- package/dist/manifest/apply.d.ts +4 -0
- package/dist/manifest/apply.js +2 -0
- package/dist/manifest/apply.js.map +1 -1
- package/dist/manifest/domains.d.ts +50 -0
- package/dist/manifest/domains.js +159 -0
- package/dist/manifest/domains.js.map +1 -0
- package/dist/manifest/link.d.ts +20 -0
- package/dist/manifest/link.js +24 -0
- package/dist/manifest/link.js.map +1 -0
- package/dist/manifest/record.d.ts +1 -1
- package/dist/tool/archive.d.ts +33 -0
- package/dist/tool/archive.js +174 -0
- package/dist/tool/archive.js.map +1 -0
- package/dist/tool/calls.d.ts +46 -0
- package/dist/tool/calls.js +274 -0
- package/dist/tool/calls.js.map +1 -0
- package/dist/tool/checks.d.ts +21 -0
- package/dist/tool/checks.js +145 -0
- package/dist/tool/checks.js.map +1 -0
- package/dist/tool/elf.d.ts +19 -0
- package/dist/tool/elf.js +107 -0
- package/dist/tool/elf.js.map +1 -0
- package/dist/tool/predict.d.ts +8 -0
- package/dist/tool/predict.js +38 -0
- package/dist/tool/predict.js.map +1 -0
- package/dist/tool/ustar.d.ts +5 -0
- package/dist/tool/ustar.js +220 -0
- package/dist/tool/ustar.js.map +1 -0
- package/package.json +6 -5
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Install the MCP server
|
|
2
|
+
|
|
3
|
+
> Connect Claude, Cursor or Codex to the B3OS MCP server so your agent can scrape, run sandboxes and call marketplace actions.
|
|
4
|
+
|
|
5
|
+
Source: https://docs.beta.b3os.org/quickstart/mcp.md
|
|
6
|
+
|
|
7
|
+
You need a key in `B3OS_API_KEY` ([get one](https://docs.beta.b3os.org/quickstart#get-a-key)) and Node.js for `npx`.
|
|
8
|
+
|
|
9
|
+
**Register the server with your client**
|
|
10
|
+
|
|
11
|
+
The CLI writes the B3OS server into your client's MCP configuration:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx -y @b3os/cli@0.2 mcp install --client claude
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`--client` takes `claude`, `cursor` or `codex`. The entry starts the local server, `npx -y @b3os/mcp@0.2`, which reads `B3OS_API_KEY` from your environment (or the token from `b3os login`), so the client's configuration holds no secret. Restart the client afterwards.
|
|
18
|
+
|
|
19
|
+
**Ask for something that needs a tool**
|
|
20
|
+
|
|
21
|
+
Try a prompt that needs the web:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
Scrape https://example.com and tell me in one sentence what the page is for.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The client calls `vision_scrape`, gets the page as Markdown and answers from it. B3OS tool names start with the product they call, such as `vision_scrape`, `render_screenshot` and `sandbox_exec`; the [MCP server](https://docs.beta.b3os.org/sdks/mcp#tools) page lists them all.
|
|
28
|
+
|
|
29
|
+
**Reach a marketplace action**
|
|
30
|
+
|
|
31
|
+
Pack actions do not crowd the tool list. The agent finds them in three calls:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
Find a B3OS action that creates a GitHub issue and tell me which inputs it needs.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
It calls `actions_search` with your words, `actions_describe` for the input schema of the best match, and `actions_call` to run it once you store a GitHub connection in the [vault](https://docs.beta.b3os.org/vault).
|
|
38
|
+
|
|
39
|
+
## Configure it by hand
|
|
40
|
+
|
|
41
|
+
The remote server lives at `https://beta-api.b3os.org/mcp`: stateless Streamable HTTP, authenticated with your key as a bearer token. The local server runs on your machine over stdio. The two list slightly different tools in this beta; see [the tool table](https://docs.beta.b3os.org/sdks/mcp#tools).
|
|
42
|
+
|
|
43
|
+
Keep the key out of the configuration files: project files such as `.mcp.json` and `.cursor/mcp.json` are often committed. Each example below refers to the `B3OS_API_KEY` environment variable instead, so start the client with it set.
|
|
44
|
+
|
|
45
|
+
**Claude Code**
|
|
46
|
+
|
|
47
|
+
The single quotes keep your shell from expanding the variable, so Claude Code stores the reference and fills in the key when it connects:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
claude mcp add --transport http b3os https://beta-api.b3os.org/mcp \
|
|
51
|
+
--header 'Authorization: Bearer ${B3OS_API_KEY}'
|
|
52
|
+
```
|
|
53
|
+
**Cursor**
|
|
54
|
+
|
|
55
|
+
In `~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project. Cursor writes environment variables as `${env:NAME}`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"b3os": {
|
|
61
|
+
"type": "http",
|
|
62
|
+
"url": "https://beta-api.b3os.org/mcp",
|
|
63
|
+
"headers": { "Authorization": "Bearer ${env:B3OS_API_KEY}" }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
**Local stdio**
|
|
69
|
+
|
|
70
|
+
`@b3os/mcp` is the local stdio server, the one `b3os mcp install` sets up. It reads `B3OS_API_KEY` from the environment the client starts it with, or the token `b3os login` stored, so the entry needs no `env` block:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcpServers": {
|
|
75
|
+
"b3os": {
|
|
76
|
+
"command": "npx",
|
|
77
|
+
"args": ["-y", "@b3os/mcp@0.2"]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
A key with fewer scopes gives the agent fewer powers: tools whose operations need a scope the key lacks fail with [`forbidden`](https://docs.beta.b3os.org/errors#forbidden).
|
|
84
|
+
|
|
85
|
+
## A small tool list
|
|
86
|
+
|
|
87
|
+
Clients send every listed tool to the model on every turn, so B3OS lists each tool in its short form: its name and description, and its arguments' names, types, allowed values and required fields. An argument's full description comes back only when a call gets that argument wrong. For the 15 core tools the list is 11,604 bytes instead of 22,080, and B3OS's own model (`b3os/qwen3.5-9b`) read it as 3,151 tokens instead of 6,232, the median over 30 requests. It picked the right tool for 30 of 30 requests with the compact list and 29 of 30 with the full one. That is one run from our development host against production on 2026-11-03; the raw data and the command are in `bench/platform/results/20261103T0040Z-mcp-payload`.
|
|
88
|
+
|
|
89
|
+
To list only some tools, name them: `https://beta-api.b3os.org/mcp?tools=vision_scrape,render_screenshot`, or `--tools vision_scrape,render_screenshot` for the local server. `?detail=full` (locally `--detail full`) lists every schema in full. The local server takes both flags from `@b3os/mcp` 0.1.3. To add a toolset beside the core tools, name it: `?toolsets=routines` (locally `--toolsets routines`).
|
|
90
|
+
|
|
91
|
+
## Next
|
|
92
|
+
|
|
93
|
+
- [MCP server reference](https://docs.beta.b3os.org/sdks/mcp): the tools each server lists, exposing chosen packs directly, and running routines.
|
|
94
|
+
- [Run an agent in a sandbox](https://docs.beta.b3os.org/quickstart/sandbox-agent) to put the agent itself on the node.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Run an agent in a sandbox next to the model
|
|
2
|
+
|
|
3
|
+
> Start a sandbox on the node, give it a scoped grant, and run a small tool-calling agent whose calls to the model and to B3OS never leave the machine.
|
|
4
|
+
|
|
5
|
+
Source: https://docs.beta.b3os.org/quickstart/sandbox-agent.md
|
|
6
|
+
|
|
7
|
+
The agent runs in a microVM on the B3OS node, calls the model the node serves, and scrapes a page with B3OS vision, all through `http://127.0.0.1:7700` inside the sandbox. No key is stored in the sandbox. You need a key in `B3OS_API_KEY` ([get one](https://docs.beta.b3os.org/quickstart#get-a-key)), `curl` and `jq`.
|
|
8
|
+
|
|
9
|
+
**Create a sandbox with a grant**
|
|
10
|
+
|
|
11
|
+
The `agent` template has Python 3.12 and Node 24. The `api` grant decides what code in the sandbox may call; here it may list and call models and scrape pages:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
SBX=$(curl -s https://beta-api.b3os.org/v1/sandboxes \
|
|
15
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
16
|
+
-H "Content-Type: application/json" \
|
|
17
|
+
-d '{"template": "agent", "timeout_s": 600,
|
|
18
|
+
"api": {"scopes": ["infer:read", "infer:run", "vision:run"]}}' | jq -r .id)
|
|
19
|
+
echo $SBX
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The sandbox runs until `timeout_s` passes or you delete it.
|
|
23
|
+
|
|
24
|
+
**Write the agent**
|
|
25
|
+
|
|
26
|
+
Save this as `agent.py` on your machine. It uses only the Python standard library. Inside the sandbox `B3OS_API_URL` is `http://127.0.0.1:7700` and no key is needed: the node knows which sandbox is calling.
|
|
27
|
+
|
|
28
|
+
```python agent.py
|
|
29
|
+
import json, os, urllib.request
|
|
30
|
+
|
|
31
|
+
API = os.environ["B3OS_API_URL"]
|
|
32
|
+
|
|
33
|
+
def call(method, path, body=None):
|
|
34
|
+
data = None if body is None else json.dumps(body).encode()
|
|
35
|
+
req = urllib.request.Request(API + path, data=data, method=method,
|
|
36
|
+
headers={"Content-Type": "application/json"})
|
|
37
|
+
with urllib.request.urlopen(req, timeout=60) as resp:
|
|
38
|
+
return json.load(resp)
|
|
39
|
+
|
|
40
|
+
# Use the chat model this node serves.
|
|
41
|
+
models = call("GET", "/v1/infer/models")["data"]
|
|
42
|
+
model = next(m["id"] for m in models if m["b3os"]["kind"] == "chat")
|
|
43
|
+
|
|
44
|
+
tools = [{"type": "function", "function": {
|
|
45
|
+
"name": "scrape",
|
|
46
|
+
"description": "Fetch a web page and return it as Markdown.",
|
|
47
|
+
"parameters": {"type": "object", "properties": {"url": {"type": "string"}}, "required": ["url"]},
|
|
48
|
+
}}]
|
|
49
|
+
# The answer is on the page, so the model has to read it: the first turn must call the tool.
|
|
50
|
+
messages = [{"role": "user", "content": "Read https://example.com and quote its first sentence exactly."}]
|
|
51
|
+
|
|
52
|
+
for turn in range(4):
|
|
53
|
+
reply = call("POST", "/v1/infer/chat/completions",
|
|
54
|
+
{"model": model, "messages": messages, "tools": tools,
|
|
55
|
+
"tool_choice": "required" if turn == 0 else "auto"})
|
|
56
|
+
message = reply["choices"][0]["message"]
|
|
57
|
+
messages.append(message)
|
|
58
|
+
if not message.get("tool_calls"):
|
|
59
|
+
print(message["content"])
|
|
60
|
+
break
|
|
61
|
+
for tool_call in message["tool_calls"]:
|
|
62
|
+
url = json.loads(tool_call["function"]["arguments"])["url"]
|
|
63
|
+
page = call("POST", "/v1/vision/scrape", {"url": url, "formats": ["markdown"]})
|
|
64
|
+
print(f"scraped {url.rstrip('/')} in {page['timing']['total_ms']} ms ({page['tier']})")
|
|
65
|
+
messages.append({"role": "tool", "tool_call_id": tool_call["id"],
|
|
66
|
+
"content": page["markdown"][:8000]})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`tool_choice: "required"` on the first turn makes the model call `scrape` before it answers. Without it, a small model often answers from memory and never reads the page.
|
|
70
|
+
|
|
71
|
+
**Copy it into the sandbox**
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
curl -s -X PUT "https://beta-api.b3os.org/v1/sandboxes/$SBX/files?path=/workspace/agent.py&mkdir=1" \
|
|
75
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
76
|
+
-H "Content-Type: application/octet-stream" \
|
|
77
|
+
--data-binary @agent.py
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Run it and watch the output**
|
|
81
|
+
|
|
82
|
+
`?stream=true` sends stdout and stderr as server-sent events while the command runs:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
curl -N -s "https://beta-api.b3os.org/v1/sandboxes/$SBX/exec?stream=true" \
|
|
86
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
87
|
+
-H "Content-Type: application/json" \
|
|
88
|
+
-d '{"cmd": "python3 -u /workspace/agent.py", "timeout_ms": 300000}'
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
You see an `exec.stdout` event with the scrape line, one with the quoted sentence, then `exec.exit`:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
id: 1
|
|
95
|
+
event: exec.stdout
|
|
96
|
+
data: {"data":"scraped https://example.com in 0.245 ms (cache)\n",...}
|
|
97
|
+
|
|
98
|
+
id: 2
|
|
99
|
+
event: exec.stdout
|
|
100
|
+
data: {"data":"\"This domain is for use in documentation...\"\n",...}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
That is a recorded run against production on 2026-11-02, shortened: the quote is cut, and each `data` line also carries `job_id`, `seq`, `ts` and `type`. `(cache)` means vision answered from its cache; a page it has not seen takes as long as the site does to answer.
|
|
104
|
+
|
|
105
|
+
**See the calls the sandbox made**
|
|
106
|
+
|
|
107
|
+
The request log records calls from inside sandboxes with `connection: sandbox`:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
curl -s "https://beta-api.b3os.org/v1/requests?sandbox_id=$SBX" \
|
|
111
|
+
-H "Authorization: Bearer $B3OS_API_KEY" | jq '.data[] | {path, duration_ms, connection}'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The model calls and the scrape reached the node over vsock, with no network hop. The scrape's own fetch of example.com still crosses the internet to that site.
|
|
115
|
+
|
|
116
|
+
**Clean up**
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
curl -s -X DELETE "https://beta-api.b3os.org/v1/sandboxes/$SBX" \
|
|
120
|
+
-H "Authorization: Bearer $B3OS_API_KEY" | jq '{status, usage}'
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Deleting returns the stopped sandbox with its final usage.
|
|
124
|
+
|
|
125
|
+
## The same loop from code
|
|
126
|
+
|
|
127
|
+
Each tab creates the sandbox, copies `agent.py` in, runs it and deletes the sandbox, also when the run fails. They use `agent.py` from the step above.
|
|
128
|
+
|
|
129
|
+
**curl**
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
SBX=$(curl -s https://beta-api.b3os.org/v1/sandboxes -H "Authorization: Bearer $B3OS_API_KEY" \
|
|
133
|
+
-H "Content-Type: application/json" \
|
|
134
|
+
-d '{"template": "agent", "timeout_s": 600, "api": {"scopes": ["infer:read", "infer:run", "vision:run"]}}' | jq -r .id)
|
|
135
|
+
trap 'curl -s -X DELETE "https://beta-api.b3os.org/v1/sandboxes/$SBX" -H "Authorization: Bearer $B3OS_API_KEY" | jq -c .usage' EXIT
|
|
136
|
+
curl -s -X PUT "https://beta-api.b3os.org/v1/sandboxes/$SBX/files?path=/workspace/agent.py&mkdir=1" \
|
|
137
|
+
-H "Authorization: Bearer $B3OS_API_KEY" -H "Content-Type: application/octet-stream" --data-binary @agent.py > /dev/null
|
|
138
|
+
curl -s "https://beta-api.b3os.org/v1/sandboxes/$SBX/exec" -H "Authorization: Bearer $B3OS_API_KEY" \
|
|
139
|
+
-H "Content-Type: application/json" -d '{"cmd": "python3 -u /workspace/agent.py", "timeout_ms": 60000}' | jq -r .stdout
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**TypeScript**
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { readFileSync } from "node:fs";
|
|
146
|
+
import { B3OS } from "@b3os/sdk";
|
|
147
|
+
|
|
148
|
+
const b3os = new B3OS();
|
|
149
|
+
const sandbox = await b3os.sandboxes.createSandbox({
|
|
150
|
+
template: "agent",
|
|
151
|
+
timeout_s: 600,
|
|
152
|
+
api: { scopes: ["infer:read", "infer:run", "vision:run"] },
|
|
153
|
+
});
|
|
154
|
+
try {
|
|
155
|
+
await b3os.sandboxes.writeFile(sandbox.id, { path: "/workspace/agent.py", mkdir: 1 }, readFileSync("agent.py"));
|
|
156
|
+
const run = await b3os.sandboxes.exec(sandbox.id, { cmd: "python3 -u /workspace/agent.py", timeout_ms: 60000 });
|
|
157
|
+
console.log(run.stdout);
|
|
158
|
+
} finally {
|
|
159
|
+
const stopped = await b3os.sandboxes.deleteSandbox(sandbox.id);
|
|
160
|
+
console.log(stopped.usage);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Python**
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
from pathlib import Path
|
|
168
|
+
from b3os import B3OS
|
|
169
|
+
|
|
170
|
+
b3os = B3OS()
|
|
171
|
+
sandbox = b3os.sandboxes.create_sandbox({
|
|
172
|
+
"template": "agent",
|
|
173
|
+
"timeout_s": 600,
|
|
174
|
+
"api": {"scopes": ["infer:read", "infer:run", "vision:run"]},
|
|
175
|
+
})
|
|
176
|
+
try:
|
|
177
|
+
b3os.sandboxes.write_file(sandbox["id"], Path("agent.py").read_bytes(), path="/workspace/agent.py", mkdir=1)
|
|
178
|
+
run = b3os.sandboxes.exec(sandbox["id"], {"cmd": "python3 -u /workspace/agent.py", "timeout_ms": 60000})
|
|
179
|
+
print(run["stdout"])
|
|
180
|
+
finally:
|
|
181
|
+
print(b3os.sandboxes.delete_sandbox(sandbox["id"])["usage"])
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**CLI**
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
SBX=$(npx -y @b3os/cli@0.2 sandbox create --template agent --timeout-s 600 --api-scope infer:read,infer:run,vision:run)
|
|
188
|
+
npx -y @b3os/cli@0.2 sandbox exec "$SBX" --stdin -- sh -c 'mkdir -p /workspace && cat > /workspace/agent.py' < agent.py
|
|
189
|
+
npx -y @b3os/cli@0.2 sandbox exec "$SBX" -- python3 -u /workspace/agent.py
|
|
190
|
+
npx -y @b3os/cli@0.2 sandbox rm "$SBX" --yes
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Check:
|
|
194
|
+
Verified 2026-11-03: the 4 runnable snippets on this page passed against `https://beta-api.b3os.org`, label `live-recorded` (recorded from production). Slowest time to first result: 2.35 s.
|
|
195
|
+
|
|
196
|
+
## What the grant allowed
|
|
197
|
+
|
|
198
|
+
The sandbox had `infer:read`, `infer:run` and `vision:run` and nothing else. A call to any other product from inside it fails with [`forbidden`](https://docs.beta.b3os.org/errors#forbidden). Scopes in a grant must be a subset of your key's, and `sandboxes:write`, the vault scopes and the platform scopes are granted only when named exactly. [Agents in sandboxes](https://docs.beta.b3os.org/sandboxes/agents) covers grants, spend caps and vault connections.
|
|
199
|
+
|
|
200
|
+
## Next
|
|
201
|
+
|
|
202
|
+
- [Fork a sandbox](https://docs.beta.b3os.org/sandboxes/snapshots#fork): run several attempts from one warm state, each in its own microVM.
|
|
203
|
+
- [Same-host latency](https://docs.beta.b3os.org/concepts/latency): what staying on the node saves per call.
|
|
204
|
+
- [Sandboxes](https://docs.beta.b3os.org/sandboxes): templates, snapshots, ports and terminals.
|
|
205
|
+
- [Infer](https://docs.beta.b3os.org/infer): the models on the node and the OpenAI-compatible API.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Scrape a page with curl
|
|
2
|
+
|
|
3
|
+
> Turn a URL into clean Markdown with one request to B3OS vision, then read the Server-Timing header to see where the time went.
|
|
4
|
+
|
|
5
|
+
Source: https://docs.beta.b3os.org/quickstart/scrape.md
|
|
6
|
+
|
|
7
|
+
You need a key in `B3OS_API_KEY` ([get one](https://docs.beta.b3os.org/quickstart#get-a-key)) and `curl`.
|
|
8
|
+
|
|
9
|
+
**Scrape a page**
|
|
10
|
+
|
|
11
|
+
Send a URL and the formats you want back:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
curl -s https://beta-api.b3os.org/v1/vision/scrape \
|
|
15
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
16
|
+
-H "Content-Type: application/json" \
|
|
17
|
+
-d '{"url": "https://example.com", "formats": ["markdown", "links"]}'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Read the response**
|
|
21
|
+
|
|
22
|
+
The page comes back as Markdown, with what served it and how long each phase took. This is the response to the request above, as recorded:
|
|
23
|
+
|
|
24
|
+
**Response 200**
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"object": "scrape",
|
|
29
|
+
"url": "https://example.com/",
|
|
30
|
+
"final_url": "https://example.com/",
|
|
31
|
+
"status_code": 200,
|
|
32
|
+
"content_type": "text/html",
|
|
33
|
+
"tier": "cache",
|
|
34
|
+
"cache": {
|
|
35
|
+
"state": "hit",
|
|
36
|
+
"age_s": 85369
|
|
37
|
+
},
|
|
38
|
+
"markdown": "This domain is for use in documentation examples…",
|
|
39
|
+
"links": [
|
|
40
|
+
"https://iana.org/help/example-domains"
|
|
41
|
+
],
|
|
42
|
+
"metadata": {
|
|
43
|
+
"title": "Example Domain",
|
|
44
|
+
"language": "en"
|
|
45
|
+
},
|
|
46
|
+
"page_state": {
|
|
47
|
+
"state": "ok"
|
|
48
|
+
},
|
|
49
|
+
"warnings": [],
|
|
50
|
+
"timing": {
|
|
51
|
+
"admit_ms": 0.044,
|
|
52
|
+
"cache_ms": 0.002,
|
|
53
|
+
"extract_ms": 0.001,
|
|
54
|
+
"total_ms": 0.117
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Request**
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
curl -s -X POST 'https://beta-api.b3os.org/v1/vision/scrape' \
|
|
63
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
64
|
+
-H 'Content-Type: application/json' \
|
|
65
|
+
-d '{"url":"https://example.com","formats":["markdown","links"]}'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Server-Timing**
|
|
69
|
+
|
|
70
|
+
```http
|
|
71
|
+
server-timing: edge_auth;dur=0.000, edge_upstream;dur=9.000, admit;dur=0.044, cache;dur=0.002, extract;dur=0.001, total;dur=0.131
|
|
72
|
+
x-request-id: req_01m6y0b9h3mm58b3pzd9sfgvy1
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
<sub>Captured 2026-11-08 from commit `48c174d9` on the host the node runs on (colo PDX), warm: median of 5 calls after 3 warm-up calls, label `live-recorded` (recorded from production); long values abridged. Case `vision/quickstart-scrape`.</sub>
|
|
76
|
+
|
|
77
|
+
`markdown` is the page's main content, without headers, navigation and footers; the title is in `metadata.title`. `status_code` is the site's own status, so a 404 page is still a successful scrape. [`page_state`](https://docs.beta.b3os.org/vision/scrape#page-state) says what came back: `ok` for the page itself, or `blocked`, `captcha` or `login` when the site sent something else. `tier` says what served it: `cache`, `fetch` (plain HTTP) or `browser` (a warm Chrome, for pages that need JavaScript). `cache.state` is `hit`, `miss` or `bypass`, and a scrape of the same URL within two days can come from the cache. `timing` holds each server-side phase in milliseconds.
|
|
78
|
+
|
|
79
|
+
**See where the time went**
|
|
80
|
+
|
|
81
|
+
Every response carries a `Server-Timing` header and an `x-request-id`. Print the headers instead of the body:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
curl -s -o /dev/null -D - https://beta-api.b3os.org/v1/vision/scrape \
|
|
85
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
86
|
+
-H "Content-Type: application/json" \
|
|
87
|
+
-d '{"url": "https://example.com"}' | grep -i -E 'server-timing|x-request-id'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The edge's entries come first: `edge_auth`, whose `desc` names the steps it waited on (`key`, `limits` and `permit`, each with where it came from), then `edge_upstream`, then `edge_colo`, the Cloudflare location that took the request. The node's phases follow: `admit`, then `cache` when this second scrape is served from the cache (`fetch_ttfb`, `fetch` and `analyze` when it is not), then `extract` and `total`. Copy the `x-request-id` value and ask the request log for the full record:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
export REQUEST_ID="req_..." # the x-request-id value from the headers
|
|
94
|
+
curl -s "https://beta-api.b3os.org/v1/requests/$REQUEST_ID" \
|
|
95
|
+
-H "Authorization: Bearer $B3OS_API_KEY"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
[Timing](https://docs.beta.b3os.org/concepts/timing) explains each phase.
|
|
99
|
+
|
|
100
|
+
**Read a URL in one line**
|
|
101
|
+
|
|
102
|
+
Put the target URL after `/v1/vision/r/` and the page comes back as Markdown:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
curl -s https://beta-api.b3os.org/v1/vision/r/https://example.com \
|
|
106
|
+
-H "Authorization: Bearer $B3OS_API_KEY"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Options go in headers so the URL stays untouched: `X-B3OS-Format` picks `html`, `text` or `json` instead, and `X-B3OS-Engine: browser` forces a browser.
|
|
110
|
+
|
|
111
|
+
The same scrape from the dashboard's playground. The answer and timing replay a production call made Nov 8 from the host the node runs on, through Cloudflare's PDX data center. It is the median of 5 calls on a warm connection.
|
|
112
|
+
|
|
113
|
+
[Open the video](https://beta.b3os.org/gallery/docs-site/demo-scrape/b521945ce3344da0.mp4) · [Transcript (WebVTT)](https://beta.b3os.org/gallery/docs-site/demo-scrape/ebe2d190f89b298a.vtt)
|
|
114
|
+
|
|
115
|
+
<details>
|
|
116
|
+
<summary>Transcript</summary>
|
|
117
|
+
|
|
118
|
+
`0:00` Pick the formats you want and press Scrape.
|
|
119
|
+
|
|
120
|
+
`0:03` The waterfall shows where the time went.
|
|
121
|
+
|
|
122
|
+
`0:07` The Markdown comes back with what served it.
|
|
123
|
+
|
|
124
|
+
`0:10` Copy the same call as curl, TypeScript or Python.
|
|
125
|
+
|
|
126
|
+
</details>
|
|
127
|
+
|
|
128
|
+
<sub>Captured 2026-11-15 from commit `2aac696d` on a GitHub Actions runner (colo MSP), one call, label `mock` (the dashboard in mock mode). Case `docs-site/demo-scrape`.</sub>
|
|
129
|
+
|
|
130
|
+
## Next
|
|
131
|
+
|
|
132
|
+
- [Scrape guide](https://docs.beta.b3os.org/vision/scrape): formats, main-content extraction, browser actions, profiles, caching.
|
|
133
|
+
- [Crawl and batch](https://docs.beta.b3os.org/vision/crawl) for many pages at once.
|
|
134
|
+
- [Firecrawl compatibility](https://docs.beta.b3os.org/compat/firecrawl) if you already use a Firecrawl SDK: change the base URL and key.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Quickstart
|
|
2
|
+
|
|
3
|
+
> Get a B3OS beta key, then scrape a page with curl, connect the MCP server, or run an agent in a sandbox next to the model.
|
|
4
|
+
|
|
5
|
+
Source: https://docs.beta.b3os.org/quickstart.md
|
|
6
|
+
|
|
7
|
+
Start with one command. It adds the B3OS MCP server to Claude Code, Cursor and Codex, signs you in through your browser when `B3OS_API_KEY` is not set, and makes a first call:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx -y @b3os/cli@0.2 init
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then ask your agent for something that needs the web, such as "Scrape https://example.com and tell me what the page is for". The sign-in works for the CLI, the local MCP server and the SDKs; curl needs a key. B3OS beta is invite-only, so a new account needs its invite code.
|
|
14
|
+
|
|
15
|
+
Or get a key and pick one of three paths below. The goal for each is a first result within a minute of having a key.
|
|
16
|
+
|
|
17
|
+
## Get a key
|
|
18
|
+
|
|
19
|
+
B3OS beta is invite-only. Redeem your invite code in the [dashboard](https://beta.b3os.org/app); it creates your organization, a project and a first API key. The key is shown once, with an export line to copy:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
export B3OS_API_KEY="b3os_sk_..."
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Keys start with `b3os_sk_`. The first key gets the default scopes: read, write and run for vision, render, sandboxes, routines, actions and infer, plus `vault:read`, `vault:run` and `platform:read`. [Keys, scopes and principals](https://docs.beta.b3os.org/concepts/auth) covers the rest.
|
|
26
|
+
|
|
27
|
+
Give each agent its own key with only the scopes it uses and an expiry. A leaked key then can do little, and you revoke it without touching anything else. Create it in the dashboard; [API keys](https://docs.beta.b3os.org/platform/keys) lists the scopes, spend cap and expiry a key takes.
|
|
28
|
+
|
|
29
|
+
Check the key works:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
curl -s https://beta-api.b3os.org/v1/keys/current \
|
|
33
|
+
-H "Authorization: Bearer $B3OS_API_KEY"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The response names your organization, project and scopes.
|
|
37
|
+
|
|
38
|
+
## Pick a path
|
|
39
|
+
|
|
40
|
+
- [Scrape with curl](https://docs.beta.b3os.org/quickstart/scrape)
|
|
41
|
+
Turn a URL into Markdown and read where the milliseconds went.
|
|
42
|
+
- [Install the MCP server](https://docs.beta.b3os.org/quickstart/mcp)
|
|
43
|
+
Give Claude, Cursor or Codex the B3OS tools.
|
|
44
|
+
- [Run an agent in a sandbox](https://docs.beta.b3os.org/quickstart/sandbox-agent)
|
|
45
|
+
The model, the tools and the agent on one machine.
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Inspections
|
|
2
|
+
|
|
3
|
+
> Record a short window of a page or a video frame by frame and get back what moved, flashed or changed, as plain lines, JSON and one contact sheet.
|
|
4
|
+
|
|
5
|
+
Source: https://docs.beta.b3os.org/render/inspections.md
|
|
6
|
+
|
|
7
|
+
`POST /v1/render/inspections` loads a page, runs the browser steps you give it, and records every frame of a short window on the page's own clock. It answers in one call with what changed from one frame to the next: layout shifts in pixels, flashes, cuts, changed regions and the boxes of elements you name. You get up to eight summary lines, the same events as JSON, and one contact-sheet image to look at. It can also read the same window from a video you already made.
|
|
8
|
+
|
|
9
|
+
Use it after you change a page, to check that a click does not make the layout jump, that a loading state does not flash, or that a skeleton gives way to content where you expect it.
|
|
10
|
+
|
|
11
|
+
Note:
|
|
12
|
+
The SDK methods on this page (`b3os.render.createInspection`, `create_inspection`) and the MCP tool `render_inspect` come with SDK and MCP server 0.2.2, the **next** release. Until then, call the HTTP API as the curl example does.
|
|
13
|
+
|
|
14
|
+
## Inspect a click
|
|
15
|
+
|
|
16
|
+
The demo routine's run page in the dashboard opens its graph when you click the Graph tab. This request clicks it and watches the block below the tabs:
|
|
17
|
+
|
|
18
|
+
**curl**
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
curl -s https://beta-api.b3os.org/v1/render/inspections \
|
|
22
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
23
|
+
-H "Content-Type: application/json" \
|
|
24
|
+
-d '{"url": "https://beta.b3os.org/app/routines/runs/run_01m5tq71pwahtw91gjjx0ms4kg?mock=1&capture=1",
|
|
25
|
+
"viewport": {"width": 1440, "height": 1200},
|
|
26
|
+
"steps": [{"kind": "click", "target": {"role": "tab", "name": "Graph"}}],
|
|
27
|
+
"watch": [{"selector": "section:has([aria-label=\"Steps view\"]) + div"}],
|
|
28
|
+
"duration_ms": 2000}'
|
|
29
|
+
```
|
|
30
|
+
**TypeScript**
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { B3OS } from "@b3os/sdk";
|
|
34
|
+
|
|
35
|
+
const b3os = new B3OS();
|
|
36
|
+
const ins = await b3os.render.createInspection({
|
|
37
|
+
url: "https://beta.b3os.org/app/routines/runs/run_01m5tq71pwahtw91gjjx0ms4kg?mock=1&capture=1",
|
|
38
|
+
viewport: { width: 1440, height: 1200 },
|
|
39
|
+
steps: [{ kind: "click", target: { role: "tab", name: "Graph" } }],
|
|
40
|
+
watch: [{ selector: "section:has([aria-label='Steps view']) + div" }],
|
|
41
|
+
duration_ms: 2000,
|
|
42
|
+
});
|
|
43
|
+
console.log(ins.summary.join("\n"));
|
|
44
|
+
console.log(ins.sheet.artifact.url, `${ins.sheet.tokens} tokens`);
|
|
45
|
+
```
|
|
46
|
+
**Python**
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from b3os import B3OS
|
|
50
|
+
|
|
51
|
+
b3os = B3OS()
|
|
52
|
+
ins = b3os.render.create_inspection({
|
|
53
|
+
"url": "https://beta.b3os.org/app/routines/runs/run_01m5tq71pwahtw91gjjx0ms4kg?mock=1&capture=1",
|
|
54
|
+
"viewport": {"width": 1440, "height": 1200},
|
|
55
|
+
"steps": [{"kind": "click", "target": {"role": "tab", "name": "Graph"}}],
|
|
56
|
+
"watch": [{"selector": "section:has([aria-label='Steps view']) + div"}],
|
|
57
|
+
"duration_ms": 2000,
|
|
58
|
+
})
|
|
59
|
+
print("\n".join(ins["summary"]))
|
|
60
|
+
print(ins["sheet"]["artifact"]["url"], ins["sheet"]["tokens"], "tokens")
|
|
61
|
+
```
|
|
62
|
+
**MCP**
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
Click the Graph tab on https://beta.b3os.org/app/routines/runs/run_01m5tq71pwahtw91gjjx0ms4kg?mock=1&capture=1 at 1440x1200 and tell me whether anything below the tabs jumps.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
With the MCP server's `render` toolset on (`--toolsets render`, or `/mcp?toolsets=render`), the agent calls `render_inspect` with the same fields as the API body. It gets the summary lines, the sheet's link and token cost, and the whole answer as structured content; the local MCP server also returns the sheet as an image.
|
|
69
|
+
|
|
70
|
+
The answer's `summary` says what happened in order, one event a line, in the same words as `report`. This request, run on production on 2026-11-16, answered:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
0.300 s content below y 836 moved up 28 px (layout)
|
|
74
|
+
0.300 s R2 x 272 y 704 528x480 changed in 1 frame, settled at 0.333 s
|
|
75
|
+
0.300 s steps/0 click Graph
|
|
76
|
+
0.667 s R1 x 288 y 576 1056x160 flashed darker for 33 ms
|
|
77
|
+
0.667 s content below y 764 moved down 88 px (layout) "Step page Succeeded vision/scrape@1 Repl"
|
|
78
|
+
0.667-0.700 s x 288 y 560 1056x208 changed in 2 frames, settled at 0.733 s
|
|
79
|
+
watch 1 (section:has(...) + div): y 831.5 -> 803.5 at 0.300 s, -> 891.5 at 0.667 s
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The click swaps the timeline for the graph, which shows as one flash. The block below the tabs moves twice: up 28 px when the timeline goes and down 88 px when the graph draws. The browser named the element that moved on the second shift's frame, so that line ends with the block's text. Shifts are read from the frames, and the frames hold only the viewport: at 1440x746 the block starts at y 831.5, below the bottom of the viewport, and the same click answers with no shift line. Give `viewport` a height that holds what you watch.
|
|
83
|
+
|
|
84
|
+
## What the answer holds
|
|
85
|
+
|
|
86
|
+
| Field | What it is |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `summary` | Up to eight lines in time order: steps, shifts, changed regions, flashes, cuts, stalls and watched boxes. When the browser named the element that moved on a shift's frame (`layout_shifts`), that shift's line ends with the element's text in quotes. A window where nothing changed has the one line `no change` |
|
|
89
|
+
| `report.changed` | `[frame, share]` for every frame where part of the picture changed against the frame before |
|
|
90
|
+
| `report.events` | Runs of changed frames: when they start and settle, the largest share changed, the step they follow, and the changed regions as boxes |
|
|
91
|
+
| `report.shifts` | Content that moved up or down: `dy` in pixels (positive is down), the row the moved content starts at (`from_y`), and `kind`: `scroll` when the page's scroll offset moved by the same amount, else `layout` |
|
|
92
|
+
| `report.flashes` | A region that changed and came back to how it was, with how long it showed and whether it was lighter or darker |
|
|
93
|
+
| `report.cuts` | Frames where most of the picture was replaced at once |
|
|
94
|
+
| `report.stalls` | Frames inside a scroll where the page did not move |
|
|
95
|
+
| `report.network` | How long the page's clock waited on requests, which never counts as page time |
|
|
96
|
+
| `trace` | For each `watch` target, its box `[t_ms, x, y, w, h, visible]` on the first frame and whenever it changed, and each move |
|
|
97
|
+
| `layout_shifts` | The browser's own layout-shift entries, each naming the elements that moved by a CSS selector and their text. Left out when the browser reported none |
|
|
98
|
+
| `sheet` | The contact sheet: its artifact with a signed URL, its size, its token cost and where each tile and crop sits on it |
|
|
99
|
+
| `timing` | The phases of the call (`queue`, `claim`, `navigate`, `settle`, `capture`, `analyze`, `sheet`, `persist`, `total`), also sent as `Server-Timing` |
|
|
100
|
+
|
|
101
|
+
Positions are CSS pixels of the viewport for a page, and pixels of the video for a video (`window.units`). Times are on the page's clock from the start of the window, or the video's own time.
|
|
102
|
+
|
|
103
|
+
## The contact sheet
|
|
104
|
+
|
|
105
|
+
The sheet is one WebP, at most 1568 pixels wide and 1176 high. It holds up to twelve tiles of the window in reading order. A black strip above each tile gives its time and frame first, then the share of the picture that changed since the frame before, then word tags such as `CLICK steps/0`, `SHIFT -29`, `FLASH` and `CUT`. Changed regions are outlined in magenta; nothing else is drawn over the page. Below the tiles, the two main regions, `R1` and `R2`, are cropped before and after their change, each labeled with its scale.
|
|
106
|
+
|
|
107
|
+
Tiles go to the first and last frames, then to flashes, cuts, shifts, the start and end of each change and each step, then to where most pixels changed. A window where nothing changed gets two tiles. `interval_ms` puts the tiles at a fixed interval instead.
|
|
108
|
+
|
|
109
|
+
`sheet.tokens` is the sheet's image cost for a vision model that reads an image in 28-pixel patches: the width and the height in patches, each rounded up, multiplied together. It is at most 2352. A model that scales large images down first reads fewer.
|
|
110
|
+
|
|
111
|
+
The sheet is kept for 24 hours. The inspection itself is not stored: there is no list or get for it, so keep the answer if you need it later.
|
|
112
|
+
|
|
113
|
+
## Inspect a video
|
|
114
|
+
|
|
115
|
+
Give `video_id` instead of `url` to read a window of a video this project made, from `from_ms` for `duration_ms`. The video must have succeeded. Shifts and flashes are not reported while the video's camera moves, cuts the camera planned are reported as `camera_cut`, and the caption rows are left out of the analysis (`report.masked`). `steps`, `watch`, `viewport` and `theme` are for pages only.
|
|
116
|
+
|
|
117
|
+
## Options
|
|
118
|
+
|
|
119
|
+
| Field | Default | Meaning |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `url` or `video_id` | | The page to load, or a succeeded video of this project |
|
|
122
|
+
| `steps` | none | Up to 20 browser steps, the same kinds as a video's (see [videos](https://docs.beta.b3os.org/render/videos)). The first starts at 300 ms on the page's clock and each next one when the one before ends |
|
|
123
|
+
| `watch` | none | Up to 8 elements to follow on every frame, each `{selector}` or `{text, exact, nth}`. Role and name targets are not accepted here |
|
|
124
|
+
| `duration_ms` | 3000, or the rest of the video | The window, from 500 ms to 10000 ms. It must end at least 200 ms after the last step ends. A video's default is the rest of it, at most 10000 ms and 300 frames; when that cuts it, the answer has a `window_cut` warning |
|
|
125
|
+
| `from_ms` | 0 | Where the window starts in a video |
|
|
126
|
+
| `fps` | 30, or the video's own rate | 10, 15, 30 or 60 frames a second, at most 300 frames in the window |
|
|
127
|
+
| `viewport` | 1280x800 | 320 to 1920 wide, 320 to 1200 high, in CSS pixels |
|
|
128
|
+
| `theme` | `auto` | Emulate a light or dark color scheme; `auto` leaves the page's default |
|
|
129
|
+
| `interval_ms` | where pixels change | Tiles at a fixed interval, for at most twelve tiles in the window |
|
|
130
|
+
|
|
131
|
+
The page is captured at device scale 1. Unlike a video's capture, banners are left in place, lazy content is not loaded ahead, and client-side routes are not run ahead of the clock, so loading states show as they happen.
|
|
132
|
+
|
|
133
|
+
The window starts once the page has loaded: after its `load` event, its images, a short network quiet and 1 s of page time. How the page first loaded is not in the window. To see a change, make it with `steps`, such as a click or a `navigate`, and the window records what follows.
|
|
134
|
+
|
|
135
|
+
## How changes are detected
|
|
136
|
+
|
|
137
|
+
- A pixel changed when its brightness moved by more than 24 levels against the frame before, read on a 2-pixel grid. A frame with no repaint changed nothing.
|
|
138
|
+
- A frame counts as changed when at least 0.1% of the picture changed. Changed frames close together form one event, and its regions are 16-pixel cells joined into boxes.
|
|
139
|
+
- A flash is a region of at least 0.5% of the picture that changed and came back within 100 ms.
|
|
140
|
+
- A cut is a frame where at least 40% of the picture was replaced while the frames on either side changed by at most 5%.
|
|
141
|
+
- A shift is reported when content moved more than 2 pixels; it is `large` from 8 pixels.
|
|
142
|
+
- The page's clock holds while code, data, style and font requests are in flight, so a network wait never shows as page time; `report.network` says how long it held. Web workers and other work on the wall clock run in real time against the page's clock.
|
|
143
|
+
|
|
144
|
+
## Billing and scopes
|
|
145
|
+
|
|
146
|
+
An inspection bills `render.inspection_s`, one per second of window rounded up, once the sheet is saved. An inspection that fails bills nothing. It needs `render:run`. The beta is free within its limits; see [pricing](https://docs.beta.b3os.org/concepts/usage#pricing). At most two inspections run at once per organization; see [render limits](https://docs.beta.b3os.org/render/limits).
|
|
147
|
+
|
|
148
|
+
## Errors
|
|
149
|
+
|
|
150
|
+
| Code | Status | What to do |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| [`invalid_request`](https://docs.beta.b3os.org/errors#invalid_request) | 400 | Give one of `url` or `video_id`; keep the window within its frame limit and after the last step |
|
|
153
|
+
| [`egress_denied`](https://docs.beta.b3os.org/errors#egress_denied) | 403 | The egress guard refused the page's URL or a `navigate` step's, such as a private address |
|
|
154
|
+
| [`video_not_found`](https://docs.beta.b3os.org/errors#video_not_found) | 404 | Check the `vid_` ID and the project |
|
|
155
|
+
| [`video_not_ready`](https://docs.beta.b3os.org/errors#video_not_ready) | 409 | Inspect the video once it has succeeded |
|
|
156
|
+
| [`script_invalid`](https://docs.beta.b3os.org/errors#script_invalid) | 422 | Fix the step `errors[]` points at |
|
|
157
|
+
| [`script_step_failed`](https://docs.beta.b3os.org/errors#script_step_failed) | 422 | A step failed while it ran, such as a target that never appeared; `step` names it. There is no partial answer |
|
|
158
|
+
| [`concurrency_limited`](https://docs.beta.b3os.org/errors#concurrency_limited) | 429 | Wait for one of your inspections to finish |
|
|
159
|
+
| [`capture_failed`](https://docs.beta.b3os.org/errors#capture_failed) | 502 | The page could not be loaded; `reason` has the browser's error |
|
|
160
|
+
| [`capacity_unavailable`](https://docs.beta.b3os.org/errors#capacity_unavailable) | 503 | The node's inspections stayed busy for 5 s, no browser was free, or the recorder had no room for another page; retry after `Retry-After` |
|
|
161
|
+
| [`product_unavailable`](https://docs.beta.b3os.org/errors#product_unavailable) | 503 | This node cannot inspect pages yet (its recorder is older, or its browsers run without the sandbox); retry after `Retry-After` |
|
|
162
|
+
| [`job_timed_out`](https://docs.beta.b3os.org/errors#job_timed_out) | 504 | The page's load, a step's wait or the capture ran past what the call has time for, about a minute in all; retry, or shorten the steps' `timeout_ms` |
|