typebulb 0.52.4 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +7 -5
  2. package/SKILL.md +9 -7
  3. package/dist/agents/claude/client.js +173 -173
  4. package/dist/agents/codex/client.js +173 -173
  5. package/dist/agents/pi/client.js +193 -193
  6. package/dist/ai/aiProvider.d.ts +2 -2
  7. package/dist/ai/aiProvider.d.ts.map +1 -1
  8. package/dist/ai/inference.d.ts +4 -3
  9. package/dist/ai/inference.d.ts.map +1 -1
  10. package/dist/ai/inference.js +24 -23
  11. package/dist/ai/inference.js.map +1 -1
  12. package/dist/ai/providers/anthropic.d.ts +1 -1
  13. package/dist/ai/providers/anthropic.d.ts.map +1 -1
  14. package/dist/ai/providers/anthropic.js +5 -5
  15. package/dist/ai/providers/anthropic.js.map +1 -1
  16. package/dist/ai/providers/chatCompletions.d.ts +1 -1
  17. package/dist/ai/providers/chatCompletions.d.ts.map +1 -1
  18. package/dist/ai/providers/chatCompletions.js +2 -2
  19. package/dist/ai/providers/chatCompletions.js.map +1 -1
  20. package/dist/ai/providers/gemini.d.ts +1 -1
  21. package/dist/ai/providers/gemini.d.ts.map +1 -1
  22. package/dist/ai/providers/gemini.js +4 -4
  23. package/dist/ai/providers/gemini.js.map +1 -1
  24. package/dist/ai/providers/openAI.d.ts +1 -1
  25. package/dist/ai/providers/openAI.d.ts.map +1 -1
  26. package/dist/ai/providers/openAI.js +3 -3
  27. package/dist/ai/providers/openAI.js.map +1 -1
  28. package/dist/ai/sseParser.d.ts +1 -1
  29. package/dist/ai/sseParser.d.ts.map +1 -1
  30. package/dist/ai/sseParser.js +6 -6
  31. package/dist/ai/sseParser.js.map +1 -1
  32. package/dist/format/parse.d.ts +15 -3
  33. package/dist/format/parse.d.ts.map +1 -1
  34. package/dist/format/parse.js +61 -14
  35. package/dist/format/parse.js.map +1 -1
  36. package/dist/format/serialize.d.ts +1 -1
  37. package/dist/format/serialize.d.ts.map +1 -1
  38. package/dist/format/serialize.js +1 -1
  39. package/dist/format/serialize.js.map +1 -1
  40. package/dist/index.js +394 -268
  41. package/dist/lint/index.js +1 -1
  42. package/dist/lint/index.js.map +1 -1
  43. package/dist/render.js +152 -152
  44. package/dist/servers.js +94 -91
  45. package/package.json +1 -1
package/README.md CHANGED
@@ -41,6 +41,7 @@ typebulb agent An agent's first command — auto-detects the har
41
41
  typebulb agent:{claude|codex|pi} Open a named harness's mirror in the foreground — the explicit form, or to override auto-detect
42
42
  typebulb call <file> <fn> […] Invoke one server.ts export headlessly: prints its return as JSON to stdout, logs/errors to stderr (needs --trust)
43
43
  typebulb send <file> [msg] Push a message into a running bulb's page (its tb.onMessage handlers); the client-side twin of call, no --trust.
44
+ A '-' message reads it from stdin (like call --args -)
44
45
  With --wait, a handler's non-undefined return prints on stdout (JSON; a bare string raw)
45
46
  typebulb send <file> tb:snapshot Print the live page's rendered outline (roles, names, visible text), headed by a viewport/content fit line
46
47
  typebulb send <file> tb:rect … Print a named control's rect ('tb:rect button "Pass"' → {x,y,width,height} + viewport)
@@ -253,21 +254,22 @@ The agent mirror turns that block into a live, sandboxed app, with a *breakout
253
254
 
