Communitygithub.com

agentuity/sdk

>- Use when adding Agentuity code to a framework app and choosing where routes, pages, server functions, config, or service clients belong. Covers Next.js, Nuxt, SvelteKit, Astro, Hono, React Router, Vite with React, and TanStack Start file placement.

Qu'est-ce que sdk ?

sdk is a Claude Code agent skill that >- Use when adding Agentuity code to a framework app and choosing where routes, pages, server functions, config, or service clients belong. Covers Next.js, Nuxt, SvelteKit, Astro, Hono, React Router, Vite with React, and TanStack Start file placement.

Compatible avec~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/agentuity/sdk/tree/HEAD/skills/agentuity-frameworks

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Agentuity Framework Placement

Agentuity works with your framework's normal file layout. Put routes, pages, server functions, and config where the framework expects them. Add Agentuity clients only in server-side code.

Create-Supported Frameworks

agentuity create can scaffold these frameworks:

FrameworkAPI route locationApp UI locationDev script owner
Next.jssrc/app/api/<name>/route.tssrc/app/page.tsxNext.js
Nuxtserver/api/<name>.get.ts or .post.tsapp/app.vueNuxt
SvelteKitsrc/routes/<path>/+server.tssrc/routes/+page.svelteVite/SvelteKit
Astrosrc/pages/api/<name>.tssrc/pages/index.astroAstro
Honosrc/index.ts route handlerssrc/landing.tsx when scaffoldedHono server script

Use the framework's route handler to validate the request, then call a shared function for the real work.

Existing-App Adoption

For apps you already have, install the CLI and import the project without changing the app shape:

npm install -D @agentuity/cli
agentuity project import --name existing-app --confirm

Useful route locations:

FrameworkServer route shape
React Routerapp/routes/api.agentuity.ts, registered in app/routes.ts
TanStack Startsrc/routes/api.agentuity.tsx with server handlers
Vite + ReactA server boundary such as server.ts; browser code calls that server
Express or other routersExisting route module; import Agentuity clients server-side

Server-Only Rule

Do not expose Agentuity SDK keys to browser bundles. Service clients belong in routes, server actions, workers, scripts, or other server-only modules.

import { KeyValueClient } from '@agentuity/keyvalue';

const kv = new KeyValueClient();

export async function GET(): Promise<Response> {
  const result = await kv.get<{ checkedAt: string }>('health', 'latest');
  return Response.json({ ok: true, exists: result.exists });
}

Browser components should call your server route:

const response = await fetch('/api/agentuity-health');
const status = await response.json();

Thin Route, Shared Function

Prefer this split for AI features, background work, and service calls:

// lib/triage.ts
export async function triageMessage(message: string): Promise<{ priority: string }> {
  return { priority: message.includes('urgent') ? 'high' : 'normal' };
}
// framework route file
import { triageMessage } from '@/lib/triage';

export async function POST(request: Request): Promise<Response> {
  const body = (await request.json()) as { message?: string };
  if (!body.message) {
    return Response.json({ error: 'message is required' }, { status: 400 });
  }

  const result = await triageMessage(body.message);
  return Response.json(result);
}

This keeps route-specific code small and lets the core function move between frameworks, tests, queues, schedules, and scripts.

Hono Middleware Option

In Hono apps, use direct clients by default when portability matters. Use @agentuity/hono when accessing clients through Hono context improves readability:

import { Hono } from 'hono';
import { agentuity } from '@agentuity/hono';
import type { Services } from '@agentuity/hono';

const app = new Hono<{ Variables: Pick<Services, 'kv'> }>();

app.use('*', agentuity());

app.get('/api/preferences/:userId', async (c) => {
  const result = await c.var.kv.get('preferences', c.req.param('userId'));
  return c.json({ exists: result.exists });
});

AI Gateway, database, object storage, webhooks, and Coder are direct clients.

Common Mistakes

MistakeBetter approach
Putting service clients in browser componentsCall a server route that owns the client
Adding new folders that bypass framework conventionsUse the framework's route/page locations
Duplicating AI or service logic in every routePut shared work in a plain function and import it
Assuming every framework uses the same API route pathCheck the route table before editing
Putting SDK keys in public env prefixesKeep AGENTUITY_SDK_KEY server-side

Useful Docs

Skills associés