Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,33 @@ class Server {

// Route: /tools, /health, /call
if (url === '/tools' && req.method === 'GET') {
result = this._router ? await sandbox.execute(() => this._router.handle('tools/list', {}), {type: 'read'}) : { tools: [] };
if (this._router) {
result = await sandbox.execute(() => this._router.handle('tools/list', {}), {type: 'read'});
} else {
// Fallback: use vant getTools()
try {
const vant = require('./vant');
result = { tools: vant.getTools() };
} catch (e) {
result = { tools: [] };
}
}
} else if (url === '/health' && req.method === 'GET') {
result = { status: 'ok', uptime: this._startTime ? Date.now() - this._startTime : 0 };
} else if (url === '/call' && req.method === 'POST') {
const request = body ? JSON.parse(body) : {};
const opType = request.read ? 'read' : 'write';
result = this._router ? await sandbox.execute(() => this._router.handle(request.method, request.params), {type: opType}) : { error: 'No handler' };
if (this._router) {
result = await sandbox.execute(() => this._router.handle(request.method, request.params), {type: opType});
} else {
// Fallback: use vant executeTool
try {
const vant = require('./vant');
result = await vant.executeTool(request.method, request.params);
} catch (e) {
result = { error: 'Tool execution failed: ' + e.message };
}
}
} else if (this._router) {
const route = this._router.match(req.method, url);
if (route) {
Expand All @@ -517,9 +537,20 @@ class Server {
res.end(JSON.stringify({ error: 'Not Found' }));
return;
}
} else {
} else if (url === '/brain' || url === '/mcp' || url === '/islands') {
// Known status endpoints
res.writeHead(200);
res.end(JSON.stringify({ vant: 'running' }));
return;
} else {
// Unknown URL without router - return 404
res.writeHead(404);
res.end(JSON.stringify({ error: 'Not Found' }));
return;
}

if (result === undefined) {
return;
}

res.writeHead(200, { 'Content-Type': 'application/json' });
Expand Down
8 changes: 7 additions & 1 deletion lib/vant.js
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,13 @@ async function executeTool(toolName, args = {}) {
remember: () => remember(args.key, args.content),
act: () => act(args.operation, args.opts),
search: () => getSearch().queryBrain(args.query, args.opts),
brain: () => getBrain().get('brain', args.key, { userCtx: args.userCtx }),
brain: () => {
// Parse key as category/key (same as learn)
const parts = args.key.split('/');
const category = parts[0] || 'brain';
const fileKey = parts.slice(1).join('/') || 'default.md';
return getBrain().get(category, fileKey, { userCtx: args.userCtx || { anonymous: true } });
},
};

// Check built-in first
Expand Down
File renamed without changes.
Loading