@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.
Files changed (217) hide show
  1. package/README.md +87 -7
  2. package/assets/b3os-run.py +137 -0
  3. package/assets/skill/b3os/SKILL.md +111 -0
  4. package/dist/commands/_agents.d.ts +14 -0
  5. package/dist/commands/_agents.js +33 -0
  6. package/dist/commands/_agents.js.map +1 -0
  7. package/dist/commands/_common.js +6 -2
  8. package/dist/commands/_common.js.map +1 -1
  9. package/dist/commands/_context.d.ts +49 -0
  10. package/dist/commands/_context.js +260 -0
  11. package/dist/commands/_context.js.map +1 -0
  12. package/dist/commands/_next.d.ts +39 -0
  13. package/dist/commands/_next.js +77 -0
  14. package/dist/commands/_next.js.map +1 -0
  15. package/dist/commands/agent.d.ts +42 -0
  16. package/dist/commands/agent.js +218 -0
  17. package/dist/commands/agent.js.map +1 -0
  18. package/dist/commands/app.d.ts +2 -0
  19. package/dist/commands/app.js +559 -54
  20. package/dist/commands/app.js.map +1 -1
  21. package/dist/commands/auth.d.ts +88 -2
  22. package/dist/commands/auth.js +354 -44
  23. package/dist/commands/auth.js.map +1 -1
  24. package/dist/commands/docs.d.ts +54 -0
  25. package/dist/commands/docs.js +202 -0
  26. package/dist/commands/docs.js.map +1 -0
  27. package/dist/commands/doctor.d.ts +23 -0
  28. package/dist/commands/doctor.js +313 -0
  29. package/dist/commands/doctor.js.map +1 -0
  30. package/dist/commands/init.d.ts +38 -1
  31. package/dist/commands/init.js +259 -60
  32. package/dist/commands/init.js.map +1 -1
  33. package/dist/commands/listen.d.ts +30 -0
  34. package/dist/commands/listen.js +194 -0
  35. package/dist/commands/listen.js.map +1 -0
  36. package/dist/commands/manifest.d.ts +13 -1
  37. package/dist/commands/manifest.js +81 -18
  38. package/dist/commands/manifest.js.map +1 -1
  39. package/dist/commands/mcp.d.ts +25 -2
  40. package/dist/commands/mcp.js +120 -11
  41. package/dist/commands/mcp.js.map +1 -1
  42. package/dist/commands/sandbox.d.ts +35 -6
  43. package/dist/commands/sandbox.js +208 -9
  44. package/dist/commands/sandbox.js.map +1 -1
  45. package/dist/commands/setup.d.ts +39 -0
  46. package/dist/commands/setup.js +203 -0
  47. package/dist/commands/setup.js.map +1 -0
  48. package/dist/commands/tool.d.ts +154 -0
  49. package/dist/commands/tool.js +785 -0
  50. package/dist/commands/tool.js.map +1 -0
  51. package/dist/config.d.ts +30 -6
  52. package/dist/config.js +39 -8
  53. package/dist/config.js.map +1 -1
  54. package/dist/ctx.d.ts +5 -45
  55. package/dist/ctx.js +25 -160
  56. package/dist/ctx.js.map +1 -1
  57. package/dist/docs/index.json +1 -0
  58. package/dist/docs/pages/actions/call.md +300 -0
  59. package/dist/docs/pages/actions/catalog/airtable.md +737 -0
  60. package/dist/docs/pages/actions/catalog/arxiv.md +166 -0
  61. package/dist/docs/pages/actions/catalog/chainalysis-sanctions.md +125 -0
  62. package/dist/docs/pages/actions/catalog/coingecko.md +1558 -0
  63. package/dist/docs/pages/actions/catalog/deps-dev.md +465 -0
  64. package/dist/docs/pages/actions/catalog/dexscreener.md +568 -0
  65. package/dist/docs/pages/actions/catalog/discord.md +784 -0
  66. package/dist/docs/pages/actions/catalog/finnhub.md +776 -0
  67. package/dist/docs/pages/actions/catalog/frankfurter.md +438 -0
  68. package/dist/docs/pages/actions/catalog/github.md +1853 -0
  69. package/dist/docs/pages/actions/catalog/gmail.md +575 -0
  70. package/dist/docs/pages/actions/catalog/google-calendar.md +654 -0
  71. package/dist/docs/pages/actions/catalog/google-drive.md +502 -0
  72. package/dist/docs/pages/actions/catalog/google-sheets.md +700 -0
  73. package/dist/docs/pages/actions/catalog/hacker-news.md +542 -0
  74. package/dist/docs/pages/actions/catalog/http.md +824 -0
  75. package/dist/docs/pages/actions/catalog/hyperliquid.md +942 -0
  76. package/dist/docs/pages/actions/catalog/jira.md +920 -0
  77. package/dist/docs/pages/actions/catalog/kalshi.md +917 -0
  78. package/dist/docs/pages/actions/catalog/linear.md +1030 -0
  79. package/dist/docs/pages/actions/catalog/markets.md +21 -0
  80. package/dist/docs/pages/actions/catalog/morpho.md +247 -0
  81. package/dist/docs/pages/actions/catalog/notion.md +1077 -0
  82. package/dist/docs/pages/actions/catalog/nws.md +485 -0
  83. package/dist/docs/pages/actions/catalog/open-meteo.md +559 -0
  84. package/dist/docs/pages/actions/catalog/polymarket.md +1523 -0
  85. package/dist/docs/pages/actions/catalog/pushbullet.md +220 -0
  86. package/dist/docs/pages/actions/catalog/resend.md +307 -0
  87. package/dist/docs/pages/actions/catalog/s3.md +513 -0
  88. package/dist/docs/pages/actions/catalog/sec-edgar.md +487 -0
  89. package/dist/docs/pages/actions/catalog/slack.md +2629 -0
  90. package/dist/docs/pages/actions/catalog/stripe.md +1405 -0
  91. package/dist/docs/pages/actions/catalog/wikipedia.md +379 -0
  92. package/dist/docs/pages/actions/catalog.md +46 -0
  93. package/dist/docs/pages/actions/limits.md +50 -0
  94. package/dist/docs/pages/actions/model-tools.md +225 -0
  95. package/dist/docs/pages/actions/packs.md +148 -0
  96. package/dist/docs/pages/actions/settings.md +69 -0
  97. package/dist/docs/pages/actions/tools.md +244 -0
  98. package/dist/docs/pages/actions/triggers.md +149 -0
  99. package/dist/docs/pages/actions.md +88 -0
  100. package/dist/docs/pages/compat/anthropic.md +168 -0
  101. package/dist/docs/pages/compat/e2b.md +194 -0
  102. package/dist/docs/pages/compat/firecrawl.md +138 -0
  103. package/dist/docs/pages/compat/openai.md +168 -0
  104. package/dist/docs/pages/concepts/auth.md +151 -0
  105. package/dist/docs/pages/concepts/beta.md +55 -0
  106. package/dist/docs/pages/concepts/glossary.md +71 -0
  107. package/dist/docs/pages/concepts/ids.md +98 -0
  108. package/dist/docs/pages/concepts/jobs.md +229 -0
  109. package/dist/docs/pages/concepts/latency.md +138 -0
  110. package/dist/docs/pages/concepts/limits.md +191 -0
  111. package/dist/docs/pages/concepts/stack.md +59 -0
  112. package/dist/docs/pages/concepts/timing.md +86 -0
  113. package/dist/docs/pages/concepts/usage.md +110 -0
  114. package/dist/docs/pages/design/b3os-yaml.md +370 -0
  115. package/dist/docs/pages/design/deploy-from-github.md +122 -0
  116. package/dist/docs/pages/design/observability.md +134 -0
  117. package/dist/docs/pages/errors.md +1824 -0
  118. package/dist/docs/pages/infer/chat.md +570 -0
  119. package/dist/docs/pages/infer/limits.md +55 -0
  120. package/dist/docs/pages/infer/messages.md +185 -0
  121. package/dist/docs/pages/infer/responses.md +173 -0
  122. package/dist/docs/pages/infer/settings.md +154 -0
  123. package/dist/docs/pages/infer/speech.md +323 -0
  124. package/dist/docs/pages/infer.md +154 -0
  125. package/dist/docs/pages/introduction.md +162 -0
  126. package/dist/docs/pages/platform/addresses.md +174 -0
  127. package/dist/docs/pages/platform/call-log.md +99 -0
  128. package/dist/docs/pages/platform/custom-domains.md +104 -0
  129. package/dist/docs/pages/platform/keys.md +79 -0
  130. package/dist/docs/pages/platform/limits.md +57 -0
  131. package/dist/docs/pages/platform/members.md +101 -0
  132. package/dist/docs/pages/platform/requests.md +116 -0
  133. package/dist/docs/pages/platform/settings.md +129 -0
  134. package/dist/docs/pages/platform/webhooks.md +68 -0
  135. package/dist/docs/pages/platform.md +67 -0
  136. package/dist/docs/pages/quickstart/mcp.md +94 -0
  137. package/dist/docs/pages/quickstart/sandbox-agent.md +205 -0
  138. package/dist/docs/pages/quickstart/scrape.md +134 -0
  139. package/dist/docs/pages/quickstart.md +45 -0
  140. package/dist/docs/pages/render/inspections.md +162 -0
  141. package/dist/docs/pages/render/limits.md +72 -0
  142. package/dist/docs/pages/render/screenshots.md +179 -0
  143. package/dist/docs/pages/render/settings.md +431 -0
  144. package/dist/docs/pages/render/styles.md +342 -0
  145. package/dist/docs/pages/render/videos.md +272 -0
  146. package/dist/docs/pages/render.md +118 -0
  147. package/dist/docs/pages/routines/callables.md +174 -0
  148. package/dist/docs/pages/routines/definitions.md +361 -0
  149. package/dist/docs/pages/routines/limits.md +117 -0
  150. package/dist/docs/pages/routines/runs.md +328 -0
  151. package/dist/docs/pages/routines/settings.md +104 -0
  152. package/dist/docs/pages/routines/triggers.md +339 -0
  153. package/dist/docs/pages/routines.md +216 -0
  154. package/dist/docs/pages/sandboxes/agents.md +217 -0
  155. package/dist/docs/pages/sandboxes/commands.md +272 -0
  156. package/dist/docs/pages/sandboxes/images.md +166 -0
  157. package/dist/docs/pages/sandboxes/limits.md +143 -0
  158. package/dist/docs/pages/sandboxes/ports.md +260 -0
  159. package/dist/docs/pages/sandboxes/settings.md +358 -0
  160. package/dist/docs/pages/sandboxes/snapshots.md +423 -0
  161. package/dist/docs/pages/sandboxes/swarms.md +146 -0
  162. package/dist/docs/pages/sandboxes/volumes.md +131 -0
  163. package/dist/docs/pages/sandboxes.md +231 -0
  164. package/dist/docs/pages/sdks/cli.md +121 -0
  165. package/dist/docs/pages/sdks/mcp.md +169 -0
  166. package/dist/docs/pages/sdks/python.md +146 -0
  167. package/dist/docs/pages/sdks/typescript.md +202 -0
  168. package/dist/docs/pages/sdks.md +282 -0
  169. package/dist/docs/pages/settings.md +33 -0
  170. package/dist/docs/pages/vault/limits.md +46 -0
  171. package/dist/docs/pages/vault.md +133 -0
  172. package/dist/docs/pages/vision/agent-browser.md +115 -0
  173. package/dist/docs/pages/vision/crawl.md +333 -0
  174. package/dist/docs/pages/vision/extract.md +152 -0
  175. package/dist/docs/pages/vision/fetcher.md +15 -0
  176. package/dist/docs/pages/vision/limits.md +79 -0
  177. package/dist/docs/pages/vision/profiles.md +111 -0
  178. package/dist/docs/pages/vision/proxy.md +131 -0
  179. package/dist/docs/pages/vision/scrape.md +356 -0
  180. package/dist/docs/pages/vision/sessions.md +311 -0
  181. package/dist/docs/pages/vision/settings.md +656 -0
  182. package/dist/docs/pages/vision.md +175 -0
  183. package/dist/errors.d.ts +129 -0
  184. package/dist/errors.js +326 -0
  185. package/dist/errors.js.map +1 -0
  186. package/dist/main.d.ts +1 -1
  187. package/dist/main.js +26 -13
  188. package/dist/main.js.map +1 -1
  189. package/dist/manifest/apply.d.ts +4 -0
  190. package/dist/manifest/apply.js +2 -0
  191. package/dist/manifest/apply.js.map +1 -1
  192. package/dist/manifest/domains.d.ts +50 -0
  193. package/dist/manifest/domains.js +159 -0
  194. package/dist/manifest/domains.js.map +1 -0
  195. package/dist/manifest/link.d.ts +20 -0
  196. package/dist/manifest/link.js +24 -0
  197. package/dist/manifest/link.js.map +1 -0
  198. package/dist/manifest/record.d.ts +1 -1
  199. package/dist/tool/archive.d.ts +33 -0
  200. package/dist/tool/archive.js +174 -0
  201. package/dist/tool/archive.js.map +1 -0
  202. package/dist/tool/calls.d.ts +46 -0
  203. package/dist/tool/calls.js +274 -0
  204. package/dist/tool/calls.js.map +1 -0
  205. package/dist/tool/checks.d.ts +21 -0
  206. package/dist/tool/checks.js +145 -0
  207. package/dist/tool/checks.js.map +1 -0
  208. package/dist/tool/elf.d.ts +19 -0
  209. package/dist/tool/elf.js +107 -0
  210. package/dist/tool/elf.js.map +1 -0
  211. package/dist/tool/predict.d.ts +8 -0
  212. package/dist/tool/predict.js +38 -0
  213. package/dist/tool/predict.js.map +1 -0
  214. package/dist/tool/ustar.d.ts +5 -0
  215. package/dist/tool/ustar.js +220 -0
  216. package/dist/tool/ustar.js.map +1 -0
  217. package/package.json +6 -5
