Vant Agent OS API Reference.
Runtime
Initialize and manage the agent.
init(options)
Initialize the agent.
const runtime = require('vant').runtime;
const state = await runtime.init({
name: 'Vant', // Agent name
role: 'AI Agent' // Agent role
});
Returns: { id, name, role, session }
think(query, options)
Query brain for context.
const result = await runtime.think('who am I', {
topK: 10, // Max memories
maxTokens: 2000 // Max tokens
});
Returns: { query, triggers, insights, memories, tokens, agent }
learn(key, content)
Store new information to brain.
await runtime.learn('key', 'Content to remember');
Returns: { success, key }
remember(key, content?)
Remember across sessions.
// Store
await runtime.remember('key', 'content');
// Recall
const content = await runtime.remember('key');
act(operation, options)
Execute operation with locks.
const result = await runtime.act(() => {
return doSomething();
}, { timeout: 30000 });
Returns: { success, result, duration }
getTools()
Get available tools.
const tools = runtime.getTools();
// [{ name, description }, ...]
getState()
Get current agent state.
const state = runtime.getState();
// { id, name, role, uptime, ... }
getStatus()
Get system status.
const status = runtime.getStatus();
// { agent, version, enabled, ... }
Agents
Multi-agent runtime.
spawn(options)
Spawn a new agent.
const agents = require('vant').agents;
const agent = await agents.spawn({
name: 'Helper',
role: 'Assistant',
type: 'default'
});
Returns: { id, name, role }
fork()
Fork self for parallel work.
const forked = await agents.fork();
join(conversationId)
Join shared conversation.
const conv = agents.join('session-1');
conv.post('message', 'author');
const messages = conv.messages;
emit(event, data)
Emit signal to other agents.
agents.emit('taskComplete', { status: 'done' });
on(event, callback)
Listen for events.
agents.on('taskComplete', (data) => {
console.log(data.status);
});
list()
List all agents.
const all = agents.list();
// [{ id, name, role, state }, ...]
IPC
Inter-agent messaging.
send(channel, message)
Send message to channel.
const ipc = require('vant').ipc;
ipc.send('alerts', { text: 'Hello' });
subscribe(channel, handler)
Subscribe to channel.
ipc.subscribe('alerts', (msg) => {
console.log(msg.text);
});
messages(channel)
Get channel messages.
const msgs = ipc.messages('alerts');
Brain
Direct brain access.
get(key)
Get brain file.
const brain = require('vant').brain;
const data = await brain.get('identity');
// { key, content, date }
write(key, content)
Write brain file.
brain.write('key', '# Content');
append(key, content)
Append to brain file.
brain.append('key', 'More content');
has(key)
Check if brain file exists.
brain.has('identity'); // true/false
queryBrain(query, options)
Query brain using search.
const result = await brain.queryBrain('query', {
topK: 10,
maxTokens: 2000
});
Search
Query brain memories.
queryBrain(query, options)
Query brain for context.
const search = require('vant').search;
const result = await search.queryBrain('query', {
topK: 10,
maxTokens: 2000
});
// { memories, stats }
rerank(memories, query, topK)
Rank memories by relevance.
const ranked = search.rerank(memories, query, 10);
Islands
Intent detection and lazy-loading.
findTriggers(prompt)
Find islands matching prompt.
const islands = require('vant').islands;
const triggers = islands.findTriggers('create a github pr');
// ['github', 'linear']
autoHydrate(prompt)
Auto-load needed islands.
const data = islands.autoHydrate('create github pr');
getAvailable()
Get available islands.
const available = islands.getAvailable();
// ['identity', 'learnings', 'github', ...]
Config
Get configuration.
get(key)
Get config value.
const config = require('vant').config;
const port = config.get('server.port');
// 3100
githubToken()
Get GitHub token.
const token = config.githubToken();
Lock
Acquire/release locks.
acquire(agentId, timeout)
Acquire lock.
const lock = require('vant').lock;
lock.acquire('agent_123', 10000);
release(agentId)
Release lock.
lock.release('agent_123');
Audit
Logging and metrics.
log(entry)
Log entry.
const audit = require('vant').audit;
audit.log({ type: 'act', key: 'value' });
increment(metric)
Increment metric.
audit.increment('requests');
Errors
Error handling.
handle(error)
Handle error.
const errors = require('vant').errors;
errors.handle(new Error('msg'));