Using Standalone Packages — Agentuity Documentation

Using Standalone Packages

Use Agentuity services from any Node.js or Bun application without the full runtime

Need to use Agentuity services from a Next.js route, Express server, or standalone script? Each service is available as a lightweight npm package with the same API you already know from ctx.*.

Available Packages

PackageInstallDescription
@agentuity/keyvaluebun add @agentuity/keyvalueStore and retrieve data by key with TTL support
@agentuity/vectorbun add @agentuity/vectorSemantic search with automatic embedding generation
@agentuity/sandboxbun add @agentuity/sandboxCreate and manage isolated execution environments
@agentuity/queuebun add @agentuity/queuePublish messages to worker and pub/sub queues
@agentuity/dbbun add @agentuity/dbExecute SQL queries and inspect table schemas
@agentuity/emailbun add @agentuity/emailSend and receive emails with managed addresses
@agentuity/webhookbun add @agentuity/webhookManage webhook endpoints and track deliveries
@agentuity/schedulebun add @agentuity/scheduleCreate cron-based scheduled jobs
@agentuity/taskbun add @agentuity/taskTrack work items with comments, tags, and attachments

Quick Example

import { KeyValueClient } from '@agentuity/keyvalue';
 
const kv = new KeyValueClient();
await kv.set('cache', 'user:123', { name: 'Alice', role: 'admin' });
const result = await kv.get('cache', 'user:123');

When to Use What

Agentuity services are accessible four ways, depending on where your code runs:

  • Agent handler (ctx.*): Inside a createAgent handler. Services are pre-configured on the context object.
  • Route handler (c.var.*): Inside a createRouter route. Same services, accessed via Hono context variables.
  • Standalone package: From any Node.js or Bun app (Next.js, Express, scripts). Install one package, set an env var.
  • REST API: Direct HTTP access from any language or environment.
ServiceAgent (ctx.*)Route (c.var.*)Standalone PackageREST API
Key-Valuectx.kvc.var.kv@agentuity/keyvalueAPI
Vectorctx.vectorc.var.vector@agentuity/vectorAPI
Sandboxctx.sandboxc.var.sandbox@agentuity/sandboxAPI
Queuesctx.queuec.var.queue@agentuity/queueAPI
DatabaseN/AN/A@agentuity/dbAPI
Emailctx.emailc.var.email@agentuity/emailAPI
WebhooksN/AN/A@agentuity/webhookAPI
Schedulesctx.schedulec.var.schedule@agentuity/scheduleAPI
Tasksctx.taskc.var.task@agentuity/taskAPI

Key-Value Storage

Fast lookups, caching, configuration, and rate limiting.

bun add @agentuity/keyvalue
import { KeyValueClient } from '@agentuity/keyvalue';
 
const kv = new KeyValueClient();
 
// Store with optional TTL (in seconds)
await kv.set('cache', 'session:abc', { userId: '123' }, { ttl: 3600 });
 
// Retrieve
const result = await kv.get('cache', 'session:abc');
if (result.exists) {
  console.log(result.data);
}
 
// Search keys by keyword
const matches = await kv.search('cache', 'session');
 
// Delete
await kv.delete('cache', 'session:abc');

Constructor options:

OptionTypeDefaultDescription
apiKeystringAGENTUITY_SDK_KEY env varAPI key for authentication
urlstringAuto-detected from regionBase URL for the KV API
orgIdstring-Organization ID for multi-tenant operations (optional)
loggerLoggerMinimal loggerCustom logger instance

Semantic search with automatic embedding generation.

bun add @agentuity/vector
import { VectorClient } from '@agentuity/vector';
 
const vector = new VectorClient();
 
// Upsert documents (embeddings are generated automatically)
await vector.upsert('docs', {
  key: 'doc-1',
  document: 'Agentuity provides cloud-native agent hosting',
  metadata: { source: 'readme' },
});
 
