Skip to content

refactor: middleware architecture for v3 - composable packages#1255

Open
Huijiro wants to merge 45 commits intomainfrom
v3
Open

refactor: middleware architecture for v3 - composable packages#1255
Huijiro wants to merge 45 commits intomainfrom
v3

Conversation

@Huijiro
Copy link
Copy Markdown
Member

@Huijiro Huijiro commented Mar 23, 2026

Summary

This PR introduces a new modular architecture for Agentuity, breaking the "batteries included" @agentuity/runtime into composable packages. The goal is to let users choose their framework while Agentuity provides services as middleware.


What Changed

New Packages

Package Purpose
@agentuity/otel OpenTelemetry initialization, Logger
@agentuity/local Local development services (Bun SQLite) with runtime detection
@agentuity/services Cloud services + event providers + local fallback
@agentuity/hono agentuity() middleware for Hono

Architecture

Before (v2):
createApp() → everything bundled together

After (v3):
agentuity() middleware
    ├── @agentuity/otel (tracing, logging)
    └── @agentuity/services
            ├── Cloud services (when SDK key present)
            ├── @agentuity/local (fallback, Bun only)
            └── Event providers (session, evalrun)

Usage

// Before (v2) - deprecated
import { createApp } from '@agentuity/runtime';
export default await createApp({ router, agents });

// After (v3)
import { Hono } from 'hono';
import { agentuity } from '@agentuity/hono';

const app = new Hono();
app.use('*', agentuity());

app.get('/data', async (c) => {
  const { kv, logger } = c.var;
  const data = await kv.get('key');
  return c.json(data);
});

export default app;

Completed Migrations

  • OTel extraction - @agentuity/otel with registerOtel(), Logger
  • Logger interface - Single source in @agentuity/core (removed duplicate)
  • Local services - @agentuity/local with Bun SQLite + runtime detection
  • Event providers - SessionEventProvider, EvalRunEventProvider moved to services
  • Services initialization - Cloud vs local auto-detection
  • Hono middleware - agentuity() composes OTel + services
  • Deprecation warning - createApp() warns users

Strategic Questions (Open for Discussion)

These are fundamental architectural decisions that need community/team input:

1. Agent Orchestration: Build vs Integrate?

Current state: @agentuity/runtime has its own createAgent() with:

  • Agent registry
  • Agent-to-agent invocation (ctx.invoke())
  • Agent middleware

Options:

Approach Pros Cons
Build @agentuity/agents Full control, tight integration with services Maintenance burden, reinventing the wheel
Integrate with Vercel AI SDK Industry standard, great DX, actively maintained Vendor lock-in concerns, may not fit all use cases
Integrate with TanStack AI Framework-agnostic, growing ecosystem Newer, less mature
Hybrid - provider plugins Best of both worlds, user choice More complexity, multiple codepaths

Questions:

  • What's the value proposition of our own agent abstraction?
  • Can we provide Agentuity services as plugins to existing frameworks?
  • Do we need agent-to-agent invocation, or is that an anti-pattern?

2. Conversation/Chat: Build vs Integrate?

Current state: packages/runtime/src/session.ts (~2000 lines) with:

  • Thread, Session management
  • ThreadProvider, SessionProvider interfaces
  • Cloud WebSocket persistence
  • Local SQLite persistence

Options:

Approach Pros Cons
Build @agentuity/chat Tailored for our use case Significant maintenance, may diverge from standards
Provide primitives only Flexible, users choose their stack Less out-of-the-box value
Integrate with Vercel AI SDK Built-in chat/conversation patterns Locks users into that ecosystem
Integrate with TanStack AI Framework agnostic conversation state Newer, patterns still emerging

Key consideration: Thread/Session has Hono-specific code (cookies, context). Extracting requires making Hono a peer dependency.

Questions:

  • Is conversation state a core product feature or a commodity?
  • Should we focus on storage primitives and let frameworks handle the abstraction?
  • How much value does our Thread/Session abstraction provide over alternatives?

3. Agent Evaluation System

Current state: @agentuity/evals package with:

  • Evaluation framework for agents
  • Built-in evaluators (quality, safety, performance)
  • Custom evaluator support
  • Integration with EvalRunEventProvider (now in @agentuity/services)
  • Results storage and reporting

