Mobile Runtime

Cloud Mobile Bridge

Hosted NyrA bridge for Android/browser swarm chat, tenant-scoped adaptive routing, voice setup, support logs, and updates. Source folder: cloud/mobile-bridge-worker.

Mobile Bridge Handoff Form

Cloud plan

Hosted Bridge Snapshot

Worker URL https://bridge.porterlabz.com Ready
Secret status Deployed Worker token verified Ready
Provider secrets Full swarm deployed Worker verified Ready
Routing D1 nyra-swarm-memory Ready
Routing learning Durable tenant isolation verified Ready
Routing privacy 7 day retention; stores user content=false Ready
Support logs R2 nyra-mobile-support-logs Ready
Android releases R2 nyra-android-releases Ready
APK R2 key alpha/0.1.0-alpha.83/NyrA.apk Ready
Bundled bridge https://bridge.porterlabz.com Ready
Phone self-test Emulator evidence 2026-07-15T10:36:06.054Z (0.1.0-alpha.83 / 83); reportPassed=yes; 10 pass / 1 warn / 0 fail; supportLogId=2026-07-15T10-36-20-680Z-a65ac36a-0ba2-4041-88d6-54e9860ba690. This does not clear the physical-phone gate. Needs input

Current Internal Hosted Alpha

npm run alpha:hosted

Temporary phone-testing host. This proves Android can reach the swarm bridge and download the current APK, but it is not the permanent paid-beta Worker.

Alpha host status HOSTED_ALPHA_READY Ready
Public test URL https://bridge.porterlabz.com Ready
Providers ready 4/4 Ready
APK proof b92bbedcc86066f17edc620a105b04a6cdbd284b6d767abdb1b88ecfb07791b0 Ready
Support-log proof 2026-07-17T04-53-44-939Z-4ef1c4c3-4c15-45d9-80ac-4a7365b366d2 Ready
Alpha version 0.1.0-alpha.83 (83) Ready
Token handling stored locally only Ready

Route Contract

npm run cloud:mobile-bridge:check

These routes mirror the local mobile bridge so Android can switch from tunnel/local PC to a stable HTTPS Worker URL without app-side route changes.

RouteRuntime Use
GET /healthPublic health or compatibility route.
GET /api/nyra/model-policySanitized, cacheable benchmark policy for task-aware model routing.
GET /api/nyra/model-policy/v2Sanitized, cacheable benchmark policy for task-aware model routing.
GET /api/nyra/statusProvider readiness and hosted bridge health for app settings.
POST /api/nyra/tester/enrollAllowlisted internal tester enrollment for passwordless device access.
GET /api/nyra/update/latestAndroid update metadata and hosted APK pointer.
POST /api/nyra/update/android/download-ticketShort-lived APK installer ticket for paid device-token update downloads.
GET /api/nyra/update/android/apkHosted Android APK download route for app updates.
HEAD /api/nyra/update/android/apkAPK metadata probe for phone self-tests without a full download.
POST /api/nyra/chatSwarm chat path with Captain/Crew council routing for deep requests.
POST /api/nyra/cancelCompatibility cancel acknowledgement for stateless Worker requests.
POST /api/nyra/transcribe-audioOne-shot voice fallback transcription.
POST /api/nyra/tts-audioText-to-speech audio fallback.
POST /api/nyra/realtime-client-secretRealtime voice ephemeral secret setup.
POST /api/nyra/logsRedacted support diagnostics upload and readback through R2.
GET /api/nyra/logsRedacted support diagnostics upload and readback through R2.
GET /api/nyra/logs/:idRedacted support diagnostics upload and readback through R2.

Secret Store Requirements

Never paste raw API keys or bridge tokens into dashboard fields. Save status here, set real values with Wrangler or Cloudflare dashboard secrets.

SecretStatusWhere It Belongs
NYRA_MOBILE_BRIDGE_TOKENSecret storeSet with Wrangler secrets only.
NYRA_OPENAI_API_KEYSecret storeSet with Wrangler secrets only.
NYRA_ANTHROPIC_API_KEYSecret storeSet with Wrangler secrets only.
NYRA_GEMINI_API_KEYSecret storeSet with Wrangler secrets only.
NYRA_GROK_API_KEYSecret storeSet with Wrangler secrets only.
NYRA_LICENSE_SIGNING_SECRETSecret storeSet with Wrangler secrets only.
NYRA_ANDROID_DOWNLOAD_TICKET_SECRETSecret storeSet with Wrangler secrets only.