254
255
  **The turn-based loop** (a game, an approval flow): a bulb whose `server.ts` does `console.log` on each user action is the event channel. Per turn — act via `typebulb call`, arm `wait <file> --match <tag>` in the background, end your turn; on wake, read state with `typebulb call <file> <getState>` (never parse it from the log line) and repeat. **`call` always boots a fresh `server.ts` instance** — it never attaches to the running bulb's server — so any state shared between the page and your calls must live on disk (load/save it in each export), not in `server.ts` module memory. A bulb's uncaught browser errors land in the same log as `[runtime error] …`, so the wake channel also catches your bulb breaking. For inline bulbs, the same subscription is `typebulb wait agent` on the mirror — see [Emitting an inline bulb](#emitting-an-inline-bulb).
255
256
 
256
- **Keep every loop command argument-stable.** A harness that permission-matches exact command strings prompts the user on *every* event if varying data (a move, a payload) rides the command line. Keep it off: write the args to a fixed file and pipe them — `cat <bulb-folder>/args.json | typebulb call <file> <fn> --args -` — so each of the loop's commands is one constant string, approved once. `wait` and a `getState` call are constant already.
257
+ **Keep every loop command argument-stable.** A harness that permission-matches exact command strings prompts the user on *every* event if varying data (a move, a payload) rides the command line. Keep it off: write the args to a fixed file and pipe them — `cat <bulb-folder>/args.json | typebulb call <file> <fn> --args -` — so each of the loop's commands is one constant string, approved once. `send` takes its message the same way (`typebulb send <file> -`), which is also how a large or quote-heavy payload avoids the shell. `wait` and a `getState` call are constant already.
257
258
 
258
259
  ### Emitting a local bulb
259
260
 
260
- - **Launch once, and share the printed link.** `npx typebulb foo.bulb.md` starts the server (in VS Code's terminal and agent shells it prints the link to share rather than opening a tab). The link stays good — a bulb keeps its port across runs.
261
+ - **Launch once, and share the printed link.** `npx typebulb foo.bulb.md` starts the server (in VS Code's terminal and agent shells it prints the link to share rather than opening a tab). The link stays good: a bulb keeps its port across runs, keyed to the filename, so re-share it after a rename.
262
+ - **In an agent shell, background the launch** (Claude Code: `run_in_background`; pi: run it plainly). The server runs until stopped, so a foreground launch only holds your turn.
261
263
 
262
264
  ### Iterating on a local bulb
263
265
 
264
266
  That one launch *is* the loop: the server watches the file, so every save recompiles and reloads the page (`server.ts` included) — editing the file is the iteration.
265
267
 
266
- - **Don't relaunch, and don't wrap it in `timeout`.** A relaunch replaces the running server (one per bulb file), reclaiming the same port so the open tab reloads itself — it costs the page's in-memory state and nothing else. `timeout` kills it outright, and the racing relaunch is what spawns extra windows.
268
+ - **Don't relaunch, and don't wrap it in the `timeout` command.** A relaunch replaces the running server (one per bulb file), reclaiming the same port so the open tab reloads itself — it costs the page's in-memory state and nothing else. The `timeout` command kills the server outright, and the racing relaunch is what spawns extra windows; your harness's own tool timeout does not kill it.
267
269
  - **What needs a restart:** a `.env` change (read once at boot) and in-memory `server.ts` state (reset on each reload).
268
270
  - **Each reload re-runs the bulb.** A save re-executes `code.tsx` from scratch, so work you start on mount repeats every edit — re-spending GPU/network, re-firing side effects, flooding the log. Put expensive or side-effecting work behind a trigger: `tb.onMessage(() => start())`, then `typebulb send <file>` when ready (also a general terminal→page channel — pass params, drive a loop).
269
271
  - **Reading the log:** it appends across every reload, so `typebulb logs --run latest <file>` shows just the current run (no need to clear).
270
- - **When done:** Ctrl-C, or `typebulb stop <file>` — closing the terminal leaves the server running detached.
272
+ - **When done:** Ctrl-C, or `typebulb stop <file>` — a backgrounded launch has no Ctrl-C, so `stop` ends it.
271
273
 
272
274
  #### Interrogating the live page
273
275
 
@@ -488,7 +490,7 @@ One bulb per command, between typebulb.com and its conventional local file — t
488
490
 
489
491
  - **Pull**: `typebulb pull <bulb-url>` (or an existing local file, to refresh in place) — brings the bulb's `assets/` folder along. Unlisted and public bulbs need no login. A local file or asset with real changes is refused; `--force` overwrites it.
490
492
  - **Push**: `typebulb push <file>` uploads as you — set `TYPEBULB_TOKEN` in `.env` (minted on your typebulb.com settings page). A slug that doesn't exist yet is created, unlisted. If the site copy changed since your last pull/push, the push is refused; `--force` overwrites it. A `**server.ts**` block is stripped from the site copy (CLI-only); your local file is never modified.
491
- - **Assets**: push and pull carry the bulb's `assets/` folder both ways — files upload to typebulb's asset host and the published bulb serves them with zero config (quotas apply; refusals say so). A local file shadows its hosted copy.
493
+ - **Assets**: push and pull carry the bulb's `assets/` folder both ways — files upload to typebulb's asset host and the published bulb serves them with zero config. Caps are **2MB per file, 10MB per bulb**; anything larger stays yours, referenced by absolute URL (a push over a cap is refused and names the live figure). A local file shadows its hosted copy.
492
494
  - **In the agent mirror**, the launcher lists your typebulb.com bulbs (pull-on-play) and local `u/<user>/` rows carry pull/push icons — same rules, same `--force` confirm. Pasting any bulb URL into its filter offers a pull-on-play row.
493
495
  - `TYPEBULB_ORIGIN` in `.env` overrides the default `https://typebulb.com` host.
494
496
 
package/SKILL.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  name: typebulb
3
3
  description: "Author and run Typebulb bulbs — single-file markdown apps (TypeScript/TSX) that run locally via `npx typebulb` (full power: filesystem, database, `server.ts`, `tb.ai`) or render live inline in your coding agent's session through Typebulb's agent mirror (sandboxed, client-only). A bulb can be a visual widget (chart, simulation, diagram, calculator, UI), a full-stack tool with a Node backend, or an AI app that calls models at runtime. Covers the bulb format, the `tb.*` API, trust, and the local run/inline workflow. Use when the user wants a bulb, a quick local tool (visual, backend-backed, or AI-powered), or something visual rendered inline in the conversation."
4
- version: 0.52.4
4
+ version: 0.55.0
5
5
  ---
6
6
 
7
- > Generated from typebulb v0.52.4. `npx typebulb agent` prints the running version alongside the path to its packaged SKILL.md: if that version is newer than this one, replace this file with that one.
7
+ > Generated from typebulb v0.55.0. `npx typebulb agent` prints the running version alongside the path to its packaged SKILL.md: if that version is newer than this one, replace this file with that one.
8
8
 
9
9
  # typebulb
10
10
 
@@ -49,6 +49,7 @@ typebulb agent An agent's first command — auto-detects the har
49
49
  typebulb agent:{claude|codex|pi} Open a named harness's mirror in the foreground — the explicit form, or to override auto-detect
50
50
  typebulb call <file> <fn> […] Invoke one server.ts export headlessly: prints its return as JSON to stdout, logs/errors to stderr (needs --trust)
51
51
  typebulb send <file> [msg] Push a message into a running bulb's page (its tb.onMessage handlers); the client-side twin of call, no --trust.
52
+ A '-' message reads it from stdin (like call --args -)
52
53
  With --wait, a handler's non-undefined return prints on stdout (JSON; a bare string raw)
53
54
  typebulb send <file> tb:snapshot Print the live page's rendered outline (roles, names, visible text), headed by a viewport/content fit line
54
55
  typebulb send <file> tb:rect … Print a named control's rect ('tb:rect button "Pass"' → {x,y,width,height} + viewport)
@@ -261,21 +262,22 @@ The agent mirror turns that block into a live, sandboxed app, with a *breakout
261
262
 
262
263
  **The turn-based loop** (a game, an approval flow): a bulb whose `server.ts` does `console.log` on each user action is the event channel. Per turn — act via `typebulb call`, arm `wait <file> --match <tag>` in the background, end your turn; on wake, read state with `typebulb call <file> <getState>` (never parse it from the log line) and repeat. **`call` always boots a fresh `server.ts` instance** — it never attaches to the running bulb's server — so any state shared between the page and your calls must live on disk (load/save it in each export), not in `server.ts` module memory. A bulb's uncaught browser errors land in the same log as `[runtime error] …`, so the wake channel also catches your bulb breaking. For inline bulbs, the same subscription is `typebulb wait agent` on the mirror — see [Emitting an inline bulb](#emitting-an-inline-bulb).
263
264
 
264
- **Keep every loop command argument-stable.** A harness that permission-matches exact command strings prompts the user on *every* event if varying data (a move, a payload) rides the command line. Keep it off: write the args to a fixed file and pipe them — `cat <bulb-folder>/args.json | typebulb call <file> <fn> --args -` — so each of the loop's commands is one constant string, approved once. `wait` and a `getState` call are constant already.
265
+ **Keep every loop command argument-stable.** A harness that permission-matches exact command strings prompts the user on *every* event if varying data (a move, a payload) rides the command line. Keep it off: write the args to a fixed file and pipe them — `cat <bulb-folder>/args.json | typebulb call <file> <fn> --args -` — so each of the loop's commands is one constant string, approved once. `send` takes its message the same way (`typebulb send <file> -`), which is also how a large or quote-heavy payload avoids the shell. `wait` and a `getState` call are constant already.
265
266
 
266
267
  ### Emitting a local bulb
267
268
 
268
- - **Launch once, and share the printed link.** `npx typebulb foo.bulb.md` starts the server (in VS Code's terminal and agent shells it prints the link to share rather than opening a tab). The link stays good — a bulb keeps its port across runs.
269
+ - **Launch once, and share the printed link.** `npx typebulb foo.bulb.md` starts the server (in VS Code's terminal and agent shells it prints the link to share rather than opening a tab). The link stays good: a bulb keeps its port across runs, keyed to the filename, so re-share it after a rename.
270
+ - **In an agent shell, background the launch** (Claude Code: `run_in_background`; pi: run it plainly). The server runs until stopped, so a foreground launch only holds your turn.
269
271
 
270
272
  ### Iterating on a local bulb
271
273
 
272
274
  That one launch *is* the loop: the server watches the file, so every save recompiles and reloads the page (`server.ts` included) — editing the file is the iteration.
273
275
 
274
- - **Don't relaunch, and don't wrap it in `timeout`.** A relaunch replaces the running server (one per bulb file), reclaiming the same port so the open tab reloads itself — it costs the page's in-memory state and nothing else. `timeout` kills it outright, and the racing relaunch is what spawns extra windows.
276
+ - **Don't relaunch, and don't wrap it in the `timeout` command.** A relaunch replaces the running server (one per bulb file), reclaiming the same port so the open tab reloads itself — it costs the page's in-memory state and nothing else. The `timeout` command kills the server outright, and the racing relaunch is what spawns extra windows; your harness's own tool timeout does not kill it.
275
277
  - **What needs a restart:** a `.env` change (read once at boot) and in-memory `server.ts` state (reset on each reload).
276
278
  - **Each reload re-runs the bulb.** A save re-executes `code.tsx` from scratch, so work you start on mount repeats every edit — re-spending GPU/network, re-firing side effects, flooding the log. Put expensive or side-effecting work behind a trigger: `tb.onMessage(() => start())`, then `typebulb send <file>` when ready (also a general terminal→page channel — pass params, drive a loop).
277
279
  - **Reading the log:** it appends across every reload, so `typebulb logs --run latest <file>` shows just the current run (no need to clear).
278
- - **When done:** Ctrl-C, or `typebulb stop <file>` — closing the terminal leaves the server running detached.
280
+ - **When done:** Ctrl-C, or `typebulb stop <file>` — a backgrounded launch has no Ctrl-C, so `stop` ends it.
279
281
 
280
282
  #### Interrogating the live page
281
283
 
@@ -496,7 +498,7 @@ One bulb per command, between typebulb.com and its conventional local file — t
496
498
 
497
499
  - **Pull**: `typebulb pull <bulb-url>` (or an existing local file, to refresh in place) — brings the bulb's `assets/` folder along. Unlisted and public bulbs need no login. A local file or asset with real changes is refused; `--force` overwrites it.
498
500
  - **Push**: `typebulb push <file>` uploads as you — set `TYPEBULB_TOKEN` in `.env` (minted on your typebulb.com settings page). A slug that doesn't exist yet is created, unlisted. If the site copy changed since your last pull/push, the push is refused; `--force` overwrites it. A `**server.ts**` block is stripped from the site copy (CLI-only); your local file is never modified.
499
- - **Assets**: push and pull carry the bulb's `assets/` folder both ways — files upload to typebulb's asset host and the published bulb serves them with zero config (quotas apply; refusals say so). A local file shadows its hosted copy.
501
+ - **Assets**: push and pull carry the bulb's `assets/` folder both ways — files upload to typebulb's asset host and the published bulb serves them with zero config. Caps are **2MB per file, 10MB per bulb**; anything larger stays yours, referenced by absolute URL (a push over a cap is refused and names the live figure). A local file shadows its hosted copy.
500
502
  - **In the agent mirror**, the launcher lists your typebulb.com bulbs (pull-on-play) and local `u/<user>/` rows carry pull/push icons — same rules, same `--force` confirm. Pasting any bulb URL into its filter offers a pull-on-play row.
501
503
  - `TYPEBULB_ORIGIN` in `.env` overrides the default `https://typebulb.com` host.
502
504