Adds an opt-in agent integration surface that lets a trusted external
tool (running as the same logged-in user) drive the running WWV browser
session — fly the globe, toggle layers, focus entities — by POSTing
JSON actions to the server, which fans them out over SSE to every
connected browser tab belonging to that user.
The motivating use case is an MCP server (a Model Context Protocol
adapter): an LLM agent calls a tool like `globe_fly_to({lat, lon})`,
the MCP server posts to `/api/agent/publish`, the browser subscriber
re-emits the action onto the existing client-side `dataBus`, and the
React + Cesium app handles it the same way it would handle any UI
button click. Read-only camera / engine queries already work via the
existing REST surface — this PR adds the missing write path.
What's added:
- `src/lib/agent/bus.ts` — process-local AgentBus singleton, scoped
per user. Subscriptions live in a `Map<userId, Map<connId, sub>>`
so user A's publish never reaches user B's stream, even though
both run on the same Node process.
- `src/app/api/agent/stream/route.ts` — SSE channel. Auth-gated. Sends
initial `:connected` + `retry:3000` directives and a `:hb` heartbeat
every 25s so intermediary proxies (Caddy, Nginx, CDNs) don't tear
down a "stalled" connection.
- `src/app/api/agent/publish/route.ts` — POST endpoint. Accepts JSON
AgentAction shapes (`fly_to`, `face_towards`, `layer_toggle`,
`highlight_layer`, `select_entity`, `ping`), broadcasts only to the
publishing user's bus bucket. Returns `{delivered, subscribers}` so
the caller knows how many tabs received the command.
- `src/components/layout/AgentBusSubscriber.tsx` — browser EventSource
client. Re-emits received actions onto `dataBus` (`cameraGoTo`,
`cameraFaceTowards`, `layerToggled`, `entitySelected`) — every plugin
is already listening on those channels, so no plugin changes needed.
- `AppShell.tsx` — mounts `AgentBusSubscriber` next to the existing
`DataBusSubscriber`. Two lines.
- `src/app/api/build/route.ts` — `/api/build` returns build id +
timestamp + public flag state. Pairs with a one-line console.log
the subscriber prints on mount so a stale-bundle / config-mismatch
is visible at a glance instead of looking like a feature regression.
Default off via `NEXT_PUBLIC_WWV_AGENT_BUS_ENABLED=true`. An unintended
deployment doesn't open a remote-control channel for users who didn't
opt in.
What's changed in the Dockerfile:
- Adds ARG declarations for the new vars (`NEXT_PUBLIC_WWV_AGENT_BUS_ENABLED`,
`NEXT_PUBLIC_WWV_BUILD_ID`, `NEXT_PUBLIC_WWV_BUILD_AT`).
- Stamps the build with millisecond-precision id + ISO timestamp
(`/app/.build-id`, `/app/.build-at`); both copied into the runner
stage for `/api/build` to read.
- Writes `/app/.env.production.local` from declared ARGs *before*
`next build` runs. Docker doesn't reliably promote ARGs into the
Node child-process environment for the build command, so
`process.env.NEXT_PUBLIC_*` references that previously inlined
through Webpack's DefinePlugin sometimes fell back to runtime
polyfill access (`tV.env.NEXT_PUBLIC_X`) that resolves to `undefined`
in the browser. Writing the env file is the documented Next.js path
and behaves the same on every host.
Default-off, no schema changes, no plugin changes, fully backwards-compatible
on operators who don't opt in.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- fix(build): Add pnpm override for @spz-loader/core to 0.3.0 to bypass Octal escape sequences error during build
- feat(healthcheck): Add /api/health endpoint and HEALTHCHECK directive to Dockerfile and docker-compose.yml for Coolify monitoring
- refactor(build): Remove Sentry config from next.config.ts to avoid webpack plugin conflicts with wasm compilation
* fix(core): install prisma globally in docker to prevent offline network failures [Patch]
* fix(core): allow universal CORS access in marketplace [Patch]
- allow any origin in marketplace bridge to ensure universal connectivity [Patch]
- remove dead origin filter code [Patch]
- bump version to 1.20.5 [Patch]
`PluginManager.registerPlugin` builds `ctx.env` for each plugin by iterating
`Object.entries(process.env)` and copying entries whose keys start with
`NEXT_PUBLIC_WWV_PLUGIN_`. In the browser bundle this loop comes back
empty even when those vars are set at build time, because Next.js only
inlines `process.env.NEXT_PUBLIC_*` at *static reference sites* — and
`Object.entries(process.env)` isn't a static reference. The result: any
plugin reading `ctx.env.SOMETHING` to override a default URL silently
gets `undefined` and falls back to its hardcoded cloud URL.
Concrete impact: setting `NEXT_PUBLIC_WWV_PLUGIN_DATA_ENGINE_URL` to a
self-hosted data-engine URL has no effect on the marketplace plugins that
read `ctx.env.DATA_ENGINE_URL` (e.g. `wwv-plugin-aviation`) — they keep
calling `https://dataengine.worldwideview.dev/data/...` even when the
operator has explicitly redirected away from it.
Add explicit static references so the values land in `envVars`. Done as
a small allow-list (currently just `DATA_ENGINE_URL`) so adding new keys
is one line.
Also declare `ARG NEXT_PUBLIC_WWV_PLUGIN_DATA_ENGINE_URL` in the
Dockerfile next to the existing public-arg block. Without it, the build
arg passed in via compose isn't visible to Next.js at build time, so
Webpack inlines `undefined` even when the operator sets the env var.
Co-authored-by: Sapphire <sapphire@tiktokcoach>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
* feat(cloud): implement Postgres DB adapter, fix static build crashes, and containerize NextAuth/Stripe integrations
* test(marketplace): fix mocks and assertions for multi-tenant Postgres architecture
* feat: rsa jwt license key verification and state integration
* feat: add internal workspace validation route for Edge Functions
* refactor: clean up hub routes and finalize db proxy/adapter for multi-tenant cloud deploy
* feat(cloud): finalize multi-tenant Prisma extensions and workspace routing
* fix(db): correct Prisma 7 better-sqlite3 adapter initialization [Patch]
- update better-sqlite3 adapter instantiation to use configuration object ({ url }) required by Prisma 7 instead of raw Database instance [Patch]
- fix PrismaClientConstructorValidationError by generating client with adapter support [Patch]
* fix(auth): support dynamic origins for local proxies and multi-tenant subdomains [Patch]
- prioritize forwarded headers and request host over hardcoded envOrigin in getRequestOrigin to support subdomain routing [Patch]
- allow ALLOWED_DEV_ORIGIN in marketplace install redirect checks to fix local network development login flows [Patch]
* fix(marketplace): enable dynamic CORS reflection for marketplace API [Patch]
- remove explicit origin array, replacing with origin header reflection to allow marketplace hosted on any domain or local IP [Patch]
- remove global wildcard CORS headers from next.config.ts to harden security against broader app injection [Patch]
* feat(db): create initial postgresql migration
* refactor(db): update remaining files for postgresql
* feat(db): unify database adapter to PostgreSQL-only [Minor]
- replace SQLite adapter with PostgreSQL PrismaPg [Minor]
- remove better-sqlite3 dependencies [Patch]
- finalize docs and implementation plan [Patch]
* fix: resolve prisma client generation and script execution issues with tsx and type module
* feat(db): port tenant isolation logic to new PostgreSQL adapter
* docs: add rule for transparent and narrated agent actions
* BREAKING CHANGE(core): migrate to PostgreSQL and add auto-migration pipeline [Major]
- unified database adapter to exclusively use PostgreSQL [Major]
- implement auto-migration pipeline to pipe legacy SQLite data to Postgres [Major]
- add sqlite to runner stage to support extraction pipeline [Patch]
* feat(core): migrate to Prisma 7 and unify PostgreSQL architecture [Minor]
- removed legacy Prisma SQLite driver and all Better-Sqlite dependencies [Minor]
- updated schema to utilize purely postgresql providers [Patch]
- modified migration scripts to seamlessly convert local sqlite DBs to PostgreSQL containers using keinos/sqlite3 [Minor]
- updated deployment scripts, Coolify pipelines, and Nginx proxy support [Patch]
- injected Prisma Client Extensions for multi-tenant Row Level Security isolation [Minor]
- stabilized PrismaClient initialization utilizing the official adapter-pg runtime pattern [Patch]
- bumped version to 2.1.0
* fix(core): resolve TypeScript compilation errors for CI [Patch]
- fixed NextResponse.json() 3-arg calls to use 2-arg ResponseInit form [Patch]
- replaced invalid 'developer' TrustTier with 'unverified' in parseWwvManifest and load-unpacked route [Patch]
- removed non-existent pluginManager.hotReload() call in DevModeSubscriber, replaced with disable/reload cycle [Patch]
- updated Stripe API version from '2024-04-10' to '2026-04-22.dahlia' to match installed SDK [Patch]
- excluded local-scripts/ from tsconfig to prevent debug scripts from breaking CI [Patch]
* fix(ci): resolve pnpm version conflict in GitHub Actions [Patch]
- removed explicit version: 9 from pnpm/action-setup@v4 — v4 auto-reads packageManager from package.json [Patch]
- updated build job DATABASE_URL from SQLite to PostgreSQL format [Patch]
* fix(docker): add explicit Prisma generator output path for Docker builds [Patch]
- Prisma 7 changed default output location, causing COPY --from=builder to fail
- added output = '../src/generated/prisma' to generator block for consistency
* fix(prisma): update client import path and resolve CI type errors [Patch]
- updated PrismaClient import in db.ts to point to custom generated output path
- resolved implicit 'any' error in marketplace check-updates route
- verified clean local build with tsc --noEmit
* chore(deps): sync Prisma versions to 7.6.0 [Patch]
* feat: implement local docker HTTPS proxy for marketplace bridge
Generates self-signed certs automatically in docker-entrypoint and spins up a native Node HTTPS proxy on port 3001 to resolve Firefox Mixed Content blocks when fetching from local containers via the live marketplace.
* fix(core): fix docker build and marketplace origin parsing [Patch]
- fix pnpm run generate script failure in Dockerfile [Patch]
- implement robust origin parsing for marketplace endpoints [Patch]
- Add prisma package to serverExternalPackages in next.config.ts
- Replace manual node_modules cherry-picking with full production install
- Copy pre-built node_modules from deps stage and prune dev dependencies
- Ensures all Prisma CLI runtime dependencies are always available
- Remove CopyPlugin from next.config.ts (was copying Cesium assets during
webpack build, causing Next.js to trace thousands of files and OOM/timeout)
- Add outputFileTracingExcludes for public/cesium/**
- Copy Cesium assets via copy-cesium.mjs after build in Dockerfile instead