Bootstrap Plan

npm run cloud:mobile-bridge:bootstrap

This is the executable path from local/tunnel phone testing to a durable HTTPS Worker with R2-hosted APK updates and support-log readback.

Bootstrap status MOBILE_BRIDGE_BOOTSTRAP_PLANNED Planned
Dry run True Dry run only
Deploy skipped True Skipped
Worker URL https://bridge.porterlabz.com Planned
APK key alpha/0.1.0-alpha.83/NyrA.apk Planned
Post-Deploy Verification Full deploy required Needs input
APK SHA b92bbedcc86066f17edc620a105b04a6cdbd284b6d767abdb1b88ecfb07791b0 Ready
StepCommandNote
check-routesnpm.cmd run cloud:mobile-bridge:checkRun from npm before deploy.
whoamiC:\Program Files\nodejs\node.exe <repo>\node_modules\wrangler\bin\wrangler.js whoamiConfirms Cloudflare auth.
create-support-r2C:\Program Files\nodejs\node.exe <repo>\node_modules\wrangler\bin\wrangler.js r2 bucket create nyra-mobile-support-logs
create-android-r2C:\Program Files\nodejs\node.exe <repo>\node_modules\wrangler\bin\wrangler.js r2 bucket create nyra-android-releases
upload-apkC:\Program Files\nodejs\node.exe <repo>\node_modules\wrangler\bin\wrangler.js r2 object put nyra-android-releases/alpha/0.1.0-alpha.83/NyrA.apk --file <repo>\release\current\android\NyrA.apk --remote

Hosted Alpha Report

Hosted Alpha Status

Status: HOSTED_ALPHA_READY

Generated: 2026-07-17T04:53:45.084Z

This internal Android alpha is hosted by the durable bridge.porterlabz.com Worker with its token-free APK in R2. It is not customer-ready until customer authentication, physical-phone proof, and trusted distribution are complete.

Current Public Test URL

Health

Providers

No-Go Boundary

Bootstrap Report

Mobile Bridge Cloud Bootstrap

Status: MOBILE_BRIDGE_BOOTSTRAP_PLANNED

Generated: 2026-07-18T13:37:03.171Z

This prepares the durable Cloudflare Worker bridge that replaces the temporary trycloudflare tunnel for Android chat, updates, support logs, and phone self-tests.

APK

Non-Secret Config

Worker Config

Command Center State

Post-Deploy Verification

Step Status

Secret Status

No-Secret Rule

Raw bridge/provider secrets are only read from process environment or approved local env files, then sent to Wrangler stdin. They are not written to reports, dashboard state, configs, or source files.

README

NyrA Mobile Bridge Worker

