@moldable-ai/ai-server
v0.1.5
Published
Local AI server for Moldable desktop
Readme
@moldable-ai/ai-server
Internal AI server that powers Moldable's desktop chat and gateway integrations.
Gateway endpoints
The gateway API accepts plain text messages from Moldable Gateway (Telegram/WhatsApp/etc.) and stores sessions separately from desktop conversations.
POST /api/gateway/chat
{
"sessionId": "agent:main:telegram:dm:123",
"messages": [{ "role": "user", "text": "hello", "timestamp": 1737811000 }],
"model": "anthropic/claude-3.7-sonnet",
"reasoningEffort": "medium",
"activeWorkspaceId": "personal",
"gateway": {
"channel": "telegram",
"peerId": "123",
"displayName": "alice",
"isGroup": false,
"agentId": "main",
"sessionKey": "agent:main:telegram:dm:123"
}
}Response:
{ "text": "assistant response", "sessionId": "agent:main:telegram:dm:123" }Session listing
GET /api/gateway/sessions?workspaceId=personalGET /api/gateway/sessions/:id?workspaceId=personalDELETE /api/gateway/sessions/:id?workspaceId=personal
Storage
- Shared sessions:
~/.moldable/shared/gateway-sessions/ - Workspace sessions:
~/.moldable/workspaces/{workspaceId}/gateway-sessions/
Notes
/api/chatremains the desktop app entry point for interactive chat sessions.- Gateway sessions are kept separate to avoid mixing UI history.
App LLM endpoints
Installed apps call the local AI server with their Moldable app id and app token.
POST /api/llm/completionreturns{ "text": "..." }for plain text output.POST /api/llm/streamstreams plain text output.POST /api/llm/generate-jsonaccepts a JSON Schema inschemaand returns{ "json": ... }from AI SDK structured generation.
Apps should define structured contracts with Zod when possible, convert them to JSON Schema at the HTTP boundary, and validate the returned object with the same Zod schema before acting on it.
