Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d11fcdb
feat: add durable token usage tracking
DorianZheng Apr 19, 2026
73772fa
chore: apply runtime test formatting
DorianZheng Apr 19, 2026
db7ca08
test: mock box runtime in usage action tests
DorianZheng Apr 19, 2026
693aa08
style: format usage action test
DorianZheng Apr 19, 2026
b95718f
fix: scope usage_get_summary to caller group; remove incorrect model …
DorianZheng Apr 23, 2026
d9613b1
fix: scope usage_get_summary to sourceGroup, fix resolveUsageModel fa…
DorianZheng Apr 24, 2026
e9c29bd
Fix token usage scoping and model attribution
DorianZheng Apr 24, 2026
23262a9
Fix test build prerequisites
DorianZheng Apr 24, 2026
44e6fb1
Merge main into token usage tracking
DorianZheng Apr 24, 2026
10e4634
Fix usage test path filtering
DorianZheng Apr 24, 2026
dd1c8b4
Fix npm test path pattern forwarding
DorianZheng Apr 24, 2026
bd3c3fe
fix: final CI fixes
DorianZheng Apr 24, 2026
3793d00
Fix usage model attribution fallback
DorianZheng Apr 24, 2026
5be9b5c
style: apply prettier formatting
DorianZheng Apr 24, 2026
c681edb
Use expected usage summary query args binding
DorianZheng Apr 24, 2026
184c15c
fix: final fixes for token usage tracking — scope + model attribution
DorianZheng Apr 24, 2026
90f1559
fix: scope usage_get_summary to sourceGroup + fix resolveUsageModel f…
DorianZheng Apr 24, 2026
2149b4e
fix: scope usage_get_summary to sourceGroup, remove bad resolveUsageM…
DorianZheng Apr 24, 2026
4e8124f
fix: BLOCKER 1 sourceGroup scoping + BLOCKER 2 resolveUsageModel fall…
DorianZheng Apr 24, 2026
db73290
fix: resolve usage model by highest token usage
DorianZheng Apr 24, 2026
83cc577
test: clarify usage source group scope
DorianZheng Apr 24, 2026
222df99
Fix token usage scoping and model attribution
DorianZheng Apr 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/skills/add-compact/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ git merge upstream/skill/compact
> **Note:** `upstream` is the remote pointing to `qwibitai/agentlite`. If using a different remote name, substitute accordingly.

This adds:

