From b83ff39b98ad88bd85de97a6e73cd30f8cfdc495 Mon Sep 17 00:00:00 2001 From: huijiro Date: Wed, 1 Apr 2026 17:18:48 -0300 Subject: [PATCH] fix(cli): remove src/generated codegen and suppress proxy errors during restart - Remove env-types-generator, lifecycle-generator, and docs-generator along with their invocations in the build pipeline and tests - Delete stale src/generated/ folders from apps/testing/* and apps/docs - Remove src/generated from file-watcher ignore lists - Simplify getGeneratedSqlDir (no longer checks for v1 registry.ts) - Suppress Vite proxy errors during backend --hot reload by downgrading transient connection errors to debug level and responding with 503 --- apps/docs/src/generated/AGENTS.md | 23 - apps/docs/src/generated/README.md | 36 - .../cloud-deployment/src/generated/AGENTS.md | 23 - .../cloud-deployment/src/generated/README.md | 36 - .../cloud-deployment/src/generated/env.d.ts | 27 - apps/testing/e2e-web/src/generated/AGENTS.md | 23 - apps/testing/e2e-web/src/generated/README.md | 36 - apps/testing/e2e-web/src/generated/env.d.ts | 27 - .../integration-suite/src/generated/AGENTS.md | 23 - .../integration-suite/src/generated/README.md | 36 - .../integration-suite/src/generated/env.d.ts | 27 - apps/testing/oauth/src/generated/AGENTS.md | 24 - apps/testing/oauth/src/generated/README.md | 37 - .../oauth/src/generated/analytics-config.ts | 33 - apps/testing/oauth/src/generated/app.ts | 565 --------------- apps/testing/oauth/src/generated/registry.ts | 55 -- apps/testing/oauth/src/generated/routes.ts | 202 ------ .../oauth/src/generated/webanalytics.ts | 97 --- .../svelte-web/src/generated/AGENTS.md | 23 - .../svelte-web/src/generated/README.md | 36 - .../cli/src/cmd/build/vite/docs-generator.ts | 103 --- .../src/cmd/build/vite/env-types-generator.ts | 145 ---- .../src/cmd/build/vite/lifecycle-generator.ts | 381 ---------- .../build/vite/vite-asset-server-config.ts | 31 + .../cli/src/cmd/build/vite/vite-builder.ts | 20 +- packages/cli/src/cmd/dev/file-watcher.ts | 2 - packages/cli/src/cmd/project/auth/shared.ts | 5 - .../cmd/build/lifecycle-generator.test.ts | 221 ------ .../build/vite/env-types-generator.test.ts | 664 ------------------ 29 files changed, 32 insertions(+), 2929 deletions(-) delete mode 100644 apps/docs/src/generated/AGENTS.md delete mode 100644 apps/docs/src/generated/README.md delete mode 100644 apps/testing/cloud-deployment/src/generated/AGENTS.md delete mode 100644 apps/testing/cloud-deployment/src/generated/README.md delete mode 100644 apps/testing/cloud-deployment/src/generated/env.d.ts delete mode 100644 apps/testing/e2e-web/src/generated/AGENTS.md delete mode 100644 apps/testing/e2e-web/src/generated/README.md delete mode 100644 apps/testing/e2e-web/src/generated/env.d.ts delete mode 100644 apps/testing/integration-suite/src/generated/AGENTS.md delete mode 100644 apps/testing/integration-suite/src/generated/README.md delete mode 100644 apps/testing/integration-suite/src/generated/env.d.ts delete mode 100644 apps/testing/oauth/src/generated/AGENTS.md delete mode 100644 apps/testing/oauth/src/generated/README.md delete mode 100644 apps/testing/oauth/src/generated/analytics-config.ts delete mode 100644 apps/testing/oauth/src/generated/app.ts delete mode 100644 apps/testing/oauth/src/generated/registry.ts delete mode 100644 apps/testing/oauth/src/generated/routes.ts delete mode 100644 apps/testing/oauth/src/generated/webanalytics.ts delete mode 100644 apps/testing/svelte-web/src/generated/AGENTS.md delete mode 100644 apps/testing/svelte-web/src/generated/README.md delete mode 100644 packages/cli/src/cmd/build/vite/docs-generator.ts delete mode 100644 packages/cli/src/cmd/build/vite/env-types-generator.ts delete mode 100644 packages/cli/src/cmd/build/vite/lifecycle-generator.ts delete mode 100644 packages/cli/test/cmd/build/lifecycle-generator.test.ts delete mode 100644 packages/cli/test/cmd/build/vite/env-types-generator.test.ts diff --git a/apps/docs/src/generated/AGENTS.md b/apps/docs/src/generated/AGENTS.md deleted file mode 100644 index 8c9d8864a..000000000 --- a/apps/docs/src/generated/AGENTS.md +++ /dev/null @@ -1,23 +0,0 @@ -# AI Agent Instructions - -**CRITICAL:** Files in this directory are AUTO-GENERATED by the Agentuity build system. - -## Rules for AI Agents - -1. ❌ NEVER edit files in `src/generated/` -2. ❌ NEVER include `src/generated/` files in context when analyzing code -3. ❌ NEVER suggest changes to generated files -4. ✅ Ignore this directory when searching for user code -5. ✅ Direct users to modify source files in `src/agent/`, `src/api/`, `app.ts`, or `.env` files - -## What Gets Generated - -- `registry.ts` - Built from agent discovery in `src/agent/` -- `app.ts` - Entry point assembled from project configuration -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state) - -These files are regenerated on every `bun run build` or `bun run dev`. diff --git a/apps/docs/src/generated/README.md b/apps/docs/src/generated/README.md deleted file mode 100644 index 3f5928ce0..000000000 --- a/apps/docs/src/generated/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Generated Files - DO NOT EDIT - -This directory contains auto-generated TypeScript files created by the Agentuity build system. - -**These files are regenerated on every build.** Any manual changes will be overwritten. - -## Generated Files - -- `registry.ts` - Agent registry from `src/agent/**` -- `app.ts` - Application entry point -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state in `app.ts`) - -## Environment Variable Types - -The `env.d.ts` file provides TypeScript intellisense for your environment variables: - -- **ProcessEnv**: All variables from your `.env` files are typed as `string` -- **ImportMetaEnv**: Only `VITE_*`, `AGENTUITY_PUBLIC_*`, and `PUBLIC_*` prefixed variables (for client-side use) - -Files are merged based on build mode: -- **Development**: `.env.{profile}` → `.env.development` → `.env` (later files override) -- **Production**: `.env.{profile}` → `.env` → `.env.production` (later files override) - -## For Developers - -Do not modify these files. Instead: -- Add/modify agents in `src/agent/` -- Add/modify routes in `src/api/` -- Configure app in `app.ts` -- Add environment variables to `.env` files - -These files ARE version controlled to enable better tooling and type checking. diff --git a/apps/testing/cloud-deployment/src/generated/AGENTS.md b/apps/testing/cloud-deployment/src/generated/AGENTS.md deleted file mode 100644 index 8c9d8864a..000000000 --- a/apps/testing/cloud-deployment/src/generated/AGENTS.md +++ /dev/null @@ -1,23 +0,0 @@ -# AI Agent Instructions - -**CRITICAL:** Files in this directory are AUTO-GENERATED by the Agentuity build system. - -## Rules for AI Agents - -1. ❌ NEVER edit files in `src/generated/` -2. ❌ NEVER include `src/generated/` files in context when analyzing code -3. ❌ NEVER suggest changes to generated files -4. ✅ Ignore this directory when searching for user code -5. ✅ Direct users to modify source files in `src/agent/`, `src/api/`, `app.ts`, or `.env` files - -## What Gets Generated - -- `registry.ts` - Built from agent discovery in `src/agent/` -- `app.ts` - Entry point assembled from project configuration -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state) - -These files are regenerated on every `bun run build` or `bun run dev`. diff --git a/apps/testing/cloud-deployment/src/generated/README.md b/apps/testing/cloud-deployment/src/generated/README.md deleted file mode 100644 index 3f5928ce0..000000000 --- a/apps/testing/cloud-deployment/src/generated/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Generated Files - DO NOT EDIT - -This directory contains auto-generated TypeScript files created by the Agentuity build system. - -**These files are regenerated on every build.** Any manual changes will be overwritten. - -## Generated Files - -- `registry.ts` - Agent registry from `src/agent/**` -- `app.ts` - Application entry point -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state in `app.ts`) - -## Environment Variable Types - -The `env.d.ts` file provides TypeScript intellisense for your environment variables: - -- **ProcessEnv**: All variables from your `.env` files are typed as `string` -- **ImportMetaEnv**: Only `VITE_*`, `AGENTUITY_PUBLIC_*`, and `PUBLIC_*` prefixed variables (for client-side use) - -Files are merged based on build mode: -- **Development**: `.env.{profile}` → `.env.development` → `.env` (later files override) -- **Production**: `.env.{profile}` → `.env` → `.env.production` (later files override) - -## For Developers - -Do not modify these files. Instead: -- Add/modify agents in `src/agent/` -- Add/modify routes in `src/api/` -- Configure app in `app.ts` -- Add environment variables to `.env` files - -These files ARE version controlled to enable better tooling and type checking. diff --git a/apps/testing/cloud-deployment/src/generated/env.d.ts b/apps/testing/cloud-deployment/src/generated/env.d.ts deleted file mode 100644 index 9bf153399..000000000 --- a/apps/testing/cloud-deployment/src/generated/env.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// @generated -// AUTO-GENERATED from local .env files -// This file is auto-generated by the build tool - do not edit manually - -declare global { - namespace NodeJS { - interface ProcessEnv { - readonly AGENTUITY_SDK_KEY: string; - } - } -} - -// Vite-compatible environment types -// Only includes variables with VITE_, AGENTUITY_PUBLIC_, or PUBLIC_ prefix -interface ImportMetaEnv { - // No VITE_*, AGENTUITY_PUBLIC_*, or PUBLIC_* prefixed variables found -} - -interface ImportMeta { - readonly env: ImportMetaEnv; -} - -export {}; - -// FOUND AN ERROR IN THIS FILE? -// Please file an issue at https://github.com/agentuity/sdk/issues -// or if you know the fix please submit a PR! diff --git a/apps/testing/e2e-web/src/generated/AGENTS.md b/apps/testing/e2e-web/src/generated/AGENTS.md deleted file mode 100644 index 8c9d8864a..000000000 --- a/apps/testing/e2e-web/src/generated/AGENTS.md +++ /dev/null @@ -1,23 +0,0 @@ -# AI Agent Instructions - -**CRITICAL:** Files in this directory are AUTO-GENERATED by the Agentuity build system. - -## Rules for AI Agents - -1. ❌ NEVER edit files in `src/generated/` -2. ❌ NEVER include `src/generated/` files in context when analyzing code -3. ❌ NEVER suggest changes to generated files -4. ✅ Ignore this directory when searching for user code -5. ✅ Direct users to modify source files in `src/agent/`, `src/api/`, `app.ts`, or `.env` files - -## What Gets Generated - -- `registry.ts` - Built from agent discovery in `src/agent/` -- `app.ts` - Entry point assembled from project configuration -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state) - -These files are regenerated on every `bun run build` or `bun run dev`. diff --git a/apps/testing/e2e-web/src/generated/README.md b/apps/testing/e2e-web/src/generated/README.md deleted file mode 100644 index 3f5928ce0..000000000 --- a/apps/testing/e2e-web/src/generated/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Generated Files - DO NOT EDIT - -This directory contains auto-generated TypeScript files created by the Agentuity build system. - -**These files are regenerated on every build.** Any manual changes will be overwritten. - -## Generated Files - -- `registry.ts` - Agent registry from `src/agent/**` -- `app.ts` - Application entry point -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state in `app.ts`) - -## Environment Variable Types - -The `env.d.ts` file provides TypeScript intellisense for your environment variables: - -- **ProcessEnv**: All variables from your `.env` files are typed as `string` -- **ImportMetaEnv**: Only `VITE_*`, `AGENTUITY_PUBLIC_*`, and `PUBLIC_*` prefixed variables (for client-side use) - -Files are merged based on build mode: -- **Development**: `.env.{profile}` → `.env.development` → `.env` (later files override) -- **Production**: `.env.{profile}` → `.env` → `.env.production` (later files override) - -## For Developers - -Do not modify these files. Instead: -- Add/modify agents in `src/agent/` -- Add/modify routes in `src/api/` -- Configure app in `app.ts` -- Add environment variables to `.env` files - -These files ARE version controlled to enable better tooling and type checking. diff --git a/apps/testing/e2e-web/src/generated/env.d.ts b/apps/testing/e2e-web/src/generated/env.d.ts deleted file mode 100644 index 9bf153399..000000000 --- a/apps/testing/e2e-web/src/generated/env.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// @generated -// AUTO-GENERATED from local .env files -// This file is auto-generated by the build tool - do not edit manually - -declare global { - namespace NodeJS { - interface ProcessEnv { - readonly AGENTUITY_SDK_KEY: string; - } - } -} - -// Vite-compatible environment types -// Only includes variables with VITE_, AGENTUITY_PUBLIC_, or PUBLIC_ prefix -interface ImportMetaEnv { - // No VITE_*, AGENTUITY_PUBLIC_*, or PUBLIC_* prefixed variables found -} - -interface ImportMeta { - readonly env: ImportMetaEnv; -} - -export {}; - -// FOUND AN ERROR IN THIS FILE? -// Please file an issue at https://github.com/agentuity/sdk/issues -// or if you know the fix please submit a PR! diff --git a/apps/testing/integration-suite/src/generated/AGENTS.md b/apps/testing/integration-suite/src/generated/AGENTS.md deleted file mode 100644 index 8c9d8864a..000000000 --- a/apps/testing/integration-suite/src/generated/AGENTS.md +++ /dev/null @@ -1,23 +0,0 @@ -# AI Agent Instructions - -**CRITICAL:** Files in this directory are AUTO-GENERATED by the Agentuity build system. - -## Rules for AI Agents - -1. ❌ NEVER edit files in `src/generated/` -2. ❌ NEVER include `src/generated/` files in context when analyzing code -3. ❌ NEVER suggest changes to generated files -4. ✅ Ignore this directory when searching for user code -5. ✅ Direct users to modify source files in `src/agent/`, `src/api/`, `app.ts`, or `.env` files - -## What Gets Generated - -- `registry.ts` - Built from agent discovery in `src/agent/` -- `app.ts` - Entry point assembled from project configuration -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state) - -These files are regenerated on every `bun run build` or `bun run dev`. diff --git a/apps/testing/integration-suite/src/generated/README.md b/apps/testing/integration-suite/src/generated/README.md deleted file mode 100644 index 3f5928ce0..000000000 --- a/apps/testing/integration-suite/src/generated/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Generated Files - DO NOT EDIT - -This directory contains auto-generated TypeScript files created by the Agentuity build system. - -**These files are regenerated on every build.** Any manual changes will be overwritten. - -## Generated Files - -- `registry.ts` - Agent registry from `src/agent/**` -- `app.ts` - Application entry point -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state in `app.ts`) - -## Environment Variable Types - -The `env.d.ts` file provides TypeScript intellisense for your environment variables: - -- **ProcessEnv**: All variables from your `.env` files are typed as `string` -- **ImportMetaEnv**: Only `VITE_*`, `AGENTUITY_PUBLIC_*`, and `PUBLIC_*` prefixed variables (for client-side use) - -Files are merged based on build mode: -- **Development**: `.env.{profile}` → `.env.development` → `.env` (later files override) -- **Production**: `.env.{profile}` → `.env` → `.env.production` (later files override) - -## For Developers - -Do not modify these files. Instead: -- Add/modify agents in `src/agent/` -- Add/modify routes in `src/api/` -- Configure app in `app.ts` -- Add environment variables to `.env` files - -These files ARE version controlled to enable better tooling and type checking. diff --git a/apps/testing/integration-suite/src/generated/env.d.ts b/apps/testing/integration-suite/src/generated/env.d.ts deleted file mode 100644 index 9bf153399..000000000 --- a/apps/testing/integration-suite/src/generated/env.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// @generated -// AUTO-GENERATED from local .env files -// This file is auto-generated by the build tool - do not edit manually - -declare global { - namespace NodeJS { - interface ProcessEnv { - readonly AGENTUITY_SDK_KEY: string; - } - } -} - -// Vite-compatible environment types -// Only includes variables with VITE_, AGENTUITY_PUBLIC_, or PUBLIC_ prefix -interface ImportMetaEnv { - // No VITE_*, AGENTUITY_PUBLIC_*, or PUBLIC_* prefixed variables found -} - -interface ImportMeta { - readonly env: ImportMetaEnv; -} - -export {}; - -// FOUND AN ERROR IN THIS FILE? -// Please file an issue at https://github.com/agentuity/sdk/issues -// or if you know the fix please submit a PR! diff --git a/apps/testing/oauth/src/generated/AGENTS.md b/apps/testing/oauth/src/generated/AGENTS.md deleted file mode 100644 index f571c2b88..000000000 --- a/apps/testing/oauth/src/generated/AGENTS.md +++ /dev/null @@ -1,24 +0,0 @@ -# AI Agent Instructions - -**CRITICAL:** Files in this directory are AUTO-GENERATED by the Agentuity build system. - -## Rules for AI Agents - -1. ❌ NEVER edit files in `src/generated/` -2. ❌ NEVER include `src/generated/` files in context when analyzing code -3. ❌ NEVER suggest changes to generated files -4. ✅ Ignore this directory when searching for user code -5. ✅ Direct users to modify source files in `src/agent/`, `src/api/`, `app.ts`, or `.env` files - -## What Gets Generated - -- `registry.ts` - Built from agent discovery in `src/agent/` -- `routes.ts` - Built from route discovery in `src/api/` -- `app.ts` - Entry point assembled from project configuration -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state) - -These files are regenerated on every `bun run build` or `bun run dev`. diff --git a/apps/testing/oauth/src/generated/README.md b/apps/testing/oauth/src/generated/README.md deleted file mode 100644 index cbfd8b5ee..000000000 --- a/apps/testing/oauth/src/generated/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Generated Files - DO NOT EDIT - -This directory contains auto-generated TypeScript files created by the Agentuity build system. - -**These files are regenerated on every build.** Any manual changes will be overwritten. - -## Generated Files - -- `registry.ts` - Agent registry from `src/agent/**` -- `routes.ts` - Route registry from `src/api/**` -- `app.ts` - Application entry point -- `analytics-config.ts` - Web analytics configuration from `agentuity.json` -- `webanalytics.ts` - Web analytics injection and route registration -- `env.d.ts` - TypeScript types for environment variables from `.env` files -- `state.ts` - App state type (only generated when `setup()` returns state in `app.ts`) -- `router.ts` - Runtime wrapper with type augmentation (only generated when `setup()` returns state in `app.ts`) - -## Environment Variable Types - -The `env.d.ts` file provides TypeScript intellisense for your environment variables: - -- **ProcessEnv**: All variables from your `.env` files are typed as `string` -- **ImportMetaEnv**: Only `VITE_*`, `AGENTUITY_PUBLIC_*`, and `PUBLIC_*` prefixed variables (for client-side use) - -Files are merged based on build mode: -- **Development**: `.env.{profile}` → `.env.development` → `.env` (later files override) -- **Production**: `.env.{profile}` → `.env` → `.env.production` (later files override) - -## For Developers - -Do not modify these files. Instead: -- Add/modify agents in `src/agent/` -- Add/modify routes in `src/api/` -- Configure app in `app.ts` -- Add environment variables to `.env` files - -These files ARE version controlled to enable better tooling and type checking. diff --git a/apps/testing/oauth/src/generated/analytics-config.ts b/apps/testing/oauth/src/generated/analytics-config.ts deleted file mode 100644 index 2a4657a94..000000000 --- a/apps/testing/oauth/src/generated/analytics-config.ts +++ /dev/null @@ -1,33 +0,0 @@ -// @generated -// Auto-generated by Agentuity -// DO NOT EDIT - This file is regenerated on every build - -export interface AnalyticsConfig { - enabled: boolean; - requireConsent: boolean; - trackClicks: boolean; - trackScroll: boolean; - trackOutboundLinks: boolean; - trackForms: boolean; - trackWebVitals: boolean; - trackErrors: boolean; - trackSPANavigation: boolean; - sampleRate: number; - excludePatterns: string[]; - globalProperties: Record; -} - -export const analyticsConfig: AnalyticsConfig = { - enabled: true, - requireConsent: false, - trackClicks: true, - trackScroll: true, - trackOutboundLinks: true, - trackForms: false, - trackWebVitals: true, - trackErrors: true, - trackSPANavigation: true, - sampleRate: 1, - excludePatterns: [], - globalProperties: {}, -}; diff --git a/apps/testing/oauth/src/generated/app.ts b/apps/testing/oauth/src/generated/app.ts deleted file mode 100644 index 6bc030b66..000000000 --- a/apps/testing/oauth/src/generated/app.ts +++ /dev/null @@ -1,565 +0,0 @@ -// @generated -// Auto-generated by Agentuity -// DO NOT EDIT - This file is regenerated on every build -// Supports both development and production modes via runtime detection -import { - createRouter, - createBaseMiddleware, - createCorsMiddleware, - createOtelMiddleware, - createAgentMiddleware, - createCompressionMiddleware, - getAppState, - getAppConfig, - getUserRouter, - register, - getSpanProcessors, - createServices, - runAgentSetups, - getThreadProvider, - getSessionProvider, - setGlobalLogger, - setGlobalTracer, - setGlobalRouter, - enableProcessExitProtection, - hasWaitUntilPending, - loadBuildMetadata, - createWorkbenchRouter, - bootstrapRuntimeEnv, - patchBunS3ForStorageDev, - runShutdown, - mimeTypes, -} from '@agentuity/runtime'; -import type { Context } from 'hono'; -import { websocket, serveStatic } from 'hono/bun'; -import { readFileSync, existsSync } from 'node:fs'; -import { type LogLevel } from '@agentuity/core'; -import { injectAnalytics, registerAnalyticsRoutes } from './webanalytics.js'; -import { analyticsConfig } from './analytics-config.js'; - -// Runtime mode detection helper -// Dynamic string concatenation prevents Bun.build from inlining NODE_ENV at build time -// See: https://github.com/oven-sh/bun/issues/20183 -const getEnv = (key: string) => process.env[key]; -const isDevelopment = () => getEnv('NODE' + '_' + 'ENV') !== 'production'; - -// Step 0: Bootstrap runtime environment (load profile-specific .env files) -// Only in development - production env vars are injected by platform -// This must happen BEFORE any imports that depend on environment variables -if (isDevelopment()) { - // Pass project directory (two levels up from src/generated/) so .env files are loaded correctly - await bootstrapRuntimeEnv({ projectDir: import.meta.dir + '/../..' }); -} - -// Step 0.25: load our runtime metadata and cache it -loadBuildMetadata(); - -// Step 0.5: Patch Bun's S3 client for Agentuity storage endpoints -// Agentuity storage uses virtual-hosted-style URLs (*.storage.dev) -// This patches s3.file() to automatically set virtualHostedStyle: true -patchBunS3ForStorageDev(); - -// Step 1: Initialize telemetry and services -const serverUrl = `http://127.0.0.1:${process.env.PORT || '3500'}`; -const otel = register({ processors: getSpanProcessors(), logLevel: (process.env.AGENTUITY_LOG_LEVEL || 'info') as LogLevel }); - -// Step 2: Create router and set as global -const app = createRouter(); -setGlobalRouter(app); - -// Step 3: Apply middleware in correct order (BEFORE mounting routes) -// Compression runs first (outermost) so it can compress the final response -app.use('*', createCompressionMiddleware()); - -app.use('*', createBaseMiddleware({ - logger: otel.logger, - tracer: otel.tracer, - meter: otel.meter, -})); - -// Workbench routes always get OTel middleware for session tracking -app.use('/_agentuity/workbench/*', createOtelMiddleware()); - -// Note: /api/* middleware (CORS, OTel, agent context) is applied in Step 6 -// after app.ts import, so user-provided routers can specify custom prefixes. - -// Step 4: Import user's app.ts (runs createApp, gets state/config) -await import('../../app.js'); - -// Step 4.5: Import agent registry to ensure all agents are registered -// This is needed for workbench metadata to return JSON schemas -await import('./registry.js'); - -// Step 5: Initialize providers -const appState = getAppState(); -const appConfig = getAppConfig(); - -createServices(otel.logger, appConfig, serverUrl); - -// Make logger and tracer globally available for user's app.ts -setGlobalLogger(otel.logger); -setGlobalTracer(otel.tracer); - -const threadProvider = getThreadProvider(); -const sessionProvider = getSessionProvider(); - -await threadProvider.initialize(appState); -await sessionProvider.initialize(appState); - -// Step 6: Mount routes (AFTER middleware is applied) - -// Health check routes (production only) -if (!isDevelopment()) { - const healthHandler = (c: Context) => { - return c.text('OK', 200, { 'Content-Type': 'text/plain; charset=utf-8' }); - }; - const idleHandler = (c: Context) => { - // Check if server is idle (no pending requests/connections) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const server = (globalThis as any).__AGENTUITY_SERVER__; - if (!server) return c.text('NO', 200, { 'Content-Type': 'text/plain; charset=utf-8' }); - - // Check for pending background tasks - if (hasWaitUntilPending()) return c.text('NO', 200, { 'Content-Type': 'text/plain; charset=utf-8' }); - - if (server.pendingRequests > 1) return c.text('NO', 200, { 'Content-Type': 'text/plain; charset=utf-8' }); - if (server.pendingWebSockets > 0) return c.text('NO', 200, { 'Content-Type': 'text/plain; charset=utf-8' }); - - return c.text('OK', 200, { 'Content-Type': 'text/plain; charset=utf-8' }); - }; - app.get('/_agentuity/health', healthHandler); - app.get('/_health', healthHandler); - app.get('/_agentuity/idle', idleHandler); - app.get('/_idle', idleHandler); -} - -// Dev readiness check - verifies Vite asset server is ready to serve frontend -if (isDevelopment()) { - app.get('/_agentuity/ready', async (c: Context) => { - const vitePort = process.env.VITE_PORT; - if (!vitePort) { - // No Vite port means we're not using Vite proxy - return c.text('OK', 200, { 'Content-Type': 'text/plain; charset=utf-8' }); - } - - try { - // Probe Vite to check if it can serve the main entry point - // Use @vite/client as a lightweight check - it's always available - const viteUrl = `http://127.0.0.1:${vitePort}/@vite/client`; - const res = await fetch(viteUrl, { - signal: AbortSignal.timeout(5000), - method: 'HEAD' - }); - - if (res.ok) { - return c.text('OK', 200, { 'Content-Type': 'text/plain; charset=utf-8' }); - } - return c.text('VITE_NOT_READY', 503, { 'Content-Type': 'text/plain; charset=utf-8' }); - } catch (err) { - otel.logger.debug('Vite readiness check failed: %s', err instanceof Error ? err.message : String(err)); - return c.text('VITE_NOT_READY', 503, { 'Content-Type': 'text/plain; charset=utf-8' }); - } - }); -} - -// Register analytics routes -registerAnalyticsRoutes(app); - -// Asset proxy routes - Development mode only (proxies to Vite asset server) -if (isDevelopment() && process.env.VITE_PORT) { - const VITE_ASSET_PORT = parseInt(process.env.VITE_PORT, 10); - - const proxyToVite = async (c: Context, pathOverride?: string) => { - const targetPath = pathOverride ?? c.req.path; - const viteUrl = `http://127.0.0.1:${VITE_ASSET_PORT}${targetPath}`; - try { - otel.logger.debug(`[Proxy] ${c.req.method} ${c.req.path} -> Vite:${VITE_ASSET_PORT}${targetPath}`); - const res = await fetch(viteUrl, { signal: AbortSignal.timeout(10000) }); - otel.logger.debug(`[Proxy] ${c.req.path} -> ${res.status} (${res.headers.get('content-type')})`); - return new Response(res.body, { - status: res.status, - headers: res.headers, - }); - } catch (err) { - if (err instanceof Error && err.name === 'TimeoutError') { - otel.logger.error(`Vite proxy timeout: ${c.req.path}`); - return c.text('Vite asset server timeout', 504); - } - otel.logger.error(`Failed to proxy to Vite: ${c.req.path} - ${err instanceof Error ? err.message : String(err)}`); - return c.text('Vite asset server error', 500); - } - }; - - // HMR WebSocket proxy - enables hot reload through tunnels (*.agentuity.live) - // This proxies the Vite HMR WebSocket connection from the Bun server to Vite - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const viteHmrWebsocket = (globalThis as any).__AGENTUITY_VITE_HMR_WEBSOCKET__ = { - // Map of client WebSocket -> Vite WebSocket - connections: new Map(), - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - open(clientWs: any) { - // Get the query string from ws.data (set during upgrade) - const queryString = clientWs.data?.queryString || ''; - const viteWsUrl = `ws://127.0.0.1:${VITE_ASSET_PORT}/__vite_hmr${queryString}`; - otel.logger.debug('[HMR Proxy] Client connected, opening connection to Vite at %s', viteWsUrl); - - // Connect to Vite with the 'vite-hmr' subprotocol (required by Vite) - const viteWs = new WebSocket(viteWsUrl, ['vite-hmr']); - - viteWs.onopen = () => { - otel.logger.debug('[HMR Proxy] Connected to Vite HMR server'); - }; - - viteWs.onmessage = (event) => { - // Forward messages from Vite to client - if (clientWs.readyState === WebSocket.OPEN) { - clientWs.send(event.data); - } - }; - - viteWs.onerror = (error) => { - otel.logger.error('[HMR Proxy] Vite WebSocket error: %s', error); - }; - - viteWs.onclose = () => { - otel.logger.debug('[HMR Proxy] Vite WebSocket closed'); - viteHmrWebsocket.connections.delete(clientWs); - if (clientWs.readyState === WebSocket.OPEN) { - clientWs.close(); - } - }; - - viteHmrWebsocket.connections.set(clientWs, viteWs); - }, - - message(clientWs: WebSocket, message: string | Buffer) { - // Forward messages from client to Vite - const viteWs = viteHmrWebsocket.connections.get(clientWs); - if (viteWs && viteWs.readyState === WebSocket.OPEN) { - viteWs.send(message); - } - }, - - close(clientWs: WebSocket) { - otel.logger.debug('[HMR Proxy] Client WebSocket closed'); - const viteWs = viteHmrWebsocket.connections.get(clientWs); - if (viteWs) { - viteWs.close(); - viteHmrWebsocket.connections.delete(clientWs); - } - }, - }; - - // Register HMR WebSocket route - must be before other routes - app.get('/__vite_hmr', (c: Context) => { - const upgradeHeader = c.req.header('upgrade'); - if (upgradeHeader?.toLowerCase() === 'websocket') { - // Get the Bun server from context using Hono's pattern - // When app.fetch(req, server) is called, Hono stores server as c.env - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const server = 'server' in (c.env as any) ? (c.env as any).server : c.env; - - if (server?.upgrade) { - // Extract query string to forward to Vite (includes token parameter) - const url = new URL(c.req.url); - const queryString = url.search; // Includes the '?' prefix - - const success = server.upgrade(c.req.raw, { - data: { type: 'vite-hmr', queryString }, - }); - if (success) { - otel.logger.debug('[HMR Proxy] WebSocket upgrade successful'); - return new Response(null); - } - otel.logger.error('[HMR Proxy] WebSocket upgrade returned false'); - } else { - otel.logger.error('[HMR Proxy] Server upgrade method not available. c.env type: %s, keys: %s', - typeof c.env, - Object.keys(c.env || {}).join(', ')); - } - return c.text('WebSocket upgrade failed', 500); - } - // Non-WebSocket request to HMR endpoint - proxy to Vite - return proxyToVite(c); - }); - - // Vite client scripts and HMR - app.get('/@vite/*', (c: Context) => proxyToVite(c)); - app.get('/@react-refresh', (c: Context) => proxyToVite(c)); - - // Source files for HMR - app.get('/src/web/*', (c: Context) => proxyToVite(c)); - app.get('/src/*', (c: Context) => proxyToVite(c)); // Catch-all for other source files - - // Workbench source files (in .agentuity/workbench-src/) - app.get('/.agentuity/workbench-src/*', (c: Context) => proxyToVite(c)); - - // Node modules (Vite transforms these) - app.get('/node_modules/*', (c: Context) => proxyToVite(c)); - - // Scoped packages (e.g., @agentuity/*, @types/*) - app.get('/@*', (c: Context) => proxyToVite(c)); - - // File system access (for Vite's @fs protocol) - app.get('/@fs/*', (c: Context) => proxyToVite(c)); - - // Module resolution (for Vite's @id protocol) - app.get('/@id/*', (c: Context) => proxyToVite(c)); - - // Static assets - Vite serves src/web/public/* at root, but code uses /public/* paths - // In production, the plugin transforms /public/foo.svg to CDN URLs - // Rewrite /public/foo.svg -> /foo.svg before proxying to Vite - app.get('/public/*', (c: Context) => { - const rootPath = c.req.path.replace(/^\/public/, ''); - return proxyToVite(c, rootPath); - }); - - // Any .js, .jsx, .ts, .tsx files (catch remaining modules) - app.get('/*.js', (c: Context) => proxyToVite(c)); - app.get('/*.jsx', (c: Context) => proxyToVite(c)); - app.get('/*.ts', (c: Context) => proxyToVite(c)); - app.get('/*.tsx', (c: Context) => proxyToVite(c)); - app.get('/*.css', (c: Context) => proxyToVite(c)); -} - -// Apply middleware and mount API routes -// If user passed router(s) via createApp({ router }), mount those instead of discovered files -const __userMounts = getUserRouter(); -if (__userMounts) { - for (const mount of __userMounts) { - // Apply Agentuity middleware (CORS, OTel, agent context) to each user-provided prefix - const prefix = mount.path.endsWith('/') ? mount.path + '*' : mount.path + '/*'; - app.use(prefix, createCorsMiddleware()); - app.use(prefix, createOtelMiddleware()); - app.use(prefix, createAgentMiddleware('')); - app.route(mount.path, mount.router); - } -} else { - // File-based routing: apply middleware to /api/* and mount discovered route files - app.use('/api/*', createCorsMiddleware()); - app.use('/api/*', createOtelMiddleware()); - app.use('/api/*', createAgentMiddleware('')); - const { default: router_0 } = await import('../api/index.js'); - app.route('/api', router_0); -} - -// Mount workbench API routes (/_agentuity/workbench/*) -// Always available for cloud workbench communication -// Auth is handled inside the router (signature verification in production) -const workbenchRouter = createWorkbenchRouter(); -app.route('/', workbenchRouter); - -// hasWorkbenchConfig controls whether the local workbench UI is served (dev mode only) -const hasWorkbenchConfig = false; - -// Workbench UI is only available in development mode (API routes are always available) -if (hasWorkbenchConfig && isDevelopment()) { - const workbenchSrcDir = import.meta.dir + '/workbench-src'; - const workbenchIndexPath = import.meta.dir + '/workbench-src/index.html'; - app.get('/workbench', async (c: Context) => { - const html = await Bun.file(workbenchIndexPath).text(); - // Rewrite script/css paths to use Vite's @fs protocol - const withVite = html - .replace('src="./main.tsx"', `src="/@fs${workbenchSrcDir}/main.tsx"`) - .replace('href="./styles.css"', `href="/@fs${workbenchSrcDir}/styles.css"`); - return c.html(withVite); - }); -} - -// Web routes - Runtime mode detection (dev proxies to Vite, prod serves static) -// Note: Session/thread cookies are set by /_agentuity/webanalytics/session.js (loaded via script tag) -// This keeps the HTML response static and cacheable - -if (isDevelopment()) { - // Development mode: Proxy HTML from Vite to enable React Fast Refresh - const VITE_ASSET_PORT = parseInt(process.env.VITE_PORT || '5173', 10); - - const devHtmlHandler = async (c: Context) => { - const viteUrl = `http://127.0.0.1:${VITE_ASSET_PORT}/src/web/index.html`; - - try { - otel.logger.debug('[Proxy] GET /src/web/index.html -> Vite:%d', VITE_ASSET_PORT); - const res = await fetch(viteUrl, { signal: AbortSignal.timeout(10000) }); - - // Get HTML text and transform relative paths to absolute - let html = await res.text(); - html = html - .replace(/src="\.\//g, 'src="/src/web/') - .replace(/href="\.\//g, 'href="/src/web/'); - - // Inject analytics config and script (session/thread read from cookies by beacon) - html = injectAnalytics(html, analyticsConfig); - - return new Response(html, { - status: res.status, - headers: res.headers, - }); - } catch (err) { - otel.logger.error('Failed to proxy HTML to Vite: %s', err instanceof Error ? err.message : String(err)); - return c.text('Vite asset server error (HTML)', 500); - } - }; - - app.get('/', devHtmlHandler); - - // 404 for unmatched API/system routes - app.all('/_agentuity/*', (c: Context) => c.notFound()); - app.all('/api/*', (c: Context) => c.notFound()); - if (!(hasWorkbenchConfig && isDevelopment())) { - app.all('/workbench/*', (c: Context) => c.notFound()); - } - - // SPA fallback - serve index.html for client-side routing - app.get('*', async (c: Context) => { - const path = c.req.path; - // If path has a file extension, try proxying to Vite first (serves public files like robots.txt, llms.txt) - // Fall back to 404 if Vite also returns 404 - if (/\.[a-zA-Z0-9]+$/.test(path)) { - try { - const viteUrl = `http://127.0.0.1:${VITE_ASSET_PORT}${path}`; - const res = await fetch(viteUrl, { signal: AbortSignal.timeout(10000) }); - if (res.status !== 404) { - return new Response(res.body, { status: res.status, headers: res.headers }); - } - } catch { - // Vite unavailable, fall through to 404 - } - return c.notFound(); - } - return devHtmlHandler(c); - }); -} else { - // Production mode: Serve static files from bundled output - const indexHtmlPath = import.meta.dir + '/client/index.html'; - const baseIndexHtml = existsSync(indexHtmlPath) - ? readFileSync(indexHtmlPath, 'utf-8') - : ''; - - if (!baseIndexHtml) { - otel.logger.warn('Production HTML not found at %s', indexHtmlPath); - } - - const prodHtmlHandler = (c: Context) => { - if (!baseIndexHtml) { - return c.text('Production build incomplete', 500); - } - // Inject analytics config and script (session/thread loaded via session.js) - const html = injectAnalytics(baseIndexHtml, analyticsConfig); - return c.html(html); - }; - - app.get('/', prodHtmlHandler); - - // Serve static assets from /assets/* (Vite bundled output) - app.use('/assets/*', serveStatic({ root: import.meta.dir + '/client', mimes: mimeTypes })); - - // Serve static public assets (favicon.ico, robots.txt, etc.) - app.use('/*', serveStatic({ root: import.meta.dir + '/client', rewriteRequestPath: (path) => path, mimes: mimeTypes })); - - // 404 for unmatched API/system routes (IMPORTANT: comes before SPA fallback) - app.all('/_agentuity/*', (c: Context) => c.notFound()); - app.all('/api/*', (c: Context) => c.notFound()); - if (!(hasWorkbenchConfig && isDevelopment())) { - app.all('/workbench/*', (c: Context) => c.notFound()); - } - - // SPA fallback with asset protection - app.get('*', (c: Context) => { - const path = c.req.path; - // If path has a file extension, it's likely an asset request - return 404 - if (/\.[a-zA-Z0-9]+$/.test(path)) { - return c.notFound(); - } - return prodHtmlHandler(c); - }); -} - -// Step 7: Run agent setup to signal completion -await runAgentSetups(appState); - -// Start Bun server -if (typeof Bun !== 'undefined') { - // Enable process exit protection now that we're starting the server - enableProcessExitProtection(); - - const port = parseInt(process.env.PORT || '3500', 10); - - // Create custom WebSocket handler that supports both regular WebSockets and HMR proxy - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const hmrHandler = (globalThis as any).__AGENTUITY_VITE_HMR_WEBSOCKET__; - const customWebsocket = { - ...websocket, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - open(ws: any) { - // Check if this is an HMR connection - if (ws.data?.type === 'vite-hmr' && hmrHandler) { - hmrHandler.open(ws); - } else if (websocket.open) { - websocket.open(ws); - } - }, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - message(ws: any, message: string | Buffer) { - // Check if this is an HMR connection - if (ws.data?.type === 'vite-hmr' && hmrHandler) { - hmrHandler.message(ws, message); - } else if (websocket.message) { - websocket.message(ws, message); - } - }, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - close(ws: any, code?: number, reason?: string) { - // Check if this is an HMR connection - if (ws.data?.type === 'vite-hmr' && hmrHandler) { - hmrHandler.close(ws); - } else if (websocket.close) { - websocket.close(ws, code, reason); - } - }, - }; - - const server = Bun.serve({ - fetch: (req, server) => { - // Get timeout from config on each request (0 = no timeout) - server.timeout(req, getAppConfig()?.requestTimeout ?? 0); - return app.fetch(req, server); - }, - websocket: customWebsocket, - port, - hostname: '127.0.0.1', - development: isDevelopment(), - }); - - // Make server available globally for health checks - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (globalThis as any).__AGENTUITY_SERVER__ = server; - - otel.logger.info(`Server listening on http://127.0.0.1:${port}`); - if (isDevelopment() && process.env.VITE_PORT) { - otel.logger.debug(`Proxying Vite assets from port ${process.env.VITE_PORT}`); - } - - // Register signal handlers for graceful shutdown (production only) - // Dev mode has its own handlers in devmode.ts - if (!isDevelopment()) { - const handleShutdown = async (signal: string) => { - otel.logger.info(`Received ${signal}, initiating graceful shutdown...`); - try { - await runShutdown(); - otel.logger.info('Shutdown complete'); - } catch (err) { - otel.logger.error(`Error during shutdown: ${err instanceof Error ? err.message : String(err)}`); - } - process.exit(0); - }; - - process.once('SIGTERM', () => handleShutdown('SIGTERM')); - process.once('SIGINT', () => handleShutdown('SIGINT')); - } -} - -// FOUND AN ERROR IN THIS FILE? -// Please file an issue at https://github.com/agentuity/sdk/issues -// or if you know the fix please submit a PR! - diff --git a/apps/testing/oauth/src/generated/registry.ts b/apps/testing/oauth/src/generated/registry.ts deleted file mode 100644 index 15371df43..000000000 --- a/apps/testing/oauth/src/generated/registry.ts +++ /dev/null @@ -1,55 +0,0 @@ -// @generated -// Auto-generated by Agentuity - DO NOT EDIT - -import type { AgentRunner } from '@agentuity/runtime'; -import type { InferInput, InferOutput } from '@agentuity/core'; - -// ============================================================================ -// Schema Type Exports -// ============================================================================ - -// ============================================================================ -// Agent Definitions -// ============================================================================ - -/** - * Agent Definitions - * - * Registry of all agents in this application. - * Provides strongly-typed access to agent metadata and runner functions. - * - * @remarks - * This object is auto-generated from your agent files during build. - * Each agent has corresponding Input, Output, and Runner types exported above. - * - * @example - * ```typescript - * import { AgentDefinitions, SessionBasicInput } from './generated/registry'; - * - * // Access agent definition - * const agent = AgentDefinitions.sessionBasic; - * - * // Use typed schema types - * const input: SessionBasicInput = { ... }; - * const result = await agent.run(input); - * ``` - */ -export const AgentDefinitions = { - -} as const; - -// ============================================================================ -// Module Augmentation -// ============================================================================ - -// Augment @agentuity/runtime types with strongly-typed agents from this project -declare module "@agentuity/runtime" { - // Augment the AgentRegistry interface with project-specific strongly-typed agents - export interface AgentRegistry { - - } -} - -// FOUND AN ERROR IN THIS FILE? -// Please file an issue at https://github.com/agentuity/sdk/issues -// or if you know the fix please submit a PR! diff --git a/apps/testing/oauth/src/generated/routes.ts b/apps/testing/oauth/src/generated/routes.ts deleted file mode 100644 index 46806e632..000000000 --- a/apps/testing/oauth/src/generated/routes.ts +++ /dev/null @@ -1,202 +0,0 @@ -// @generated -// Auto-generated by Agentuity - DO NOT EDIT - -// ============================================================================ -// Route Schema Type Exports -// ============================================================================ - -// ============================================================================ -// Route Definitions -// ============================================================================ - -/** - * Route Definitions - * - * Type-safe route registry for all API routes, WebSocket connections, and SSE endpoints. - * Used by @agentuity/react and @agentuity/frontend for client-side type-safe routing. - * - * @remarks - * This module augmentation is auto-generated from your route files during build. - * Individual route Input/Output types are exported above for direct usage. - * - * The augmentation targets @agentuity/frontend (the canonical source of registry types). - * Since @agentuity/react re-exports these types, the augmentation is visible when - * importing from either package. - */ - -declare module '@agentuity/frontend' { - /** - * API Route Registry - * - * Maps route keys (METHOD /path) to their input/output schemas - */ - export interface RouteRegistry { - 'GET /api/oauth/login': { - inputSchema: never; - outputSchema: never; - stream: false; - params: never; - }; - 'GET /api/oauth/logout': { - inputSchema: never; - outputSchema: never; - stream: false; - params: never; - }; - 'GET /api/oauth/me': { - inputSchema: never; - outputSchema: never; - stream: false; - params: never; - }; - } - - /** - * WebSocket Route Registry - * - * Maps WebSocket route paths to their schemas - */ - export interface WebSocketRouteRegistry { - - } - - /** - * Server-Sent Events Route Registry - * - * Maps SSE route paths to their schemas - */ - export interface SSERouteRegistry { - - } - - /** - * RPC Route Registry - * - * Nested structure for RPC-style client access (e.g., client.hello.post()) - * Used by createClient() from @agentuity/frontend for type-safe RPC calls. - */ - export interface RPCRouteRegistry { - oauth: { - login: { - /** - * Route: GET /api/oauth/login - */ - get: { input: never; output: never; type: 'api'; params: never; paramsTuple: [] }; - }; - logout: { - /** - * Route: GET /api/oauth/logout - */ - get: { input: never; output: never; type: 'api'; params: never; paramsTuple: [] }; - }; - me: { - /** - * Route: GET /api/oauth/me - */ - get: { input: never; output: never; type: 'api'; params: never; paramsTuple: [] }; - }; - }; - } -} - -// Backward compatibility: also augment @agentuity/react for older versions -// that define RouteRegistry locally instead of re-exporting from @agentuity/frontend -declare module '@agentuity/react' { - export interface RouteRegistry { - 'GET /api/oauth/login': { - inputSchema: never; - outputSchema: never; - stream: false; - params: never; - }; - 'GET /api/oauth/logout': { - inputSchema: never; - outputSchema: never; - stream: false; - params: never; - }; - 'GET /api/oauth/me': { - inputSchema: never; - outputSchema: never; - stream: false; - params: never; - }; - } - export interface WebSocketRouteRegistry { - - } - export interface SSERouteRegistry { - - } - export interface RPCRouteRegistry { - oauth: { - login: { - /** - * Route: GET /api/oauth/login - */ - get: { input: never; output: never; type: 'api'; params: never; paramsTuple: [] }; - }; - logout: { - /** - * Route: GET /api/oauth/logout - */ - get: { input: never; output: never; type: 'api'; params: never; paramsTuple: [] }; - }; - me: { - /** - * Route: GET /api/oauth/me - */ - get: { input: never; output: never; type: 'api'; params: never; paramsTuple: [] }; - }; - }; - } -} - -/** - * Runtime metadata for RPC routes. - * Contains route type information for client routing decisions. - * @internal - */ -const _rpcRouteMetadata = { - "oauth": { - "login": { - "get": { - "type": "api", - "path": "/api/oauth/login" - } - }, - "logout": { - "get": { - "type": "api", - "path": "/api/oauth/logout" - } - }, - "me": { - "get": { - "type": "api", - "path": "/api/oauth/me" - } - } - } -} as const; - -// Store metadata globally for createAPIClient() to access -if (typeof globalThis !== 'undefined') { - (globalThis as Record).__rpcRouteMetadata = _rpcRouteMetadata; -} - -/** - * Type-safe API client is available from @agentuity/react - * - * @example - * ```typescript - * import { createAPIClient } from '@agentuity/react'; - * - * const api = createAPIClient(); - * const result = await api.hello.post({ name: 'World' }); - * ``` - */ - -// FOUND AN ERROR IN THIS FILE? -// Please file an issue at https://github.com/agentuity/sdk/issues -// or if you know the fix please submit a PR! diff --git a/apps/testing/oauth/src/generated/webanalytics.ts b/apps/testing/oauth/src/generated/webanalytics.ts deleted file mode 100644 index 875e63cfd..000000000 --- a/apps/testing/oauth/src/generated/webanalytics.ts +++ /dev/null @@ -1,97 +0,0 @@ -// @generated -// Auto-generated by Agentuity -// DO NOT EDIT - This file is regenerated on every build - -import type { Context } from 'hono'; -import { - BEACON_SCRIPT, - createRouter, - createWebSessionMiddleware, - getOrganizationId, - getProjectId, - isDevMode as runtimeIsDevMode, -} from '@agentuity/runtime'; -import type { AnalyticsConfig } from './analytics-config'; - -// Inject analytics config and script into HTML -// Note: Only static config is injected (org, project, devmode, tracking options) -// Session and thread IDs are read from cookies by the beacon script -// -// In production: beacon is served from CDN as a hashed asset (injected by Vite build) -// In development: beacon is served from /_agentuity/webanalytics/analytics.js route -export function injectAnalytics(html: string, analyticsConfig: AnalyticsConfig): string { - if (!analyticsConfig.enabled) return html; - - const orgId = getOrganizationId() || ''; - const projectId = getProjectId() || ''; - const isDevmode = runtimeIsDevMode(); - - // Only include static config - session/thread come from cookies - const pageConfig = { - ...analyticsConfig, - orgId, - projectId, - isDevmode, - }; - - const configScript = ``; - // Session script sets cookies and window.__AGENTUITY_SESSION__ (dynamic, not cached) - const sessionScript = ''; - - // In production, the beacon is already in HTML as a CDN asset (data-agentuity-beacon marker) - // Inject config/session BEFORE the beacon marker so config exists when beacon runs - const beaconMarker = '