Agent Service skills
npx claudepluginhub hhopkins95/agent-runtimeSkills and patterns for creating apps that use the agent service
A flexible, framework-agnostic runtime for orchestrating AI agents (Claude, Gemini) in isolated sandboxes with real-time streaming support.
This repository contains two npm packages that work together to provide a complete agent orchestration solution:
npm install @hhopkins/agent-runtime
# or
pnpm add @hhopkins/agent-runtime
npm install @hhopkins/agent-runtime-react
# or
pnpm add @hhopkins/agent-runtime-react
The runtime requires you to provide adapters for persistence and configuration:
import { AgentRuntime } from '@hhopkins/agent-runtime';
import type { PersistenceAdapter, RuntimeConfig } from '@hhopkins/agent-runtime/types';
// Implement your persistence adapter
const persistenceAdapter: PersistenceAdapter = {
async listAllSessions() { /* ... */ },
async loadSession(sessionId) { /* ... */ },
async createSessionRecord(data) { /* ... */ },
async updateSession(sessionId, updates) { /* ... */ },
// ... other methods
};
// Configure the runtime
const config: RuntimeConfig = {
modal: {
tokenId: process.env.MODAL_TOKEN_ID,
tokenSecret: process.env.MODAL_TOKEN_SECRET,
},
anthropicApiKey: process.env.ANTHROPIC_API_KEY,
persistence: persistenceAdapter,
port: 3000,
};
// Start the runtime
const runtime = new AgentRuntime(config);
await runtime.start();
See backend/README.md for detailed runtime documentation.
Use the React hooks to connect to your runtime:
import { AgentServiceProvider, useAgentSession, useMessages } from '@hhopkins/agent-runtime-react';
function App() {
return (
<AgentServiceProvider config={{
apiUrl: 'http://localhost:3000',
wsUrl: 'ws://localhost:3000',
apiKey: 'your-api-key',
}}>
<AgentChat />
</AgentServiceProvider>
);
}
function AgentChat() {
const { session, createSession, sendMessage } = useAgentSession();
const { messages } = useMessages(session?.sessionId);
// Build your UI...
}
See client/README.md for detailed React hooks documentation.
┌─────────────────────────────────────────┐
│ Your Application │
│ (React, Next.js, Express, etc.) │
└────────────┬────────────────────────────┘
│
│ HTTP/WebSocket
↓
┌─────────────────────────────────────────┐
│ @hhopkins/agent-runtime (Backend) │
│ • Session management │
│ • WebSocket streaming │
│ • Adapter integration │
└────────────┬────────────────────────────┘
│
├──→ Modal Sandboxes (Agent execution)
├──→ Your Persistence Layer (via adapter)
└──→ Your Custom Logic (via adapters)
This library is a runtime and client, not a complete service. Your application must provide:
PersistenceAdapter for your database (Convex, PostgreSQL, MongoDB, etc.)See the backend README for a complete guide on implementing adapters.
agent-service/
├── backend/ # @hhopkins/agent-runtime
│ ├── src/
│ │ ├── core/ # Session management, event bus
│ │ ├── types/ # Shared type definitions
│ │ ├── transport/ # HTTP + WebSocket servers
│ │ └── lib/ # Agent architectures, utilities
│ └── sandbox/ # Modal sandbox configuration
│
├── client/ # @hhopkins/agent-runtime-react
│ ├── src/
│ │ ├── hooks/ # React hooks (useAgentSession, etc.)
│ │ ├── context/ # Provider and state management
│ │ └── client/ # REST + WebSocket clients
│ └── dist/ # Built output
│
└── README.md # This file