This Worker is the durable hosted replacement for the temporary local/tunnel mobile bridge. It exposes the same /api/nyra/* route contract already used by the Android and browser surfaces, so phones can keep using NyrA chat, provider status, app updates, realtime setup, audio fallback, and support-log upload after the development PC is offline.

Local Checks

npm run cloud:mobile-bridge:check
npm run test:cloud-mobile-bridge
npm run cloud:mobile-bridge:bootstrap -- --dry-run --skip-secrets --skip-deploy

Deploy Path

  1. Create or confirm the Cloudflare account and route for the hosted bridge, for example https://bridge.porterlabz.com.
  2. Run the bootstrap dry run and inspect docs/launch_command_center/MOBILE_BRIDGE_CLOUD_BOOTSTRAP.md.
  3. Confirm the nyra-swarm-memory D1 database exists. The production SWARM_DB binding in wrangler.jsonc must point to it.
  4. Run the full bootstrap after Wrangler is authenticated. It applies all D1 migrations before deploying:
npm run cloud:mobile-bridge:bootstrap -- --worker-url=https://bridge.porterlabz.com --write-state
  1. Only the full bootstrap can update command-center deployment facts. Dry runs never write stable bridge values into command-center-state.json, even if --write-state is passed.
  2. A full bootstrap runs post-deploy verification before writing state: /health, authenticated status, update metadata, APK HEAD, support-log upload/list/readback, and a live chat smoke must pass.
  3. If secrets already exist in Cloudflare, use --skip-secrets and set only missing secrets manually.
  4. Replace the production bucket_name values only if the deployed bucket names differ.
  5. Save the deployed bridge URL in the command center and in Android build/runtime settings.
  6. Run a phone self-test from Settings > Updates > Bridge self-test.

The bootstrap creates the support-log and Android-release R2 buckets when needed, uploads the current signed APK to R2, writes non-secret Worker vars for the current APK SHA/version, and can deploy the Worker. It never writes raw bridge/provider secrets to reports, dashboard state, configs, or source files.

Routing Learning Storage

SWARM_DB is a D1 binding for tenant-scoped adaptive routing outcomes. Each authenticated account gets an irreversible SHA-256 tenant identifier. NyrA retains up to seven days of task category, provider, model, success/failure, latency, token counts, and an outcome code so future Worker isolates can choose better routes from measured results.

The table does not store prompts, answers, transcripts, email addresses, screenshots, files, API keys, bridge tokens, or other user content. GET /api/nyra/status reports routingLearning.storage: d1, durable: true, and storesUserContent: false when durable learning is active. If D1 is unavailable, chat remains fail-open with isolated in-memory routing evidence and status reports the degraded storage state.

For a manual production migration and deploy:

npm run cloud:mobile-bridge:migrate
npm run cloud:mobile-bridge:deploy

Secret Setup

npx wrangler secret put NYRA_MOBILE_BRIDGE_TOKEN --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_OPENAI_API_KEY --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_ANTHROPIC_API_KEY --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_GEMINI_API_KEY --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_GROK_API_KEY --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_LICENSE_SIGNING_SECRET --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_ANDROID_DOWNLOAD_TICKET_SECRET --cwd cloud/mobile-bridge-worker --env production

Routes

  • GET /health: public structural health check with storage/auth configuration only.
  • GET /api/nyra/model-policy/v2: current public cacheable quality-gated routing policy without credentials or user data.
  • GET /api/nyra/model-policy: legacy policy URL retained for older clients.
  • GET /api/nyra/status: authenticated provider readiness and hosted bridge status.
  • POST /api/nyra/tester/enroll: authenticated allowlisted internal-tester device enrollment.
  • GET /api/nyra/update/latest: authenticated Android update metadata.
  • POST /api/nyra/update/android/download-ticket: authenticated short-lived Android APK download ticket for paid/device-token installs.
  • GET /api/nyra/update/android/apk: authenticated Android APK download. Streams from the ANDROID_RELEASES R2 bucket when NYRA_ANDROID_UPDATE_APK_R2_KEY is set, or redirects to an absolute NYRA_ANDROID_UPDATE_APK_URL.
  • HEAD /api/nyra/update/android/apk: authenticated APK metadata probe for phone self-tests without downloading the APK.
  • POST /api/nyra/chat: authenticated swarm chat with Captain/Crew council routing for deeper prompts.
  • POST /api/nyra/cancel: compatibility route. Hosted Workers are stateless per request, so this acknowledges but cannot cancel a completed fetch after the HTTP request is gone.
  • POST /api/nyra/transcribe-audio: authenticated OpenAI transcription fallback.
  • POST /api/nyra/tts-audio: authenticated OpenAI text-to-speech fallback.
  • POST /api/nyra/realtime-client-secret: authenticated OpenAI realtime ephemeral secret setup.
  • POST /api/nyra/logs: authenticated redacted support diagnostics upload to R2.
  • GET /api/nyra/logs and GET /api/nyra/logs/:id: authenticated support-log listing/readback for Codex debugging.

No-Go Rules

  • Do not deploy with ALLOW_DEV_OPEN_API=true in production.
  • Do not ship a production Android build with a shared bridge token as customer authentication. Paid/customer builds must use the billing device access token plus short-lived APK download tickets.
  • Do not store raw chats, API keys, card data, passwords, screenshots, or unrestricted transcripts in support logs.
  • Do not claim phone/computer control is production-ready until Android accessibility, screen capture, and high-impact consent gates pass on the final build.

Deployment Checklist

NyrA Mobile Bridge Deployment Checklist

Preflight

  • cloud/mobile-bridge-worker/wrangler.jsonc has nodejs_compat, observability, production ALLOWED_ORIGIN, the SUPPORT_LOGS and ANDROID_RELEASES R2 bindings, and the SWARM_DB D1 binding.
  • The nyra-swarm-memory D1 database exists and 0001_tenant_routing_outcomes.sql is present.
  • ALLOW_DEV_OPEN_API is false in production.
  • NYRA_MOBILE_BRIDGE_TOKEN is set through Wrangler secrets.
  • NYRA_LICENSE_SIGNING_SECRET matches the billing worker so paid device access tokens can authenticate to the bridge.
  • NYRA_ANDROID_DOWNLOAD_TICKET_SECRET is set through Wrangler secrets for short-lived APK installer links.
  • Provider secrets are set through Wrangler secrets: OpenAI, Anthropic, Gemini, and Grok/xAI.
  • Android update metadata vars are set if this Worker is the hosted update source.
  • The Android APK is either uploaded to the ANDROID_RELEASES R2 bucket with NYRA_ANDROID_UPDATE_APK_R2_KEY, or NYRA_ANDROID_UPDATE_APK_URL is an absolute external HTTPS URL.

Commands

npm run cloud:mobile-bridge:bootstrap -- --dry-run --skip-secrets --skip-deploy
npm run cloud:mobile-bridge:check
npx wrangler r2 bucket create nyra-mobile-support-logs
npx wrangler r2 bucket create nyra-android-releases
npx wrangler secret put NYRA_MOBILE_BRIDGE_TOKEN --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_OPENAI_API_KEY --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_ANTHROPIC_API_KEY --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_GEMINI_API_KEY --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_GROK_API_KEY --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_LICENSE_SIGNING_SECRET --cwd cloud/mobile-bridge-worker --env production
npx wrangler secret put NYRA_ANDROID_DOWNLOAD_TICKET_SECRET --cwd cloud/mobile-bridge-worker --env production
npm run cloud:mobile-bridge:migrate
npm run cloud:mobile-bridge:deploy

After Cloudflare authentication is working and secrets are available in environment variables, the preferred one-command path is:

npm run cloud:mobile-bridge:bootstrap -- --worker-url=https://bridge.porterlabz.com --write-state

Use --skip-secrets only when the Cloudflare Worker secrets have already been set manually. The bootstrap report is written to docs/launch_command_center/MOBILE_BRIDGE_CLOUD_BOOTSTRAP.md and docs/launch_command_center/mobile-bridge-cloud-bootstrap.json.

Dry runs are plan-only and cannot write deployment facts into docs/launch_command_center/command-center-state.json, even when --write-state is passed.

Full bootstrap state writes require post-deploy verification: /health, authenticated status, update manifest, APK HEAD, support-log roundtrip, and chat smoke.

Post-Deploy Verification

  • GET /health returns service: nyra-mobile-bridge-api.
  • GET /health reports storage.swarmRoutingD1: true.
  • GET /api/nyra/status rejects missing tokens.
  • GET /api/nyra/status with X-NyrA-Bridge-Token shows provider readiness without returning secret values.
  • GET /api/nyra/status with a signed paid device access token succeeds without X-NyrA-Bridge-Token.
  • Authenticated status reports routingLearning.storage: d1, durable: true, scope: tenant, and storesUserContent: false.
  • A chat outcome remains available to the same tenant in a fresh Worker isolate and is absent from a different tenant.
  • POST /api/nyra/chat returns text and provider/model route metadata.
  • GET /api/nyra/update/latest returns the alpha version, version code, SHA, and APK route or absolute APK URL.
  • POST /api/nyra/update/android/download-ticket returns a short-lived APK URL for Android installer handoff.
  • GET /api/nyra/update/android/apk downloads an APK or redirects to the configured absolute APK URL.
  • HEAD /api/nyra/update/android/apk returns APK content metadata for phone self-tests without a full download.
  • POST /api/nyra/logs, GET /api/nyra/logs, and GET /api/nyra/logs/:id round-trip a redacted diagnostics bundle through R2.
  • Android Settings > Updates bridge self-test reaches the deployed URL.

Wrangler Config

{
  "$schema": "../../node_modules/wrangler/config-schema.json",
  "name": "nyra-mobile-bridge-api",
  "main": "src/index.mjs",
  "compatibility_date": "2026-06-09",
  "compatibility_flags": [
    "nodejs_compat"
  ],
  "observability": {
    "enabled": true
  },
  "vars": {
    "ALLOWED_ORIGIN": "http://localhost:5173",
    "ALLOW_DEV_OPEN_API": "false",
    "NYRA_TESTER_EMAILS": "porter4040@gmail.com",
    "NYRA_ADMIN_TESTER_EMAIL": "porter4040@gmail.com",
    "NYRA_TESTER_DEVICE_TOKEN_SECONDS": "2592000",
    "NYRA_ANDROID_UPDATE_CHANNEL": "alpha"
  },
  "d1_databases": [
    {
      "binding": "SWARM_DB",
      "database_name": "nyra-swarm-memory",
      "database_id": "5fa71710-ce4f-432f-a031-a36d8a28d317",
      "migrations_dir": "migrations"
    }
  ],
  "r2_buckets": [
    {
      "binding": "SUPPORT_LOGS",
      "bucket_name": "nyra-mobile-support-logs"
    },
    {
      "binding": "ANDROID_RELEASES",
      "bucket_name": "nyra-android-releases"
    }
  ],
  "env": {
    "local": {
      "vars": {
        "ALLOWED_ORIGIN": "http://localhost:5173",
        "ALLOW_DEV_OPEN_API": "true",
        "NYRA_TESTER_EMAILS": "porter4040@gmail.com",
        "NYRA_ADMIN_TESTER_EMAIL": "porter4040@gmail.com",
        "NYRA_TESTER_DEVICE_TOKEN_SECONDS": "2592000",
        "NYRA_ANDROID_UPDATE_CHANNEL": "alpha"
      },
      "d1_databases": [
        {
          "binding": "SWARM_DB",
          "database_name": "nyra-swarm-memory",
          "database_id": "5fa71710-ce4f-432f-a031-a36d8a28d317",
          "migrations_dir": "migrations"
        }
      ],
      "r2_buckets": [
        {
          "binding": "SUPPORT_LOGS",
          "bucket_name": "nyra-mobile-support-logs"
        },
        {
          "binding": "ANDROID_RELEASES",
          "bucket_name": "nyra-android-releases"
        }
      ]
    },
    "production": {
      "routes": [
        {
          "pattern": "bridge.porterlabz.com",
          "custom_domain": true
        }
      ],
      "vars": {
        "ALLOWED_ORIGIN": "https://porterlabz.com",
        "ALLOW_DEV_OPEN_API": "false",
        "NYRA_TESTER_EMAILS": "porter4040@gmail.com",
        "NYRA_ADMIN_TESTER_EMAIL": "porter4040@gmail.com",
        "NYRA_TESTER_DEVICE_TOKEN_SECONDS": "2592000",
        "NYRA_ANDROID_UPDATE_CHANNEL": "alpha",
        "NYRA_ANDROID_UPDATE_VERSION": "0.1.0-alpha.83",
        "NYRA_ANDROID_UPDATE_VERSION_CODE": "83",
        "NYRA_ANDROID_UPDATE_APK_R2_KEY": "alpha/0.1.0-alpha.83/NyrA.apk",
        "NYRA_ANDROID_UPDATE_APK_FILENAME": "NyrA.apk",
        "NYRA_ANDROID_UPDATE_SHA256": "b92bbedcc86066f17edc620a105b04a6cdbd284b6d767abdb1b88ecfb07791b0",
        "NYRA_ANDROID_UPDATE_NOTES": "Builds the current Android app code as an installable alpha release APK.|Current alpha signing material is stored outside the repo under the Windows user profile.|Internal alpha APKs can include the hosted mobile bridge URL and token from local runtime handoff files so remote phones connect without manual bridge setup.|If a phone has an older NyrA APK signed by a different certificate, Android requires uninstalling that build before installing this signer lineage."
      },
      "d1_databases": [
        {
          "binding": "SWARM_DB",
          "database_name": "nyra-swarm-memory",
          "database_id": "5fa71710-ce4f-432f-a031-a36d8a28d317",
          "migrations_dir": "migrations"
        }
      ],
      "r2_buckets": [
        {
          "binding": "SUPPORT_LOGS",
          "bucket_name": "nyra-mobile-support-logs"
        },
        {
          "binding": "ANDROID_RELEASES",
          "bucket_name": "nyra-android-releases"
        }
      ]
    }
  }
}