Options:

Approach Pros Cons
Keep as-is, @agentuity/evals Already extracted, working May need updates for new architecture
Integrate with existing eval frameworks Leverage ecosystem tools May not fit our agent model
Make framework-agnostic Works with any agent implementation More abstraction, less tight integration
Deprecate, recommend external tools Less maintenance Loses unique value prop

Questions:

  • Is agent evaluation a core differentiator for Agentuity?
  • Should evals be tied to our agent abstraction or work with any agent?
  • How does this integrate with third-party agent frameworks (Vercel AI SDK, TanStack)?
  • Should we support third-party eval frameworks (e.g., Ragas, DeepEval)?

4. Framework Adapters

Not started:

  • @agentuity/next - Next.js middleware
  • @agentuity/express - Express middleware
  • @agentuity/fastify - Fastify middleware

Questions:

  • Which frameworks should we prioritize?
  • Should we wait for the agent/chat/evals decisions first?
  • Can we provide service injection without framework-specific packages?

5. Local Services for Non-Bun Runtimes

Current: @agentuity/local only supports Bun (SQLite)

Potential runtimes:

  • Node.js (better-sqlite3, libsql)
  • Cloudflare Workers (D1, KV)
  • Deno (native SQLite)

Questions:

  • Should we add Node.js support now?
  • Use Drizzle ORM for cross-platform?
  • Keep it Bun-only, expect cloud services for other runtimes?

Breaking Changes

This is a v3 breaking change with no backward compatibility guarantees:

  1. createApp() is deprecated (will be removed)
  2. Direct imports from @agentuity/runtime internals will break
  3. Service access pattern changes from globals to c.var in Hono

Decision Timeline

Topic Blocking? Target Decision
Agent orchestration approach Yes - blocks @agentuity/agents Pre-merge discussion
Chat/conversation approach Partially - blocks extraction Post-merge, pre-next-release
Evaluation system direction Yes - relates to agent decision Pre-merge discussion
Framework adapters No Post-merge, demand-driven
Non-Bun local services No Post-merge, demand-driven

Looking for feedback on:

  1. Agent orchestration: build our own vs integrate with AI SDKs?
  2. Chat/conversation: extract or defer?
  3. Evaluation system: keep, integrate, or deprecate?
  4. Priority order for follow-up work

Huijiro and others added 30 commits March 10, 2026 14:39
…ead AST code

- Workbench schema endpoint now generates TypeScript interface syntax
  from JSON Schema (via runtime toJSONSchema) instead of requiring
  Zod source strings from the AST-extracted metadata. Falls back to
  metadata strings only when no runtime schema is available.

- Add jsonSchemaToTypeScript() utility in workbench.ts that converts
  JSON Schema → clean TypeScript type notation for display:
  { name: string; age: number; tags?: string[] }

- Delete findCreateAppEndPosition() from ast.ts — dead code, exported
  but never imported anywhere.

- 20 new tests covering all JSON Schema → TypeScript conversions:
  primitives, objects, optionals, descriptions, arrays, unions,
  intersections, enums, literals, nullables, records, nested objects.
…hemaToTypeScript

Address CodeRabbit review feedback:
- Escape quotes, backslashes, and newlines in const/enum string values
- Quote property keys that aren't valid JS identifiers (hyphens, spaces, leading digits)
- 3 new test cases covering both fixes
Remove 402 lines of dead code from the AST pipeline:

- Delete analyzeWorkbench() + parseConfigObject() — only imported by
  the dead workbench.ts file, never used in production
- Delete checkFunctionUsage() — exported but never imported anywhere
- Delete checkRouteConflicts() — exported but never imported anywhere
- Delete WorkbenchAnalysis interface — only used by dead code
- Remove WorkbenchConfig import from ast.ts (no longer needed)
- Delete packages/cli/src/cmd/build/workbench.ts entirely — the whole
  file was dead code (getWorkbench, generateWorkbenchMainTsx, etc.
  are superseded by vite/workbench-generator.ts)
- Remove analyzeWorkbench tests from ast.test.ts (testing dead code)

