| generate | ||
| models | ||
| tools | ||
| utils | ||
| .gitignore | ||
| bun.lock | ||
| index.ts | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
llm-common
Shared library providing common types, tools, and utilities for LLM interactions. Serves as a foundation for agents to interact with different LLM backends (Claude via Anthropic SDK and LM Studio local models) with standardized abstractions for chat messages, tools, and generation results.
Structure
llm-common/
├── models/ # Data models and interfaces
├── tools/ # Tool implementations (file, memory, web)
├── utils/ # Utility functions
└── generate/ # Core generation logic and model clients
Tools
simpleFileTools(workfolder, readonly?)
Sandboxed file operations restricted to a work folder: file__view, file__list, file__write, file__delete, file__insert, file__str_replace.
webTools(allow, maxResponseSize?)
HTTP client with security allow/deny callback: web__fetch supporting GET/POST/PUT/PATCH/DELETE with custom headers and body.
memoryTools(memoryFile)
Persistent short-term agent memory (max 10 records): memory__add, memory__recall, memory__str_replace, memory__forget.
Generate
generate(modelId, chat, options) - Unified LLM generation function supporting both Claude (Anthropic SDK) and LM Studio backends.
Handles multi-turn conversations with automatic tool execution loops.
Model Clients
getAnthropicClient(apiKey?)- fromANTHROPIC_API_KEYenv vargetLMSClient(baseUrl?)- fromLMSTUDIO_API_URLenv var
Dependencies
zod- Schema validation@anthropic-ai/sdk- Anthropic Claude SDK@anthropic-ai/claude-agent-sdk- Claude Agent SDK@lmstudio/sdk- LM Studio SDK