Skip to content

Add bool.ai — server-side AI with no API key (AI battery) - #12

Merged
max-bader merged 4 commits into
mainfrom
claude/bool-ai-battery
Jul 21, 2026
Merged

max-bader merged 4 commits into
mainfrom
claude/bool-ai-battery

Conversation

@max-bader

Copy link
Copy Markdown
Contributor

What

Adds bool.ai — the first "battery". A deployed Bool gets server-side AI with no API key in the bundle: calls route through the gateway AI plane (/_bool/v1/ai/*), which runs the prompt against Bool's own provider credential and meters one AI credit against the app owner's workspace. The key never reaches the client.

const text = await bool.ai.generate("Summarize: " + review);

const { sentiment, topics } = await bool.ai.generate<{ sentiment: string; topics: string[] }>({
  prompt: review,
  schema: { type: "object", properties: { sentiment: { type: "string" }, topics: { type: "array", items: { type: "string" } } }, required: ["sentiment", "topics"] },
});

for await (const chunk of bool.ai.stream("Write a haiku")) setText((t) => t + chunk);

Surface

  • bool.ai.generate(prompt)Promise<string>
  • bool.ai.generate({ prompt, schema })Promise<T> (JSON-Schema-validated, typed)
  • bool.ai.stream(prompt)AsyncIterable<string>
  • New exports: BoolAi, BoolAiSchema, BoolAiError (carries status + machine-readable code such as "out_of_ai_credits" on a 402)

Transport mirrors the db/users planes — credentials: "include" + x-bool-viewer / x-bool-eu-session identity headers. Return-data-directly-and-throw ergonomics, same as entities.

Notes

  • Additive, canary channel: version 0.2.0-next.11. Numbered .11 because .10 is reserved for the in-flight bool.secrets branch.
  • Requires the server side: the gateway AI plane (lib/gateway/ai-route.ts) in the Bool platform repo. The plane is gated by the bool-ai feature flag (off by default), so bool.ai only works where a workspace has been opted in.
  • extractFromFile is intentionally not included yet (no server sub-route for it).

Tests

src/client.test.ts: generate (text + schema), failure → BoolAiError with status/code, stream chunking, non-ok stream, viewer-token replay. Full suite 67 pass / 0 fail; tsc build clean.

🤖 Generated with Claude Code

max-bader and others added 4 commits July 21, 2026 10:42
bool.ai.generate/stream route through the gateway AI plane (/_bool/v1/ai/*),
which runs the prompt against Bool's own provider credential and meters one AI
credit against the app owner's workspace. The key never reaches the client — a
static Bool becomes an AI app with no signup, no .env, no backend. Mirrors the
db/users planes: credentials included, viewer/eu-session identity headers
replayed for the preview.

- src/client.ts: BoolAi + BoolAiSchema + BoolAiError types, `ai` on BoolClient,
  and the implementation (generate text/structured, stream via a text/plain
  reader).
- src/index.ts: export the new types + BoolAiError.
- src/client.test.ts: generate (text + schema), failure → BoolAiError w/ status
  + code, stream chunking, non-ok stream, viewer-token replay.
- README + CHANGELOG; version 0.2.0-next.11 (additive, canary channel — .10 is
  reserved for the in-flight bool.secrets branch).

Requires the gateway AI plane in the Bool platform repo (lib/gateway/ai-route.ts).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Update version from 0.2.0-next.11 to 0.2.0-next.10 in the changelog.
…ranch

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@max-bader
max-bader merged commit 5c13773 into main Jul 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant