typebulb 0.51.3 → 0.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +4 -4
  2. package/SKILL.md +6 -6
  3. package/dist/agents/claude/client.js +201 -200
  4. package/dist/agents/claude/styles.css +34 -10
  5. package/dist/agents/codex/client.js +203 -202
  6. package/dist/agents/codex/styles.css +34 -10
  7. package/dist/agents/pi/client.js +217 -216
  8. package/dist/agents/pi/styles.css +34 -10
  9. package/dist/ai/index.d.ts +1 -1
  10. package/dist/ai/index.d.ts.map +1 -1
  11. package/dist/ai/index.js +1 -1
  12. package/dist/ai/index.js.map +1 -1
  13. package/dist/ai/protocol.d.ts +24 -0
  14. package/dist/ai/protocol.d.ts.map +1 -1
  15. package/dist/ai/protocol.js +15 -0
  16. package/dist/ai/protocol.js.map +1 -1
  17. package/dist/ai/providers/anthropic.d.ts +4 -0
  18. package/dist/ai/providers/anthropic.d.ts.map +1 -1
  19. package/dist/ai/providers/anthropic.js +32 -1
  20. package/dist/ai/providers/anthropic.js.map +1 -1
  21. package/dist/ai/providers/chatCompletions.d.ts +13 -0
  22. package/dist/ai/providers/chatCompletions.d.ts.map +1 -1
  23. package/dist/ai/providers/chatCompletions.js +19 -11
  24. package/dist/ai/providers/chatCompletions.js.map +1 -1
  25. package/dist/ai/providers/gemini.d.ts +10 -0
  26. package/dist/ai/providers/gemini.d.ts.map +1 -1
  27. package/dist/ai/providers/gemini.js +21 -2
  28. package/dist/ai/providers/gemini.js.map +1 -1
  29. package/dist/ai/providers/ollama.d.ts +3 -0
  30. package/dist/ai/providers/ollama.d.ts.map +1 -1
  31. package/dist/ai/providers/ollama.js +5 -1
  32. package/dist/ai/providers/ollama.js.map +1 -1
  33. package/dist/ai/providers/openAI.d.ts +12 -0
  34. package/dist/ai/providers/openAI.d.ts.map +1 -1
  35. package/dist/ai/providers/openAI.js +18 -1
  36. package/dist/ai/providers/openAI.js.map +1 -1
  37. package/dist/ai/providers/openRouter.d.ts +3 -0
  38. package/dist/ai/providers/openRouter.d.ts.map +1 -1
  39. package/dist/ai/providers/openRouter.js +5 -0
  40. package/dist/ai/providers/openRouter.js.map +1 -1
  41. package/dist/ai/sseParser.d.ts +13 -1
  42. package/dist/ai/sseParser.d.ts.map +1 -1
  43. package/dist/ai/sseParser.js +26 -5
  44. package/dist/ai/sseParser.js.map +1 -1
  45. package/dist/dts/tbTypings.d.ts.map +1 -1
  46. package/dist/dts/tbTypings.js +15 -4
  47. package/dist/dts/tbTypings.js.map +1 -1
  48. package/dist/index.js +254 -229
  49. package/dist/render.js +4 -3
  50. package/dist/servers.js +103 -102
  51. package/package.json +1 -1
package/README.md CHANGED
@@ -420,10 +420,10 @@ Run `typebulb models` to list the models available for the providers specified.
420
420
  Trusted bulbs can call AI providers **from their own code** at runtime, billed to your API keys.
421
421
 
422
422
  ```ts
423
- tb.ai({ messages, system?, effort?, provider?, model?, webSearch? }) // → Promise<{ text }>
423
+ tb.ai({ messages, system?, effort?, provider?, model?, webSearch? }) // → Promise<{ text, usage? }>
424
424
  ```
425
425
 
426
- Name the provider and model explicitly — `tb.ai({ provider: "openai", model: "gpt-5.6-luna", … })` — or rely on the defaults you set in `.env`. `webSearch` defaults **off**; pass `webSearch: true` to give the model a web-search tool (searches bill to your key).
426
+ Name the provider and model explicitly — `tb.ai({ provider: "openai", model: "gpt-5.6-luna", … })` — or rely on the defaults you set in `.env`. `webSearch` defaults **off**; pass `webSearch: true` to give the model a web-search tool (searches bill to your key). `usage` is the provider-reported token counts — `{ input, output, reasoning?, cacheRead? }`, reasoning included in `output` — absent when the provider reports none; use it to meter calls instead of estimating from text length.
427
427
 