- `src/session-commands.ts` (extract and authorize session commands)
- `src/session-commands.test.ts` (unit tests for command parsing and auth)
- Session command interception in `src/orchestrator.ts` (both `processGroupMessages` and `startMessageLoop`)
Expand Down
6 changes: 6 additions & 0 deletions .claude/skills/add-discord/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ git merge discord/main || {
```

This merges in:

- `src/channels/discord.ts` (DiscordChannel class with self-registration via `registerChannel`)
- `src/channels/discord.test.ts` (unit tests with discord.js mock)
- `import './discord.js'` appended to the channel barrel file `src/channels/index.ts`
Expand Down Expand Up @@ -151,6 +152,7 @@ npx tsx setup/index.ts --step register -- --jid "dc:<channel-id>" --name "<serve
Tell the user:

> Send a message in your registered Discord channel:
>
> - For main channel: Any message works
> - For non-main: @mention the bot in Discord
>
Expand All @@ -175,12 +177,14 @@ tail -f logs/agentlite.log
### Bot only responds to @mentions

This is the default behavior for non-main channels (`requiresTrigger: true`). To change:

- Update the registered group's `requiresTrigger` to `false`
- Or register the channel as the main channel

### Message Content Intent not enabled

If the bot connects but can't read messages, ensure:

1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
2. Select your application > **Bot** tab
3. Under **Privileged Gateway Intents**, enable **Message Content Intent**
Expand All @@ -189,12 +193,14 @@ If the bot connects but can't read messages, ensure:
### Getting Channel ID

If you can't copy the channel ID:

- Ensure **Developer Mode** is enabled: User Settings > Advanced > Developer Mode
- Right-click the channel name in the server sidebar > Copy Channel ID

## After Setup

The Discord bot supports:

- Text messages in registered channels
- Attachment descriptions (images, videos, files shown as placeholders)
- Reply context (shows who the user is replying to)
Expand Down
1 change: 1 addition & 0 deletions .claude/skills/add-gmail/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ git merge gmail/main || {
```

This merges in:

- `src/channels/gmail.ts` (GmailChannel class with self-registration via `registerChannel`)
- `src/channels/gmail.test.ts` (unit tests)
- `import './gmail.js'` appended to the channel barrel file `src/channels/index.ts`
Expand Down
3 changes: 3 additions & 0 deletions .claude/skills/add-image-vision/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ git merge whatsapp/skill/image-vision || {
```

This merges in:

- `src/image.ts` (image download, resize via sharp, base64 encoding)
- `src/image.test.ts` (8 unit tests)
- Image attachment handling in `src/channels/whatsapp.ts`
Expand All @@ -62,11 +63,13 @@ All tests must pass and build must be clean before proceeding.
## Phase 3: Configure

1. Rebuild the container (agent-runner changes need a rebuild):

```bash
./container/build.sh
```

2. Sync agent-runner source to group caches:

```bash
for dir in data/sessions/*/agent-runner-src/; do
cp container/agent-runner/src/*.ts "$dir"
Expand Down
4 changes: 4 additions & 0 deletions .claude/skills/add-ollama-tool/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description: Add Ollama MCP server so the container agent can call local models
This skill adds a stdio-based MCP server that exposes local Ollama models as tools for the container agent. Claude remains the orchestrator but can offload work to local models.

Tools added:

- `ollama_list_models` — lists installed Ollama models
- `ollama_generate` — sends a prompt to a specified model and returns the response

Expand Down Expand Up @@ -59,6 +60,7 @@ git merge upstream/skill/ollama-tool
```

This merges in:

- `container/agent-runner/src/ollama-mcp-stdio.ts` (Ollama MCP server)
- `scripts/ollama-watch.sh` (macOS notification watcher)
- Ollama MCP config in `container/agent-runner/src/index.ts` (allowedTools + mcpServers)
Expand Down Expand Up @@ -129,6 +131,7 @@ tail -f logs/agentlite.log | grep -i ollama
```

Look for:

- `Agent output: ... Ollama ...` — agent used Ollama successfully
- `[OLLAMA] >>> Generating` — generation started (if log surfacing works)
- `[OLLAMA] <<< Done` — generation completed
Expand All @@ -138,6 +141,7 @@ Look for:
### Agent says "Ollama is not installed"

The agent is trying to run `ollama` CLI inside the container instead of using the MCP tools. This means:

1. The MCP server wasn't registered — check `container/agent-runner/src/index.ts` has the `ollama` entry in `mcpServers`
2. The per-group source wasn't updated — re-copy files (see Phase 2)
3. The container wasn't rebuilt — run `./container/build.sh`
Expand Down
69 changes: 49 additions & 20 deletions .claude/skills/add-parallel/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Adds Parallel AI MCP integration to AgentLite for advanced web research capabili
## Prerequisites

User must have:

1. Parallel AI API key from https://platform.parallel.ai
2. AgentLite already set up and running
3. Docker installed and running
Expand All @@ -28,6 +29,7 @@ Collect it now.

**If they need one:**
Tell them:

> 1. Go to https://platform.parallel.ai
> 2. Sign up or log in
> 3. Navigate to API Keys section
Expand Down Expand Up @@ -58,6 +60,7 @@ fi
```

Verify:

```bash
grep "PARALLEL_API_KEY" .env | head -c 50
```
Expand All @@ -67,48 +70,56 @@ grep "PARALLEL_API_KEY" .env | head -c 50
Add `PARALLEL_API_KEY` to allowed environment variables in `src/container-runner.ts`:

Find the line:

```typescript
const allowedVars = ['CLAUDE_CODE_OAUTH_TOKEN', 'ANTHROPIC_API_KEY'];
```

Replace with:

```typescript
const allowedVars = ['CLAUDE_CODE_OAUTH_TOKEN', 'ANTHROPIC_API_KEY', 'PARALLEL_API_KEY'];
const allowedVars = [
'CLAUDE_CODE_OAUTH_TOKEN',
'ANTHROPIC_API_KEY',
'PARALLEL_API_KEY',
];
```

### 4. Configure MCP Servers in Agent Runner

Update `container/agent-runner/src/index.ts`:

Find the section where `mcpServers` is configured (around line 237-252):

```typescript
const mcpServers: Record<string, any> = {
agentlite: ipcMcp
agentlite: ipcMcp,
};
```

Add Parallel AI MCP servers after the agentlite server:

```typescript
const mcpServers: Record<string, any> = {
agentlite: ipcMcp
agentlite: ipcMcp,
};

// Add Parallel AI MCP servers if API key is available
const parallelApiKey = process.env.PARALLEL_API_KEY;
if (parallelApiKey) {
mcpServers['parallel-search'] = {
type: 'http', // REQUIRED: Must specify type for HTTP MCP servers
type: 'http', // REQUIRED: Must specify type for HTTP MCP servers
url: 'https://search-mcp.parallel.ai/mcp',
headers: {
'Authorization': `Bearer ${parallelApiKey}`
}
Authorization: `Bearer ${parallelApiKey}`,
},
};
mcpServers['parallel-task'] = {
type: 'http', // REQUIRED: Must specify type for HTTP MCP servers
type: 'http', // REQUIRED: Must specify type for HTTP MCP servers
url: 'https://task-mcp.parallel.ai/mcp',
headers: {
'Authorization': `Bearer ${parallelApiKey}`
}
Authorization: `Bearer ${parallelApiKey}`,
},
};
log('Parallel AI MCP servers configured');
} else {
Expand All @@ -117,6 +128,7 @@ if (parallelApiKey) {
```

Also update the `allowedTools` array to include Parallel MCP tools (around line 242-248):

```typescript
allowedTools: [
'Bash',
Expand All @@ -133,20 +145,24 @@ allowedTools: [
Add Parallel AI usage instructions to `groups/main/CLAUDE.md`:

Find the "## What You Can Do" section and add after the existing bullet points:

```markdown
- Use Parallel AI for web research and deep learning tasks
```

Then add a new section after "## What You Can Do":

```markdown
## Web Research Tools

You have access to two Parallel AI research tools:

### Quick Web Search (`mcp__parallel-search__search`)

**When to use:** Freely use for factual lookups, current events, definitions, recent information, or verifying facts.

**Examples:**

- "Who invented the transistor?"
- "What's the latest news about quantum computing?"
- "When was the UN founded?"
Expand All @@ -157,9 +173,11 @@ You have access to two Parallel AI research tools:
**Permission:** Not needed - use whenever it helps answer the question

### Deep Research (`mcp__parallel-task__create_task_run`)

**When to use:** Comprehensive analysis, learning about complex topics, comparing concepts, historical overviews, or structured research.

**Examples:**

- "Explain the development of quantum mechanics from 1900-1930"
- "Compare the literary styles of Hemingway and Faulkner"
- "Research the evolution of jazz from bebop to fusion"
Expand All @@ -171,28 +189,32 @@ You have access to two Parallel AI research tools:

**How to ask permission:**
```

AskUserQuestion: I can do deep research on [topic] using Parallel's Task API. This will take 2-5 minutes and provide comprehensive analysis with citations. Should I proceed?

```

**After permission - DO NOT BLOCK! Use scheduler instead:**

1. Create the task using `mcp__parallel-task__create_task_run`
2. Get the `run_id` from the response
3. Create a polling scheduled task using `mcp__agentlite__schedule_task`:
```
Prompt: "Check Parallel AI task run [run_id] and send results when ready.
```

Prompt: "Check Parallel AI task run [run_id] and send results when ready.

1. Use the Parallel Task MCP to check the task status
2. If status is 'completed', extract the results
3. Send results to user with mcp__agentlite__send_message
4. Use mcp__agentlite__complete_scheduled_task to mark this task as done
1. Use the Parallel Task MCP to check the task status
2. If status is 'completed', extract the results
3. Send results to user with mcp**agentlite**send_message
4. Use mcp**agentlite**complete_scheduled_task to mark this task as done

If status is still 'running' or 'pending', do nothing (task will run again in 30s).
If status is 'failed', send error message and complete the task."
If status is still 'running' or 'pending', do nothing (task will run again in 30s).
If status is 'failed', send error message and complete the task."

Schedule: interval every 30 seconds
Context mode: isolated
```
Schedule: interval every 30 seconds
Context mode: isolated

```
4. Send acknowledgment with tracking link
5. Exit immediately - scheduler handles the rest

Expand Down Expand Up @@ -223,6 +245,7 @@ Build the container with updated agent runner:
```

Verify the build:

```bash
echo '{}' | docker run -i --entrypoint /bin/echo agentlite-agent:latest "Container OK"
```
Expand All @@ -238,6 +261,7 @@ launchctl kickstart -k gui/$(id -u)/com.agentlite # macOS
```

Wait 3 seconds for service to start, then verify:

```bash
sleep 3
launchctl list | grep agentlite # macOS
Expand All @@ -247,6 +271,7 @@ launchctl list | grep agentlite # macOS
### 8. Test Integration

Tell the user to test:

> Send a message to your assistant: `@[YourAssistantName] what's the latest news about AI?`
>
> The assistant should use Parallel Search API to find current information.
Expand All @@ -256,6 +281,7 @@ Tell the user to test:
> The assistant should ask for permission before using the Task API.

Check logs to verify MCP servers loaded:

```bash
tail -20 logs/agentlite.log
```
Expand All @@ -265,16 +291,19 @@ Look for: `Parallel AI MCP servers configured`
## Troubleshooting

**Container hangs or times out:**

- Check that `type: 'http'` is specified in MCP server config
- Verify API key is correct in .env
- Check container logs: `cat groups/main/logs/container-*.log | tail -50`

**MCP servers not loading:**

- Ensure PARALLEL_API_KEY is in .env
- Verify container-runner.ts includes PARALLEL_API_KEY in allowedVars
- Check agent-runner logs for "Parallel AI MCP servers configured" message

**Task polling not working:**

- Verify scheduled task was created: `sqlite3 store/messages.db "SELECT * FROM scheduled_tasks"`
- Check task runs: `tail -f logs/agentlite.log | grep "scheduled task"`
- Ensure task prompt includes proper Parallel MCP tool names
Expand Down
3 changes: 3 additions & 0 deletions .claude/skills/add-pdf-reader/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ git merge whatsapp/skill/pdf-reader || {
```

This merges in:

- `container/skills/pdf-reader/SKILL.md` (agent-facing documentation)
- `container/skills/pdf-reader/pdf-reader` (CLI script)
- `poppler-utils` in `container/Dockerfile`
Expand Down Expand Up @@ -71,6 +72,7 @@ launchctl kickstart -k gui/$(id -u)/com.agentlite # macOS
### Test PDF extraction

Send a PDF file in any registered WhatsApp chat. The agent should:

1. Download the PDF to `attachments/`
2. Respond acknowledging the PDF
3. Be able to extract text when asked
Expand All @@ -86,6 +88,7 @@ tail -f logs/agentlite.log | grep -i pdf
```

Look for:

- `Downloaded PDF attachment` — successful download
- `Failed to download PDF attachment` — media download issue

Expand Down
3 changes: 3 additions & 0 deletions .claude/skills/add-reactions/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ git merge whatsapp/skill/reactions || {
```

This adds:

- `scripts/migrate-reactions.ts` (database migration for `reactions` table with composite PK and indexes)
- `src/status-tracker.ts` (forward-only emoji state machine for message lifecycle signaling, with persistence and retry)
- `src/status-tracker.test.ts` (unit tests for StatusTracker)
Expand Down Expand Up @@ -75,11 +76,13 @@ npm run build
```

Linux:

```bash
systemctl --user restart agentlite
```

macOS:

```bash
launchctl kickstart -k gui/$(id -u)/com.agentlite
```
Expand Down
Loading