common types, tools and utilities for llm interactions
Find a file
Michael Scherbakow ad24ee35c4 add timestamp tool
2026-02-15 05:39:28 +01:00
generate Converts generate function to an async generator 2026-02-14 14:35:09 +01:00
models Refactors generation result to use events 2026-02-14 02:58:34 +01:00
tools add timestamp tool 2026-02-15 05:39:28 +01:00
utils Initial commit 2026-02-13 22:46:39 +01:00
.gitignore Initial commit 2026-02-13 22:46:39 +01:00
bun.lock Initial commit 2026-02-13 22:46:39 +01:00
index.ts Initial commit 2026-02-13 22:46:39 +01:00
package.json Initial commit 2026-02-13 22:46:39 +01:00
README.md Initial commit 2026-02-13 22:46:39 +01:00
tsconfig.json Initial commit 2026-02-13 22:46:39 +01:00

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?) - from ANTHROPIC_API_KEY env var
  • getLMSClient(baseUrl?) - from LMSTUDIO_API_URL env var

Dependencies

  • zod - Schema validation
  • @anthropic-ai/sdk - Anthropic Claude SDK
  • @anthropic-ai/claude-agent-sdk - Claude Agent SDK
  • @lmstudio/sdk - LM Studio SDK