// Search by natural language query
const results = await vector.search('docs', {
  query: 'how to deploy agents',
  limit: 5,
});

Constructor options:

OptionTypeDefaultDescription
apiKeystringAGENTUITY_SDK_KEY env varAPI key for authentication
urlstringAuto-detected from regionBase URL for the Vector API
orgIdstring-Organization ID for multi-tenant operations (optional)
loggerLoggerMinimal loggerCustom logger instance

Sandbox

Isolated execution environments for running untrusted code, build pipelines, or compute jobs.

bun add @agentuity/sandbox
import { SandboxClient } from '@agentuity/sandbox';
 
const client = new SandboxClient();
 
// One-shot execution (creates, runs, destroys automatically)
const result = await client.run(
  { command: { exec: ['echo', 'hello world'] } },
  { stdout: process.stdout, stderr: process.stderr }
);
console.log('Exit code:', result.exitCode);
 
// Interactive sandbox (long-lived)
const sandbox = await client.create({ runtime: 'bun:1' });
await sandbox.execute({ command: ['bun', 'install'] });
await sandbox.writeFiles([{ path: 'index.ts', content: Buffer.from('console.log("hi")') }]);
await sandbox.destroy();

Constructor options:

OptionTypeDefaultDescription
apiKeystringAGENTUITY_SDK_KEY env varAPI key for authentication
urlstringAuto-detected from regionBase URL for the Sandbox API
orgIdstring-Organization ID for multi-tenant operations (optional)
loggerLoggerMinimal loggerCustom logger instance

Message Queues

Publish messages to worker and pub/sub queues for asynchronous processing.

bun add @agentuity/queue
import { QueueClient } from '@agentuity/queue';
 
const queue = new QueueClient();
 
// Create a queue
await queue.createQueue('notifications');
 
// Publish a message
await queue.publish('notifications', {
  type: 'welcome',
  userId: '123',
});
 
// Delete a queue
await queue.deleteQueue('notifications');

Constructor options:

OptionTypeDefaultDescription
apiKeystringAGENTUITY_SDK_KEY env varAPI key for authentication
urlstringAuto-detected from regionBase URL for the Queue API
orgIdstring-Organization ID for multi-tenant operations (optional)
loggerLoggerMinimal loggerCustom logger instance

Database

Execute SQL queries and inspect table schemas on your Agentuity-managed database.

bun add @agentuity/db
import { DBClient } from '@agentuity/db';
 
const db = new DBClient({
  database: 'my-database',
  orgId: 'org_abc123',
});
 
// Execute a query
const result = await db.query('SELECT * FROM users LIMIT 10');
console.log(result.columns, result.rows);
 
// List tables
const tables = await db.tables();
 
// Get query logs
const logs = await db.logs({ limit: 50 });

Constructor options:

OptionTypeDefaultDescription
apiKeystringAGENTUITY_SDK_KEY env varAPI key for authentication
urlstringAuto-detected from regionBase URL for the DB API
databasestringRequiredDatabase name
orgIdstringRequiredOrganization ID
regionstringAGENTUITY_REGION or uscCloud region
loggerLoggerMinimal loggerCustom logger instance

Email

Send and receive emails using managed addresses with webhook-based inbound routing.

bun add @agentuity/email
import { EmailClient } from '@agentuity/email';
 
const email = new EmailClient();
 
// Create a managed email address
const address = await email.createAddress('support');
 
// Send an email
await email.send({
  from: address.address,
  to: 'user@example.com',
  subject: 'Welcome!',
  text: 'Thanks for signing up.',
});
 
// List inbound emails
const inbound = await email.listInbound(address.id);

Constructor options:

OptionTypeDefaultDescription
apiKeystringAGENTUITY_SDK_KEY env varAPI key for authentication
urlstringAuto-detected from regionBase URL for the Email API
orgIdstring-Organization ID for multi-tenant operations (optional)
loggerLoggerMinimal loggerCustom logger instance

Webhooks