428
428
  ### Reasoning effort
429
429
 
@@ -446,7 +446,7 @@ const { text } = await tb.ai({
446
446
 
447
447
  ### Streaming
448
448
 
449
- `tb.ai.stream({ … })` is the streaming counterpart of `tb.ai()` — an async iterable of `{ kind: "text" | "reasoning", text }` deltas. `tb.ai()` (await the full text) is unchanged; reach for `.stream` only when a response is long enough to be worth showing as it arrives.
449
+ `tb.ai.stream({ … })` is the streaming counterpart of `tb.ai()` — an async iterable of `{ kind: "text" | "reasoning", text }` deltas, closed by one `{ kind: "usage", usage }` chunk with the call's token counts. `tb.ai()` (await the full text) is unchanged; reach for `.stream` only when a response is long enough to be worth showing as it arrives.
450
450
 
451
451
  ```ts
452
452
  let answer = "";
@@ -455,7 +455,7 @@ for await (const c of tb.ai.stream({ messages })) {
455
455
  }
456
456
  ```
457
457
 
458
- Breaking the loop stops the stream; same options as `tb.ai()`. **`kind: "reasoning"` chunks require `effort: 1-4` and a thinking-capable model**.
458
+ Breaking the loop stops the stream; same options as `tb.ai()`. **`kind: "reasoning"` chunks require `effort: 1-4` and a thinking-capable model**. Match `kind` positively as above — a bare `else` that assumes "not reasoning means text" misreads the usage chunk.
459
459
 
460
460
  ### AI access
461
461
 
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.51.3
4
+ version: 0.52.1
5
5
  ---
6
6
 
7
- > Generated from typebulb v0.51.3. `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.52.1. `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
 
@@ -428,10 +428,10 @@ Run `typebulb models` to list the models available for the providers specified.
428
428
  Trusted bulbs can call AI providers **from their own code** at runtime, billed to your API keys.
429
429
 
430
430
  ```ts
431
- tb.ai({ messages, system?, effort?, provider?, model?, webSearch? }) // → Promise<{ text }>
431
+ tb.ai({ messages, system?, effort?, provider?, model?, webSearch? }) // → Promise<{ text, usage? }>
432
432
  ```
433
433
 
434
- Name the provider and model explicitly — `tb.ai({ provider: "openai", model: "gpt-5.6-luna", … })` — or rely on the defaults you set in `.env`. `webSearch` defaults **off**; pass `webSearch: true` to give the model a web-search tool (searches bill to your key).
434
+ Name the provider and model explicitly — `tb.ai({ provider: "openai", model: "gpt-5.6-luna", … })` — or rely on the defaults you set in `.env`. `webSearch` defaults **off**; pass `webSearch: true` to give the model a web-search tool (searches bill to your key). `usage` is the provider-reported token counts — `{ input, output, reasoning?, cacheRead? }`, reasoning included in `output` — absent when the provider reports none; use it to meter calls instead of estimating from text length.
435
435
 
436
436
  ### Reasoning effort
437
437
 
@@ -454,7 +454,7 @@ const { text } = await tb.ai({
454
454
 
455
455
  ### Streaming
456
456
 
457
- `tb.ai.stream({ … })` is the streaming counterpart of `tb.ai()` — an async iterable of `{ kind: "text" | "reasoning", text }` deltas. `tb.ai()` (await the full text) is unchanged; reach for `.stream` only when a response is long enough to be worth showing as it arrives.
457
+ `tb.ai.stream({ … })` is the streaming counterpart of `tb.ai()` — an async iterable of `{ kind: "text" | "reasoning", text }` deltas, closed by one `{ kind: "usage", usage }` chunk with the call's token counts. `tb.ai()` (await the full text) is unchanged; reach for `.stream` only when a response is long enough to be worth showing as it arrives.
458
458
 
459
459
  ```ts
460
460
  let answer = "";
@@ -463,7 +463,7 @@ for await (const c of tb.ai.stream({ messages })) {
463
463
  }
464
464
  ```
465
465
 
466
- Breaking the loop stops the stream; same options as `tb.ai()`. **`kind: "reasoning"` chunks require `effort: 1-4` and a thinking-capable model**.
466
+ Breaking the loop stops the stream; same options as `tb.ai()`. **`kind: "reasoning"` chunks require `effort: 1-4` and a thinking-capable model**. Match `kind` positively as above — a bare `else` that assumes "not reasoning means text" misreads the usage chunk.
467
467
 
468
468
  ### AI access
469
469