ast.ts: 3,526 → 3,124 lines (402 lines removed, cumulative with
previous findCreateAppEndPosition deletion)
The lifecycle generator now uses TypeScript's own type checker to
extract the setup() return type instead of walking AST literals and
guessing types from values. This handles:

- Inline setup in createApp({ setup: () => ... })
- Exported setup functions (function decl or const arrow)
- Shorthand property: createApp({ setup })
- Variable references: setup: () => someVar
- Async functions (Promise unwrapping)
- Any pattern TypeScript itself can resolve

Also extract getDevmodeDeploymentId into ids.ts (pure hash, not AST).

ast.ts consumers remaining: only parseRoute (route-discovery.ts)
…iscovery + app-router-detector

createRouter() no longer wraps Hono methods — it's now just `new Hono()`
with Agentuity's Env type. This preserves Hono's full Schema type inference
chain, enabling `typeof router` to encode all route types.

The routeId lookup (for OTel spans) and returnResponse auto-conversion that
createRouter previously did will move to entry-file middleware in a follow-up.

agent-discovery.ts: rewritten to import() agent files at build time instead
of AST-parsing with acorn-loose. The agent instance already knows its own
metadata, schemas, and evals. Schemas are now extracted as JSON Schema
strings via toJSONSchema() instead of Zod source strings via astring.

app-router-detector.ts: rewritten to use TypeScript's compiler API instead
of acorn-loose. Detects createApp({ router }) patterns for explicit routing.

Both rewrites eliminate acorn-loose/astring usage from their respective files.
Only ast.ts itself still imports acorn-loose (for parseRoute, used by
route-discovery.ts).

Tests: 18 agent-discovery tests, 8 app-router-detector tests, 8 lifecycle
tests, dev-registry-generation tests all pass. Runtime: 665 tests pass.
- Delete ast.ts (3,120 lines) — entire acorn-loose + astring AST pipeline
- Delete route-migration.ts (793 lines) — file-based routing migration
- Delete api-mount-path.ts (87 lines) — file-based path computation
- Remove acorn-loose + astring from package.json
- Remove file-based routing fallback from entry-generator.ts
- Remove migration prompts from dev/index.ts and vite-bundler.ts
- Remove src/api/ directory watcher from file-watcher.ts
- Remove migrateRoutes CLI option
- Delete 15 test files testing deleted AST/file-based routing code
- Rewrite route-discovery + dev-registry tests for new architecture

Net: -13,073 lines deleted, +199 lines added
- Import toForwardSlash from normalize-path.ts instead of duplicating
- Replace existsSync with Bun.file().exists() in lifecycle-generator,
  app-router-detector, and agent-discovery
