File size: 2,984 Bytes
74c37a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60402f0
74c37a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# API Reference
Complete documentation for all public APIs

## Overview

This reference documents all public APIs in Donkey. Types and functions marked with `*` are exported.

## Core Modules

### Ports (Interfaces)

| Module | Description |
|--------|-------------|
| [hook](hook.md) | Hook system interface |
| [channel](channel.md) | Channel abstraction |
| [provider](provider.md) | LLM provider interface |
| [memory](memory.md) | Memory system interface |
| [tool](tool.md) | Tool abstraction |

### Core

| Module | Description |
|--------|-------------|
| [types](types.md) | Core types (UserId, SessionId...) |
| [session](session.md) | Session management |
| [orchestrator](orchestrator.md) | Message orchestration |

### Domain

| Module | Description |
|--------|-------------|
| [message](message.md) | Message types |
| [agent_message](agent_message.md) | Internal agent messages |
| [subagents](subagents.md) | Subagent policy, budgets and runtime |

### Commands

| Module | Description |
|--------|-------------|
| [command_routing](command_routing.md) | Command parsing and routing |
| [command_catalog](command_catalog.md) | Command metadata catalog |

## Adapters

### Channel Adapters

| Adapter | File | Description |
|---------|------|-------------|
| Telegram | `adapters/channel/telegram.nim` | Telegram Bot API |
| Discord | `adapters/channel/discord.nim` | Discord WebSocket |
| Slack | `adapters/channel/slack.nim` | Slack API |

### Provider Adapters

| Adapter | File | Description |
|---------|------|-------------|
| Anthropic | `adapters/provider/anthropic.nim` | Claude API |
| OpenAI | `adapters/provider/openai.nim` | GPT API |
| OpenRouter | `adapters/provider/openrouter.nim` | Multi-provider |
| Gemini | `adapters/provider/gemini.nim` | Google AI |

### Memory Adapters

| Adapter | File | Description |
|---------|------|-------------|
| MdFile | `adapters/memory/md_file.nim` | Markdown files |
| SQLite MAGMA | `adapters/memory/sqlite_magma_store.nim` | Default SQLite-first graph storage |
| Postgres | `adapters/memory/postgres.nim` | Optional PostgreSQL-backed MAGMA |

## Configuration

| Document | Description |
|----------|-------------|
| [Configuration](configuration.md) | Complete donkey.toml reference |
| [Types](types.md) | Configuration types |

## Examples

### Creating a Hook

```nim
import donkey/ports/hook

proc myHook*(ctx: HookContext): HookResult =
  # Process context
  var modified = ctx
  modified.metadata["processed"] = "true"
  newHookResultContinue(modified)

# Register hook
let definition = HookDefinition(
  name: "my_hook",
  phase: hpPreLlm,
  handler: myHook
)
executor.registerHook(definition)
```

### Using Memory

```nim
import donkey/adapters/memory/md_file

let memory = newMdFileAdapter("~/.donkey/paddocks")
let userDoc = memory.readUserDoc(userId, "MEMORY.md")
```

### Configuration Loading

```nim
import donkey/config/loader

let config = loadConfig("~/.config/donkey/donkey.toml").get()
```