Add bool.ai — server-side AI with no API key (AI battery) - #12
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Surface
bool.ai.generate(prompt)→Promise<string>bool.ai.generate({ prompt, schema })→Promise<T>(JSON-Schema-validated, typed)bool.ai.stream(prompt)→AsyncIterable<string>BoolAi,BoolAiSchema,BoolAiError(carriesstatus+ machine-readablecodesuch as"out_of_ai_credits"on a 402)Transport mirrors the db/users planes —
credentials: "include"+x-bool-viewer/x-bool-eu-sessionidentity headers. Return-data-directly-and-throw ergonomics, same asentities.Notes
0.2.0-next.11. Numbered.11because.10is reserved for the in-flightbool.secretsbranch.lib/gateway/ai-route.ts) in the Bool platform repo. The plane is gated by thebool-aifeature flag (off by default), sobool.aionly works where a workspace has been opted in.extractFromFileis intentionally not included yet (no server sub-route for it).Tests
src/client.test.ts: generate (text + schema), failure →BoolAiErrorwithstatus/code, stream chunking, non-ok stream, viewer-token replay. Full suite 67 pass / 0 fail;tscbuild clean.🤖 Generated with Claude Code