- Import toJSONSchema from @agentuity/schema public entry point (resolved
  from user's node_modules) instead of reaching into src/ internals
- Remove createAgent substring gate — check exported value shape instead,
  supporting re-exported agents
- Default createRouter S generic to BlankSchema ({}) to match Hono 4.7.13
- Migrate integration-suite, e2e-web, svelte-web, auth-package-app,
  webrtc-test, nextjs-app, tanstack-start, vite-rsc-app to explicit
  createApp({ router }) pattern
- Create combined router.ts files for apps with multiple route files
- Expose agent.evals on AgentRunner (was missing, breaking eval discovery)
- Deduplicate agents by name (re-exported agents from index.ts)
- Update route-metadata-nested tests for explicit routing
…estart loop

- Runtime: createApp() returns fetch/port/hostname for bun --hot to
  hot-swap the server's request handler without process restart
- Runtime: skip Bun.serve() in dev mode (bun --hot manages server
  via default export)
- Runtime: add idempotent OTel re-registration guard for hot reloads
- Runtime: pass cors/compression config directly to middleware instead
  of lazy global lookup via getAppConfig()
- Runtime: remove getAppState/getAppConfig/setAppConfig globals
  (config passed directly, app state was always {})
- Runtime: add typed _globals.ts for Symbol.for() state and globals.d.ts
  for string-keyed globalThis properties, eliminating unsafe casts
- Runtime: use Symbol.for() pattern in _process-protection.ts
- Runtime: guard one-time log messages (server started, local services)
  to prevent reprinting on hot reloads
- Runtime: downgrade internal port messages to debug level
- CLI: use bun --hot --no-clear-screen for backend subprocess
- CLI: remove file-watcher.ts usage, restart loop, stopBunServer,
  cleanupForRestart — bun --hot handles all backend HMR
- CLI: run 'Preparing dev server' once at startup instead of on
  every file change (~490 lines removed from dev/index.ts)
In production mode, startServer() already calls Bun.serve() on the
configured port. Bun v1.2+ also auto-serves when the default export
has fetch + port properties (added in c98ce19 for --hot support),
causing a second bind attempt and EADDRINUSE.

Strip fetch/port/hostname from the returned AppResult in production
so only the explicit Bun.serve() is active. Dev mode keeps them for
bun --hot auto-serve.
Resolve conflicts:
- modify/delete: keep v2's deletions of generated files (app.ts, routes.ts),
  ast.ts, and route-migration.ts — superseded by v2's import-based architecture
- agent-discovery.ts: keep v2's import-based version, port duplicate eval name
  detection from main (cab51e2)
- dev/index.ts: keep v2's bun --hot version — main's file-watcher restart loop
  fixes (5b7f9b8) don't apply since v2 removed the restart loop

Auto-merged from main:
- Gateway URL fallback update (agentuity.ai → catalyst.agentuity.cloud)
- Windows path fix for AI SDK patches (buildPatchFilter)
- Task status aliases, sandbox events, OIDC commands, monitoring
- Coder TUI updates, API reference docs, various CLI fixes
Bun --hot creates the server from the default export's properties.
Without the websocket handler, WebSocket upgrades fail with:
'To enable websocket support, set the "websocket" object in Bun.serve({})'

Add websocket from hono/bun to the AppResult (and strip it in
production alongside fetch/port/hostname).
json5 was not declared as a dependency in cli/package.json, causing
a type error. Use the existing parseJSONC utility (from utils/jsonc)
which handles tsconfig.json comments and trailing commas.
## @agentuity/migrate package (new)

A CLI tool to migrate v1 projects to v2:
- `npx @agentuity/migrate` — guided migration with codemods
- Deletes `src/generated/` directory
- Removes `bootstrapRuntimeEnv()` call from app.ts
- Transforms routes from createRouter() mutable style to new Hono<Env>() chained
- Generates src/api/index.ts and src/agent/index.ts barrels
- Adds migration comments for setup/shutdown lifecycle
- Guides on agentuity.config.ts deprecation
- Detects frontend using removed APIs (createClient, useAPI, RPCRouteRegistry)
- Runs bun install and typecheck post-migration

## agentuity.config.ts deprecation

- New app-config-extractor.ts extracts analytics/workbench from createApp()
- config-loader.ts emits deprecation warning when loading agentuity.config.ts
- getWorkbenchConfig() now prefers runtime config from createApp()
- dev/index.ts and vite-builder.ts use loadRuntimeConfig()

Config consolidation in v2:
- Runtime config (analytics, workbench, cors, etc.) → createApp() only
- Vite config (plugins, define, render, bundle) → vite.config.ts
- agentuity.config.ts → deprecated, delete entirely

## Documentation

- Updated migration-guide.mdx with v1→v2 tab
- Includes automated migration instructions and manual steps
- Covers all breaking changes and troubleshooting
This commit consolidates several v2 improvements:

### bun-dev-server error diagnostics
- Add app.ts validation to detect v1 pattern (destructuring without export default)
- Capture Bun stderr/stdout and show in error messages
- Add port cleanup with ensurePortAvailable() to kill orphan processes
- Warn before starting if app.ts has common issues
- Export validation functions for testing

### Process manager for dev mode
- New ProcessManager class to track all spawned processes/servers
- Ordered cleanup (LIFO for processes)
- Force kill fallback after timeout
- Integrated into dev/index.ts for cleanup on failure/shutdown

### Remove agentuity.config.ts support
- Deleted loadAgentuityConfig from config-loader.ts
- getWorkbenchConfig now only takes (dev, runtimeConfig) - no config file fallback
- Users must use vite.config.ts for Vite config
- Users must use createApp() for runtime config (workbench, analytics)

### Remove auto-adding React plugin
- Vite no longer auto-adds @vitejs/plugin-react
- Users must configure frontend framework in vite.config.ts

### Deprecate @agentuity/react
- Added deprecation notice to README.md and package.json
- @agentuity/auth no longer depends on @agentuity/react
- AuthProvider now accepts callback props instead of relying on AgentuityProvider

### Migrate tool updates
- Detect missing vite.config.ts when frontend exists
- Detect deprecated @agentuity/react API usage
- Detect agentuity.config.ts and suggest migration

Tests: Updated workbench tests, removed define-config test (obsolete), added process-manager tests
Tests verify:
- publicDir is set correctly in dev mode config
- Public files are served at root paths in dev
- Public files maintain directory structure
- Various file types are handled correctly
- Edge cases (empty folder, hidden files, subdirectories)
- Integration with vite-builder functions
Add tests for dev server orchestration covering:

- dev-lock.test.ts: Lockfile management, orphan process cleanup,
  edge cases for corrupted/missing lockfiles

- ws-proxy.test.ts: Front-door TCP proxy routing decisions,
  error handling, URL parsing, query strings

- dev-server-integration.test.ts: Full lifecycle testing,
  crash recovery, hot reload validation, error resilience

All 60 tests pass covering:
- Startup/shutdown with port cleanup
- Hot reload behavior (Bun --hot, Vite HMR)
- Crash recovery (SIGTERM/SIGKILL escalation)
- WS proxy routing (HTTP→Vite, WS upgrade→Bun)
- Error resilience (TypeScript errors, v1 patterns)
Merge main (1.0.54) into v2 branch.

Resolution strategy:
- Deleted files (v2): Kept v2's removal of src/generated/*, ast.ts, route-migration.ts
- Dev server files: Kept v2's no-bundle architecture with bun --hot
- Package versions: Took main's higher versions
- New features from main: Accepted (oauth, sandbox jobs, service packages)
- API docs: Took main's updated documentation

Key changes merged from main:
- New standalone service packages (@agentuity/db, @agentuity/email, etc.)
- OAuth service support
- Sandbox job commands
- Updated CLI commands for all cloud services
- API reference documentation updates
Since React is no longer auto-added by the CLI, each project with a
frontend needs its own vite.config.ts with the appropriate plugins.

Added vite.config.ts for:
- apps/docs (React + Tailwind + MDX + TanStack Router)
- apps/testing/e2e-web (React)
- apps/testing/cloud-deployment (React)
- apps/testing/integration-suite (React)
- apps/testing/auth-package-app (React)
- apps/testing/oauth (React)
- apps/testing/webrtc-test (React)
- apps/testing/svelte-web (Svelte - pending investigation for CLI build)

Updated vite-builder.ts to properly merge user vite.config.ts:
- User plugins now come FIRST (important for framework plugins like Svelte)
- User config values are preserved unless overridden by Agentuity-specific needs
- Removed mergeConfig in favor of explicit spread to avoid array merge issues

Note: Svelte builds work with vite v8.0.1 building client environment for production...
�[2K
transforming...✓ 1 modules transformed. but fail when built
through the CLI. This requires further investigation into how the
Svelte plugin interacts with the CLI's build process.
…lity

## Problem
Svelte 5 builds failed when invoked through CLI's programmatic viteBuild()
call, but worked correctly with `bunx vite build`. The error showed the
Svelte compile plugin receiving already-compiled JavaScript instead of
Svelte source code.

## Root Cause
Bun's module loading system has issues with Vite's plugin pipeline when
importing Vite and calling build() programmatically. Certain plugins like
@sveltejs/vite-plugin-svelte receive already-compiled code, possibly due to
module state caching or transformation order issues.

## Solution
For client builds, spawn `bun x vite build` as a subprocess instead of
importing Vite and calling build() programmatically. This gives Vite complete
control over its module loading and plugin execution, avoiding Bun's
module system entirely.

Workbench builds continue using programmatic viteBuild() since those use
our own React plugin without external framework plugins.

## Additional Changes
- Updated vite.config.ts for all test projects to include root and input
  path (required when spawning vite as subprocess)
- Updated svelte-web agentuity.config.ts to v2 format (removed plugins)
- Removed temporary svelte.config.js that was added during debugging

## Testing
All test projects now build successfully:
- apps/testing/e2e-web (React)
- apps/testing/svelte-web (Svelte 5)
- apps/testing/cloud-deployment (React)
- apps/testing/integration-suite (React)
- apps/testing/auth-package-app (React)
- apps/testing/oauth (React)
- apps/testing/webrtc-test (React)
The migrate package was missing from the root tsconfig.json references,
causing it to not be built during CI builds.
The evals package depends on @agentuity/runtime and @agentuity/schema
but was missing the TypeScript project references, causing build failures.
Since the CLI now spawns vite as a subprocess for client builds,
projects need a vite.config.ts file with the proper input path.

Added:
- templates/_base/vite.config.ts with React plugin and input path
- vite and @vitejs/plugin-react to devDependencies in package.json
When vite.config.ts sets root='.' and input='src/web/index.html',
vite outputs the HTML at client/src/web/index.html instead of
client/index.html. The runtime now checks both locations.

This fixes cloud deployment tests that were failing because
the analytics beacon injection couldn't find the HTML file.
Huijiro added 8 commits March 20, 2026 15:32
The previous logic incorrectly fell back to process.cwd()/.agentuity/client
when running from the .agentuity/ directory, resulting in a wrong path
like .agentuity/.agentuity/client.

Now simply uses import.meta.dir/client (where app.js runs from) and
checks for index.html at both:
- client/index.html (flat output)
- client/src/web/index.html (nested vite output)
Extract OpenTelemetry setup from runtime into its own package.
This will be composed with @agentuity/services in framework-specific
implementations.
Extract service initialization from runtime into its own package.
Provides kv, stream, vector, queue, email, task, schedule services.

This will be composed with @agentuity/otel in framework-specific
implementations.
Composes @agentuity/otel and @agentuity/services into a single
agentuity() middleware for Hono.

Usage:
  import { Hono } from 'hono';
  import { agentuity } from '@agentuity/hono';

  const app = new Hono();
  app.use('*', agentuity());
- createApp now uses agentuity() middleware from @agentuity/hono
- Logger interface consolidated in @agentuity/core (removed duplicate)
- Services still created via runtime's createServices() for now
  (thread/session providers not yet migrated)
Provides local storage implementations for development:
- Runtime detection (bun, node, deno, workers)
- Bun SQLite implementations for kv, stream, vector, queue, email, task
- Exports interfaces so users can implement their own

Users can provide custom implementations via service overrides.
- Add session event providers (local, http, json, composite)
- Add evalrun event providers (local, http, json, composite)
- Add local services support via @agentuity/local (optional peer dep)
- Auto-select cloud vs local services based on SDK key
- Export event providers and services interfaces
- createApp() now warns users to migrate to agentuity() middleware
- Updated @agentuity/hono to use @agentuity/services with local support
@agentuity-agent
Copy link
Copy Markdown

agentuity-agent bot commented Mar 23, 2026

The latest Agentuity deployment details.

Project Deployment Preview Updated (UTC)
docs 🔴 Failed (deploy_e5701699dfb39f11eb90b3e5621b126d) - 2026-03-25T21:56:54Z

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55fa4293-07b4-4f94-a57d-521408268392

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands and usage tips.

@Huijiro Huijiro changed the base branch from main to v2 March 23, 2026 19:54
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 23, 2026

📦 Canary Packages Published

version: 1.0.54-480694f

Packages
Package Version URL
@agentuity/sandbox 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-sandbox-1.0.54-480694f.tgz
@agentuity/postgres 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-postgres-1.0.54-480694f.tgz
@agentuity/email 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-email-1.0.54-480694f.tgz
@agentuity/runtime 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-runtime-1.0.54-480694f.tgz
@agentuity/keyvalue 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-keyvalue-1.0.54-480694f.tgz
@agentuity/task 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-task-1.0.54-480694f.tgz
@agentuity/schedule 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-schedule-1.0.54-480694f.tgz
@agentuity/opencode 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-opencode-1.0.54-480694f.tgz
@agentuity/auth 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-auth-1.0.54-480694f.tgz
@agentuity/cli 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-cli-1.0.54-480694f.tgz
@agentuity/vector 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-vector-1.0.54-480694f.tgz
@agentuity/core 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-core-1.0.54-480694f.tgz
@agentuity/workbench 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-workbench-1.0.54-480694f.tgz
@agentuity/server 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-server-1.0.54-480694f.tgz
@agentuity/frontend 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-frontend-1.0.54-480694f.tgz
@agentuity/migrate 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-migrate-1.0.54-480694f.tgz
@agentuity/queue 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-queue-1.0.54-480694f.tgz
@agentuity/drizzle 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-drizzle-1.0.54-480694f.tgz
@agentuity/local 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-local-1.0.54-480694f.tgz
@agentuity/hono 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-hono-1.0.54-480694f.tgz
@agentuity/otel 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-otel-1.0.54-480694f.tgz
@agentuity/services 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-services-1.0.54-480694f.tgz
@agentuity/react 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-react-1.0.54-480694f.tgz
@agentuity/claude-code 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-claude-code-1.0.54-480694f.tgz
@agentuity/schema 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-schema-1.0.54-480694f.tgz
@agentuity/db 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-db-1.0.54-480694f.tgz
@agentuity/webhook 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-webhook-1.0.54-480694f.tgz
@agentuity/coder 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-coder-1.0.54-480694f.tgz
@agentuity/evals 1.0.54-480694f https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-evals-1.0.54-480694f.tgz
Install

Add to your package.json:

{
  "dependencies": {
    "@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-sandbox-1.0.54-480694f.tgz",
    "@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-postgres-1.0.54-480694f.tgz",
    "@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-email-1.0.54-480694f.tgz",
    "@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-runtime-1.0.54-480694f.tgz",
    "@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-keyvalue-1.0.54-480694f.tgz",
    "@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-task-1.0.54-480694f.tgz",
    "@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-schedule-1.0.54-480694f.tgz",
    "@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-opencode-1.0.54-480694f.tgz",
    "@agentuity/auth": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-auth-1.0.54-480694f.tgz",
    "@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-cli-1.0.54-480694f.tgz",
    "@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-vector-1.0.54-480694f.tgz",
    "@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-core-1.0.54-480694f.tgz",
    "@agentuity/workbench": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-workbench-1.0.54-480694f.tgz",
    "@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-server-1.0.54-480694f.tgz",
    "@agentuity/frontend": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-frontend-1.0.54-480694f.tgz",
    "@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-migrate-1.0.54-480694f.tgz",
    "@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-queue-1.0.54-480694f.tgz",
    "@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-drizzle-1.0.54-480694f.tgz",
    "@agentuity/local": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-local-1.0.54-480694f.tgz",
    "@agentuity/hono": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-hono-1.0.54-480694f.tgz",
    "@agentuity/otel": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-otel-1.0.54-480694f.tgz",
    "@agentuity/services": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-services-1.0.54-480694f.tgz",
    "@agentuity/react": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-react-1.0.54-480694f.tgz",
    "@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-claude-code-1.0.54-480694f.tgz",
    "@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-schema-1.0.54-480694f.tgz",
    "@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-db-1.0.54-480694f.tgz",
    "@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-webhook-1.0.54-480694f.tgz",
    "@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-coder-1.0.54-480694f.tgz",
    "@agentuity/evals": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-evals-1.0.54-480694f.tgz"
  }
}

Or install directly:

bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-sandbox-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-postgres-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-email-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-runtime-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-keyvalue-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-task-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-schedule-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-opencode-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-auth-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-cli-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-vector-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-core-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-workbench-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-server-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-frontend-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-migrate-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-queue-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-drizzle-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-local-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-hono-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-otel-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-services-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-react-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-claude-code-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-schema-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-db-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-webhook-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-coder-1.0.54-480694f.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.54-480694f/agentuity-evals-1.0.54-480694f.tgz

Huijiro added 6 commits March 25, 2026 15:02
…kage

## TypeScript 6.0 + tsgo Migration

- Update TypeScript from ^5.9.0 to ^6.0.2
- Add @typescript/native-preview for tsgo (native Go compiler)
- Update build scripts to use  instead of
- Fix type errors caught by stricter tsgo:
  - websocket-manager.ts: narrow ArrayBufferView to exclude SharedArrayBuffer
  - react.tsx: add explicit return types for functions with unexported external types
  - workbench/tsconfig.json: remove deprecated baseUrl option

## New @agentuity/adapter Package

Create minimal HTTP adapter package (~28KB) for service clients:
- createServerFetchAdapter() - HTTP client adapter
- buildClientHeaders() - auth header builder
- ServiceAdapterConfig, BuildClientHeadersOptions types
- redact() - sensitive data redaction utility
- Logger type re-export

## Client Package Migration

Update 7 service client packages to use @agentuity/adapter instead of
@agentuity/server, reducing transitive bundle size from ~1.2MB to ~28KB:
- @agentuity/keyvalue
- @agentuity/queue
- @agentuity/email
- @agentuity/vector
- @agentuity/webhook
- @agentuity/schedule
- @agentuity/task

## @agentuity/server Updates

- Add @agentuity/adapter as dependency
- Re-export adapter functions for backward compatibility
- Update to TypeScript 6.0 and tsgo build

## @agentuity/db

- Remove unnecessary @agentuity/server dependency (uses core directly)

Resolves bundle size issue where users pulling a single client package
would transitively get all service interfaces from @agentuity/core.
Major refactoring of service packages:

1. Rename @agentuity/otel → @agentuity/analytics
   - Vercel-style auto-initialization from AGENTUITY_* env vars
   - Lazy-loaded exports: tracer, logger, meter
   - Simplified API: import '@agentuity/analytics' auto-configures
   - sideEffects: true for auto-init on import

2. Delete @agentuity/services package
   - Was redundant with @agentuity/runtime's own service init
   - @agentuity/hono now initializes clients directly
   - Event providers remain in runtime/src/services/

3. Create @agentuity/stream package
   - StreamClient wrapping StreamStorageService
   - Fills gap in dedicated client packages

4. Update @agentuity/runtime
   - Remove duplicate OTel implementation
   - Remove 14 @opentelemetry/* dependencies
   - Use @agentuity/analytics for telemetry
   - Keep otel/config.ts as backwards-compatible wrapper

Package dependency changes:
- @agentuity/hono: depends on analytics + dedicated clients
- @agentuity/runtime: depends on analytics (removed OTel deps)

This consolidates service clients into dedicated packages and
simplifies the telemetry initialization pattern.
1. Rename @agentuity/analytics → @agentuity/telemetry
   - Server-side OTel (traces, metrics, logs)
   - Clear naming: 'telemetry' = infrastructure observability
   - Exports: tracer, logger, meter, register()

2. Simplify build scripts
   - Remove redundant sequential package builds
   - tsgo handles all package builds via project references
   - Build time: 30s → 3.6s for packages

This distinguishes server telemetry from browser analytics:
- @agentuity/telemetry → Server OTel (traces, metrics, logs)
- @agentuity/frontend/analytics → Browser (page views, vitals)
- build: just packages (1.5s)
- build:apps: test apps only
- build:all: packages + apps

This separates concerns:
- Package builds are fast (tsgo)
- App builds are optional (for testing)
- CI can choose what to build
- New @agentuity/analytics package for browser analytics
- Beacon imported directly: `import '@agentuity/analytics/beacon'`
- No special serving by runtime - works with any bundler
- @agentuity/frontend re-exports for backwards compatibility

Package structure:
- beacon.ts: Auto-initializing tracking (page views, vitals, scroll)
- client.ts: Programmatic API (track, identify, flush)
- config.ts: Config from window.__AGENTUITY_ANALYTICS__
- types.ts: Shared type definitions

This enables standalone use in any frontend framework.
- Remove threadId from analytics payload
- Remove session.js route from runtime
- Remove session script injection from HTML
- Analytics is now fully standalone - no runtime coupling

Users who need thread context can add it themselves via:
  identify(userId, { threadId: '...' })
Base automatically changed from v2 to main March 27, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant