Getting Started
agentrunner provides language-native libraries for programmatically invoking AI coding agents. Each library implements a common Runner interface that lets you swap agents without changing your code.
Installation
sh
go get github.com/driangle/agentrunner/gosh
npm install @driangle/agentrunnersh
pip install driangle-agentrunnerEach library is versioned independently, so version numbers differ across languages. Release notes for each are on the GitHub releases page, tagged go/v*, ts/v* and python/v*.
Prerequisites
You need the CLI for whichever runner you plan to use:
| Runner | Requirement |
|---|---|
| Claude Code | claude CLI >= 2.1.0 |
| Ollama | Ollama server running at localhost:11434 |
Quick Example
go
package main
import (
"context"
"fmt"
"log"
"github.com/driangle/agentrunner/go/claudecode"
)
func main() {
runner := claudecode.NewRunner()
result, err := runner.Run(context.Background(), "What is 2+2?")
if err != nil {
log.Fatal(err)
}
fmt.Println(result.Text)
}ts
import { createClaudeRunner } from "@driangle/agentrunner/claudecode";
const runner = createClaudeRunner();
const result = await runner.run("What is 2+2?");
console.log(result.text);python
import asyncio
from agentrunner import ClaudeRunner
async def main():
runner = ClaudeRunner()
result = await runner.run("What is 2+2?")
print(result.text)
asyncio.run(main())Streaming
All runners support real-time message streaming:
go
session, err := runner.Start(ctx, "Explain this codebase")
if err != nil {
log.Fatal(err)
}
for msg := range session.Messages {
if text := msg.Text(); text != "" {
fmt.Print(text)
}
}
result, err := session.Result()ts
const session = runner.start("Explain this codebase");
for await (const msg of session.messages) {
const text = messageText(msg);
if (text) process.stdout.write(text);
}
const result = await session.result;python
session = runner.start("Explain this codebase")
async for msg in session:
if msg.text:
print(msg.text, end="")
result = await session.resultNext Steps
- Runner Interface — understand the common interface all runners share
- Channels — two-way communication with running agents
- Go Library — Go-specific API reference
- TypeScript Library — TypeScript-specific API reference
- Python Library — Python-specific API reference