Create webhook endpoints, route deliveries to destinations, and track receipts.

bun add @agentuity/webhook
import { WebhookClient } from '@agentuity/webhook';
 
const webhooks = new WebhookClient();
 
// Create a webhook endpoint
const result = await webhooks.create({ name: 'stripe-events' });
 
// Add a destination
await webhooks.createDestination(result.webhook.id, {
  type: 'url',
  config: { url: 'https://myapp.com/api/stripe' },
});
 
// List receipts
const receipts = await webhooks.listReceipts(result.webhook.id);

Constructor options:

OptionTypeDefaultDescription
apiKeystringAGENTUITY_SDK_KEY env varAPI key for authentication
urlstringAuto-detected from regionBase URL for the Webhook API
orgIdstring-Organization ID for multi-tenant operations (optional)
loggerLoggerMinimal loggerCustom logger instance

Schedules

Create cron-based scheduled jobs that deliver payloads to configured destinations.

bun add @agentuity/schedule
import { ScheduleClient } from '@agentuity/schedule';
 
const schedules = new ScheduleClient();
 
// Create a schedule (runs every hour)
const result = await schedules.create({
  name: 'hourly-sync',
  cron: '0 * * * *',
});
 
// List all schedules
const list = await schedules.list();
 
// Get a specific schedule
const details = await schedules.get(result.schedule.id);

Constructor options:

OptionTypeDefaultDescription
apiKeystringAGENTUITY_SDK_KEY env varAPI key for authentication
urlstringAuto-detected from regionBase URL for the Schedule API
orgIdstring-Organization ID for multi-tenant operations (optional)
loggerLoggerMinimal loggerCustom logger instance

Tasks

Track work items with comments, tags, attachments, and a full activity changelog.

bun add @agentuity/task
import { TaskClient } from '@agentuity/task';
 
const tasks = new TaskClient();
 
// Create a task
const task = await tasks.create({
  title: 'Fix login bug',
  type: 'bug',
  priority: 'high',
});
 
// Add a comment
await tasks.createComment(task.id, 'Reproduced on Chrome 120', 'user_abc');
 
// Tag it
const tag = await tasks.createTag('urgent', '#ff0000');
await tasks.addTagToTask(task.id, tag.id);
 
// List all tasks
const list = await tasks.list({ status: 'open' });

Constructor options:

OptionTypeDefaultDescription
apiKeystringAGENTUITY_SDK_KEY env varAPI key for authentication
urlstringAuto-detected from regionBase URL for the Task API
orgIdstring-Organization ID for multi-tenant operations (optional)
loggerLoggerMinimal loggerCustom logger instance

Configuration

All standalone packages share the same configuration pattern. Set environment variables once, and every client picks them up automatically.

Environment Variables

VariableDescriptionDefault
AGENTUITY_SDK_KEYAPI key for authenticationRequired
AGENTUITY_REGIONRegion for API endpointsusc

Each service also supports a URL override variable for custom deployments:

VariableService
AGENTUITY_KEYVALUE_URLKey-Value Storage
AGENTUITY_VECTOR_URLVector Search
AGENTUITY_SANDBOX_URLSandbox
AGENTUITY_QUEUE_URLMessage Queues
AGENTUITY_DB_URLDatabase
AGENTUITY_EMAIL_URLEmail
AGENTUITY_WEBHOOK_URLWebhooks
AGENTUITY_SCHEDULE_URLSchedules
AGENTUITY_TASK_URLTasks

Shared Constructor Pattern

Every client follows the same constructor pattern:

import { KeyValueClient } from '@agentuity/keyvalue';
 
// Minimal: uses env vars for everything
const kv = new KeyValueClient();
 
// Explicit: override specific options
const kvCustom = new KeyValueClient({
  apiKey: 'agentuity_sk_...',
  orgId: 'org_abc123',
});

All constructor options are validated at initialization using Zod schemas. Invalid options throw immediately with descriptive error messages.