typebulb 0.13.3 → 0.13.5
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 +59 -8
- package/dist/agents/claude/client.js +334 -176
- package/dist/index.js +118 -118
- package/dist/render.js +246 -88
- package/dist/servers.js +54 -54
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
**Typebulb** runs apps in markdown files called **bulbs**. To run bulbs:
|
|
4
4
|
|
|
5
5
|
* `npx typebulb`. When you want a quick local app or tool where the overhead of an entire npm project is overkill *(trivial for your LLM to convert to when you actually need to)*. Can be entirely client code, or both client and nodejs code that talk via a secure bridge.
|
|
6
|
-
* `npx typebulb agent
|
|
6
|
+
* `npx typebulb agent`. When you want a browser view of your project's Claude Code sessions that renders embedded bulbs live — the **agent mirror**. Tell Claude to run this command.
|
|
7
7
|
* **[typebulb.com](https://typebulb.com)**. When you want to share tools, visualizations, experiments etc. See [FAQ](https://typebulb.com/faq).
|
|
8
8
|
|
|
9
9
|
The `typebulb` CLI enables the first two cases, by compiling and serving hot-reloadable bulbs locally.
|
|
@@ -27,7 +27,7 @@ A `.bulb.md` file bundles code, styles, data, and config in one file.
|
|
|
27
27
|
- **AI calls** — `tb.ai()` for general-purpose AI (chatbots, agents, experiments). `tb.models()` lists available models. Set API keys in `.env` (see below). Requires `--trust`.
|
|
28
28
|
- **Sandboxed by default** — A plain `npx typebulb my-app.bulb.md` runs with no filesystem or `server.ts` (like typebulb.com); `--trust` grants those for a run. Trust is **remembered**: `typebulb trust <file>` elevates a bulb once so later plain runs are trusted, `untrust` revokes it, and `--no-trust` forces sandboxed for a single run.
|
|
29
29
|
- **Predict trust** — `typebulb predict <file>` reports the capability a bulb will likely need (fs / AI / `server.ts`) without running it, so you can decide on `--trust` up front rather than after a mid-run permission failure.
|
|
30
|
-
- **Agent mirror** —
|
|
30
|
+
- **Agent mirror** — a browser view of your project's Claude Code sessions that renders embedded bulbs, KaTeX, and mermaid live inline, plus runs/stops local bulbs (see [Claude](#claude)). `typebulb agent:claude` opens it. `typebulb agent` (no target) is the first command an agent runs: it brings up the mirror without opening a browser, prints its link, and points at the authoring skill. `typebulb skill` prints this whole README as an Agent Skill the agent can read and save.
|
|
31
31
|
|
|
32
32
|
## Quick Start
|
|
33
33
|
|
|
@@ -117,9 +117,9 @@ npm install -g typebulb
|
|
|
117
117
|
|
|
118
118
|
```
|
|
119
119
|
typebulb [file.bulb.md] Run a bulb (defaults to .bulb.md in cwd)
|
|
120
|
-
typebulb agent:claude Open the agent mirror
|
|
121
|
-
typebulb agent
|
|
122
|
-
|
|
120
|
+
typebulb agent:claude Open the agent mirror of your project's Claude Code sessions
|
|
121
|
+
typebulb agent An agent's first command — brings up the agent mirror,
|
|
122
|
+
prints its URL + the authoring-skill paths; always exits 0
|
|
123
123
|
typebulb skill Print this README as an Agent Skill on stdout
|
|
124
124
|
typebulb call <file> <fn> […] Invoke one server.ts export headlessly: prints its return as JSON to stdout, logs/errors to stderr (needs --trust)
|
|
125
125
|
typebulb check [file.bulb.md] Type-check a bulb without running it
|
|
@@ -231,18 +231,18 @@ A local `.bulb.md` can be re-imported into typebulb.com. If it has a `**server.t
|
|
|
231
231
|
|
|
232
232
|
The agent mirror currently supports Claude Code only. `npx typebulb agent:claude` gives the user a great scratchpad experience:
|
|
233
233
|
|
|
234
|
-
* a view
|
|
234
|
+
* a view of the project's Claude Code sessions, where assistant messages containing bulbs render as sandboxed embedded bulbs inline in the conversation, alongside KaTeX math, mermaid diagrams and svg.
|
|
235
235
|
* run and stop any bulb in their project.
|
|
236
236
|
* promote any embedded bulb to a `.bulb.md` file in the `typebulbs/` folder.
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
Start it yourself with `npx typebulb agent` — don't wait for the user — and end your reply with the localhost link it prints: it's the user's next click, and a link buried mid-message gets missed.
|
|
239
239
|
|
|
240
240
|
To keep this skill on hand across sessions, run `npx typebulb skill` and copy its output into your skills folder (for Claude Code, `.claude/skills/typebulb/SKILL.md`) — only if the user asks.
|
|
241
241
|
|
|
242
242
|
### When Claude should output local vs embedded bulbs
|
|
243
243
|
|
|
244
244
|
- **First, can it even embed?** A bulb needing `tb.ai`, `tb.fs`, or `server.ts` must be **local** — embeds are client-only, so those calls fail there. The choice below is only for client-only bulbs.
|
|
245
|
-
- **Is anyone watching?** An embed only renders live when the agent mirror is open; with none it shows as raw text. `typebulb agent`
|
|
245
|
+
- **Is anyone watching?** An embed only renders live when the agent mirror is open; with none it shows as raw text. `npx typebulb agent` starts the mirror if needed and prints its link — share it with the user; don't make the user start anything.
|
|
246
246
|
- **Something to see right now, in the flow of the conversation** — a chart of some numbers, a quick simulation, an illustrative widget. → **embedded**: emit it in a `bulb` block so it renders live inline.
|
|
247
247
|
- **A tool worth keeping** — something to reuse, run on its own, or refine over several turns. → **local**: write a `.bulb.md` file run with `npx typebulb`. An embedded block is throwaway and can't be edited in place, so it's the wrong fit for anything iterative.
|
|
248
248
|
|
|
@@ -289,6 +289,57 @@ The host owns a bulb's **width**; you own its **height**.
|
|
|
289
289
|
- **`config.json` → `ts.jsxImportSource`** — the one supported `ts` option; defaults to `react`. Set it to use a different JSX runtime (e.g. `preact`).
|
|
290
290
|
- **Never invent a connection string or API key** — a `server.ts` that needs a database or API reads it from `.env` (loaded from the directory you run in). Ask the user for the value; don't fabricate one or commit it.
|
|
291
291
|
|
|
292
|
+
## Trust Model
|
|
293
|
+
|
|
294
|
+
Typebulb has 3 trust tiers for a bulb, captured by 2 axes:
|
|
295
|
+
|
|
296
|
+
| | browser: **iframe** | browser: **top-level** |
|
|
297
|
+
|---|:---:|:---:|
|
|
298
|
+
| node access: **no** | **Embedded** | **Restricted** |
|
|
299
|
+
| node access: **yes** | — | **Trusted** |
|
|
300
|
+
|
|
301
|
+
The 3 Tiers from least to most powerful:
|
|
302
|
+
|
|
303
|
+
* **Embedded**: These bulbs live in an iframe, and have the most restricted capability. They're created by Typebulb's Agent Mirror when rendering chat files. When bulb-markdown is detected in your agent's replies, they're rendered as embedded bulbs.
|
|
304
|
+
* **Restricted**: These bulbs are launched as localhost pages. Unlike embedded bulbs, they can also access storage, cookies, web workers, WebGPU etc.
|
|
305
|
+
* **Trusted**: These bulbs are the most powerful and must be explicitly marked as trusted. Unlike restricted bulbs, they can access node via your `server.ts` or via privileged `tb.*` functions such as `tb.fs` or `tb.ai`. To grant, call typebulb with `--trust` for one run, or `typebulb trust <file>` to remember it — per file, for your user account, across all your projects. Revoke a remembered grant with `typebulb untrust <file>`; `--no-trust` forces a single sandboxed run without forgetting the grant.
|
|
306
|
+
|
|
307
|
+
Here's a state transition diagram for the trust tiers:
|
|
308
|
+
|
|
309
|
+
```mermaid
|
|
310
|
+
stateDiagram-v2
|
|
311
|
+
direction LR
|
|
312
|
+
[*] --> Embedded
|
|
313
|
+
[*] --> Restricted
|
|
314
|
+
Embedded --> Restricted: breakout
|
|
315
|
+
Restricted --> Trusted: trust
|
|
316
|
+
Trusted --> Restricted: untrust
|
|
317
|
+
```
|
|
318
|
+
**Capability Summary Table**:
|
|
319
|
+
|
|
320
|
+
| Capability | Embedded | Restricted | Trusted |
|
|
321
|
+
|---|:--:|:--:|:--:|
|
|
322
|
+
| Run code in browser, access network including localhost | ✅ | ✅ | ✅ |
|
|
323
|
+
| Use storage, cookies, background threads, and the GPU | 🚫 | ✅ | ✅ |
|
|
324
|
+
| Read local files, run node code with `server.ts`, use your AI keys | 🚫 | 🚫 | ✅ |
|
|
325
|
+
|
|
326
|
+
## Bulb Imports
|
|
327
|
+
|
|
328
|
+
Imports in `code.tsx` can only use bare specifiers (otherwise the linter will error):
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
import React, { useState } from "react"
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Which must be declared in the dependencies section:
|
|
335
|
+
```json
|
|
336
|
+
"dependencies": {
|
|
337
|
+
"react": "^19.2.7"
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Typebulb has a package resolver that will load and cache these packages from `esm.sh` when the bulb runs.
|
|
342
|
+
|
|
292
343
|
## License
|
|
293
344
|
|
|
294
345
|
MIT
|