An experimental TypeScript agent loop with tools and an Ink terminal interface. It uses OpenRouter for model access, keeps conversation history during a session, streams responses and dispatches tool calls.
Requires Node.js 22.12 or newer, npm and a terminal. Shell tools use /bin/bash. Media-processing tasks may also need FFmpeg/ffprobe installed on your machine.
git clone https://github.com/DomBarker99/agent-harness.git
cd agent-harness
npm ci
cp .env.example .envEdit .env before running:
| Variable | Purpose |
|---|---|
OPENROUTER_API_KEY |
Required. Your OpenRouter API key. |
OPENROUTER_MODEL |
Required. A text model ID with tool-calling support that your account can access. Choose one from the OpenRouter model catalog. |
OPENROUTER_BASE_URL |
Optional. Defaults to https://openrouter.ai/api/v1. An explicit override applies to chat, model lookup, media-model discovery and media generation. Include the complete API base path when using a development proxy. |
BRAVE_SEARCH_API_KEY |
Optional. A Brave Search API key for the web_search tool. Without it, the tool tells the model it is not configured and sends no request. |
Model capabilities and prices vary. The .env file is ignored by Git, and values already set in your environment take precedence over that file.
Check configuration without sending an API request:
npm start -- --checknpm startThis opens the chat input and waits for your message. Type a prompt and press Enter. Press Ctrl+C to exit. An interactive terminal is required for this mode.
For a small first turn, try: Explain what an agent harness does in three sentences. Do not call any tools. This sends a model request and may incur charges, but does not ask the agent to modify files or generate media.
npm start -- --prompt "Explain what an agent harness does in three sentences. Do not call any tools."This uses the existing noninteractive terminal renderer and submits only the prompt you provide. It is not a JSON-output or stdin-pipeline interface. Empty prompts, unknown flags and non-terminal startup without --prompt fail with an actionable message.
npm start -- --helpHelp works without credentials.
The registry includes shell execution, system information, web search (when BRAVE_SEARCH_API_KEY is set) and experimental image/video tools. Shell commands run as your user from the harness's working directory. The harness is not a sandbox and does not ask for confirmation before each tool call. Use an appropriate scratch directory when trying tasks that can write files.
This is a learning prototype, not a production agent service. Session history is in memory. Media behavior and availability depend on the selected model/API.
npm run typecheck
npm testTests cover startup/configuration errors, offline help and configuration checks, a one-shot turn, media-model discovery against local mock HTTP servers and web-search credential handling against a stubbed fetch. The mocks verify the configured endpoint/model and exact supplied prompt without real credentials, paid model calls or generated media. Passing these checks does not establish live-provider or end-to-end media compatibility.
src/main.ts CLI startup and session-mode selection
src/config.ts argument parsing and shared OpenRouter configuration
src/TUI.tsx terminal UI
src/chatSession.ts session and conversation history
src/turnRunners.ts streamed responses and tool-call loop
src/tools/ shell, web search, system info and media tools
test/ offline startup and local mock-server checks