@@ -0,0 +1,225 @@
1
+ # Your model's tools
2
+
3
+ > The packs and B3OS products a service declares in b3os.yaml are tools its model calls over MCP, at one URL inside the sandbox that any agent framework mounts.
4
+
5
+ Source: https://docs.beta.b3os.org/actions/model-tools.md
6
+
7
+ A service that declares a pack in its b3os.yaml gets that pack's actions as MCP tools, and one that declares `browser`, `vision` or `render` gets that product's tools. The node serves them inside the service's sandbox at `http://127.0.0.1:7700/v1/actions/mcp` and puts that address in the service's environment as `B3OS_MCP_URL`. Any framework with an MCP client mounts it with that one URL, and its model can call the tools with no code that names a pack or an API route. Nothing new goes in the file: the pack you add on the canvas, or the entry in `uses`, is the tool.
8
+
9
+ ## What a service gets
10
+
11
+ ```yaml
12
+ actions:
13
+ packs:
14
+ - id: io.b3os/wikipedia
15
+ version: 1.0.1
16
+ services:
17
+ - name: researcher
18
+ uses: [model/b3os/default, pack/io.b3os/wikipedia]
19
+ ```
20
+
21
+ The plan says what the model will see:
22
+
23
+ ```text
24
+ + researcher first generation
25
+ grant actions:read actions:run infer:read infer:run; actions io.b3os/wikipedia/*@1.0.1
26
+ tools for the model: the actions of io.b3os/wikipedia/*@1.0.1, over MCP at B3OS_MCP_URL
27
+ ```
28
+
29
+ The service's sandbox gets:
30
+
31
+ - an actions rule in its grant, `api.actions.allow: ["io.b3os/wikipedia/*@1.0.1"]`: one entry per pack it uses, at the version `actions.packs` gives. A pack without a version gets `io.b3os/wikipedia/*`, which follows the publisher's newest version, new actions included, with no deploy; give `version` to hold it;
32
+ - `B3OS_MCP_URL=http://127.0.0.1:7700/v1/actions/mcp`, beside `B3OS_API_URL` and the model variables;
33
+ - the pack's actions as tools, named as the pack names them: `wikipedia__search`, `wikipedia__get-summary`, `wikipedia__get-article-text` and `wikipedia__get-on-this-day`, each with the pack's own description and input schema.
34
+
35
+ Add a pack on the canvas, merge and deploy, and the next `tools/list` has it.
36
+
37
+ ## Product tools: browser, vision, render
38
+
39
+ Node release 1119. Name the product in `uses`, as a bare entry beside your model and packs:
40
+
41
+ ```yaml
42
+ services:
43
+ - name: researcher
44
+ uses: [model/b3os/default, browser, vision, render, pack/io.b3os/wikipedia]
45
+ ```
46
+
47
+ | `uses` | The grant gets | Tools at `B3OS_MCP_URL` |
48
+ |---|---|---|
49
+ | `browser` | `vision:run`, `vision:write` | the 12 `browser_*` tools, and the `vision_*` tools |
50
+ | `vision` | `vision:run` | `vision_scrape`, `vision_screenshot`; `vision_extract` too when the grant holds `infer:run` (a `model/...` entry gives it) |
51
+ | `render` | `render:run` | `render_screenshot`, `render_video`, `render_inspect` |
52
+
53
+ The plan lists them after the packs:
54
+
55
+ ```text
56
+ tools for the model: the actions of io.b3os/wikipedia/*@1.0.1; browser (browser_navigate, browser_navigate_back, browser_snapshot, browser_click, browser_type, browser_press_key, browser_hover, browser_select_option, browser_wait_for, browser_take_screenshot, browser_evaluate, browser_close); vision (vision_scrape, vision_extract, vision_screenshot); render (render_screenshot, render_video, render_inspect), over MCP at B3OS_MCP_URL
57
+ ```
58
+
59
+ The node lists a tool when the grant holds the scopes it needs, whatever gave them (`uses`, `grant.scopes`, or `api.scopes` for a sandbox you create through the API), and the sandbox was created by a node with release 1119. `vision` and `render` grant what they did before this release, so a service that already uses them keeps its sandbox, and its tool list, until the next sandbox is created for it: a sandbox created before the release lists its packs only, whatever its scopes. That next sandbox may run the same spec (a keepalive recreate, or a fork); it gets the tools all the same.
60
+
61
+ `browser` grants `vision:write` because opening and closing a session needs it; nothing narrower does. Over REST that scope also lets the service close any browser session of its project, create, change and delete the project's saved profiles, and save a session into a profile. Exporting a profile's cookies and storage needs `vision:profiles:export` too, which `browser` does not grant (since the scope split's kept window ended, `[vision] profile_scopes_kept_until`; production's has ended).
62
+
63
+ ### The browser
64
+
65
+ The tools have Playwright MCP's names and arguments, so a model that knows that server uses them without new instructions. Each sandbox has one browser, as each Playwright MCP client does: the first `browser_navigate` opens a dedicated Chrome (a [vision session](https://docs.beta.b3os.org/vision/sessions), viewport 1280x800 CSS px), every other tool acts on it, and `browser_close` closes it. A browser closes 5 minutes after it opened (vision's default session timeout), after 2 minutes without a call, and when its sandbox ends (the node closes it itself then, even if the deploying key was revoked meanwhile); the next `browser_navigate` opens a new one, and the other tools say so until then. It bills `vision.browser_ms` from open to close and holds one of the organization's browser sessions meanwhile, so `browser_close` when the task ends.
66
+
67
+ | Tool | Does |
68
+ |---|---|
69
+ | `browser_navigate` | Opens `url` and returns the page's title, URL and outline |
70
+ | `browser_navigate_back` | Goes back one page |
71
+ | `browser_snapshot` | Outlines the page: one element per line, controls and headings ending in `[ref=3f9a2c10:e4]`; `mode: full` lists every control |
72
+ | `browser_click`, `browser_hover` | Act on `ref` with real mouse events; a click on a covered element fails with `target_covered` and clicks nothing |
73
+ | `browser_type` | Replaces a field's text, then presses Enter with `submit: true` |
74
+ | `browser_press_key` | Presses `Enter`, `Escape`, `Control+a` and the like |
75
+ | `browser_select_option` | Chooses one option of a select by its value |
76
+ | `browser_wait_for` | Waits for `text`, for `textGone`, or for `time` seconds (at most 30) |
77
+ | `browser_take_screenshot` | The viewport, the whole page or one element, as an image |
78
+ | `browser_evaluate` | Runs `() => ...` in the page and returns the JSON result |
79
+ | `browser_close` | Closes the browser |
80
+
81
+ Every action tool is one `POST /v1/vision/sessions/{session_id}/act` batch that ends with a fresh outline (`snapshot`, with the page's title and URL), read in vision's isolated world like vision's own lookups, never in the page's world, so the model sees the page change without a second call. When the action's own steps succeed and only that outline fails (the page was still navigating), the tool succeeds and says to call `browser_snapshot`. When the action itself fails, the error carries vision's `delivery` (`not_delivered`: nothing was sent; `delivered_unverified`: the input went out) and `retry`, so a model knows whether repeating it is safe. `ref` takes the outline's own `3f9a2c10:e4`, the short `e4` that Playwright MCP prints and the `@e4` that agent-browser prints (both resolved against the newest outline of that browser), `text=Sign in`, or a CSS selector. A ref names one element of one page: after the page navigates, use the refs of the new outline (an old one fails with `stale_ref`). Not served, with the reason: tabs and `browser_resize` (one page per browser, its viewport fixed at open), `browser_file_upload` (vision refuses file inputs), console and network logs, and `browser_handle_dialog` (vision dismisses dialogs itself and lists them in the step's result).
82
+
83
+ ### Vision and render
84
+
85
+ - `vision_scrape` reads one page as Markdown (or `html`, `text`, `links`), from the cache when a fresh copy exists, with a browser only when the page needs one. `vision_extract` returns JSON the node's model fills from the page (`schema`, `prompt` or both). `vision_screenshot` returns the page as an image. Each is one `POST /v1/vision/scrape`.
86
+ - `render_screenshot` is a styled capture (background, window frame, consent walls hidden) as an image and its link; `render_video` records one beat of a page (optional narration and steps) and waits up to 50 seconds for the MP4, answering with its link and the poster frame, or, while it still records, with its id: `render_video` with `video_id` waits for that video again and starts none (render lets a video's creator read it with `render:run`, so the sandbox that started it needs no `render:read`; another sandbox does); `render_inspect` records a window of the page frame by frame and answers with the change report's summary and the contact sheet as an image.
87
+
88
+ Text over 16,000 characters is cut with a line saying how much was left out, as for pack tools.
89
+
90
+ ### What a product tool call does
91
+
92
+ A product tool call is that product's own API request, sent on the sandbox's own connection: the route checks the scope, admits the call against the organization's credits, the key's and the grant's spend caps and the operation's own limits (`vision.scrape.rpm` counts REST scrapes and `vision_scrape` calls together), meters it, and logs it, exactly as when your code calls the route. So the request log has two lines for one tool call (three for a `browser_navigate` that opens the browser): the MCP request (`operation_id: actionsMcp`, with `action.pack` the toolset, `action.tool` the tool and `action.ref` the product operation, such as `vision/visionAct`) and the product request (`operation_id: visionAct`, `connection: sandbox`, the sandbox's id). `GET /v1/sandboxes/{sandbox_id}/requests?pack=browser` lists one service's browser tool calls. Usage records are the product's (`vision.page`, `vision.browser_ms`, `render.screenshot`, `render.video_s`, `render.inspection_s`), with the sandbox and the product request's id. A tool the grant lacks a scope for answers with `isError: true` and `403 forbidden`, naming the scope and the `uses` entry that grants it; a product refusal (`spend_cap_exceeded`, `rate_limited`, `target_covered`, ...) comes back the same way, with the product's own code.
93
+
94
+ ## Mount it
95
+
96
+ A product tool can take until the endpoint's own limit of 65 seconds (a cold `browser_navigate` opens a browser and loads the page; `render_video` waits up to 50 seconds), so give your MCP client a tool timeout above it. The OpenAI Agents SDK waits 5 seconds by default (openai-agents 0.24.0, the version in the `agent` template): the example sets 75.
97
+
98
+ **OpenAI Agents SDK**
99
+
100
+ ```python
101
+ import asyncio, os
102
+ from agents import Agent, Runner, set_tracing_disabled
103
+ from agents.mcp import MCPServerStreamableHttp
104
+
105
+ set_tracing_disabled(True) # the traces would go to OpenAI
106
+
107
+ async def main():
108
+ async with MCPServerStreamableHttp(
109
+ name="b3os",
110
+ params={"url": os.environ["B3OS_MCP_URL"]},
111
+ cache_tools_list=True,
112
+ # The SDK waits 5 s for a tool by default (openai-agents 0.24.0, the agent template's); a browser or
113
+ # render tool can take until the endpoint's own limit (65 s).
114
+ client_session_timeout_seconds=75,
115
+ ) as b3os:
116
+ agent = Agent(
117
+ name="researcher",
118
+ instructions="Answer from Wikipedia and cite the article.",
119
+ model=os.environ["B3OS_MODEL"], # OPENAI_BASE_URL points at the node's model
120
+ mcp_servers=[b3os],
121
+ )
122
+ result = await Runner.run(agent, "When did Ada Lovelace publish her notes?")
123
+ print(result.final_output)
124
+
125
+ asyncio.run(main())
126
+ ```
127
+ **LangGraph**
128
+
129
+ ```python
130
+ import asyncio, os
131
+ from langchain_mcp_adapters.client import MultiServerMCPClient
132
+ from langchain_openai import ChatOpenAI
133
+ from langgraph.prebuilt import create_react_agent
134
+
135
+ async def main():
136
+ client = MultiServerMCPClient(
137
+ {"b3os": {"url": os.environ["B3OS_MCP_URL"], "transport": "streamable_http"}}
138
+ )
139
+ tools = await client.get_tools()
140
+ model = ChatOpenAI(model=os.environ["B3OS_MODEL"]) # reads OPENAI_BASE_URL and OPENAI_API_KEY
141
+ agent = create_react_agent(model, tools)
142
+ out = await agent.ainvoke({"messages": [("user", "When did Ada Lovelace publish her notes?")]})
143
+ print(out["messages"][-1].content)
144
+
145
+ asyncio.run(main())
146
+ ```
147
+ **Vercel AI SDK**
148
+
149
+ ```ts
150
+ import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
151
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
152
+ import { experimental_createMCPClient as createMCPClient, generateText, stepCountIs } from "ai";
153
+
154
+ const mcp = await createMCPClient({
155
+ transport: new StreamableHTTPClientTransport(new URL(process.env.B3OS_MCP_URL!)),
156
+ });
157
+ const b3os = createOpenAICompatible({
158
+ name: "b3os",
159
+ baseURL: process.env.OPENAI_BASE_URL!, // the node's model, set in the sandbox
160
+ apiKey: process.env.OPENAI_API_KEY,
161
+ });
162
+ const { text } = await generateText({
163
+ model: b3os(process.env.B3OS_MODEL!),
164
+ tools: await mcp.tools(),
165
+ stopWhen: stepCountIs(5),
166
+ prompt: "When did Ada Lovelace publish her notes?",
167
+ });
168
+ console.log(text);
169
+ await mcp.close();
170
+ ```
171
+
172
+ AI SDK 5 exports the client from `ai` as above; AI SDK 6 has it as `createMCPClient` in `@ai-sdk/mcp`.
173
+ **curl**
174
+
175
+ ```bash
176
+ # inside the sandbox: no key, the sandbox's grant is the credential
177
+ curl -s "$B3OS_MCP_URL" -H 'Content-Type: application/json' \
178
+ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"wikipedia__get-summary","arguments":{"title":"Ada Lovelace"}}}'
179
+ ```
180
+
181
+ GPT Researcher takes the server per research request, with no code change: `"mcp_enabled": true, "mcp_configs": [{"name": "b3os", "connection_url": "http://127.0.0.1:7700/v1/actions/mcp"}]`.
182
+
183
+ ## What a pack tool call does
184
+
185
+ - **It runs under the service's grant**: its scopes (`actions:run` to call, `actions:read` to list), its connections (each connection key of the pack resolves among the connections the grant names, the ones `actions.packs[].connections` chose) and its spend cap.
186
+ - **It bills what the REST call bills.** A `tools/call` is the same call as `POST /v1/actions/call`: one `actions.call`, its `egress.bytes`, or a hosted tool's units, to the service. Listing tools bills nothing. Model tokens the tool definitions add are the model's own meter.
187
+ - **A refused or failed call is a tool result the model reads**: `isError: true` with `action_not_allowed: ...`, `spend_cap_exceeded: ...` or the action's own error as text, and the code and status in `structuredContent.error`. A missing connection says which dashboard link adds it.
188
+ - **The answer** is the action's output as compact JSON text, cut at 16,000 characters with a line saying how much was left out, so one long article cannot fill a small model's context. `structuredContent` is the output itself when it is an object that was not cut.
189
+ - **Tool results are text from outside services.** A page can carry instructions; the rule below keeps what the model can reach to what the service declared, and write actions keep their effects.
190
+
191
+ ## Only the declared packs
192
+
193
+ The actions rule is a boundary, not a filter on a list. A service's sandbox may call only the pack actions its rule names, at the versions it names, through MCP and through `POST /v1/actions/call` alike: anything else answers [`403 action_not_allowed`](https://docs.beta.b3os.org/errors#action_not_allowed) before the input is read, a connection is resolved or anything is billed. A call that names a range (`io.b3os/wikipedia/search@1`) runs the newest version the rule allows that the range admits, so a service pinned to 1.0.1 keeps running 1.0.1 after 1.0.2 is published.
194
+
195
+ Routines stay inside it too. A run the service starts (`POST /v1/routines/{routine}/runs`, or a replay) acts as the routine's publisher, as every run does, but only within the service's rule: a step that calls a pack outside it fails with `action_not_allowed`, and a sub-routine inherits the rule. The service may signal a run, or send it an event, only when that run is within its rule (one it started), and may not test-deliver a hook. A routine's public routes (its webhook URL, its wait links) carry their own credentials and are not the service's. The rule bounds calls; reading the catalog (describe, the packs and tools routes) shows every pack your organization can see.
196
+
197
+ `B3OS_MCP_URL` answers only inside the sandbox, and being there is its only credential, as for the rest of the in-VM API. Never proxy `127.0.0.1:7700` out of the sandbox (a dev server's proxy, for one), and never let your app's visitors choose the MCP URL your agent connects to (GPT Researcher's `mcp_configs`, for one): either hands the service's grant to whoever reaches it, within the rule and the spend cap. With product tools that includes a browser on B3OS's network and renders billed to you.
198
+
199
+ A service deployed before node release 1118 has no rule until its next generation, which the first `b3os apply` or keepalive after the release makes: the deploy engine replaces each generation the node shows without the rule its revision gives it. If your code calls a pack by hand that its b3os.yaml does not declare, declare it in `uses` before that apply.
200
+
201
+ ## Seeing the calls
202
+
203
+ Each tool call is one line of the [request log](https://docs.beta.b3os.org/platform/requests) with `operation_id: actionsMcp` and `action`: the action ref that ran, its pack, the tool name and the call's own `status_code` and `error_code` (a `tools/call` answers HTTP 200 either way). `GET /v1/requests?pack=io.b3os/wikipedia` lists one pack's calls, and `GET /v1/sandboxes/{sandbox_id}/requests?pack=...` one service's. Usage records carry the pack, version and action in `meta` and the sandbox in `sandbox_id`, as for any action call.
204
+
205
+ ## Outside a deployed service
206
+
207
+ A sandbox you create through the API gets the same rule, address and product tools from its grant:
208
+
209
+ ```json
210
+ {"template": "agent",
211
+ "api": {"scopes": ["actions:read", "actions:run"],
212
+ "actions": {"allow": ["io.b3os/wikipedia/*@1.0.1", "io.b3os/github/create-issue"]}}}
213
+ ```
214
+
215
+ Each entry is `<namespace>/<name>/<action or *>[@<version>]`, at most 16. Its `api.scopes` list the product tools: `["vision:run", "vision:write"]` for the browser. A sandbox with neither a rule nor a product's scopes lists no tools and gets no `B3OS_MCP_URL`; the sandboxes it creates inherit its rule and may only narrow it. With an API key, outside a sandbox, use the edge's MCP server instead: `https://beta-api.b3os.org/mcp?packs=io.b3os/wikipedia` ([MCP server](https://docs.beta.b3os.org/sdks/mcp)). The node endpoint answers a key with `403 forbidden` (`reason: sandbox_only`).
216
+
217
+ ## The cost of a call (dev baseline)
218
+
219
+ A dev baseline from 2026-11-18, on a dev stack on our development node (not production, no Cloudflare in the path): from inside one sandbox with io.b3os/wikipedia, in 30 interleaved pairs, a tool call over MCP added 0.064 ms at p50 and 0.173 ms at p95 to the same `POST /v1/actions/call`, with Wikipedia's own time taken out of both sides. Mounting the server costs one `initialize` (0.277 ms at p50) and one `tools/list` (0.359 ms at p50). The raw data and the commands are in `bench/actions/results/dev-20261118-mcp-tool-call-cost`.
220
+
221
+ Product tools, a dev baseline from 2026-11-20 on the same kind of stack with vision and render added (node release 1119): a `vision_scrape` of a cached page added 0.028 to 0.085 ms at p50 to the same `POST /v1/vision/scrape` from the same sandbox, in seven runs of 30 interleaved pairs, with the product request's own time taken out of both sides (0.181 ms in the first run after a restart of the node). A pack tool call on that stack added 0.044 to 0.075 ms at p50 in five runs, as in release 1118. The raw data, the commands and every run are in `bench/actions/results/dev-20261120-toolsets-cost`.
222
+
223
+ ## The protocol
224
+
225
+ Streamable HTTP without sessions, JSON answers only: `POST` one JSON-RPC message per request (no batches), `GET` and `DELETE` answer 405. Revisions 2026-07-28 (stateless, with the `MCP-Protocol-Version`, `Mcp-Method` and `Mcp-Name` headers mirroring the body) and 2024-11-05 through 2025-11-25, as the edge's `/mcp`. Every JSON-RPC answer is HTTP 200; what the transport cannot take (not JSON, a batch, another content type, mismatched headers) is a 400 or 415 problem that names the JSON-RPC code. A request with an `Origin` header is refused (`403 forbidden`, `reason: origin`), so no page a browser in the sandbox opens can call the tools. The reference is [`POST /v1/actions/mcp`](https://docs.beta.b3os.org/api/post-v1-actions-mcp).
@@ -0,0 +1,148 @@
1
+ # Packs
2
+
3
+ > What a B3OS pack contains, how a declarative HTTP action is written with CEL templates, and how packs are hashed, signed, published and verified.
4
+
5
+ Source: https://docs.beta.b3os.org/actions/packs.md
6
+
7
+ A pack is a versioned bundle with a `b3pack.json` manifest at its root. The manifest names the pack, declares the hosts it may reach and the credentials it may use, and describes each action and trigger.
8
+
9
+ ## A small pack
10
+
11
+ This pack has one action, which calls the public Open-Meteo geocoding API and needs no credential:
12
+
13
+ ```json b3pack.json
14
+ {
15
+ "pack": "io.b3os/open-meteo",
16
+ "version": "1.0.0",
17
+ "title": "Open-Meteo",
18
+ "description": "Place search and current weather from the Open-Meteo API.",
19
+ "publisher": { "id": "io.b3os", "name": "B3OS" },
20
+ "license": "MIT",
21
+ "engine": "^1.0",
22
+ "egress": [{ "host": "geocoding-api.open-meteo.com" }],
23
+ "actions": [
24
+ {
25
+ "key": "search-places",
26
+ "title": "Search places",
27
+ "description": "Find places by name. Returns coordinates and time zone for each match, best match first.",
28
+ "inputSchema": {
29
+ "type": "object",
30
+ "additionalProperties": false,
31
+ "required": ["name"],
32
+ "properties": { "name": { "type": "string", "minLength": 2, "maxLength": 100 } }
33
+ },
34
+ "outputSchema": {
35
+ "type": "object",
36
+ "additionalProperties": false,
37
+ "required": ["places"],
38
+ "properties": { "places": { "type": "array" } }
39
+ },
40
+ "effects": { "class": "read" },
41
+ "impl": {
42
+ "kind": "http",
43
+ "request": {
44
+ "method": "GET",
45
+ "url": "https://geocoding-api.open-meteo.com/v1/search",
46
+ "query": { "name": "${{ input.name }}", "format": "json" }
47
+ },
48
+ "response": {
49
+ "map": { "places": "${{ has(response.body.results) ? response.body.results : [] }}" }
50
+ }
51
+ }
52
+ }
53
+ ]
54
+ }
55
+ ```
56
+
57
+ Its action is called as `io.b3os/open-meteo/search-places@1.0.0`, and its MCP tool name is `open-meteo__search-places`.
58
+
59
+ ## Manifest fields
60
+
61
+ | Field | Meaning |
62
+ |---|---|
63
+ | `pack`, `version` | `<namespace>/<name>` and a semantic version without build metadata. The namespace is the publisher's reverse-DNS name. |
64
+ | `title`, `description`, `license`, `publisher` | What the pack is and who publishes it. Verification status lives in the registry, never in the manifest. |
65
+ | `engine` | The pack runtime it needs, as a caret range; the v1 runtime is `1.0.0`. |
66
+ | `egress` | Every host any action or trigger may reach. Actions may narrow it. A new host in a later version is a major change. |
67
+ | `connections` | The credentials the pack can use, by key, each with a type (`api_key`, `bearer`, `basic`, `oauth2`) and the hosts it is injected for |
68
+ | `actions` | Up to 256 actions: `key`, `title`, `description`, `inputSchema`, `outputSchema`, `effects` and `impl` |
69
+ | `triggers` | Up to 64 webhook, poll or schedule triggers |
70
+ | `signature` | Written by the publish tool: the content hash and the publisher's Ed25519 signature |
71
+
72
+ ## How a declarative action runs
73
+
74
+ 1. The input is validated against `inputSchema`, and schema defaults fill in absent fields.
75
+ 2. The request template is evaluated. Expressions are CEL inside `${{ }}`, with `input` and the connections' non-secret `params` in scope. Text spliced into the URL is percent-encoded, so an input cannot add a path segment, a query parameter or a fragment; [safe templates](#safe-templates) covers what encoding does not.
76
+ 3. The final URL's host must match the action's egress list.
77
+ 4. The egress proxy adds the credential for each connection the action requires, only on requests to that connection's hosts: `api_key` where the pack's `inject` says, `bearer` and `oauth2` as `Authorization: Bearer`, `basic` as `Authorization: Basic`. Templates never see secrets and cannot set the injected header.
78
+ 5. A response counts as success on a 2xx status unless `response.success` says otherwise. `response.map` builds the output, which must match `outputSchema`; the default map is the response body. On failure, the first matching `errors[]` entry names the pack's error, reported in the problem's `pack_error`.
79
+
80
+ Packs whose logic needs code are written in JavaScript and run in a separate runtime with no credentials, reaching the network only through the egress proxy. In the beta those are first-party packs only.
81
+
82
+ Credentials go only into `https` requests, for declarative and JavaScript actions alike: a request that would carry a credential over plain `http` fails with `403` [`egress_denied`](https://docs.beta.b3os.org/errors#egress_denied), reason `scheme`. A pack's request to an `http` host it holds no credential for goes out as usual.
83
+
84
+ ## Safe templates
85
+
86
+ The first-party catalog's build refuses a pack that breaks any of these rules; follow them in your own pack definitions too.
87
+
88
+ - **Dot segments.** `.` and `..` survive percent-encoding, and URL parsing removes them: `repos/${{ input.repo }}` with `repo = ".."` reaches another endpoint of the same host, credential included. An interpolation that forms a whole path segment must exclude both, with a pattern, an enum, a format or a number.
89
+ - **Whole-string URLs** (`url: "${{ input.url }}"`) are used as given. A credentialed action that builds a URL from input must constrain it so it cannot carry `?`, `#`, `%`, a backslash, control characters or a `.` or `..` segment.
90
+ - **Wildcard hosts.** A templated host is one DNS label under a wildcard egress entry, such as `${{ params.site }}.atlassian.net`. When the credential is bound to that wildcard, the label must come from the connection's params, never from input: otherwise the credential could go to another tenant's site.
91
+ - **URL inputs stay out of messages and outputs.** A URL can carry its own authorization (a webhook token in the path, a presigned signature in the query). Error messages reach problem details, run history and request logs, and outputs reach run history, so no error message or response map reads a URL input.
92
+ - **CEL type names.** Compare types with a literal's type, `type(x) == type('')`, never `type(x) == string`: the node resolves every identifier as a variable, so a bare type name does not load.
93
+ - **Functions.** Use only the spec's CEL function library (`size`, `has`, `matches`, the conversions, the list macros, `contains`, `startsWith`, `endsWith`, `format`, `join`, `toJSON`, `fromJSON`), and in packs `fromBase64(s)` (base64 or base64url, padding optional, read as UTF-8 with invalid bytes as U+FFFD) and `truncate(s, n)` (the first `n` characters), which decode and bound a message body. There is no `now()`; pass dates in the input.
94
+
95
+ ## Signing and verification
96
+
97
+ Every pack version has a content hash over all of its files (the manifest serialized with RFC 8785, without its signature) and an Ed25519 signature by the publisher's registered key over `b3pack-sig-v1`, the pack, the version and the hash. Before loading a version, a node recomputes the hash, compares it with the registry's record, and checks the signature. A pack that fails is not loaded, and calls to it fail with [`pack_unavailable`](https://docs.beta.b3os.org/errors#pack_unavailable).
98
+
99
+ The key that signs first-party B3OS packs is held by a person, outside every automated agent, CI job and ops tool, so publishing a first-party version always takes that person's step. Development and test keys (`#dev-` and `#test-` key IDs) are never trusted in production.
100
+
101
+ ## The registry
102
+
103
+ | Call | Does |
104
+ |---|---|
105
+ | `GET /v1/actions/packs` | Packs the node serves, with their latest version, action and trigger counts, facets, connection types, `keyless` (no credential to store) and icons |
106
+ | `GET /v1/actions/packs/{namespace}/{name}` | A pack version with its actions, triggers, connections and egress hosts |
107
+ | `GET /v1/actions/packs/{namespace}/{name}/tools` | Every action of the version as an MCP tool, in one response with an `ETag` and `ttlMs`; `effects` and `actions` narrow it |
108
+ | `GET /v1/actions/packs/{namespace}/{name}/versions/{version}/manifest` | The exact `b3pack.json`, as published and signed |
109
+ | `GET /v1/actions/registry/packs` | The registry at `beta-api.b3os.org`, with every published version |
110
+ | `POST /v1/actions/registry/packs` | Publish a version as a gzip tarball (`actions:write`) |
111
+
112
+ To see what a pack does before an agent calls it, read its manifest:
113
+
114
+ **curl**
115
+
116
+ ```bash
117
+ curl -s https://beta-api.b3os.org/v1/actions/packs/io.b3os/open-meteo \
118
+ -H "Authorization: Bearer $B3OS_API_KEY"
119
+ curl -s https://beta-api.b3os.org/v1/actions/packs/io.b3os/open-meteo/versions/1.0.0/manifest \
120
+ -H "Authorization: Bearer $B3OS_API_KEY"
121
+ ```
122
+ **TypeScript**
123
+
124
+ ```ts
125
+ import { B3OS } from "@b3os/sdk";
126
+
127
+ const b3os = new B3OS();
128
+ const pack = await b3os.actions.getPack("io.b3os", "open-meteo");
129
+ console.log(pack.version, pack.actions.map((a) => a.key));
130
+ const manifest = await b3os.actions.getPackManifest("io.b3os", "open-meteo", pack.version);
131
+ console.log(manifest.egress);
132
+ ```
133
+ **Python**
134
+
135
+ ```python
136
+ from b3os import B3OS
137
+
138
+ b3os = B3OS()
139
+ pack = b3os.actions.get_pack("io.b3os", "open-meteo")
140
+ print(pack["version"], [a["key"] for a in pack["actions"]])
141
+ manifest = b3os.actions.get_pack_manifest("io.b3os", "open-meteo", pack["version"])
142
+ print(manifest["egress"])
143
+ ```
144
+ **MCP**
145
+
146
+ `actions_describe` gives an agent one action's schemas, effect class and connections. Whole packs and manifests are read from code.
147
+
148
+ Versions are immutable once published. In the beta only first-party B3OS packs (`io.b3os`) can be published; public publishing comes later, with signed provenance and a review of each version's new capabilities.
@@ -0,0 +1,69 @@
1
+ # Action settings
2
+
3
+ > The settings of an action call: its timeout and which connection it uses, with defaults and examples, and the response size cap.
4
+
5
+ Source: https://docs.beta.b3os.org/actions/settings.md
6
+
7
+ An action call takes few settings: what it may wait for, and which stored credential it uses. The rest is the action's own input, described on its [catalog](https://docs.beta.b3os.org/actions/catalog) page.
8
+
9
+ | Setting | Default |
10
+ |---|---|
11
+ | [Call timeout](#call-timeout): `timeout_ms` | the action's own, on its catalog page |
12
+ | [Connection](#connection): `connections` | your project's newest connection for the key with no `subject` ([per field](#connection)) |
13
+
14
+ ## Calls
15
+
16
+ ### Call timeout
17
+
18
+ The longest the whole call may take.
19
+
20
+ - **Field:** `timeout_ms` on [call](https://docs.beta.b3os.org/api/post-v1-actions-call)
21
+ - **Default:** the action's own, on its catalog page
22
+ - **Values:** 100 to 60,000 ms
23
+ - **Invalid value:** [`400 invalid_request`](https://docs.beta.b3os.org/errors#invalid_request)
24
+
25
+ ```json
26
+ {"ref": "io.b3os/github/get-repo@1", "input": {"owner": "octocat", "repo": "hello-world"}, "timeout_ms": 10000}
27
+ ```
28
+
29
+ ```bash
30
+ b3os action call io.b3os/github/get-repo@1 --timeout-ms 10000
31
+ ```
32
+
33
+ ### Connection
34
+
35
+ Which stored credential the call uses. Name one per connection key, or give `subject` to use that end user's newest connection. With neither, a key with no matching connection fails with `422 connection_required`.
36
+
37
+ - **Field:** `connections` and `subject` on [call](https://docs.beta.b3os.org/api/post-v1-actions-call)
38
+ - **Default:** your project's newest connection for the key with no `subject` (`connections`), none (`subject`)
39
+ - **Values:** `connections` maps a pack's connection key to a `conn_` ID; `subject` is your end user's ID
40
+ - **Invalid value:** [`400 invalid_request`](https://docs.beta.b3os.org/errors#invalid_request), [`422 connection_required`](https://docs.beta.b3os.org/errors#connection_required)
41
+ - **Guide:** [Connections](https://docs.beta.b3os.org/actions/call#connections)
42
+
43
+ ```json
44
+ {"ref": "io.b3os/github/get-repo@1", "input": {"owner": "octocat", "repo": "hello-world"}, "connections": {"api": "conn_01m5t6cbgdjs1ketgcqwa2sne8"}}
45
+ ```
46
+
47
+ ```bash
48
+ b3os action call io.b3os/github/get-repo@1 --connection api=conn_01m5t6cbgdjs1ketgcqwa2sne8
49
+ ```
50
+
51
+ ## Fixed in the beta
52
+
53
+ These work one way in the beta, and no request field changes them.
54
+
55
+ ### Response size
56
+
57
+ **5 MiB per upstream response.** An action reads at most 5 MiB of each response from the service it calls. A larger response fails the call with `502 upstream_too_large`, and retrying does not help.
58
+
59
+ - **Error:** [`502 upstream_too_large`](https://docs.beta.b3os.org/errors#upstream_too_large)
60
+
61
+ ### Retries
62
+
63
+ **Pure and read actions only.** B3OS retries a failed `pure` or `read` action on its own and never a `write` or `irreversible` one, which could repeat its effect. Send an `Idempotency-Key` and retry yourself.
64
+
65
+ - **Guide:** [Retries and idempotency](https://docs.beta.b3os.org/actions/call#retries-and-idempotency)
66
+
67
+ ### Publishers
68
+
69
+ **B3OS only.** Only first-party B3OS packs (`io.b3os`) are in the catalog during the beta.