
Security News
Feross on TBPN: Socket's Series C and the State of Software Supply Chain Security
Feross Aboukhadijeh joins TBPN to discuss Socket's $60M Series C, 500%+ ARR growth, AI's impact on open source, and the rise in supply chain attacks.
@agentuity/runtime
Advanced tools
Server runtime for building Agentuity applications with Bun and Hono.
bun add @agentuity/runtime
@agentuity/runtime provides the server-side runtime for Agentuity applications. Built on Hono and optimized for Bun, it enables you to create type-safe agents with automatic routing, validation, and observability.
import { createApp } from '@agentuity/runtime';
const { app, server, logger } = createApp();
// Start the server
server.listen(3000);
logger.info('Server running on http://localhost:3000');
import { type AgentContext, createAgent } from '@agentuity/runtime';
import { z } from 'zod';
const agent = createAgent({
schema: {
input: z.object({
message: z.string(),
}),
output: z.object({
response: z.string(),
}),
},
handler: async (ctx: AgentContext, input) => {
ctx.logger.info('Processing message:', input.message);
return { response: `You said: ${input.message}` };
},
});
export default agent;
import { createRouter } from '@agentuity/runtime';
const router = createRouter();
router.get('/hello', (c) => {
return c.json({ message: 'Hello, world!' });
});
router.post('/data', async (c) => {
const body = await c.req.json();
return c.json({ received: body });
});
export default router;
router.stream('/events', async (c) => {
return new ReadableStream({
start(controller) {
controller.enqueue('Event 1\n');
controller.enqueue('Event 2\n');
controller.close();
},
});
});
router.websocket('/chat', (c) => (ws) => {
ws.onOpen(() => {
console.log('Client connected');
});
ws.onMessage((event) => {
const data = JSON.parse(event.data);
ws.send(JSON.stringify({ echo: data }));
});
ws.onClose(() => {
console.log('Client disconnected');
});
});
router.sse('/updates', (c) => async (stream) => {
for (let i = 0; i < 10; i++) {
await stream.writeSSE({
data: JSON.stringify({ count: i }),
event: 'update',
});
await stream.sleep(1000);
}
});
Creates a new Agentuity application instance.
Returns:
app - Hono application instanceserver - Server instance with listen() methodlogger - Structured loggerCreates a type-safe agent with input/output validation.
Config:
schema.input? - Schema for input validation (Zod, Valibot, etc.)schema.output? - Schema for output validationhandler - Agent handler function (ctx: AgentContext, input) => outputCreates a new router for defining custom API routes.
Methods:
get/post/put/delete/patch - HTTP method handlersstream(path, handler) - Streaming response handlerwebsocket(path, handler) - WebSocket handlersse(path, handler) - Server-Sent Events handlerContext object available in agent handlers:
interface AgentContext {
logger: Logger; // Structured logger
tracer: Tracer; // OpenTelemetry tracer
sessionId: string; // Unique session ID
kv: KeyValueStorage; // Key-value storage
objectstore: ObjectStorage; // Object storage
stream: StreamStorage; // Stream storage
vector: VectorStorage; // Vector storage
agent: AgentRegistry; // Access to other agents
waitUntil: (promise) => void; // Defer cleanup tasks
}
Agentuity provides built-in storage abstractions:
Access these via the agent context:
const agent = createAgent({
schema: {
output: z.object({ value: z.string().optional() }),
},
handler: async (ctx, input) => {
await ctx.kv.set('key', 'value');
const value = await ctx.kv.get('key');
return { value };
},
});
Built-in OpenTelemetry support for logging, tracing, and metrics:
const agent = createAgent({
schema: {
output: z.object({ success: z.boolean() }),
},
handler: async (ctx, input) => {
ctx.logger.info('Processing request');
const span = ctx.tracer.startSpan('custom-operation');
// ... do work ...
span.end();
return { success: true };
},
});
Fully typed with TypeScript. Input and output types are automatically inferred from your schemas.
MIT
FAQs
Unknown package
The npm package @agentuity/runtime receives a total of 1,213 weekly downloads. As such, @agentuity/runtime popularity was classified as popular.
We found that @agentuity/runtime demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Feross Aboukhadijeh joins TBPN to discuss Socket's $60M Series C, 500%+ ARR growth, AI's impact on open source, and the rise in supply chain attacks.

Security News
OSV withdrew 157 OSV malware reports after automated false positives incorrectly flagged trusted npm and PyPI packages, sending bad records into tools that rely on OSV data.

Research
/Security News
TrapDoor crypto stealer hits 36 malicious packages across npm, PyPI, and Crates.io, targeting crypto, DeFi, AI, and security developers.