Skip to content

Add the Cloud plugin and AI Gateway - #1034

Draft
ymichael wants to merge 2 commits into
bb/local-cloud-developmentfrom
bb/plan-for-metadata-inference-thr_ujvarx7qmi
Draft

Add the Cloud plugin and AI Gateway#1034
ymichael wants to merge 2 commits into
bb/local-cloud-developmentfrom
bb/plan-for-metadata-inference-thr_ujvarx7qmi

Conversation

@ymichael

@ymichael ymichael commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #1168, the local Cloud development workflow PR. This PR contains only the Cloud plugin and AI Gateway commit.

  • expand the existing getbb.app connection into one user-facing Cloud plugin while preserving the compatibility id connect and the bb connect command
  • keep the existing Remote access experience and make the sidebar phone a shortcut to that section of the Cloud plugin settings
  • add an experiment-gated AI Gateway section with one preference: “Enable for thread titles, commit messages and voice transcription”
  • add authenticated Cloudflare endpoints for structured inference and voice transcription, including input limits and per-account daily budget enforcement
  • route thread-title generation, commit-message generation, and voice transcription through Cloud first, then fall back to locally configured providers

Responsibility boundaries

server cloudAi experiment policy
  -> server inference / transcription
  -> experimental plugin provider slot
  -> builtin Cloud plugin (compatibility id: connect)
  -> @bb/connect-client
  -> Connect worker
  -> OpenAI

Connect worker -> D1 ai_usage metering
  • Server: owns experiment policy, provider ordering, timeout behavior, final validation, and local fallback
  • Connect worker: owns authentication, cloud model/cost policy, input caps, upstream calls, quota reservation/refunds, and sanitized errors
  • Connect client: owns request encoding, credential headers, response validation, and stable transport errors
  • Cloud plugin: owns pairing-aware availability, the AI Gateway preference, credential/quota backoff, UI, CLI, and RPC integration
  • App host: owns plugin identity, lifecycle switch, experiment-gated settings sections, and deep-linked sidebar navigation

Contract changes

  • add required cloudAi: boolean to the server-backed experiments contract; it defaults to false
  • add POST /api/connect/ai/inference and POST /api/connect/ai/transcription
  • add typed inference/transcription calls and errors to @bb/connect-client
  • add experimental Cloud AI provider registration to the plugin SDK
  • allow sidebar actions to open a specific plugin settings section
  • add cloudAiEnabled to Connect status, setCloudAi RPC, and bb connect ai [on|off]
  • preserve the internal plugin id, RPC paths, storage namespace, and bb connect compatibility
  • no host-daemon wire/protocol change

Data model

  • add local SQLite system_experiments.cloud_ai, non-null with a false default
  • add D1 ai_usage, keyed by user and UTC day, storing estimated aggregate spend in micro-USD
  • reserve usage atomically before the upstream call and refund failed upstream calls best-effort
  • store no prompts, schemas, responses, diffs, or audio
  • retain the plugin KV preference cloudAiEnabled, defaulting to true when absent, as the inner routing switch

Lifecycle and fallback

  • effective Cloud routing requires the outer experiment, the inner plugin preference, a live pairing, no quota cooldown, and an accepted credential
  • disabling the experiment hides AI Gateway and prevents server routing without affecting Remote access
  • Cloud failures and provider bugs fall back to local providers; timeouts preserve existing host timeout semantics
  • rejected credentials remain latched until re-pairing supplies a different credential; quota exhaustion pauses attempts for five minutes
  • disabling the Cloud plugin cuts off Remote access and AI Gateway together

Verification

  • affected-package Turbo test/typecheck matrix: 26/26 tasks passed
  • includes app, server, CLI, Connect worker/client/database, domain, plugin SDK, templates, web, and Connect plugin suites

@ymichael
ymichael force-pushed the bb/plan-for-metadata-inference-thr_ujvarx7qmi branch 5 times, most recently from 7ec0718 to 957737d Compare August 7, 2026 17:21
@ymichael
ymichael force-pushed the bb/plan-for-metadata-inference-thr_ujvarx7qmi branch from 60fdd90 to 705d727 Compare August 7, 2026 23:06
@ymichael ymichael changed the title Route AI features through bb Cloud Add the Cloud plugin and AI Gateway Aug 7, 2026
@ymichael
ymichael changed the base branch from main to bb/local-cloud-development August 7, 2026 23:07
@ymichael
ymichael force-pushed the bb/local-cloud-development branch from bbf0b34 to be8e538 Compare August 8, 2026 00:01
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