feat(dev): public-URL gravity tunnel + @agentuity/vite plugin (blocked on infra#210)#1455
Draft
Huijiro wants to merge 3 commits into
Draft
feat(dev): public-URL gravity tunnel + @agentuity/vite plugin (blocked on infra#210)#1455Huijiro wants to merge 3 commits into
Huijiro wants to merge 3 commits into
Conversation
Reintroduces v2's `agentuity dev --public` workflow for v3, adapted
to the new framework-passthrough architecture.
New package
- @agentuity/vite: a Vite plugin that reads
AGENTUITY_DEVMODE_HOSTNAME (set by the CLI when --public is on)
and configures `server.allowedHosts` + `server.hmr` so Vite
accepts requests from the gravity tunnel and HMR works over wss://
through the tunnel. No-op when the env var is absent.
Dev command
- New --public / --no-public flags. On first run with no saved
preference and a TTY, prompt (default no) and persist the answer
to `agentuity.json` under `devmode.public`. Non-TTY defaults to
off.
- When public is on, hard-fail without a registered project (point
at `agentuity project import`) or valid auth (point at
`agentuity auth login`).
- When public is on:
1. Reserve a devmode endpoint via /cli/devmode/3/<projectId>
(re-using the saved hostname + private key for stability).
2. Download the gravity binary if missing or stale (re-uses the
cached version under `~/.config/agentuity/gravity`).
3. Spawn gravity targeting the user's dev port; tail its
HEARTBEAT_PORT line and POST /heartbeat every 5s; forward
stderr to the CLI logger.
4. Export AGENTUITY_DEVMODE_HOSTNAME / AGENTUITY_DEVMODE_URL
into the dev process so framework plugins can react.
5. SIGTERM the gravity process group on shutdown.
- Detect Vite-based projects without @agentuity/vite installed and
print a one-line install reminder.
- New banner shows Local + Public URLs side-by-side.
Supporting changes
- ProjectSchema gains `devmode.public?: boolean`.
- Config types already had `devmode.hostname` / `devmode.privateKey`
/ `gravity.version` / `overrides.gravity_url` — wired up.
- api.ts: getGravityDevModeURL(region, config).
- runtime.ts: validateGravityRequiresUpgrade(version) with
MIN_GRAVITY_VERSION = >=1.0.6.
- dev/api.ts (generateEndpoint), dev/download.ts (gravity tarball),
dev/gravity.ts (lifecycle orchestrator) — all Node-compatible
(node:child_process / node:fs / fetch).
Scaffolding
- vite-react / sveltekit / astro templates now include
@agentuity/vite as a devDependency.
- vite-react ships the plugin pre-wired in vite.config.ts.
- sveltekit / astro users get the dev --public reminder until they
add `agentuity()` to their config.
Cleanup
- Drop stale `./vite-plugin` export from packages/cli/package.json
(the file under dist/cmd/build/vite/ no longer exists).
End-to-end testing surfaced four mismatches with v2's behavior plus
a confirmed platform-side blocker.
Lifecycle/cleanup gaps fixed:
- Add killLingeringGravityProcesses() (pkill -f scoped to project
id) and call it before reserving a new endpoint, matching v2.
Without this, an orphan tunnel from a prior aborted dev session
could still be holding the public URL.
- Expose forceKillSync() on the gravity handle and register it in a
process.on('exit') hook so a terminating CLI sends SIGKILL to the
gravity process group as a last resort. Async stop() runs first
during normal shutdown.
- Sweep old gravity binary versions only AFTER the new version has
reported its first heartbeat (handle.ready). Previous timer-based
approach could discard the working fallback before confirming the
new one connects.
- Signal handler for SIGINT/SIGTERM now fires gravity.stop() in
parallel with proc.kill() instead of waiting for the framework to
exit first. Matches v2's procManager.cleanup() behavior.
Platform issue:
- /cli/devmode/3 issues hostnames in `*.agentuity.live` (no DNS) for
v3-shaped User-Agents and `*.agentuity-us.live` (works) for v2 /
curl. Filed agentuity/infra#210. Added doc-comment in api.ts
pointing at the tracking issue.
Until #210 is fixed the public URL prints but doesn't resolve. The
SDK-side wiring (banner, endpoint reservation, gravity spawn,
shutdown, env injection for @agentuity/vite) is all working.
|
The latest Agentuity deployment details.
|
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
📦 Canary Packages Publishedversion: PackagesInstallAdd to your {
"dependencies": {
"@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-server-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-webhook-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-postgres-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-migrate-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/local": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-local-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/coder-tui": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-coder-tui-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-schedule-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/vite": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-vite-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/storage": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-storage-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/telemetry": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-telemetry-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-runtime-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-db-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/analytics": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-analytics-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-sandbox-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-vector-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-claude-code-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-opencode-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-coder-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-core-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-drizzle-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-email-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/aigateway": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-aigateway-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-queue-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/stream": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-stream-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-schema-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/adapter": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-adapter-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/hono": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-hono-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-cli-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-keyvalue-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/pi": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-pi-3.0.0-beta.6-cbbc716.tgz",
"@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-task-3.0.0-beta.6-cbbc716.tgz",
"create-agentuity": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/create-agentuity-3.0.0-beta.6-cbbc716.tgz"
}
}Or install directly: bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-server-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-webhook-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-postgres-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-migrate-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-local-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-coder-tui-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-schedule-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-vite-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-storage-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-telemetry-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-runtime-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-db-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-analytics-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-sandbox-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-vector-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-claude-code-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-opencode-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-coder-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-core-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-drizzle-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-email-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-aigateway-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-queue-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-stream-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-schema-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-adapter-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-hono-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-cli-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-keyvalue-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-pi-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/agentuity-task-3.0.0-beta.6-cbbc716.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.0.0-beta.6-cbbc716/create-agentuity-3.0.0-beta.6-cbbc716.tgz |
# Conflicts: # packages/cli/src/cmd/project/frameworks.ts # packages/cli/src/cmd/project/templates/vite-react/vite.config.ts
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.
Summary
Reintroduces v2's
agentuity dev --publicworkflow on v3, adapted to the framework-passthrough architecture, plus a new@agentuity/viteplugin so Vite-based projects work through the public URL without the user editing their config.Status: blocked on agentuity/infra#210. The SDK side is done and tested end-to-end; the public URL prints, gravity connects, the framework starts behind it, and shutdown cleans up. The URL itself just doesn't resolve because the platform issues hostnames in a DNS zone that isn't wired up for v3-shaped User-Agents.
Parked here until the platform fix lands; then this is a clean merge into v3.
What lands
New package:
@agentuity/viteA Vite plugin that reads
AGENTUITY_DEVMODE_HOSTNAME(set by the CLI when--publicis on) and configures Vite for the gravity tunnel:server.allowedHostsso Vite stops responding with "Blocked request"server.hmratwss://<hostname>:443so HMR works for users browsing the public URLNo-op when the env var is absent; safe to keep in
vite.config.tspermanently.CLI:
agentuity dev --public/--no-publicagentuity.jsonunderdevmode.public). Non-TTY defaults to off.tui.fatalif no registered project (point atagentuity project import) or no valid auth (point atagentuity auth login).POST /cli/devmode/3/<projectId>, re-using saved hostname + private key for stability.~/.config/agentuity/gravity/<version>/gravity).HEARTBEAT_PORT=line; POST/heartbeatevery 5 s.AGENTUITY_DEVMODE_HOSTNAME/AGENTUITY_DEVMODE_URLinto the framework process.process.on('exit').@agentuity/viteinstalled and print a one-line install reminder.Schema + helpers
ProjectSchemagainsdevmode.public?: boolean.Config.devmode.{hostname,privateKey}andConfig.gravity.{version,checked}already existed in v3 — wired up.api.ts:getGravityDevModeURL(region, config).runtime.ts:validateGravityRequiresUpgrade(version)withMIN_GRAVITY_VERSION = >=1.0.6.node:child_process,node:fs/promises, plainfetch. NoBun.*calls.Scaffold integration
vite-react/sveltekit/astrotemplates add@agentuity/vitetodevDependencies.vite-reactships the plugin pre-wired invite.config.ts.sveltekit/astrousers get the runtime install reminder until they addagentuity()to their config.Cleanup
./vite-pluginexport frompackages/cli/package.json(the file underdist/cmd/build/vite/no longer exists in v3).Lifecycle/cleanup details
The second commit (
d9ac7a43) closes four gaps surfaced during end-to-end testing against v2:killLingeringGravityProcesses()(pkill -fscoped to project id) runs before reserving the new endpoint.gravity.forceKillSync()registered inprocess.on('exit')for last-resort SIGKILL.handle.ready(first heartbeat) instead of a 5 s timer.proc.kill()andgravity.stop()in parallel rather than sequentially.Testing
End-to-end tested against
~/Dev/agentuity/v3-test-projects/v3-node-nextjs(Next.js, regionuse):devmode.public: truesaved toagentuity.json)usc.yaml)forceKillSyncfix (orphan reproducible before, gone after)Blocker: agentuity/infra#210
POST /cli/devmode/3issues hostnames under*.agentuity.live(no wildcard DNS) forUser-Agent: Agentuity CLI/3.xand under*.agentuity-us.live(works, CNAMEs toion-usc.agentuity.cloud) for v2 / curl. Reproduced via rawcurlwith only the User-Agent differing. Tracking in agentuity/infra#210.A doc-comment in
packages/cli/src/cmd/dev/api.tsflags this for future maintainers.Compat / drop-in safety
--publicdefaults to off; no behavior change for users runningagentuity devwithout the flag.@agentuity/viteinvite.config.tswork in normalvite devtoo.Checklist before merging (when #210 lands)
References