fix: apply gateway env patching before agent discovery in dev mode#1303
Conversation
Agent discovery imports eval files at build time, which may import LLM SDKs (e.g. groq-sdk) at module scope. These SDKs check for API keys like GROQ_API_KEY at import time, but the gateway env patching that sets these keys was only running later (inside createApp → applyDevPatches). Move SDK key loading, AGENTUITY_TRANSPORT_URL setup, and gateway env patching (GROQ_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY) to a new Step 0b that runs before discoverAgents(), matching the same gateway logic from runtime/src/dev-patches/gateway.ts. Also includes template fixes: - Remove deprecated agentuity.config.ts - Update vite.config.ts - Add workbench config to app.ts
The _base template enables @tailwindcss/vite in vite.config.ts but never imports Tailwind, so utilities are never generated. Add src/web/App.css with the Tailwind import directive and import it from frontend.tsx (the entry point), matching the pattern used in the default template.
The _base template uses inline <style> blocks with plain CSS — it doesn't use Tailwind at all. The Tailwind Vite plugin and CSS import belong in the default template which actually uses Tailwind classes. - Remove tailwindcss import and plugin from _base/vite.config.ts - Add vite.config.ts with Tailwind plugin to default/ overlay - Remove App.css from _base (added in previous commit, not needed) - Revert frontend.tsx App.css import in _base The overlay system ensures default's vite.config.ts overwrites _base's when the default template is selected, and package.overlay.json already adds the @tailwindcss/vite and tailwindcss devDependencies.
The Vite build requires build.rollupOptions.input pointing to src/web/index.html so Vite finds the HTML entry point. The migrate tool now: 1. Includes rollupOptions.input in the missing-vite-config hint 2. Includes rollupOptions.input in the agentuity-config-vite-keys hint 3. Adds a new vite-config-missing-rollup-input finding when an existing vite.config.ts doesn't contain rollupOptions or index.html references
|
The latest Agentuity deployment details.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-12-21T00:31:41.858ZApplied to files:
🔇 Additional comments (1)
📝 WalkthroughWalkthroughVite detection in the migration package now checks for an explicit Rollup input pointing to Changes
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
📦 Canary Packages Publishedversion: PackagesInstallAdd to your {
"dependencies": {
"@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-cli-2.0.2-ec44b3e.tgz",
"@agentuity/auth": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-auth-2.0.2-ec44b3e.tgz",
"@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-coder-2.0.2-ec44b3e.tgz",
"@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-migrate-2.0.2-ec44b3e.tgz",
"@agentuity/evals": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-evals-2.0.2-ec44b3e.tgz",
"@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-schema-2.0.2-ec44b3e.tgz",
"@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-keyvalue-2.0.2-ec44b3e.tgz",
"@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-task-2.0.2-ec44b3e.tgz",
"@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-drizzle-2.0.2-ec44b3e.tgz",
"@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-vector-2.0.2-ec44b3e.tgz",
"@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-schedule-2.0.2-ec44b3e.tgz",
"@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-email-2.0.2-ec44b3e.tgz",
"@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-claude-code-2.0.2-ec44b3e.tgz",
"@agentuity/workbench": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-workbench-2.0.2-ec44b3e.tgz",
"@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-runtime-2.0.2-ec44b3e.tgz",
"@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-core-2.0.2-ec44b3e.tgz",
"@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-opencode-2.0.2-ec44b3e.tgz",
"@agentuity/react": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-react-2.0.2-ec44b3e.tgz",
"@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-webhook-2.0.2-ec44b3e.tgz",
"@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-queue-2.0.2-ec44b3e.tgz",
"@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-db-2.0.2-ec44b3e.tgz",
"@agentuity/frontend": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-frontend-2.0.2-ec44b3e.tgz",
"@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-postgres-2.0.2-ec44b3e.tgz",
"@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-server-2.0.2-ec44b3e.tgz",
"@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-sandbox-2.0.2-ec44b3e.tgz"
}
}Or install directly: bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-cli-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-auth-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-coder-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-migrate-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-evals-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-schema-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-keyvalue-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-task-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-drizzle-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-vector-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-schedule-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-email-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-claude-code-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-workbench-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-runtime-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-core-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-opencode-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-react-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-webhook-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-queue-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-db-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-frontend-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-postgres-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-server-2.0.2-ec44b3e.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.2-ec44b3e/agentuity-sandbox-2.0.2-ec44b3e.tgz |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/migrate/src/detect.ts`:
- Around line 751-752: The current detection checks viteSrc for 'rollupOptions'
but not for the actual 'input' property, so update the condition that references
viteSrc (the one that currently does if (!viteSrc.includes('rollupOptions') ||
!viteSrc.includes('index.html')) { ... findings.push(...) }) to ensure it looks
for the input key too (e.g. check for 'build.rollupOptions.input' or a regex
that matches rollupOptions followed by an input property) so configs missing
build.rollupOptions.input are flagged; modify the check on viteSrc accordingly
before pushing to findings.
- Around line 490-503: The Vite config examples use join(__dirname,
'src/web/index.html') which will throw in ESM where __dirname is undefined;
update the examples that set build.rollupOptions.input to use an ESM-safe path
resolution instead — either compute __dirname from import.meta.url via
fileURLToPath and dirname (referencing fileURLToPath, dirname, import.meta.url)
or use node:path.resolve/resolve('./src/web/index.html') (referencing resolve)
and replace join(__dirname, ...) occurrences accordingly so the example works in
"type":"module" projects.
In `@templates/default/vite.config.ts`:
- Line 11: The Vite config uses join(__dirname, 'src/web/index.html') which
breaks in ESM; replace use of __dirname with an ESM-safe resolved directory by
computing the config file directory via fileURLToPath(new URL('.',
import.meta.url)) (or equivalent) and then join that directory with
'src/web/index.html' so the input property uses the resolved path; update the
expression where join(__dirname, 'src/web/index.html') appears (in the Vite
config input option) to use the new ESM-safe directory variable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 32192691-f84d-40ee-b6e0-cad862b36682
📒 Files selected for processing (2)
packages/migrate/src/detect.tstemplates/default/vite.config.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Build
- GitHub Check: Playwright E2E Smoke Test
- GitHub Check: Sandbox CLI Tests
- GitHub Check: Cloud Deployment Tests
- GitHub Check: SDK Integration Test Suite
- GitHub Check: Agentuity Deployment
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Biome as code formatter with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5
Files:
templates/default/vite.config.tspackages/migrate/src/detect.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
UseStructuredErrorfrom@agentuity/corefor error handling
Files:
templates/default/vite.config.tspackages/migrate/src/detect.ts
🧠 Learnings (1)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.
Applied to files:
templates/default/vite.config.tspackages/migrate/src/detect.ts
…upOptions.input detection - Replace __dirname with import.meta.dirname in all vite.config.ts hint strings in detect.ts (3 locations) and in template vite.config.ts files for ESM compatibility - Tighten the vite-config-missing-rollup-input detection to also check for 'input' keyword and 'src/web/index.html' path specifically Resolves CodeRabbit review conversations.
Agent discovery imports eval files at build time, which may import LLM
SDKs (e.g. groq-sdk) at module scope. These SDKs check for API keys
like GROQ_API_KEY at import time, but the gateway env patching that
sets these keys was only running later (inside createApp → applyDevPatches).
Move SDK key loading, AGENTUITY_TRANSPORT_URL setup, and gateway env
patching (GROQ_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY) to a new
Step 0b that runs before discoverAgents(), matching the same gateway
logic from runtime/src/dev-patches/gateway.ts.
Also includes template fixes:
Summary by CodeRabbit